armadillo | Armadillo C linear algebra library from http

 by   EmanueleCannizzaro C++ Version: Current License: MPL-2.0

kandi X-RAY | armadillo Summary

kandi X-RAY | armadillo Summary

armadillo is a C++ library. armadillo has no bugs, it has no vulnerabilities, it has a Weak Copyleft License and it has low support. You can download it from GitHub.

Armadillo is a high quality C++ linear algebra library, aiming towards a good balance between speed and ease of use. It’s useful for algorithm development directly in C++, and/or quick conversion of research code into production environments. The syntax (API) is deliberately similar to Matlab. The library provides efficient classes for vectors, matrices and cubes, as well as 200+ associated functions (eg. contiguous and non-contiguous submatrix views). Various matrix decompositions are provided through integration with LAPACK, or one of its high performance drop-in replacements (eg. OpenBLAS, Intel MKL, AMD ACML, Apple Accelerate framework, etc). A sophisticated expression evaluator (via C++ template meta-programming) automatically combines several operations (at compile time) to increase speed and efficiency. The library can be used for machine learning, pattern recognition, computer vision, signal processing, bioinformatics, statistics, econometrics, etc. Armadillo is primarily developed at Data61 / NICTA (Australia). For information about Data61 see Main developers: Conrad Sanderson - Ryan Curtin -
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              armadillo has a low active ecosystem.
              It has 6 star(s) with 1 fork(s). There are 1 watchers for this library.
              OutlinedDot
              It had no major release in the last 6 months.
              armadillo has no issues reported. There are no pull requests.
              It has a neutral sentiment in the developer community.
              The latest version of armadillo is current.

            kandi-Quality Quality

              armadillo has no bugs reported.

            kandi-Security Security

              armadillo has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.

            kandi-License License

              armadillo is licensed under the MPL-2.0 License. This license is Weak Copyleft.
              Weak Copyleft licenses have some restrictions, but you can use them in commercial projects.

            kandi-Reuse Reuse

              armadillo releases are not available. You will need to build from source code and install.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of armadillo
            Get all kandi verified functions for this library.

            armadillo Key Features

            No Key Features are available at this moment for armadillo.

            armadillo Examples and Code Snippets

            No Code Snippets are available at this moment for armadillo.

            Community Discussions

            QUESTION

            Using Armadillo C++ library in Swift 5
            Asked 2021-Jun-03 at 22:39

            I'm trying to use Armadillo C++ library in my swift code to create sinusoidal curved arrow. Earlier it worked well with Objective C. But when I'm trying to do the same implementation in Swift, it's showing 'armadillo' file not found error.

            I've downloaded the file from https://github.com/gadomski/armadillo/tree/master/branch-5.600/include path and copied both armadillo_bits folder and armadillo file into the project.

            I've created a Objective C++ Wrapper around the C++ class too.

            Objective C++ Wrapper DrawSinusoidal.h file

            ...

            ANSWER

            Answered 2021-Jun-03 at 22:39

            Finally I found the solution to it. Sharing the steps which I followed.

            • We need to install the pre-built Armadillo packages to macOS which can be installed via MacPorts or HomeBrew
            • I installed using HomeBrew.

            $ brew install armadillo

            Once it is completed, please keep a note on the installed path from the last line.

            In my machine, it is installed on path /usr/local/Cellar/armadillo/10.5.1

            • Next, we need to provide the Header Search Paths. Headers are available in below location, so just copy the path and paste in Xcode.

            /usr/local/Cellar/armadillo/10.5.1/include/armadillo_bits

            • Next, we need to link the libarmadillo.dylib library that is available in the installed path to the sdk path in the Xcode. Open terminal and type following command.

            Source https://stackoverflow.com/questions/67734805

            QUESTION

            C++ armadillo linear algebra library linker error with GCC
            Asked 2021-May-28 at 21:59

            I'm getting the following error with GCC >=9 and std>=11 merely by adding the header (MacOSX on MacBook Pro 2020 and armadillo installed with Homebrew and the code is compiled with standard CMake configuration) #include to my project.

            Undefined symbols for architecture x86_64: "___emutls_v._ZN4arma19mt19937_64_instanceE", referenced from: __GLOBAL__sub_I_Test_HPP.cpp in Test_HPP.cpp.o ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status make[2]: *** [Test_HPP] Error 1 make[1]: *** [CMakeFiles/Test_HPP.dir/all] Error 2

            I've tried various hacks including optimization flags e.g. O2, O3 etc. but finally adding the preprocessor header #define ARMA_DONT_USE_WRAPPER apparently resolved the issue for now but I need an explanation to feel settled. If the above pre-processor is absolutely necessary to compile the code, should the armadillo library maintainers absorb the macro within the library itself? This kind of issues may take a lot of time to resolve as it is not originated in any programming logic.

            ...

            ANSWER

            Answered 2021-May-28 at 21:59

            The preprocessor directive ARMA_DONT_USE_WRAPPER disables code that uses thread_local which depends on emutls in gcc on macOS. This appears unsupported on macOS 11 (Big Sur) according to the maintainers of Armadillo. As shown here CMakeLists.txt.

            A related workaround is provided by the maintainers Commit 83e48f8c in file include/armadillo_bits/arma_rng.hpp

            I'm unable to confirm why it is unsupported in macOS or Homebrew but from other doc, it looks like trying a different build system configuration with correct TLS support might fix the issue e.g ugrading gcc or maybe rebuilding gcc with the --enable-tls switch. I'm using Catalina and my gcc version installed with Homebrew is 11.1.0. If you need gcc version 9 you can switch between them using the brew link @ command.

            Source https://stackoverflow.com/questions/67730549

            QUESTION

            When two libraries have variable types with the same name, how to define the variable type correctly?
            Asked 2021-May-20 at 04:06

            I need to use the armadillo library and opencv library, but I find that both have mat type variables. How can I use them correctly when I use them?

            ...

            ANSWER

            Answered 2021-May-20 at 04:06

            opencv places type definitions in a namespace named cv, and armadillo places type definitions in namespace arma. The reason that libraries use namespaces is to provide a means of avoiding name clashes that results from two libraries using the same name.

            The simple approach is then to avoid ANY using directives (e.g. using namespace cv, using namespace arma, or using namespace std) in your code, and use fully qualified names (e.g. cv::mat or arma::mat, in this case).

            The reason to avoid using directives is that the end result can be ambiguity. For example, when the unqualified name mat is used in code following a using namespace arma and using namespace cv, both cv::mat and arma::mat can be equally viable matches. Such ambiguity is a diagnosable error.

            If you have a name mat in the global (unnamed) namespace it is also often preferable to refer to it explicitly as ::mat. Even if using the unqualified name (i.e. mat) is acceptable, using the fully qualified name reduces effort for developers (including yourself in future) from having to work out what mat actually resolves to.

            Source https://stackoverflow.com/questions/67612941

            QUESTION

            "Illegal value" of blas functions called by Armadillo
            Asked 2021-May-19 at 08:07

            I'm using Armadillo (10.4.1) in Visual Studio 2019 to do some matrix stuff. I used OpenBlas from NuGet manager, but everything was slow. I now want to switch to an up-to-date version of OpenBlas. I took the last one (0.3.15) and compiled it with minGW following this tuto : https://github.com/xianyi/OpenBLAS/wiki/How-to-use-OpenBLAS-in-Microsoft-Visual-Studio.

            The compilation works fine, but when I try matrix multiplication, an error is thrown in the console : On entry to DSPR2 parameter number 1 had an illegal value

            I do have defined ARMA_USE_BLAS, ARMA_DONT_USE_WRAPPER. I tried to played with ARMA_BLAS_LONG, ARMA_BLAS_UNDERSCORE, ARMA_USE_FORTRAN_HIDDEN_ARGS but nothing change.

            Everything was working great using NuGet manager (OpenBlas 0.2.14.1). Here is a sample that doesn't works:

            ...

            ANSWER

            Answered 2021-May-19 at 08:07

            I finally manage to fix the issue: First, I downloaded the pre compiled binary (x86) here: https://github.com/xianyi/OpenBLAS/releases/download/v0.3.10/OpenBLAS-0.3.10-x86.zip

            I put the dll in my project folder, renamed the "libopenblas.dll.a" into "libopenblas.lib". It worked well, but was still slower than Matlab ... So I benchmarked matrix multiplication and custom functions on a fresh new x64 project (using the precompiled binaries given by Armadillo). And ... Everything is much faster !

            So I'm leaving x86 to switch to x64 ! Subject is closed!

            Source https://stackoverflow.com/questions/67589862

            QUESTION

            C++11 conditional data type
            Asked 2021-May-14 at 15:34

            I wrote a C++11 function that conditionally initializes an object. Consider the following example:

            ...

            ANSWER

            Answered 2021-May-14 at 14:37

            You'll probably need to put the common code in a template function which can be instantiated for all 4 different types. Then, in all 4 branches, call this template. The compiler will generate 4 different instantiations.

            Source https://stackoverflow.com/questions/67535946

            QUESTION

            How to use write access using iterators and armadillo sparse matrices?
            Asked 2021-Apr-29 at 13:26

            I have to replace some columns in a sparse matrix with columns from another sparse matrix that has the same nonzero elements, just different values, based on a condition.

            I am struggling with write access using iterators in Armadillo. The docs say that using sp_mat::col_iterator provides read/write access, however, when I try to write a value *it = B.col(...) I get an error message error: no match for ‘operator=’ (operand types are ‘arma::SpValProxy >’ and ‘arma::SpSubview_col’). Do I have a syntax mistake or am I understanding the concept of "write access" wrong?

            ...

            ANSWER

            Answered 2021-Apr-29 at 13:26

            Looking at the (generally excellent) Armadillo documentation, I think you are up a against a design issue. Quoting

            Caveats:

            • to modify the non-zero elements in a safer manner, use .transform() or .for_each() instead of iterators;
            • writing a zero value into a sparse matrix through an iterator will invalidate all current iterators associated with the sparse matrix row iterators for sparse matrices are only useful with Armadillo 8.500 and later versions; in earlier versions they are inefficient

            Source https://stackoverflow.com/questions/67317793

            QUESTION

            Complex matrix exponential with Armadillo library
            Asked 2021-Apr-27 at 13:58

            I'm doing some physics simulation in C++ using Armadillo. I need to calculate a product looking like:

            ...

            ANSWER

            Answered 2021-Apr-27 at 13:58

            You need to use the expmat() function for a matrix exponential, exp() calculates an element-wise exponential.

            For example, some code I'm currently using for a physics simulation:

            Source https://stackoverflow.com/questions/66370264

            QUESTION

            How to serialize sparse matrix in Armadillo and use with mpi implementation of boost?
            Asked 2021-Apr-27 at 12:30

            I've been trying to serialize the sparse matrix from armadillo cpp library. I am doing some large-scale numerical computations, in which the data get stored in a sparse matrix, which I'd like to gather using mpi(Boost implementation) and sum over the matrices coming from different nodes. I'm stuck right now is how to send the sparse matrix from one node to other nodes. Boost suggests that to send user-defined objects (SpMat in this case) it needs to be serialized.

            Boost's documentation gives a good tutorial on how to serialize a user-defined type and I can serialize some basic classes. Now, armadillo's SpMat class is very complicated for me to understand, and serialize.

            I've come across few questions and their very elegant answers

            1. This answer by Ryan Curtin the co-author of Armadillo and author of mlpack has shown a very elegant way to serialize the Mat class.
            2. This answer by sehe shows a very simple way to serialize sparse matrix.

            Using the first I can mpi::send a Mat class to another node in the communicator, but using the latter I couldn't do mpi::send.

            This is adapted from the second linked answer

            ...

            ANSWER

            Answered 2021-Apr-27 at 12:30

            I hate to say so, but that answer by that sehe guy was just flawed. Thanks for finding it.

            The problem was that it didn't store the number of non-zero cells during serialization. Oops. I don't know how I overlooked this when testing.

            (Looks like I had several versions and must have patched together a Frankenversion of it that wasn't actually properly tested).

            I also threw in a test the matrix is cleared (so that if you deserialize into an instance that had the right shape but wasn't empty you don't end up with a mix of old and new data.)

            FIXED

            Source https://stackoverflow.com/questions/67267414

            QUESTION

            Directly accessing entries of armadillo-matrix by memory-pointer (memptr) does not work after matrix is modified
            Asked 2021-Apr-22 at 00:13

            I have a problem where I want to access certain entries of an armadillo-matrix "M" by a pointer in a struct (or class). After initializing M I set the pointer in the struct. By dereferencing the pointer I can see it has the right value (the first entry of M - or M(0,0)).

            Then I change M to M * M. But now dereferencing the pointer does not give me the right value anymore. What's weird: If I have a small matrix i.e. 3x3 or 4x4 (see "matrixSize" in my code) the error does not happen. With small matrices dereferencing the pointer gives the RIGHT value. Bigger matrices though result in the wrong values (with 5x5 something like "2.76282e-320", which is probably some random place in memory).

            What am I doing wrong here? How can I solve this problem?

            If it helps, I'd like to explain what I want to achieve: I have a network of delay-coupled nodes that each have some sort of dynamic behaviour. (think delay-coupled differential equations DDEs - delay-coupled Oscillators). As they are delay-coupled I need to store their past states (an array of their histories). Each oscillator also has some LOCAL dynamic with dynamical variables that are not influencing other nodes which means that I don't have to store their histories. The matrix shall be used to keep the past states of some variable of the nodes. I want to have them in a matrix, because I want to use vector-operations on them (one index of the matrix represents time, while the other is the node-index). But I also want to access them individually to calculate some local dynamic at each of the nodes (oscillators). So I want to update the individual nodes, but also the global state. That's why having both representations helps: For the local dynamics I access the delayed states through a pointer into the matrix. For the global dynamics I access the coupled variables through a row in the matrix that functions as a history-array.

            ...

            ANSWER

            Answered 2021-Apr-22 at 00:13

            The operation M = M * M in Armadillo is a matrix multiply (not an element by element multiply). So storing the intermediate calculations of M * M directly into M would be problematic. It would overwrite existing data in M that is still needed to complete the M * M operation.

            It's probably safe to assume that Armadillo detects this problem and stores the result of M * M into a separate chunk of memory and then assigns that chunk to M.

            There are ways around that. Use fixed size matrices like darcamo mentioned in the comments. Use Mat::fixed<4, 4> M; to declare the matrix.

            Another way is to manually manage the memory for the matrix elements and tell the M matrix to always use that memory. There are the advanced constructors to do that:

            Source https://stackoverflow.com/questions/67195147

            QUESTION

            Fail to call ones or eye function when using RcppArmadillo
            Asked 2021-Apr-08 at 15:33

            I want to use one or eye function in Armadillo to construct matrices or vectors. However, it does not allow me to do so. Here is a sample code:

            ...

            ANSWER

            Answered 2021-Apr-08 at 15:33

            There are a few problems in your code:

            • Why return SEXP? Use types to your advantage
            • Why pass Mat in if you do not use it?
            • No return statement
            • Somewhat loose use of namespaces.

            A cleaned up version follows:

            Source https://stackoverflow.com/questions/67006975

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install armadillo

            The installation is comprised of 3 steps:.
            Step 1: Copy the entire "include" folder to a convenient location and tell your compiler to use that location for header files (in addition to the locations it uses already). Alternatively, you can use the "include" folder directly.
            Step 2: Modify "include/armadillo_bits/config.hpp" to indicate which libraries are currently available on your system. For example, if you have LAPACK, BLAS (or OpenBLAS), ARPACK and SuperLU present, uncomment the following lines: #define ARMA_USE_LAPACK #define ARMA_USE_BLAS #define ARMA_USE_ARPACK #define ARMA_USE_SUPERLU If you don't need sparse matrices, don't worry about ARPACK or SuperLU.
            Step 3: Configure your compiler to link with LAPACK and BLAS (and optionally ARPACK and SuperLU).

            Support

            Technical support can be obtained by purchasing the commercial license (see above). Please contact Conrad Sanderson for more information: http://conradsanderson.id.au.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            CLONE
          • HTTPS

            https://github.com/EmanueleCannizzaro/armadillo.git

          • CLI

            gh repo clone EmanueleCannizzaro/armadillo

          • sshUrl

            git@github.com:EmanueleCannizzaro/armadillo.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Consider Popular C++ Libraries

            tensorflow

            by tensorflow

            electron

            by electron

            terminal

            by microsoft

            bitcoin

            by bitcoin

            opencv

            by opencv

            Try Top Libraries by EmanueleCannizzaro

            metis

            by EmanueleCannizzaroC

            h5nastran

            by EmanueleCannizzaroPython

            flight_delays

            by EmanueleCannizzaroPython

            suitesparse

            by EmanueleCannizzaroC

            pynastran2

            by EmanueleCannizzaroPython