-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinearEquation.h
74 lines (62 loc) · 1.53 KB
/
linearEquation.h
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Universidade Federal do Rio de Janeiro
* Author: Luiz Giserman
* Class: Numeric Linear Algebra
*/
#ifndef LINEAR_EQUATION_H
#define LINEAR_EQUATION_H
#include <math.h>
#include <string>
#include "basicMatrix.h"
#define ERROR_NO_SOLUTION 2
class LinearEquation : public Utilities
{
public:
LinearEquation(string s="");
LinearEquation(bool empty);
LinearEquation(BasicMatrix a, BasicMatrix b);
virtual ~LinearEquation() { };
BasicMatrix matrixA, matrixB, solutionMatrix;
unsigned int numberVariables;
vector<double> solution;
virtual bool Solve() {return true;};
bool ForwardSubstitution(BasicMatrix triangular, BasicMatrix b, BasicMatrix &result);
bool BackwardsSubstitution(BasicMatrix U, BasicMatrix Y, BasicMatrix &X);
bool PrintSolution();
};
class Jacobi : public LinearEquation
{
public:
Jacobi(string s="");
double threshold = 0.0;
bool Solve();
};
class GaussSeidel : public LinearEquation
{
public:
GaussSeidel(string s="");
double threshold = 0.0;
bool Solve();
};
class LU : public LinearEquation
{
public:
LU(string s="");
LU(bool empty) : LinearEquation(empty) {};
LU(BasicMatrix a, BasicMatrix b) : LinearEquation (a, b) {this->Check();};
BasicMatrix matrixLU;
bool Decompose();
void Check();
void MakeL (BasicMatrix &L);
void MakeU (BasicMatrix &U);
bool Solve();
};
class Cholesky : public LinearEquation
{
public:
Cholesky(string s="");
BasicMatrix L, LT;
bool Decompose();
bool Solve();
};
#endif