在 RcppArmadillo 中启用 ARMA_64BIT_WORD

问题描述 投票:0回答:1

我正在开发一个 R 包。当输入矩阵非常大时,我收到错误消息

Error: Mat::init(): requested size is too large; suggest to enable ARMA_64BIT_WORD

我遵循了here的建议,但是在编译我的C++代码期间出现了错误消息。

我按照此处所述修改了我的 C++ 代码:

#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]]

/src/Makevars{.win}
用于打包使用:

PKG_CPPFLAGS=-I. -IANN -DRANN -DARMA_64BIT_WORD=1
PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) 
rcpparmadillo
1个回答
0
投票

是的,hbrerkere的解决方案非常有效。

我必须另外修改代码。

以前我的代码有:

arma::ivec Ytrain ... int *label=Ytrain.memptr();

我必须修改如下:

arma::ivec Ytrain ... long long int *label=Ytrain.memptr();

© www.soinside.com 2019 - 2024. All rights reserved.