- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用 Eigen 分解稀疏 SPD 矩阵 A。它将是 LLt 或 LDLt 分解 (Cholesky),因此我们可以假设矩阵将分解为D 对角线(可能是恒等式)。如果我这样做
SolverClassName<SparseMatrix<double> > solver;
solver.compute(A);
要解决 Lx=b
那么执行以下操作是否有效?
solver.matrixL().TriangularView<Lower>().solve(b)
类似地,要解决 Px=b
那么执行以下操作是否有效?
solver.permutationPinv()*b
我想这样做是为了高效稳定地计算bt A-1 b
。
最佳答案
看看 _solve_impl
是如何为 SimplicialCholesky
实现的。本质上,你可以简单地写:
Eigen::VectorXd x = solver.permutationP()*b; // P not Pinv!
solver.matrixL().solveInPlace(x); // matrixL is already a triangularView
// depending on LLt or LDLt use either:
double res_llt = x.squaredNorm();
double res_ldlt = x.dot(solver.vectorD().asDiagonal().inverse()*x);
请注意,您需要乘以 P
而不是 Pinv
,因为A = P^-1 L D L^t P
是
P^-1 L^-t D^-1 L^-1 P
因为在对乘积求逆时矩阵的顺序会颠倒。
关于c++ - 当 A=LLt 时求解 Lx=b 和 Px=b,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49412750/
首先,我认为问题出在我身上,而不是 Eigen 的 LLT 模块。也就是说,这是代码(我将简要解释问题)但是在 Rstudio 中获取代码应该会重现错误。 #include using namesp
我写了下面的函数: template inline static boost::any ApplyCholesky(boost::any const& A, boost::any const&
我正在使用 Eigen 3 的 Cholesky 模块求解线性方程组。 Eigen 文档指出,使用 LDLT而不是 LLT为此目的会更快,但我的基准测试显示不同的结果。 我使用以下代码进行基准测试:
我正在使用 Eigen 分解稀疏 SPD 矩阵 A。它将是 LLt 或 LDLt 分解 (Cholesky),因此我们可以假设矩阵将分解为D 对角线(可能是恒等式)。如果我这样做 SolverClas
我正在尝试使用 Eigen::CholmodSupernodalLLT然而,对于 Cholesky 分解,我似乎无法得到 matrixL()和 matrixU() .如何提取matrixL()和 ma
我是一名优秀的程序员,十分优秀!