Installation and Use of clapack on Windows

Source: Internet
Author: User
Tags lapack
1. Introduction to clapack

To understand clapack, we must first know what LAPACK is.

LAPACK (LInearALgebraPackAge) is a high-performance linear algebra computing library, with Blas (BASICLInearALgebraSBased on ubprograms, it is written in FORTRAN and can be used to solve problems such as linear algebra equations, Least Square solutions of linear system equations, calculation of feature values and feature vectors. Clapack is the C language interface of LAPACK.

 

2. clpack Installation

Search a lot of web pages, and finally find a convenient installation method (http://icl.cs.utk.edu/lapack-for-windows/clapack/index.html#running ). This installation method is passed in my PC test. The PC configuration is Windows XP SP3 and vc6. The procedure is as follows:

  1. Download clapack-3.2.1-CMAKE.tgz and unzip.
  2. Download cmake and install it on your machine.
  3. Open cmake
    • Point to your CLAPACK-3.2.1-CMAKE folder in the source code folder
    • Point to a new folder where you want the build to be (not the same is better)
    • Click Configure, check the install path if you want to have the libraries and between des in a particle location.
    • Choose Visual Studio solution. You can also choose nmake or any other platform.
    • You may have to click again configure until everything becomes white
    • Click Generate, that will create the Visual Studio for clapack and you are done.
    • Close cmake
  4. Look in your "build" folder, you have your clapack Visual Studio solution, just open it.
  5. Build"All_build"Project, it will build the solution and create the librarires
  6. Build"Install". This will put the libraries and include in your Install Folder.
  7. Build"Run_tests". The BLAs and clapack testings will be run.

If the settings in cmake are not modified, after completing step 1, you will find the *. h and *. Lib you need in c: \ Program Files \ clapack.

Note: Some of run_tests cannot pass, and other functions are not affected.

 

3. Use clapack

Before using clpack, you must first understand four points:

The first is levels of routines, that is, the hierarchy of functions. LAPACK divides the entire database into three major parts: Driver, computional, and auxiliary. For more information about which part is used, see the link.

The second is naming scheme, that is, naming rules. The driver and computational function names of LAPACK are usually xyyzzz. X indicates the data type used, YY indicates the matrix type, and ZZZ indicates the function. For example, sgebrd indicates that the bidiagonal reduction (BRD) operation is performed on the general matrix (GE) with single precision (s). For more information, see the link.

Again, the clapack function does not receive two-dimensional arrays, that is, it can only replace two-dimensional arrays with one-dimensional arrays. For example, I want an array [2] [2] = {1, 2 }, {3, 4}. The correct syntax is array [2*2] = {1, 2, 3, 4 }.

The last is the primary order of the row and the Primary Order of the column. Clapack will regard it as a one-dimensional arrayStore by Column. Therefore, we are used to seeing one-dimensional arraysStore by rowPay special attention. If it is uncomfortable, what about column-based storage? You can reset it before calculation.

The following uses the dgemm _ function as an example to describe how to use clapack. From the dgemm _ name, we can see that this is a double precision (d) function that executes the matrix-matrix operation in the general matrix (GE). More specifically, is to execute the c = Alpha * op (a) * op (B) + BETA * C operation. The statement in clapack. H is as follows:

Int dgemm _ (char * transa, char * transb, integer * m, integer * n, integer * k, doublereal * Alpha, doublereal * a, integer * Lda, doublereal * B, integer * LDB, doublereal * beta, doublereal * C __, integer * LDC );

Where

Transa indicates the OP (a) operation. If transa = 'T', it indicates that a is transposed.

Transa indicates OP (B) Operations

M indicates the number of rows in matrix.

N indicates the number of columns in matrix B.

K indicates the number of columns in matrix.

Alpha is the Alpha value.

A is the one-dimensional storage of matrix A. Note that the called function will regard it as the primary column order.

LDA indicates the first dimension (LDA specifies the first dimension of a) of matrix A. Its value varies according to the value of transa.

B is one-dimensional storage of matrix B

LDB indicates the first dimension of matrix B, and its value changes according to the value of transb.

C is one-dimensional storage of matrix C

LDC indicates the first dimension of matrix C.

The following program calculates

// Author: Zero # include "iostream" # include "f2c. H "# include" clapack. H "using namespace STD; int main () {char transa = 'T', transb = 'T'; integer m = 2, n = 2, K = 2, LDA = K, LDB = N, LDC = m; double alpha = 1.0, a [4] = {1, 2, 3, 4}, B [4] = {5, 6, 7, 8}, Beta = 0.0, C [4]; // The following function indicates c = 1.0 * t (a) * t (B) + 0 * C, where T () indicates to transpose a matrix. // note that C is stored by column in dgemm _ (& transa, & transb, & M, & N, & K, & Alpha, A, & Lda, B, & LDB, & beta, C, & LDC ); cout <C [0] <"" <C [2] <Endl; cout <C [1] <"" <C [3] <Endl; return 0 ;}

To compile this program successfully, perform the following settings:

 

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.