DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
lapack_support.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2005 - 2018 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dftfe_lapack_support_h
17#define dftfe_lapack_support_h
18
19
20#include "headers.h"
21
22namespace dftfe
23{
24 namespace types
25 {
26#ifdef LAPACK_WITH_64BIT_BLAS_INDICES
27 /**
28 * Integer type in BLAS.
29 */
30 using blas_int = long long;
31#else
32 /**
33 * Integer type in BLAS.
34 */
35 using blas_int = int;
36#endif
37 } // namespace types
38
39 /**
40 * A namespace containing constants, exceptions, enumerations, and other
41 * utilities used by the deal.II LAPACK bindings.
42 */
43 namespace LAPACKSupport
44 {
45 /**
46 * Most of the LAPACK functions one can apply to a matrix (e.g., by calling
47 * the member functions of this class) change its content in some ways. For
48 * example, they may invert the matrix, or may replace it by a matrix whose
49 * columns represent the eigenvectors of the original content of the matrix.
50 * The elements of this enumeration are therefore used to track what is
51 * currently being stored by this object.
52 */
53 enum State
54 {
55 /// Contents is actually a matrix.
57 /// Contents is the inverse of a matrix.
59 /// Contents is an LU decomposition.
61 /// Contents is a Cholesky decomposition.
63 /// Eigenvalue vector is filled
65 /// Matrix contains singular value decomposition,
67 /// Matrix is the inverse of a singular value decomposition
69 /// Contents is something useless.
70 unusable = 0x8000
71 };
72
73 /**
74 * %Function printing the name of a State.
75 */
76 inline const char *
78 {
79 switch (s)
80 {
81 case matrix:
82 return "matrix";
83 case inverse_matrix:
84 return "inverse matrix";
85 case lu:
86 return "lu decomposition";
87 case cholesky:
88 return "cholesky decomposition";
89 case eigenvalues:
90 return "eigenvalues";
91 case svd:
92 return "svd";
93 case inverse_svd:
94 return "inverse_svd";
95 case unusable:
96 return "unusable";
97 default:
98 return "unknown";
99 }
100 }
101
102 /**
103 * A matrix can have certain features allowing for optimization, but hard to
104 * test. These are listed here.
105 */
107 {
108 /// No special properties
110 /// Matrix is symmetric
112 /// Matrix is upper triangular
114 /// Matrix is lower triangular
116 /// Matrix is diagonal
118 /// Matrix is in upper Hessenberg form
120 };
121
122 /**
123 * %Function printing the name of a Property.
124 */
125 inline const char *
127 {
128 switch (s)
129 {
130 case general:
131 return "general";
132 case hermitian:
133 return "hermitian";
134 case upper_triangular:
135 return "upper triangular";
136 case lower_triangular:
137 return "lower triangular";
138 case diagonal:
139 return "diagonal";
140 case hessenberg:
141 return "Hessenberg";
142 }
143
144 Assert(false, dealii::ExcNotImplemented());
145 return "invalid";
146 }
147
148 /**
149 * Character constant.
150 */
151 static const char A = 'A';
152 /**
153 * Character constant.
154 */
155 static const char N = 'N';
156 /**
157 * Character constant.
158 */
159 static const char O = 'O';
160 /**
161 * Character constant.
162 */
163 static const char T = 'T';
164 /**
165 * Character constant for conjugate transpose.
166 */
167 static const char C = 'C';
168 /**
169 * Character constant.
170 */
171 static const char U = 'U';
172 /**
173 * Character constant.
174 */
175 static const char L = 'L';
176 /**
177 * Character constant.
178 */
179 static const char V = 'V';
180 /**
181 * Integer constant.
182 */
183 static const types::blas_int zero = 0;
184 /**
185 * Integer constant.
186 */
187 static const types::blas_int one = 1;
188
189 /**
190 * A LAPACK function returned an error code.
191 */
192 DeclException2(ExcErrorCode,
193 std::string,
195 << "The function " << arg1 << " returned with an error code "
196 << arg2);
197
198 /**
199 * Exception thrown when a matrix is not in a suitable state for an
200 * operation. For instance, a LAPACK routine may have left the matrix in an
201 * unusable state, then vmult does not make sense anymore.
202 */
204 ExcState,
205 State,
206 << "The function cannot be called while the matrix is in state "
207 << state_name(arg1));
208
209 /**
210 * Exception thrown when a matrix does not have suitable properties for an
211 * operation.
212 */
213 DeclException1(ExcProperty,
214 Property,
215 << "The function cannot be called with a "
216 << property_name(arg1) << " matrix.");
217
218 /**
219 * This exception is thrown if a certain LAPACK function is not available
220 * because no LAPACK installation was detected during configuration.
221 */
223 ExcMissing,
224 std::string,
225 << "When you ran 'cmake' during installation of deal.II, "
226 << "no suitable installation of the BLAS or LAPACK library could "
227 << "be found. Consequently, the function <" << arg1
228 << "> can not be called. Refer to the doc/readme.html "
229 << "file for information on how to ensure that deal.II "
230 << "picks up an existing BLAS and LAPACK installation at "
231 << "configuration time.");
232 } // namespace LAPACKSupport
233} // namespace dftfe
234#endif
Definition lapack_support.h:44
const char * state_name(State s)
Definition lapack_support.h:77
static const char V
Definition lapack_support.h:179
static const char T
Definition lapack_support.h:163
DeclException1(ExcState, State,<< "The function cannot be called while the matrix is in state "<< state_name(arg1))
static const char O
Definition lapack_support.h:159
static const char U
Definition lapack_support.h:171
const char * property_name(const Property s)
Definition lapack_support.h:126
State
Definition lapack_support.h:54
@ eigenvalues
Eigenvalue vector is filled.
Definition lapack_support.h:64
@ matrix
Contents is actually a matrix.
Definition lapack_support.h:56
@ svd
Matrix contains singular value decomposition,.
Definition lapack_support.h:66
@ unusable
Contents is something useless.
Definition lapack_support.h:70
@ inverse_matrix
Contents is the inverse of a matrix.
Definition lapack_support.h:58
@ inverse_svd
Matrix is the inverse of a singular value decomposition.
Definition lapack_support.h:68
@ lu
Contents is an LU decomposition.
Definition lapack_support.h:60
@ cholesky
Contents is a Cholesky decomposition.
Definition lapack_support.h:62
static const char A
Definition lapack_support.h:151
static const char C
Definition lapack_support.h:167
static const types::blas_int one
Definition lapack_support.h:187
static const char L
Definition lapack_support.h:175
static const char N
Definition lapack_support.h:155
DeclException2(ExcErrorCode, std::string, types::blas_int,<< "The function "<< arg1<< " returned with an error code "<< arg2)
Property
Definition lapack_support.h:107
@ lower_triangular
Matrix is lower triangular.
Definition lapack_support.h:115
@ general
No special properties.
Definition lapack_support.h:109
@ hessenberg
Matrix is in upper Hessenberg form.
Definition lapack_support.h:119
@ diagonal
Matrix is diagonal.
Definition lapack_support.h:117
@ upper_triangular
Matrix is upper triangular.
Definition lapack_support.h:113
@ hermitian
Matrix is symmetric.
Definition lapack_support.h:111
static const types::blas_int zero
Definition lapack_support.h:183
Definition lapack_support.h:25
int blas_int
Definition lapack_support.h:35
Definition pseudoPotentialToDftfeConverter.cc:34