Repository navigation
Expand file tree
/
Copy pathCSROperators.cpp
More file actions
43 lines (32 loc) · 1.52 KB
/
Copy pathCSROperators.cpp
File metadata and controls
43 lines (32 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "CSROperators.hpp"
#include "CSRMatrix.hpp"
#include "LowLevelOperators.hpp"
#include <vector>
void matrixVectorProd(const CSRMatrix & A, const std::vector<double> & x, std::vector<double>& y )
{
y.resize(A.nrows());
ax_cr( A.nrows(), A.nnzero(), A.I().data(), A.J().data(), A.K().data(), x.data(), y.data() );
}
void matrixTransposedVectorProd(const CSRMatrix & A, const std::vector<double> & x, std::vector<double>& y )
{
y.resize(A.nrows());
atx_cr( A.nrows(), A.nnzero(), A.I().data(), A.J().data(), A.K().data(), x.data(), y.data() );
}
void alphMlumpAij(CSRMatrix & A, const std::vector<double> & mlump, const double & alpha )
{
alpha_mlumpx_cr(mlump.data(), A.K().data(), A.I().data(), A.J().data(), alpha, A.nrows());
}
void alphInvMlumpAij(CSRMatrix & A, const std::vector<double> & mlump, const double & alpha )
{
alpha_invmlumpx_cr(mlump.data(), A.K().data(), A.I().data(), A.J().data(), alpha, A.nrows());
}
void solveGMERES( CSRMatrix & A, std::vector<double> & x, const std::vector<double>& RHS,
long int itr_max, long int dimKrilovSp, double abs_toll, double rel_toll, short int verbose )
{
if( dimKrilovSp > static_cast<long int>(A.nrows()) )
{
dimKrilovSp=static_cast<long int>(A.nrows());
std::cout<<"Warning: Krilov space dimension was bigger than matrix size; changed to "<<A.nrows()<<std::endl;
}
pmgmres_ilu_cr( A.nrows(), A.nnzero(), A.I().data(), A.J().data(), A.K().data(), x.data(), RHS.data(), itr_max, dimKrilovSp, abs_toll, rel_toll, verbose );
}