CSRMAT
This class is used to store sparse matrices as CSR data structure. It is composed by 3 vectors for row and column indices and for the data. More…
#include "CSRMAT.h"
Public Functions
Name | |
---|---|
CSRMAT() Constructs an empty object. |
|
CSRMAT(iRegExt input_nrows, iRegExt input_ncols, iExt input_nterm, iRegExt * ja_in, iExt * iat_in, rExt * coef_in) Constructs the and stores the object. |
|
~CSRMAT() Deletes the object. |
|
void | overlap(iRegExt nrows, iRegExt ncols, iExt nterm, iExt * iat, iRegExt * ja, rExt * coef) Fills object assigning pointer. |
void | assign_null() Assign null pointer. |
void | mk_CSRMAT(const iRegExt restrict input_nrows, const iRegExt restrict input_ncols, const iExt restrict input_nterm) Allocate the object structure. |
void | resize_CSRMAT(const iRegExt restrict new_nrows, const iRegExt restrict new_ncols, const iExt restrict new_nterm) Resize the object structure. |
void | swap(CSRMAT< iRegExt > & M) Swap two CSRMAT objects. |
void | apply_perm(const iRegExt restrict perm, const iRegExt restrict iperm, CSRMAT< iRegExt > &restrict mat_out) Applies a permutation to a CSRMAT instance. |
iRegExt | get_nrows() const Retrieves the matrix number of rows. |
iRegExt | get_ncols() const Retrieves the matrix number of columns. |
void | set_ncols(iRegExt input_ncols) Sets the number of columns. |
iExt | get_nterm() const Retrieves the matrix number of stored terms. |
iRegExt * | get_ptr_nrows() Retrieves the pointer to the matrix number of rows. |
const iRegExt * | get_ptr_nrows() const |
iRegExt * | get_ptr_ncols() Retrieves the pointer to the matrix number of columns. |
const iRegExt * | get_ptr_ncols() const |
iExt * | get_ptr_nterm() Retrieves the pointer to the matrix number of stored terms. |
const iExt * | get_ptr_nterm() const |
iExt * | get_ptr_iat_data() Retrieves the pointer to the iat data. |
const iExt * | get_ptr_iat_data() const |
iRegExt * | get_ptr_ja_data() Retrieves the pointer to the ja data. |
const iRegExt * | get_ptr_ja_data() const |
rExt * | get_ptr_coef_data() Retrieves the pointer to the coef data. |
const rExt * | get_ptr_coef_data() const |
void | wrCSR_unit_ASCII(ofstream &restrict out_f, const bool patt, const iExt restrict shift) Writes the CSRMAT to the output ASCII unit. |
void | fPrintAll_CSRMAT_ASCII(const string &restrict filename, const iReg restrict myid, const iReg restrict nproc) Prints a csr matrix in ASCII, distributed as slices among the various processors. |
void | wrCSR_unit_BIN(ofstream &restrict out_f, const bool patt, const iExt restrict shift) Writes the CSRMAT to the output BINARY unit. |
void | fPrintAll_CSRMAT_BIN(const string &restrict filename, const iReg restrict myid, const iReg restrict nproc) Prints a csr matrix in BINARY, distributed as slices among the various processors. |
void | diag_block(const iRegExt restrict input_nrows, VEC< rExt > &restrict input_diagonal_coef) Sets diagonal terms equal to some coeff. |
VEC< rExt > | extract_diag_coef() Extracts diagonal coef. |
void | CreateLowerCSR(const iReg nRows_i, CSRMAT< iReg > &restrict LowerCSR) Extracts the lower part of a square csr matrix including its diagonal. |
void | Transpose(iExt *restrict WI1, iExt restrict WI2, CSRMAT< iRegExt > &restrict MatT) const Transpose a csr matrix. |
void | SoC_Transpose(const iReg restrict coef_SoC, iExt restrict WI1, iExt restrict WI2, CSRMAT< iRegExt > &restrict MatT) const Transpose SoC matrix. |
void | MxV(const iReg nRHS, const rExt restrict x, rExt restrict b) Multiplies the csrmat (A) by a vector Ax=b with b initialization. |
void | MxV_sum(const iReg nRHS, const rExt restrict x, rExt restrict b) Multiplies the csrmat (A) by a vector Ax=b. |
void | MxM(VEC< iReg > & nnz, const iReg lfil, const type_OMP_iReg nthreads, CSRMAT< iRegExt > & B, VEC< CSRMAT< iRegExt >> & C_old, VEC< CSRMAT< iRegExt >> & C_new, VEC< iReg > & WN) Computes the product M x M. C_new = C_old + A x B (with ‘this’ == A). |
void | SoC_DiagDom(const bool Diag_Flag, const rExt restrict Dr, const rExt restrict Dc, const rExt restrict TVnorm_r, const rExt restrict TVnorm_c, const bool TVnorm_FLAG, const rExt restrict tau_jump, const rExt restrict tau, iReg restrict ind_SoC, rExt restrict coef_SoC, iExt & str_count) Computes SoC for a csr block B: SoC = coef_B / sqrt ( Dr * Dc ). |
void | SoC_Classical(const bool Diag_Flag, const rExt restrict aij_max, const rExt restrict akj_max, const rExt restrict tau, iReg restrict ind, rExt restrict coef, iExt & str_count) const Computes SoC for a csr block B: SoC = coef_B / sqrt ( Dr * Dc ). |
void | SoC_DiagDom_tune(const bool Diag_Flag, const rExt restrict Dr, const rExt restrict Dc, const rExt restrict TVnorm_r, const rExt restrict TVnorm_c, const bool TVnorm_FLAG, const rExt restrict tau_jump, iReg restrict ind_SoC, rExt restrict coef_SoC, const iReg restrict nbins, iExt *restrict mybins) Computes SoC for a csr block B: SoC = coef_B / sqrt ( Dr * Dc ) and dynamically computes a value for tau leaving a given average number of connections per node. |
void | SoC_Affinity(const bool Diag_Flag, const rExt ZERO_nrm, const iReg nTV, const rExt restrict TVnorm_r, const rExt restrict TVnorm_c, const rExt restrict TV_r, const rExt restrict TV_c, const rExt restrict tau_jump, const rExt restrict tau, iReg restrict ind_SoC, rExt restrict coef_SoC, iExt & str_count) Computes SoC for a csr block B: SoC = coef_B / sqrt ( Dr * Dc ). |
void | SoC_Affinity_tune(const bool Diag_Flag, const rExt ZERO_nrm, const iReg nTV, const rExt restrict TVnorm_r, const rExt restrict TVnorm_c, const rExt restrict TV_r, const rExt restrict TV_c, const rExt restrict tau_jump, iReg restrict ind_SoC, rExt restrict coef_SoC, const iReg restrict nbins, iExt *restrict mybins) Computes SoC for a csr block B: SoC = coef_B / sqrt ( Dr * Dc ) and dynamically computes a value for tau leaving a given average number of connections per node. |
void | SoC_Filter(const rExt restrict tau, iReg restrict ind, rExt restrict coef, iExt & str_count) Filters an already computed SoC for a csr block using a tolerance tau. |
Detailed Description
template <typename iRegExt >
class CSRMAT;
This class is used to store sparse matrices as CSR data structure. It is composed by 3 vectors for row and column indices and for the data.
class CSRMAT.
Public Functions Documentation
function CSRMAT
CSRMAT()
Constructs an empty object.
function CSRMAT
CSRMAT(
iRegExt input_nrows,
iRegExt input_ncols,
iExt input_nterm,
iRegExt * ja_in,
iExt * iat_in,
rExt * coef_in
)
Constructs the and stores the object.
function ~CSRMAT
~CSRMAT()
Deletes the object.
function overlap
void overlap(
iRegExt nrows,
iRegExt ncols,
iExt nterm,
iExt * iat,
iRegExt * ja,
rExt * coef
)
Fills object assigning pointer.
function assign_null
void assign_null()
Assign null pointer.
function mk_CSRMAT
void mk_CSRMAT(
const iRegExt __restrict__ input_nrows,
const iRegExt __restrict__ input_ncols,
const iExt __restrict__ input_nterm
)
Allocate the object structure.
Parameters:
- input_nrows number of rows.
- input_ncols number of columns.
- input_nterm number of stored terms.
function resize_CSRMAT
void resize_CSRMAT(
const iRegExt __restrict__ new_nrows,
const iRegExt __restrict__ new_ncols,
const iExt __restrict__ new_nterm
)
Resize the object structure.
Parameters:
- new_nrows new number of rows.
- new_ncols new number of columns.
- new_nterm new number of stored terms.
function swap
void swap(
CSRMAT< iRegExt > & M
)
Swap two CSRMAT objects.
Parameters:
- M CSRMAT to swap with ‘this’.
function apply_perm
void apply_perm(
const iRegExt *__restrict__ perm,
const iRegExt *__restrict__ iperm,
CSRMAT< iRegExt > &__restrict__ mat_out
)
Applies a permutation to a CSRMAT instance.
function get_nrows
iRegExt get_nrows() const
Retrieves the matrix number of rows.
function get_ncols
iRegExt get_ncols() const
Retrieves the matrix number of columns.
function set_ncols
void set_ncols(
iRegExt input_ncols
)
Sets the number of columns.
function get_nterm
iExt get_nterm() const
Retrieves the matrix number of stored terms.
function get_ptr_nrows
iRegExt * get_ptr_nrows()
Retrieves the pointer to the matrix number of rows.
function get_ptr_nrows
const iRegExt * get_ptr_nrows() const
function get_ptr_ncols
iRegExt * get_ptr_ncols()
Retrieves the pointer to the matrix number of columns.
function get_ptr_ncols
const iRegExt * get_ptr_ncols() const
function get_ptr_nterm
iExt * get_ptr_nterm()
Retrieves the pointer to the matrix number of stored terms.
function get_ptr_nterm
const iExt * get_ptr_nterm() const
function get_ptr_iat_data
iExt * get_ptr_iat_data()
Retrieves the pointer to the iat data.
function get_ptr_iat_data
const iExt * get_ptr_iat_data() const
function get_ptr_ja_data
iRegExt * get_ptr_ja_data()
Retrieves the pointer to the ja data.
function get_ptr_ja_data
const iRegExt * get_ptr_ja_data() const
function get_ptr_coef_data
rExt * get_ptr_coef_data()
Retrieves the pointer to the coef data.
function get_ptr_coef_data
const rExt * get_ptr_coef_data() const
function wrCSR_unit_ASCII
void wrCSR_unit_ASCII(
ofstream &__restrict__ out_f,
const bool patt,
const iExt __restrict__ shift
)
Writes the CSRMAT to the output ASCII unit.
Parameters:
- out_f output file.
- patt flag to print only the pattern.
- shift shift row index.
function fPrintAll_CSRMAT_ASCII
void fPrintAll_CSRMAT_ASCII(
const string &__restrict__ filename,
const iReg __restrict__ myid,
const iReg __restrict__ nproc
)
Prints a csr matrix in ASCII, distributed as slices among the various processors.
Parameters:
- filename output file name.
- myid process id.
- nproc total number of processes.
function wrCSR_unit_BIN
void wrCSR_unit_BIN(
ofstream &__restrict__ out_f,
const bool patt,
const iExt __restrict__ shift
)
Writes the CSRMAT to the output BINARY unit.
Parameters:
- out_f output file.
- patt flag to print only the pattern.
- shift shift row index.
function fPrintAll_CSRMAT_BIN
void fPrintAll_CSRMAT_BIN(
const string &__restrict__ filename,
const iReg __restrict__ myid,
const iReg __restrict__ nproc
)
Prints a csr matrix in BINARY, distributed as slices among the various processors.
Parameters:
- filename output file name.
- myid process id.
- nproc total number of processes.
function diag_block
void diag_block(
const iRegExt __restrict__ input_nrows,
VEC< rExt > &__restrict__ input_diagonal_coef
)
Sets diagonal terms equal to some coeff.
Parameters:
- input_nrows number of rows.
- input_diagonal_coef coeff to set.
function extract_diag_coef
VEC< rExt > extract_diag_coef()
Extracts diagonal coef.
function CreateLowerCSR
void CreateLowerCSR(
const iReg nRows_i,
CSRMAT< iReg > &__restrict__ LowerCSR
)
Extracts the lower part of a square csr matrix including its diagonal.
Parameters:
- nRows_i number of internal rows (variables).
- LowerCSR lower part of th csr matrix.
function Transpose
void Transpose(
iExt **__restrict__ WI1,
iExt *__restrict__ WI2,
CSRMAT< iRegExt > &__restrict__ MatT
) const
Transpose a csr matrix.
Parameters:
- WI1 scratch matrix.
- WI2 scratch array.
- MatT transposed matrix.
function SoC_Transpose
void SoC_Transpose(
const iReg *__restrict__ coef_SoC,
iExt **__restrict__ WI1,
iExt *__restrict__ WI2,
CSRMAT< iRegExt > &__restrict__ MatT
) const
Transpose SoC matrix.
Parameters:
- coef_SoC SoC coefficients.
- WI1 scratch matrix.
- WI2 scratch array.
- MatT transposed matrix.
function MxV
void MxV(
const iReg nRHS,
const rExt *__restrict__ x,
rExt *__restrict__ b
)
Multiplies the csrmat (A) by a vector Ax=b with b initialization.
function MxV_sum
void MxV_sum(
const iReg nRHS,
const rExt *__restrict__ x,
rExt *__restrict__ b
)
Multiplies the csrmat (A) by a vector Ax=b.
function MxM
void MxM(
VEC< iReg > & nnz,
const iReg lfil,
const type_OMP_iReg nthreads,
CSRMAT< iRegExt > & B,
VEC< CSRMAT< iRegExt >> & C_old,
VEC< CSRMAT< iRegExt >> & C_new,
VEC< iReg > & WN
)
Computes the product M x M. C_new = C_old + A x B (with ‘this’ == A).
Parameters:
- nnz estimated number of P non-zeros per row ( with nnz[A nrows] ).
- lfil nnz[i]+lfil is the maximum number of non-zeros for the i-th row.
- nthreads number of threads to be used.
- B second factor matrix.
- C_old old reulting matrix.
- C_new reulting matrix to update.
- WN scratch.
function SoC_DiagDom
void SoC_DiagDom(
const bool Diag_Flag,
const rExt *__restrict__ Dr,
const rExt *__restrict__ Dc,
const rExt *__restrict__ TVnorm_r,
const rExt *__restrict__ TVnorm_c,
const bool TVnorm_FLAG,
const rExt __restrict__ tau_jump,
const rExt __restrict__ tau,
iReg *__restrict__ ind_SoC,
rExt *__restrict__ coef_SoC,
iExt & str_count
)
Computes SoC for a csr block B: SoC = coef_B / sqrt ( Dr * Dc ).
Parameters:
- B CSR block.
- Dr diagonal terms related to the row.
- Dc diagonal terms related to the column.
- tau tolerance for filtering.
- ind index of SoC (-1 if SoC < tau, 1 if SoC => tau).
function SoC_Classical
void SoC_Classical(
const bool Diag_Flag,
const rExt *__restrict__ aij_max,
const rExt *__restrict__ akj_max,
const rExt __restrict__ tau,
iReg *__restrict__ ind,
rExt *__restrict__ coef,
iExt & str_count
) const
Computes SoC for a csr block B: SoC = coef_B / sqrt ( Dr * Dc ).
Parameters:
- Diag_Flag flag for the diagonal CSR block.
- aij_max max off-diagonal terms for each row.
- tau tolerance for filtering.
- ind index of SoC (-1 if SoC < tau, 1 if SoC => tau).
- coef value of SoC.
- str_count SoC counter.
function SoC_DiagDom_tune
void SoC_DiagDom_tune(
const bool Diag_Flag,
const rExt *__restrict__ Dr,
const rExt *__restrict__ Dc,
const rExt *__restrict__ TVnorm_r,
const rExt *__restrict__ TVnorm_c,
const bool TVnorm_FLAG,
const rExt __restrict__ tau_jump,
iReg *__restrict__ ind_SoC,
rExt *__restrict__ coef_SoC,
const iReg __restrict__ nbins,
iExt *__restrict__ mybins
)
Computes SoC for a csr block B: SoC = coef_B / sqrt ( Dr * Dc ) and dynamically computes a value for tau leaving a given average number of connections per node.
Parameters:
- B CSR block.
- Dr diagonal terms related to the row.
- Dc diagonal terms related to the column.
- ind index of SoC (-1 if SoC < tau, 1 if SoC => tau).
function SoC_Affinity
void SoC_Affinity(
const bool Diag_Flag,
const rExt ZERO_nrm,
const iReg nTV,
const rExt *__restrict__ TVnorm_r,
const rExt *__restrict__ TVnorm_c,
const rExt *__restrict__ TV_r,
const rExt *__restrict__ TV_c,
const rExt __restrict__ tau_jump,
const rExt __restrict__ tau,
iReg *__restrict__ ind_SoC,
rExt *__restrict__ coef_SoC,
iExt & str_count
)
Computes SoC for a csr block B: SoC = coef_B / sqrt ( Dr * Dc ).
Parameters:
- B CSR block.
- Dr diagonal terms related to the row.
- Dc diagonal terms related to the column.
- tau tolerance for filtering.
- ind index of SoC (-1 if SoC < tau, 1 if SoC => tau).
function SoC_Affinity_tune
void SoC_Affinity_tune(
const bool Diag_Flag,
const rExt ZERO_nrm,
const iReg nTV,
const rExt *__restrict__ TVnorm_r,
const rExt *__restrict__ TVnorm_c,
const rExt *__restrict__ TV_r,
const rExt *__restrict__ TV_c,
const rExt __restrict__ tau_jump,
iReg *__restrict__ ind_SoC,
rExt *__restrict__ coef_SoC,
const iReg __restrict__ nbins,
iExt *__restrict__ mybins
)
Computes SoC for a csr block B: SoC = coef_B / sqrt ( Dr * Dc ) and dynamically computes a value for tau leaving a given average number of connections per node.
Parameters:
- B CSR block.
- Dr diagonal terms related to the row.
- Dc diagonal terms related to the column.
- ind index of SoC (-1 if SoC < tau, 1 if SoC => tau).
function SoC_Filter
void SoC_Filter(
const rExt __restrict__ tau,
iReg *__restrict__ ind,
rExt *__restrict__ coef,
iExt & str_count
)
Filters an already computed SoC for a csr block using a tolerance tau.
Updated on 12 February 2021 at 11:59:50 CET