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

const issues on .array() conversion

Tags: None
(comma "," separated)
johnm1019
Registered Member
Posts
46
Karma
0

const issues on .array() conversion

Tue May 14, 2013 9:30 am
with variables defined as class members as follows
Code: Select all
Eigen::Matrix<float,Eigen::Dynamic,Eigen::Dynamic,Eigen::ColMajor>      m_systemMatrix;
Eigen::ArrayXf                                                           m_columnSums;

in my code I am calling
Code: Select all
//int rowNumber (method param)
m_columnSums += m_systemMatrix.row(rowNumber).array();

Which compile-error dies as
Code: Select all
local_code\trunk\thirdparty\eigen\eigen\src/Core/ArrayWrapper.h(58): error C2440: 'return' : cannot convert from 'const float *' to 'float *'
1>          Conversion loses qualifiers
1>          c:\users\SUPERSECRET\desktop\local_code\trunk\thirdparty\eigen\eigen\src/Core/ArrayWrapper.h(58) : while compiling class template member function 'float *Eigen::ArrayWrapper<ExpressionType>::data(void)'
1>          with
1>          [
1>              ExpressionType=Eigen::Block<Eigen::Matrix<float,-1,-1>,1,-1,false>
1>          ]
1>          SystemMatrix.cpp(117) : see reference to class template instantiation 'Eigen::ArrayWrapper<ExpressionType>' being compiled
1>          with
1>          [
1>              ExpressionType=Eigen::Block<Eigen::Matrix<float,-1,-1>,1,-1,false>
1>          ]
1>


Even if I get the row back const it should be OK because it is not modified. Thoughts?
This seems like I've made a simple error somewhere. I've just tried this on Eigen/default 5297.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS
edit: actually adding a row vector with a column vector is not allowed, so you have to transpose one:

m_columnSums += m_systemMatrix.row(0).transpose().array();
johnm1019
Registered Member
Posts
46
Karma
0
ggael wrote:edit: actually adding a row vector with a column vector is not allowed, so you have to transpose one:

m_columnSums += m_systemMatrix.row(0).transpose().array();



Is this a little pedantic or would this behavior actually protect someone? For two vectors, being able to omit the transpose seems like a nice 'beautification' feature.


Bookmarks



Who is online

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