Skip to content

Commit

Permalink
Updates in CSRMatrix
Browse files Browse the repository at this point in the history
- Adding Scal method
- working on issue #264
  • Loading branch information
vickysharma0812 committed Dec 16, 2023
1 parent b81e5b0 commit 10e14d3
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 48 deletions.
64 changes: 63 additions & 1 deletion src/modules/CSRMatrix/src/CSRMatrix_UnaryMethods.F90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,53 @@
!
! You should have received a copy of the GNU General Public License
! along with this program. If not, see <https: //www.gnu.org/licenses/>
!

!> author: Vikas Sharma, Ph. D.
! date: 22 March 2021
! summary: UnaryMethods operator for [[SparseMaatrix_]]
!
! Following subroutines are planned to include in this module
!
! | subroutine | description |
! |---|---|
! | `SUBMAT` | extracts a submatrix from a sparse matrix |
! | `FILTER` | filters elements from a matrix according to their magnitude |
! | `CSORT` | sorts the elements in increasing order of columns |
! | `CLNCSR` | clean up the CSR format matrix, remove duplicate entry, etc |
! | `TRANSP` | in-place transposition routine |
! | `COPMAT` | copy of a matrix into another matrix (both stored csr) |
! | `GETELM` | returns a(i,j) for any (i,j) from a CSR-stored matrix. |
! | `GETDIA` | extracts a specified diagonal from a matrix. |
! | `GETL` | extracts lower triangular part |
! | `GETU` | extracts upper triangular part |
! | `LEVELS` | gets the level scheduling structure for lower triangular matrices |
! | `AMASK` | extracts C = A mask M |
! | `RPERM` | permutes the rows of a matrix (B = P A) |
! | `CPERM` | permutes the columns of a matrix (B = A Q) |
! | `DPERM` | permutes both the rows and columns of a matrix (B = P A Q ) |
! | `DPERM1` | general extraction routine (extracts arbitrary rows) |
! | `DPERM2` | general submatrix permutation/extraction routine |
! | `DVPERM` | permutes a real vector (in-place) |
! | `IVPERM` | permutes an integer vector (in-place) |
! | `RETMX` | returns the max absolute value in each row of the matrix |
! | `DIAPOS` | returns the positions of the diagonal elements in A. |
! | `EXTBDG` | extracts the main diagonal blocks of a matrix. |
! | `GETBWD` | returns the bandwidth information on a matrix. |
! | `BLKFND` | finds the block-size of a matrix. |
! | `BLKCHK` | checks whether a given integer is the block size of A. |
! | `INFDIA` | obtains information on the diagonals of A. |
! | `AMUBDG` | gets number of nonzeros in each row of A*B (as well as NNZ) |
! | `APLBDG` | gets number of nonzeros in each row of A+B (as well as NNZ) |
! | `RNRMS` | computes the norms of the rows of A |
! | `CNRMS` | computes the norms of the columns of A |
! | `ROSCAL` | scales the rows of a matrix by their norms. |
! | `COSCAL` | scales the columns of a matrix by their norms. |
! | `ADDBLK` | Adds a matrix B into a block of A. |
! | `GET1UP` | Collects the first elements of each row of the upper triangular portion of the matrix |
! | `XTROWS` | extracts given rows from a matrix in CSR format. |
! | `CSRKVSTR`| Finds block row partitioning of matrix in CSR format |
! | `CSRKVSTC`| Finds block column partitioning of matrix in CSR format |
! | `KVSTMERGE`| Merges block partitionings, for conformal row/col pattern |

MODULE CSRMatrix_UnaryMethods
USE GlobalData, ONLY: I4B, DFP, LGT
Expand All @@ -37,6 +83,22 @@ MODULE CSRMatrix_UnaryMethods
PUBLIC :: Permute
PUBLIC :: GetSym
PUBLIC :: ASSIGNMENT(=)
PUBLIC :: SCAL

!----------------------------------------------------------------------------
! Scal@Methods
!----------------------------------------------------------------------------

!> author: Vikas Sharma, Ph. D.
! date: 2023-12-17
! summary: Scale the matrix

INTERFACE Scal
MODULE SUBROUTINE obj_Scal(obj, a)
TYPE(CSRMatrix_), INTENT(INOUT) :: obj
REAL(DFP), INTENT(IN) :: a
END SUBROUTINE obj_Scal
END INTERFACE Scal

!----------------------------------------------------------------------------
! Convert@Unary
Expand Down
55 changes: 8 additions & 47 deletions src/submodules/CSRMatrix/src/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -15,58 +15,19 @@
! along with this program. If not, see <https: //www.gnu.org/licenses/>
!

!> author: Vikas Sharma, Ph. D.
! date: 22 March 2021
! summary: UnaryMethods operator for [[SparseMaatrix_]]
!
! Following subroutines are planned to include in this module
!
! | subroutine | description |
! |---|---|
! | `SUBMAT` | extracts a submatrix from a sparse matrix |
! | `FILTER` | filters elements from a matrix according to their magnitude |
! | `CSORT` | sorts the elements in increasing order of columns |
! | `CLNCSR` | clean up the CSR format matrix, remove duplicate entry, etc |
! | `TRANSP` | in-place transposition routine |
! | `COPMAT` | copy of a matrix into another matrix (both stored csr) |
! | `GETELM` | returns a(i,j) for any (i,j) from a CSR-stored matrix. |
! | `GETDIA` | extracts a specified diagonal from a matrix. |
! | `GETL` | extracts lower triangular part |
! | `GETU` | extracts upper triangular part |
! | `LEVELS` | gets the level scheduling structure for lower triangular matrices |
! | `AMASK` | extracts C = A mask M |
! | `RPERM` | permutes the rows of a matrix (B = P A) |
! | `CPERM` | permutes the columns of a matrix (B = A Q) |
! | `DPERM` | permutes both the rows and columns of a matrix (B = P A Q ) |
! | `DPERM1` | general extraction routine (extracts arbitrary rows) |
! | `DPERM2` | general submatrix permutation/extraction routine |
! | `DVPERM` | permutes a real vector (in-place) |
! | `IVPERM` | permutes an integer vector (in-place) |
! | `RETMX` | returns the max absolute value in each row of the matrix |
! | `DIAPOS` | returns the positions of the diagonal elements in A. |
! | `EXTBDG` | extracts the main diagonal blocks of a matrix. |
! | `GETBWD` | returns the bandwidth information on a matrix. |
! | `BLKFND` | finds the block-size of a matrix. |
! | `BLKCHK` | checks whether a given integer is the block size of A. |
! | `INFDIA` | obtains information on the diagonals of A. |
! | `AMUBDG` | gets number of nonzeros in each row of A*B (as well as NNZ) |
! | `APLBDG` | gets number of nonzeros in each row of A+B (as well as NNZ) |
! | `RNRMS` | computes the norms of the rows of A |
! | `CNRMS` | computes the norms of the columns of A |
! | `ROSCAL` | scales the rows of a matrix by their norms. |
! | `COSCAL` | scales the columns of a matrix by their norms. |
! | `ADDBLK` | Adds a matrix B into a block of A. |
! | `GET1UP` | Collects the first elements of each row of the upper triangular portion of the matrix |
! | `XTROWS` | extracts given rows from a matrix in CSR format. |
! | `CSRKVSTR`| Finds block row partitioning of matrix in CSR format |
! | `CSRKVSTC`| Finds block column partitioning of matrix in CSR format |
! | `KVSTMERGE`| Merges block partitionings, for conformal row/col pattern |

SUBMODULE(CSRMatrix_UnaryMethods) Methods
USE BaseMethod
IMPLICIT NONE
CONTAINS

!----------------------------------------------------------------------------
! Scal
!----------------------------------------------------------------------------

MODULE PROCEDURE obj_Scal
CALL SCAL(X=obj%A, A=a)
END PROCEDURE obj_Scal

!----------------------------------------------------------------------------
! Convert
!----------------------------------------------------------------------------
Expand Down

0 comments on commit 10e14d3

Please sign in to comment.