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

assignment to Array by scalar

Tags: None
(comma "," separated)
owens
Registered Member
Posts
4
Karma
0

assignment to Array by scalar

Thu Oct 31, 2013 3:40 am
Hi,

I have some code that works using std::valarray and I would like to try replacing std::valarray with Eigen::Array. I am hitting a problem with assignment from a scalar which seems to be possible with valarray but not Array. For example, the following works:

Code: Select all
std::valarray<double> x (3);
x = 1.0;


Whereas the following generates an error for me:

Code: Select all
Eigen::ArrayXd x (3);
x = 1.0;


Is there some easy way to make this work without changing the assignment statement? If not, I would be happy to try and patch in this behaviour but I would really appreciate it if someone could give me some pointers on where to start. Also, if I were to patch in such behaviour would this potentially be a useful addition to the Array class?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: assignment to Array by scalar

Fri Nov 01, 2013 9:06 am
the best is to patch the class ArrayBase in src/Core/ArrayBase.h to add an overload of operator= for Scalar that would simply call derived().fill(value) and send the path on the bugzilla: http://eigen.tuxfamily.org/bz/ so that other developers can comment on this addition.
owens
Registered Member
Posts
4
Karma
0

Re: assignment to Array by scalar

Tue Nov 05, 2013 8:19 pm
ggael wrote:the best is to patch...


Thanks, the advice is appreciated.


Bookmarks



Who is online

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