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


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Tue Jan 23 2024 03:15:01