PEXSI
 All Classes Namespaces Files Functions Variables Typedefs Pages
lapack.hpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2012 The Regents of the University of California,
3  through Lawrence Berkeley National Laboratory.
4 
5  Authors: Jack Poulson and Lin Lin
6 
7  This file is part of PEXSI. All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions are met:
11 
12  (1) Redistributions of source code must retain the above copyright notice, this
13  list of conditions and the following disclaimer.
14  (2) Redistributions in binary form must reproduce the above copyright notice,
15  this list of conditions and the following disclaimer in the documentation
16  and/or other materials provided with the distribution.
17  (3) Neither the name of the University of California, Lawrence Berkeley
18  National Laboratory, U.S. Dept. of Energy nor the names of its contributors may
19  be used to endorse or promote products derived from this software without
20  specific prior written permission.
21 
22  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
26  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33  You are under no obligation whatsoever to provide any bug fixes, patches, or
34  upgrades to the features, functionality or performance of the source code
35  ("Enhancements") to anyone; however, if you choose to make your Enhancements
36  available either publicly, or directly to Lawrence Berkeley National
37  Laboratory, without imposing a separate written license agreement for such
38  Enhancements, then you hereby grant the following license: a non-exclusive,
39  royalty-free perpetual license to install, use, modify, prepare derivative
40  works, incorporate into other computer software, distribute, and sublicense
41  such enhancements or derivative works thereof, in binary and source code form.
42 */
46 #ifndef _PEXSI_LAPACK_HPP_
47 #define _PEXSI_LAPACK_HPP_
48 
49 #include "pexsi/environment.hpp"
50 
51 namespace PEXSI {
52 
56 namespace lapack {
57 
58  typedef int Int;
59  typedef std::complex<float> scomplex;
60  typedef std::complex<double> dcomplex;
61 
62 
63  // *********************************************************************
64  // Cholesky factorization
65  // *********************************************************************
66 
67  void Potrf( char uplo, Int n, const float* A, Int lda );
68  void Potrf( char uplo, Int n, const double* A, Int lda );
69  void Potrf( char uplo, Int n, const scomplex* A, Int lda );
70  void Potrf( char uplo, Int n, const dcomplex* A, Int lda );
71 
72 
73  // *********************************************************************
74  // LU factorization (with partial pivoting)
75  // *********************************************************************
76 
77  void Getrf( Int m, Int n, float* A, Int lda, Int* p );
78  void Getrf( Int m, Int n, double* A, Int lda, Int* p );
79  void Getrf( Int m, Int n, scomplex* A, Int lda, Int* p );
80  void Getrf( Int m, Int n, dcomplex* A, Int lda, Int* p );
81 
82  // *********************************************************************
83  // For reducing well-conditioned Hermitian generalized-definite EVP's
84  // to standard form.
85  // *********************************************************************
86 
87  void Hegst
88  ( Int itype, char uplo,
89  Int n, float* A, Int lda, const float* B, Int ldb );
90  void Hegst
91  ( Int itype, char uplo,
92  Int n, double* A, Int lda, const double* B, Int ldb );
93  void Hegst
94  ( Int itype, char uplo,
95  Int n, scomplex* A, Int lda, const scomplex* B, Int ldb );
96  void Hegst
97  ( Int itype, char uplo,
98  Int n, dcomplex* A, Int lda, const dcomplex* B, Int ldb );
99 
100  // *********************************************************************
101  // For solving the standard eigenvalue problem using the divide and
102  // conquer algorithm
103  // *********************************************************************
104 
105  void Syevd
106  ( char jobz, char uplo, Int n, double* A, Int lda, double* eigs );
107 
108  // *********************************************************************
109  // For solving the generalized eigenvalue problem using the divide and
110  // conquer algorithm
111  // *********************************************************************
112 
113  void Sygvd
114  ( int itype, char jobz, char uplo, Int n, double* A, Int lda,
115  double* B, Int ldb, double* eigs );
116 
117 
118 
119  // *********************************************************************
120  // For computing the inverse of a triangular matrix
121  // *********************************************************************
122 
123  void Trtri
124  ( char uplo, char diag, Int n, const float* A, Int lda );
125  void Trtri
126  ( char uplo, char diag, Int n, const double* A, Int lda );
127  void Trtri
128  ( char uplo, char diag, Int n, const scomplex* A, Int lda );
129  void Trtri
130  ( char uplo, char diag, Int n, const dcomplex* A, Int lda );
131 
132 
133  // *********************************************************************
134  // Compute the SVD of a general matrix using a divide and conquer algorithm
135  // *********************************************************************
136 
137  void DivideAndConquerSVD
138  ( Int m, Int n, float* A, Int lda,
139  float* s, float* U, Int ldu, float* VTrans, Int ldvt );
140  void DivideAndConquerSVD
141  ( Int m, Int n, double* A, Int lda,
142  double* s, double* U, Int ldu, double* VTrans, Int ldvt );
143  void DivideAndConquerSVD
144  ( Int m, Int n, scomplex* A, Int lda,
145  float* s, scomplex* U, Int ldu, scomplex* VAdj, Int ldva );
146  void DivideAndConquerSVD
147  ( Int m, Int n, dcomplex* A, Int lda,
148  double* s, dcomplex* U, Int ldu, dcomplex* VAdj, Int ldva );
149 
150  //
151  // Compute the SVD of a general matrix using the QR algorithm
152  //
153 
154  void QRSVD
155  ( Int m, Int n, float* A, Int lda,
156  float* s, float* U, Int ldu, float* VTrans, Int ldvt );
157  void QRSVD
158  ( Int m, Int n, double* A, Int lda,
159  double* s, double* U, Int ldu, double* VTrans, Int ldvt );
160  void QRSVD
161  ( Int m, Int n, scomplex* A, Int lda,
162  float* s, scomplex* U, Int ldu, scomplex* VAdj, Int ldva );
163  void QRSVD
164  ( Int m, Int n, dcomplex* A, Int lda,
165  double* s, dcomplex* U, Int ldu, dcomplex* VAdj, Int ldva );
166 
167 
168  // *********************************************************************
169  // Compute the singular values of a general matrix using the QR algorithm
170  // *********************************************************************
171 
172  void SingularValues( Int m, Int n, float* A, Int lda, float* s );
173  void SingularValues( Int m, Int n, double* A, Int lda, double* s );
174  void SingularValues( Int m, Int n, scomplex* A, Int lda, float* s );
175  void SingularValues( Int m, Int n, dcomplex* A, Int lda, double* s );
176 
177  // *********************************************************************
178  // Compute the SVD of a bidiagonal matrix using the QR algorithm
179  // *********************************************************************
180 
181  void BidiagQRAlg
182  ( char uplo, Int n, Int numColsVTrans, Int numRowsU,
183  float* d, float* e, float* VTrans, Int ldVTrans, float* U, Int ldU );
184  void BidiagQRAlg
185  ( char uplo, Int n, Int numColsVTrans, Int numRowsU,
186  double* d, double* e, double* VTrans, Int ldVTrans, double* U, Int ldU );
187  void BidiagQRAlg
188  ( char uplo, Int n, Int numColsVAdj, Int numRowsU,
189  float* d, float* e, scomplex* VAdj, Int ldVAdj, scomplex* U, Int ldU );
190  void BidiagQRAlg
191  ( char uplo, Int n, Int numColsVAdj, Int numRowsU,
192  double* d, double* e, dcomplex* VAdj, Int ldVAdj, dcomplex* U, Int ldU );
193 
194  // *********************************************************************
195  // Compute the linear least square problem using SVD
196  // *********************************************************************
197  void SVDLeastSquare( Int m, Int n, Int nrhs, float * A, Int lda,
198  float * B, Int ldb, float * S, float rcond,
199  Int* rank );
200  void SVDLeastSquare( Int m, Int n, Int nrhs, double * A, Int lda,
201  double * B, Int ldb, double * S, double rcond,
202  Int* rank );
203  void SVDLeastSquare( Int m, Int n, Int nrhs, scomplex * A, Int lda,
204  scomplex * B, Int ldb, float * S, float rcond,
205  Int* rank );
206  void SVDLeastSquare( Int m, Int n, Int nrhs, dcomplex * A, Int lda,
207  dcomplex * B, Int ldb, double * S, double rcond,
208  Int* rank );
209 
210  // *********************************************************************
211  // Copy
212  // *********************************************************************
213 
214  void Lacpy( char uplo, Int m, Int n, const double* A, Int lda,
215  double* B, Int ldb );
216 
217  void Lacpy( char uplo, Int m, Int n, const dcomplex* A, Int lda,
218  dcomplex* B, Int ldb );
219 
220  // *********************************************************************
221  // Inverting a factorized matrix: Getri
222  // *********************************************************************
223 
224 
225  void Getri ( Int n, double* A, Int lda, const Int* ipiv );
226 
227  void Getri ( Int n, dcomplex* A, Int lda, const Int* ipiv );
228 
229 
230 
231 
232 
233 
234  double Lange ( char norm, Int m, Int n, float * A, Int lda, float* work);
235  double Lange ( char norm, Int m, Int n, double * A, Int lda, double* work);
236  double Lange ( char norm, Int m, Int n, scomplex * A, Int lda, scomplex* work);
237  double Lange ( char norm, Int m, Int n, dcomplex * A, Int lda, dcomplex* work);
238 
239 } // namespace lapack
240 } // namespace PEXSI
241 
242 #endif //_PEXSI_LAPACK_HPP_
Environmental variables.