#ifndef RATICATE_SIMPLEMATRIX_HPP #define RATICATE_SIMPLEMATRIX_HPP #include "utils.hpp" #include "tatami/tatami.hpp" #include "tatami/ext/ArrayView.hpp" namespace raticate { template Parsed parse_simple_matrix_internal(const V& y) { Parsed output; typedef typename std::remove_const::type>::type Value; tatami::ArrayView view(static_cast(y.begin()), y.size()); output.matrix.reset(new tatami::DenseColumnMatrix(y.rows(), y.cols(), std::move(view))); output.contents = Rcpp::List::create(y); return output; } template Parsed parse_simple_matrix(const Rcpp::RObject& seed) { Parsed output; if (seed.sexp_type() == REALSXP) { Rcpp::NumericMatrix y(seed); output = parse_simple_matrix_internal(y); } else if (seed.sexp_type() == INTSXP) { Rcpp::IntegerMatrix y(seed); output = parse_simple_matrix_internal(y); } else if (seed.sexp_type() == LGLSXP) { Rcpp::LogicalMatrix y(seed); output = parse_simple_matrix_internal(y); } return output; } } #endif