Mercurial > hg > segmenter-vamp-plugin
comparison armadillo-2.4.4/include/armadillo_bits/fn_svd.hpp @ 0:8b6102e2a9b0
Armadillo Library
author | maxzanoni76 <max.zanoni@eecs.qmul.ac.uk> |
---|---|
date | Wed, 11 Apr 2012 09:27:06 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:8b6102e2a9b0 |
---|---|
1 // Copyright (C) 2009-2011 NICTA (www.nicta.com.au) | |
2 // Copyright (C) 2009-2011 Conrad Sanderson | |
3 // | |
4 // This file is part of the Armadillo C++ library. | |
5 // It is provided without any warranty of fitness | |
6 // for any purpose. You can redistribute this file | |
7 // and/or modify it under the terms of the GNU | |
8 // Lesser General Public License (LGPL) as published | |
9 // by the Free Software Foundation, either version 3 | |
10 // of the License or (at your option) any later version. | |
11 // (see http://www.opensource.org/licenses for more info) | |
12 | |
13 | |
14 //! \addtogroup fn_svd | |
15 //! @{ | |
16 | |
17 | |
18 | |
19 template<typename T1> | |
20 inline | |
21 bool | |
22 svd | |
23 ( | |
24 Col<typename T1::pod_type>& S, | |
25 const Base<typename T1::elem_type,T1>& X, | |
26 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 | |
27 ) | |
28 { | |
29 arma_extra_debug_sigprint(); | |
30 arma_ignore(junk); | |
31 | |
32 // it doesn't matter if X is an alias of S, as auxlib::svd() makes a copy of X | |
33 | |
34 const bool status = auxlib::svd(S, X); | |
35 | |
36 if(status == false) | |
37 { | |
38 S.reset(); | |
39 arma_bad("svd(): failed to converge", false); | |
40 } | |
41 | |
42 return status; | |
43 } | |
44 | |
45 | |
46 | |
47 template<typename T1> | |
48 inline | |
49 Col<typename T1::pod_type> | |
50 svd | |
51 ( | |
52 const Base<typename T1::elem_type,T1>& X, | |
53 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 | |
54 ) | |
55 { | |
56 arma_extra_debug_sigprint(); | |
57 arma_ignore(junk); | |
58 | |
59 Col<typename T1::pod_type> out; | |
60 | |
61 const bool status = auxlib::svd(out, X); | |
62 | |
63 if(status == false) | |
64 { | |
65 out.reset(); | |
66 arma_bad("svd(): failed to converge"); | |
67 } | |
68 | |
69 return out; | |
70 } | |
71 | |
72 | |
73 | |
74 template<typename T1> | |
75 inline | |
76 bool | |
77 svd | |
78 ( | |
79 Mat<typename T1::elem_type>& U, | |
80 Col<typename T1::pod_type >& S, | |
81 Mat<typename T1::elem_type>& V, | |
82 const Base<typename T1::elem_type,T1>& X, | |
83 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 | |
84 ) | |
85 { | |
86 arma_extra_debug_sigprint(); | |
87 arma_ignore(junk); | |
88 | |
89 typedef typename T1::elem_type eT; | |
90 | |
91 arma_debug_check | |
92 ( | |
93 ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*)(&V)) ), | |
94 "svd(): two or more output objects are the same object" | |
95 ); | |
96 | |
97 // auxlib::svd() makes an internal copy of X | |
98 const bool status = auxlib::svd(U, S, V, X); | |
99 | |
100 if(status == false) | |
101 { | |
102 U.reset(); | |
103 S.reset(); | |
104 V.reset(); | |
105 arma_bad("svd(): failed to converge", false); | |
106 } | |
107 | |
108 return status; | |
109 } | |
110 | |
111 | |
112 | |
113 template<typename T1> | |
114 inline | |
115 bool | |
116 svd_econ | |
117 ( | |
118 Mat<typename T1::elem_type>& U, | |
119 Col<typename T1::pod_type >& S, | |
120 Mat<typename T1::elem_type>& V, | |
121 const Base<typename T1::elem_type,T1>& X, | |
122 const char mode = 'b', | |
123 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 | |
124 ) | |
125 { | |
126 arma_extra_debug_sigprint(); | |
127 arma_ignore(junk); | |
128 | |
129 typedef typename T1::elem_type eT; | |
130 | |
131 arma_debug_check | |
132 ( | |
133 ( ((void*)(&U) == (void*)(&S)) || (&U == &V) || ((void*)(&S) == (void*)(&V)) ), | |
134 "svd_econ(): two or more output objects are the same object" | |
135 ); | |
136 | |
137 arma_debug_check | |
138 ( | |
139 ( (mode != 'l') && (mode != 'r') && (mode != 'b') ), | |
140 "svd_econ(): parameter 'mode' is incorrect" | |
141 ); | |
142 | |
143 | |
144 // auxlib::svd_econ() makes an internal copy of X | |
145 const bool status = auxlib::svd_econ(U, S, V, X, mode); | |
146 | |
147 if(status == false) | |
148 { | |
149 U.reset(); | |
150 S.reset(); | |
151 V.reset(); | |
152 arma_bad("svd_econ(): failed to converge", false); | |
153 } | |
154 | |
155 return status; | |
156 } | |
157 | |
158 | |
159 | |
160 template<typename T1> | |
161 arma_deprecated | |
162 inline | |
163 bool | |
164 svd_thin | |
165 ( | |
166 Mat<typename T1::elem_type>& U, | |
167 Col<typename T1::pod_type >& S, | |
168 Mat<typename T1::elem_type>& V, | |
169 const Base<typename T1::elem_type,T1>& X, | |
170 const char mode = 'b', | |
171 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0 | |
172 ) | |
173 { | |
174 arma_ignore(junk); | |
175 | |
176 return svd_econ(U,S,V,X,mode); | |
177 } | |
178 | |
179 | |
180 | |
181 //! @} |