Compare commits

...

2 Commits

Author SHA1 Message Date
e5ed6001f8 Ready linear MKE solver 2025-09-10 14:34:30 +03:00
b66a923d26 Delete matrix.txt 2025-09-10 14:34:08 +03:00
5 changed files with 26 additions and 8 deletions

1
.gitignore vendored
View File

@@ -636,3 +636,4 @@ FodyWeavers.xsd
*.msix
*.msm
*.msp
*.txt

View File

@@ -2,9 +2,8 @@
#include "Solver.h"
int main() {
std::ifstream file("matrix.txt");
Solver slv(1., 0., 1., 3, 0, 1);
slv.Execute();
Solver slv(1., 0., 1., 20, 0, 1);
slv.Execute_Linear();
return 0;
}

View File

@@ -9,7 +9,7 @@ Solver::Solver(double _A, double _B, double _C, int _N, int _l, int _u) {
dx = L / N;
}
void Solver::Execute() {
void Solver::Execute_Linear() {
MatrixXd local = MatrixXd::Zero(2, 2);
local(0, 0) = A / dx - B / 2;
local(0, 1) = -A / dx + B / 2;
@@ -76,4 +76,24 @@ void Solver::Execute() {
VectorXd solution = ansamb.fullPivLu().solve(global_load);
std::cout << "\nSolution:" << std::endl;
std::cout << solution << std::endl;
std::ofstream file("matrix_2.txt");
for (int i = 0; i < N + 1; i++) {
file << solution(i) << ' ';
}
file << std::endl;
}
void Solver::Execute_Cubic() {
MatrixXd local = MatrixXd::Zero(2, 2);
local(0, 0) = A * 37/(10 * dx) + B / 2;
local(0, 1) = -A / dx + B / 2;
local(0, 1) = A;
local(1, 0) = -A / dx - B / 2;
local(1, 1) = A / dx + B / 2;
std::cout << "Local matrix:\n" << local << std::endl;
VectorXd local_load(2);
local_load(0) = C * dx / 2;
local_load(1) = C * dx / 2;
}

View File

@@ -5,5 +5,6 @@ private:
int N, upper, lower;
public:
Solver(double _A, double _B, double _C, int _N, int _l, int _u);
void Execute();
void Execute_Linear();
void Execute_Cubic();
};

View File

@@ -1,3 +0,0 @@
1 2 4
4 5 6
7 8 9