Armadillo is a linear algebra library developed by C ++.AlgorithmPort to C ++. You can use only header files, or use efficient LAPACK and blas for acceleration. The installation process is as follows:
1. Go
Download the source code and decompress it to any directory, such as X :\Armadillo: add the \ include directory to the include file directory of Visual Studio. vs2008 is set in "tool> Option> VC ++ directory> include file, other versions are similar.
2. Modify the X: \ Armadillo \ include \ armadillo_bits \ config. HPP file and cancel the comments of the following two rows.
# Define arma_use_lapack
# Define arma_use_blas
Uncomment indicates that LAPACK And Blas are used for more efficient computation. Otherwise, built-in functions may be used for computation, which may lead to a reduction in performance.
3. Install LAPACK And Blas, go to the http://icl.cs.utk.edu/lapack-for-windows/clapack/index.html to download Blas. Lib, libf2c. Lib, LAPACK. Lib three libraries, and add these three libraries in the additional dependent libraries of the compiling environment. (Blasd. Lib, libf2cd. Lib, lapackd. Lib
Is the debug version library, debuggingProgramYou can use). In step 1, add the path for storing the. Lib file to the library file path of Visual Studio.
4. Add
Blas. Lib, libf2c. Lib, LAPACK. Lib
5. Okay. Write a demo to test it.
# Include <iostream> # include <Armadillo> int main () {ARMA: mat A = ARMA: randu <ARMA: mat> (4, 5) * 10; arma: mat B = ARMA: randu <ARMA: mat> (4, 5) * 10; ARMA: mat c = A % B;. print ("A = \ n"); B. print ("B = \ n"); C. print (". * B = \ n "); Return 0 ;}
Running result:
A =
0.0125 5.8501 8.2284 7.1050 0.9140
5.6359 4.7987 7.4660 5.1353 3.6445
1.9330 3.5029 1.7411 3.0399 1.4731
8.0874 8.9596 8.5894 0.1498 1.6590
B =
9.8853 0.0891 6.0176 4.5079 7.8332
4.4569 3.7788 6.0717 3.5212 8.0261
1.1908 5.3166 1.6623 0.5704 5.1988
0.0467 5.7118 6.6305 6.0768 3.0195
A. * B =
0.1237 0.5213 49.5155 32.0286 7.1598
25.1186 18.1335 45.3313 18.0827 29.2511
2.3019 18.6237 2.8943 1.7340 7.6585
0.3776 51.1760 56.9518 0.9106 5.0093
Press any key to continue...