1 //=================================================================================================
2 /*!
3 //  \file blaze/math/InversionFlag.h
4 //  \brief Header file for the dense matrix inversion flags
5 //
6 //  Copyright (C) 2012-2020 Klaus Iglberger - All Rights Reserved
7 //
8 //  This file is part of the Blaze library. You can redistribute it and/or modify it under
9 //  the terms of the New (Revised) BSD License. Redistribution and use in source and binary
10 //  forms, with or without modification, are permitted provided that the following conditions
11 //  are met:
12 //
13 //  1. Redistributions of source code must retain the above copyright notice, this list of
14 //     conditions and the following disclaimer.
15 //  2. Redistributions in binary form must reproduce the above copyright notice, this list
16 //     of conditions and the following disclaimer in the documentation and/or other materials
17 //     provided with the distribution.
18 //  3. Neither the names of the Blaze development group nor the names of its contributors
19 //     may be used to endorse or promote products derived from this software without specific
20 //     prior written permission.
21 //
22 //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
23 //  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 //  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
25 //  SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 //  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
27 //  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28 //  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 //  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30 //  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 //  DAMAGE.
32 */
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_INVERSIONFLAG_H_
36 #define _BLAZE_MATH_INVERSIONFLAG_H_
37 
38 
39 namespace blaze {
40 
41 //=================================================================================================
42 //
43 //  INVERSION FLAG VALUES
44 //
45 //=================================================================================================
46 
47 //*************************************************************************************************
48 /*!\brief Inversion flag.
49 // \ingroup math
50 //
51 // The InversionFlag type enumeration represents the different types of matrix inversion algorithms
52 // that are available within the Blaze library. The following flags are available:
53 //
54 //  - \c byLU: The default inversion algorithm for general square matrices. It uses the LU
55 //          algorithm to decompose a matrix into a lower unitriangular matrix \c L, an upper
56 //          triangular matrix \c U, and a permutation matrix \c P (\f$ A = P L U \f$). If no
57 //          permutations are required, \c P is the identity matrix.
58 //  - \c byLDLT: The Bunch-Kaufman inversion algorithm for symmetric indefinite matrices. It
59 //          decomposes the given matrix into either \f$ A = U D U^{T} \f$ or \f$ A = L D L^{T} \f$,
60 //          where \c U (or \c L) is a product of permutation and unit upper (lower) triangular
61 //          matrices, and \c D is symmetric and block diagonal with 1-by-1 and 2-by-2 diagonal
62 //          blocks.
63 //  - \c byLDLH: The Bunch-Kaufman inversion algorithm for Hermitian indefinite matrices. It
64 //          decomposes the given matrix into either \f$ A = U D U^{H} \f$ or \f$ A = L D L^{H} \f$,
65 //          where \c U (or \c L) is a product of permutation and unit upper (lower) triangular
66 //          matrices, and \c D is Hermitian and block diagonal with 1-by-1 and 2-by-2 diagonal
67 //          blocks.
68 //  - \c byLLH: The Cholesky inversion algorithm for Hermitian positive definite matrices. It
69 //          decomposes a given matrix into either \f$ A = L L^H \f$, where \c L is a lower
70 //          triangular matrix, or \f$ A = U^H U \f$, where \c U is an upper triangular matrix.
71 //
72 // Alternatively, the type of the matrix can be specified, leaving it to the Blaze library to
73 // select the appropriate matrix inversion algorithm. The following flags are available:
74 //
75 //  - \c asGeneral: This flag selects the best suited inversion algorithm for general square
76 //          matrices. In case no further compile time information is available, this will imply
77 //          the use of the LU decomposition algorithm (see the \c byLU flag).
78 //  - \c asSymmetric: This flag selects the most suited inversion algorithm for symmetric matrices.
79 //          In case no further compile time information is available, the Bunch-Kaufman matrix
80 //          decomposition algorithm will be used (see the \c byLDLT flag).
81 //  - \c asHermitian: This flag selects the most suited inversion algorithm for Hermitian matrices.
82 //          In case no further compile time information is available, the Bunch-Kaufman matrix
83 //          decomposition algorithm will be used (see the \c byLDLH flag).
84 //  - \c asLower: This flag selects the most suited inversion algorithm for lower triangular
85 //          matrices. In case no further compile time information is available, the inversion will
86 //          be performed by a forward substitution. No matrix decomposition will be performed.
87 //  - \c asUniLower: This flag selects the most suited inversion algorithm for lower unitriangular
88 //          matrices. In case no further compile time information is available, the inversion will
89 //          be performed by a forward substitution. No matrix decomposition will be performed.
90 //  - \c asUpper: This flag selects the most suited inversion algorithm for upper triangular
91 //          matrices. In case no further compile time information is available, the inversion will
92 //          be performed by a back substitution. No matrix decomposition will be performed.
93 //  - \c asUniUpper: This flag selects the most suited inversion algorithm for upper unitriangular
94 //          matrices. In case no further compile time information is available, the inversion will
95 //          be performed by a back substitution. No matrix decomposition will be performed.
96 //  - \c asDiagonal: This flag selects the most suited inversion algorithm for diagonal matrices.
97 //          In case no further compile time information is available, the inversion will be
98 //          performed by directly computing the reciprocal of each diagonal element. No matrix
99 //          decomposition will be performed.
100 */
101 enum InversionFlag
102 {
103    byLU        =  0,  //!< Flag for the LU-based matrix inversion.
104    byLDLT      =  1,  //!< Flag for the Bunch-Kaufman-based inversion for symmetric matrices.
105    byLDLH      =  2,  //!< Flag for the Bunch-Kaufman-based inversion for Hermitian matrices.
106    byLLH       =  3,  //!< Flag for the Cholesky-based inversion for positive-definite matrices.
107 
108    asGeneral   =  4,  //!< Flag for the inversion of a general matrix (same as byLU).
109    asSymmetric =  5,  //!< Flag for the inversion of a symmetric matrix (same as byLDLT).
110    asHermitian =  6,  //!< Flag for the inversion of a Hermitian matrix (same as byLDLH).
111    asLower     =  7,  //!< Flag for the inversion of a lower triangular matrix.
112    asUniLower  =  8,  //!< Flag for the inversion of a lower unitriangular matrix.
113    asUpper     =  9,  //!< Flag for the inversion of a upper triangular matrix.
114    asUniUpper  = 10,  //!< Flag for the inversion of a upper unitriangular matrix.
115    asDiagonal  = 11   //!< Flag for the inversion of a diagonal matrix.
116 };
117 //*************************************************************************************************
118 
119 } // namespace blaze
120 
121 #endif
122