[eigen] Coercion of matrices with mixed types ?

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


It appears that Eigen will not coerce matrices, even if the scalar type does. Is this a design decision or am I missing something ?

For example, if you change the
    # if 0
to
    # if 1
the following program does not compile:
----------------------------------------------------
# include <Eigen/Dense>
# include <iostream>

# if 0
// The following case generates a compile time error
# define OTHER_TYPE int
# else
// The following case works
# define OTHER_TYPE double
# endif

int main(void)
{    typedef Eigen::Matrix<     double, Eigen::Dynamic, 1  > d_vector;
     typedef Eigen::Matrix< OTHER_TYPE, Eigen::Dynamic, 1  > other_vector;

     size_t n = 10;
     other_vector  u(n);
     d_vector  v(n), w(n);
     for(int i = 0; i < n; i++)
     {    u[i] = OTHER_TYPE(i);
          v[i] = double(2*i);
     }
     w = v - u;
     std::cout << "w = [";
     for(int i = 0; i < n; i++)
             std::cout << " " << w[i];
     std::cout << " ]" << std::endl;
}




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/