DMatrixModule Module

This module allows one to convert a sparse matrix to a dense matrix. It also



Contents


Interfaces

public interface Matrix_ldr

  • private pure function ConstructEmptyMatrix_ldr(rows, columns) result(this)

    Construct an empty dense matrix with a set number of rows and columns

    Arguments

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

    Rows of the matrix

    integer, intent(in) :: columns

    Columns of the matrix.

    Return Value type(Matrix_ldr)

    The matrix to construct.

public interface Matrix_ldc

  • private pure function ConstructEmptyMatrix_ldc(rows, columns) result(this)

    Construct an empty dense matrix with a set number of rows and columns

    Arguments

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

    Rows of the matrix

    integer, intent(in) :: columns

    Columns of the matrix.

    Return Value type(Matrix_ldc)

    The matrix to construct.

public interface ConstructEmptyMatrix

  • private subroutine ConstructEmptyMatrixSup_ldr(this, rows, columns)

    A subroutine wrapper for the empty constructor.

    Arguments

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

    The matrix to construct

    integer, intent(in) :: rows

    Rows of the matrix

    integer, intent(in) :: columns

    Columns of the matrix

  • private subroutine ConstructEmptyMatrixSup_ldc(this, rows, columns)

    A subroutine style wrapper for the constructor.

    Arguments

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

    The matrix to construct.

    integer, intent(in) :: rows

    The number of rows of the matrix.

    integer, intent(in) :: columns

    The number of columns o the matrix.

public interface ConstructMatrixDFromS

  • private subroutine ConstructMatrixDFromS_ldr(sparse_matrix, dense_matrix)

    A function that converts a sparse matrix to a dense matrix.

    Arguments

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

    The sparse matrix to convert.

    type(Matrix_ldr), intent(inout) :: dense_matrix

    Output. Must be preallocated.

  • private subroutine ConstructMatrixDFromS_ldc(sparse_matrix, dense_matrix)

    A function that converts a sparse matrix to a dense matrix.

    Arguments

    Type IntentOptional AttributesName
    type(Matrix_lsc), intent(in) :: sparse_matrix

    The sparse matrix to convert.

    type(Matrix_ldc), intent(inout) :: dense_matrix

    Dense matrix output. Must be preallocated.

public interface ConstructMatrixSFromD

  • private subroutine ConstructMatrixSFromD_ldr(dense_matrix, sparse_matrix, threshold_in)

    A function that converts a dense matrix to a sparse matrix.

    Arguments

    Type IntentOptional AttributesName
    type(Matrix_ldr), intent(in) :: dense_matrix

    Matrix to convert.

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

    Output matrix.

    real(kind=NTREAL), intent(in), optional :: threshold_in

    Value for pruning values to zero.

  • private subroutine ConstructMatrixSFromD_ldc(dense_matrix, sparse_matrix, threshold_in)

    A function that converts a dense matrix to a sparse matrix.

    Arguments

    Type IntentOptional AttributesName
    type(Matrix_ldc), intent(in) :: dense_matrix

    The matrix to convert.

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

    The sparse output matrix.

    real(kind=NTREAL), intent(in), optional :: threshold_in

    Value for pruning values to zero.

public interface CopyMatrix

  • private subroutine CopyMatrix_ldr(matA, matB)

    Copy the matrix A into the B.

    Arguments

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

    The matrix to copy.

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

    matB = matA

  • private subroutine CopyMatrix_ldc(matA, matB)

    Copy the matrix A into the B.

    Arguments

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

    The matrix to copy.

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

    matB = matA

public interface DestructMatrix

  • private subroutine DestructMatrix_ldr(this)

    Deallocate the memory associated with this matrix.

    Arguments

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

    The matrix to delete.

  • private subroutine DestructMatrix_ldc(this)

    Deallocate the memory associated with this matrix.

    Arguments

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

    This the matrix to delete.

public interface SplitMatrix

  • private subroutine SplitMatrix_ldr(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_ldr), 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_ldr), intent(inout), DIMENSION(:,:):: split_array

    A block_columns x block_rows 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_ldc(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_ldc), 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_ldc), 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 ComposeMatrix

  • private subroutine ComposeMatrix_ldr(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_ldr), 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_ldr), intent(inout) :: out_matrix

    The composed matrix.

  • private subroutine ComposeMatrix_ldc(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_ldc), 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_ldc), intent(inout) :: out_matrix

    The composed matrix.

public interface MatrixNorm

  • private function MatrixNorm_ldr(this) result(norm)

    Compute the norm of a dense matrix. Computes the Frobenius norm.

    Arguments

    Type IntentOptional AttributesName
    type(Matrix_ldr), intent(in) :: this

    The matrix to compute the norm of.

    Return Value real(kind=NTREAL)

    The norm of the matrix.

  • private function MatrixNorm_ldc(this) result(norm)

    Compute the norm of a dense matrix. Computes the Frobenius norm.

    Arguments

    Type IntentOptional AttributesName
    type(Matrix_ldc), intent(in) :: this

    The matrix to compute the norm of.

    Return Value real(kind=NTREAL)

    The norm of the matrix.

public interface IncrementMatrix

  • private subroutine IncrementMatrix_ldr(MatA, MatB, alpha_in)

    AXPY for dense matrices. B = B + alpha*A

    Arguments

    Type IntentOptional AttributesName
    type(Matrix_ldr), intent(in) :: MatA

    MatA is added

    type(Matrix_ldr), intent(inout) :: MatB

    MatB is incremented.

    real(kind=NTREAL), intent(in), optional :: alpha_in

    A scaling parameter.

  • private subroutine IncrementMatrix_ldc(MatA, MatB, alpha_in)

    AXPY for dense matrices. B = B + alpha*A

    Arguments

    Type IntentOptional AttributesName
    type(Matrix_ldc), intent(in) :: MatA

    MatA is added

    type(Matrix_ldc), intent(inout) :: MatB

    MatB is incremented.

    real(kind=NTREAL), intent(in), optional :: alpha_in

    A scaling parameter.

public interface MultiplyMatrix

  • private subroutine MultiplyMatrix_ldr(MatA, MatB, MatC)

    A wrapper for multiplying two dense matrices.

    Arguments

    Type IntentOptional AttributesName
    type(Matrix_ldr), intent(in) :: MatA

    The first matrix.

    type(Matrix_ldr), intent(in) :: MatB

    The second matrix.

    type(Matrix_ldr), intent(inout) :: MatC

    MatC = MatA*MatB.

  • private subroutine MultiplyMatrix_ldc(MatA, MatB, MatC)

    A wrapper for multiplying two dense matrices.

    Arguments

    Type IntentOptional AttributesName
    type(Matrix_ldc), intent(in) :: MatA

    The first matrix.

    type(Matrix_ldc), intent(in) :: MatB

    The second matrix.

    type(Matrix_ldc), intent(inout) :: MatC

    MatC = MatA*MatB.

public interface TransposeMatrix

  • private subroutine TransposeMatrix_ldr(matA, matAT)

    Transpose a dense matrix.

    Arguments

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

    matA the matrix to transpose.

    type(Matrix_ldr), intent(inout) :: matAT

    matAT = matA^T.

  • private subroutine TransposeMatrix_ldc(matA, matAT)

    Transpose a dense matrix.

    Arguments

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

    The matrix to transpose.

    type(Matrix_ldc), intent(inout) :: matAT

    matAT = matA^T.

public interface EigenDecomposition

  • private subroutine EigenDecomposition_ldr(MatA, MatV, MatW)

    Compute the eigenvectors of a dense matrix. Wraps a standard dense linear algebra routine.

    Arguments

    Type IntentOptional AttributesName
    type(Matrix_ldr), intent(in) :: MatA

    MatA the matrix to decompose.

    type(Matrix_ldr), intent(inout) :: MatV

    The eigenvectors.

    type(Matrix_ldr), intent(inout), optional :: MatW

    The eigenvalues.

  • private subroutine EigenDecomposition_ldc(MatA, MatV, MatW)

    Compute the eigenvectors of a dense matrix. Wraps a standard dense linear algebra routine.

    Arguments

    Type IntentOptional AttributesName
    type(Matrix_ldc), intent(in) :: MatA

    The matrix to decompose.

    type(Matrix_ldc), intent(inout) :: MatV

    The eigenvectors.

    type(Matrix_ldc), intent(inout), optional :: MatW

    The eigenvalues.


Derived Types

type, public :: Matrix_ldr

A datatype for storing a dense matrix.

Components

TypeVisibility AttributesNameInitial
real(kind=NTREAL), public, DIMENSION(:,:), ALLOCATABLE:: DATA

values of the matrix.

integer, public :: rows

Matrix dimension: rows.

integer, public :: columns

Matrix dimension: columns.

Constructor

private pure function ConstructEmptyMatrix_ldr(rows, columns)

Construct an empty dense matrix with a set number of rows and columns

type, public :: Matrix_ldc

A datatype for storing a dense matrix.

Components

TypeVisibility AttributesNameInitial
complex(kind=NTCOMPLEX), public, DIMENSION(:,:), ALLOCATABLE:: DATA

values of the matrix.

integer, public :: rows

Matrix dimension: rows.

integer, public :: columns

Matrix dimension: columns.

Constructor

private pure function ConstructEmptyMatrix_ldc(rows, columns)

Construct an empty dense matrix with a set number of rows and columns