Registered Member
|
Is there a way to extend Cwise to use my own binary function? Let's say, I want to apply element wise my own binary function with the following signature
to two matrices of doubles? I could always do it using a nested loop, but I want the whole thing to be vectorized. Regards, renorm. |
Registered Member
|
Yes, you can use:
http://eigen.tuxfamily.org/dox/classEig ... d88f6af1ad However, if you want the resulting code to be vectorized, you'll have to provide some extra information in your functor, especially the packetOp() method. See e.g. Core/Functors.h for some examples e.g. ei_scalar_sum_op.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
Thanks. That was very helpful.
Another tiny question. Static factory methods Zeros(), Ones() etc of fixed size matrix don't require any arguments, because the sizes are known. Won't it be an error to supply arguments to those methods? I am using Eigne in generic code and the type of matrix can be both fixed and dynamic. |
Registered Member
|
It won't be an error. It will just assert() that your arguments are the correct values. The reason is exactly your use case.
Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list! |
Registered Member
|
That makes perfect sense. Thanks again.
|
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]