Module that contains the datastructure for a linked-list matrix representation.
General matrix type, represents the linked list implementation
Type | Visibility | Attributes | Name | Initial | |||
---|---|---|---|---|---|---|---|
integer, | public | :: | matrix_dim | dimension of the matrix, number of rows |
|||
type(row_t), | public, | allocatable | :: | rows(:) | array containing the various rows |
||
character, | private, | allocatable | :: | label | label to distinguish between different matrix instances |
procedure, public :: add_element | |
procedure, public :: set_label | |
procedure, public :: get_complex_element | |
procedure, public :: get_total_nb_elements | |
procedure, public :: get_label | |
procedure, public :: get_nb_diagonals | |
procedure, public :: copy | |
procedure, public :: delete_matrix |
Constructor for a new matrix matrix with a given number of rows. Allocates and initialises the matrix datatype.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | nb_rows | number of rows in the matrix |
||
character, | intent(in), | optional | :: | label | label of the matrix |
matrix datatype with rows/columns in a linked list
Checks if a given element is valid in order to add it to the matrix.
Returns .true.
if the element is of type real or complex, .false.
otherwise.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(*), | intent(in) | :: | element | Matrix element that is to be added |
Checks if a given index is valid for the current matrix datastructure.
Returns .true.
if the index (either row or column) is larger than 0 and
smaller than the dimension of the matrix. Returns .false.
otherwise.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(matrix_t), | intent(in) | :: | matrix | matrix datastructure object |
||
integer, | intent(in) | :: | index | index to check |
Returns the complex element associated with the linked-list node at position (row, column) in the matrix datastructure. Non-existing nodes correspond to zero values, so when a node at (row, column) is not foudn this function returns (complex) zero.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(matrix_t), | intent(in) | :: | this | type instance |
||
integer, | intent(in) | :: | row | row position of the needed element |
||
integer, | intent(in) | :: | column | column position of the needed element |
the element at position (row, column) in the matrix
Returns the total number of elements (nodes) across the various rows.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(matrix_t), | intent(in) | :: | this | type instance |
total number of (non-zero) elements in this matrix
Returns the current label.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(matrix_t), | intent(in) | :: | this | type instance |
current matrix label
Dedicated function to copy a matrix structure into a new matrix structure. The datastructure contains pointers, such that simply setting matrix1 = matrix2 may result in pointer target losses (and wrong results).
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(matrix_t), | intent(in) | :: | matrix_in | the original matrix |
copy from the original matrix
Adds a given element at a certain (row, column) position to the matrix datastructure. Elements that are zero are not added, sanity checks are done on the row and column indices.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(matrix_t), | intent(inout) | :: | this | type instance |
||
integer, | intent(in) | :: | row | row position of the element |
||
integer, | intent(in) | :: | column | column position of the element |
||
class(*), | intent(in) | :: | element | polymorphic variable to add to the matrix |
Sets the label of the current matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(matrix_t), | intent(inout) | :: | this | type instance |
||
character(len=*), | intent(in) | :: | label | label to set |
Subroutine to get the number of super- and sub-diagonals in the matrix.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(matrix_t), | intent(in) | :: | this | type instance |
||
integer, | intent(out) | :: | ku | number of superdiagonals |
||
integer, | intent(out) | :: | kl | number of subdiagonals |
Deallocates the matrix datastructure, nullifies all corresponding pointers and deallocates the various nodes in the rows.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(matrix_t), | intent(inout) | :: | this |