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

conservativeResize of a DenseBase<Derived>

Tags: None
(comma "," separated)
martinakos
Registered Member
Posts
53
Karma
0
OS
Hi,

I'm creating a helper function to append a dense matrix at the bottom of another one. This is the code:

Code: Select all
   template<class Derived>
   void v_append(Eigen::DenseBase<Derived> &data, const Eigen::DenseBase<Derived> &append)
   {
      assert(data.cols() == append.cols());
      int initial_length = data.rows();
      data.derived().conservativeResize(initial_length + append.rows(), NoChange);
      data.block(initial_length, 0, append.rows(), append.cols()) = append;
   }


This seems to work for Matrixes of more than one column and rows.
But when I use it with data and append being ArrayXi I get a non very clear compiler error, which I assume it's down to conservativeResize having a single parameter for column Vectors.
How can I change this code so that it can work for both Matrixes (of more than one column and rows) and column Vectors?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
Please post the error you get. As a side note instead of block, you can use data.bottomRows(append.rows()) = append;
martinakos
Registered Member
Posts
53
Karma
0
OS
The compile error is:

Code: Select all
1>t:\eigen\eigen3.2\eigen\src\core\plainobjectbase.h(341) : error C2661: 'Eigen::internal::conservative_resize_like_impl<Derived>::run' : no overloaded function takes 3 arguments
1>        with
1>        [
1>            Derived=Eigen::Array<int,-1,1>
1>        ]
1>        t:\eigen\eigen3.2\eigen\src\core\plainobjectbase.h(340) : while compiling class template member function 'void Eigen::PlainObjectBase<Derived>::conservativeResize(__w64 int,__w64 int)'
1>        with
1>        [
1>            Derived=Eigen::Array<int,-1,1>
1>        ]
1>        t:\eigen\eigen3.2\eigen\src\core\array.h(44) : see reference to class template instantiation 'Eigen::PlainObjectBase<Derived>' being compiled
1>        with
1>        [
1>            Derived=Eigen::Array<int,-1,1>
1>        ]
1>        frames_v2.h(42) : see reference to class template instantiation 'Eigen::Array<_Scalar,_Rows,_Cols>' being compiled
1>        with
1>        [
1>            _Scalar=int,
1>            _Rows=-1,
1>            _Cols=1
1>        ]


Compiler is Visual Studio 2008 Express.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
alright, this is fixed in the devel branch and backported in 3.2:

https://bitbucket.org/eigen/eigen/commits/eb7573ee22e4/
Changeset: eb7573ee22e4
User: ggael
Date: 2013-10-16 12:07:33
Summary: Allow .conservativeResize(rows,cols) on vectors


Bookmarks



Who is online

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