Chris@49: // Copyright (C) 2008-2011 NICTA (www.nicta.com.au) Chris@49: // Copyright (C) 2008-2011 Conrad Sanderson Chris@49: // Chris@49: // This Source Code Form is subject to the terms of the Mozilla Public Chris@49: // License, v. 2.0. If a copy of the MPL was not distributed with this Chris@49: // file, You can obtain one at http://mozilla.org/MPL/2.0/. Chris@49: Chris@49: Chris@49: //! \addtogroup fn_lu Chris@49: //! @{ Chris@49: Chris@49: Chris@49: Chris@49: //! immediate lower upper decomposition, permutation info is embedded into L (similar to Matlab/Octave) Chris@49: template Chris@49: inline Chris@49: bool Chris@49: lu Chris@49: ( Chris@49: Mat& L, Chris@49: Mat& U, Chris@49: const Base& X, Chris@49: const typename arma_blas_type_only::result* junk = 0 Chris@49: ) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: arma_ignore(junk); Chris@49: Chris@49: arma_debug_check( (&L == &U), "lu(): L and U are the same object"); Chris@49: Chris@49: const bool status = auxlib::lu(L, U, X); Chris@49: Chris@49: if(status == false) Chris@49: { Chris@49: L.reset(); Chris@49: U.reset(); Chris@49: arma_bad("lu(): failed to converge", false); Chris@49: } Chris@49: Chris@49: return status; Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: //! immediate lower upper decomposition, also providing the permutation matrix Chris@49: template Chris@49: inline Chris@49: bool Chris@49: lu Chris@49: ( Chris@49: Mat& L, Chris@49: Mat& U, Chris@49: Mat& P, Chris@49: const Base& X, Chris@49: const typename arma_blas_type_only::result* junk = 0 Chris@49: ) Chris@49: { Chris@49: arma_extra_debug_sigprint(); Chris@49: arma_ignore(junk); Chris@49: Chris@49: arma_debug_check( ( (&L == &U) || (&L == &P) || (&U == &P) ), "lu(): two or more output objects are the same object"); Chris@49: Chris@49: const bool status = auxlib::lu(L, U, P, X); Chris@49: Chris@49: if(status == false) Chris@49: { Chris@49: L.reset(); Chris@49: U.reset(); Chris@49: P.reset(); Chris@49: arma_bad("lu(): failed to converge", false); Chris@49: } Chris@49: Chris@49: return status; Chris@49: } Chris@49: Chris@49: Chris@49: Chris@49: //! @}