FEDEM Solver  R8.0
Source code of the dynamics solver
Data Types | Functions/Subroutines | Variables
sparsematrixmodule Module Reference

Module for management of general sparse matrices. More...

Data Types

type  sparsematrixtype
 Data type representing a rectangular sparse matrix. More...
 

Functions/Subroutines

subroutine smnullify (this)
 Initializes a sparse matrix object. More...
 
subroutine smallocate (this, nRows, nCols, useInitSize, err)
 Allocates a sparse matrix object. More...
 
subroutine smsetmatrix (this, mRow, mCol, values, err)
 Initializes a sparse matrix with the given data. More...
 
integer function smsize (this, iDim)
 Returns the dimension of a sparse matrix. More...
 
subroutine smdeallocate (this)
 Deallocates a sparse matrix. More...
 
subroutine smtranspose (this)
 Transposes a sparse matrix. More...
 
subroutine smsetvalue (this, value, rInd, cInd, err, lpu)
 Assigns a matrix element. More...
 
real(dp) function smgetvalue (this, rInd, cInd)
 Returns a matrix element. More...
 
real(dp) function, dimension(this%nrows) smgetcol (this, cInd)
 Returns a matrix column. More...
 
real(dp) function, dimension(this%ncols) smgetrow (this, rInd)
 Returns a matrix row. More...
 
subroutine smmattimesvec (this, xVec, yVec, err)
 Multiplies a sparse matrix with a vector. More...
 
subroutine smmattranstimesvec (this, xVec, yVec, err)
 Multiplies the transpose of a sparse matrix with a vector. More...
 
subroutine smshrinktofit (this, err)
 Reallocates a sparse matrix to exactly fit its dimensions. More...
 
subroutine smwrite (this, name, lpu, writeMatrixElms)
 Writes out the size parameters for a sparse matrix. More...
 
subroutine, private smgrow (this, err, lpu)
 Expands the allocated space for a sparse matrix by a fixed amount. More...
 

Variables

integer, parameter, private initsize_p = 10000
 Initial allocated size for a new sparse matrix. More...
 
real(dp), parameter, private growfactor_p = 1.5_dp
 Relative size increment when the matrix is too small. More...
 

Detailed Description

Module for management of general sparse matrices.

This module contains a data type and associated utility routines for representing a general sparse matrix stored on classic coordinate form.

Note
All data members of sparsematrixmodule::sparsematrixtype are private and can therefore be accessed only through the subroutines/functions contained in this module.

Function/Subroutine Documentation

◆ smallocate()

subroutine sparsematrixmodule::smallocate ( type(sparsematrixtype), intent(out)  this,
integer, intent(in)  nRows,
integer, intent(in)  nCols,
logical, intent(in)  useInitSize,
integer, intent(out)  err 
)

Allocates a sparse matrix object.

Parameters
[out]thisThe sparsematrixmodule::sparsematrixtype object to be allocated
[in]nRowsNumber of matrix rows
[in]nColsNumber of matrix columns
[in]useInitSizeIf .true., perform initial allocation using the sparsematrixmodule::initsize_p value as number of non-zeroes
[out]errError indicator
Author
Knut Morten Okstad
Date
Jan 2003
Here is the caller graph for this function:

◆ smdeallocate()

subroutine sparsematrixmodule::smdeallocate ( type(sparsematrixtype), intent(inout)  this)

Deallocates a sparse matrix.

Parameters
thisThe sparsematrixmodule::sparsematrixtype object to deallocate
Author
Knut Morten Okstad
Date
Jan 2003
Here is the caller graph for this function:

◆ smgetcol()

real(dp) function, dimension(this%nrows) sparsematrixmodule::smgetcol ( type(sparsematrixtype), intent(in)  this,
integer, intent(in)  cInd 
)

Returns a matrix column.

Parameters
[in]thisThe sparsematrixmodule::sparsematrixtype object to return the column for
[in]cIndIndex of the matrix column to return
Author
Bjorn Haugen
Date
Jan 1999

◆ smgetrow()

real(dp) function, dimension(this%ncols) sparsematrixmodule::smgetrow ( type(sparsematrixtype), intent(in)  this,
integer, intent(in)  rInd 
)

Returns a matrix row.

Parameters
[in]thisThe sparsematrixmodule::sparsematrixtype object to return the row for
[in]rIndIndex of the matrix row to return
Author
Bjorn Haugen
Date
Jan 1999

◆ smgetvalue()

real(dp) function sparsematrixmodule::smgetvalue ( type(sparsematrixtype), intent(in)  this,
integer, intent(in)  rInd,
integer, intent(in)  cInd 
)

Returns a matrix element.

Parameters
[in]thisThe sparsematrixmodule::sparsematrixtype object to return the element for
[in]rIndRow index of the matrix element to return
[in]cIndColumn index of the matrix element to return
Author
Bjorn Haugen
Date
Jan 1999

◆ smgrow()

subroutine, private sparsematrixmodule::smgrow ( type(sparsematrixtype), intent(inout)  this,
integer, intent(out)  err,
integer, intent(in), optional  lpu 
)
private

Expands the allocated space for a sparse matrix by a fixed amount.

Parameters
thisThe sparsematrixmodule::sparsematrixtype object to expand
[out]errError indicator
[in]lpuOptional file unit number logging the rellocation

The number of times n to call this subroutine to grow a matrix to size x with a given growfactor is:

n = log(x) / log(growfactor)
Author
Knut Morten Okstad
Date
Jan 2003
Here is the caller graph for this function:

◆ smmattimesvec()

subroutine sparsematrixmodule::smmattimesvec ( type(sparsematrixtype), intent(in)  this,
real(dp), dimension(:), intent(in)  xVec,
real(dp), dimension(:), intent(out)  yVec,
integer, intent(out)  err 
)

Multiplies a sparse matrix with a vector.

Parameters
[in]thisThe sparsematrixmodule::sparsematrixtype object (A) being the left-hand-size of the multiplication operation
[in]xVecThe right-hand-side vector (x) of the multiplication
[out]yVecThe resulting vector (y)
[out]errError indicator

Performs the operation y = A * x .

Author
Bjorn Haugen
Date
Jan 1999

◆ smmattranstimesvec()

subroutine sparsematrixmodule::smmattranstimesvec ( type(sparsematrixtype), intent(in)  this,
real(dp), dimension(:), intent(in)  xVec,
real(dp), dimension(:), intent(out)  yVec,
integer, intent(out)  err 
)

Multiplies the transpose of a sparse matrix with a vector.

Parameters
[in]thisThe sparsematrixmodule::sparsematrixtype object (A) being the left-hand-size of the multiplication operation
[in]xVecThe right-hand-side vector (x) of the multiplication
[out]yVecThe resulting vector (y)
[out]errError indicator

Performs the operation y = At * x .

Author
Bjorn Haugen
Date
Jan 1999
Here is the caller graph for this function:

◆ smnullify()

subroutine sparsematrixmodule::smnullify ( type(sparsematrixtype), intent(out)  this)

Initializes a sparse matrix object.

Parameters
[out]thisThe sparsematrixmodule::sparsematrixtype object to be initialized
Author
Knut Morten Okstad
Date
Mar 2003
Here is the caller graph for this function:

◆ smsetmatrix()

subroutine sparsematrixmodule::smsetmatrix ( type(sparsematrixtype), intent(inout)  this,
integer, dimension(:), pointer  mRow,
integer, dimension(:), pointer  mCol,
real(dp), dimension(:), pointer  values,
integer, intent(out)  err 
)

Initializes a sparse matrix with the given data.

Parameters
thisThe sparsematrixmodule::sparsematrixtype object to initialize
[in]mRowRow indices of the non-zero entries
[in]mColColumn indices of the non-zero entries
[in]valuesAll non-zero entries of the matrix
[out]errError indicator
Note
The input arrays are referenced directly by the sparsematrixmodule::sparsematrixtype object (pointer-associated) and not copied. They must therefore not be accessed from outside the object after its destruction (by calling sparsematrixmodule::smdeallocate), as these arrays then would be deallocated as well.
Author
Knut Morten Okstad
Date
16 Sep 2004
Here is the caller graph for this function:

◆ smsetvalue()

subroutine sparsematrixmodule::smsetvalue ( type(sparsematrixtype), intent(inout)  this,
real(dp), intent(in)  value,
integer, intent(in)  rInd,
integer, intent(in)  cInd,
integer, intent(out)  err,
integer, intent(in), optional  lpu 
)

Assigns a matrix element.

Parameters
thisThe sparsematrixmodule::sparsematrixtype object to receive the new matrix element
[in]valueThe new matrix element value
[in]rIndRow index of the new matrix element
[in]cIndColumn index of the new matrix element
[out]errError indicator
[in]lpuOptional file unit number for error- and other messages
Author
Bjorn Haugen
Date
Jan 1999
Here is the caller graph for this function:

◆ smshrinktofit()

subroutine sparsematrixmodule::smshrinktofit ( type(sparsematrixtype), intent(inout)  this,
integer, intent(out)  err 
)

Reallocates a sparse matrix to exactly fit its dimensions.

Parameters
thisThe sparsematrixmodule::sparsematrixtype object to reallocate
[out]errError indicator
Author
Knut Morten Okstad
Date
Jan 2003
Here is the caller graph for this function:

◆ smsize()

integer function sparsematrixmodule::smsize ( type(sparsematrixtype), intent(in)  this,
integer, intent(in), optional  iDim 
)

Returns the dimension of a sparse matrix.

Parameters
[in]thisThe sparsematrixmodule::sparsematrixtype object to return the dimension of
[in]iDimWhich dimension to return the size for:
  1. Number of rows
  2. Number of columns
  3. Number of non-zeroes
Author
Bjorn Haugen
Date
Jan 1999
Here is the caller graph for this function:

◆ smtranspose()

subroutine sparsematrixmodule::smtranspose ( type(sparsematrixtype), intent(inout)  this)

Transposes a sparse matrix.

Parameters
thisThe sparsematrixmodule::sparsematrixtype object to transpose
Author
Bjorn Haugen
Date
Jan 1999

◆ smwrite()

subroutine sparsematrixmodule::smwrite ( type(sparsematrixtype), intent(in)  this,
character(len=*), intent(in)  name,
integer, intent(in)  lpu,
logical, intent(in), optional  writeMatrixElms 
)

Writes out the size parameters for a sparse matrix.

Parameters
[in]thisThe sparsematrixmodule::sparsematrixtype object to write size parameters for
[in]nameMatrix identifier
[in]lpuFile unit number to write to
[in]writeMatrixElmsIf .true., write out the matrix elements as well
Author
Knut Morten Okstad
Date
Mar 2003
Here is the caller graph for this function:

Variable Documentation

◆ growfactor_p

real(dp), parameter, private sparsematrixmodule::growfactor_p = 1.5_dp
private

Relative size increment when the matrix is too small.

◆ initsize_p

integer, parameter, private sparsematrixmodule::initsize_p = 10000
private

Initial allocated size for a new sparse matrix.