Registered Member
|
Hi all
Recently I have tried to pass a matrix converted to an array to a function template taking array as argument and resizes the array. I have read the tutorial page http://eigen.tuxfamily.org/dox/TopicFun ... Types.html and implemented the function resizePassedParameterTest according to. template<typename Derived> void resizePassedParameterTest(const Eigen::ArrayBase<Derived>& param_) { // create a modifiable reference of parameter TH_ Eigen::ArrayBase<Derived>& param = const_cast< Eigen::ArrayBase<Derived>& >(param_); param.derived().resize(param.rows()+1, param.cols()+1 ); } Within main, call the function and pass a converted matrix using .array() main() { Eigen::MatrixXd test(3,7); resizePassedParameterTest(test.array()); } This yields a runtime error. What did I do wrong? What is the solution for this? DenseBase.h:235: void Eigen::DenseBase<Derived>::resize(typename Eigen::internal::traits<T>::Index, typename Eigen::internal::traits<T>::Index) [with Derived = Eigen::ArrayWrapper<Eigen::Matrix<double, -0x00000000000000001, -0x00000000000000001, 0, -0x00000000000000001, -0x00000000000000001> >]: Assertion `rows == this->rows() && cols == this->cols() && "DenseBase::resize() does not actually allow to resize."' failed. |
Moderator
|
Right, mat.array() was considered like a general read/write expression like mat.transpose(). This is fixed now:
https://bitbucket.org/eigen/eigen/chang ... 16488639a/ changeset: 97e16488639a user: ggael date: 2012-08-30 16:28:53 summary: forward resize() function from Array/Matrix-Wrapper to the nested expression such that mat.array().resize(a,b) is now allowed. |
Registered users: Baidu [Spider], Bing [Bot], Google [Bot], Yahoo [Bot]