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

Problem with product of sparse integer matrices

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

the following program
Code: Select all
#include <iostream>
#include <Eigen/Eigen>

using namespace Eigen;

int main()
{
  //typedef SparseMatrix<float> SM;   //this works...
  typedef SparseMatrix<int> SM;
 
  SM m1(2, 2);
  SM m2(2, 2);
  SM m3 = m1 * m2;
}

triggers these error messages:
In file included from ../eigen2/Eigen/Sparse:89,
from ../eigen2/Eigen/Eigen:2,
from main.cpp:2:
../eigen2/Eigen/src/Sparse/AmbiVector.h: In instantiation of »Eigen::AmbiVector<int>«:
../eigen2/Eigen/src/Sparse/SparseProduct.h:176: instantiated from »void Eigen::ei_sparse_product_impl(const Lhs&, const Rhs&, ResultType&) [with Lhs = Eigen::SparseMatrix<int, 0>, Rhs = Eigen::SparseMatrix<int, 0>, ResultType = Eigen::SparseMatrix<int, 0>]«
../eigen2/Eigen/src/Sparse/SparseProduct.h:224: instantiated from »static void Eigen::ei_sparse_product_selector<Lhs, Rhs, ResultType, 0, 0, 0>::run(const Lhs&, const Rhs&, ResultType&) [with Lhs = Eigen::SparseMatrix<int, 0>, Rhs = Eigen::SparseMatrix<int, 0>, ResultType = Eigen::SparseMatrix<int, 0>]«
../eigen2/Eigen/src/Sparse/SparseProduct.h:300: instantiated from »Derived& Eigen::SparseMatrixBase<Derived>::operator=(const Eigen::SparseProduct<Lhs, Rhs, 2>&) [with Lhs = const Eigen::SparseMatrix<int, 0>&, Rhs = const Eigen::SparseMatrix<int, 0>&, Derived = Eigen::SparseMatrix<int, 0>]«
../eigen2/Eigen/src/Sparse/SparseMatrix.h:486: instantiated from »Eigen::SparseMatrix<_Scalar, _Flags>& Eigen::SparseMatrix<_Scalar, _Flags>::operator=(const Eigen::SparseMatrixBase<OtherDerived>&) [with OtherDerived = Eigen::SparseProduct<const Eigen::SparseMatrix<int, 0>&, const Eigen::SparseMatrix<int, 0>&, 2>, _Scalar = int, int _Options = 0]«
../eigen2/Eigen/src/Sparse/SparseMatrix.h:403: instantiated from »Eigen::SparseMatrix<_Scalar, _Flags>::SparseMatrix(const Eigen::SparseMatrixBase<OtherDerived>&) [with OtherDerived = Eigen::SparseProduct<const Eigen::SparseMatrix<int, 0>&, const Eigen::SparseMatrix<int, 0>&, 2>, _Scalar = int, int _Options = 0]«
main.cpp:13: instantiated from here
../eigen2/Eigen/src/Sparse/AmbiVector.h:155: Fehler: »void Eigen::AmbiVector<_Scalar>::init(int) [with _Scalar = int]« kann nicht überladen werden
../eigen2/Eigen/src/Sparse/AmbiVector.h:146: Fehler: mit »void Eigen::AmbiVector<_Scalar>::init(typename Eigen::NumTraits<_Real>::Real) [with _Scalar = int]«



With float instead of int, everything works fine. Is this a bug in the sparse module? I'm using the current development branch, and g++ 4.4.1.

Best regards,
Martin
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
hi, problem fixed, thanks for the report.
djp
Registered Member
Posts
7
Karma
0
Thanks a lot for your quick help!

I just noticed another thing which does not work, namely multiplying a sparse matrix with a sparse vector. It works when I manually cast the SparseVector<T> into a SparseMatrix<T>, but I think that matrix times vector should also work directly. On the other hand, the case sv=sm*sv is missing in the list of supported operations in the tutorial, so perhaps this case is not supported for some reason.

Best regards,
Martin


Bookmarks



Who is online

Registered users: Bing [Bot], daret, Google [Bot], sandyvee, Sogou [Bot]