-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Field of matrices being returned with class matrix
instead of list
#263
Comments
matrix
instead of list
Yeah, so the offending piece of code is setting two dimensions and enforcing a matrix object return instead of a list. RcppArmadillo/inst/include/RcppArmadilloWrap.h Lines 133 to 138 in 188beea
|
For anyone else who might stumble upon this issue - as I did - the following worked for me: // [[Rcpp::export]]
Rcpp::List conv_arma_field_to_rcpp_list(int init_arma_mat = 5,
int dimensions = 6) {
arma::field<arma::Mat<double> > Field_obj(init_arma_mat);
for (unsigned int s = 0; s < init_arma_mat; s++) {
int rows_cols = arma::randi<int>(arma::distr_param(dimensions, dimensions));
Field_obj(s).zeros(rows_cols, rows_cols);
}
Rcpp::List list_obj = Rcpp::wrap( Rcpp::RcppArmadillo::FieldImporter< arma::Mat<double> >( Field_obj ) );
return list_obj;
}
# res = conv_arma_field_to_rcpp_list()
|
This should now be fixed, albeit behind a |
Stumbled across an interesting hiccup in the exporter for
arma::field<T>
(the generic vector). In particular, the attributes associated with anarma::field<arma::mat>
shows asmatrix
under aclass(x)
call instead oflist
. The only way to obtain thelist
type is to use atypeof()
call.The class issue is shown under
d4
beingmatrix
instead oflist
.Moreover, the list is registering as a
matrix
withdim(x)
of N x 1 instead of alist
without dimensions.And the object structure:
The text was updated successfully, but these errors were encountered: