This forum has been archived. All content is frozen. Please use KDE Discuss instead.

analyzePattern of Eigen::SparseQR fails

Tags: None
(comma "," separated)
User avatar
Hecke
Registered Member
Posts
16
Karma
0
Hi All,

this is similar to Naval's question here:
viewtopic.php?f=74&t=120694

My setting: I have a non-quadratic sparse matrix (N+1xN) with rank N and want to solve it.
Now I am left with SparseQR as the other solvers require a quadratic matrix, right?

I use
Code: Select all
   SparseQR<SparseMatrix<double,ColMajor>, COLAMDOrdering<int>  > phi_solver_ ;


and then
Code: Select all
      phi_solver_.analyzePattern(phi_matrix_);


gives no compiler warning, but a very similar Assertion failed during the run:
Code: Select all
 
karman: /home/hecke/turb/channelflow/eigen3/Eigen/src/OrderingMethods/Ordering.h:141: void Eigen::COLAMDOrdering<Index>::operator()(const MatrixType&, Eigen::COLAMDOrdering<Index>::PermutationType&) [with MatrixType = Eigen::SparseMatrix<double>; Index = int; Eigen::COLAMDOrdering<Index>::PermutationType = Eigen::PermutationMatrix<-1>]: Assertion `info && "COLAMD failed "' failed.


If I compile in release mode I get a segfault...

Unfortunately, I cannot find enough info to solve this on my own, so here's my cry for help!

addendum:
If I change the Ordering method to NaturalOdering, (which seems kind of justified as the coefficients in my matrix are all in a tight range and there are similarly many coefficients in one column) analyzePattern() runs fine, but I get a problem from within factorize()

Code: Select all
karman: /home/hecke/turb/channelflow/nsolver/../eigen3/Eigen/src/Core/DenseCoeffsBase.h:394: Eigen::DenseCoeffsBase<Derived, 1>::Scalar& Eigen::DenseCoeffsBase<Derived, 1>::operator()(Eigen::DenseCoeffsBase<Derived, 1>::Index) [with Derived = Eigen::Matrix<int, -1, 1>; Eigen::DenseCoeffsBase<Derived, 1>::Scalar = int; Eigen::DenseCoeffsBase<Derived, 1>::Index = long int]: Assertion `index >= 0 && index < size()' failed.


Still, there seems to be a problem with a matrix having more rows than columns...

thanks a bunch
Hecke
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Can you try with the latest "stable" branch (https://bitbucket.org/eigen/eigen/get/3.2.tar.bz2) or even the devel branch to make sure this issue has not been solved already. Otherwise, please save you matrix to a zipped file so that we can check what's going wrong.

Code: Select all
#include <unsupported/Eigen/SparseExtra>
...
Eigen::saveMarket(A, "filename.mtx", Eigen::Symmetric);
Eigen::saveMarketVector(B, "filename_b.mtx");
User avatar
Hecke
Registered Member
Posts
16
Karma
0
Hey Ggael,

I was really hoping for you to chime in. Thanks a lot!

I used the latest stable version, and trying the unstable one leads to the same error.

You find the matrix producing the error here:
http://www.nld.ds.mpg.de/~hecke/archiv/phi_matrix.zip

If I can be of any help, please let me know.

cheers
Hecke
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
hm, it works very well for me.

Perhaps try to call phi_matrix_.makeCompress() before passing it to SparseQR?

Code: Select all
#include <Eigen/SparseQR>
#include <iostream>
#include <unsupported/Eigen/SparseExtra>
using namespace Eigen;
int main(int argc, char** argv)
{
  typedef SparseMatrix<double> SpMat;
  SpMat A;
  loadMarket(A, argv[1]);
 
  SparseQR<SpMat,COLAMDOrdering<int> > qr(A);
  std::cout << qr.info() << " == " << Success << "\n\n";
 
  VectorXd x(A.cols()), b(A.rows());
  x.setRandom();
  b = A * x;
  x.setZero();
 
  x = qr.solve(b);
  std::cout << qr.info() << " == " << Success << "\n\n";
  std::cout << "err: " << (A*x-b).norm() / b.norm() << "\n";
 
  return 0;
}
User avatar
Hecke
Registered Member
Posts
16
Karma
0
Great, Ggael,

that did the trick.

you are my hero!

thanks.
Hecke
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
User avatar
Hecke
Registered Member
Posts
16
Karma
0
Yep, now it is hard to miss ;-)

thanks again
Hecke


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell, Yahoo [Bot]