GNU Octave  8.1.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-2023 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 
32 
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) : m_chol_mat (), m_rcond (0), m_is_upper (true) { }
45 
46  chol (const T& a, bool upper = true, bool calc_cond = false)
47  : m_chol_mat (), m_rcond (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  : m_chol_mat (), m_rcond (0)
55  {
56  info = init (a, upper, calc_cond);
57  }
58 
59  chol (const chol& a)
60  : m_chol_mat (a.m_chol_mat), m_rcond (a.m_rcond), m_is_upper (a.m_is_upper) { }
61 
62  chol& operator = (const chol& a)
63  {
64  if (this != &a)
65  {
66  m_chol_mat = a.m_chol_mat;
67  m_rcond = a.m_rcond;
68  m_is_upper = a.m_is_upper;
69  }
70 
71  return *this;
72  }
73 
74  T chol_matrix (void) const { return m_chol_mat; }
75 
76  COND_T rcond (void) const { return m_rcond; }
77 
78  // Compute the inverse of a matrix using the Cholesky factorization.
79  OCTAVE_API T inverse (void) const;
80 
81  OCTAVE_API void set (const T& R);
82 
83  OCTAVE_API void update (const VT& u);
84 
86 
88 
90 
92 
93 private:
94 
96 
98 
99  bool m_is_upper;
100 
101  OCTAVE_API octave_idx_type init (const T& a, bool upper, bool calc_cond);
102 };
103 
104 template <typename T>
105 OCTAVE_API T
106 chol2inv (const T& r);
107 
110 
111 #endif
OCTAVE_END_NAMESPACE(octave)
OCTAVE_API T chol2inv(const T &r)
Definition: chol.cc:242
Definition: chol.h:38
bool m_is_upper
Definition: chol.h:99
COND_T rcond(void) const
Definition: chol.h:76
OCTAVE_API void delete_sym(octave_idx_type j)
OCTAVE_API void update(const VT &u)
chol(const chol &a)
Definition: chol.h:59
T::column_vector_type VT
Definition: chol.h:41
chol(const T &a, octave_idx_type &info, bool upper=true, bool calc_cond=false)
Definition: chol.h:52
COND_T m_rcond
Definition: chol.h:97
OCTAVE_API octave_idx_type downdate(const VT &u)
chol(const T &a, bool upper=true, bool calc_cond=false)
Definition: chol.h:46
chol(void)
Definition: chol.h:44
T::real_elt_type COND_T
Definition: chol.h:42
T chol_matrix(void) const
Definition: chol.h:74
OCTAVE_API octave_idx_type insert_sym(const VT &u, octave_idx_type j)
OCTAVE_API octave_idx_type init(const T &a, bool upper, bool calc_cond)
OCTAVE_API void shift_sym(octave_idx_type i, octave_idx_type j)
T m_chol_mat
Definition: chol.h:95
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
#define OCTAVE_API
Definition: main.in.cc:55
T * r
Definition: mx-inlines.cc:773