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

Several matrix utilities. More...

#include <math.h>
#include "superlu_zdefs.h"
Include dependency graph for zutil_dist.c:

Functions

 for (j=0;j< N;++j) for(i=0
 
 if (! L->Store)
 
void zCopy_CompRowLoc_Matrix_dist (SuperMatrix *A, SuperMatrix *B)
 
void zZero_CompRowLoc_Matrix_dist (SuperMatrix *A)
 Sets all entries of a matrix to zero, A_{i,j}=0, for i,j=1,..,n. More...
 
void zScaleAddId_CompRowLoc_Matrix_dist (SuperMatrix *A, doublecomplex 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 zScaleAdd_CompRowLoc_Matrix_dist (SuperMatrix *A, SuperMatrix *B, doublecomplex 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 zScalePermstructInit (const int_t m, const int_t n, zScalePermstruct_t *ScalePermstruct)
 Allocate storage in ScalePermstruct. More...
 
void zScalePermstructFree (zScalePermstruct_t *ScalePermstruct)
 Deallocate ScalePermstruct. More...
 
int zAllocGlu_3d (int_t n, int_t nsupers, zLUstruct_t *LUstruct)
 
int zDeAllocGlu_3d (zLUstruct_t *LUstruct)
 
int zDeAllocLlu_3d (int_t n, zLUstruct_t *LUstruct, gridinfo3d_t *grid3d)
 
void zGenXtrue_dist (int_t n, int_t nrhs, doublecomplex *x, int_t ldx)
 
void zFillRHS_dist (char *trans, int_t nrhs, doublecomplex *x, int_t ldx, SuperMatrix *A, doublecomplex *rhs, int_t ldb)
 Let rhs[i] = sum of i-th row of A, so the solution vector is all 1's. More...
 
void zfill_dist (doublecomplex *a, int_t alen, doublecomplex dval)
 Fills a doublecomplex precision array with a given value. More...
 
void zinf_norm_error_dist (int_t n, int_t nrhs, doublecomplex *x, int_t ldx, doublecomplex *xtrue, int_t ldxtrue, gridinfo_t *grid)
 Check the inf-norm of the error vector. More...
 
void PrintDoublecomplex (char *name, int_t len, doublecomplex *x)
 
int file_PrintDoublecomplex (FILE *fp, char *name, int_t len, doublecomplex *x)
 
void zPrintLblocks (int iam, int_t nsupers, gridinfo_t *grid, Glu_persist_t *Glu_persist, zLocalLU_t *Llu)
 Print the blocks in the factored matrix L. More...
 
void zZeroLblocks (int iam, int n, gridinfo_t *grid, zLUstruct_t *LUstruct)
 Sets all entries of matrix L to zero. More...
 
void zDumpLblocks (int iam, int_t nsupers, gridinfo_t *grid, Glu_persist_t *Glu_persist, zLocalLU_t *Llu)
 Dump the factored matrix L using matlab triple-let format. More...
 
void zPrintUblocks (int iam, int_t nsupers, gridinfo_t *grid, Glu_persist_t *Glu_persist, zLocalLU_t *Llu)
 Print the blocks in the factored matrix U. More...
 
void zZeroUblocks (int iam, int n, gridinfo_t *grid, zLUstruct_t *LUstruct)
 Sets all entries of matrix U to zero. More...
 
int zprint_gsmv_comm (FILE *fp, int_t m_loc, pzgsmv_comm_t *gsmv_comm, gridinfo_t *grid)
 

Variables

int i
 
int j
 
i< M;++i) Y[i+j *ldy]=X[i+j *ldx];}voidzCreate_SuperNode_Matrix_dist(SuperMatrix *L, int_t m, int_t n, int_t nnz, doublecomplex *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
zCreate_CompCol_Matrix_dist(SuperMatrix *A, int_t m, int_t n, int_t nnz,
                doublecomplex *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
zCreate_CompRowLoc_Matrix_dist(SuperMatrix *A, int_t m, int_t n,
                   int_t nnz_loc, int_t m_loc, int_t fst_row,
                   doublecomplex *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
zCompRow_to_CompCol_dist(int_t m, int_t n, int_t nnz,
                         doublecomplex *a, int_t *colind, int_t *rowptr,
                         doublecomplex **at, int_t **rowind, int_t **colptr)
{
    register int i, j, col, relpos;
    int_t *marker;

    /* Allocate storage for another copy of the matrix. */
    *at = (doublecomplex *) doublecomplexMalloc_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
zCopy_CompCol_Matrix_dist(SuperMatrix *A, SuperMatrix *B)
{
    NCformat *Astore, *Bstore;
    int      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)
    ((doublecomplex *)Bstore->nzval)[i] = ((doublecomplex *)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 zPrint_CompCol_Matrix_dist(SuperMatrix *A)
{
    NCformat     *Astore;
    register int i;
    doublecomplex       *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 = (doublecomplex *) Astore->nzval) != NULL ) {
        printf("nzval:\n");
        for (i = 0; i < Astore->nnz; ++i) printf("%f\t%f\n", dp[i].r, dp[i].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 zPrint_Dense_Matrix_dist(SuperMatrix *A)
{
    DNformat     *Astore;
    register int i;
    doublecomplex       *dp;

    printf("\nDense matrix: ");
    printf("Stype %d, Dtype %d, Mtype %d\n", A->Stype,A->Dtype,A->Mtype);
    Astore = (DNformat *) A->Store;
    dp = (doublecomplex *) 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\t%f\n", dp[i].r, dp[i].i);
    printf("\nend Dense matrix.\n");
}

int zPrint_CompRowLoc_Matrix_dist(SuperMatrix *A)
{
    NRformat_loc  *Astore;
    int_t  nnz_loc, m_loc;
    doublecomplex  *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 = (doublecomplex *) Astore->nzval) != NULL )
        PrintDoublecomplex("nzval", nnz_loc, dp);
    printf("==== end CompRowLoc matrix\n");
    return 0;
}

int file_zPrint_CompRowLoc_Matrix_dist(FILE *fp, SuperMatrix *A)
{
    NRformat_loc     *Astore;
    int_t  nnz_loc, m_loc;
    doublecomplex       *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 = (doublecomplex *) Astore->nzval) != NULL )
        file_PrintDoublecomplex(fp, "nzval", nnz_loc, dp);
    fprintf(fp, "==== end CompRowLoc matrix\n");
    return 0;
}

void
zCreate_Dense_Matrix_dist(SuperMatrix *X, int_t m, int_t n, doublecomplex *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 = (doublecomplex *) x;
}

void
zCopy_Dense_Matrix_dist(int_t M, int_t N, doublecomplex *X, int_t ldx,
            doublecomplex *Y, int_t ldy)
{
/*!


   
    Purpose
    =======

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

Function Documentation

◆ file_PrintDoublecomplex()

int file_PrintDoublecomplex ( FILE *  fp,
char *  name,
int_t  len,
doublecomplex x 
)

◆ for()

for ( )
pure virtual
Here is the caller graph for this function:

◆ if()

if ( L->Store)

◆ PrintDoublecomplex()

void PrintDoublecomplex ( char *  name,
int_t  len,
doublecomplex x 
)
Here is the caller graph for this function:

◆ zAllocGlu_3d()

int zAllocGlu_3d ( int_t  n,
int_t  nsupers,
zLUstruct_t LUstruct 
)

◆ zCopy_CompRowLoc_Matrix_dist()

void zCopy_CompRowLoc_Matrix_dist ( SuperMatrix A,
SuperMatrix B 
)

◆ zDeAllocGlu_3d()

int zDeAllocGlu_3d ( zLUstruct_t LUstruct)

◆ zDeAllocLlu_3d()

int zDeAllocLlu_3d ( int_t  n,
zLUstruct_t LUstruct,
gridinfo3d_t grid3d 
)

◆ zDumpLblocks()

void zDumpLblocks ( int  iam,
int_t  nsupers,
gridinfo_t grid,
Glu_persist_t Glu_persist,
zLocalLU_t Llu 
)

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

Here is the caller graph for this function:

◆ zfill_dist()

void zfill_dist ( doublecomplex a,
int_t  alen,
doublecomplex  dval 
)

Fills a doublecomplex precision array with a given value.

◆ zFillRHS_dist()

void zFillRHS_dist ( char *  trans,
int_t  nrhs,
doublecomplex x,
int_t  ldx,
SuperMatrix A,
doublecomplex rhs,
int_t  ldb 
)

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

◆ zGenXtrue_dist()

void zGenXtrue_dist ( int_t  n,
int_t  nrhs,
doublecomplex x,
int_t  ldx 
)

◆ zinf_norm_error_dist()

void zinf_norm_error_dist ( int_t  n,
int_t  nrhs,
doublecomplex x,
int_t  ldx,
doublecomplex xtrue,
int_t  ldxtrue,
gridinfo_t grid 
)

Check the inf-norm of the error vector.

◆ zprint_gsmv_comm()

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

◆ zPrintLblocks()

void zPrintLblocks ( int  iam,
int_t  nsupers,
gridinfo_t grid,
Glu_persist_t Glu_persist,
zLocalLU_t Llu 
)

Print the blocks in the factored matrix L.

◆ zPrintUblocks()

void zPrintUblocks ( int  iam,
int_t  nsupers,
gridinfo_t grid,
Glu_persist_t Glu_persist,
zLocalLU_t Llu 
)

Print the blocks in the factored matrix U.

◆ zScaleAdd_CompRowLoc_Matrix_dist()

void zScaleAdd_CompRowLoc_Matrix_dist ( SuperMatrix A,
SuperMatrix B,
doublecomplex  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.

◆ zScaleAddId_CompRowLoc_Matrix_dist()

void zScaleAddId_CompRowLoc_Matrix_dist ( SuperMatrix A,
doublecomplex  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.

◆ zScalePermstructFree()

void zScalePermstructFree ( zScalePermstruct_t ScalePermstruct)

Deallocate ScalePermstruct.

◆ zScalePermstructInit()

void zScalePermstructInit ( const int_t  m,
const int_t  n,
zScalePermstruct_t ScalePermstruct 
)

Allocate storage in ScalePermstruct.

◆ zZero_CompRowLoc_Matrix_dist()

void zZero_CompRowLoc_Matrix_dist ( SuperMatrix A)

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

◆ zZeroLblocks()

void zZeroLblocks ( int  iam,
int  n,
gridinfo_t grid,
zLUstruct_t LUstruct 
)

Sets all entries of matrix L to zero.

◆ zZeroUblocks()

void zZeroUblocks ( int  iam,
int  n,
gridinfo_t grid,
zLUstruct_t LUstruct 
)

Sets all entries of matrix U to zero.

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];}voidzCreate_SuperNode_Matrix_dist(SuperMatrix *L, int_t m, int_t n, int_t nnz, doublecomplex *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