Re: [eigen] Setting diagonal of a sparse matrix |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
I was using eigen-3.2.7. Changing to
using hg to clone the current version of the repository from
https://bitbucket.org/eigen/eigen/ the following example now runs (Thanks Peter): # include <Eigen/SparseCore> # include <iostream> int main() { using Eigen::Dynamic; using Eigen::Lower; typedef Eigen::Matrix<double, Dynamic, 1> vector; typedef Eigen::SparseMatrix<double> sparse_matrix; typedef Eigen::TriangularView<sparse_matrix, Lower> sparse_lower_view; // sparse_matrix sA(3, 3); sA.setIdentity(); sA.diagonal() = sA.diagonal() / 2.0; vector b = vector::Ones(3); // sparse_lower_view sL(sA); vector x = sL.solve(b); std::cout << "x =\n" << x << "\n"; } On 9/22/2016 7:24 AM, Brad Bell wrote: My actual problem is quite complex. I do some computation, end of with a symmetric matrix, and must divide the diagonal by two. On top of that, in some cases, I must take the lower triangular view and do a solve. The exact mathematics can be found at... snip ... |
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |