armadillo

armadillo how to get rid of error message

蓝咒 提交于 2019-12-02 02:23:59
Running the following code still produces an error message that goes to stdout (not stderr) although the exception was successfully caught: Mat<double> matrix_quantiles(const vector<double> & quantiles, const Mat<double> & m) { Mat<double> sorted_matrix; try { sorted_matrix = arma::sort(arma::cor(m)); } catch(std::logic_error & e) { /* Sometimes a col is constant, causing the correlation to be infinite. If that happens, add normal random jitter to the values and retry. */ const Mat<double> jitter = Mat<double>( m.n_rows, m.n_cols, arma::fill::randn); return matrix_quantiles(quantiles, 1.e-3 *

How to link Armadillo with Eclipse

北战南征 提交于 2019-12-02 01:37:27
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->Settings->Cross G++ Linker->Libraries->Library search path (-L) . However when I compile the code in

C++ linear algebra library armadillo : how to use eig_pair to get the same result as eig function in Matlab?

随声附和 提交于 2019-12-01 12:09:13
I try to use eig_pair to get Eigen decomposition for pair of general dense square matrices A and B of the same size, such that A*eigvec = B*eigvec*diagmat(eigval), but the result doesn't match the Matlab function eig. for example: A= [1,2;3,4] B=[2,4;5,8] in Matlab: [u,v] = eig(A,B) result: u = -1.0000 -0.0000 0.5000 -1.0000 v = 1.0000 0 0 0.5000 in armadillo: eig_pair(v,u,A,B) result: u: 9.9301e-016 -1.0000e+000 1.0000e+000 5.0000e-001 v: 0.5000 1.0000 My question is: how to get the values of u and v that match the results in Matlab? Looking forwards to your reply!!! Eigenvectors are not

C++ linear algebra library armadillo : how to use eig_pair to get the same result as eig function in Matlab?

隐身守侯 提交于 2019-12-01 11:57:27
问题 I try to use eig_pair to get Eigen decomposition for pair of general dense square matrices A and B of the same size, such that A*eigvec = B*eigvec*diagmat(eigval), but the result doesn't match the Matlab function eig. for example: A= [1,2;3,4] B=[2,4;5,8] in Matlab: [u,v] = eig(A,B) result: u = -1.0000 -0.0000 0.5000 -1.0000 v = 1.0000 0 0 0.5000 in armadillo: eig_pair(v,u,A,B) result: u: 9.9301e-016 -1.0000e+000 1.0000e+000 5.0000e-001 v: 0.5000 1.0000 My question is: how to get the values

Using Armadillo library; Linking Error with BLAS and LAPACK

风格不统一 提交于 2019-12-01 11:33:58
问题 I am trying to compile and run the sample in example2.cpp from Armadillo, using the pre-compiled blas and lapack dll files provided. This is what I didin Visual C++ 2013: 1) I set up a new and empty win32 console application project; 2) Add a new and empty cpp file called test.cpp. 3) I copyed the content of example2.cpp into this test.cpp file. 4) In the project properties->C/C++->Additional Include Directories, I added the path of the "include" folder from the Armadillo library. 5) In

C++ building error for a simple code using armadillo and hdf5 libraries

偶尔善良 提交于 2019-12-01 11:28:38
I'm quite new to C++ and armadillo, and I get stuck with a building error describe below. I'm trying to test the following simple code to save an armadillo matrix as hdf5 file: #include <iostream> #include <armadillo> using namespace std; using namespace arma; int main() { mat A = randu<mat>(240,320); A.save("A.hdf5",hdf5_binary); return 0; } When compiling, I get the following errors: /usr/include/armadillo_bits/hdf5_misc.hpp:131: undefined reference in « arma_H5T_NATIVE_DOUBLE » /usr/include/armadillo_bits/hdf5_misc.hpp:131: undefined reference in « arma_H5Tcopy » obj/Debug/main.o: in

How to serialize armadillo's vector

微笑、不失礼 提交于 2019-12-01 09:47: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 (world.rank() == 0) { s.cvector[0] = 2; s.cvector[1] = 2; world.send(1, 0, s); } else { world.recv(0, 0, s);

Rcpp implementation of mvtnorm::pmvnorm slower than original R function

人盡茶涼 提交于 2019-12-01 08:19:04
问题 I am trying to get a Rcpp version of pmvnorm to work at least as fast as mvtnorm::pmvnorm in R. I have found https://github.com/zhanxw/libMvtnorm and created a Rcpp skeleton package with the relevant source files. I have added the following functions which make use of Armadillo (since I'm using it across other code I've been writing). //[[Rcpp::export]] arma::vec triangl(const arma::mat& X){ arma::mat LL = arma::trimatl(X, -1); // omit the main diagonal return LL.elem(arma::find(LL != 0)); }

armadillo linear system solver (with openblas)

强颜欢笑 提交于 2019-12-01 06:14:55
问题 I've been testing various open source codes for solving a linear system of equations in C++. So far the fastest I've found is armadillo, using the OPENblas package as well. To solve a dense linear NxN system, where N=5000 takes around 8.3 seconds on my system, which is really really fast (without openblas installed, it takes around 30 seconds). One reason for this increase is that armadillo+openblas seems to enable using multiple threads. It runs on two of my cores, whereas armadillo without

Is there a way to print an Armadillo matrix in gdb?

陌路散爱 提交于 2019-12-01 04:25:55
I'm using gdb to debug my c++ program. I'm using the armadillo numerical library to define my matrices. I have an armadillo matrix defined like so: mat A = randu<mat>(5,5); Is it possible to print the whole matrix while using the gdb debugger? The question may be old, but stumbling over it made me find a solution for my own work. Due to the template-based nature of the Armadillo library you need to provide some helpers of your own: #include <iostream> #include <armadillo> template<class Matrix> void print_matrix(Matrix matrix) { matrix.print(std::cout); } //provide explicit instantiations of