I am trying to write a R package that is a wrapper for a C++ library that uses RcppGSL. I have successfully installed gsl and the package check stops at the Rcpp function compilation:
#include <Rcpp.h>
#include <RcppGSL.h>
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <iostream>
#include <stdlib.h>
#include "graphm-0.52/graph.h"
#include <cstdlib>
#include <iostream>
#include <stdlib.h>
#include <gsl/gsl_matrix.h>
#include <gsl/gsl_permutation.h>
using namespace std;
using namespace Rcpp;
// declare a dependency on the RcppGSL package; also activates plugin
// (but not needed when ’LinkingTo: RcppGSL’ is used with a package)
//
// [[Rcpp::depends(RcppGSL)]]
//
//
// [[Rcpp::export]]
Rcpp::List run_graph_match(const RcppGSL::Matrix & A, const RcppGSL::Matrix & B, const Rcpp::List &algorithm_params ){
graph graphm_obj_A;
graphm_obj_A.set_adjmatrix (((*A)));
graph graphm_obj_B;
graphm_obj_B.set_adjmatrix (((*B)));
}
The function graph::set_adjmatrix (const gsl_matrix* A) takes in a const gsl_matrix pointer. My question is what would be the right level of referencing I need from going from const RcppGSL::Matrix reference to const gsl_matrix pointer. I would think just one, but I get the following error
graphmatch_rcpp.cpp:31:34: error: no matching function for call to 'graph::set_adjmatrix(RcppGSL::matrix<double>::gsltype&)'
graphm_obj_A.set_adjmatrix((*A)));
^
graphmatch_rcpp.cpp:31:34: note: candidate is:
In file included from graphmatch_rcpp.cpp:9:0:
graphm-0.52/graph.h:52:9: note: int graph::set_adjmatrix(const gsl_matrix*)
int set_adjmatrix(const gsl_matrix* _gm_A);
^
graphm-0.52/graph.h:52:9: note: no known conversion for argument 1 from 'RcppGSL::matrix<double>::gsltype {aka gsl_matrix}' to 'const gsl_matrix*'
graphmatch_rcpp.cpp:33:34: error: no matching function for call to 'graph::set_adjmatrix(RcppGSL::matrix<double>::gsltype&)'
graphm_obj_B.set_adjmatrix((*B)));
which suggests I should reference it once more and cast to const pointer. There is some implicit conversion from RcppGSL::matrix to gsl_matrix, so I am not sure I understand the details. Can anyone more familiar with RcppGSL, Rcpp give an answer as to how I could pass RcppGSL::matrix & to 'const gsl_matrix*' ?