Assignment of matrices with zero dimension to dynamically sized matrices
My last issue (#2080 (closed)) dealt with the problem of matrix producs with matrices having one dimension being zero. This can now be handled correctly due to !323 (merged). By further investigations I ran into some cases where I want to assign a matrix with a zero dimension to a dnamically sized matrix. But this again yields compile time errors. If I assign the matrix to a correct fixed size matrix everything works as expected. A single combination of fixed and dynamically sized matrix leads to a runtime error.
A working example of all cases I came up with are given below. The might be used for a zerosized test case later.
#include <Eigen/Dense>
template<typename ResultMat>
void mat33_mat30()
{
Eigen::Matrix<double, 3, 3> Mat33;
Eigen::Matrix<double, 3, 0> Mat30;
ResultMat Res = Mat33 * Mat30;
assert( Res.isApprox(ResultMat::Random()) ); // both matrices have no values
}
template<typename ResultMat>
void mat03_mat33()
{
Eigen::Matrix<double, 0, 3> Mat03;
Eigen::Matrix<double, 3, 3> Mat33;
ResultMat Res = Mat03 * Mat33;
assert( Res.isApprox(ResultMat::Random()) ); // both matrices have no values
}
int main()
{
mat33_mat30<Eigen::Matrix<double, 3, 0>>();
// mat33_mat30<Eigen::Matrix<double, Eigen::Dynamic, 0>>(); // compile time error "YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES"
// mat33_mat30<Eigen::Matrix<double, 3, Eigen::Dynamic>>(); // compile time error "YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES"
// mat33_mat30<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>>(); // compile time error "YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES"
mat03_mat33<Eigen::Matrix<double, 0, 3>>();
// mat03_mat33<Eigen::Matrix<double, 0, Eigen::Dynamic>>(); // runtime error: "Expression: rows >= 0 && (RowsAtCompileTime == Dynamic || RowsAtCompileTime == rows) && cols >= 0 && (ColsAtCompileTime == Dynamic || ColsAtCompileTime == cols)"
// mat03_mat33<Eigen::Matrix<double, Eigen::Dynamic, 3>>(); // compile time error "YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES"
// mat03_mat33<Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic>>(); // compile time error "YOU_MIXED_MATRICES_OF_DIFFERENT_SIZES"
// this works as expected
Eigen::Matrix<double, 3, 3> Mat33;
Eigen::Matrix<double, 3, 1> Mat31;
Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> Res = Mat33 * Mat31;
}