Scythe-1.0.3
lapack.h
Go to the documentation of this file.
00001 /* 
00002  * Scythe Statistical Library Copyright (C) 2000-2002 Andrew D. Martin
00003  * and Kevin M. Quinn; 2002-present Andrew D. Martin, Kevin M. Quinn,
00004  * and Daniel Pemstein.  All Rights Reserved.
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify under the terms of the GNU General Public License as
00008  * published by Free Software Foundation; either version 2 of the
00009  * License, or (at your option) any later version.  See the text files
00010  * COPYING and LICENSE, distributed with this source code, for further
00011  * information.
00012  * --------------------------------------------------------------------
00013  *  scythe/lapack.h
00014  *
00015  */
00016 
00030 #ifndef SCYTHE_LAPACK_H
00031 #define SCYTHE_LAPACK_H
00032 
00033 #ifdef SCYTHE_COMPILE_DIRECT
00034 #endif
00035 
00036 namespace scythe {
00037 
00038   namespace lapack {
00039     inline void
00040     make_symmetric(double* matrix, int rows)
00041     {
00042       for (int i = 1; i < rows; ++i)
00043         for (int j = 0; j < i; ++j)
00044           matrix[i * rows + j] = matrix[j * rows + i];
00045     }
00046 
00047     extern "C" {
00048 
00049       /* Matrix multiplication and gaxpy */
00050       void dgemm_ (char* transa, char* transb, const int* m,
00051                    const int* n, const int* k, const double* alpha,
00052                    const double* a, const int* lda, const double* b,
00053                    const int* ldb, const double* beta, double* c, 
00054                    const int* ldc);
00055 
00056       /* Matrix cross product A'A */
00057       void dsyrk_(const char* uplo, const char* trans, const int* n,
00058                   const int* k, const double* alpha, const double* a,
00059                   const int* lda, const double* beta, double* c,
00060                   const int* ldc);
00061 
00062       /* LU decomposition */
00063       void dgetrf_ (const int* rows, const int* cols, double* a,
00064                     const int* lda, int* ipiv, int *info);
00065       
00066       /* General inversion (given LU decomposion)*/
00067       void dgetri_ (const int* n, double* a, const int* lda,
00068                     const int* ipiv, double* work, const int* lwork,
00069                     int* info);
00070 
00071       /* Cholesky decomposition */
00072       void dpotrf_(const char* uplo, const int* n, double* a,
00073                    const int* lda, int* info);
00074 
00075       /* chol_solve give cholesky */
00076       void dpotrs_ (const char* uplo, const int* n, const int* nrhs,
00077                     const double* a, const int* lda, double *b,
00078                     const int* ldb, int* info);
00079       
00080       /* chol_solve from A and b */
00081       void dposv_ (const char* uplo, const int* n, const int* nrhs,
00082                    double* a, const int* lda, double* b, const int* ldb,
00083                    int* info);
00084 
00085       /* Positive Definite Inversion (given LU decomposition) */
00086       void dpotri_(const char* uplo, const int* n, double* a,
00087                    const int* lda, int* info);
00088 
00089       /* Eigenvalues/vectors for general (nonsymmetric) square matrices */
00090       void dgeev_(const char* jobvl, const char* jobvr, const int* n,
00091                   double* a, const int* lda, double* wr, double* wi,
00092                   double* vl, const int* ldvl, double* vr, const int* ldvr,
00093                   double* work, const int* lwork, int* info);
00094       
00095 
00096       /* Eigenvalues/vectors for symmetric matrices */
00097       void dsyevr_ (const char* jobz, const char* range, const char* uplo,
00098                     const int* n, double* a, const int* lda, double* vl,
00099                     double* vu, const int* il, const int* iu,
00100                     const double* abstol, const int* m, double* w,
00101                     double* z, const int* ldz, int* isuppz, double*
00102                     work, int* lwork, int* iwork, const int* liwork,
00103                     int* info);
00104 
00105       /* QR decomposition */
00106       void dgeqp3_ (const int* m, const int* n, double* a, const int* lda,
00107                     int* jpvt, double* tau, double* work, const int* lwork,
00108                     int* info);
00109 
00110       /* QR solve routines */
00111       void dormqr_ (const char* side, const char* trans, const int* m,
00112                     const int* n, const int* k, const double* a,
00113                     const int* lda, const double* tau, double* c,
00114                     const int* ldc, double* work, const int* lwork,
00115                     int* info);
00116 
00117       void dtrtrs_ (const char* uplo, const char* trans, const char* diag,
00118                     const int* n, const int* nrhs, const double* a,
00119                     const int* lda, double* b, const int* ldb, int* info);
00120 
00121       /* SVD */
00122       void dgesdd_ (const char* jobz, const int* m, const int* n, double* a,
00123                     const int* lda, double* s, double* u, const int* ldu,
00124                     double* vt, const int* ldvt, double* work,
00125                     const int* lwork, int* iwork, int* info);
00126 
00127     } // end extern
00128   } // end namespace lapack
00129 } // end namespace scythe
00130 
00131 #endif /* SCYTHE_LAPACK_H */