source: mmcs/armadillo_bits/fn_lu.hpp @ 8ad4484

matrices
Last change on this file since 8ad4484 was 9dd61b1, checked in by rboet <rboet@…>, 9 years ago

Avance del proyecto 60%

  • Property mode set to 100644
File size: 1.7 KB
Line 
1// Copyright (C) 2008-2011 Conrad Sanderson
2// Copyright (C) 2008-2011 NICTA (www.nicta.com.au)
3//
4// This Source Code Form is subject to the terms of the Mozilla Public
5// License, v. 2.0. If a copy of the MPL was not distributed with this
6// file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
8
9//! \addtogroup fn_lu
10//! @{
11
12
13
14//! immediate lower upper decomposition, permutation info is embedded into L (similar to Matlab/Octave)
15template<typename T1>
16inline
17bool
18lu
19  (
20         Mat<typename T1::elem_type>&    L,
21         Mat<typename T1::elem_type>&    U,
22  const Base<typename T1::elem_type,T1>& X,
23  const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
24  )
25  {
26  arma_extra_debug_sigprint();
27  arma_ignore(junk);
28 
29  arma_debug_check( (&L == &U), "lu(): L and U are the same object");
30 
31  const bool status = auxlib::lu(L, U, X);
32 
33  if(status == false)
34    {
35    L.reset();
36    U.reset();
37    arma_bad("lu(): failed to converge", false);
38    }
39 
40  return status;
41  }
42
43
44
45//! immediate lower upper decomposition, also providing the permutation matrix
46template<typename T1>
47inline
48bool
49lu
50  (
51         Mat<typename T1::elem_type>&    L,
52         Mat<typename T1::elem_type>&    U, 
53         Mat<typename T1::elem_type>&    P,
54  const Base<typename T1::elem_type,T1>& X,
55  const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
56  )
57  {
58  arma_extra_debug_sigprint();
59  arma_ignore(junk);
60 
61  arma_debug_check( ( (&L == &U) || (&L == &P) || (&U == &P) ), "lu(): two or more output objects are the same object");
62 
63  const bool status = auxlib::lu(L, U, P, X);
64 
65  if(status == false)
66    {
67    L.reset();
68    U.reset();
69    P.reset();
70    arma_bad("lu(): failed to converge", false);
71    }
72 
73  return status;
74  }
75
76
77
78//! @}
Note: See TracBrowser for help on using the repository browser.