Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
eigen
eigen
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 590
    • Issues 590
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Custom Issue Tracker
    • Custom Issue Tracker
  • Merge Requests 17
    • Merge Requests 17
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • libeigen
  • eigeneigen
  • Issues
  • #2109

Closed
Open
Opened Jan 03, 2021 by Jonas Harsch@JonasHarsch

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;
}
Edited Jan 03, 2021 by Jonas Harsch
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: libeigen/eigen#2109