[eigen] Forcing a conversion to ColMajor

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

In the RcppEigen package for R (www.R-project.org) the functions that
convert an Eigen object into an R object are said to "wrap" the Eigen
object.  The final destination for plain dense objects is this

// for plain dense objects
template <typename T>
SEXP eigen_wrap_plain_dense( const T& obj, Rcpp::traits::true_type ){
    int m = obj.rows(), n = obj.cols();
    SEXP ans = PROTECT(::Rcpp::wrap(obj.data(), obj.data() + m * n));
    if( T::ColsAtCompileTime != 1 ) {
        if (T::IsRowMajor)
            throw std::invalid_argument("R requires column-major dense
        SEXP dd = PROTECT(::Rf_allocVector(INTSXP, 2));
        int *d = INTEGER(dd);
        d[0] = m;
        d[1] = n;
        ::Rf_setAttrib(ans, R_DimSymbol, dd);
    return ans;

An R matrix must be stored in column major order.  At present I throw
an exception when I detect a Matrix or Array in RowMajor order.  Is
there some way I can convert the object to a similar Matrix or Array
but in ColMajor order, given the information that I have in this

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