Learn R Programming

miceadds (version 1.5-0)

cxxfunction.copy: RUtilities: Copy of an Rcpp File

Description

Copy the Rcpp function into the working directory.

Usage

cxxfunction.copy(cppfct , name)

Arguments

cppfct
The Rcpp function
name
Name of the output Rcpp function to be generated

References

Eddelbuettel, D. & Francois, R. (2011). Rcpp: Seamless R and C++ integration. Journal of Statistical Software, 40(8), 1-18.

See Also

See also the cxxfunction in the inline package

Examples

Run this code
# define Rcpp file
code1 <- "
    // array A
    Rcpp::NumericMatrix AA(A);
    // Rcpp::IntegerVector dimAA(dimA);
    int nrows = AA.nrow();
    int ncolumns = AA.ncol();
    NumericMatrix Alogis(nrows,ncolumns)  ; 
    // compute logistic distribution
    for (int ii=0; ii<nrows; ++ii){
        NumericVector h1=AA.row(ii) ;
        NumericVector res = plogis( h1 ) ;
        for (int jj=0;jj<ncolumns;++jj){
            Alogis(ii,jj) = res[jj] ;
                        }
                    }
                
    return( wrap(Alogis) );
    "
# compile Rcpp code
calc1 <- cxxfunction( signature( A= "matrix"), code1, plugin = "Rcpp", verbose=TRUE )
cxxfunction.copy( cppfct=calc1, name="calclogis" )

Run the code above in your browser using DataLab