54 const bool svd_ok =
svd(U,s,coeff_out,score_out);
68 score_out *= coeff_out;
72 score_out.
cols(n_rows-1,n_cols-1).zeros();
78 s_tmp.
rows(0,n_rows-2) = s.
rows(0,n_rows-2);
82 s_tmp.
rows(0,n_rows-2) = eT(1) / s_tmp.
rows(0,n_rows-2);
85 tsquared_out =
sum(S%S,1);
91 tsquared_out =
sum(S%S,1);
99 coeff_out.
eye(n_cols, n_cols);
108 tsquared_out.
zeros();
122 template<
typename eT>
147 const bool svd_ok =
svd(U,s,coeff_out,score_out);
161 score_out *= coeff_out;
165 score_out.
cols(n_rows-1,n_cols-1).zeros();
167 Col<eT> s_tmp = zeros< Col<eT> >(n_cols);
168 s_tmp.
rows(0,n_rows-2) = s.
rows(0,n_rows-2);
178 coeff_out.
eye(n_cols, n_cols);
197 template<
typename eT>
221 const bool svd_ok =
svd(U,s,coeff_out,score_out);
234 score_out *= coeff_out;
238 score_out.
cols(n_rows-1,n_cols-1).zeros();
240 Col<eT> s_tmp = zeros< Col<eT> >(n_cols);
241 s_tmp.
rows(0,n_rows-2) = s.
rows(0,n_rows-2);
247 coeff_out.
eye(n_cols, n_cols);
261 template<
typename eT>
280 const bool svd_ok =
svd(U,s,coeff_out, tmp);
309 Mat< std::complex<T> >& coeff_out,
310 Mat< std::complex<T> >& score_out,
312 Col< std::complex<T> >& tsquared_out,
313 const Mat< std::complex<T> >& in
318 typedef std::complex<T> eT;
332 const bool svd_ok =
svd(U,s,coeff_out,score_out);
346 score_out *= coeff_out;
350 score_out.
cols(n_rows-1,n_cols-1).zeros();
352 Col<T> s_tmp = zeros< Col<T> >(n_cols);
353 s_tmp.
rows(0,n_rows-2) = s.
rows(0,n_rows-2);
357 s_tmp.
rows(0,n_rows-2) = 1.0 / s_tmp.
rows(0,n_rows-2);
359 tsquared_out =
sum(S%S,1);
365 tsquared_out =
sum(S%S,1);
374 coeff_out.
eye(n_cols, n_cols);
383 tsquared_out.
zeros();
402 Mat< std::complex<T> >& coeff_out,
403 Mat< std::complex<T> >& score_out,
405 const Mat< std::complex<T> >& in
410 typedef std::complex<T> eT;
424 const bool svd_ok =
svd(U,s,coeff_out,score_out);
438 score_out *= coeff_out;
442 score_out.
cols(n_rows-1,n_cols-1).zeros();
444 Col<T> s_tmp = zeros< Col<T> >(n_cols);
445 s_tmp.
rows(0,n_rows-2) = s.
rows(0,n_rows-2);
455 coeff_out.
eye(n_cols, n_cols);
479 Mat< std::complex<T> >& coeff_out,
480 Mat< std::complex<T> >& score_out,
481 const Mat< std::complex<T> >& in
486 typedef std::complex<T> eT;
500 const bool svd_ok =
svd(U,s,coeff_out,score_out);
513 score_out *= coeff_out;
517 score_out.
cols(n_rows-1,n_cols-1).zeros();
523 coeff_out.
eye(n_cols, n_cols);
543 Mat< std::complex<T> >& coeff_out,
544 const Mat< std::complex<T> >& in
549 typedef typename std::complex<T> eT;
559 const bool svd_ok =
svd(U,s,coeff_out, tmp);
576 template<
typename T1>
587 typedef typename T1::elem_type eT;
598 arma_bad(
"princomp(): failed to converge");
arma_inline const Op< T1, op_sum > sum(const Base< typename T1::elem_type, T1 > &X, const uword dim=0)
Delayed sum of elements of a matrix along a specified dimension (either rows or columns). The result is stored in a dense matrix that has either one column or one row. For dim = 0, find the sum of each column. For dim = 1, find the sum of each row. The default is dim = 0. NOTE: this function works differently than in Matlab/Octave.
void set_size(const uword in_elem)
change the matrix to have user specified dimensions (data is not preserved)
arma_inline const eOp< T1, eop_sqrt > sqrt(const Base< typename T1::elem_type, T1 > &A)
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...
const uword n_cols
number of columns in the matrix (read-only)
const uword n_elem
number of elements in the matrix (read-only)
const uword n_rows
number of rows in the matrix (read-only)
arma_inline const Op< T1, op_mean > mean(const Base< typename T1::elem_type, T1 > &X, const uword dim=0)
arma_aligned const T1 & m
storage of reference to the operand (eg. a matrix)
arma_inline subview_col< eT > rows(const uword in_row1, const uword in_row2)
Class for column vectors (matrices with only one column)
void copy_size(const Mat< eT2 > &m)
change the matrix (without preserving data) to have the same dimensions as the given matrix ...
#define arma_extra_debug_sigprint
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
arma_inline const Op< T1, op_diagmat > diagmat(const Base< typename T1::elem_type, T1 > &X)
interpret a matrix or a vector as a diagonal matrix (i.e. off-diagonal entries are zero) ...
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)
arma_inline const Op< T1, op_repmat > repmat(const Base< typename T1::elem_type, T1 > &A, const uword r, const uword c)
delayed 'repeat matrix' construction of a matrix
arma_inline subview< eT > cols(const uword in_col1, const uword in_col2)
creation of subview (submatrix comprised of specified column vectors)
static void apply(Mat< typename T1::elem_type > &out, const Op< T1, op_princomp > &in)