I am currently trying to adapt the Eigen API to support the following function:
matrix.similarity(similarityTransformationMatrix);
which simply does the following:
similarityTransformationMatrix * matrix * similarityTransformationMatrix.transpose();
My previous implementation only allows to take square matrices for both:
inline MatrixBase< Derived > similarity( const MatrixBase< Derived >& m) const {
MatrixBase< Derived > t = m;
t.transposeInPlace();
return m*(*this)*t;
}
I need instead to be able to call this on a (square, but check for cols = rows not required) matrix, and a similarityTransformation of a different dimension. My problem is that the return matrix is not of the type of either of those, but it can be derived:
Matrix< double, similarityTransformation.rows(), similarityTransformation.rows()>
Could you give me pointers how to implement this? I didn't try implementing it as Eigen::Matrix but I'd rather stick to MatrixBase if possible, but MatrixBase didn't want to accept multiple arguments for the return type of the form
MatrixBase< OtherDerived::Scalar, OtherDerived::RowsAtCompileTime, OtherDerived::RowsAtCompileTime>