Skip to content

Instantly share code, notes, and snippets.

@pati-ni
pati-ni / RcppExports.cpp
Last active Mar 13, 2018
Rcpp with armadillo
View RcppExports.cpp
arma::mat testmx(const arma::mat& dat);
RcppExport SEXP _testmx(SEXP datSEXP) {
BEGIN_RCPP
Rcpp::RObject rcpp_result_gen;
Rcpp::RNGScope rcpp_rngScope_gen;
Rcpp::traits::input_parameter< const arma::mat& >::type dat(datSEXP);
rcpp_result_gen = Rcpp::wrap(testmx(dat));
return rcpp_result_gen;
END_RCPP
}
@pati-ni
pati-ni / Rinternals_create.cpp
Created Mar 13, 2018
R internals matrix manipulations
View Rinternals_create.cpp
#include <RcppArmadillo.h>
#include <Rinternals.h>
#include <Rcpp.h>
#include <iostream>
SEXP createMat(const SEXP& input)
{
arma::mat matrix(REAL(input), Rf_nrows(input), Rf_ncols(input), false);
@pati-ni
pati-ni / big_memory.R
Last active Mar 13, 2018
Big Memory Package matrix reference wrap
View big_memory.R
library('bigmemory')
options(bigmemory.allow.dimnames = TRUE)
# Read SingleCellExperiment object
sce <- readRDS('lake.rds')
normcounts(sce) <- as.big.matrix(normcounts(sce))
process(normcounts(sce))