armadillo

Rcpp error: /usr/bin/ld cannot find -lgfortran

我的未来我决定 提交于 2019-11-27 08:19:28
问题 I am working through the book "Seamless R and C++ Integration with Rcpp". I am using R version 3.1.0 on Ubuntu 12.04. I cannot figure out how to properly link the necessary libraries. I have the following code in R: R> library(Rcpp) R> library(RcppArmadillo) R> suppressMessages(require(inline)) R> code <- ' + arma::mat coeff = Rcpp::as<arma::mat>(a); + arma::mat errors = Rcpp::as<arma::mat>(u); + int m = errors.n_rows; + int n = errors.n_cols; + arma::mat simdata(m,n); + simdata.row(0) = arma

RcppArmadillo pass user-defined function

回眸只為那壹抹淺笑 提交于 2019-11-27 04:28:17
Consider the following R code, ## ----------- R version ----------- caller <- function(x=1:3, fun = "identity", ...){ ## do some other stuff ## ... ## then call the function eval(call(fun, x)) } fun1 <- function(x, ...){ x + x } fun2 <- function(x, a = 10) a * x caller(fun = "fun1") caller(fun = "fun2") The user can pass a function name "fun", that is used by caller . I wish to perform the same task with RcppArmadillo objects (as part of a more complex task, obviously). The function would be defined in C++ , and the user selects it at the R level by referring to its name: caller_cpp(1:3, "fun1

C++: Convert text file of integers into a bitmap image file in BMP format

若如初见. 提交于 2019-11-27 02:24:40
问题 I have a text file being saved by a matrix library containing a 2D matrix as such: 1 0 0 6 0 4 0 1 1 Where each number is represented with a colored pixel. I am looking for some insight as to how I'd go about solving this problem. If any more information is required, do not hesitate to ask. EDIT: Another approach I've tried is: fwrite(&intmatrix, size,1, bmp_ptr); where I pass in the matrix pointer, which does not seem to output a readable BMP file. The value of size is the rows*cols of

RcppArmadillo pass user-defined function

女生的网名这么多〃 提交于 2019-11-26 11:12:30
问题 Consider the following R code, ## ----------- R version ----------- caller <- function(x=1:3, fun = \"identity\", ...){ ## do some other stuff ## ... ## then call the function eval(call(fun, x)) } fun1 <- function(x, ...){ x + x } fun2 <- function(x, a = 10) a * x caller(fun = \"fun1\") caller(fun = \"fun2\") The user can pass a function name \"fun\", that is used by caller . I wish to perform the same task with RcppArmadillo objects (as part of a more complex task, obviously). The function