armadillo

Requiring OpenMP availability for use in an Rcpp package

泪湿孤枕 提交于 2019-11-29 09:58:31
问题 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

Armadillo + BLAS + LAPACK: Linking error?

一个人想着一个人 提交于 2019-11-29 07:40:02
When I try to compile example1.cpp that comes with Armadillo 2.4.2, I keep getting the following linking error: /tmp/ccbnLbA0.o: In function `double arma::blas::dot<double>(unsigned int, double const*, double const*)': main.cpp:(.text._ZN4arma4blas3dotIdEET_jPKS2_S4_[double arma::blas::dot<double>(unsigned int, double const*, double const*)]+0x3b): undefined reference to `wrapper_ddot_' /tmp/ccbnLbA0.o: In function `void arma::blas::gemv<double>(char const*, int const*, int const*, double const*, double const*, int const*, double const*, int const*, double const*, double*, int const*)': main

armadillo C++: matrix initialization from array

寵の児 提交于 2019-11-29 05:56:26
I am new to using armadillo, and could not get the following in spite of trying / searching quite a bit. There are two huge (dynamic) arrays (not vectors) that I need to perform correlation on. I resolved to use armadillo for this. I understand how to initialize arma::mat using vectors, but can I use arrays to do so? I understand not as I don't see any mention in the documentation . I am trying to avoid the use of vectors for internal design reasons. I tried manually initializing each element using sample arrays (as a dumb but starting point). Something like the following code wouldn't work.

Integrate Fortran, C++ with R

陌路散爱 提交于 2019-11-29 00:54:07
问题 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:

Compare blitz++, armadillo, boost::MultiArray

青春壹個敷衍的年華 提交于 2019-11-28 22:13:51
问题 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

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

两盒软妹~` 提交于 2019-11-28 14:10:05
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::zeros<arma::mat>(1, n); + for (int row=1; row < m; row++) { + simdata.row(row) = simdata.row(row-1)

How to serialize armadillo's vector

不想你离开。 提交于 2019-11-28 06:15:22
问题 How can I serialize arma::Col ? Below are a MWE and the error output. MWE: #include <boost/mpi/environment.hpp> #include <boost/mpi/communicator.hpp> #include <iostream> #include "armadillo" namespace mpi = boost::mpi; struct S { int i; arma::Col<double>::fixed<3> cvector; friend class boost::serialization::access; template<class Archive> void serialize(Archive& ar, const unsigned int version) { ar& i; ar& cvector; } }; int main() { mpi::environment env; mpi::communicator world; S s; if

armadillo C++: matrix initialization from array

狂风中的少年 提交于 2019-11-28 02:45:58
问题 I am new to using armadillo, and could not get the following in spite of trying / searching quite a bit. There are two huge (dynamic) arrays (not vectors) that I need to perform correlation on. I resolved to use armadillo for this. I understand how to initialize arma::mat using vectors, but can I use arrays to do so? I understand not as I don't see any mention in the documentation. I am trying to avoid the use of vectors for internal design reasons. I tried manually initializing each element

Armadillo + BLAS + LAPACK: Linking error?

萝らか妹 提交于 2019-11-28 01:15:01
问题 When I try to compile example1.cpp that comes with Armadillo 2.4.2, I keep getting the following linking error: /tmp/ccbnLbA0.o: In function `double arma::blas::dot<double>(unsigned int, double const*, double const*)': main.cpp:(.text._ZN4arma4blas3dotIdEET_jPKS2_S4_[double arma::blas::dot<double>(unsigned int, double const*, double const*)]+0x3b): undefined reference to `wrapper_ddot_' /tmp/ccbnLbA0.o: In function `void arma::blas::gemv<double>(char const*, int const*, int const*, double

Converting an Armadillo Matrix to an Eigen MatriXd and vice versa

这一生的挚爱 提交于 2019-11-27 15:08:37
问题 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