GNU Octave  4.4.1
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-2018 John W. Eaton
4 Copyright (C) 2008-2009 Jaroslav Hajek
5 
6 This file is part of Octave.
7 
8 Octave is free software: you can redistribute it and/or modify it
9 under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12 
13 Octave is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17 
18 You should have received a copy of the GNU General Public License
19 along with Octave; see the file COPYING. If not, see
20 <https://www.gnu.org/licenses/>.
21 
22 */
23 
24 #if ! defined (octave_chol_h)
25 #define octave_chol_h 1
26 
27 #include "octave-config.h"
28 
29 namespace octave
30 {
31  namespace math
32  {
33  template <typename T>
34  class
35  chol
36  {
37  public:
38 
39  typedef typename T::column_vector_type VT;
40  typedef typename T::real_elt_type COND_T;
41 
42  chol (void) : chol_mat (), xrcond (0) { }
43 
44  chol (const T& a, bool upper = true, bool calc_cond = false)
45  : chol_mat (), xrcond (0)
46  {
47  init (a, upper, calc_cond);
48  }
49 
50  chol (const T& a, octave_idx_type& info, bool upper = true,
51  bool calc_cond = false)
52  : chol_mat (), xrcond (0)
53  {
54  info = init (a, upper, calc_cond);
55  }
56 
57  chol (const chol& a)
58  : chol_mat (a.chol_mat), xrcond (a.xrcond) { }
59 
60  chol& operator = (const chol& a)
61  {
62  if (this != &a)
63  {
64  chol_mat = a.chol_mat;
65  xrcond = a.xrcond;
66  }
67 
68  return *this;
69  }
70 
71  T chol_matrix (void) const { return chol_mat; }
72 
73  COND_T rcond (void) const { return xrcond; }
74 
75  // Compute the inverse of a matrix using the Cholesky factorization.
76  T inverse (void) const;
77 
78  void set (const T& R);
79 
80  void update (const VT& u);
81 
82  octave_idx_type downdate (const VT& u);
83 
84  octave_idx_type insert_sym (const VT& u, octave_idx_type j);
85 
86  void delete_sym (octave_idx_type j);
87 
88  void shift_sym (octave_idx_type i, octave_idx_type j);
89 
90  private:
91 
93 
95 
96  bool is_upper;
97 
98  octave_idx_type init (const T& a, bool upper, bool calc_cond);
99  };
100 
101  template <typename T>
102  T
103  chol2inv (const T& r);
104  }
105 }
106 
107 #endif
chol(const chol &a)
Definition: chol.h:57
COND_T xrcond
Definition: chol.h:94
T::real_elt_type COND_T
Definition: chol.h:40
chol(const T &a, bool upper=true, bool calc_cond=false)
Definition: chol.h:44
u
Definition: lu.cc:138
COND_T rcond(void) const
Definition: chol.h:73
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
static void downdate(double *c, int n, int d, int *nans, int nnans)
Definition: quadcc.cc:1458
T::column_vector_type VT
Definition: chol.h:39
T chol2inv(const T &r)
Definition: chol.cc:242
chol(void)
Definition: chol.h:42
for i
Definition: data.cc:5264
chol(const T &a, octave_idx_type &info, bool upper=true, bool calc_cond=false)
Definition: chol.h:50
bool is_upper
Definition: chol.h:96
T chol_matrix(void) const
Definition: chol.h:71