SpM Handbook 1.2.4
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
d_spm_norm.c File Reference
#include "common.h"
#include <lapacke.h>
#include <cblas.h>
#include "frobeniusupdate.h"

Go to the source code of this file.

#define LAPACKE_dlassq_work(_n_, _X_, _incx_, _scale_, _sumsq_)    __spm_dlassq( (_n_), (_X_), (_incx_), (_scale_), (_sumsq_) )
 TODO.
 
static int __spm_dlassq (spm_int_t n, double *x, spm_int_t incx, double *scale, double *sumsq)
 Updates the values scale and sumsq such that.
 
static void d_spm_frobenius_elt_sym_diag (spm_int_t dofs, const double *valptr, double *data)
 Compute the Frobenius norm of a diagonal element within a symmetric/symmetric matrix with column/row major storage.
 
static void d_spm_frobenius_elt_sym_offd (spm_int_t nbelts, const double *valptr, double *data)
 Compute the Frobenius norm of an off-diagonal element matrix in the symmetric/symmetric case.
 
static void d_spm_frobenius_elt_sym (spm_int_t row, spm_int_t dofi, spm_int_t col, spm_int_t dofj, const double *valptr, double *data)
 Compute the Frobenius norm of any element matrix in the symmetric/symmetric case.
 
static void d_spmFrobeniusNorm_csc (const spmatrix_t *spm, double *data)
 Compute the Frobenius norm of a symmetrix/symmetric CSC matrix.
 
static void d_spmFrobeniusNorm_csr (const spmatrix_t *spm, double *data)
 Compute the Frobenius norm of a symmetrix/symmetric CSR matrix.
 
static void d_spmFrobeniusNorm_ijv (const spmatrix_t *spm, double *data)
 Compute the Frobenius norm of a symmetrix/symmetric IJV matrix.
 
double d_spmFrobeniusNorm (const spmatrix_t *spm)
 Compute the Frobenius norm of the given spm structure.
 
double d_spmMaxNorm (const spmatrix_t *spm)
 Compute the Max norm of the given spm structure.
 
static void d_spm_oneinf_elt_sym_diag (spm_int_t row, spm_int_t dofi, const double *valptr, double *sumtab)
 Compute the sum array for the one/inf norms of a diagonal element within a symmetric/symmetric matrix with column/row major storage.
 
static void d_spm_oneinf_elt_gen_A (spm_int_t dofi, spm_int_t dofj, const double *valptr, double *sumtab)
 Compute the sum array for the one/inf norms of a general element.
 
static void d_spm_oneinf_elt_gen_B (spm_int_t dofi, spm_int_t dofj, const double *valptr, double *sumtab)
 Compute the sum array for the one/inf norms of a general element.
 
static void d_spm_oneinf_elt_gen_AB (spm_int_t row, spm_int_t dofi, spm_int_t col, spm_int_t dofj, const double *valptr, double *sumtab)
 Compute the sum array for both the one and inf norms for the off-diagonal elements of symmetric/symmetric element matrices.
 
static void d_spm_oneinf_elt_gen (spm_layout_t layout, spm_int_t row, spm_int_t dofi, spm_int_t col, spm_int_t dofj, const double *valptr, spm_normtype_t ntype, double *sumtab)
 Compute the sum array for the one and inf norms of a general element.
 
static void d_spm_oneinf_elt_sym_offd (spm_layout_t layout, spm_int_t row, spm_int_t dofi, spm_int_t col, spm_int_t dofj, const double *valptr, double *sumtab)
 Compute the sum array for both the one and inf norms for the off-diagonal elements of symmetric/symmetric element matrices in either column or row major layout.
 
static void d_spm_oneinf_elt (spm_mtxtype_t mtxtype, spm_layout_t layout, spm_int_t row, spm_int_t dofi, spm_int_t col, spm_int_t dofj, const double *valptr, spm_normtype_t ntype, double *sumtab)
 Compute the sum array for the one/inf norm for an element matrix.
 
static void d_spmOneInfNorm_csc (spm_normtype_t ntype, const spmatrix_t *spm, double *sumtab)
 Compute the one/inf norm of an spm CSC structure.
 
static void d_spmOneInfNorm_csr (spm_normtype_t ntype, const spmatrix_t *spm, double *sumtab)
 Compute the one/inf norm of an spm CSR structure.
 
static void d_spmOneInfNorm_ijv (spm_normtype_t ntype, const spmatrix_t *spm, double *sumtab)
 Compute the one/inf norm of an spm IJV structure.
 
static double d_spmOneInfNorm (spm_normtype_t ntype, const spmatrix_t *spm)
 Compute the one/inf norm of the given spm structure given by the maximum row sum.
 
double d_spmNorm (spm_normtype_t ntype, const spmatrix_t *spm)
 Compute the norm of an spm matrix.
 
double d_spmNormMat (spm_normtype_t ntype, const spmatrix_t *spm, spm_int_t n, const double *A, spm_int_t lda)
 Compute the norm of a dense matrix that follows the distribution of an spm matrix.
 

Detailed Description

SParse Matrix package norm routine.

Version
1.2.4
Author
Mathieu Faverge
Pierre Ramet
Tony Delarue
Matias Hastaran
Alycia Lisito
Date
2024-06-25
Generated arithmetic file from /builds/2mk6rsew/0/fpruvost/spm/src/z_spm_norm.c, normal z -> d, Fri Nov 29 11:34:29 2024

Definition in file d_spm_norm.c.

Macro Definition Documentation

◆ LAPACKE_dlassq_work

#define LAPACKE_dlassq_work (   _n_,
  _X_,
  _incx_,
  _scale_,
  _sumsq_ 
)     __spm_dlassq( (_n_), (_X_), (_incx_), (_scale_), (_sumsq_) )

TODO.

Definition at line 88 of file d_spm_norm.c.

Function Documentation

◆ __spm_dlassq()

static int __spm_dlassq ( spm_int_t  n,
double *  x,
spm_int_t  incx,
double *  scale,
double *  sumsq 
)
static

Updates the values scale and sumsq such that.

( scale**2 )*sumsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq,

This routine is inspired from LAPACK dlassq function.

Parameters
[in]nThe number of elements in the vector
[in]xThe vector of size abs(n * incx)
[in]incxThe increment between two elements in the vector x.
[in,out]scaleOn entry, the former scale On exit, the update scale to take into account the value
[in,out]sumsqOn entry, the former sumsq On exit, the update sumsq to take into account the value
Returns
SPM_SUCESS to match the prototype of LAPACKE_dlassq_work

Definition at line 63 of file d_spm_norm.c.

◆ d_spm_frobenius_elt_sym_diag()

static void d_spm_frobenius_elt_sym_diag ( spm_int_t  dofs,
const double *  valptr,
double *  data 
)
static

Compute the Frobenius norm of a diagonal element within a symmetric/symmetric matrix with column/row major storage.

Note that column major is using the low triangular part only of the diagonal element matrices, and row major, by symmetry, is using only the upper triangular part.

The comments in the code are made for column major storage.

Parameters
[in]dofsTODO
[in]valptrTODO
[in,out]dataTODO

Definition at line 152 of file d_spm_norm.c.

Referenced by d_spm_frobenius_elt_sym().

◆ d_spm_frobenius_elt_sym_offd()

static void d_spm_frobenius_elt_sym_offd ( spm_int_t  nbelts,
const double *  valptr,
double *  data 
)
static

Compute the Frobenius norm of an off-diagonal element matrix in the symmetric/symmetric case.

Parameters
[in]nbeltsTODO
[in]valptrTODO
[in,out]data

Definition at line 206 of file d_spm_norm.c.

Referenced by d_spm_frobenius_elt_sym().

◆ d_spm_frobenius_elt_sym()

static void d_spm_frobenius_elt_sym ( spm_int_t  row,
spm_int_t  dofi,
spm_int_t  col,
spm_int_t  dofj,
const double *  valptr,
double *  data 
)
static

Compute the Frobenius norm of any element matrix in the symmetric/symmetric case.

Parameters
[in]rowTODO
[in]dofiTODO
[in]colTODO
[in]dofjTODO
[in]valptrTODO
[in,out]dataTODO

Definition at line 252 of file d_spm_norm.c.

References d_spm_frobenius_elt_sym_diag(), and d_spm_frobenius_elt_sym_offd().

Referenced by d_spmFrobeniusNorm_csc(), d_spmFrobeniusNorm_csr(), and d_spmFrobeniusNorm_ijv().

◆ d_spmFrobeniusNorm_csc()

static void d_spmFrobeniusNorm_csc ( const spmatrix_t spm,
double *  data 
)
static

Compute the Frobenius norm of a symmetrix/symmetric CSC matrix.

Parameters
[in]spmThe spm from which the norm need to be computed.
[in,out]dataTODO

Definition at line 283 of file d_spm_norm.c.

References spmatrix_s::baseval, spmatrix_s::colptr, d_spm_frobenius_elt_sym(), spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::flttype, spmatrix_s::fmttype, spmatrix_s::loc2glob, spmatrix_s::n, spmatrix_s::replicated, spmatrix_s::rowptr, SpmCSC, SpmDouble, and spmatrix_s::values.

Referenced by d_spmFrobeniusNorm().

◆ d_spmFrobeniusNorm_csr()

static void d_spmFrobeniusNorm_csr ( const spmatrix_t spm,
double *  data 
)
static

Compute the Frobenius norm of a symmetrix/symmetric CSR matrix.

Parameters
[in]spmThe spm from which the norm need to be computed.
[in,out]dataTODO

Definition at line 350 of file d_spm_norm.c.

References spmatrix_s::baseval, spmatrix_s::colptr, d_spm_frobenius_elt_sym(), spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::flttype, spmatrix_s::fmttype, spmatrix_s::loc2glob, spmatrix_s::n, spmatrix_s::replicated, spmatrix_s::rowptr, SpmCSR, SpmDouble, and spmatrix_s::values.

Referenced by d_spmFrobeniusNorm().

◆ d_spmFrobeniusNorm_ijv()

static void d_spmFrobeniusNorm_ijv ( const spmatrix_t spm,
double *  data 
)
static

Compute the Frobenius norm of a symmetrix/symmetric IJV matrix.

Parameters
[in]spmThe spm from which the norm need to be computed.
[in,out]dataTODO

Definition at line 418 of file d_spm_norm.c.

References spmatrix_s::baseval, spmatrix_s::colptr, d_spm_frobenius_elt_sym(), spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::flttype, spmatrix_s::fmttype, spmatrix_s::nnz, spmatrix_s::rowptr, SpmDouble, SpmIJV, and spmatrix_s::values.

Referenced by d_spmFrobeniusNorm().

◆ d_spmFrobeniusNorm()

double d_spmFrobeniusNorm ( const spmatrix_t spm)

Compute the Frobenius norm of the given spm structure.

||A|| = sqrt( sum( a_ij ^ 2 ) )

Parameters
[in]spmThe spm from which the norm need to be computed.
Returns
The computed frobenius norm

Definition at line 480 of file d_spm_norm.c.

References spmatrix_s::clustnbr, spmatrix_s::comm, d_spmFrobeniusNorm_csc(), d_spmFrobeniusNorm_csr(), d_spmFrobeniusNorm_ijv(), spmatrix_s::fmttype, spmatrix_s::mtxtype, spmatrix_s::nnzexp, spmatrix_s::replicated, SpmCSC, SpmCSR, SpmGeneral, SpmIJV, and spmatrix_s::values.

Referenced by d_spmNorm().

◆ d_spmMaxNorm()

double d_spmMaxNorm ( const spmatrix_t spm)

Compute the Max norm of the given spm structure.

||A|| = max( abs(a_ij) )

Parameters
[in]spmThe spm from which the norm need to be computed.
Returns
The computed max norm

Definition at line 543 of file d_spm_norm.c.

References spmatrix_s::clustnbr, spmatrix_s::comm, spmatrix_s::nnzexp, spmatrix_s::replicated, and spmatrix_s::values.

Referenced by d_spmNorm().

◆ d_spm_oneinf_elt_sym_diag()

static void d_spm_oneinf_elt_sym_diag ( spm_int_t  row,
spm_int_t  dofi,
const double *  valptr,
double *  sumtab 
)
static

Compute the sum array for the one/inf norms of a diagonal element within a symmetric/symmetric matrix with column/row major storage.

Note that column major is using the low triangular part only of the diagonal element matrices, and row major, by symmetry, is using only the upper triangular part.

The comments in the code are made for column major storage.

Parameters
[in]rowTODO
[in]dofiTODO
[in]valptrTODO
[in,out]sumtabTODO

Definition at line 591 of file d_spm_norm.c.

Referenced by d_spm_oneinf_elt().

◆ d_spm_oneinf_elt_gen_A()

static void d_spm_oneinf_elt_gen_A ( spm_int_t  dofi,
spm_int_t  dofj,
const double *  valptr,
double *  sumtab 
)
static

Compute the sum array for the one/inf norms of a general element.

We can observe two cases A and B;


| | | | | | |________| | | | | | | |A| OR |________| |B| |__|__|__| |_| |________| |_|


|___B____| |___A____|

          | One Norm | Inf norm |

----------—+-------—+-------—+ Column Major | B | A | ----------—+-------—+-------—+ Row Major | A | B | ----------—+-------—+-------—+

Warning
: The sumtab must be shifted at the right place on input
Parameters
[in]dofiTODO
[in]dofjTODO
[in]valptrTODO
[in,out]sumtabTODO

Definition at line 659 of file d_spm_norm.c.

Referenced by d_spm_oneinf_elt_gen().

◆ d_spm_oneinf_elt_gen_B()

static void d_spm_oneinf_elt_gen_B ( spm_int_t  dofi,
spm_int_t  dofj,
const double *  valptr,
double *  sumtab 
)
static

Compute the sum array for the one/inf norms of a general element.

See d_spm_oneinf_elt_gen_A()

Parameters
[in]dofiTODO
[in]dofjTODO
[in]valptrTODO
[in,out]sumtabTODO

Definition at line 698 of file d_spm_norm.c.

Referenced by d_spm_oneinf_elt_gen().

◆ d_spm_oneinf_elt_gen_AB()

static void d_spm_oneinf_elt_gen_AB ( spm_int_t  row,
spm_int_t  dofi,
spm_int_t  col,
spm_int_t  dofj,
const double *  valptr,
double *  sumtab 
)
static

Compute the sum array for both the one and inf norms for the off-diagonal elements of symmetric/symmetric element matrices.

See d_spm_oneinf_elt_gen_A()

Parameters
[in]rowTODO
[in]dofiTODO
[in]colTODO
[in]dofjTODO
[in]valptrTODO
[in,out]sumtabTODO

Definition at line 744 of file d_spm_norm.c.

Referenced by d_spm_oneinf_elt_sym_offd().

◆ d_spm_oneinf_elt_gen()

static void d_spm_oneinf_elt_gen ( spm_layout_t  layout,
spm_int_t  row,
spm_int_t  dofi,
spm_int_t  col,
spm_int_t  dofj,
const double *  valptr,
spm_normtype_t  ntype,
double *  sumtab 
)
static

Compute the sum array for the one and inf norms of a general element.

Parameters
[in]layoutTODO
[in]rowTODO
[in]dofiTODO
[in]colTODO
[in]dofjTODO
[in]valptrTODO
[in]ntypeTODO
[in,out]sumtabTODO

Definition at line 799 of file d_spm_norm.c.

References d_spm_oneinf_elt_gen_A(), d_spm_oneinf_elt_gen_B(), SpmColMajor, SpmInfNorm, and SpmOneNorm.

Referenced by d_spm_oneinf_elt().

◆ d_spm_oneinf_elt_sym_offd()

static void d_spm_oneinf_elt_sym_offd ( spm_layout_t  layout,
spm_int_t  row,
spm_int_t  dofi,
spm_int_t  col,
spm_int_t  dofj,
const double *  valptr,
double *  sumtab 
)
static

Compute the sum array for both the one and inf norms for the off-diagonal elements of symmetric/symmetric element matrices in either column or row major layout.

Parameters
[in]layoutTODO
[in]rowTODO
[in]dofiTODO
[in]colTODO
[in]dofjTODO
[in]valptrTODO
[in,out]sumtabTODO

Definition at line 860 of file d_spm_norm.c.

References d_spm_oneinf_elt_gen_AB(), and SpmColMajor.

Referenced by d_spm_oneinf_elt().

◆ d_spm_oneinf_elt()

static void d_spm_oneinf_elt ( spm_mtxtype_t  mtxtype,
spm_layout_t  layout,
spm_int_t  row,
spm_int_t  dofi,
spm_int_t  col,
spm_int_t  dofj,
const double *  valptr,
spm_normtype_t  ntype,
double *  sumtab 
)
static

Compute the sum array for the one/inf norm for an element matrix.

Parameters
[in]mtxtypeTODO
[in]layoutTODO
[in]rowTODO
[in]dofiTODO
[in]colTODO
[in]dofjTODO
[in]valptrTODO
[in]ntypeTODO
[in,out]sumtabTODO

Definition at line 912 of file d_spm_norm.c.

References d_spm_oneinf_elt_gen(), d_spm_oneinf_elt_sym_diag(), d_spm_oneinf_elt_sym_offd(), and SpmGeneral.

Referenced by d_spmOneInfNorm_csc(), d_spmOneInfNorm_csr(), and d_spmOneInfNorm_ijv().

◆ d_spmOneInfNorm_csc()

static void d_spmOneInfNorm_csc ( spm_normtype_t  ntype,
const spmatrix_t spm,
double *  sumtab 
)
static

Compute the one/inf norm of an spm CSC structure.

Parameters
[in]ntypeTODO
[in]spmTODO
[in,out]sumtabTODO

Definition at line 953 of file d_spm_norm.c.

References spmatrix_s::baseval, spmatrix_s::colptr, d_spm_oneinf_elt(), spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::layout, spmatrix_s::loc2glob, spmatrix_s::mtxtype, spmatrix_s::n, spmatrix_s::replicated, spmatrix_s::rowptr, and spmatrix_s::values.

Referenced by d_spmOneInfNorm().

◆ d_spmOneInfNorm_csr()

static void d_spmOneInfNorm_csr ( spm_normtype_t  ntype,
const spmatrix_t spm,
double *  sumtab 
)
static

Compute the one/inf norm of an spm CSR structure.

Parameters
[in]ntypeTODO
[in]spmTODO
[in,out]sumtabTODO

Definition at line 1019 of file d_spm_norm.c.

References spmatrix_s::baseval, spmatrix_s::colptr, d_spm_oneinf_elt(), spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::layout, spmatrix_s::loc2glob, spmatrix_s::mtxtype, spmatrix_s::n, spmatrix_s::replicated, spmatrix_s::rowptr, and spmatrix_s::values.

Referenced by d_spmOneInfNorm().

◆ d_spmOneInfNorm_ijv()

static void d_spmOneInfNorm_ijv ( spm_normtype_t  ntype,
const spmatrix_t spm,
double *  sumtab 
)
static

Compute the one/inf norm of an spm IJV structure.

Parameters
[in]ntypeTODO
[in]spmTODO
[in,out]sumtabTODO

Definition at line 1085 of file d_spm_norm.c.

References spmatrix_s::baseval, spmatrix_s::colptr, d_spm_oneinf_elt(), spmatrix_s::dof, spmatrix_s::dofs, spmatrix_s::layout, spmatrix_s::mtxtype, spmatrix_s::nnz, spmatrix_s::rowptr, and spmatrix_s::values.

Referenced by d_spmOneInfNorm().

◆ d_spmOneInfNorm()

static double d_spmOneInfNorm ( spm_normtype_t  ntype,
const spmatrix_t spm 
)
static

Compute the one/inf norm of the given spm structure given by the maximum row sum.

  • SpmOneNorm: ||A|| = max_j( sum_i(|a_ij|) )
  • SpmInfNorm: ||A|| = max_i( sum_j(|a_ij|) )
Parameters
[in]ntypeThe type of norm to compute.
[in]spmThe spm from which the norm need to be computed.
Returns
The computed one norm

Definition at line 1149 of file d_spm_norm.c.

References spmatrix_s::clustnbr, spmatrix_s::comm, d_spmOneInfNorm_csc(), d_spmOneInfNorm_csr(), d_spmOneInfNorm_ijv(), spmatrix_s::fmttype, spmatrix_s::gNexp, spmatrix_s::replicated, SpmCSC, SpmCSR, and SpmIJV.

Referenced by d_spmNorm().