Bayes++ Bayesian Filtering Classes  Release 2014.5 - Copyright (c) 2003,2004,2005,2006,2011,2012,2014 Michael Stevens
matSup.hpp
Go to the documentation of this file.
1 #ifndef _BAYES_FILTER_MATRIX_SUPPORT
2 #define _BAYES_FILTER_MATRIX_SUPPORT
3 
4 /*
5  * Bayes++ the Bayesian Filtering Library
6  * Copyright (c) 2002 Michael Stevens
7  * See accompanying Bayes++.htm for terms and conditions of use.
8  *
9  * $Id$
10  */
11 
12 /*
13  * Matrix support functions for filter classes
14  * Members of the Bayesian_filter_matrix namespace are used in the
15  * interface of Bayesian_filter and for internal operations.
16  * Be aware! These functions and their implementation are more likely to change
17  * then those in Bayesian_filter.
18  */
19 
20 /* Filter Matrix Namespace */
21 namespace Bayesian_filter_matrix
22 {
23 
24 
25 /*
26  * Assertion support
27  */
28 #ifndef NDEBUG
29 void assert_isPSD (const SymMatrix &M);
30 #else
31 inline void assert_isPSD (const SymMatrix &M) {}
32 #endif
33 
34 /*
35  * Local support functions
36  */
37 bool isPSD (const SymMatrix &M);
38 bool isSymmetric (const Matrix &M);
39 void forceSymmetric (Matrix &M, bool bUpperToLower = false);
40 
41 /*
42  * UdU' and LdL' and UU' Cholesky Factorisation and function
43  * Very important to manipulate PD and PSD matrices
44  *
45  * Return values:
46  * Many algorithms return a value_type which is a reciprocal condition number
47  * These values are documented for each algorithm and are important way to
48  * determine the validity of the results
49  */
50 Vec::value_type UdUrcond (const Vec& d);
51 RowMatrix::value_type UdUrcond (const RowMatrix& UD);
52 RowMatrix::value_type UdUrcond (const RowMatrix& UD, std::size_t n);
53 UTriMatrix::value_type UCrcond (const UTriMatrix& UC);
54 SymMatrix::value_type UdUdet (const SymMatrix& UD);
55 
56 // In-place factorisations
57 RowMatrix::value_type UdUfactor_variant1 (RowMatrix& M, std::size_t n);
58 RowMatrix::value_type UdUfactor_variant2 (RowMatrix& M, std::size_t n);
59 inline RowMatrix::value_type UdUfactor (RowMatrix& M, std::size_t n)
60 { return UdUfactor_variant2(M,n);
61 }
62 LTriMatrix::value_type LdLfactor (LTriMatrix& M, std::size_t n);
63 UTriMatrix::value_type UCfactor (UTriMatrix& M, std::size_t n);
64 
65 // Copy factorisations
66 RowMatrix::value_type UdUfactor (RowMatrix& UD, const SymMatrix& M);
67 LTriMatrix::value_type LdLfactor (LTriMatrix& LD, const SymMatrix& M);
68 UTriMatrix::value_type UCfactor (UTriMatrix& UC, const SymMatrix& M);
69 
70 // Factor manipulations
71 bool UdUinverse (RowMatrix& UD);
72 bool UTinverse (UTriMatrix& U);
74 void UdUrecompose (RowMatrix& M);
75 void UdUrecompose (SymMatrix& X, const RowMatrix& M);
76 void UdUfromUCholesky (RowMatrix& U);
77 void UdUseperate (RowMatrix& U, Vec& d, const RowMatrix& UD);
78 void Lzero (RowMatrix& M);
79 void Uzero (RowMatrix& M);
80 
81 /*
82  * Functions using UdU factorisation:
83  * inverse of Positive Definite matrix returning rcond
84  */
85 SymMatrix::value_type UdUinversePDignoreInfinity (SymMatrix& M);
86 SymMatrix::value_type UdUinversePD (SymMatrix& M);
87 SymMatrix::value_type UdUinversePD (SymMatrix& M, SymMatrix::value_type& detM);
88 SymMatrix::value_type UdUinversePD (SymMatrix& MI, const SymMatrix& M);
89 SymMatrix::value_type UdUinversePD (SymMatrix& MI, SymMatrix::value_type& detM, const SymMatrix& M);
90 
91 
92 }//namespace
93 
94 #endif
void forceSymmetric(Matrix &M, bool bUpperToLower)
Definition: matSup.cpp:100
void UdUrecompose(RowMatrix &M)
Definition: UdU.cpp:647
RowMatrix::value_type UdUfactor_variant2(RowMatrix &M, std::size_t n)
Definition: UdU.cpp:260
void UdUfromUCholesky(RowMatrix &U)
Definition: UdU.cpp:719
FMMatrix< detail::BaseUpperTriMatrix > UTriMatrix
Definition: uBLASmatrix.hpp:328
bool UdUinverse(RowMatrix &UD)
Definition: UdU.cpp:511
SymMatrix::value_type UdUinversePDignoreInfinity(SymMatrix &M)
Definition: UdU.cpp:793
RowMatrix::value_type UdUfactor_variant1(RowMatrix &M, std::size_t n)
Definition: UdU.cpp:193
Vec::value_type UdUrcond(const Vec &d)
Definition: UdU.cpp:119
bool isPSD(const SymMatrix &M)
Definition: matSup.cpp:54
void UdUseperate(RowMatrix &U, Vec &d, const RowMatrix &UD)
Definition: UdU.cpp:751
FMVec< detail::BaseVector > Vec
Definition: uBLASmatrix.hpp:323
UTriMatrix::value_type UCfactor(UTriMatrix &M, std::size_t n)
Definition: UdU.cpp:392
bool UTinverse(UTriMatrix &U)
Definition: UdU.cpp:560
RowMatrix Matrix
Definition: uBLASmatrix.hpp:325
SymMatrix::value_type UdUdet(const SymMatrix &UD)
Definition: UdU.cpp:176
void Lzero(RowMatrix &M)
Definition: UdU.cpp:684
LTriMatrix::value_type LdLfactor(LTriMatrix &M, std::size_t n)
Definition: UdU.cpp:330
FMMatrix< detail::SymMatrixWrapper< detail::BaseRowMatrix > > SymMatrix
Definition: uBLASmatrix.hpp:327
Definition: matSup.cpp:33
FMMatrix< detail::BaseLowerTriMatrix > LTriMatrix
Definition: uBLASmatrix.hpp:329
SymMatrix::value_type UdUinversePD(SymMatrix &M)
Definition: UdU.cpp:820
void UdUrecompose_transpose(RowMatrix &M)
Definition: UdU.cpp:602
UTriMatrix::value_type UCrcond(const UTriMatrix &UC)
Definition: UdU.cpp:147
RowMatrix::value_type UdUfactor(RowMatrix &M, std::size_t n)
Definition: matSup.hpp:59
FMMatrix< detail::BaseRowMatrix > RowMatrix
Definition: uBLASmatrix.hpp:324
void assert_isPSD(const SymMatrix &M)
Definition: matSup.cpp:38
bool isSymmetric(const Matrix &M)
Definition: matSup.cpp:73
void Uzero(RowMatrix &M)
Definition: UdU.cpp:701