[datatable-help] Problem with calling a function in RcppArmadillo to R?

zkokia zkokia at 163.com
Thu Nov 10 11:47:36 CET 2016


I want to call a kronecker function, the corresponding file in the
fn_kron.hpp file are:

1) In "R":
Rcpparma_hello_world <- function () {
.Call ( 'fn_kron_hpp_rcpparma_hello_world', PACKAGE = 'fn_kron.hpp')
}}

Rcpparma_outerproduct <- function (x) {
.Call ( 'fn_kron_hpp_rcpparma_outerproduct', PACKAGE = 'fn_kron.hpp', x)
}}

2) "src":
#Include <Rcpp.h>
Using namespace Rcpp;

// rcpparma_hello_world
Arma :: mat rcpparma_hello_world ();
RcppExport SEXP fn_kron_hpp_rcpparma_hello_world () {
BEGIN_RCPP
Rcpp :: RObject rcpp_result_gen;
Rcpp :: RNGScope rcpp_rngScope_gen;
Rcpp_result_gen = Rcpp :: wrap (rcpparma_hello_world ());
Return rcpp_result_gen;
END_RCPP
}}
// rcpparma_outerproduct
Arma :: mat rcpparma_outerproduct (const arma :: colvec & x);
RcppExport SEXP fn_kron_hpp_rcpparma_outerproduct (SEXP xSEXP) {
BEGIN_RCPP
Rcpp :: RObject rcpp_result_gen;
Rcpp :: RNGScope rcpp_rngScope_gen;
Rcpp :: traits :: input_parameter <const arma :: colvec &> :: type x
(xSEXP);
Rcpp_result_gen = Rcpp :: wrap (rcpparma_outerproduct (x));
Return rcpp_result_gen;
END_RCPP
}}

3)"man" includes rcpparma_hello_world.Rd and fn_kron.hpp-package.Rd two
documents.


# =================================================
So now the question is that I not know how to call the function in R ?
Library (RcppArmadillo)
Ws <- .Call ( 'fn_kron_hpp_rcpparma_outerproduct', PACKAGE = 'fn_kron.hpp',
listw)

Note: I used the R kronecker function, the code is as follows:
I_T <- Diagonal (T)
Ws <- kronecker (I_T, listw)

I do not understand what 'x' represents in . Call (
'fn_kron_hpp_rcpparma_outerproduct', PACKAGE = 'fn_kron.hpp', x).



--
View this message in context: http://r.789695.n4.nabble.com/Problem-with-calling-a-function-in-RcppArmadillo-to-R-tp4726408.html
Sent from the datatable-help mailing list archive at Nabble.com.


More information about the datatable-help mailing list