Simple Nano Circuit 0.0.2
MathMatrixClass.h
1#ifndef _MathMatrixClass_H_
2#define _MathMatrixClass_H_
3
4#include <vector>
5#include <cstdlib>
6#include <iostream>
7#include <set>
8#include <stack>
9#include <sstream>
10#include <unordered_map>
11#include <list>
12
14{
15 public:
16 using VectorDouble = std::vector<double>;
17 using pVectorDouble = std::vector<double*>;
18
19 using Matrix = std::vector<VectorDouble>;
20 using pMatrix = std::vector<pVectorDouble>;
21
22 using VectorIndex = std::vector<size_t>;
23 using pVectorIndex = std::vector<size_t*>;
24
25 using BipartiteGraph = std::unordered_map<std::string, std::set<std::string>>;
26
27 pMatrix *pA = nullptr;
28 pVectorDouble *pB = nullptr;
29 pVectorDouble *pSolution = nullptr;
30 pVectorIndex *pSolutionBeloneNetlistIndex = nullptr;
31
32 MathMatrixClass(Matrix* , VectorDouble* , VectorDouble* , VectorIndex* );
33 MathMatrixClass(MathMatrixClass* , const VectorIndex& , const VectorIndex& );
35
36 void showDescription();
37
38 void solveBigQuestion();
39
40 private:
41
42 size_t n = 0;
43
44 void copyMatrix(Matrix*, pMatrix*);
45 void copyVectorDouble(VectorDouble*, pVectorDouble*);
46 void copyVectorIndex(VectorIndex*, pVectorIndex*);
47
48 void copyMatrix(pMatrix*, pMatrix*, const VectorIndex&, const VectorIndex&);
49 void copyVectorDouble(pVectorDouble*, pVectorDouble*, const VectorIndex&);
50 void copyVectorIndex(pVectorIndex*, pVectorIndex*, const VectorIndex&);
51
52 void printMatrix(const pMatrix* );
53 void printVector(const pVectorDouble* );
54 void printVector(const pVectorIndex* );
55
57 std::list<MathMatrixClass*> splitToMultiSubQuestions();
58
59 BipartiteGraph buildBipartiteGraph();
60 void dfs(const std::string& , BipartiteGraph& , std::set<std::string>& , std::vector<std::string>& );
61
62 bool solve();
63 bool isSingularMatrix();
64 bool isSquareMatrix();
65 double determinant(const Matrix& matrix);
66
67 bool solveLinearSystem();
68
69 void luDecomposition( Matrix& , Matrix& );
70
71 VectorDouble forwardSubstitution( const Matrix& );
72
73 VectorDouble backwardSubstitution(const Matrix& , const VectorDouble&);
74};
75#endif
Definition: MathMatrixClass.h:14