GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
chol.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1994-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_chol_h)
27 #define octave_chol_h 1
28 
29 #include "octave-config.h"
30 
31 namespace octave
32 {
33  namespace math
34  {
35  template <typename T>
36  class
37  chol
38  {
39  public:
40 
41  typedef typename T::column_vector_type VT;
42  typedef typename T::real_elt_type COND_T;
43 
44  chol (void) : chol_mat (), xrcond (0), is_upper (true) { }
45 
46  chol (const T& a, bool upper = true, bool calc_cond = false)
47  : chol_mat (), xrcond (0)
48  {
49  init (a, upper, calc_cond);
50  }
51 
52  chol (const T& a, octave_idx_type& info, bool upper = true,
53  bool calc_cond = false)
54  : chol_mat (), xrcond (0)
55  {
56  info = init (a, upper, calc_cond);
57  }
58 
59  chol (const chol& a)
60  : chol_mat (a.chol_mat), xrcond (a.xrcond), is_upper (a.is_upper) { }
61 
62  chol& operator = (const chol& a)
63  {
64  if (this != &a)
65  {
66  chol_mat = a.chol_mat;
67  xrcond = a.xrcond;
68  is_upper = a.is_upper;
69  }
70 
71  return *this;
72  }
73 
74  T chol_matrix (void) const { return chol_mat; }
75 
76  COND_T rcond (void) const { return xrcond; }
77 
78  // Compute the inverse of a matrix using the Cholesky factorization.
79  T inverse (void) const;
80 
81  void set (const T& R);
82 
83  void update (const VT& u);
84 
86 
88 
90 
92 
93  private:
94 
96 
98 
99  bool is_upper;
100 
101  octave_idx_type init (const T& a, bool upper, bool calc_cond);
102  };
103 
104  template <typename T>
105  T
106  chol2inv (const T& r);
107  }
108 }
109 
110 #endif
T chol_matrix(void) const
Definition: chol.h:74
T::real_elt_type COND_T
Definition: chol.h:42
bool is_upper
Definition: chol.h:99
octave_idx_type insert_sym(const VT &u, octave_idx_type j)
octave_idx_type downdate(const VT &u)
octave_idx_type init(const T &a, bool upper, bool calc_cond)
void shift_sym(octave_idx_type i, octave_idx_type j)
void update(const VT &u)
COND_T xrcond
Definition: chol.h:97
chol(const T &a, bool upper=true, bool calc_cond=false)
Definition: chol.h:46
chol(void)
Definition: chol.h:44
chol(const T &a, octave_idx_type &info, bool upper=true, bool calc_cond=false)
Definition: chol.h:52
chol(const chol &a)
Definition: chol.h:59
T::column_vector_type VT
Definition: chol.h:41
COND_T rcond(void) const
Definition: chol.h:76
void delete_sym(octave_idx_type j)
T * r
Definition: mx-inlines.cc:773
T chol2inv(const T &r)
Definition: chol.cc:242