test_LDLT.py
Go to the documentation of this file.
1 import numpy as np
2 
3 import eigenpy
4 
5 dim = 100
6 rng = np.random.default_rng()
7 
8 A = rng.random((dim, dim))
9 A = (A + A.T) * 0.5 + np.diag(10.0 + rng.random(dim))
10 
11 ldlt = eigenpy.LDLT(A)
12 
13 L = ldlt.matrixL()
14 D = ldlt.vectorD()
15 P = ldlt.transpositionsP()
16 
17 assert eigenpy.is_approx(
18  np.transpose(P).dot(L.dot(np.diag(D).dot(np.transpose(L).dot(P)))), A
19 )
20 
21 X = rng.random((dim, 20))
22 B = A.dot(X)
23 X_est = ldlt.solve(B)
24 assert eigenpy.is_approx(X, X_est)
25 assert eigenpy.is_approx(A.dot(X_est), B)
eigenpy::is_approx
EIGEN_DONT_INLINE bool is_approx(const Eigen::SparseMatrixBase< MatrixType1 > &mat1, const Eigen::SparseMatrixBase< MatrixType2 > &mat2)
Definition: is-approx.hpp:36


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Wed Jun 5 2024 02:14:54