Reputation: 45
I am developing an R package. I have the error message Error: Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD
when the input matrix is very large.
I followed the suggestion here, but then I have an error message during the compilation on my C++ code.
I modified my C++ code as described here:
#define R_NO_REMAP
#include <map>
#include <vector>
#include <iostream>
#include <stream>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include "ANN/ANN.h" // ANN library header
#include "NN.h" // ANN library header
#include <R.h> // R header
#define ARMA_64BIT_WORD 1
#include <RcppArmadillo.h>
#define Malloc(type,n) (type *)malloc((n)*sizeof(type))
#ifdef _OPENMP
#include <omp.h>
#endif
#include <cstdlib>
using namespace std;
using namespace Rcpp;
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::plugins(cpp11)]]
// [[Rcpp::export]]
and the /src/Makevars{.win}
for a package use:
PKG_CPPFLAGS=-I. -IANN -DRANN -DARMA_64BIT_WORD=1
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
Upvotes: 0
Views: 158
Reputation: 45
Yes, the solution of hbrerkere works perfectly.
You're defining ARMA_64BIT_WORD twice. First in the C++ code, and again in the Makevars file. Use either the first or the second one, but not both.
I had to modify additionally the code.
Previously my code had:
arma::ivec Ytrain
...
int *label=Ytrain.memptr();
I had to modify as following:
arma::ivec Ytrain
...
long long int *label=Ytrain.memptr();
Upvotes: 0