fn_princomp.hpp
Go to the documentation of this file.
1 // Copyright (C) 2010-2011 NICTA (www.nicta.com.au)
2 // Copyright (C) 2010-2011 Conrad Sanderson
3 // Copyright (C) 2010 Dimitrios Bouzas
4 //
5 // This file is part of the Armadillo C++ library.
6 // It is provided without any warranty of fitness
7 // for any purpose. You can redistribute this file
8 // and/or modify it under the terms of the GNU
9 // Lesser General Public License (LGPL) as published
10 // by the Free Software Foundation, either version 3
11 // of the License or (at your option) any later version.
12 // (see http://www.opensource.org/licenses for more info)
13 
14 
17 
18 
19 
26 template<typename T1>
27 inline
28 bool
30  (
31  Mat<typename T1::elem_type>& coeff_out,
32  Mat<typename T1::elem_type>& score_out,
33  Col<typename T1::pod_type>& latent_out,
34  Col<typename T1::elem_type>& tsquared_out,
37  )
38  {
40 
41  typedef typename T1::elem_type eT;
42 
43  const unwrap<T1> tmp(X.get_ref());
44  const Mat<eT>& A = tmp.M;
45 
46  const bool status = op_princomp::direct_princomp(coeff_out, score_out, latent_out, tsquared_out, A);
47 
48  if(status == false)
49  {
50  coeff_out.reset();
51  score_out.reset();
52  latent_out.reset();
53  tsquared_out.reset();
54 
55  arma_bad("princomp(): failed to converge", false);
56  }
57 
58  return status;
59  }
60 
61 
62 
68 template<typename T1>
69 inline
70 bool
72  (
73  Mat<typename T1::elem_type>& coeff_out,
74  Mat<typename T1::elem_type>& score_out,
75  Col<typename T1::pod_type>& latent_out,
78  )
79  {
81 
82  typedef typename T1::elem_type eT;
83 
84  const unwrap<T1> tmp(X.get_ref());
85  const Mat<eT>& A = tmp.M;
86 
87  const bool status = op_princomp::direct_princomp(coeff_out, score_out, latent_out, A);
88 
89  if(status == false)
90  {
91  coeff_out.reset();
92  score_out.reset();
93  latent_out.reset();
94 
95  arma_bad("princomp(): failed to converge", false);
96  }
97 
98  return status;
99  }
100 
101 
102 
107 template<typename T1>
108 inline
109 bool
110 princomp
111  (
112  Mat<typename T1::elem_type>& coeff_out,
113  Mat<typename T1::elem_type>& score_out,
116  )
117  {
119 
120  typedef typename T1::elem_type eT;
121 
122  const unwrap<T1> tmp(X.get_ref());
123  const Mat<eT>& A = tmp.M;
124 
125  const bool status = op_princomp::direct_princomp(coeff_out, score_out, A);
126 
127  if(status == false)
128  {
129  coeff_out.reset();
130  score_out.reset();
131 
132  arma_bad("princomp(): failed to converge", false);
133  }
134 
135  return status;
136  }
137 
138 
139 
143 template<typename T1>
144 inline
145 bool
146 princomp
147  (
148  Mat<typename T1::elem_type>& coeff_out,
151  )
152  {
154 
155  typedef typename T1::elem_type eT;
156 
157  const unwrap<T1> tmp(X.get_ref());
158  const Mat<eT>& A = tmp.M;
159 
160  const bool status = op_princomp::direct_princomp(coeff_out, A);
161 
162  if(status == false)
163  {
164  coeff_out.reset();
165 
166  arma_bad("princomp(): failed to converge", false);
167  }
168 
169  return status;
170  }
171 
172 
173 
174 template<typename T1>
175 inline
177 princomp
178  (
181  )
182  {
184 
185  return Op<T1, op_princomp>(X.get_ref());
186  }
187 
188 
189 
arma_inline const derived & get_ref() const
Definition: Base_meat.hpp:22
static bool direct_princomp(Mat< eT > &coeff_out, const Mat< eT > &in)
principal component analysis – 1 argument version computation is done via singular value decompositi...
Class for column vectors (matrices with only one column)
Definition: Col_bones.hpp:20
void reset()
Definition: Mat_meat.hpp:4553
#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 princomp(Mat< typename T1::elem_type > &coeff_out, Mat< typename T1::elem_type > &score_out, Col< typename T1::pod_type > &latent_out, Col< typename T1::elem_type > &tsquared_out, const Base< typename T1::elem_type, T1 > &X, const typename arma_blas_type_only< typename T1::elem_type >::result *junk=0)
principal component analysis – 4 arguments version coeff_out -> principal component coefficients sco...
Definition: fn_princomp.hpp:30
Dense matrix class.


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