armadillo

Update Rcpp::NumericMatrix passed by reference using RcppArmadillo submat()

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 22:00:01
问题 Following on this question, I am trying to understand how to efficiently update a subset of a Rccp::NumericMatrix data type. I have the following scenario: Rcpp::NumericMatrix m of 5 x 5 that needs few rows and columns updated. It will be passed by reference to a function ( void return type) that will convert it to an arma::mat , and update the respective submat() . At this point I don't understand how to " apply " the changes that occurred inside the function to the m matrix that was passed

Elementwise matrix multiplication: R versus Rcpp (How to speed this code up?)

强颜欢笑 提交于 2019-12-02 21:19:51
I am new to C++ programming (using Rcpp for seamless integration into R ), and I would appreciate some advice on how to speed up some calculations. Consider the following example: testmat <- matrix(1:9, nrow=3) testvec <- 1:3 testmat*testvec # [,1] [,2] [,3] #[1,] 1 4 7 #[2,] 4 10 16 #[3,] 9 18 27 Here, R recycled testvec so that, loosely speaking, testvec "became" a matrix of the same dimensions as testmat for the purpose of this multiplication. Then the Hadamard product is returned. I wish to implement this behavior using Rcpp , that is I want that each element of the i -th row in the matrix

Why some eigen vector signs from C++ Armadillo are different from Python and R

我的梦境 提交于 2019-12-02 20:08:32
问题 I was wondering why the sign of the elements in the eigen vectors from Armadillo is the opposite from other languages like Python (i.e. numpy) and R. For example: C++ using namespace arma; vec eigval; mat eigvec; // C++11 initialization mat A = { 1, -1, 0, -1, 2, -1, 0, -1, 1}; eig_sym(eigval, eigvec, A); eigvec.print("Eigen Vectors"); Output Eigen Vectors -5.7735e-01 -7.071068e-01 0.4082483 -5.7735e-01 9.714451e-e17 -0.8164966 -5.7735e-01 7.017068e-01 0.4082483 Python import numpy as np w,v

How to install c++ library on linux

那年仲夏 提交于 2019-12-02 17:45:54
问题 I am a noob in Linux environment. I am using ubuntu 13.10 and I want to install Armadillo. The readme file said that I should install three other libraries first, LAPACK, BLAS and ATLAS. I downloaded lapack-3.5.0, but I don't know how to install it(I only know apt-get install for installation). I found the installation steps inside the readme file as: LAPACK can be installed with make. Configuration have to be set in the make.inc file. A make.inc.example for a Linux machine running GNU

How to install c++ library on linux

ぐ巨炮叔叔 提交于 2019-12-02 12:45:26
I am a noob in Linux environment. I am using ubuntu 13.10 and I want to install Armadillo . The readme file said that I should install three other libraries first, LAPACK, BLAS and ATLAS. I downloaded lapack-3.5.0, but I don't know how to install it(I only know apt-get install for installation). I found the installation steps inside the readme file as: LAPACK can be installed with make. Configuration have to be set in the make.inc file. A make.inc.example for a Linux machine running GNU compilers is given in the main directory. Some specific make.inc are also available in the INSTALL directory

Rcpp causes segfault RcppArmadillo does not

故事扮演 提交于 2019-12-02 09:50:37
I'm currently trying to parallelize an existing hierarchical MCMC sampling scheme. The majority of my (by now sequential) source code is written in RcppArmadillo, so I'd like to stick with this framework for parallelization, too. Before starting with parallelizing my code I have read a couple of blog posts on Rcpp/Openmp. In the majority of these blog posts (e.g. Drew Schmidt, wrathematics ) the authors warn about the issue of thread safety, R/Rcpp data structures and Openmp. The bottom line of all posts I have read so far is, R and Rcpp are not thread safe, don't call them from within an omp

Update Rcpp::NumericMatrix passed by reference using RcppArmadillo submat()

夙愿已清 提交于 2019-12-02 09:18:55
Following on this question , I am trying to understand how to efficiently update a subset of a Rccp::NumericMatrix data type. I have the following scenario: Rcpp::NumericMatrix m of 5 x 5 that needs few rows and columns updated. It will be passed by reference to a function ( void return type) that will convert it to an arma::mat , and update the respective submat() . At this point I don't understand how to " apply " the changes that occurred inside the function to the m matrix that was passed to the function. The code looks like this: #include <iostream> #include <RcppArmadillo.h> // [[Rcpp:

Invalid mex-file, libarmadillo, cannot open shared object file

筅森魡賤 提交于 2019-12-02 07:11:27
问题 I know there are a lot of posts about the topic, this might be a duplicate, but I don't think so. My config is: Matlab R2014b, clang 3.4, Ubuntu 14.04, armadillo-4.600.4. I have a local install (not system-wise, so including/linking manually) of Armadillo that works fine when outside of Matlab. I'm trying to run a Mex file using Armadillo from Matlab. It compiles fine using the command (truncated for short): mex -compatibleArrayDims -outdir +mx -L/home/john/.local/arma/lib -larmadillo -I/home

How to link Armadillo with Eclipse

断了今生、忘了曾经 提交于 2019-12-02 05:48:56
问题 I want to use Armadillo with Eclipse. However all the instructions to link Armadillo is given for Visual Studio. Now I followed the instructions outlined in the ReadMe file of the Armadillo library. I added the Armadillo include folder in project(right click)->properties->C/C++ Build->Settings->Cross G++ Compiler->Includes->Inlcude paths(-I) and then I added the libraries folder (The library folder contain lapack and blas .lib and .dll files) in project(right click)->properties->C/C++ Build-

Why does `fastLm()` return results when I run a regression with one observation?

荒凉一梦 提交于 2019-12-02 03:30:01
Why does fastLm() return results when I run regressions with one observation? In the following, why aren't the lm() and fastLm() results equal? library(Rcpp) library(RcppArmadillo) library(data.table) set.seed(1) DT <- data.table(y = rnorm(5), x1 = rnorm(5), x2 = rnorm(5), my.key = 1:5) # y x1 x2 my.key # 1: -0.6264538 -0.8204684 1.5117812 1 # 2: 0.1836433 0.4874291 0.3898432 2 # 3: -0.8356286 0.7383247 -0.6212406 3 # 4: 1.5952808 0.5757814 -2.2146999 4 # 5: 0.3295078 -0.3053884 1.1249309 5 lm(y ~ 1 + x1 + x2, data = DT[my.key == 1]) # Coefficients: # (Intercept) x1 x2 # -0.6265 NA NA fastLm(X