DMatrixModule Module

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



Contents


Interfaces

public interface ConstructEmptyMatrix

  • private pure subroutine ConstructEmptyMatrixSup_ldr(this, rows, columns)

    A subroutine wrapper for the empty constructor.

    Arguments

    Type IntentOptional Attributes Name
    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 pure subroutine ConstructEmptyMatrixSup_ldc(this, rows, columns)

    A subroutine style wrapper for the constructor.

    Arguments

    Type IntentOptional Attributes Name
    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 pure subroutine ConstructMatrixDFromS_ldr(sparse_matrix, dense_matrix)

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

    Arguments

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

    The sparse matrix to convert.

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

    Output. Must be preallocated.

  • private pure subroutine ConstructMatrixDFromS_ldc(sparse_matrix, dense_matrix)

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

    Arguments

    Type IntentOptional Attributes Name
    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 pure subroutine ConstructMatrixSFromD_ldr(dense_matrix, sparse_matrix, threshold_in)

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

    Arguments

    Type IntentOptional Attributes Name
    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 pure subroutine ConstructMatrixSFromD_ldc(dense_matrix, sparse_matrix, threshold_in)

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

    Arguments

    Type IntentOptional Attributes Name
    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 pure subroutine CopyMatrix_ldr(matA, matB)

    Copy the matrix A into the B.

    Arguments

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

    The matrix to copy.

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

    matB = matA

  • private pure subroutine CopyMatrix_ldc(matA, matB)

    Copy the matrix A into the B.

    Arguments

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

    The matrix to copy.

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

    matB = matA

public interface DestructMatrix

  • private pure subroutine DestructMatrix_ldr(this)

    Deallocate the memory associated with this matrix.

    Arguments

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

    The matrix to delete.

  • private pure subroutine DestructMatrix_ldc(this)

    Deallocate the memory associated with this matrix.

    Arguments

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

    This the matrix to delete.

public interface SplitMatrix

  • private pure 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 Attributes Name
    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 pure 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 Attributes Name
    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 pure 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 Attributes Name
    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 pure 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 Attributes Name
    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 Attributes Name
    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 Attributes Name
    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 pure subroutine IncrementMatrix_ldr(MatA, MatB, alpha_in)

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

    Arguments

    Type IntentOptional Attributes Name
    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 pure subroutine IncrementMatrix_ldc(MatA, MatB, alpha_in)

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

    Arguments

    Type IntentOptional Attributes Name
    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, IsATransposed_in, IsBTransposed_in)

    A wrapper for multiplying two dense matrices.

    Arguments

    Type IntentOptional Attributes Name
    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.

    logical, intent(in), optional :: IsATransposed_in

    True if A is already transposed.

    logical, intent(in), optional :: IsBTransposed_in

    True if B is already transposed.

  • private subroutine MultiplyMatrix_ldc(MatA, MatB, MatC, IsATransposed_in, IsBTransposed_in)

    A wrapper for multiplying two dense matrices.

    Arguments

    Type IntentOptional Attributes Name
    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.

    logical, intent(in), optional :: IsATransposed_in

    True if A is already transposed.

    logical, intent(in), optional :: IsBTransposed_in

    True if B is already transposed.

public interface TransposeMatrix

  • private pure subroutine TransposeMatrix_ldr(matA, matAT)

    Transpose a dense matrix.

    Arguments

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

    matA the matrix to transpose.

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

    matAT = matA^T.

  • private pure subroutine TransposeMatrix_ldc(matA, matAT)

    Transpose a dense matrix.

    Arguments

    Type IntentOptional Attributes Name
    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 Attributes Name
    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 Attributes Name
    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

Type Visibility Attributes Name Initial
real(kind=NTREAL), public, DIMENSION(:,:), ALLOCATABLE :: DATA

values of the matrix.

integer, public :: rows

Matrix dimension: rows.

integer, public :: columns

Matrix dimension: columns.

type, public ::  Matrix_ldc

A datatype for storing a dense matrix.

Components

Type Visibility Attributes Name Initial
complex(kind=NTCOMPLEX), public, DIMENSION(:,:), ALLOCATABLE :: DATA

values of the matrix.

integer, public :: rows

Matrix dimension: rows.

integer, public :: columns

Matrix dimension: columns.