Chi-Tech
chi_math.h
Go to the documentation of this file.
1#ifndef CHI_MATH_H
2#define CHI_MATH_H
3
4#include "chi_math_incdef.h"
5
9
10#include <memory>
11
12typedef std::vector<double> VecDbl;
13typedef std::vector<VecDbl> MatDbl;
14
15namespace chi_math
16{
17 class SparseMatrix;
18
19 class UnknownManager;
20 class CDFSampler;
21
22 class SpatialDiscretization;
23 class SpatialDiscretization_FV;
24 class SpatialDiscretization_PWLD;
25 class SpatialDiscretization_PWLC;
26
27 /**Coordinate system type.*/
29 {
30 UNDEFINED = 0,
31 CARTESIAN = 1,
32 CYLINDRICAL = 2,
33 SPHERICAL = 3,
34 };
35 /**Spatial discretization type.*/
37 {
38 UNDEFINED = 0,
39 FINITE_VOLUME = 1,
44 };
45
46 enum class NormType : int
47 {
48 L1_NORM = 1,
49 L2_NORM = 2,
50 LINF_NORM = 3
51 };
52
53 int SampleCDF(double x, std::vector<double> cdf_bin);
54
55 //01 Utility
56 double Factorial(int x);
57
58 std::pair<double,double> OmegaToPhiThetaSafe(const chi_mesh::Vector3 &omega);
59
60 //02 Vector operations
61 void PrintVector(const VecDbl& x);
62 void Scale(VecDbl& x, const double& val);
63 void Set(VecDbl& x, const double& val);
64 VecDbl VecMul(const VecDbl& x, const double& val);
65 double Vec1Norm(const VecDbl& x);
66 double Vec2Norm(const VecDbl& x);
67 double VecInfinityNorm(const VecDbl& x);
68 double VecPNorm(const VecDbl& x, const double& p);
69 double Dot(const VecDbl& x, const VecDbl& y);
70 VecDbl operator+(const VecDbl& a, const VecDbl& b);
71 VecDbl operator-(const VecDbl& a, const VecDbl& b);
72
73 //03 Matrix operations
74 void PrintMatrix(const MatDbl& A);
75 void Scale(MatDbl& A, const double& val);
76 void Set(MatDbl& A, const double& val);
77 MatDbl Transpose(const MatDbl& A);
78 void SwapRow(size_t r1, size_t r2, MatDbl& A);
79 void SwapColumn(size_t c1, size_t c2, MatDbl& A);
80 MatDbl MatMul(const MatDbl& A, const double c);
81 VecDbl MatMul(const MatDbl& A, const VecDbl& x);
82 MatDbl MatMul(const MatDbl& A, const MatDbl& B);
83 MatDbl MatAdd(const MatDbl& A, const MatDbl& B);
84 MatDbl MatSubtract(const MatDbl& A, const MatDbl& B);
85 double Determinant(const MatDbl& A);
86 MatDbl SubMatrix( const size_t r,
87 const size_t c,
88 const MatDbl& A );
89 void GaussElimination(MatDbl& A, VecDbl& b, int n);
91 MatDbl Inverse(const MatDbl& A);
92
93 double PowerIteration(const MatDbl& A,
94 VecDbl& e_vec, int max_it = 2000, double tol = 1.0e-13);
95
96
97}//namespace chi_math
98
99
100#endif
std::vector< VecDbl > MatDbl
Definition: chi_math.h:13
std::vector< double > VecDbl
Definition: chi_math.h:12
void PrintMatrix(const MatDbl &A)
void PrintVector(const VecDbl &x)
double Vec1Norm(const VecDbl &x)
double PowerIteration(const MatDbl &A, VecDbl &e_vec, int max_it=2000, double tol=1.0e-13)
VecDbl operator-(const VecDbl &a, const VecDbl &b)
void Scale(VecDbl &x, const double &val)
int SampleCDF(double x, std::vector< double > cdf_bin)
Definition: cdfsampler.cc:272
VecDbl VecMul(const VecDbl &x, const double &val)
std::pair< double, double > OmegaToPhiThetaSafe(const chi_mesh::Vector3 &omega)
SpatialDiscretizationType
Definition: chi_math.h:37
void Set(VecDbl &x, const double &val)
MatDbl Inverse(const MatDbl &A)
MatDbl SubMatrix(const size_t r, const size_t c, const MatDbl &A)
double VecInfinityNorm(const VecDbl &x)
double Determinant(const MatDbl &A)
void SwapColumn(size_t c1, size_t c2, MatDbl &A)
MatDbl Transpose(const MatDbl &A)
VecDbl operator+(const VecDbl &a, const VecDbl &b)
MatDbl MatAdd(const MatDbl &A, const MatDbl &B)
void GaussElimination(MatDbl &A, VecDbl &b, int n)
MatDbl MatMul(const MatDbl &A, const double c)
double Dot(const VecDbl &x, const VecDbl &y)
double VecPNorm(const VecDbl &x, const double &p)
double Factorial(int x)
MatDbl InverseGEPivoting(const MatDbl &A)
MatDbl MatSubtract(const MatDbl &A, const MatDbl &B)
double Vec2Norm(const VecDbl &x)
CoordinateSystemType
Definition: chi_math.h:29
void SwapRow(size_t r1, size_t r2, MatDbl &A)