Questions tagged [armadillo]

Armadillo is a linear algebra library for C++ that makes use of template metaprogramming and delayed evaluation.

Armadillo is an open-source C++ linear algebra library (matrix maths) aiming towards a good balance between speed and ease of use. The syntax is deliberately similar to Matlab.

Integer, floating point and complex numbers are supported, as well as a subset of trigonometric and statistics functions. Various matrix decompositions are provided through optional integration with LAPACK, or one of its high performance drop-in replacements (such as the multi-threaded MKL or ACML libraries).

A delayed evaluation approach is employed (during compile time) to combine several operations into one and reduce (or eliminate) the need for temporaries. This is accomplished through recursive templates and template meta-programming.

This library is useful if C++ has been decided as the language of choice, due to speed and/or integration capabilities. It is distributed under a license that is useful in both open-source and commercial contexts.

Armadillo is primarily developed at NICTA (Australia), with contributions from around the world.

Information about Armadillo is available at http://arma.sourceforge.net.

1054 questions
86
votes
2 answers

Is armadillo solve() thread safe?

In my code I have loop in which I construct and over determined linear system and try to solve it: #pragma omp parallel for for (int i = 0; i < n[0]+1; i++) { for (int j = 0; j < n[1]+1; j++) { for (int k = 0; k < n[2]+1; k++) { …
maxdebayser
  • 1,066
  • 7
  • 10
40
votes
1 answer

RcppArmadillo pass user-defined function

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…
baptiste
  • 75,767
  • 19
  • 198
  • 294
36
votes
4 answers

Compare blitz++, armadillo, boost::MultiArray

I did a comparison between blitz++, armadillo, boost::MultiArray with the following code (borrowed from an old post) #include using namespace std; #include #define _SCL_SECURE_NO_WARNINGS #define BOOST_DISABLE_ASSERTS…
user1899020
  • 13,167
  • 21
  • 79
  • 154
21
votes
1 answer

Integrate Fortran, C++ with R

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.…
Dajun Xu
  • 311
  • 1
  • 4
19
votes
3 answers

Performance of R stats::sd() vs. arma::stddev() vs. Rcpp implementation

Just for the purpose of working on my C++ / Rcpp programming, I took a shot at implementing a (sample) standard deviation function: #include #include #include #include // [[Rcpp::export]] double…
nrussell
  • 18,382
  • 4
  • 47
  • 60
18
votes
1 answer

how to check if BLAS and ATLAS already installed

I'm trying to install armadillo library onto my linux system(ubuntu 12.04). The BOOST BLAS ATLAS and LAPACK is required first for the installation. Is there a way to check if those libraries are already installed or not?
lolibility
  • 2,187
  • 6
  • 25
  • 45
17
votes
2 answers

Deciding between NumericVector and arma::vec in Rcpp

With RcppArmadillo the conversion from R to Rcpp with arma::vec is just as easy as with Rcpp and NumericVector. My project utilizes RcppArmadillo. I'm unsure what to use, NumericVector or arma::vec? What are the key differences between those two?…
Clawish
  • 2,934
  • 3
  • 24
  • 28
17
votes
2 answers

A C++ version of the %in% operator in R

Is there any function in C++ equivalent to %in% operator in R? Consider the command below in R: which(y %in% x) I tried to find something equivalent in C++ (specifically in Armadillo) and I couldn't find anything. I then wrote my own function which…
Sam
  • 4,357
  • 6
  • 36
  • 60
16
votes
3 answers

Difference between R's sum() and Armadillo's accu()

There are small differences in the results of R's sum() function and RcppArmadillo's accu() function when given the same input. For example, the following code: R: vec <- runif(100, 0, 0.00001) accu(vec) sum(vec) C++: //…
Matthew Lueder
  • 953
  • 2
  • 12
  • 25
16
votes
1 answer

How do I convert an armadillo matrix to a vector of vectors?

I created an armadillo c++ matrix as follows: arma::mat A; A.zeros(3,4); I want to convert it to a vector of vectors defined by std::vector< std::vector > B(3, std::vector(4) ); How do I set B to equal A? If there is not an easy…
Bluegreen17
  • 983
  • 1
  • 11
  • 25
16
votes
1 answer

armadillo C++: matrix initialization from array

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…
ND_27
  • 764
  • 3
  • 8
  • 26
14
votes
3 answers

Convert RcppArmadillo vector to Rcpp vector

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(wrap(temp)), assuming temp is an…
Raymond Wong
  • 149
  • 1
  • 4
13
votes
1 answer

Fastest way to compute the cdf of the Normal distribution over vectors - R::pnorm vs erfc vs?

I hope my reworded question now fits the criteria of Stackoverflow. Please consider the example below. I am writing a Log-Likelihood function in which computing the cdf over vectors is the most time consuming part. Example 1 uses the R::pnorm,…
chameau13
  • 626
  • 7
  • 24
12
votes
2 answers

Converting an Armadillo Matrix to an Eigen MatriXd and vice versa

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) +…
Ari.stat
  • 463
  • 4
  • 13
12
votes
1 answer

Inverse of a matrix using eigen

I have learnt how to find inverse of a matrix using Eigen. But when I'm finding inverse of an array that is a output of function I got an error request for member ‘inverse’ in ‘x’, which is of non-class type ‘double**’ Please help me out, in…
AGN
  • 223
  • 1
  • 2
  • 7
1
2 3
70 71