ESYS13  Revision_
SparseMatrix.h
Go to the documentation of this file.
00001 
00002 /*******************************************************
00003 *
00004 * Copyright (c) 2003-2012 by University of Queensland
00005 * Earth Systems Science Computational Center (ESSCC)
00006 * http://www.uq.edu.au/esscc
00007 *
00008 * Primary Business: Queensland, Australia
00009 * Licensed under the Open Software License version 3.0
00010 * http://www.opensource.org/licenses/osl-3.0.php
00011 *
00012 *******************************************************/
00013 
00014 
00015 /**************************************************************/
00016 
00017 /*   Paso: SparseMatrix and SystemVector */
00018 
00019 /**************************************************************/
00020 
00021 /*   Author: lgross@uq.edu.au */
00022 
00023 /**************************************************************/
00024 
00025 #ifndef INC_PASO_SPARSEMATRIX
00026 #define INC_PASO_SPARSEMATRIX
00027 
00028 #include "Common.h"
00029 #include "Pattern.h"
00030 #include "Options.h"
00031 #include "Paso.h"
00032 
00033 /**************************************************************/
00034 
00035 /*  this struct holds a stiffness matrix: */
00036 
00037 
00038 typedef int Paso_SparseMatrixType;
00039 
00040 typedef struct Paso_SparseMatrix {
00041   Paso_SparseMatrixType type;
00042   dim_t reference_counter;
00043 
00044   dim_t row_block_size;
00045   dim_t col_block_size;
00046   dim_t block_size;
00047 
00048   dim_t numRows;
00049   dim_t numCols;
00050   Paso_Pattern* pattern;
00051   dim_t len;
00052 
00053   double *val;         /* this is used for classical CSR or CSC */
00054 
00055   index_t solver_package;  /* package controlling the solver pointer */
00056   void* solver_p;  /* pointer to data needed by a solver */
00057 
00058 } Paso_SparseMatrix;
00059 
00060 /*  interfaces: */
00061 
00062 Paso_SparseMatrix* Paso_SparseMatrix_alloc(Paso_SparseMatrixType,Paso_Pattern*,dim_t,dim_t,const bool_t);
00063 Paso_SparseMatrix* Paso_SparseMatrix_getReference(Paso_SparseMatrix*);
00064 dim_t Paso_SparseMatrix_getNumColors(Paso_SparseMatrix*);
00065 void Paso_SparseMatrix_applyDiagonal_CSR_OFFSET0(Paso_SparseMatrix* A, const double* left, const double* right);
00066 index_t* Paso_SparseMatrix_borrowColoringPointer(Paso_SparseMatrix*);
00067 void Paso_SparseMatrix_free(Paso_SparseMatrix*);
00068 void Paso_SparseMatrix_MatrixVector_CSC_OFFSET0(const double alpha, const Paso_SparseMatrix* A, const double* in, const double beta, double* out);
00069 void Paso_SparseMatrix_MatrixVector_CSC_OFFSET1(const double alpha, const Paso_SparseMatrix* A, const double* in, const double beta, double* out);
00070 void Paso_SparseMatrix_MatrixVector_CSR_OFFSET0(const double alpha, const Paso_SparseMatrix* A, const double* in, const double beta, double* out);
00071 void Paso_SparseMatrix_MatrixVector_CSR_OFFSET1(const double alpha, const Paso_SparseMatrix* A, const double* in, const double beta, double* out);
00072 void  Paso_SparseMatrix_MatrixVector_CSR_OFFSET0_DIAG(const double alpha, const Paso_SparseMatrix* A, const double* in, const double beta, double* out);
00073 
00074 void Paso_SparseMatrix_copy(Paso_SparseMatrix*,double*);
00075 void Paso_SparseMatrix_maxAbsRow_CSR_OFFSET0(const Paso_SparseMatrix*,double*);
00076 void Paso_SparseMatrix_addAbsRow_CSR_OFFSET0(const Paso_SparseMatrix*,double*);
00077 void Paso_SparseMatrix_addRow_CSR_OFFSET0(Paso_SparseMatrix*,double*);
00078 void Paso_SparseMatrix_nullifyRowsAndCols_CSC_BLK1(Paso_SparseMatrix* A, double* mask_row, double* mask_col, double main_diagonal_value);
00079 void Paso_SparseMatrix_nullifyRowsAndCols_CSR_BLK1(Paso_SparseMatrix* A, double* mask_row, double* mask_col, double main_diagonal_value);
00080 void Paso_SparseMatrix_nullifyRowsAndCols_CSC(Paso_SparseMatrix* A, double* mask_row, double* mask_col, double main_diagonal_value);
00081 void Paso_SparseMatrix_nullifyRowsAndCols_CSR(Paso_SparseMatrix* A, double* mask_row, double* mask_col, double main_diagonal_value);
00082 void Paso_SparseMatrix_nullifyRows_CSR_BLK1(Paso_SparseMatrix* A, double* mask_row, double main_diagonal_value);
00083 void Paso_SparseMatrix_saveHB_CSC(Paso_SparseMatrix *, FILE*);
00084 Paso_SparseMatrix* Paso_SparseMatrix_getSubmatrix(Paso_SparseMatrix* A,dim_t,dim_t,index_t*,index_t*);
00085 Paso_SparseMatrix* Paso_SparseMatrix_getBlock(Paso_SparseMatrix* A, int blockid);
00086 Paso_SparseMatrix* Paso_SparseMatrix_MatrixMatrix(const Paso_SparseMatrix* A, const Paso_SparseMatrix* B);
00087 void Paso_SparseMatrix_MatrixMatrix_DD(Paso_SparseMatrix *C, const Paso_SparseMatrix* A, const Paso_SparseMatrix* B);
00088 void Paso_SparseMatrix_MatrixMatrix_DB(Paso_SparseMatrix *C, const Paso_SparseMatrix* A, const Paso_SparseMatrix* B);
00089 void Paso_SparseMatrix_MatrixMatrix_BD(Paso_SparseMatrix *C, const Paso_SparseMatrix* A, const Paso_SparseMatrix* B);
00090 void Paso_SparseMatrix_MatrixMatrix_BB(Paso_SparseMatrix *C, const Paso_SparseMatrix* A, const Paso_SparseMatrix* B);
00091 
00092 Paso_SparseMatrix* Paso_SparseMatrix_MatrixMatrixTranspose(const Paso_SparseMatrix* A, const Paso_SparseMatrix* B, const Paso_SparseMatrix* T);
00093 void Paso_SparseMatrix_MatrixMatrixTranspose_DD(Paso_SparseMatrix *C, const Paso_SparseMatrix* A, const Paso_SparseMatrix* B, const Paso_SparseMatrix* T);
00094 void Paso_SparseMatrix_MatrixMatrixTranspose_DB(Paso_SparseMatrix *C, const Paso_SparseMatrix* A, const Paso_SparseMatrix* B, const Paso_SparseMatrix* T);
00095 void Paso_SparseMatrix_MatrixMatrixTranspose_BD(Paso_SparseMatrix *C, const Paso_SparseMatrix* A, const Paso_SparseMatrix* B, const Paso_SparseMatrix* T);
00096 void Paso_SparseMatrix_MatrixMatrixTranspose_BB(Paso_SparseMatrix *C, const Paso_SparseMatrix* A, const Paso_SparseMatrix* B, const Paso_SparseMatrix* T);
00097 
00098 Paso_SparseMatrix* Paso_SparseMatrix_unroll(const Paso_SparseMatrixType type, const Paso_SparseMatrix* A);
00099 Paso_SparseMatrix* Paso_SparseMatrix_getTranspose(Paso_SparseMatrix* P);
00100 
00101 void Paso_SparseMatrix_setValues(Paso_SparseMatrix*,double);
00102 void Paso_SparseMatrix_saveMM_CSC(Paso_SparseMatrix *, FILE *);
00103 void  Paso_SparseMatrix_MatrixVector_CSR_OFFSET0_stripe(const double alpha, const dim_t nRows, const dim_t row_block_size, const dim_t col_block_size, const index_t* ptr, const index_t* index, const double* val, const double* in, const double beta, double* out);
00104 Paso_SparseMatrix* Paso_SparseMatrix_loadMM_toCSR( char *fileName_p );
00105 void Paso_SparseMatrix_saveMM(Paso_SparseMatrix * A_p, char * fileName_p);
00106 void Paso_SparseMatrix_nullifyRows_CSR(Paso_SparseMatrix*, double*, double);
00107 index_t* Paso_SparseMatrix_borrowMainDiagonalPointer(Paso_SparseMatrix * A_p);
00108 void Paso_SparseMatrix_copyFromMainDiagonal(Paso_SparseMatrix * A_p, double* out);
00109 void Paso_SparseMatrix_copyToMainDiagonal(Paso_SparseMatrix * A_p, const double* in);
00110 void Paso_SparseMatrix_copyBlockFromMainDiagonal(Paso_SparseMatrix * A_p, double* out);
00111 void Paso_SparseMatrix_copyBlockToMainDiagonal(Paso_SparseMatrix * A_p, const double* in);
00112 void Paso_SparseMatrix_applyBlockMatrix(Paso_SparseMatrix * A_p, double* block_diag, int* pivot, double*x, double *b);
00113 void Paso_SparseMatrix_invMain(Paso_SparseMatrix * A_p, double* inv_diag, int* pivot);
00114 dim_t Paso_SparseMatrix_maxDeg(Paso_SparseMatrix * A_p);
00115 dim_t Paso_SparseMatrix_getTotalNumRows(const Paso_SparseMatrix* A);
00116 dim_t Paso_SparseMatrix_getTotalNumCols(const Paso_SparseMatrix*A);
00117 dim_t Paso_SparseMatrix_getNumRows(const Paso_SparseMatrix*A);
00118 dim_t Paso_SparseMatrix_getNumCols(const Paso_SparseMatrix*A);
00119 double Paso_SparseMatrix_getSize(const Paso_SparseMatrix*A);
00120 double Paso_SparseMatrix_getSparsity(const Paso_SparseMatrix*A);
00121 
00122 
00123 #endif /* #ifndef INC_PASO_SPARSEMATRIX */
00124