Jet  v1.3.3
fdm_linear_system2.h
Go to the documentation of this file.
1 // Copyright (c) 2018 Doyub Kim
2 //
3 // I am making my contributions/submissions to this project solely in my
4 // personal capacity and am not conveying any rights to any intellectual
5 // property of any third parties.
6 
7 #ifndef INCLUDE_JET_FDM_LINEAR_SYSTEM2_H_
8 #define INCLUDE_JET_FDM_LINEAR_SYSTEM2_H_
9 
10 #include <jet/array1.h>
11 #include <jet/array2.h>
12 #include <jet/matrix_csr.h>
13 #include <jet/vector_n.h>
14 
15 namespace jet {
16 
18 struct FdmMatrixRow2 {
20  double center = 0.0;
21 
23  double right = 0.0;
24 
26  double up = 0.0;
27 };
28 
31 
34 
39 
42 
45 
47  void clear();
48 
50  void resize(const Size2& size);
51 };
52 
57 
60 
63 
65  void clear();
66 };
67 
69 struct FdmBlas2 {
70  typedef double ScalarType;
73 
75  static void set(ScalarType s, VectorType* result);
76 
78  static void set(const VectorType& v, VectorType* result);
79 
81  static void set(ScalarType s, MatrixType* result);
82 
84  static void set(const MatrixType& m, MatrixType* result);
85 
87  static double dot(const VectorType& a, const VectorType& b);
88 
91  static void axpy(double a, const VectorType& x, const VectorType& y,
92  VectorType* result);
93 
95  static void mvm(const MatrixType& m, const VectorType& v,
96  VectorType* result);
97 
99  static void residual(const MatrixType& a, const VectorType& x,
100  const VectorType& b, VectorType* result);
101 
103  static ScalarType l2Norm(const VectorType& v);
104 
106  static ScalarType lInfNorm(const VectorType& v);
107 };
108 
111  typedef double ScalarType;
114 
116  static void set(ScalarType s, VectorType* result);
117 
119  static void set(const VectorType& v, VectorType* result);
120 
122  static void set(ScalarType s, MatrixType* result);
123 
125  static void set(const MatrixType& m, MatrixType* result);
126 
128  static double dot(const VectorType& a, const VectorType& b);
129 
132  static void axpy(double a, const VectorType& x, const VectorType& y,
133  VectorType* result);
134 
136  static void mvm(const MatrixType& m, const VectorType& v,
137  VectorType* result);
138 
140  static void residual(const MatrixType& a, const VectorType& x,
141  const VectorType& b, VectorType* result);
142 
144  static ScalarType l2Norm(const VectorType& v);
145 
147  static ScalarType lInfNorm(const VectorType& v);
148 };
149 
150 } // namespace jet
151 
152 #endif // INCLUDE_JET_FDM_LINEAR_SYSTEM2_H_
jet::FdmBlas2::dot
static double dot(const VectorType &a, const VectorType &b)
Performs dot product with vector a and b.
array2.h
jet::VectorN< double >
jet::FdmCompressedLinearSystem2
Compressed linear system (Ax=b) for 2-D finite differencing.
Definition: fdm_linear_system2.h:54
jet::FdmCompressedBlas2::MatrixType
MatrixCsrD MatrixType
Definition: fdm_linear_system2.h:113
jet::FdmLinearSystem2
Linear system (Ax=b) for 2-D finite differencing.
Definition: fdm_linear_system2.h:36
jet::FdmBlas2::l2Norm
static ScalarType l2Norm(const VectorType &v)
Returns L2-norm of the given vector v.
jet::FdmCompressedBlas2::mvm
static void mvm(const MatrixType &m, const VectorType &v, VectorType *result)
Performs matrix-vector multiplication.
jet::FdmCompressedBlas2::lInfNorm
static ScalarType lInfNorm(const VectorType &v)
Returns Linf-norm of the given vector v.
jet::FdmCompressedLinearSystem2::clear
void clear()
Clears all the data.
jet::FdmLinearSystem2::clear
void clear()
Clears all the data.
jet::FdmBlas2::MatrixType
FdmMatrix2 MatrixType
Definition: fdm_linear_system2.h:72
jet::FdmMatrix2
Array2< FdmMatrixRow2 > FdmMatrix2
Matrix type for 2-D finite differencing.
Definition: fdm_linear_system2.h:33
jet::FdmBlas2::set
static void set(ScalarType s, MatrixType *result)
Sets entire element of given matrix result with scalar s.
jet::FdmCompressedLinearSystem2::b
VectorND b
RHS vector.
Definition: fdm_linear_system2.h:62
jet::FdmLinearSystem2::x
FdmVector2 x
Solution vector.
Definition: fdm_linear_system2.h:41
jet::FdmCompressedBlas2::l2Norm
static ScalarType l2Norm(const VectorType &v)
Returns L2-norm of the given vector v.
jet::MatrixCsr< double >
jet::FdmMatrixRow2::up
double up
Off-diagonal element where column refers to (i, j+1) grid point.
Definition: fdm_linear_system2.h:26
jet::Array< T, 2 >
2-D array class.
Definition: array2.h:42
jet::FdmCompressedBlas2::axpy
static void axpy(double a, const VectorType &x, const VectorType &y, VectorType *result)
jet::FdmCompressedBlas2::set
static void set(const VectorType &v, VectorType *result)
Copies entire element of given vector result with other vector v.
jet::FdmCompressedBlas2::set
static void set(const MatrixType &m, MatrixType *result)
Copies entire element of given matrix result with other matrix v.
matrix_csr.h
jet::FdmMatrixRow2::center
double center
Diagonal component of the matrix (row, row).
Definition: fdm_linear_system2.h:20
jet
Definition: advection_solver2.h:18
jet::FdmCompressedBlas2
BLAS operator wrapper for compressed 2-D finite differencing.
Definition: fdm_linear_system2.h:110
jet::FdmCompressedLinearSystem2::A
MatrixCsrD A
System matrix.
Definition: fdm_linear_system2.h:56
jet::FdmCompressedBlas2::VectorType
VectorND VectorType
Definition: fdm_linear_system2.h:112
jet::FdmBlas2::mvm
static void mvm(const MatrixType &m, const VectorType &v, VectorType *result)
Performs matrix-vector multiplication.
jet::FdmMatrixRow2
The row of FdmMatrix2 where row corresponds to (i, j) grid point.
Definition: fdm_linear_system2.h:18
jet::FdmBlas2::residual
static void residual(const MatrixType &a, const VectorType &x, const VectorType &b, VectorType *result)
Computes residual vector (b - ax).
jet::FdmBlas2::lInfNorm
static ScalarType lInfNorm(const VectorType &v)
Returns Linf-norm of the given vector v.
jet::FdmCompressedLinearSystem2::x
VectorND x
Solution vector.
Definition: fdm_linear_system2.h:59
jet::FdmLinearSystem2::resize
void resize(const Size2 &size)
Resizes the arrays with given grid size.
jet::FdmLinearSystem2::b
FdmVector2 b
RHS vector.
Definition: fdm_linear_system2.h:44
jet::FdmCompressedBlas2::residual
static void residual(const MatrixType &a, const VectorType &x, const VectorType &b, VectorType *result)
Computes residual vector (b - ax).
jet::FdmBlas2
BLAS operator wrapper for 2-D finite differencing.
Definition: fdm_linear_system2.h:69
jet::FdmLinearSystem2::A
FdmMatrix2 A
System matrix.
Definition: fdm_linear_system2.h:38
jet::FdmCompressedBlas2::dot
static double dot(const VectorType &a, const VectorType &b)
Performs dot product with vector a and b.
jet::Size2
2-D size class.
Definition: size2.h:19
jet::FdmBlas2::set
static void set(ScalarType s, VectorType *result)
Sets entire element of given vector result with scalar s.
jet::FdmBlas2::VectorType
FdmVector2 VectorType
Definition: fdm_linear_system2.h:71
jet::FdmCompressedBlas2::set
static void set(ScalarType s, VectorType *result)
Sets entire element of given vector result with scalar s.
jet::FdmBlas2::ScalarType
double ScalarType
Definition: fdm_linear_system2.h:70
vector_n.h
jet::FdmBlas2::set
static void set(const MatrixType &m, MatrixType *result)
Copies entire element of given matrix result with other matrix v.
jet::FdmBlas2::set
static void set(const VectorType &v, VectorType *result)
Copies entire element of given vector result with other vector v.
jet::FdmCompressedBlas2::set
static void set(ScalarType s, MatrixType *result)
Sets entire element of given matrix result with scalar s.
jet::FdmCompressedBlas2::ScalarType
double ScalarType
Definition: fdm_linear_system2.h:111
jet::FdmVector2
Array2< double > FdmVector2
Vector type for 2-D finite differencing.
Definition: fdm_linear_system2.h:30
jet::FdmMatrixRow2::right
double right
Off-diagonal element where colum refers to (i+1, j) grid point.
Definition: fdm_linear_system2.h:23
array1.h
jet::FdmBlas2::axpy
static void axpy(double a, const VectorType &x, const VectorType &y, VectorType *result)