Re: [eigen] How to compute the inverse of a sparse matrix? And how ist computeInverseWithCheck(..) used correctly?

```Am 30.09.2010 14:41, Mathias Goldau wrote:
> Is there a way in Eigen to compute the inverse of a sparse matrix?
>
> ATM I try to do that for dense matrix, and read the doc so I am aware that in
> case of non invertibility the result is undefined. So I looked into the repos
> and found: computeInverseWithCheck(..) function.
> But if I try to use it it aborts with:
>
> In file included from /usr/local/eigen/include/eigen3/Eigen/LU:27,
>                  from
> /home/math/repos/Wassermann/src/modules/detTract2GPConvert/WGaussProcess.cpp:25:
> /usr/local/eigen/include/eigen3/Eigen/src/LU/Inverse.h: In member function
> ‘void Eigen::MatrixBase<Derived>::computeInverseAndDetWithCheck(ResultType&,
> typename ResultType::Scalar&, bool&, const typename Eigen::NumTraits<typename
> Eigen::ei_traits<Derived>::Scalar>::Real&) const [with ResultType =
> Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001, 0,
> -0x00000000000000001, -0x00000000000000001>, Derived = Eigen::Matrix<double,
> -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001,
> -0x00000000000000001>]’:
> /usr/local/eigen/include/eigen3/Eigen/src/LU/Inverse.h:400:   instantiated
> from ‘void Eigen::MatrixBase<Derived>::computeInverseWithCheck(ResultType&,
> bool&, const typename Eigen::NumTraits<typename
> Eigen::ei_traits<Derived>::Scalar>::Real&) const [with ResultType =
> Eigen::MatrixXd, Derived = Eigen::Matrix<double, -0x00000000000000001,
> -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>]’
> /home/math/repos/Wassermann/src/modules/detTract2GPConvert/WGaussProcess.cpp:53:
>   instantiated from here
> /usr/local/eigen/include/eigen3/Eigen/src/LU/Inverse.h:368: error: ‘run’ is
> not a member of
> ‘Eigen::ei_compute_inverse_and_det_with_check<Eigen::Matrix<double,
> -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001,
> -0x00000000000000001>, Eigen::Matrix<double, -0x00000000000000001,
> -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001>,
> -0x00000000000000001>’
>
> The calling code looks like this:
>
> Eigen::MatrixXd Cff( static_cast< int >( tract.size() ), static_cast< int >(
> tract.size() ) );
> size_t i = 0, j = 0;
> for( WFiber::const_iterator cit = tract.begin(); cit != tract.end(); ++cit, ++i )
> {
>     for( WFiber::const_iterator cit2 = tract.begin(); cit2 != tract..end();
> ++cit2, ++j )
>     {
>         Cff( i, j ) = cov( *cit, *cit2 );
>     }
> }
> bool isInvertible = false;
> Cff.computeInverseWithCheck( m_CffInverse, isInvertible );
>
> I want to use eigen for many covariance matrix which I assume to be sparse.
> But until I know how to compute the inverse of a spares matrix with eigen, I
> will use dense matrices at first...

BTW: Is there an implementation for pseudo inverse matrices aka moore-penrose
inverse. Luckily for sparse matrices?

--
Institut für Informatik
Universität Leipzig
Johannisgasse 26, 04103 Leipzig
Phone: +493419732283

```

• Follow-Ups:
• References:

 Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/