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

CholmodSuppurt.h compile error

Tags: None
(comma "," separated)
kimsoohwan
Registered Member
Posts
7
Karma
0

CholmodSuppurt.h compile error

Fri Aug 30, 2013 5:37 am
Hi,

I'm trying to use Eigen with SuiteSparse for matrix inversion.
I've included header files and linked with the libraries in Visual Studio on Windows using suitesparse-metis-for-windows.
(https://code.google.com/p/suitesparse-m ... r-windows/)

When I "compute" the Cholesky factor with Eigen::CholmodSupernodalLLT, it works fine.
But when I add a line of code to "solve" a linear equation, it produces compile errors.
I don't know what to do. Please, help!
Thank you very much in advance.

Code: Select all
const int n = 5000;
Eigen::SparseMatrix<double> sparseMatrix(n, n);
Eigen::MatrixXd denseMatrix(n, n);

// initializing the sparse matrix

Eigen::CholmodSupernodalLLT<EigenSparseMatrix, Eigen::Upper> cholmodCholLLT;
cholmodCholLLT.compute(sparseMatrix); // OK
denseMatrix = cholmodCholLLT.solve(Eigen::MatrixXd::Identity(n, n)); // Compile Error!


[Error]
Error 1 error C2440: '=' : cannot convert from 'void' to 'size_t' e:\documents\eigen-3.1.0\eigen\src\CholmodSupport\CholmodSupport.h 125
Error 2 error C2039: 'data' : is not a member of 'Eigen::CwiseNullaryOp<NullaryOp,PlainObjectType>' e:\documents\eigen-3.1.0\eigen\src\CholmodSupport\CholmodSupport.h 126

The errors come from the function, viewAsCholmod in CholmodSuppurt.h
Code: Select all
template<typename Derived>
cholmod_dense viewAsCholmod(MatrixBase<Derived>& mat)
{
  EIGEN_STATIC_ASSERT((internal::traits<Derived>::Flags&RowMajorBit)==0,THIS_METHOD_IS_ONLY_FOR_COLUMN_MAJOR_MATRICES);
  typedef typename Derived::Scalar Scalar;

  cholmod_dense res;
  res.nrow   = mat.rows();
  res.ncol   = mat.cols();
  res.nzmax  = res.nrow * res.ncol;
  res.d      = Derived::IsVectorAtCompileTime ? mat.derived().size() : mat.derived().outerStride(); // Error 1 (Line 125)
  res.x      = mat.derived().data(); // Error 2 (Line 126)
  res.z      = 0;

  internal::cholmod_configure_matrix<Scalar>(res);

  return res;
}
kimsoohwan
Registered Member
Posts
7
Karma
0

Re: CholmodSuppurt.h compile error

Fri Aug 30, 2013 6:16 am
Could you explain how to "compute" and "solve" with Eigen::CholmodSupernodalLLT?
Simple codes or reference URLs are welcomed.
Thank you so much.
kimsoohwan
Registered Member
Posts
7
Karma
0

Re: CholmodSuppurt.h compile error

Fri Aug 30, 2013 6:39 am
I just found that it only works well with a vector argument.

That is, instead of
denseMatrix = cholmodCholLLT.solve(Eigen::MatrixXd::Identity(n, n));

this works well,
VectorXd x(n);
VectorXd b(n);
x = cholmodCholLLT.solve(b);

So, I think that the choleskey solvers are only for linear equations, not for matrix inversion.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: CholmodSuppurt.h compile error

Fri Aug 30, 2013 6:44 am
no, the problem is more likely that is does not accept expression. Doing MatrixXd I = MatrixXd::Identity(n,n); and then call solve on I should do the job. However, internally, cholmod only deals with right hand side vectors, so the solving will happen one column at once.


Bookmarks



Who is online

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