mat.h File Reference

Class Mat: a sparse matrix object. More...

#include <mc/mc_base.h>
#include <mc/mtool.h>
#include <mc/slu.h>

Include dependency graph for mat.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  sMat
 Contains public data memebers for Mat class. More...

Typedefs

typedef struct sMat Mat
 Declaration of the Mat class as the Mat structure.

Functions

MatMat_ctor (Vmem *vmem, const char *name, int pnumR, int pnumC)
 The sparse matrix constructor.
void Mat_dtor (Mat **thee)
 The sparse matrix destructor.
void Mat_initStructure (Mat *thee, MATformat frmt, MATsym sym, int numO, int *IJA, double *A)
 Initialize the nonzero structure given structure information.
void Mat_copyStructure (Mat *thee, Mat *model)
 Initialize the nonzero structure given structure information.
void Mat_killStructure (Mat *thee)
 Kill the nonzero structure and structure information.
int Mat_numR (Mat *thee)
 Return number of rows in the matrix.
int Mat_numC (Mat *thee)
 Return number of columns in the matrix.
int Mat_numA (Mat *thee)
 Return number of nonzeros we are actually storing.
int Mat_numO (Mat *thee)
 Return number of nonzeros we are actually storing which are located in upper (or lower) triangle.
int Mat_numZ (Mat *thee)
 Return number of nonzeros we WOULD be storing if we were ignoring symmetry and storing all nonzeros.
MATformat Mat_format (Mat *thee)
 Return the format.
MATsym Mat_sym (Mat *thee)
 Return the symmetry.
MATstate Mat_state (Mat *thee)
 Return the state.
MATimpl Mat_impl (Mat *thee)
 Return the impl.
void Mat_setFormat (Mat *thee, MATformat format)
 Set the format.
void Mat_setSym (Mat *thee, MATsym sym)
 Set the symmetry.
void Mat_setState (Mat *thee, MATstate state)
 Set the state.
void Mat_setImpl (Mat *thee, MATimpl impl)
 Set the impl.
int Mat_sizeIJA (Mat *thee)
 Return total number of INTEGER STORAGE LOCATIONS in the matrix.
int Mat_sizeA (Mat *thee)
 Return total number of REAL STORAGE LOCATIONS in the matrix.
int * Mat_IJA (Mat *thee)
 Return the integer structure IJA.
int * Mat_IA (Mat *thee)
 Return the integer structure IA.
int * Mat_JA (Mat *thee)
 Return the integer structure JA.
double * Mat_A (Mat *thee)
 Return the real structure A.
double * Mat_diag (Mat *thee)
 Return the diagonal structure A.
double * Mat_offU (Mat *thee)
 Return the upper-triangle structure A.
double * Mat_offL (Mat *thee)
 Return the lower-triangle structure A.
void Mat_print (Mat *thee)
 Print the matrix as a DENSE matrix in MATLAB format.
void Mat_printSp (Mat *thee, char *fname, int pflag)
 Print the matrix as a SPARSE matrix in MATLAB format.
void Mat_printNoD (Mat *thee)
 Print the matrix as a DENSE matrix in MATLAB format, but first zero out any rows/cols corresponding to Dirichlet boundary points.
void Mat_printSpNoD (Mat *thee, char *fname, int pflag)
 Print the matrix as a DENSE matrix in MATLAB format, but first zero out any rows/cols corresponding to Dirichlet boundary points.
void Mat_zero (Mat *thee)
 Clear the floating point storage for the sparse matrix. Also clear any sparse factorization storage.
void Mat_set (Mat *thee, int i, int j, double val)
 Set a value in a matrix.
void Mat_addTo (Mat *thee, int i, int j, double val)
 Add to a value in a matrix.
void Mat_buildBRC (Mat *thee, int numBR, int numBC, int *BR, int *BC)
 Set the boundary row and column information.
void Mat_zeroBRC (Mat *thee)
 Apply the boundary row and column information.
void Mat_diagBRC (Mat *thee)
 Place identity entries on diagonal of boundary row/col.
void Mat_galerkin (Mat *thee, Mat *rmat, Mat *amat, Mat *pmat)
 Enforce the Galerkin conditions algebraically.
int Mat_sluDirect (Mat *thee)
 Make a decision about whether or not a sparse direct solver should be used in place of an iterative solver, based on the size of the system.
void Mat_sluCreate (Mat *thee)
 Setup for a sparse LU factorization of matrix.
int Mat_sluFactor (Mat *thee)
 Create the sparse LU factors for the system matrix.
int Mat_sluSolve (Mat *thee, int key, double *f, double *u)
 Performs a forward/backward solve using the sparse LU factors.
void Mat_sluDestroy (Mat *thee)
 Destroy the sparse LU factors for the system matrix.
void Mat_memChk (Mat *thee)
 Print the exact current malloc usage.
void Mat_copy (Mat *thee, Mat *smat)
 Copy a matrix.
void Mat_copyROW2COL (Mat *thee, Mat *smat)
 Copy a matrix from ROW to COL.
void Mat_copyCOL2ROW (Mat *thee, Mat *smat)
 Copy a matrix from COL to ROW.
void Mat_copyDRC2RLN (Mat *thee, Mat *smat)
 Copy a matrix from DRC to RLN.
void Mat_copyROW2RLN (Mat *thee, Mat *smat)
 Copy a matrix from ROW to RLN.
void Mat_copyCOL2RLN (Mat *thee, Mat *smat)
 Copy a matrix from COL to RLN.
void Mat_copyRLN2ROW (Mat *thee, Mat *smat)
 Copy a matrix from RLN to ROW.
void Mat_copyDRC2CLN (Mat *thee, Mat *smat)
 Copy a matrix from DRC to CLN.
void Mat_copyROW2CLN (Mat *thee, Mat *smat)
 Copy a matrix from ROW to CLN.
void Mat_copyCOL2CLN (Mat *thee, Mat *smat)
 Copy a matrix from COL to CLN.
void Mat_copyCLN2COL (Mat *thee, Mat *smat)
 Copy a matrix from CLN to COL.
void Mat_copyCLN2RLN (Mat *thee, Mat *smat)
 Copy a matrix from CLN to RLN.
void Mat_copyRLN2CLN (Mat *thee, Mat *smat)
 Copy a matrix from RLN to CLN.
void Mat_copyDRC2XLN (Mat *thee, Mat *smat)
 Copy a matrix from DRC to XLN.
void Mat_copyROW2XLN (Mat *thee, Mat *smat)
 Copy a matrix from ROW to XLN.
void Mat_copyCOL2XLN (Mat *thee, Mat *smat)
 Copy a matrix from COL to XLN.
void Mat_copyRLN2XLN (Mat *thee, Mat *smat)
 Copy a matrix from RLN to XLN.
void Mat_copyCLN2XLN (Mat *thee, Mat *smat)
 Copy a matrix from CLN to XLN.
void Mat_copyXLN2DRC (Mat *thee, Mat *smat)
 Copy a matrix from XLN to DRC.
void Mat_copyXLN2ROW (Mat *thee, Mat *smat)
 Copy a matrix from XLN to ROW.
void Mat_copyXLN2COL (Mat *thee, Mat *smat)
 Copy a matrix from XLN to COL.
void Mat_copyXLN2RLN (Mat *thee, Mat *smat)
 Copy a matrix from XLN to RLN.
void Mat_copyXLN2CLN (Mat *thee, Mat *smat)
 Copy a matrix from XLN to CLN.
void Mat_squeezeBRC (Mat *thee, int key)
 Remove the boundary rows or columns from a matrix.
void Mat_copy2 (Mat *Y, Mat *X)
 Raw copy of the nonzeros of X into Y.
void Mat_axpy (Mat *Y, Mat *X, double val, int key)
 scalar times a Mat plus a Mat: Y += val*X.
void Mat_initStructureLN (Mat *thee, MATformat frmt, MATsym sym)
 Initialize the nonzero structure given structure information.
void Mat_killStructureLN (Mat *thee)
 Kill the nonzero structure and structure information.
LinkRCMat_accessXLN (Mat *thee, int idx, int key)
 Access the first element in the ROW or COL of an XLN.
void Mat_contribXLN (Mat *thee, int key, int i, int j, double val)
 Set or add a value to a doubly linked matrix entry array.
void Mat_contribNSYMXLN (Mat *thee, int key, int i, int j, double val)
 Set or add a value to a NOTSYM XLN matrix.
void Mat_contribSSYMXLN (Mat *thee, int key, int i, int j, double val)
 Set or add a value to a STRUC_SYM XLN matrix.
void Mat_contribSYMXLN (Mat *thee, int key, int i, int j, double val)
 Set or add a value to a SYM XLN Matrix.
void Mat_printLN (Mat *thee)
 Print an LN format matrix as a DENSE matrix in MATLAB format.
void Mat_printLNSp (Mat *thee, char *fname, int pflag)
 Print an LN format matrix as a SPARSE matrix in MATLAB format.


Detailed Description

Class Mat: a sparse matrix object.

Author:
Michael Holst
Note:
None
 * This class support several datastructures for sparse matrices.
 *           The following formats are supported (see below for descriptions):
 *
 *             ZERO (the zero matrix; no storage at all)
 *             DRC  (diag-row-col-YSMP variant)
 *             ROW  (row-YSMP)
 *             COL  (col-YSMP)
 *             SLU  (sparse-LU)
 *             RLN  (row-linked-list)
 *             CLN  (col-linked-list)
 *             XLN  (row-linked-list AND col-linked-list)
 *             RFL  (row-wise dense matrix; i.e., C-style 2D array)
 *             CFL  (col-wise dense matrix; i.e., FORTRAN-style 2D array)
 *
 *           NOTE: This class is very efficient in both memory and operation
 *           complexity for LARGE sparse matrices.  It also supports dense
 *           matrices (RFL and CFL formats).
 *
 *           ANOTHER NOTE:  Only ONE format is supported at a time; i.e.,
 *           you cannot simultaneously have a matrix in multiple formats
 *           maintained WITHIN that Mat datastructure.  You must create a
 *           new one of the desired type, and copy the old one into it, if
 *           you want to have an existing matrix represented in a different
 *           format.  (This is a change from the previous version of this
 *           library.)
 *
 * Formats:  Here is a brief description of the suppored matrix formats:
 *
 *           ZERO:       .                  This is a zero matrix (no storage).
 *
 *           DRC:        \-----             This is a symmetric storage
 *                       |\----             format; only the upper triangle
 *                       ||\---             need be stored in the case of
 *                       |||\--             symmetry.  However, we must assume
 *                       ||||\-             that the upper and lower triangles
 *                       |||||\             have identical nonzero structures;
 *                                          the matrix MUST BE SQUARE.
 *                                          The diagonal entries are stored
 *                                          separately from the triangles.
 *
 *                                          NOTE: In the case of symmetry,
 *                                          we simply point the lower triangle
 *                                          nonzeros A to the upper, as well as
 *                                          the IA and JA pointers.
 *
 *           ROW:        ---------          This is a completely nonsymmetric
 *                       ---------          storage format; no provision is
 *                       ---------          made to handle storage savings
 *                       ---------          in the case of symmetry.
 *                                          No assumptions are made about the
 *                                          nonzero-structure of the matrix;
 *                                          the matrix can be non-square.
 *                                          Row-start pointers are kept in IA,
 *                                          and column indices are kept in JA.
 *                                          The diagonal entriecs are treated
 *                                          like any other row entry.
 *
 *           COL:        ||||               This is a column-wise variant
 *                       ||||               of the ROW format.  Col-start
 *                       ||||               pointers are kept in IA, and
 *                       ||||               row indices are kept in JA.
 *                       ||||
 *                       ||||
 *                       ||||
 *                       ||||
 *                       ||||
 *
 *           SLU:        [LU]               This format is determined by
 *                                          the particular sparse direct
 *                                          solver which we use to factor
 *                                          the matrix, and we do not use
 *                                          any information about the
 *                                          particular storage format.
 *
 *           RLN:        [linked-list]      This is a row-wise linked list
 *                                          representation of the matrix.
 *                                          It is usually used to accumulate
 *                                          a matrix product for which there
 *                                          is no a priori knowledge about
 *                                          the resulting nonzero structure.
 *                                          It is usually converted into one
 *                                          of the other matrix formats before
 *                                          it is used for anything else, since
 *                                          linked-list implementations of
 *                                          operations such as matrix-vector
 *                                          products tend to be inefficient.
 *
 *           CLN:        [linked-list]      This is a column-wise variant
 *                                          of the RLN format.
 *
 *           XLN:        [linked-list]      Simultaneous RLN and CLN.
 *
 *           RFL:        ---------          This is a dense row-wise storage
 *                       ---------          format.  All nonzeros are stored;
 *                       ---------          no integer storage is used.
 *
 *           CFL:        ||||               This is a dense col-wise storage
 *                       ||||               format.  All nonzeros are stored;
 *                       ||||               no integer storage is used.
 *
 * Storage:  Details of the DRC/ROW/COL format storage are as follows.
 *           The integer part IJA of the structure has the following layout:
 *
 *               IJA = [ IA ; JA ]
 *
 *               length(IA)    = N+1      row(col) start pointers into JA/A
 *               length(JA)    = NZ       col(row) indices for each row(col)
 *               ------------------------
 *               length(IJA)   = N+1+NZ
 *
 *           which is a DRC, ROW, or COL pointer structure for a matrix.
 *           The IA part of the array points into the JA portion of the array
 *           for the beginning of each row (or column) left-to-right
 *           (or top-to-bottom).
 *
 *           The JA portion then contains the column (or row) indices for the
 *           corresponding entries in that row (or column), ordered
 *           left-to-right (or top to bottom).
 *
 *           The corresponding array of the actual nonzeros in the case of
 *           the DRC style format has the form:
 *
 *               A = [ diag ; offU ; offL ]
 *
 *               length(diag) = N         (diag)
 *               length(offU) = NZ        (upper-triang)
 *               length(offL) = NZ        (lower-triang, or null if symmetric)
 *               -----------------------
 *               length(A)    = N+2*NZ    (or N+NZ if symmetric)
 *
 *           In the case of ROW or COL, the matrix A is simply a row-wise or
 *           col-wise ordering of all of the nozeros, with no special role
 *           played by the diagonal entries.
 *  
Version:
Id
mat.h,v 1.46 2009/04/24 22:54:03 fetk Exp

Attention:
 *
 * MC = < Manifold Code >
 * Copyright (C) 1994--2008 Michael Holst
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 *  

Generated on Mon Aug 9 11:13:40 2010 for MC by  doxygen 1.5.6