LU decomposition을 이용한 solve
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | //Ax = v mxd::t A(3,3); vxd::t v(3); A << 1,2,3, 4,5,6, 7,8,10; v << 3,3,4; co(A, "here is the mat A :"); co(v, "here is the vec b :"); vxd::t x = A.fullPivLu().solve(v); co(x, "solution x :"); | cs |
llt를 이용한 solve
1 2 3 4 5 6 7 8 9 10 11 12 13 | m2d::t A; v2d::t b; A << 2, -1, -1, 3; b << 1, 2; co(A, "mat A :"); co(b, "vec b :"); v2d::t x = A.llt().solve(b); co(x, "solution : "); | cs |
오차 검정
1 2 3 4 5 6 7 8 9 | mxd::t A = mxd::t::Random(100, 100); mxd::t b = mxd::t::Random(100,50); mxd::t x = A.fullPivLu().solve(b); d::t relative_error = (A*x - b).norm() /b.norm(); co(relative_error, "relative error is :"); | cs |
'Linear Algebra' 카테고리의 다른 글
[Eigen] 아이겐을 사용한 선형대수 복습 1일차 (0) | 2019.05.21 |
---|---|
[Eigen] extracting a vector from the vector space (0) | 2019.05.21 |
[Eigen]Blocking (0) | 2019.05.21 |
[C++] Eigen 사용법 2.초기화 (0) | 2019.05.21 |
[C++] Eigen 사용법 1.메뉴얼 (0) | 2019.02.04 |