armadillo

Armadillo + Matlab Mex segfault

强颜欢笑 提交于 2019-12-06 11:50:21
I fiddled with this the whole day, so I thought I might make everyone benefit from my experience, please see my answer below. I first had a problem with running a compiled Mex file within Matlab, because Matlab complained that it couldn't open the shared library libarmadillo . I solved this using the environment variables LD_LIBRARY_PATH and LD_RUN_PATH ( DYLD_LIBRARY_PATH and LYLD_RUN_PATH in osx). The problem remained however, that a simple test file would segfault at runtime even though the exact same code would compile and run fine outside Matlab (not Mex'd). The segfault seems to be

Multiplying a column vector by a numeric scalar in RcppArmadillo

本小妞迷上赌 提交于 2019-12-06 11:47:45
问题 I am having some trouble compiling this simple c++ code using Rcpp and the RcppArmadillo package. Take the following simple example to multiply each column of a matrix by a numeric scalar: code <- 'arma::mat out = Rcpp::as<arma::mat>(m); for(int i = 0; i < out.n_cols; ++i){ out.col(i) *= v; } return Rcpp::wrap( out );' Trying to compile this using... require( RcppArmadillo ) armMult <- cxxfunction( signature( m = "numeric" , v = "numeric" ), code , plugin = "RcppArmadillo" ) Results in the

Is there a way to print an Armadillo matrix or vector in Visual Studio Debug?

人盡茶涼 提交于 2019-12-06 05:56:25
问题 I'm wondering whether there is any method to show vector/matrix entries values in the debugging section on Visual Studio (in particular VS2012). This question is very similar to the one posted in: Is there a way to print an Armadillo matrix in gdb? however I did not manage to figure out whether this approach also applies to VS. Thanks. 回答1: This .natvis XML code works fine in visual studio 2013. I added @Claes Rolen XML in visual studio 2013 and that dose not work fine for me. The trick is to

low RAM consuming c++ eigen solver

馋奶兔 提交于 2019-12-06 05:44:17
问题 I'm newbie in C++ programming , but I have a task to compute eigenvalues and eigenvectors (standard eigenproblem Ax=lx ) for symmetric matrices (and hermitian)) for very large matrix of size: binomial(L,L/2) where L is about 18-22. Now I'm testing it on machine which has about 7.7 GB ram available, but at final I'll have access to PC with 64GB RAM. I've started with Lapack++ . At the beginning my project assume to solve this problem only for symmetrical real matrices. This library was great.

Importing Armadillo C++ library into Xcode

我的未来我决定 提交于 2019-12-06 04:59:05
问题 I'm a mac user and am trying to install and import C++ Armadillo library. Here are the steps I've had so far: 1) I downloaded the Armadillo library from its website. 2) I went over the Readme.txt file in the download file explaining how to install it. 3) I used CMake to make the armadillo download files into binary files. 4) Then by using terminal and the code sudo make install, I installed the binary codes and they generated some "library-like" files: libarmadillo.4.0.2.dylib, libarmadillo.4

Fast LAPACK/BLAS for matrix multiplication

柔情痞子 提交于 2019-12-06 01:07:43
问题 I'm exploring the Armadillo C++ library for linear algebra at the moment. As far as I understood it uses LAPACK/BLAS library for basic matrix operations (e.g. matrix multiplication). As a Windows user I downloaded LAPACK/BLAS from here: http://icl.cs.utk.edu/lapack-for-windows/lapack/#running. The problem is that matrix multiplications are very slow comparing to Matlab or even R. For example, Matlab multiplies two 1000x1000 matrices in ~0.15 seconds on my computer, R needs ~1 second, while C+

Why do I get errors installing precompiled versions of LAPACK on Windows?

二次信任 提交于 2019-12-05 23:15:16
I am trying to use the Armadillo matrix library to do matrix calcualtions and it needs BLAS and LAPACK. The Armadillo documentation recommended getting the precompiled versions from http://www.stanford.edu/~vkl/code/libs.html There are .lib and .dll files in there. The only problem is I don't know how to get Visual Studio (Express Edition 2008) to recognize these files. I try to copy them to the Visual C++ include and lib directories C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\ and C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\lib\ , but it doesn't seem to do anything

What is the best way to use the OpenCV library in conjunction with the Armadillo library?

不想你离开。 提交于 2019-12-05 17:47:21
I am building an image processing application using OpenCV. I am also using the Armadillo library because it has some very neat matrix related functions. The thing is though, in order to use Armadillo functions on cv::Mat I need frequent conversions from cv::Mat to arma::Mat . To accomplish this I convert the cv::Mat to an arma::Mat using a function like this arma::Mat cvMat2armaMat(cv::Mat M) { copy cv::Mat data to a arma::Mat return arma::Mat } Is there a more efficient way of doing this? To avoid or reduce copying, you can access the memory used by Armadillo matrices via the .memptr()

How do I draw multinomial distributed samples with RcppArmadillo?

守給你的承諾、 提交于 2019-12-05 16:01:54
The problem is that I have a variable arma::mat prob_vec and want something equivalent to rmultinom(1, 1, prob_vec) in R. I found the rmultinom function provided by RcppArmadillo has a weird argument requirement which is different from that in R! So it won't pass the compilation. I just wanna know how to draw the desired sample in RcppArmadillo, or equivalently in Armadillo. If I need to get the pointer or convert my prob_vec variable, please tell me how. Many thanks! Dirk Eddelbuettel Your friendly neighbourhood co-author of RcppArmadillo here: I can assure you that it does not provide

Accessing view of a NumPy array using the C API

断了今生、忘了曾经 提交于 2019-12-05 12:53:42
In a Python extension module I've written in C++, I use the following snippet of code to convert a NumPy array into an Armadillo array for use in the C++ portion of the code: static arma::mat convertPyArrayToArma(PyArrayObject* pyarr, int nrows, int ncols) { // Check if the dimensions are what I expect. if (!checkPyArrayDimensions(pyarr, nrows, ncols)) throw WrongDimensions(); const std::vector<int> dims = getPyArrayDimensions(pyarr); // Gets the dimensions using the API PyArray_Descr* reqDescr = PyArray_DescrFromType(NPY_DOUBLE); if (reqDescr == NULL) throw std::bad_alloc(); // Convert the