SMatrixModule Module

A module for handling locally stored CSR matrices.



Contents


Interfaces

public interface Matrix_lsr

  • private pure function ConstructEmptyMatrix_lsr(rows, columns, zero_in) result(this)

    Create a sparse matrix with a certain number of columns and rows. Will allocate storage for the outer values, nothing else unless you set zero_in to true.

    Arguments

    Type IntentOptional AttributesName
    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.

    Return Value type(Matrix_lsr)

    The matrix to construct.

  • private function ConstructMatrixFromFile_lsr(file_name) result(this)

    Create a sparse matrix by reading in a matrix market file.

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: file_name

    Name of the file.

    Return Value type(Matrix_lsr)

    The matrix being constructed.

  • private pure function ConstructMatrixFromTripletList_lsr(triplet_list, rows, columns) result(this)

    Construct a sparse matrix from a \b SORTED triplet list. The triplet list must be sorted to efficiently fill in the matrix. This constructor assumes \b you have already sorted the triplet list.

    Arguments

    Type IntentOptional AttributesName
    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

    Return Value type(Matrix_lsr)

    The matrix being constructed

public interface Matrix_lsc

  • private pure function ConstructEmptyMatrix_lsc(rows, columns, zero_in) result(this)

    Create a sparse matrix with a certain number of columns and rows. Will allocate storage for the outer values, nothing else unless you set zero_in to true.

    Arguments

    Type IntentOptional AttributesName
    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.

    Return Value type(Matrix_lsc)

    The matrix to construct.

  • private function ConstructMatrixFromFile_lsc(file_name) result(this)

    Create a sparse matrix by reading in a matrix market file.

    Arguments

    Type IntentOptional AttributesName
    character(len=*), intent(in) :: file_name

    Name of the file.

    Return Value type(Matrix_lsc)

    The matrix being constructed.

  • private pure function ConstructMatrixFromTripletList_lsc(triplet_list, rows, columns) result(this)

    Construct a sparse matrix from a \b SORTED triplet list. The triplet list must be sorted to efficiently fill in the matrix. This constructor assumes \b you have already sorted the triplet list.

    Arguments

    Type IntentOptional AttributesName
    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

    Return Value type(Matrix_lsc)

    The matrix being constructed

public interface ConstructEmptyMatrix

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

    A subroutine type wrapper for the constructor.

    Arguments

    Type IntentOptional AttributesName
    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 subroutine ConstructEmptyMatrixSub_lsc(this, rows, columns, zero_in)

    A subroutine type wrapper for the constructor.

    Arguments

    Type IntentOptional AttributesName
    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 AttributesName
    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 AttributesName
    type(Matrix_lsc), intent(inout) :: this

    The matrix being constructed.

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

    Name of the file.

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

    A subroutine wrapper for the triplet list based constructor.

    Arguments

    Type IntentOptional AttributesName
    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 subroutine ConstructMatrixFromTripletListSub_lsc(this, triplet_list, rows, columns)

    A subroutine wrapper for the triplet list based constructor.

    Arguments

    Type IntentOptional AttributesName
    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 subroutine DestructMatrix_lsr(this)

    Explicitly destruct a sparse matrix.

    Arguments

    Type IntentOptional AttributesName
    type(Matrix_lsr), intent(inout) :: this

    The matrix to free up.

  • private subroutine DestructMatrix_lsc(this)

    Explicitly destruct a sparse matrix.

    Arguments

    Type IntentOptional AttributesName
    type(Matrix_lsc), intent(inout) :: this

    The matrix to free up.

public interface CopyMatrix

  • private subroutine CopyMatrix_lsr(matA, matB)

    Copy a sparse matrix in a safe way.

    Arguments

    Type IntentOptional AttributesName
    type(Matrix_lsr), intent(in) :: matA

    Matrix to copy

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

    matB = matA

  • private subroutine CopyMatrix_lsc(matA, matB)

    Copy a sparse matrix in a safe way.

    Arguments

    Type IntentOptional AttributesName
    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 AttributesName
    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 AttributesName
    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 AttributesName
    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 AttributesName
    type(Matrix_lsc), intent(in) :: this

    Return Value integer

    The number of columns.

public interface ExtractMatrixRow

  • private subroutine ExtractMatrixRow_lsr(this, row_number, row_out)

    Extract a row from the matrix.

    Arguments

    Type IntentOptional AttributesName
    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 subroutine ExtractMatrixRow_lsc(this, row_number, row_out)

    Extract a row from the matrix.

    Arguments

    Type IntentOptional AttributesName
    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 subroutine ExtractMatrixColumn_lsr(this, column_number, column_out)

    Extract a column from the matrix.

    Arguments

    Type IntentOptional AttributesName
    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 subroutine ExtractMatrixColumn_lsc(this, column_number, column_out)

    Extract a column from the matrix.

    Arguments

    Type IntentOptional AttributesName
    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 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 AttributesName
    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 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 AttributesName
    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 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 AttributesName
    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 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 AttributesName
    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 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 AttributesName
    type(Matrix_lsr), intent(in), DIMENSION(block_rows,block_columns):: 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 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 AttributesName
    type(Matrix_lsc), intent(in), DIMENSION(block_rows,block_columns):: 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 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 AttributesName
    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 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 AttributesName
    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 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 AttributesName
    type(Matrix_lsr), intent(in) :: this

    The matrix to be transposed.

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

    The input matrix transposed.

  • private 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 AttributesName
    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 subroutine ConjugateMatrix_lsc(this)

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

    Arguments

    Type IntentOptional AttributesName
    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 AttributesName
    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 AttributesName
    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 subroutine MatrixToTripletList_lsr(this, triplet_list)

    Construct a triplet list from a matrix.

    Arguments

    Type IntentOptional AttributesName
    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 subroutine MatrixToTripletList_lsc(this, triplet_list)

    Construct a triplet list from a matrix.

    Arguments

    Type IntentOptional AttributesName
    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 AttributesName
    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 AttributesName
    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

TypeVisibility AttributesNameInitial
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

Constructor

private pure function ConstructEmptyMatrix_lsr(rows, columns, zero_in)

Create a sparse matrix with a certain number of columns and rows. Will allocate storage for the outer values, nothing else unless you set zero_in to true.

private function ConstructMatrixFromFile_lsr(file_name)

Create a sparse matrix by reading in a matrix market file.

private pure function ConstructMatrixFromTripletList_lsr(triplet_list, rows, columns)

Construct a sparse matrix from a \b SORTED triplet list. The triplet list must be sorted to efficiently fill in the matrix. This constructor assumes \b you have already sorted the triplet list.

type, public :: Matrix_lsc

A datatype for storing a local, complex CSR matrix.

Components

TypeVisibility AttributesNameInitial
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

Constructor

private pure function ConstructEmptyMatrix_lsc(rows, columns, zero_in)

Create a sparse matrix with a certain number of columns and rows. Will allocate storage for the outer values, nothing else unless you set zero_in to true.

private function ConstructMatrixFromFile_lsc(file_name)

Create a sparse matrix by reading in a matrix market file.

private pure function ConstructMatrixFromTripletList_lsc(triplet_list, rows, columns)

Construct a sparse matrix from a \b SORTED triplet list. The triplet list must be sorted to efficiently fill in the matrix. This constructor assumes \b you have already sorted the triplet list.