📄 linsys.h
字号:
#ifndef CLASS_LINSYS#define CLASS_LINSYS#include "vector.h"class LinearSystem {public: enum IterMethod { MethodJacobi, MethodGaussSeidel, MethodSOR } ; enum ErrorCode { ERROR_MATRIX_SINGULAR, ERROR_MATRIX_NOT_SQUARE, ERROR_SIZE_MISMATCH } ; LinearSystem( const Matrix& A ) { m_A = A; m_Factored = false; } LinearSystem( const LinearSystem& S ); ~LinearSystem() { } ColVector DirectSolve( const ColVector& b ); ColVector IterativeSolve( const ColVector& b, IterMethod m, double w = 1.0 ); void SetMaxIter( int n ) { m_maxiter = n; } void SetTol( double tol ) { m_tol = tol; }private: Matrix m_A; Matrix m_L; Matrix m_U; bool m_Factored; int m_maxiter; double m_tol; void GaussElim(); ColVector ForwardSub( const Matrix& L, const ColVector& b ); ColVector BackSub( const Matrix& U, const ColVector& y ); ColVector StationarySolve( const Matrix& M, const Matrix& N, const ColVector& b ); ColVector Jacobi( const ColVector& b ); ColVector GaussSeidel( const ColVector& b ); ColVector SOR( const ColVector& b, double w ); // Leave these alone! They are used for error reporting static void ReportError( ErrorCode errorcode ); static char *ErrorMessages[];} ;#endif // CLASS_LINSYS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -