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

Matrix error : theint is not usable in a constant expre

Tags: None
(comma "," separated)
kde-ztdep
Registered Member
Posts
1
Karma
0
I need to declare a Matrix with a row size of "sizz", but it can not work. the error : " the int is not usable in a constatn expression "
How to resolve this problem.

Code: Select all
    for(auto ii:Mesh->LocalCells)

     const int sizz=ii..size();
      Eigen::Matrix<double,sizz,3> A;A.setZero();
}
jensw
Registered Member
Posts
8
Karma
0
The problem is, that you are trying to create fixed size matrices at runtime

Code: Select all
  for(auto ii:Mesh->LocalCells)
{
     const int sizz=ii..size();
      Eigen::Matrix<double,Eigen::dynamic,3> A=Eigen::Matrix<double,Eigen::dynamic,3>(sizz,3);
}


allocates a matrix on the heap and it should work.

If sizz is a constant for all matrices and known at compile time, then you can use your approach depending on the C++ version


Bookmarks



Who is online

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