armadillo

Linking armadillo with Xcode

丶灬走出姿态 提交于 2019-12-01 00:07:08
I have a large existing Xcode project and now I want to add the armadillo library to it . http://arma.sourceforge.net/ I have downloaded it (with macports) and got it working using Cmake (just as a C++ terminal app). I am not using Cmake for my large project (iPad app) so I have tried to link the library. I looked in the xcode-project file that I got working with cmake and added the same to my project. Added: header search path: /opt/local/include Library search path: /opt/local/lib Other linker flags: -larmadillo I also added the libarmadillo.3.4.0.dylib to "link library with binaries" ld:

Linking armadillo with Xcode

青春壹個敷衍的年華 提交于 2019-11-30 18:20:22
问题 I have a large existing Xcode project and now I want to add the armadillo library to it . http://arma.sourceforge.net/ I have downloaded it (with macports) and got it working using Cmake (just as a C++ terminal app). I am not using Cmake for my large project (iPad app) so I have tried to link the library. I looked in the xcode-project file that I got working with cmake and added the same to my project. Added: header search path: /opt/local/include Library search path: /opt/local/lib Other

Convert RcppArmadillo vector to Rcpp vector

别来无恙 提交于 2019-11-30 12:50:17
问题 I am trying to convert RcppArmadillo vector (e.g. arma::colvec ) to a Rcpp vector ( NumericVector ). I know I can first convert arma::colvec to SEXP and then convert SEXP to NumericVector (e.g. as<NumericVector>(wrap(temp) ), assuming temp is an arma::colvec object). But what is a good way to do that? I want to do that simply because I am unsure if it is okay to pass arma::colvec object as a parameter to an Rcpp::Function object. 回答1: I was trying to Evaluate a Rcpp::Function with argument

Converting an Armadillo Matrix to an Eigen MatriXd and vice versa

这一生的挚爱 提交于 2019-11-30 09:37:28
How can I convert from an Armadillo Matrix to an Eigen MatrixXd and vice versa? I have nu as an arma::vec of size N , z as arma::mat of dimension N x 3 . I want to compute a matrix P such as the entry P_ij is Pij=exp(nu(i) + nu(j) + z.row(j)*z.row(j))) Thus I used this code int N=z.n_rows; mat P= exp(nu*ones(1,N) + one(N,1)*(nu.t()) + z*(z.t())); But the computation takes too long. In particular, for N = 50,000 the run time is far to high. It seems that using Eigen can be faster. But my matrix are Armadillo. How can I use Eigen operations ? Or how can I do this operation faster. Using

Requiring OpenMP availability for use in an Rcpp package

北战南征 提交于 2019-11-30 07:33:48
I have prepared a package in R by using RcppArmadillo and OpenMP libraries and following commands: RcppArmadillo.package.skeleton("mypackage") compileAttributes(verbose=TRUE) Also, in the DESCRIPTION file I added: Imports: Rcpp (>= 0.12.8), RcppArmadillo LinkingTo:Rcpp, RcppArmadillo Depends: RcppArmadillo and in the NAMESPACE file I added: import(RcppArmadillo) importFrom(Rcpp, evalCpp) Then I run the following codes in cmd : R CMD build mypackage R CMD INSTALL mypackage.tar.gz I build and install the package in my computer and I use it now. But my colleges and friends are not able to install

Integrate Fortran, C++ with R

拥有回忆 提交于 2019-11-30 05:01:22
My task it to rewrite a R function in C++ to accelerate the while loops. All R codes has been rewritten in the help of Rcpp and Armadillo except the .Fortran() . I try to use Rinside to at first and it works at a very slow speed as Dirk indicated. (It is expensive for data to go through R -> C++ -> R -> Fortran) Since I don't want to rewrite the Fortran codes in C++ and vice versa, it looks natural to accelerate the programs by linking C++ directly to Fortran: R -> C++ -> Fortran. // [[Rcpp::depends(RcppArmadillo)]] #include <RcppArmadillo.h> using namespace Rcpp; extern "C"{ List f_(int *n

Convert RcppArmadillo vector to Rcpp vector

二次信任 提交于 2019-11-30 03:49:52
I am trying to convert RcppArmadillo vector (e.g. arma::colvec ) to a Rcpp vector ( NumericVector ). I know I can first convert arma::colvec to SEXP and then convert SEXP to NumericVector (e.g. as<NumericVector>(wrap(temp) ), assuming temp is an arma::colvec object). But what is a good way to do that? I want to do that simply because I am unsure if it is okay to pass arma::colvec object as a parameter to an Rcpp::Function object. I was trying to Evaluate a Rcpp::Function with argument arma::vec , it seems that it takes the argument in three forms without compilation errors. That is, if f is a

Compare blitz++, armadillo, boost::MultiArray

醉酒当歌 提交于 2019-11-30 01:24:24
I did a comparison between blitz++, armadillo, boost::MultiArray with the following code (borrowed from an old post ) #include <iostream> using namespace std; #include <windows.h> #define _SCL_SECURE_NO_WARNINGS #define BOOST_DISABLE_ASSERTS #include <boost/multi_array.hpp> #include <blitz/array.h> #include <armadillo> int main(int argc, char* argv[]) { const int X_SIZE = 1000; const int Y_SIZE = 1000; const int ITERATIONS = 100; unsigned int startTime = 0; unsigned int endTime = 0; // Create the boost array //------------------Measure boost Loop------------------------------------------ {

RcppArmadillo sample on armadillo vector classes

家住魔仙堡 提交于 2019-11-29 17:21:52
We have been using the sample function from RcppArmadillo to randomly sample a NumericVector object. However, we have noticed that it isn't possible to use the same function on Armadillo types ( vec or uvec ). We have looked at the function definitions from the sample.h file and it looks like a templated function that should be able to work with these types, but we haven't been able to figure out how to make it work with Armadillo classes without doing a lot of conversions to and from the NumericVector or IntegerVector types from the Rcpp library. For example, we have this function written in

Calling 'mypackage' function within public worker

别来无恙 提交于 2019-11-29 16:26:09
I know the problem I have is a thread-safety issue. As the code I have now will execute with 'seThreadOptions(1)'. My question is what would be a good practice to overcome this. I know this: Threadsafe function pointer with Rcpp and RcppParallel via std::shared_ptr Will come into play somehow. And I have also been thinking/playing around with making the internal function part of the structure for the parallel worker. Realistically, I am calling two internal functions and I would like one to be variable and the other to be constant, this tends me to think that i will need 2 solutions. The error