max@0: // Copyright (C) 2010-2011 NICTA (www.nicta.com.au) max@0: // Copyright (C) 2010-2011 Conrad Sanderson max@0: // Copyright (C) 2010 Dimitrios Bouzas max@0: // max@0: // This file is part of the Armadillo C++ library. max@0: // It is provided without any warranty of fitness max@0: // for any purpose. You can redistribute this file max@0: // and/or modify it under the terms of the GNU max@0: // Lesser General Public License (LGPL) as published max@0: // by the Free Software Foundation, either version 3 max@0: // of the License or (at your option) any later version. max@0: // (see http://www.opensource.org/licenses for more info) max@0: max@0: max@0: //! \addtogroup fn_princomp max@0: //! @{ max@0: max@0: max@0: max@0: //! \brief max@0: //! principal component analysis -- 4 arguments version max@0: //! coeff_out -> principal component coefficients max@0: //! score_out -> projected samples max@0: //! latent_out -> eigenvalues of principal vectors max@0: //! tsquared_out -> Hotelling's T^2 statistic max@0: template max@0: inline max@0: bool max@0: princomp max@0: ( max@0: Mat& coeff_out, max@0: Mat& score_out, max@0: Col& latent_out, max@0: Col& tsquared_out, max@0: const Base& X, max@0: const typename arma_blas_type_only::result* junk = 0 max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: typedef typename T1::elem_type eT; max@0: max@0: const unwrap tmp(X.get_ref()); max@0: const Mat& A = tmp.M; max@0: max@0: const bool status = op_princomp::direct_princomp(coeff_out, score_out, latent_out, tsquared_out, A); max@0: max@0: if(status == false) max@0: { max@0: coeff_out.reset(); max@0: score_out.reset(); max@0: latent_out.reset(); max@0: tsquared_out.reset(); max@0: max@0: arma_bad("princomp(): failed to converge", false); max@0: } max@0: max@0: return status; max@0: } max@0: max@0: max@0: max@0: //! \brief max@0: //! principal component analysis -- 3 arguments version max@0: //! coeff_out -> principal component coefficients max@0: //! score_out -> projected samples max@0: //! latent_out -> eigenvalues of principal vectors max@0: template max@0: inline max@0: bool max@0: princomp max@0: ( max@0: Mat& coeff_out, max@0: Mat& score_out, max@0: Col& latent_out, max@0: const Base& X, max@0: const typename arma_blas_type_only::result* junk = 0 max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: typedef typename T1::elem_type eT; max@0: max@0: const unwrap tmp(X.get_ref()); max@0: const Mat& A = tmp.M; max@0: max@0: const bool status = op_princomp::direct_princomp(coeff_out, score_out, latent_out, A); max@0: max@0: if(status == false) max@0: { max@0: coeff_out.reset(); max@0: score_out.reset(); max@0: latent_out.reset(); max@0: max@0: arma_bad("princomp(): failed to converge", false); max@0: } max@0: max@0: return status; max@0: } max@0: max@0: max@0: max@0: //! \brief max@0: //! principal component analysis -- 2 arguments version max@0: //! coeff_out -> principal component coefficients max@0: //! score_out -> projected samples max@0: template max@0: inline max@0: bool max@0: princomp max@0: ( max@0: Mat& coeff_out, max@0: Mat& score_out, max@0: const Base& X, max@0: const typename arma_blas_type_only::result* junk = 0 max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: typedef typename T1::elem_type eT; max@0: max@0: const unwrap tmp(X.get_ref()); max@0: const Mat& A = tmp.M; max@0: max@0: const bool status = op_princomp::direct_princomp(coeff_out, score_out, A); max@0: max@0: if(status == false) max@0: { max@0: coeff_out.reset(); max@0: score_out.reset(); max@0: max@0: arma_bad("princomp(): failed to converge", false); max@0: } max@0: max@0: return status; max@0: } max@0: max@0: max@0: max@0: //! \brief max@0: //! principal component analysis -- 1 argument version max@0: //! coeff_out -> principal component coefficients max@0: template max@0: inline max@0: bool max@0: princomp max@0: ( max@0: Mat& coeff_out, max@0: const Base& X, max@0: const typename arma_blas_type_only::result* junk = 0 max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: typedef typename T1::elem_type eT; max@0: max@0: const unwrap tmp(X.get_ref()); max@0: const Mat& A = tmp.M; max@0: max@0: const bool status = op_princomp::direct_princomp(coeff_out, A); max@0: max@0: if(status == false) max@0: { max@0: coeff_out.reset(); max@0: max@0: arma_bad("princomp(): failed to converge", false); max@0: } max@0: max@0: return status; max@0: } max@0: max@0: max@0: max@0: template max@0: inline max@0: const Op max@0: princomp max@0: ( max@0: const Base& X, max@0: const typename arma_blas_type_only::result* junk = 0 max@0: ) max@0: { max@0: arma_extra_debug_sigprint(); max@0: max@0: return Op(X.get_ref()); max@0: } max@0: max@0: max@0: max@0: //! @}