SuperLU Distributed 8.2.1
Distributed memory sparse direct solver
dutil_dist.c File Reference

Several matrix utilities. More...

#include <math.h>
#include "superlu_ddefs.h"
Include dependency graph for dutil_dist.c:

Functions

 for (j=0;j< N;++j) for(i=0
 
 if (! L->Store)
 
void dCopy_CompRowLoc_Matrix_dist (SuperMatrix *A, SuperMatrix *B)
 
void dZero_CompRowLoc_Matrix_dist (SuperMatrix *A)
 Sets all entries of a matrix to zero, A_{i,j}=0, for i,j=1,..,n. More...
 
void dScaleAddId_CompRowLoc_Matrix_dist (SuperMatrix *A, double c)
 Scale and add I: scales a matrix and adds an identity. A_{i,j} = c * A_{i,j} + \delta_{i,j} for i,j=1,...,n and \delta_{i,j} is the Kronecker delta. More...
 
void dScaleAdd_CompRowLoc_Matrix_dist (SuperMatrix *A, SuperMatrix *B, double c)
 Scale and add: adds a scalar multiple of one matrix to another. A_{i,j} = c * A_{i,j} + B_{i,j}$ for i,j=1,...,n. More...
 
void dScalePermstructInit (const int_t m, const int_t n, dScalePermstruct_t *ScalePermstruct)
 Allocate storage in ScalePermstruct. More...
 
void dScalePermstructFree (dScalePermstruct_t *ScalePermstruct)
 Deallocate ScalePermstruct. More...
 
int dAllocGlu_3d (int_t n, int_t nsupers, dLUstruct_t *LUstruct)
 
int dDeAllocGlu_3d (dLUstruct_t *LUstruct)
 
int dDeAllocLlu_3d (int_t n, dLUstruct_t *LUstruct, gridinfo3d_t *grid3d)
 
void dGenXtrue_dist (int_t n, int_t nrhs, double *x, int_t ldx)
 
void dFillRHS_dist (char *trans, int_t nrhs, double *x, int_t ldx, SuperMatrix *A, double *rhs, int_t ldb)
 Let rhs[i] = sum of i-th row of A, so the solution vector is all 1's. More...
 
void dfill_dist (double *a, int_t alen, double dval)
 Fills a double precision array with a given value. More...
 
void dinf_norm_error_dist (int_t n, int_t nrhs, double *x, int_t ldx, double *xtrue, int_t ldxtrue, gridinfo_t *grid)
 Check the inf-norm of the error vector. More...
 
void Printdouble5 (char *name, int_t len, double *x)
 
int file_Printdouble5 (FILE *fp, char *name, int_t len, double *x)
 
void dPrintLblocks (int iam, int_t nsupers, gridinfo_t *grid, Glu_persist_t *Glu_persist, dLocalLU_t *Llu)
 Print the blocks in the factored matrix L. More...
 
void dZeroLblocks (int iam, int n, gridinfo_t *grid, dLUstruct_t *LUstruct)
 Sets all entries of matrix L to zero. More...
 
void dDumpLblocks (int iam, int_t nsupers, gridinfo_t *grid, Glu_persist_t *Glu_persist, dLocalLU_t *Llu)
 Dump the factored matrix L using matlab triple-let format. More...
 
void dComputeLevelsets (int iam, int_t nsupers, gridinfo_t *grid, Glu_persist_t *Glu_persist, dLocalLU_t *Llu, int_t *levels)
 
void dGenCOOLblocks (int iam, int_t nsupers, gridinfo_t *grid, Glu_persist_t *Glu_persist, dLocalLU_t *Llu, int_t **cooRows, int_t **cooCols, double **cooVals, int_t *n, int_t *nnzL)
 
void dGenCSCLblocks (int iam, int_t nsupers, gridinfo_t *grid, Glu_persist_t *Glu_persist, dLocalLU_t *Llu, double **nzval, int_t **rowind, int_t **colptr, int_t *n, int_t *nnzL)
 
void dGenCSRLblocks (int iam, int_t nsupers, gridinfo_t *grid, Glu_persist_t *Glu_persist, dLocalLU_t *Llu, double **nzval, int_t **colind, int_t **rowptr, int_t *n, int_t *nnzL)
 
void dPrintUblocks (int iam, int_t nsupers, gridinfo_t *grid, Glu_persist_t *Glu_persist, dLocalLU_t *Llu)
 Print the blocks in the factored matrix U. More...
 
void dZeroUblocks (int iam, int n, gridinfo_t *grid, dLUstruct_t *LUstruct)
 Sets all entries of matrix U to zero. More...
 
int dprint_gsmv_comm (FILE *fp, int_t m_loc, pdgsmv_comm_t *gsmv_comm, gridinfo_t *grid)
 
void dGenXtrueRHS (int nrhs, SuperMatrix *A, Glu_persist_t *Glu_persist, gridinfo_t *grid, double **xact, int *ldx, double **b, int *ldb)
 

Variables

int i
 
int j
 
i< M;++i) Y[i+j *ldy]=X[i+j *ldx];}voiddCreate_SuperNode_Matrix_dist(SuperMatrix *L, int_t m, int_t n, int_t nnz, double *nzval, int_t *nzval_colptr, int_t *rowind, int_t *rowind_colptr, int_t *col_to_sup, int_t *sup_to_col, Stype_t stype, Dtype_t dtype, Mtype_t mtype){ SCformat *Lstore;L-> Stype = stype
 
Dtype = dtype
 
Mtype = mtype
 
nrow = m
 
ncol = n
 
Store = (void *) SUPERLU_MALLOC( sizeof(SCformat) )
 

Detailed Description

Several matrix utilities.

Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy)

All rights reserved.

The source code is distributed under BSD license, see the file License.txt at the top-level directory.

   -- Distributed SuperLU routine (version 7.1.0) --
   Lawrence Berkeley National Lab, Univ. of California Berkeley.
   March 15, 2003
   October 5, 2021
 */




void
dCreate_CompCol_Matrix_dist(SuperMatrix *A, int_t m, int_t n, int_t nnz,
                double *nzval, int_t *rowind, int_t *colptr,
                Stype_t stype, Dtype_t dtype, Mtype_t mtype)
{
    NCformat *Astore;

    A->Stype = stype;
    A->Dtype = dtype;
    A->Mtype = mtype;
    A->nrow = m;
    A->ncol = n;
    A->Store = (void *) SUPERLU_MALLOC( sizeof(NCformat) );
    if ( !(A->Store) ) ABORT("SUPERLU_MALLOC fails for A->Store");
    Astore = (NCformat *) A->Store;
    Astore->nnz = nnz;
    Astore->nzval = nzval;
    Astore->rowind = rowind;
    Astore->colptr = colptr;
}

void
dCreate_CompRowLoc_Matrix_dist(SuperMatrix *A, int_t m, int_t n,
                   int_t nnz_loc, int_t m_loc, int_t fst_row,
                   double *nzval, int_t *colind, int_t *rowptr,
                   Stype_t stype, Dtype_t dtype, Mtype_t mtype)
{
    NRformat_loc *Astore;

    A->Stype = stype;
    A->Dtype = dtype;
    A->Mtype = mtype;
    A->nrow = m;
    A->ncol = n;
    A->Store = (void *) SUPERLU_MALLOC( sizeof(NRformat_loc) );
    if ( !(A->Store) ) ABORT("SUPERLU_MALLOC fails for A->Store");
    Astore = (NRformat_loc *) A->Store;
    Astore->nnz_loc = nnz_loc;
    Astore->fst_row = fst_row;
    Astore->m_loc = m_loc;
    Astore->nzval = nzval;
    Astore->colind = colind;
    Astore->rowptr = rowptr;
}

/*!
Convert a row compressed storage into a column compressed storage.
 */
void
dCompRow_to_CompCol_dist(int_t m, int_t n, int_t nnz,
                         double *a, int_t *colind, int_t *rowptr,
                         double **at, int_t **rowind, int_t **colptr)
{
    register int_t i, j, col, relpos;
    int_t *marker;

    /* Allocate storage for another copy of the matrix. */
    *at = (double *) doubleMalloc_dist(nnz);
    *rowind = intMalloc_dist(nnz);
    *colptr = intMalloc_dist(n+1);
    marker = intCalloc_dist(n);

    /* Get counts of each column of A, and set up column pointers */
    for (i = 0; i < m; ++i)
    for (j = rowptr[i]; j < rowptr[i+1]; ++j) ++marker[colind[j]];
    (*colptr)[0] = 0;
    for (j = 0; j < n; ++j) {
    (*colptr)[j+1] = (*colptr)[j] + marker[j];
    marker[j] = (*colptr)[j];
    }

    /* Transfer the matrix into the compressed column storage. */
    for (i = 0; i < m; ++i) {
    for (j = rowptr[i]; j < rowptr[i+1]; ++j) {
        col = colind[j];
        relpos = marker[col];
        (*rowind)[relpos] = i;
        (*at)[relpos] = a[j];
        ++marker[col];
    }
    }

    SUPERLU_FREE(marker);
}

/*!
Copy matrix A into matrix B. */
void
dCopy_CompCol_Matrix_dist(SuperMatrix *A, SuperMatrix *B)
{
    NCformat *Astore, *Bstore;
    int_t      ncol, nnz, i;

    B->Stype = A->Stype;
    B->Dtype = A->Dtype;
    B->Mtype = A->Mtype;
    B->nrow  = A->nrow;;
    B->ncol  = ncol = A->ncol;
    Astore   = (NCformat *) A->Store;
    Bstore   = (NCformat *) B->Store;
    Bstore->nnz = nnz = Astore->nnz;
    for (i = 0; i < nnz; ++i)
    ((double *)Bstore->nzval)[i] = ((double *)Astore->nzval)[i];
    for (i = 0; i < nnz; ++i) Bstore->rowind[i] = Astore->rowind[i];
    for (i = 0; i <= ncol; ++i) Bstore->colptr[i] = Astore->colptr[i];
}


void dPrint_CompCol_Matrix_dist(SuperMatrix *A)
{
    NCformat     *Astore;
    register int_t i;
    double       *dp;

    printf("\nCompCol matrix: ");
    printf("Stype %d, Dtype %d, Mtype %d\n", A->Stype,A->Dtype,A->Mtype);
    Astore = (NCformat *) A->Store;
    printf("nrow %lld, ncol %lld, nnz %lld\n", (long long) A->nrow,
        (long long) A->ncol, (long long) Astore->nnz);
    if ( (dp = (double *) Astore->nzval) != NULL ) {
        printf("nzval:\n");
        for (i = 0; i < Astore->nnz; ++i) printf("%f  ", dp[i]);
    }
    printf("\nrowind:\n");
    for (i = 0; i < Astore->nnz; ++i)
        printf("%lld  ", (long long) Astore->rowind[i]);
    printf("\ncolptr:\n");
    for (i = 0; i <= A->ncol; ++i)
        printf("%lld  ", (long long) Astore->colptr[i]);
    printf("\nend CompCol matrix.\n");
}

void dPrint_Dense_Matrix_dist(SuperMatrix *A)
{
    DNformat     *Astore;
    register int_t i;
    double       *dp;

    printf("\nDense matrix: ");
    printf("Stype %d, Dtype %d, Mtype %d\n", A->Stype,A->Dtype,A->Mtype);
    Astore = (DNformat *) A->Store;
    dp = (double *) Astore->nzval;
    printf("nrow %lld, ncol %lld, lda %lld\n",
        (long long) A->nrow, (long long) A->ncol, (long long) Astore->lda);
    printf("\nnzval: ");
    for (i = 0; i < A->nrow; ++i) printf("%f  ", dp[i]);
    printf("\nend Dense matrix.\n");
}

int dPrint_CompRowLoc_Matrix_dist(SuperMatrix *A)
{
    NRformat_loc  *Astore;
    int_t  nnz_loc, m_loc;
    double  *dp;

    printf("\n==== CompRowLoc matrix: ");
    printf("Stype %d, Dtype %d, Mtype %d\n", A->Stype,A->Dtype,A->Mtype);
    Astore = (NRformat_loc *) A->Store;
    printf("nrow %ld, ncol %ld\n",
            (long int) A->nrow, (long int) A->ncol);
    nnz_loc = Astore->nnz_loc; m_loc = Astore->m_loc;
    printf("nnz_loc %ld, m_loc %ld, fst_row %ld\n", (long int) nnz_loc,
            (long int) m_loc, (long int) Astore->fst_row);
    PrintInt10("rowptr", m_loc+1, Astore->rowptr);
    PrintInt10("colind", nnz_loc, Astore->colind);
    if ( (dp = (double *) Astore->nzval) != NULL )
        Printdouble5("nzval", nnz_loc, dp);
    printf("==== end CompRowLoc matrix\n");
    return 0;
}

int file_dPrint_CompRowLoc_Matrix_dist(FILE *fp, SuperMatrix *A)
{
    NRformat_loc     *Astore;
    int_t  nnz_loc, m_loc;
    double       *dp;

    fprintf(fp, "\n==== CompRowLoc matrix: ");
    fprintf(fp, "Stype %d, Dtype %d, Mtype %d\n", A->Stype,A->Dtype,A->Mtype);
    Astore = (NRformat_loc *) A->Store;
    fprintf(fp, "nrow %ld, ncol %ld\n", (long int) A->nrow, (long int) A->ncol);
    nnz_loc = Astore->nnz_loc; m_loc = Astore->m_loc;
    fprintf(fp, "nnz_loc %ld, m_loc %ld, fst_row %ld\n", (long int) nnz_loc,
            (long int) m_loc, (long int) Astore->fst_row);
    file_PrintInt10(fp, "rowptr", m_loc+1, Astore->rowptr);
    file_PrintInt10(fp, "colind", nnz_loc, Astore->colind);
    if ( (dp = (double *) Astore->nzval) != NULL )
        file_Printdouble5(fp, "nzval", nnz_loc, dp);
    fprintf(fp, "==== end CompRowLoc matrix\n");
    return 0;
}

void
dCreate_Dense_Matrix_dist(SuperMatrix *X, int_t m, int_t n, double *x,
              int_t ldx, Stype_t stype, Dtype_t dtype,
              Mtype_t mtype)
{
    DNformat    *Xstore;

    X->Stype = stype;
    X->Dtype = dtype;
    X->Mtype = mtype;
    X->nrow = m;
    X->ncol = n;
    X->Store = (void *) SUPERLU_MALLOC( sizeof(DNformat) );
    if ( !(X->Store) ) ABORT("SUPERLU_MALLOC fails for X->Store");
    Xstore = (DNformat *) X->Store;
    Xstore->lda = ldx;
    Xstore->nzval = (double *) x;
}

void
dCopy_Dense_Matrix_dist(int_t M, int_t N, double *X, int_t ldx,
            double *Y, int_t ldy)
{
/*!


   
    Purpose
    =======

    Copies a two-dimensional matrix X to another matrix Y.
   

Function Documentation

◆ dAllocGlu_3d()

int dAllocGlu_3d ( int_t  n,
int_t  nsupers,
dLUstruct_t LUstruct 
)
Here is the call graph for this function:

◆ dComputeLevelsets()

void dComputeLevelsets ( int  iam,
int_t  nsupers,
gridinfo_t grid,
Glu_persist_t Glu_persist,
dLocalLU_t Llu,
int_t levels 
)

\Compute the level sets in the L factor

◆ dCopy_CompRowLoc_Matrix_dist()

void dCopy_CompRowLoc_Matrix_dist ( SuperMatrix A,
SuperMatrix B 
)

◆ dDeAllocGlu_3d()

int dDeAllocGlu_3d ( dLUstruct_t LUstruct)

◆ dDeAllocLlu_3d()

int dDeAllocLlu_3d ( int_t  n,
dLUstruct_t LUstruct,
gridinfo3d_t grid3d 
)

◆ dDumpLblocks()

void dDumpLblocks ( int  iam,
int_t  nsupers,
gridinfo_t grid,
Glu_persist_t Glu_persist,
dLocalLU_t Llu 
)

Dump the factored matrix L using matlab triple-let format.

◆ dfill_dist()

void dfill_dist ( double *  a,
int_t  alen,
double  dval 
)

Fills a double precision array with a given value.

◆ dFillRHS_dist()

void dFillRHS_dist ( char *  trans,
int_t  nrhs,
double *  x,
int_t  ldx,
SuperMatrix A,
double *  rhs,
int_t  ldb 
)

Let rhs[i] = sum of i-th row of A, so the solution vector is all 1's.

Here is the call graph for this function:

◆ dGenCOOLblocks()

void dGenCOOLblocks ( int  iam,
int_t  nsupers,
gridinfo_t grid,
Glu_persist_t Glu_persist,
dLocalLU_t Llu,
int_t **  cooRows,
int_t **  cooCols,
double **  cooVals,
int_t n,
int_t nnzL 
)

\Dump the factored matrix L using matlab triple-let format

◆ dGenCSCLblocks()

void dGenCSCLblocks ( int  iam,
int_t  nsupers,
gridinfo_t grid,
Glu_persist_t Glu_persist,
dLocalLU_t Llu,
double **  nzval,
int_t **  rowind,
int_t **  colptr,
int_t n,
int_t nnzL 
)

\Dump the factored matrix L using CSC format

Here is the call graph for this function:

◆ dGenCSRLblocks()

void dGenCSRLblocks ( int  iam,
int_t  nsupers,
gridinfo_t grid,
Glu_persist_t Glu_persist,
dLocalLU_t Llu,
double **  nzval,
int_t **  colind,
int_t **  rowptr,
int_t n,
int_t nnzL 
)

\Dump the factored matrix L using CSR format

Here is the call graph for this function:

◆ dGenXtrue_dist()

void dGenXtrue_dist ( int_t  n,
int_t  nrhs,
double *  x,
int_t  ldx 
)

◆ dGenXtrueRHS()

void dGenXtrueRHS ( int  nrhs,
SuperMatrix A,
Glu_persist_t Glu_persist,
gridinfo_t grid,
double **  xact,
int *  ldx,
double **  b,
int *  ldb 
)
Here is the call graph for this function:

◆ dinf_norm_error_dist()

void dinf_norm_error_dist ( int_t  n,
int_t  nrhs,
double *  x,
int_t  ldx,
double *  xtrue,
int_t  ldxtrue,
gridinfo_t grid 
)

Check the inf-norm of the error vector.

◆ dprint_gsmv_comm()

int dprint_gsmv_comm ( FILE *  fp,
int_t  m_loc,
pdgsmv_comm_t gsmv_comm,
gridinfo_t grid 
)
Here is the call graph for this function:

◆ dPrintLblocks()

void dPrintLblocks ( int  iam,
int_t  nsupers,
gridinfo_t grid,
Glu_persist_t Glu_persist,
dLocalLU_t Llu 
)

Print the blocks in the factored matrix L.

Here is the call graph for this function:

◆ dPrintUblocks()

void dPrintUblocks ( int  iam,
int_t  nsupers,
gridinfo_t grid,
Glu_persist_t Glu_persist,
dLocalLU_t Llu 
)

Print the blocks in the factored matrix U.

Here is the call graph for this function:

◆ dScaleAdd_CompRowLoc_Matrix_dist()

void dScaleAdd_CompRowLoc_Matrix_dist ( SuperMatrix A,
SuperMatrix B,
double  c 
)

Scale and add: adds a scalar multiple of one matrix to another. A_{i,j} = c * A_{i,j} + B_{i,j}$ for i,j=1,...,n.

◆ dScaleAddId_CompRowLoc_Matrix_dist()

void dScaleAddId_CompRowLoc_Matrix_dist ( SuperMatrix A,
double  c 
)

Scale and add I: scales a matrix and adds an identity. A_{i,j} = c * A_{i,j} + \delta_{i,j} for i,j=1,...,n and \delta_{i,j} is the Kronecker delta.

Here is the call graph for this function:

◆ dScalePermstructFree()

void dScalePermstructFree ( dScalePermstruct_t ScalePermstruct)

Deallocate ScalePermstruct.

◆ dScalePermstructInit()

void dScalePermstructInit ( const int_t  m,
const int_t  n,
dScalePermstruct_t ScalePermstruct 
)

Allocate storage in ScalePermstruct.

Here is the call graph for this function:

◆ dZero_CompRowLoc_Matrix_dist()

void dZero_CompRowLoc_Matrix_dist ( SuperMatrix A)

Sets all entries of a matrix to zero, A_{i,j}=0, for i,j=1,..,n.

Here is the call graph for this function:

◆ dZeroLblocks()

void dZeroLblocks ( int  iam,
int  n,
gridinfo_t grid,
dLUstruct_t LUstruct 
)

Sets all entries of matrix L to zero.

◆ dZeroUblocks()

void dZeroUblocks ( int  iam,
int  n,
gridinfo_t grid,
dLUstruct_t LUstruct 
)

Sets all entries of matrix U to zero.

◆ file_Printdouble5()

int file_Printdouble5 ( FILE *  fp,
char *  name,
int_t  len,
double *  x 
)

◆ for()

for ( )
pure virtual

◆ if()

if ( L->Store)

◆ Printdouble5()

void Printdouble5 ( char *  name,
int_t  len,
double *  x 
)

Variable Documentation

◆ Dtype

L Dtype = dtype

◆ i

int i

◆ j

int j

◆ Mtype

L Mtype = mtype

◆ ncol

L ncol = n

◆ nrow

L nrow = m

◆ Store

L Store = (void *) SUPERLU_MALLOC( sizeof(SCformat) )

◆ Stype

i< M; ++i) Y[i + j*ldy] = X[i + j*ldx];}voiddCreate_SuperNode_Matrix_dist(SuperMatrix *L, int_t m, int_t n, int_t nnz, double *nzval, int_t *nzval_colptr, int_t *rowind, int_t *rowind_colptr, int_t *col_to_sup, int_t *sup_to_col, Stype_t stype, Dtype_t dtype, Mtype_t mtype){ SCformat *Lstore; L-> Stype = stype