SMatrixModule Module

A module for handling locally stored CSR matrices.



Contents


Interfaces

public interface ConstructEmptyMatrix

  • private pure subroutine ConstructEmptyMatrixSub_lsr(this, rows, columns, zero_in)

    A subroutine type wrapper for the constructor.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(inout) :: this

    The matrix to construct.

    integer, intent(in) :: rows

    The number of matrix rows.

    integer, intent(in) :: columns

    The number of matrix columns.

    logical, intent(in), optional :: zero_in

    Whether to set the matrix to zero.

  • private pure subroutine ConstructEmptyMatrixSub_lsc(this, rows, columns, zero_in)

    A subroutine type wrapper for the constructor.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(inout) :: this

    The matrix to construct.

    integer, intent(in) :: rows

    The number of matrix rows.

    integer, intent(in) :: columns

    The number of matrix columns.

    logical, intent(in), optional :: zero_in

    Whether to set the matrix to zero.

public interface ConstructMatrixFromFile

  • private subroutine ConstructMatrixFromFileSub_lsr(this, file_name)

    Subroutine wrapper for the construct from file function.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(inout) :: this

    The matrix being constructed.

    character(len=*), intent(in) :: file_name

    Name of the file.

  • private subroutine ConstructMatrixFromFileSub_lsc(this, file_name)

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(inout) :: this

    The matrix being constructed.

    character(len=*), intent(in) :: file_name

    Name of the file.

  • private pure subroutine ConstructMatrixFromTripletListSub_lsr(this, triplet_list, rows, columns)

    A subroutine wrapper for the triplet list based constructor.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(inout) :: this

    The matrix being constructed

    type(TripletList_r), intent(in) :: triplet_list

    A list of triplet values. They must be sorted.

    integer, intent(in) :: rows

    Number of matrix rows

    integer, intent(in) :: columns

    Number of matrix columns

  • private pure subroutine ConstructMatrixFromTripletListSub_lsc(this, triplet_list, rows, columns)

    A subroutine wrapper for the triplet list based constructor.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(inout) :: this

    The matrix being constructed

    type(TripletList_c), intent(in) :: triplet_list

    A list of triplet values. They must be sorted.

    integer, intent(in) :: rows

    Number of matrix rows

    integer, intent(in) :: columns

    Number of matrix columns

public interface DestructMatrix

  • private pure subroutine DestructMatrix_lsr(this)

    Explicitly destruct a sparse matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(inout) :: this

    The matrix to free up.

  • private pure subroutine DestructMatrix_lsc(this)

    Explicitly destruct a sparse matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(inout) :: this

    The matrix to free up.

public interface CopyMatrix

  • private pure subroutine CopyMatrix_lsr(matA, matB)

    Copy a sparse matrix in a safe way.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(in) :: matA

    Matrix to copy

    type(Matrix_lsr), intent(inout) :: matB

    matB = matA

  • private pure subroutine CopyMatrix_lsc(matA, matB)

    Copy a sparse matrix in a safe way.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(in) :: matA

    Matrix to copy

    type(Matrix_lsc), intent(inout) :: matB

    matB = matA

public interface GetMatrixRows

  • private pure function GetMatrixRows_lsr(this) result(rows)

    Get the number of rows of a matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(in) :: this

    The matrix.

    Return Value integer

    The number of rows.

  • private pure function GetMatrixRows_lsc(this) result(rows)

    Get the number of rows of a matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(in) :: this

    The matrix.

    Return Value integer

    The number of rows.

public interface GetMatrixColumns

  • private pure function GetMatrixColumns_lsr(this) result(columns)

    Get the number of columns of a matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(in) :: this

    Return Value integer

    The number of columns.

  • private pure function GetMatrixColumns_lsc(this) result(columns)

    Get the number of columns of a matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(in) :: this

    Return Value integer

    The number of columns.

public interface ExtractMatrixRow

  • private pure subroutine ExtractMatrixRow_lsr(this, row_number, row_out)

    Extract a row from the matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(in) :: this

    The matrix to extract from.

    integer, intent(in) :: row_number

    The row to extract.

    type(Matrix_lsr), intent(inout) :: row_out

    The matrix representing that row.

  • private pure subroutine ExtractMatrixRow_lsc(this, row_number, row_out)

    Extract a row from the matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(in) :: this

    The matrix to extract from.

    integer, intent(in) :: row_number

    The row to extract.

    type(Matrix_lsc), intent(inout) :: row_out

    The matrix representing that row.

public interface ExtractMatrixColumn

  • private pure subroutine ExtractMatrixColumn_lsr(this, column_number, column_out)

    Extract a column from the matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(in) :: this

    The matrix to extract from.

    integer, intent(in) :: column_number

    The column to extract.

    type(Matrix_lsr), intent(inout) :: column_out

    The column representing that row.

  • private pure subroutine ExtractMatrixColumn_lsc(this, column_number, column_out)

    Extract a column from the matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(in) :: this

    The matrix to extract from.

    integer, intent(in) :: column_number

    The column to extract.

    type(Matrix_lsc), intent(inout) :: column_out

    The column representing that row.

public interface SplitMatrix

  • private pure subroutine SplitMatrix_lsr(this, block_rows, block_columns, split_array, block_size_row_in, block_size_column_in)

    Split a sparse matrix into an array of sparse matrices.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(in) :: this

    The matrix to split.

    integer, intent(in) :: block_rows

    Number of rows to split the matrix into.

    integer, intent(in) :: block_columns

    Number of columns to split the matrix into.

    type(Matrix_lsr), intent(inout), DIMENSION(:,:) :: split_array

    A COLUMNxROW array for the output to go into.

    integer, intent(in), optional, DIMENSION(:) :: block_size_row_in

    Specifies the size of the rows.

    integer, intent(in), optional, DIMENSION(:) :: block_size_column_in

    Specifies the size of the columns.

  • private pure subroutine SplitMatrix_lsc(this, block_rows, block_columns, split_array, block_size_row_in, block_size_column_in)

    Split a sparse matrix into an array of sparse matrices.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(in) :: this

    The matrix to split.

    integer, intent(in) :: block_rows

    Number of rows to split the matrix into.

    integer, intent(in) :: block_columns

    Number of columns to split the matrix into.

    type(Matrix_lsc), intent(inout), DIMENSION(:,:) :: split_array

    A COLUMNxROW array for the output to go into.

    integer, intent(in), optional, DIMENSION(:) :: block_size_row_in

    Specifies the size of the rows.

    integer, intent(in), optional, DIMENSION(:) :: block_size_column_in

    Specifies the size of the columns.

public interface SplitMatrixColumns

  • private pure subroutine SplitMatrixColumns_lsr(this, num_blocks, block_sizes, split_list)

    Split a matrix into into small blocks based on the specified offsets.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(in) :: this

    This matrix to perform this operation on.

    integer, intent(in) :: num_blocks

    Number of blocks to split into.

    integer, intent(in), DIMENSION(num_blocks) :: block_sizes

    The sizes used for splitting.

    type(Matrix_lsr), intent(inout), DIMENSION(num_blocks) :: split_list

    1D array of blocks.

  • private pure subroutine SplitMatrixColumns_lsc(this, num_blocks, block_sizes, split_list)

    Split a matrix into into small blocks based on the specified offsets.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(in) :: this

    This matrix to perform this operation on.

    integer, intent(in) :: num_blocks

    Number of blocks to split into.

    integer, intent(in), DIMENSION(num_blocks) :: block_sizes

    The sizes used for splitting.

    type(Matrix_lsc), intent(inout), DIMENSION(num_blocks) :: split_list

    1D array of blocks.

public interface ComposeMatrix

  • private pure subroutine ComposeMatrix_lsr(mat_array, block_rows, block_columns, out_matrix)

    Create a big matrix from an array of matrices by putting them one next to another.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(in), DIMENSION(:, :) :: mat_array

    2d array of matrices to compose.

    integer, intent(in) :: block_rows

    The number of rows of the array of blocks.

    integer, intent(in) :: block_columns

    The number of columns of the array of blocks.

    type(Matrix_lsr), intent(inout) :: out_matrix

    The composed matrix.

  • private pure subroutine ComposeMatrix_lsc(mat_array, block_rows, block_columns, out_matrix)

    Create a big matrix from an array of matrices by putting them one next to another.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(in), DIMENSION(:, :) :: mat_array

    2d array of matrices to compose.

    integer, intent(in) :: block_rows

    The number of rows of the array of blocks.

    integer, intent(in) :: block_columns

    The number of columns of the array of blocks.

    type(Matrix_lsc), intent(inout) :: out_matrix

    The composed matrix.

public interface ComposeMatrixColumns

  • private pure subroutine ComposeMatrixColumns_lsr(mat_list, out_matrix)

    Create a big Matrix C = [Matrix 1 | Matrix 1, ...] where the columns of the first matrix are followed by the columns of the matrices in the list.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(in), DIMENSION(:) :: mat_list

    A list of matrices to compose.

    type(Matrix_lsr), intent(inout) :: out_matrix

    out_matrix = [Matrix 1 | Matrix 2, ...].

  • private pure subroutine ComposeMatrixColumns_lsc(mat_list, out_matrix)

    Create a big Matrix C = [Matrix 1 | Matrix 1, ...] where the columns of the first matrix are followed by the columns of the matrices in the list.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(in), DIMENSION(:) :: mat_list

    A list of matrices to compose.

    type(Matrix_lsc), intent(inout) :: out_matrix

    out_matrix = [Matrix 1 | Matrix 2, ...].

public interface TransposeMatrix

  • private pure subroutine TransposeMatrix_lsr(this, matT)

    Transpose a sparse matrix and return it in a separate matrix. The current implementation has you go from matrix to triplet list, triplet list to transposed triplet list. The triplet list must then be sorted and then the return matrix is constructed.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(in) :: this

    The matrix to be transposed.

    type(Matrix_lsr), intent(inout) :: matT

    The input matrix transposed.

  • private pure subroutine TransposeMatrix_lsc(this, matT)

    Transpose a sparse matrix and return it in a separate matrix. The current implementation has you go from matrix to triplet list, triplet list to transposed triplet list. The triplet list must then be sorted and then the return matrix is constructed.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(in) :: this

    The matrix to be transposed.

    type(Matrix_lsc), intent(inout) :: matT

    The input matrix transposed.

public interface ConjugateMatrix

  • private pure subroutine ConjugateMatrix_lsc(this)

    Every value in the matrix is changed into its complex conjugate.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(inout) :: this

    The matrix to compute the complex conjugate of.

public interface PrintMatrix

  • private subroutine PrintMatrix_lsr(this, file_name_in)

    Print out a sparse matrix to the console.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(in) :: this

    The matrix to be printed.

    character(len=*), intent(in), optional :: file_name_in

    Optionally you can pass a file to print to.

  • private subroutine PrintMatrix_lsc(this, file_name_in)

    Print out a sparse matrix to the console.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(in) :: this

    The matrix to be printed.

    character(len=*), intent(in), optional :: file_name_in

    Optionally you can pass a file to print to.

public interface MatrixToTripletList

  • private pure subroutine MatrixToTripletList_lsr(this, triplet_list)

    Construct a triplet list from a matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(in) :: this

    The matrix to construct the triplet list from.

    type(TripletList_r), intent(inout) :: triplet_list

    The triplet list we created.

  • private pure subroutine MatrixToTripletList_lsc(this, triplet_list)

    Construct a triplet list from a matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(in) :: this

    The matrix to construct the triplet list from.

    type(TripletList_c), intent(inout) :: triplet_list

    The triplet list we created.

public interface ConvertMatrixType

  • private subroutine ConvertMatrixType_lsrtolsc(cin, rout)

    Convert a complex matrix to a real matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsc), intent(in) :: cin

    The starting matrix.

    type(Matrix_lsr), intent(inout) :: rout

    Real valued matrix.

  • private subroutine ConvertMatrixType_lsctolsr(rin, cout)

    Convert a real matrix to a complex matrix.

    Arguments

    Type IntentOptional Attributes Name
    type(Matrix_lsr), intent(in) :: rin

    The starting matrix.

    type(Matrix_lsc), intent(inout) :: cout

    The complex valued matrix.


Derived Types

type, public ::  Matrix_lsr

A datatype for storing a local, real CSR matrix.

Components

Type Visibility Attributes Name Initial
integer, public, DIMENSION(:), ALLOCATABLE :: outer_index

Outer indices

integer, public, DIMENSION(:), ALLOCATABLE :: inner_index

Inner indices

real(kind=NTREAL), public, DIMENSION(:), ALLOCATABLE :: values

Values

integer, public :: rows

Matrix dimension: rows

integer, public :: columns

Matrix dimension: columns

type, public ::  Matrix_lsc

A datatype for storing a local, complex CSR matrix.

Components

Type Visibility Attributes Name Initial
integer, public, DIMENSION(:), ALLOCATABLE :: outer_index

Outer indices

integer, public, DIMENSION(:), ALLOCATABLE :: inner_index

Inner indices

complex(kind=NTCOMPLEX), public, DIMENSION(:), ALLOCATABLE :: values

Values

integer, public :: rows

Matrix dimension: rows

integer, public :: columns

Matrix dimension: columns