I have the following Rcpp code
#include <RcppArmadillo.h>
#define _USE_MATH_DEFINES
#include<cmath>
#include <boost/math/special_functions/bessel.hpp>
#include <mlpack.h>
#include <mlpack/methods/kmeans.hpp>
// [[Rcpp::depends(RcppEnsmallen)]]
// [[Rcpp::depends(mlpack)]]
// [[Rcpp::plugins(cpp17)]]
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::plugins(openmp)]]
// [[Rcpp::depends(BH)]]
using namespace arma;
using namespace Rcpp;
#define ARMA_USE_ARPACK 1
#define ARMA_USE_SUPERLU 1
#define tolr 1e-5
#define crossprod(x) symmatu((x).t() * (x))
#define tcrossprod(x) symmatu((x) * (x).t())
#define pi_sq 9.869604401089358
// [[Rcpp::export]]
Rcpp::List NNGP_fit(const int n){
sp_mat A = sprandu<sp_mat>(n, n, 0.1);
sp_mat B = A.t()*A;
vec eigval;
mat eigvec;
eigs_sym(eigval, eigvec, B, n-1); // find n-1 eigenvalues/eigenvectors
Rcpp::Rcout<<"flag eig"<<endl;
superlu_opts opts;
opts.symmetric = true;
opts.equilibrate =true;
vec mu_f,
y(n, fill::randn);
bool status = spsolve(mu_f,B, y, "superlu",opts);
Rcpp::Rcout<<"status= "<<status<<endl;
return Rcpp::List::create(Rcpp::Named("covmat") =wrap(B),
Rcpp::Named("eigval") =wrap(eigval),
Rcpp::Named("eigvec") =wrap(eigvec),
Rcpp::Named("y") =wrap(y),
Rcpp::Named("mu_f") =wrap(mu_f)
);
}
I am getting the following output
flag eig
Error: spsolve(): use of SuperLU must be enabled
That is, the code stops working at the spsolve command but executes eigs_sym.
However, removing mlpack by deleting the following solves the problem.
#include <mlpack.h>
#include <mlpack/methods/kmeans.hpp>
// [[Rcpp::depends(RcppEnsmallen)]]
// [[Rcpp::depends(mlpack)]]
So I believe I have linked superlu correctly.
This is only a reproducible part of the code and I want to use mlpack in my project. How can I solve this issue? I also need functions from the boost library for the project and kept that header as well.