armadillo

Faster way to read a data file using armadilo in C++

一世执手 提交于 2019-12-13 18:04:25
问题 Hi I just recently discovered the armadillo library for C++ and I quite like it. I am building an application after prototyping it in MATLAB so that I can execute it much faster. The problem I am facing is that when I try to load a matrix from a .mat file as follows: A.load("A.mat",raw_ascii); //raw_ascii because I can port data to MATLAB as well. it takes about 10 seconds. I was wondering if there was a faster way of doing it in armadillo or C++ in general. Any thoughts are much appreciated,

Armadillo installation

流过昼夜 提交于 2019-12-13 14:30:24
问题 Hi I installed Armadillo3.0.1 in my own working directory /home/me/package/armadillo3.0.1/ as the README.txt said. But when I try an example: g++ -I /home/me/package/armadillo3.0.1/usr/include/ example.cpp -o example -O1 It always shows the error: /tmp/ccZAE9pj.o: In function void arma::gemm<false, false, false, false>::apply_blas_type<double>(arma::Mat<double>&, arma::Mat<double> const&, arma::Mat<double> const&, double, double)': example.cpp:(.text._ZN4arma4gemmILb0ELb0ELb0ELb0EE15apply

convert MATLAB cell type to c++

我怕爱的太早我们不能终老 提交于 2019-12-13 12:08:48
问题 i'm converting a MATLAB program in c++ using Armadillo for matrix algebra. i'm stuck on cell type. someone has some hints? 回答1: That's because 'cell' is not really a type - it is a placeholder for anything you want to place in it. The closest thing I can think of in languages such as C# and Python is a 'tuple', which intrinsically can contain anonymous types. Since C++ does not have a built-in tuple type, I suggest you take a look at Boost, which is a very comprehensive, mature and open

How to share common memory in armadillo?

两盒软妹~` 提交于 2019-12-13 07:39:00
问题 In armadillo, the advanced constructor provide the way to share memory like mat B(10,10); mat A(B.memptr(),2,50,false, true); but in c++ program about class, one should first declare variables in head file,like mat A,B; and realize other things in cpp file. So, anyone can tell me how to share memory between mat A and mat B in cpp file with the declaration of mat A and B in head file? 回答1: You can declare the B matrix as reference the A matrix when declaring your class. For example: class foo

Converting Eigen::MatrixXd to arma::mat and make a copy on a new object

时光毁灭记忆、已成空白 提交于 2019-12-12 22:44:33
问题 I have a function within which I want to convert an Eigen::MatrixXd object to arma::mat . I am aware of this question but I can't seem to be able to correct the behavior that I'm getting. Calling matrixxd_to_armamat from R would cause no issues, the problem is when I have this conversion in another function in C. This is a little confusing and I would like to understand what's going on. #include <RcppArmadillo.h> #include <RcppEigen.h> // [[Rcpp::depends(RcppEigen)]] // [[Rcpp::depends

rcpp: removing NAs in a moving window calculation

笑着哭i 提交于 2019-12-12 21:36:27
问题 My idea is to calculate several statistics in a moving window (2 by 2). For example, the code below calculate the mean value in a moving window. It works well when the input data hasn't got NA values, however gives bad results (NAs are treated as the lowest int) when NAs are in the dataset. Can you guide me how it can be improved - for example by excluding NA in these calculations? #include <RcppArmadillo.h> using namespace Rcpp; // [[Rcpp::depends(RcppArmadillo)]] // [[Rcpp::export]] Rcpp:

Armadillo C++ expmat stacks

限于喜欢 提交于 2019-12-12 19:39:04
问题 I'm trying to execute the expmat() function from the Armadillo c++ library but it gets stacked when i run it. First i tried in Matlab with the expm function, and with different values in the C++ program and it works in both cases. So, the problem is with something related with the values i put on the matrix, seem that some of them are too small... This is the squared [14x14] matrix i want to calculate the exponential: mat A; A << 0 << -0.0000769006 << -0.0000511322 << -0.0000915495 << 0 << 0

Using boost serialization with armadillo datum::nan value

筅森魡賤 提交于 2019-12-12 18:11:47
问题 I use boost serialization in my C++ / CLI program, and some classes have datamembers that contain some double which are initialized to arma::datum::nan (the "not-a-number" value for armadillo library). I serialize via a boost::archive::text_oarchive. When I try to deserialize via boost::archive::text_iarchive oa, a boost serialization archive exception is launched when it tries to read a arma::datum::nan value. I tried using a binary archive, but it seems other types (std::vector> for

Rcpp Parallel or openmp for matrixvector product

大兔子大兔子 提交于 2019-12-12 12:27:05
问题 I am trying to program the naive parallel version of Conjugate gradient, so I started with the simple Wikipedia algorithm, and I want to change the dot-products and MatrixVector products by their appropriate parallel version, The Rcppparallel documentation has the code for the dot-product using parallelReduce; I think I'm gonna use that version for my code, but I'm trying to make the MatrixVector multiplication, but I haven't achieved good results compared to R base (no parallel) Some

How to write a third-party library wrapper class around expression templates

百般思念 提交于 2019-12-12 10:39:49
问题 We are trying to implement a new C++ code in my research group to perform large numerical simulations (finite elements, finite difference methods, topology optimization, etc.) The software will be used by people from academia and industry alike. For the dense linear algebra piece of the software, we want to use either Eigen or Armadillo. We wish to build a wrapper around these packages for two reasons: 1. to expose our own API to the users rather than the third-party API; and 2. in case we