STK++ 0.9.13
STK_InvertMatrix.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright (C) 2004-2016 Serge Iovleff, Université Lille 1, Inria
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with this program; if not, write to the
16 Free Software Foundation, Inc.,
17 59 Temple Place,
18 Suite 330,
19 Boston, MA 02111-1307
20 USA
21
22 Contact : S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
23*/
24
25/*
26 * Project: stkpp::Algebra
27 * created on: 9 août 2016
28 * Author: iovleff, S..._Dot_I..._At_stkpp_Dot_org (see copyright for ...)
29 **/
30
35#ifndef STK_INVERTMATRIX_H
36#define STK_INVERTMATRIX_H
37
38#include "invert/STK_Invert.h"
44
46
47namespace STK
48{
49// forward declaration
50template<class Matrix, int Size_> class InvertMatrix;
51
52namespace hidden
53{
57template<class Matrix, int Size_, int structure_>
59
63template<class Matrix, int Size_>
64struct DispatcherChooser<Matrix, Size_, Arrays::array2D_>
65{
66 typedef typename Matrix::Type Type;
69};
73template<class Matrix, int Size_>
74struct DispatcherChooser<Matrix, Size_, Arrays::square_>
75{
76 typedef typename Matrix::Type Type;
79};
83template<class Matrix, int Size_>
84struct DispatcherChooser<Matrix, Size_, Arrays::upper_triangular_>
85{
86 typedef typename Matrix::Type Type;
89};
93template<class Matrix, int Size_>
94struct DispatcherChooser<Matrix, Size_, Arrays::lower_triangular_>
95{
96 typedef typename Matrix::Type Type;
99};
103template<class Matrix, int Size_>
104struct DispatcherChooser<Matrix, Size_, Arrays::symmetric_>
105{
106 typedef typename Matrix::Type Type;
109};
113template<class Matrix, int Size_>
114struct DispatcherChooser<Matrix, Size_, Arrays::upper_symmetric_>
115{
116 typedef typename Matrix::Type Type;
119};
120template<class Matrix, int Size_>
121struct DispatcherChooser<Matrix, Size_, Arrays::lower_symmetric_>
122{
123 typedef typename Matrix::Type Type;
126};
127
131template<class Matrix, int Size_>
144
145
146} // namespace hidden
147
155template<class Matrix, int Size_>
157{
158 public:
159 enum
160 {
161 size_ = Size_,
163 };
166 typedef typename Matrix::Type Type;
168 inline InvertMatrix( Matrix const& m)
169 : inv_()
170 , det_(Dispatcher::run(m, inv_))
171 { inv_.shift(m.beginRows());}
173 inline ~InvertMatrix() {}
174
176 inline Result const& inv() const { return inv_;}
178 inline Type const& det() const { return det_;}
180 inline bool isInvertible() const { return(det_!=0);}
181
183 inline Result const& operator()() { return inv_;}
184
185 protected:
190};
191
195template<class Matrix>
198{
199 enum
200 {
203 size_ = (sizeRows_<sizeCols_) ? sizeRows_ : sizeCols_
204 };
206}
207
208
209}
210
211#endif /* STK_INVERTMATRIX_H_ */
In this file we implement the final class CArray.
In this file we implement inversion method for lower symmetric matrices.
In this file we implement inversion method for lower triangular matrices.
In this file we implement inversion method for symmetric matrices.
In this file we implement inversion method for upper symmetric matrices.
In this file we implement inversion method for upper triangular matrices.
In this file we implement inversion method for general matrices.
The InvertMatrix class is a functor class allowing to compute the inverse of a symmetric matrix.
hidden::AlgebraTraits< InvertMatrix< Matrix, Size_ > >::Dispatcher Dispatcher
Type const & det() const
~InvertMatrix()
Destructor.
bool isInvertible() const
Result const & operator()()
compute the inverse of the matrix m_.
Type det_
determinant of the matrix m_
Result const & inv() const
Result inv_
The inverse (or adjugate matrix if det_ is zero) of m_.
hidden::AlgebraTraits< InvertMatrix< Matrix, Size_ > >::Result Result
InvertMatrix(Matrix const &m)
Constructor.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
hidden::AlgebraTraits< InvertMatrix< Matrix, hidden::Traits< Matrix >::sizeRows_ > >::Result invert(Matrix const &mat)
Utility function allowing to compute the inverse of a matrix.
The namespace STK is the main domain space of the Statistical ToolKit project.
DispatcherChooser< Matrix, Size_, structure_ >::Result Result
DispatcherChooser< Matrix, Size_, structure_ >::Dispatcher Dispatcher
traits class for the algebra methods.
hidden::InvertMatrixDispatcher< Matrix, Size_ > Dispatcher
hidden::InvertLowerSymMatrixDispatcher< Matrix, Size_ > Dispatcher
hidden::InvertLowerTriangularDispatcher< Matrix, Size_ > Dispatcher
hidden::InvertMatrixDispatcher< Matrix, Size_ > Dispatcher
hidden::InvertSymMatrixDispatcher< Matrix, Size_ > Dispatcher
hidden::InvertUpperSymMatrixDispatcher< Matrix, Size_ > Dispatcher
hidden::InvertUpperTriangularDispatcher< Matrix, Size_ > Dispatcher
Utility class allowing to choose the dispatcher for inversion matrix.
computing the inverse of a lower symmetric matrix.
utility class allowing to call the correct static function computing the inverse of a matrix.
computing the inverse of a matrix.
Definition STK_Invert.h:296
computing the inverse of a symmetric matrix.
computing the inverse of a symmetric matrix.