matrix Derived Type

type, public :: matrix


Contents


Constructor

public interface matrix

Construct a matrix

  • private elemental function matrix_ctr_nk(n, k) result(A)

    Create a new -by- matrix by passing the number of rows and the number of columns

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n

    The number of rows in

    integer, intent(in) :: k

    The number of cols in

    Return Value type(matrix)

  • private elemental function matrix_ctr_nk_int(n, k, val) result(A)

    Create a new -by- matrix by passing the number of rows and the number of columns

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n

    The number of rows in

    integer, intent(in) :: k

    The number of cols in

    integer, intent(in) :: val

    Return Value type(matrix)

  • private elemental function matrix_ctr_nk_r32(n, k, val) result(A)

    Create a new -by- matrix by passing the number of rows and the number of columns

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n

    The number of rows in

    integer, intent(in) :: k

    The number of cols in

    real(kind=real32), intent(in) :: val

    Return Value type(matrix)

  • private elemental function matrix_ctr_nk_r64(n, k, val) result(A)

    Create a new -by- matrix by passing the number of rows and the number of columns

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in) :: n

    The number of rows in

    integer, intent(in) :: k

    The number of cols in

    real(kind=real64), intent(in) :: val

    Return Value type(matrix)

  • private pure function matrix_ctr_matrix(m2) result(A)

    Create a new -by- matrix by passing a rank2 integer array

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: m2

    Return Value type(matrix)

  • private pure function matrix_ctr_int(array) result(A)

    Create a new -by- matrix by passing a rank2 integer array

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in), dimension(:,:):: array

    Return Value type(matrix)

  • private pure function matrix_ctr_r32(array) result(A)

    Create a new -by- matrix by passing a rank2 integer array

    Arguments

    Type IntentOptional AttributesName
    real(kind=real32), intent(in), dimension(:,:):: array

    Return Value type(matrix)

  • private pure function matrix_ctr_r64(array) result(A)

    Create a new -by- matrix by passing a rank2 integer array

    Arguments

    Type IntentOptional AttributesName
    real(kind=real64), intent(in), dimension(:,:):: array

    Return Value type(matrix)

  • private pure function matrix_ctr_rank1_int(array, n, k) result(A)

    Construct a -by- given a rank1 array of ints

    Arguments

    Type IntentOptional AttributesName
    integer, intent(in), dimension(:):: array
    integer, intent(in) :: n
    integer, intent(in) :: k

    Return Value type(matrix)

  • private pure function matrix_ctr_rank1_r32(array, n, k) result(A)

    Construct a -by- given a rank1 array of ints

    Arguments

    Type IntentOptional AttributesName
    real(kind=real32), intent(in), dimension(:):: array
    integer, intent(in) :: n
    integer, intent(in) :: k

    Return Value type(matrix)

  • private pure function matrix_ctr_rank1_r64(array, n, k) result(A)

    Construct a -by- given a rank1 array of ints

    Arguments

    Type IntentOptional AttributesName
    real(kind=real64), intent(in), dimension(:):: array
    integer, intent(in) :: n
    integer, intent(in) :: k

    Return Value type(matrix)


Type-Bound Procedures

generic, public :: new => new_, new_matrix_

Create a new matrix

  • private elemental subroutine new_matrix(self, n, k)

    Wipe the contents of a matrix and allocate the proper amount of space

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self

    Matrix object to wipe

    integer, intent(in) :: n

    Dimension of each constituent vector

    integer, intent(in) :: k

    Number of vectors

  • private elemental subroutine new_matrix_from_matrix(self, m2)

    Wipe the contents of a matrix and allocate the proper amount of space

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self

    Matrix object to wipe

    class(matrix), intent(in) :: m2

    Matrix object to wipe

procedure, public :: clear => clear_matrix

Clear all of the elements of a matrix

  • private elemental subroutine clear_matrix(self)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self

procedure, public :: print => print_matrix

Print the contents of a matrix

  • private subroutine print_matrix(self)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self

procedure, public :: vec => access_vector_matrix

Get the kth vector in the matrix

  • private elemental function access_vector_matrix(self, v) result(vec)

    Get a copy of the vth vector

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self
    integer, intent(in) :: v

    Return Value type(vector)

procedure, public :: at => at_index_matrix

Get the element at the index (i, j)

  • private elemental function at_index_matrix(self, i, j) result(element)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self
    integer, intent(in) :: i

    ith element

    integer, intent(in) :: j

    jth vector

    Return Value real(kind=real64)

procedure, public :: gram_schmidt => gram_schmidt_matrix

Compute an otrthonormal basis for the vector space spanned by the columns of a matrix

  • private elemental function gram_schmidt_matrix(self) result(ortho)

    If there are more vectors than the dimension of the vector, only output n vectors

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self

    Return Value type(matrix)

procedure, public :: is_orthonormal => is_orthonormal_matrix

Check whether a matrix is orthonormal

  • private elemental function is_orthonormal_matrix(self) result(bool)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self

    Return Value logical

procedure, public :: as_array => matrix_as_array

Return a rank2 Fortran array

  • private pure function matrix_as_array(self) result(array)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self

    Return Value real(kind=real64), dimension(self%n, self%k)

procedure, public :: id => identity_matrix

  • private elemental function identity_matrix(self, n) result(I_n)

    Return

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self
    integer, optional value:: n

    Return Value type(matrix)

procedure, public :: ncol => matrix_ncol

Return the number of cols of A

  • private elemental function matrix_ncol(self) result(icol)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self

    Return Value integer

procedure, public :: nrow => matrix_nrow

Return the number of rows of A

  • private elemental function matrix_nrow(self) result(irow)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self

    Return Value integer

generic, public :: create_hh => create_hh_

  • private elemental function matrix_create_householder_matrix(normal) result(m)

    Arguments

    Type IntentOptional AttributesName
    class(vector), intent(in) :: normal

    A UNIT vector that is normal to a plane of rotation

    Return Value type(matrix)

generic, public :: fill => fill_int_, fill_r32_, fill_r64_

  • private elemental subroutine matrix_fill_int(self, val)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    integer, intent(in) :: val
  • private elemental subroutine matrix_fill_r32(self, val)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    real(kind=real32), intent(in) :: val
  • private elemental subroutine matrix_fill_r64(self, val)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    real(kind=real64), intent(in) :: val

generic, public :: set => set_int_, set_r32_, set_r64_

Set the value of (a_{i,j})

  • private elemental subroutine set_index_matrix_int(self, i, j, x)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    integer, intent(in) :: i

    ith element

    integer, intent(in) :: j

    jth vector

    integer, intent(in) :: x
  • private elemental subroutine set_index_matrix_r32(self, i, j, x)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    integer, intent(in) :: i

    ith element

    integer, intent(in) :: j

    jth vector

    real(kind=real32), intent(in) :: x
  • private elemental subroutine set_index_matrix_r64(self, i, j, x)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    integer, intent(in) :: i

    ith element

    integer, intent(in) :: j

    jth vector

    real(kind=real64), intent(in) :: x

generic, public :: assignment(=) => from_array_int_, from_array_r32_, from_array_r64_, from_matrix

Assign the contents of a matrix from a rank2 Fortran array

  • private pure subroutine matrix_from_rank2_array_int(self, array)

    Assign a matrix from a rank2 integer array

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    integer, intent(in), dimension(:,:):: array
  • private pure subroutine matrix_from_rank2_array_r32(self, array)

    Assign a matrix from a rank2 single precision real array

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    real(kind=real32), intent(in), dimension(:,:):: array
  • private pure subroutine matrix_from_rank2_array_r64(self, array)

    Assign a matrix from a rank2 double precision array

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    real(kind=real64), intent(in), dimension(:,:):: array
  • private elemental subroutine matrix_from_matrix(self, m)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    class(matrix), intent(in) :: m

procedure, public :: get_row => matrix_get_row

  • private elemental function matrix_get_row(self, i) result(row_i)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self
    integer, intent(in) :: i

    th row

    Return Value type(vector)

procedure, public :: get_col => matrix_get_col

  • private elemental function matrix_get_col(self, j) result(col_j)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self
    integer, intent(in) :: j

    th row

    Return Value type(vector)

generic, public :: set_row => set_row_int_, set_row_r32_, set_row_r64_, set_row_vec_

  • private pure subroutine matrix_set_row_array_int(self, i, array)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    integer, intent(in) :: i

    Row number

    integer, intent(in), dimension(:):: array
  • private pure subroutine matrix_set_row_array_r32(self, i, array)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    integer, intent(in) :: i

    Row number

    real(kind=real32), intent(in), dimension(:):: array
  • private pure subroutine matrix_set_row_array_r64(self, i, array)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    integer, intent(in) :: i

    Row number

    real(kind=real64), intent(in), dimension(:):: array
  • private elemental subroutine matrix_set_row_vec(self, i, vec)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    integer, intent(in) :: i

    Row number

    class(vector), intent(in) :: vec

generic, public :: set_col => set_col_int_, set_col_r32_, set_col_r64_, set_col_vec_

  • private pure subroutine matrix_set_col_array_int(self, j, array)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    integer, intent(in) :: j

    Column number

    integer, intent(in), dimension(:):: array
  • private pure subroutine matrix_set_col_array_r32(self, j, array)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    integer, intent(in) :: j

    Column number

    real(kind=real32), intent(in), dimension(:):: array
  • private pure subroutine matrix_set_col_array_r64(self, j, array)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    integer, intent(in) :: j

    Column number

    real(kind=real64), intent(in), dimension(:):: array
  • private elemental subroutine matrix_set_col_vec(self, j, vec)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    integer, intent(in) :: j

    Column number

    class(vector), intent(in) :: vec

generic, public :: operator(+) => add_matrix_

Operator interface to add two matrices

  • private elemental function matrix_add_matrix(self, m2) result(m3)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self
    class(matrix), intent(in) :: m2

    Return Value type(matrix)

generic, public :: operator(-) => minus_matrix_

Operator interface to subtract a matrix

  • private elemental function matrix_minus_matrix(self, m2) result(m3)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self
    class(matrix), intent(in) :: m2

    Return Value type(matrix)

generic, public :: operator(*) => times_matrix_, times_vector_

Operator interface to multiply two matrices

  • private elemental function matrix_times_matrix(self, m2) result(m3)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self
    class(matrix), intent(in) :: m2

    Return Value type(matrix)

  • private elemental function matrix_times_vector(self, v) result(v2)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self
    class(vector), intent(in) :: v

    Return Value type(vector)

generic, public :: operator(.o.) => hadamard_

  • private elemental function matrix_hadamard_matrix(self, m2) result(m3)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self
    class(matrix), intent(in) :: m2

    Return Value type(matrix)

generic, public :: operator(**) => to_the_n_

  • private elemental function matrix_to_the_n(self, n) result(m2)

    Raise a matrix to the nth power. Must be a square matrix

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(in) :: self
    integer, intent(in) :: n

    Return Value type(matrix)

generic, public :: plus => add_matrix_sub_

Subroutine interface to add two matrices

  • private elemental subroutine matrix_add_matrix_sub(self, m2)

    Subroutine interface to add two matrices

    Read more…

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    class(matrix), intent(in) :: m2

generic, public :: minus => minus_matrix_sub_

Subroutine interface to add two matrices

  • private elemental subroutine matrix_minus_matrix_sub(self, m2)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    class(matrix), intent(in) :: m2

generic, public :: times => times_int_sub_, times_r32_sub_, times_r64_sub_

  • private elemental subroutine matrix_times_int_sub(self, val)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    integer, intent(in) :: val
  • private elemental subroutine matrix_times_r32_sub(self, val)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    real(kind=real32), intent(in) :: val
  • private elemental subroutine matrix_times_r64_sub(self, val)

    Arguments

    Type IntentOptional AttributesName
    class(matrix), intent(inout) :: self
    real(kind=real64), intent(in) :: val