comparison armadillo-3.900.4/include/armadillo_bits/fn_inv.hpp @ 49:1ec0e2823891

Switch to using subrepo copies of qm-dsp, nnls-chroma, vamp-plugin-sdk; update Armadillo version; assume build without external BLAS/LAPACK
author Chris Cannam
date Thu, 13 Jun 2013 10:25:24 +0100
parents
children
comparison
equal deleted inserted replaced
48:69251e11a913 49:1ec0e2823891
1 // Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2008-2011 Conrad Sanderson
3 //
4 // This Source Code Form is subject to the terms of the Mozilla Public
5 // License, v. 2.0. If a copy of the MPL was not distributed with this
6 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8
9 //! \addtogroup fn_inv
10 //! @{
11
12
13
14 //! delayed matrix inverse (general matrices)
15 template<typename T1>
16 arma_inline
17 const Op<T1, op_inv>
18 inv
19 (
20 const Base<typename T1::elem_type,T1>& X,
21 const bool slow = false,
22 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
23 )
24 {
25 arma_extra_debug_sigprint();
26 arma_ignore(junk);
27
28 return Op<T1, op_inv>(X.get_ref(), ((slow == false) ? 0 : 1), 0);
29 }
30
31
32
33 //! remove the inverse operation if applied twice consecutively
34 template<typename T1>
35 arma_inline
36 const T1&
37 inv(const Op<T1, op_inv>& X, const bool slow = false)
38 {
39 arma_extra_debug_sigprint();
40 arma_ignore(slow);
41
42 return X.m;
43 }
44
45
46
47 //! delayed matrix inverse (triangular matrices)
48 template<typename T1>
49 arma_inline
50 const Op<T1, op_inv_tr>
51 inv
52 (
53 const Op<T1, op_trimat>& X,
54 const bool slow = false,
55 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
56 )
57 {
58 arma_extra_debug_sigprint();
59 arma_ignore(slow);
60 arma_ignore(junk);
61
62 return Op<T1, op_inv_tr>(X.m, X.aux_uword_a, 0);
63 }
64
65
66
67 //! delayed matrix inverse (symmetric positive definite matrices)
68 template<typename T1>
69 arma_inline
70 const Op<T1, op_inv_sympd>
71 inv
72 (
73 const Op<T1, op_sympd>& X,
74 const bool slow = false,
75 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
76 )
77 {
78 arma_extra_debug_sigprint();
79 arma_ignore(slow);
80 arma_ignore(junk);
81
82 return Op<T1, op_inv_sympd>(X.m, 0, 0);
83 }
84
85
86
87 template<typename T1>
88 inline
89 bool
90 inv
91 (
92 Mat<typename T1::elem_type>& out,
93 const Base<typename T1::elem_type,T1>& X,
94 const bool slow = false,
95 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
96 )
97 {
98 arma_extra_debug_sigprint();
99 arma_ignore(junk);
100
101 try
102 {
103 out = inv(X,slow);
104 }
105 catch(std::runtime_error&)
106 {
107 return false;
108 }
109
110 return true;
111 }
112
113
114
115 //! @}