Registered Member
|
Scenario:
I'm writing a template function that take a const MatrixBase<Derived>& parameter. I want to take this matrix and perform operations on it, when it's better to have it evaluated first, instead of evaluating the matrix on every access. If I was on C++ 11+ only, I would have done:
But prior to C++ 11, how can I do it? At first I did:
But even when it's valid, if the Derived is kind of Map, it get copied to a plain object which is bad. 1. What typedef should I use? 2. Is it on documentation? If not, please add it. |
Moderator
|
There is typename Derived::EvalReturnType.
Also, if you know what you want but avoid copying Map of sub-matrices, you can use Ref: Ref<const Matrix3f> evaluatedMat = mat; You can also combine it with PlainObject: Ref<const typename Derived::PlainObject> evaluatedMat = mat; The advantage of Ref<> is that you more precisely control what you will get, for instance you can control alignment and stride requirements. |
Registered users: Bing [Bot], Google [Bot], q.ignora, watchstar