Registered Member
|
What would be the best way to convert the following to a generic ArrayBase type?
I think I can figure out the first case (both argument and return are double), but the second case (argument is complex, return is double) is not clear to me. Thanks. |
Moderator
|
you can use typename Derived::RealScalar for the scalar type of the returned Array object.
|
Registered Member
|
Associated with this (maybe if I fix this one, I can fix my original issue), I have working code for an inplace function:
And I want a non-inplace version (one returning a value). I've tried various code fragments like:
But have not been successful in getting to compile. Any ideas? Thanks. |
Moderator
|
remove the OtherDerived template parameter, and use Derived everywhere.
|
Registered Member
|
Thanks. That's what I tried first:
But get a "No matching function" error on compile. |
Moderator
|
How do you call it? Perhaps you could also directly use the input type:
template <typename T> typename T::PlainObject my_swap(const T& x) { typename T::PlainObject y = x.derived(); ... |
Registered Member
|
Thanks. Directly using the input type worked fine.
For the initial problem of returning a real scalar I ended up with:
which seems to work fine for all array types. Please let me know if there was a better way (other than the ReturnByValue class I've seen described at http://listengine.tuxfamily.org/lists.t ... 00216.html which is probably overkill for this case). Thanks. |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]