Re: [eigen] matrix function / exponential warnings |

[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]

On Sun, 20 Jun 2010, Hauke Heibel wrote:

The issue is that the classes MatrixFunction and MatrixExponential are storing
const MatrixType& m_M;
and it seems to be expected that the MatrixType is always a
PlainObject. I am not sure whether that is really necessary. We
already have a solution to this in Eigen which means storing objects
as ei_nested<...>::type.

`I think I didn't know about ei_nested when I wrote the code. As far as I
``remember it, I modeled it on the implementation of MatrixBase::lu() .
`

`What warnings do you get? I don't remember that I got any, so I guess it's
``MS specific. I think that MatrixBase::fullPivLu() does something very
``similar, so I'm interested why you don't get warnings there.
`

Even when we leave the code as is, I think we need to change at least
const typename ei_eval<Derived>::type srcEvaluated = m_src.eval();
to
const typename Derived::PlainObject srcEvaluated = m_src.eval();
because ei_eval<...>::type is not necessarily equal to
Derived::PlainObject and here, you really want to pass a reference to
Derived::PlainObject.

`I thought that eval() always returns either a PlainObject or a constant
``reference to a PlainObject. That's what the comment "ei_plain_matrix_type:
``the difference from ei_eval is that ei_plain_matrix_type is always a plain
``matrix type,whereas ei_eval is a const reference in the case of a matrix"
``in XprHelper.h suggests to me.
`

`The problem with the code you suggest is that it copies the matrix if
``Derived is Matrix<...> (assuming that I understand everything correctly).
`

Any comments? Is there a particular reason why ei_nested<...>::type
should not be working out of the box?

`I don't know what n should be in ei_nested<...> . It should definitely be
``high because computing matrix functions is very expensive. In fact, I
``thought that the argument of matrix functions should always be evaluated
``in situations like (matrixA+matrixB).exp() onless the argument is a matrix
``as in matrixA.exp(), in which case there is nothing to evaluate. This is
``exactly what eval() is doing.
`
Cheers,
Jitse