NTPoly
Data Types | Functions/Subroutines
sparsematrixmodule Module Reference

A module for handling locally stored CSR matrices. More...

Data Types

type  sparsematrix_t
 A datatype for storing a CSR matrix. More...
 

Functions/Subroutines

pure subroutine, public constructemptysparsematrix (this, columns, rows)
 Create a sparse matrix with a certain number of columns and rows. Will allocate storage for the outer values. More...
 
subroutine, public constructsparsematrixfromfile (this, file_name)
 Create a sparse matrix by reading in a matrix market file. More...
 
pure subroutine, public constructfromtripletlist (this, triplet_list, rows, columns)
 Construct a sparse matrix from a SORTED triplet list. The triplet list must be sorted to efficiently fill in the matrix. This constructor assumes you have already sorted the triplet list. More...
 
pure subroutine, public destructsparsematrix (this)
 Explicitly destruct a sparse matrix. This will always check if arrays are actually allocated, so you can feel free to destruct a matrix even if it has no data. More...
 
pure subroutine, public copysparsematrix (matA, matB)
 Copy a sparse matrix in a safe way. More...
 
pure integer function, public getrows (this)
 Get the number of rows of a matrix. More...
 
pure integer function, public getcolumns (this)
 Get the number of columns of a matrix. More...
 
pure subroutine, public transposesparsematrix (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. More...
 
pure subroutine, public composesparsematrixcolumns (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. More...
 
pure subroutine, public splitsparsematrixcolumns (this, num_blocks, split_list, block_offsets_out)
 Take a matrix, and split into into small blocks. More...
 
pure subroutine, public matrixtotripletlist (this, triplet_list)
 Construct a triplet list from a matrix. More...
 
subroutine, public printsparsematrix (this, file_name_in)
 Print out a sparse matrix. We first create a triplet list, and then call the print triplet list function. More...
 
pure logical function, public checkifidentity (this, threshold_in)
 Check if a matrix is equal to the identity matrix. This routine is really just for testing. You can multiply a matrix and its inverse, and then call this routine to make sure multiplication is correct. More...
 

Detailed Description

A module for handling locally stored CSR matrices.

Function/Subroutine Documentation

◆ checkifidentity()

pure logical function, public sparsematrixmodule::checkifidentity ( type(sparsematrix_t), intent(in)  this,
real(ntreal), intent(in), optional  threshold_in 
)

Check if a matrix is equal to the identity matrix. This routine is really just for testing. You can multiply a matrix and its inverse, and then call this routine to make sure multiplication is correct.

Parameters
[in]thisthe matrix to check.
[in]threshold_infor flushing values to zero. Default value is 10^-8.
Returns
true if the matrix is equal to the identity matrix.

◆ composesparsematrixcolumns()

pure subroutine, public sparsematrixmodule::composesparsematrixcolumns ( type(sparsematrix_t), dimension(:), intent(in)  mat_list,
type(sparsematrix_t), intent(inout)  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.

Parameters
[in]mat_listlist of matrices to compose.
[out]out_matrix= [Matrix 1 | Matrix 2, ...] .

◆ constructemptysparsematrix()

pure subroutine, public sparsematrixmodule::constructemptysparsematrix ( type(sparsematrix_t), intent(out)  this,
integer, intent(in)  columns,
integer, intent(in)  rows 
)

Create a sparse matrix with a certain number of columns and rows. Will allocate storage for the outer values.

Parameters
[out]thisthe matrix being created. It will have the outer index allocated, but nothing else.
[in]columnsnumber of matrix columns.
[in]rowsnumber of matrix rows.

◆ constructfromtripletlist()

pure subroutine, public sparsematrixmodule::constructfromtripletlist ( type(sparsematrix_t), intent(out)  this,
type(tripletlist_t), intent(in)  triplet_list,
integer, intent(in)  rows,
integer, intent(in)  columns 
)

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

Parameters
[out]thisthe matrix being constructed
[in]triplet_lista list of triplet values. They must be sorted.
[in]rowsnumber of matrix rows
[in]columnsnumber of matrix columns

◆ constructsparsematrixfromfile()

subroutine, public sparsematrixmodule::constructsparsematrixfromfile ( type(sparsematrix_t), intent(out)  this,
character(len=*), intent(in)  file_name 
)

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

Parameters
[out]thisthe matrix being constructed.
[in]file_namename of the file.

◆ copysparsematrix()

pure subroutine, public sparsematrixmodule::copysparsematrix ( type(sparsematrix_t), intent(in)  matA,
type(sparsematrix_t), intent(inout)  matB 
)

Copy a sparse matrix in a safe way.

Parameters
[in]matAmatrix to copy
[in,out]matB= matA

◆ destructsparsematrix()

pure subroutine, public sparsematrixmodule::destructsparsematrix ( type(sparsematrix_t), intent(inout)  this)

Explicitly destruct a sparse matrix. This will always check if arrays are actually allocated, so you can feel free to destruct a matrix even if it has no data.

Parameters
[in,out]thisthe matrix to free up

◆ getcolumns()

pure integer function, public sparsematrixmodule::getcolumns ( type(sparsematrix_t), intent(in)  this)

Get the number of columns of a matrix.

Parameters
[in]thisthe matrix.
Returns
number of columns.

◆ getrows()

pure integer function, public sparsematrixmodule::getrows ( type(sparsematrix_t), intent(in)  this)

Get the number of rows of a matrix.

Parameters
[in]thisthe matrix.
Returns
number of rows.

◆ matrixtotripletlist()

pure subroutine, public sparsematrixmodule::matrixtotripletlist ( type(sparsematrix_t), intent(in)  this,
type(tripletlist_t), intent(inout)  triplet_list 
)

Construct a triplet list from a matrix.

Parameters
[in]thisthe matrix to construct the triplet list from.
[out]triplet_listthe triplet list we created.

◆ printsparsematrix()

subroutine, public sparsematrixmodule::printsparsematrix ( type(sparsematrix_t), intent(in)  this,
character(len=*), intent(in), optional  file_name_in 
)

Print out a sparse matrix. We first create a triplet list, and then call the print triplet list function.

Parameters
[in]thisthe matrix to be printed.
[in]file_name_inoptionally, you can pass a file to print to.

◆ splitsparsematrixcolumns()

pure subroutine, public sparsematrixmodule::splitsparsematrixcolumns ( type(sparsematrix_t), intent(in)  this,
integer, intent(in)  num_blocks,
type(sparsematrix_t), dimension(num_blocks), intent(out)  split_list,
integer, dimension(num_blocks+1), intent(out), optional  block_offsets_out 
)

Take a matrix, and split into into small blocks.

Parameters
[in]thismatrix to perform this operation on.
[in]num_blocksnumber of blocks to split into.
[out]split_list1D array of blocks.
[out]block_offsets_outthe offsets used for splitting.

◆ transposesparsematrix()

pure subroutine, public sparsematrixmodule::transposesparsematrix ( type(sparsematrix_t), intent(in)  this,
type(sparsematrix_t), intent(inout)  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.

Parameters
[in]thisthe matrix to be transposed.
[out]matTthe input matrix transposed.