fn_svd.hpp
Go to the documentation of this file.
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 
16 
17 
18 
19 template<typename T1>
20 inline
21 bool
22 svd
23  (
27  )
28  {
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
50 svd
51  (
54  )
55  {
58 
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  (
84  )
85  {
88 
89  typedef typename T1::elem_type eT;
90 
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  (
122  const char mode = 'b',
124  )
125  {
127  arma_ignore(junk);
128 
129  typedef typename T1::elem_type eT;
130 
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 
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>
162 inline
163 bool
164 svd_thin
165  (
170  const char mode = 'b',
172  )
173  {
174  arma_ignore(junk);
175 
176  return svd_econ(U,S,V,X,mode);
177  }
178 
179 
180 
arma_deprecated bool svd_thin(Mat< typename T1::elem_type > &U, Col< typename T1::pod_type > &S, Mat< typename T1::elem_type > &V, const Base< typename T1::elem_type, T1 > &X, const char mode= 'b', const typename arma_blas_type_only< typename T1::elem_type >::result *junk=0)
Definition: fn_svd.hpp:165
Class for column vectors (matrices with only one column)
Definition: Col_bones.hpp:20
#define arma_deprecated
#define arma_debug_check
Definition: debug.hpp:1084
#define arma_ignore(variable)
void reset()
Definition: Mat_meat.hpp:4553
bool svd_econ(Mat< typename T1::elem_type > &U, Col< typename T1::pod_type > &S, Mat< typename T1::elem_type > &V, const Base< typename T1::elem_type, T1 > &X, const char mode= 'b', const typename arma_blas_type_only< typename T1::elem_type >::result *junk=0)
Definition: fn_svd.hpp:117
#define arma_extra_debug_sigprint
Definition: debug.hpp:1116
void arma_cold arma_bad(const T1 &x, const bool hurl=true)
print a message to get_stream_err2() and/or throw a run-time error exception
Definition: debug.hpp:150
bool svd(Col< typename T1::pod_type > &S, const Base< typename T1::elem_type, T1 > &X, const typename arma_blas_type_only< typename T1::elem_type >::result *junk=0)
Definition: fn_svd.hpp:23
Dense matrix class.
static bool svd(Col< eT > &S, const Base< eT, T1 > &X, uword &n_rows, uword &n_cols)
static bool svd_econ(Mat< eT > &U, Col< eT > &S, Mat< eT > &V, const Base< eT, T1 > &X, const char mode)


armadillo_matrix
Author(s):
autogenerated on Fri Apr 16 2021 02:31:57