forked from EPCCed/archer2-cpp
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexplicit.cpp
More file actions
48 lines (37 loc) · 917 Bytes
/
Copy pathexplicit.cpp
File metadata and controls
48 lines (37 loc) · 917 Bytes
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
#include <Eigen/Dense>
#include <fstream>
#include <iostream>
#include <vector>
int main()
{
int n = 20;
int steps = 200;
std::vector<double> Avec(n * n);
// Set up matrix A
Eigen::Map<Eigen::MatrixXd> A(Avec.data(), n, n);
A = Eigen::MatrixXd::Identity(n, n);
double delta = 0.4;
for (int i = 0; i < n - 1; ++i)
{
A(i + 1, i) += delta;
A(i + 1, i + 1) += -delta;
A(i, i) += -delta;
A(i, i + 1) += +delta;
}
std::cout << "A = \n" << A << std::endl
<< std::endl;
// T_n
Eigen::VectorXd b(n);
b.setZero();
b.head(n / 2).array() = 1.0;
std::ofstream f;
f.open("explicit_sim.txt");
for (int i = 0; i < steps; ++i)
{
f << b.transpose() << std::endl;
// update time-step T_{n+1} = A.T_{n}
b = A * b;
}
std::cout << b.transpose() << std::endl;
return 0;
}