Install Armadillo for matrix calculation (install armadillo on Windows for Visual Studio)

Source: Internet
Author: User
Tags lapack

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...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.