test_SimplicialLLT.py
Go to the documentation of this file.
1 import numpy as np
2 from scipy.sparse import csc_matrix
3 
4 import eigenpy
5 
6 dim = 100
7 rng = np.random.default_rng()
8 
9 A = rng.random((dim, dim))
10 A = (A + A.T) * 0.5 + np.diag(10.0 + rng.random(dim))
11 
12 A = csc_matrix(A)
13 
14 llt = eigenpy.SimplicialLLT(A)
15 
16 assert llt.info() == eigenpy.ComputationInfo.Success
17 
18 L = llt.matrixL()
19 U = llt.matrixU()
20 
21 LU = L @ U
22 assert eigenpy.is_approx(LU.toarray(), A.toarray())
23 
24 X = rng.random((dim, 20))
25 B = A.dot(X)
26 X_est = llt.solve(B)
27 assert eigenpy.is_approx(X, X_est)
28 assert eigenpy.is_approx(A.dot(X_est), B)
29 
30 llt.analyzePattern(A)
31 llt.factorize(A)
32 permutation = llt.permutationP()
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 Sat Nov 2 2024 02:14:45