Registered Member
|
I'm new to c++ and Eigen. I would like to know if I can use NullaryExpr to fill a matrix with the results of a function that changes state everytime the () operator is used.
Thank you for your help. |
Moderator
|
yes, this is how random is implemented.
|
Registered Member
|
Thank you for the quick response. The problem is that when I try to compile my function I get the following error:
c:\program files (x86)\eigen-eigen-3.0.2\eigen\src/Core/CwiseNullaryOp.h (95): error C3848: expression having type 'const fill<Scalar>' would lose some const-volatile qualifiers in order to call 'double fill<Scalar>::operator ()(Eigen::DenseIndex &)' Here is my code:
thank you again for your help. I suspect this is a silly question but I cannot figure it out. |
Moderator
|
I think that operator() has to be const qualified, and thus counter should be mutable.
btw, toy can use setLinSpace(...) to reproduce what you want to achieve. |
Registered Member
|
Thank you. I'm now using mutable and everything is working fine.
|
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]