Re: [eigen] Block sparse matrices and std vector compilation error

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


I am not sure about the problem.

It compiles with g++ 4.8.2

It is a good idea to define use typedef or some other construction
to further simplify the program. For example the following compiles
as well:
------------------------------------------
#include <iostream>
#include <Eigen/Dense>
#include <Eigen/Sparse>

typedef Eigen::SparseMatrix<double, Eigen::ColMajor> MyMatrix;

int main(int argc, char** argv)
{
  MyMatrix A_sparse(10, 10);
  std::vector<Eigen::Block<MyMatrix> > sparse_block_vector;
  Eigen::Block<MyMatrix> sparse_block = A_sparse.block(0, 0, 5, 5);
  sparse_block_vector.push_back(sparse_block);
}
-----------------------------------
Best,

  Mathieu

On Wed, Nov 26, 2014 at 1:04 PM, Hilario Tomé <tome.hilario@xxxxxxxxx> wrote:
Dear all,


I am interested in storing block sparse matrices in std vectors but get a compiling error, the error does not happen for dense matrices. I am using Eigen 3.2.2 with gcc version 4.6.3


Here is small code to reproduce the problem

#include <iostream>
#include <Eigen/Dense>
#include <Eigen/Sparse>

int main(int argc, char** argv){

  Eigen::SparseMatrix<double, Eigen::ColMajor> A_sparse(10, 10);
  std::vector< Eigen::Block<Eigen::SparseMatrix<double, Eigen::ColMajor> > > sparse_block_vector;
  Eigen::Block<Eigen::SparseMatrix<double, Eigen::ColMajor> > sparse_block = A_sparse.block(0, 0, 5, 5);
  sparse_block_vector.push_back(sparse_block);

}

And the error output

In file included from ../include/Eigen/Eigen/SparseCore:37:0,
                 from ../include/Eigen/Eigen/Sparse:19,
                 from eigen_vector_blocks_error.cpp:3:
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h: In member function ‘Derived& Eigen::SparseMatrixBase<Derived>::assign(const OtherDerived&) [with OtherDerived = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>, Derived = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’:
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:196:36:   instantiated from ‘Derived& Eigen::SparseMatrixBase<Derived>::operator=(const Derived&) [with Derived = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
../include/Eigen/Eigen/src/Core/Block.h:110:5:   instantiated from ‘Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>& Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::operator=(const Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>&) [with XprType = Eigen::SparseMatrix<double, 0>, int BlockRows = -0x00000000000000001, int BlockCols = -0x00000000000000001, bool InnerPanel = false, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel> = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
/usr/include/c++/4.6/bits/vector.tcc:317:4:   instantiated from ‘void std::vector<_Tp, _Alloc>::_M_insert_aux(std::vector<_Tp, _Alloc>::iterator, const _Tp&) [with _Tp = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>, _Alloc = std::allocator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> >, std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>*, std::vector<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> > >, typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>*]’
/usr/include/c++/4.6/bits/stl_vector.h:834:4:   instantiated from ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>, _Alloc = std::allocator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> >, std::vector<_Tp, _Alloc>::value_type = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
eigen_vector_blocks_error.cpp:10:45:   instantiated from here
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:210:9: error: ‘class Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>’ has no member named ‘resize’
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:211:9: error: ‘class Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>’ has no member named ‘setZero’
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:212:9: error: ‘class Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>’ has no member named ‘reserve’
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:196:36:   instantiated from ‘Derived& Eigen::SparseMatrixBase<Derived>::operator=(const Derived&) [with Derived = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
../include/Eigen/Eigen/src/Core/Block.h:110:5:   instantiated from ‘Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>& Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::operator=(const Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>&) [with XprType = Eigen::SparseMatrix<double, 0>, int BlockRows = -0x00000000000000001, int BlockCols = -0x00000000000000001, bool InnerPanel = false, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel> = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
/usr/include/c++/4.6/bits/vector.tcc:317:4:   instantiated from ‘void std::vector<_Tp, _Alloc>::_M_insert_aux(std::vector<_Tp, _Alloc>::iterator, const _Tp&) [with _Tp = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>, _Alloc = std::allocator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> >, std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>*, std::vector<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> > >, typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>*]’
/usr/include/c++/4.6/bits/stl_vector.h:834:4:   instantiated from ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>, _Alloc = std::allocator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> >, std::vector<_Tp, _Alloc>::value_type = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
eigen_vector_blocks_error.cpp:10:45:   instantiated from here
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:215:11: error: ‘class Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>’ has no member named ‘startVec’
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:196:36:   instantiated from ‘Derived& Eigen::SparseMatrixBase<Derived>::operator=(const Derived&) [with Derived = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
../include/Eigen/Eigen/src/Core/Block.h:110:5:   instantiated from ‘Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>& Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::operator=(const Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>&) [with XprType = Eigen::SparseMatrix<double, 0>, int BlockRows = -0x00000000000000001, int BlockCols = -0x00000000000000001, bool InnerPanel = false, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel> = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
/usr/include/c++/4.6/bits/vector.tcc:317:4:   instantiated from ‘void std::vector<_Tp, _Alloc>::_M_insert_aux(std::vector<_Tp, _Alloc>::iterator, const _Tp&) [with _Tp = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>, _Alloc = std::allocator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> >, std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>*, std::vector<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> > >, typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>*]’
/usr/include/c++/4.6/bits/stl_vector.h:834:4:   instantiated from ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>, _Alloc = std::allocator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> >, std::vector<_Tp, _Alloc>::value_type = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
eigen_vector_blocks_error..cpp:10:45:   instantiated from here
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:219:13: error: ‘class Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>’ has no member named ‘insertBackByOuterInner’
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:196:36:   instantiated from ‘Derived& Eigen::SparseMatrixBase<Derived>::operator=(const Derived&) [with Derived = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
../include/Eigen/Eigen/src/Core/Block.h:110:5:   instantiated from ‘Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>& Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::operator=(const Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>&) [with XprType = Eigen::SparseMatrix<double, 0>, int BlockRows = -0x00000000000000001, int BlockCols = -0x00000000000000001, bool InnerPanel = false, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel> = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
/usr/include/c++/4.6/bits/vector.tcc:317:4:   instantiated from ‘void std::vector<_Tp, _Alloc>::_M_insert_aux(std::vector<_Tp, _Alloc>::iterator, const _Tp&) [with _Tp = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>, _Alloc = std::allocator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> >, std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>*, std::vector<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> > >, typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>*]’
/usr/include/c++/4.6/bits/stl_vector.h:834:4:   instantiated from ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>, _Alloc = std::allocator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> >, std::vector<_Tp, _Alloc>::value_type = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
eigen_vector_blocks_error.cpp:10:45:   instantiated from here
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:222:9: error: ‘class Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>’ has no member named ‘finalize’
In file included from ../include/Eigen/Eigen/SparseCore:37:0,
                 from ../include/Eigen/Eigen/Sparse:19,
                 from eigen_vector_blocks_error.cpp:3:
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h: In member function ‘void Eigen::SparseMatrixBase<Derived>::assignGeneric(const OtherDerived&) [with OtherDerived = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>, Derived = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’:
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:226:9:   instantiated from ‘Derived& Eigen::SparseMatrixBase<Derived>::assign(const OtherDerived&) [with OtherDerived = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>, Derived = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:196:36:   instantiated from ‘Derived& Eigen::SparseMatrixBase<Derived>::operator=(const Derived&) [with Derived = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
../include/Eigen/Eigen/src/Core/Block.h:110:5:   instantiated from ‘Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>& Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::operator=(const Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>&) [with XprType = Eigen::SparseMatrix<double, 0>, int BlockRows = -0x00000000000000001, int BlockCols = -0x00000000000000001, bool InnerPanel = false, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel> = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
/usr/include/c++/4.6/bits/vector.tcc:317:4:   instantiated from ‘void std::vector<_Tp, _Alloc>::_M_insert_aux(std::vector<_Tp, _Alloc>::iterator, const _Tp&) [with _Tp = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>, _Alloc = std::allocator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> >, std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>*, std::vector<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> > >, typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type::pointer = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>*]’
/usr/include/c++/4.6/bits/stl_vector.h:834:4:   instantiated from ‘void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>, _Alloc = std::allocator<Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false> >, std::vector<_Tp, _Alloc>::value_type = Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>]’
eigen_vector_blocks_error.cpp:10:45:   instantiated from here
.../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:245:46: error: no matching function for call to ‘Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>::Block(int, int)’
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:245:46: note: candidates are:
../include/Eigen/Eigen/src/Core/Block.h:133:12: note: Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::Block(XprType&, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::Index, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::Index, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::Index, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::Index) [with XprType = Eigen::SparseMatrix<double, 0>, int BlockRows = -0x00000000000000001, int BlockCols = -0x00000000000000001, bool InnerPanel = false, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::Index = int]
../include/Eigen/Eigen/src/Core/Block.h:133:12: note:   candidate expects 5 arguments, 2 provided
../include/Eigen/Eigen/src/Core/Block.h:123:12: note: Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::Block(XprType&, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::Index, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::Index) [with XprType = Eigen::SparseMatrix<double, 0>, int BlockRows = -0x00000000000000001, int BlockCols = -0x00000000000000001, bool InnerPanel = false, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::Index = int]
../include/Eigen/Eigen/src/Core/Block.h:123:12: note:   candidate expects 3 arguments, 2 provided
../include/Eigen/Eigen/src/Core/Block.h:114:12: note: Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::Block(XprType&, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::Index) [with XprType = Eigen::SparseMatrix<double, 0>, int BlockRows = -0x00000000000000001, int BlockCols = -0x00000000000000001, bool InnerPanel = false, Eigen::Block<XprType, BlockRows, BlockCols, InnerPanel>::Index = int]
../include/Eigen/Eigen/src/Core/Block.h:114:12: note:   no known conversion for argument 1 from ‘int’ to ‘Eigen::SparseMatrix<double, 0>&’
../include/Eigen/Eigen/src/Core/Block.h:102:81: note: Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>::Block(const Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>&)
../include/Eigen/Eigen/src/Core/Block.h:102:81: note:   candidate expects 1 argument, 2 provided
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:247:7: error: ‘class Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>’ has no member named ‘reserve’
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:250:9: error: ‘class Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>’ has no member named ‘startVec’
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:254:11: error: ‘class Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>’ has no member named ‘insertBackByOuterInner’
../include/Eigen/Eigen/src/SparseCore/SparseMatrixBase.h:257:7: error: ‘class Eigen::Block<Eigen::SparseMatrix<double, 0>, -0x00000000000000001, -0x00000000000000001, false>’ has no member named ‘finalize’

Does somebody have an insight on why this is happening?

Best,

--
Hilario.



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