1 |
|
2 |
/******************************************************* |
3 |
* |
4 |
* Copyright (c) 2003-2010 by University of Queensland |
5 |
* Earth Systems Science Computational Center (ESSCC) |
6 |
* http://www.uq.edu.au/esscc |
7 |
* |
8 |
* Primary Business: Queensland, Australia |
9 |
* Licensed under the Open Software License version 3.0 |
10 |
* http://www.opensource.org/licenses/osl-3.0.php |
11 |
* |
12 |
*******************************************************/ |
13 |
|
14 |
|
15 |
/**************************************************************/ |
16 |
|
17 |
/* Paso: SparseMatrix and SystemVector */ |
18 |
|
19 |
/**************************************************************/ |
20 |
|
21 |
/* Author: lgross@uq.edu.au */ |
22 |
|
23 |
/**************************************************************/ |
24 |
|
25 |
#ifndef INC_PASO_SPARSEMATRIX |
26 |
#define INC_PASO_SPARSEMATRIX |
27 |
|
28 |
#include "Common.h" |
29 |
#include "Pattern.h" |
30 |
#include "Options.h" |
31 |
#include "Paso.h" |
32 |
|
33 |
/**************************************************************/ |
34 |
|
35 |
/* this struct holds a stiffness matrix: */ |
36 |
|
37 |
|
38 |
typedef int Paso_SparseMatrixType; |
39 |
|
40 |
typedef struct Paso_SparseMatrix { |
41 |
Paso_SparseMatrixType type; |
42 |
dim_t reference_counter; |
43 |
|
44 |
dim_t row_block_size; |
45 |
dim_t col_block_size; |
46 |
dim_t block_size; |
47 |
|
48 |
dim_t numRows; |
49 |
dim_t numCols; |
50 |
Paso_Pattern* pattern; |
51 |
dim_t len; |
52 |
|
53 |
double *val; /* this is used for classical CSR or CSC */ |
54 |
|
55 |
index_t solver_package; /* package controling the solver pointer */ |
56 |
void* solver_p; /* pointer to data needed by a solver */ |
57 |
|
58 |
} Paso_SparseMatrix; |
59 |
|
60 |
/* interfaces: */ |
61 |
|
62 |
Paso_SparseMatrix* Paso_SparseMatrix_alloc(Paso_SparseMatrixType,Paso_Pattern*,dim_t,dim_t,const bool_t); |
63 |
Paso_SparseMatrix* Paso_SparseMatrix_getReference(Paso_SparseMatrix*); |
64 |
dim_t Paso_SparseMatrix_getNumColors(Paso_SparseMatrix*); |
65 |
void Paso_SparseMatrix_applyDiagonal_CSR_OFFSET0(Paso_SparseMatrix* A, const double* left, const double* right); |
66 |
index_t* Paso_SparseMatrix_borrowColoringPointer(Paso_SparseMatrix*); |
67 |
void Paso_SparseMatrix_free(Paso_SparseMatrix*); |
68 |
void Paso_SparseMatrix_MatrixVector_CSC_OFFSET0(const double alpha, const Paso_SparseMatrix* A, const double* in, const double beta, double* out); |
69 |
void Paso_SparseMatrix_MatrixVector_CSC_OFFSET1(const double alpha, const Paso_SparseMatrix* A, const double* in, const double beta, double* out); |
70 |
void Paso_SparseMatrix_MatrixVector_CSR_OFFSET0(const double alpha, const Paso_SparseMatrix* A, const double* in, const double beta, double* out); |
71 |
void Paso_SparseMatrix_MatrixVector_CSR_OFFSET1(const double alpha, const Paso_SparseMatrix* A, const double* in, const double beta, double* out); |
72 |
void Paso_SparseMatrix_MatrixVector_CSR_OFFSET0_DIAG(const double alpha, const Paso_SparseMatrix* A, const double* in, const double beta, double* out); |
73 |
|
74 |
void Paso_SparseMatrix_copy(Paso_SparseMatrix*,double*); |
75 |
void Paso_SparseMatrix_maxAbsRow_CSR_OFFSET0(const Paso_SparseMatrix*,double*); |
76 |
void Paso_SparseMatrix_addAbsRow_CSR_OFFSET0(const Paso_SparseMatrix*,double*); |
77 |
void Paso_SparseMatrix_addRow_CSR_OFFSET0(Paso_SparseMatrix*,double*); |
78 |
void Paso_SparseMatrix_nullifyRowsAndCols_CSC_BLK1(Paso_SparseMatrix* A, double* mask_row, double* mask_col, double main_diagonal_value); |
79 |
void Paso_SparseMatrix_nullifyRowsAndCols_CSR_BLK1(Paso_SparseMatrix* A, double* mask_row, double* mask_col, double main_diagonal_value); |
80 |
void Paso_SparseMatrix_nullifyRowsAndCols_CSC(Paso_SparseMatrix* A, double* mask_row, double* mask_col, double main_diagonal_value); |
81 |
void Paso_SparseMatrix_nullifyRowsAndCols_CSR(Paso_SparseMatrix* A, double* mask_row, double* mask_col, double main_diagonal_value); |
82 |
void Paso_SparseMatrix_nullifyRows_CSR_BLK1(Paso_SparseMatrix* A, double* mask_row, double main_diagonal_value); |
83 |
void Paso_SparseMatrix_saveHB_CSC(Paso_SparseMatrix *, FILE*); |
84 |
Paso_SparseMatrix* Paso_SparseMatrix_getSubmatrix(Paso_SparseMatrix* A,dim_t,dim_t,index_t*,index_t*); |
85 |
Paso_SparseMatrix* Paso_SparseMatrix_getBlock(Paso_SparseMatrix* A, int blockid); |
86 |
Paso_SparseMatrix* Paso_SparseMatrix_MatrixMatrix(const Paso_SparseMatrix* A, const Paso_SparseMatrix* B); |
87 |
void Paso_SparseMatrix_MatrixMatrix_DD(Paso_SparseMatrix *C, const Paso_SparseMatrix* A, const Paso_SparseMatrix* B); |
88 |
void Paso_SparseMatrix_MatrixMatrix_DB(Paso_SparseMatrix *C, const Paso_SparseMatrix* A, const Paso_SparseMatrix* B); |
89 |
void Paso_SparseMatrix_MatrixMatrix_BD(Paso_SparseMatrix *C, const Paso_SparseMatrix* A, const Paso_SparseMatrix* B); |
90 |
void Paso_SparseMatrix_MatrixMatrix_BB(Paso_SparseMatrix *C, const Paso_SparseMatrix* A, const Paso_SparseMatrix* B); |
91 |
|
92 |
Paso_SparseMatrix* Paso_SparseMatrix_unroll(const Paso_SparseMatrixType type, const Paso_SparseMatrix* A); |
93 |
Paso_SparseMatrix* Paso_SparseMatrix_getTranspose(Paso_SparseMatrix* P); |
94 |
|
95 |
void Paso_SparseMatrix_setValues(Paso_SparseMatrix*,double); |
96 |
void Paso_SparseMatrix_saveMM_CSC(Paso_SparseMatrix *, FILE *); |
97 |
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); |
98 |
Paso_SparseMatrix* Paso_SparseMatrix_loadMM_toCSR( char *fileName_p ); |
99 |
void Paso_SparseMatrix_saveMM(Paso_SparseMatrix * A_p, char * fileName_p); |
100 |
void Paso_SparseMatrix_nullifyRows_CSR(Paso_SparseMatrix*, double*, double); |
101 |
index_t* Paso_SparseMatrix_borrowMainDiagonalPointer(Paso_SparseMatrix * A_p); |
102 |
void Paso_SparseMatrix_copyFromMainDiagonal(Paso_SparseMatrix * A_p, double* out); |
103 |
void Paso_SparseMatrix_copyToMainDiagonal(Paso_SparseMatrix * A_p, const double* in); |
104 |
void Paso_SparseMatrix_copyBlockFromMainDiagonal(Paso_SparseMatrix * A_p, double* out); |
105 |
void Paso_SparseMatrix_copyBlockToMainDiagonal(Paso_SparseMatrix * A_p, const double* in); |
106 |
void Paso_SparseMatrix_applyBlockMatrix(Paso_SparseMatrix * A_p, double* block_diag, int* pivot, double*x, double *b); |
107 |
void Paso_SparseMatrix_invMain(Paso_SparseMatrix * A_p, double* inv_diag, int* pivot); |
108 |
dim_t Paso_SparseMatrix_maxDeg(Paso_SparseMatrix * A_p); |
109 |
dim_t Paso_SparseMatrix_getTotalNumRows(const Paso_SparseMatrix* A); |
110 |
dim_t Paso_SparseMatrix_getTotalNumCols(const Paso_SparseMatrix*A); |
111 |
dim_t Paso_SparseMatrix_getNumRows(Paso_SparseMatrix*A); |
112 |
dim_t Paso_SparseMatrix_getNumCols(Paso_SparseMatrix*A); |
113 |
|
114 |
|
115 |
#endif /* #ifndef INC_PASO_SPARSEMATRIX */ |
116 |
|