• Jason Rhinelander's avatar
    Eigen: fix partially-fixed matrix conversion · d9d224f2
    Jason Rhinelander authored
    Currently when we do a conversion between a numpy array and an Eigen
    Vector, we allow the conversion only if the Eigen type is a
    compile-time vector (i.e. at least one dimension is fixed at 1 at
    compile time), or if the type is dynamic on *both* dimensions.
    
    This means we can run into cases where MatrixXd allow things that
    conforming, compile-time sizes does not: for example,
    `Matrix<double,4,Dynamic>` is currently not allowed, even when assigning
    from a 4-element vector, but it *is* allowed for a
    `Matrix<double,Dynamic,Dynamic>`.
    
    This commit also reverts the current behaviour of using the matrix's
    storage order to determine the structure when the Matrix is fully
    dynamic (i.e. in both dimensions).  Currently we assign to an eigen row
    if the storage order is row-major, and column otherwise: this seems
    wrong (the storage order has nothing to do with the shape!).  While
    numpy doesn't distinguish between a row/column vector, Eigen does, but
    it makes more sense to consistently choose one than to produce
    something with a different shape based on the intended storage layout.
    d9d224f2
test_eigen.cpp 5.58 KB