MCPcopy Create free account
hub / github.com/PX4/eigen / main

Function main

doc/special_examples/Tutorial_sparse_example.cpp:10–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8void saveAsBitmap(const Eigen::VectorXd& x, int n, const char* filename);
9
10int main(int argc, char** argv)
11{
12 assert(argc==2);
13
14 int n = 300; // size of the image
15 int m = n*n; // number of unknows (=number of pixels)
16
17 // Assembly:
18 std::vector<T> coefficients; // list of non-zeros coefficients
19 Eigen::VectorXd b(m); // the right hand side-vector resulting from the constraints
20 buildProblem(coefficients, b, n);
21
22 SpMat A(m,m);
23 A.setFromTriplets(coefficients.begin(), coefficients.end());
24
25 // Solving:
26 Eigen::SimplicialCholesky<SpMat> chol(A); // performs a Cholesky factorization of A
27 Eigen::VectorXd x = chol.solve(b); // use the factorization to solve for the given right hand side
28
29 // Export the result to a file:
30 saveAsBitmap(x, n, argv[1]);
31
32 return 0;
33}
34

Callers

nothing calls this directly

Calls 6

buildProblemFunction · 0.85
saveAsBitmapFunction · 0.85
beginMethod · 0.80
endMethod · 0.80
setFromTripletsMethod · 0.45
solveMethod · 0.45

Tested by

no test coverage detected