annotate liboctave/numeric/chol.cc @ 29228:5c14f81e0937

Set API tags in files in liboctave/numeric (patch #8919). Add API tag to template class definitions. Add API tag to (un-defined) functions and member functions in headers. Export template class instantiations and template functions from .cc files.
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 29 Dec 2020 17:51:23 +0100
parents bd51beb6205e
children 7854d5752dd2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
3 // Copyright (C) 1994-2020 The Octave Project Developers
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21285
diff changeset
27 # include "config.h"
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
28 #endif
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
29
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23220
diff changeset
30 #include "Array.h"
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
31 #include "CColVector.h"
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
32 #include "CMatrix.h"
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
33 #include "chol.h"
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
34 #include "dColVector.h"
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
35 #include "dMatrix.h"
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
36 #include "fCColVector.h"
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
37 #include "fCMatrix.h"
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
38 #include "fColVector.h"
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
39 #include "fMatrix.h"
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
40 #include "lo-error.h"
22322
93b3cdd36854 move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents: 22317
diff changeset
41 #include "lo-lapack-proto.h"
93b3cdd36854 move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents: 22317
diff changeset
42 #include "lo-qrupdate-proto.h"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 7725
diff changeset
43 #include "oct-locbuf.h"
9862
c0aeedd8fb86 improve chol Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 8562
diff changeset
44 #include "oct-norm.h"
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
45
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
46 #if ! defined (HAVE_QRUPDATE)
21285
d3b265a83adc make building without qrupdate work again
John W. Eaton <jwe@octave.org>
parents: 21270
diff changeset
47 # include "qr.h"
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
48 #endif
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
49
22317
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22274
diff changeset
50 namespace octave
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22274
diff changeset
51 {
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
52 static Matrix
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
53 chol2inv_internal (const Matrix& r, bool is_upper = true)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
54 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
55 Matrix retval;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
56
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
57 octave_idx_type r_nr = r.rows ();
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
58 octave_idx_type r_nc = r.cols ();
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
59
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
60 if (r_nr != r_nc)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
61 (*current_liboctave_error_handler) ("chol2inv requires square matrix");
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
62
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27101
diff changeset
63 F77_INT n = to_f77_int (r_nc);
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
64 F77_INT info;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
65
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
66 Matrix tmp = r;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
67 double *v = tmp.fortran_vec ();
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
68
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
69 if (is_upper)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
70 F77_XFCN (dpotri, DPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
71 v, n, info
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
72 F77_CHAR_ARG_LEN (1)));
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
73 else
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
74 F77_XFCN (dpotri, DPOTRI, (F77_CONST_CHAR_ARG2 ("L", 1), n,
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
75 v, n, info
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
76 F77_CHAR_ARG_LEN (1)));
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
77
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
78 // FIXME: Should we check info exit value and possibly report an error?
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
79
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
80 // If someone thinks of a more graceful way of doing this
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
81 // (or faster for that matter :-)), please let me know!
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
82
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
83 if (n > 1)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
84 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
85 if (is_upper)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
86 for (octave_idx_type j = 0; j < r_nc; j++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
87 for (octave_idx_type i = j+1; i < r_nr; i++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
88 tmp.xelem (i, j) = tmp.xelem (j, i);
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
89 else
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
90 for (octave_idx_type j = 0; j < r_nc; j++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
91 for (octave_idx_type i = j+1; i < r_nr; i++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
92 tmp.xelem (j, i) = tmp.xelem (i, j);
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
93 }
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
94
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
95 retval = tmp;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
96
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
97 return retval;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
98 }
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
99
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
100 static FloatMatrix
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
101 chol2inv_internal (const FloatMatrix& r, bool is_upper = true)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
102 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
103 FloatMatrix retval;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
104
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
105 octave_idx_type r_nr = r.rows ();
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
106 octave_idx_type r_nc = r.cols ();
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
107
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
108 if (r_nr != r_nc)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
109 (*current_liboctave_error_handler) ("chol2inv requires square matrix");
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
110
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27101
diff changeset
111 F77_INT n = to_f77_int (r_nc);
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
112 F77_INT info;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
113
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
114 FloatMatrix tmp = r;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
115 float *v = tmp.fortran_vec ();
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
116
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
117 if (is_upper)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
118 F77_XFCN (spotri, SPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
119 v, n, info
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
120 F77_CHAR_ARG_LEN (1)));
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
121 else
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
122 F77_XFCN (spotri, SPOTRI, (F77_CONST_CHAR_ARG2 ("L", 1), n,
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
123 v, n, info
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
124 F77_CHAR_ARG_LEN (1)));
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
125
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
126 // FIXME: Should we check info exit value and possibly report an error?
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
127
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
128 // If someone thinks of a more graceful way of doing this (or
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
129 // faster for that matter :-)), please let me know!
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
130
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
131 if (n > 1)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
132 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
133 if (is_upper)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
134 for (octave_idx_type j = 0; j < r_nc; j++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
135 for (octave_idx_type i = j+1; i < r_nr; i++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
136 tmp.xelem (i, j) = tmp.xelem (j, i);
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
137 else
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
138 for (octave_idx_type j = 0; j < r_nc; j++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
139 for (octave_idx_type i = j+1; i < r_nr; i++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
140 tmp.xelem (j, i) = tmp.xelem (i, j);
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
141 }
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
142
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
143 retval = tmp;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
144
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
145 return retval;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
146 }
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
147
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
148 static ComplexMatrix
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
149 chol2inv_internal (const ComplexMatrix& r, bool is_upper = true)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
150 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
151 ComplexMatrix retval;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
152
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
153 octave_idx_type r_nr = r.rows ();
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
154 octave_idx_type r_nc = r.cols ();
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
155
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
156 if (r_nr != r_nc)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
157 (*current_liboctave_error_handler) ("chol2inv requires square matrix");
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
158
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27101
diff changeset
159 F77_INT n = to_f77_int (r_nc);
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
160 F77_INT info;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
161
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
162 ComplexMatrix tmp = r;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
163
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
164 if (is_upper)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
165 F77_XFCN (zpotri, ZPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
166 F77_DBLE_CMPLX_ARG (tmp.fortran_vec ()), n, info
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
167 F77_CHAR_ARG_LEN (1)));
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
168 else
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
169 F77_XFCN (zpotri, ZPOTRI, (F77_CONST_CHAR_ARG2 ("L", 1), n,
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
170 F77_DBLE_CMPLX_ARG (tmp.fortran_vec ()), n, info
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
171 F77_CHAR_ARG_LEN (1)));
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
172
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
173 // If someone thinks of a more graceful way of doing this (or
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
174 // faster for that matter :-)), please let me know!
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
175
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
176 if (n > 1)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
177 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
178 if (is_upper)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
179 for (octave_idx_type j = 0; j < r_nc; j++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
180 for (octave_idx_type i = j+1; i < r_nr; i++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
181 tmp.xelem (i, j) = std::conj (tmp.xelem (j, i));
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
182 else
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
183 for (octave_idx_type j = 0; j < r_nc; j++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
184 for (octave_idx_type i = j+1; i < r_nr; i++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
185 tmp.xelem (j, i) = std::conj (tmp.xelem (i, j));
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
186 }
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
187
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
188 retval = tmp;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
189
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
190 return retval;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
191 }
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
192
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
193 static FloatComplexMatrix
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
194 chol2inv_internal (const FloatComplexMatrix& r, bool is_upper = true)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
195 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
196 FloatComplexMatrix retval;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
197
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
198 octave_idx_type r_nr = r.rows ();
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
199 octave_idx_type r_nc = r.cols ();
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
200
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
201 if (r_nr != r_nc)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
202 (*current_liboctave_error_handler) ("chol2inv requires square matrix");
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
203
27102
84ff9953faa1 where possible, eliminate octave:: namespace qualifier inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 27101
diff changeset
204 F77_INT n = to_f77_int (r_nc);
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
205 F77_INT info;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
206
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
207 FloatComplexMatrix tmp = r;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
208
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
209 if (is_upper)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
210 F77_XFCN (cpotri, CPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
211 F77_CMPLX_ARG (tmp.fortran_vec ()), n, info
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
212 F77_CHAR_ARG_LEN (1)));
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
213 else
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
214 F77_XFCN (cpotri, CPOTRI, (F77_CONST_CHAR_ARG2 ("L", 1), n,
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
215 F77_CMPLX_ARG (tmp.fortran_vec ()), n, info
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
216 F77_CHAR_ARG_LEN (1)));
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
217
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
218 // If someone thinks of a more graceful way of doing this (or
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
219 // faster for that matter :-)), please let me know!
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
220
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
221 if (n > 1)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
222 {
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
223 if (is_upper)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
224 for (octave_idx_type j = 0; j < r_nc; j++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
225 for (octave_idx_type i = j+1; i < r_nr; i++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
226 tmp.xelem (i, j) = std::conj (tmp.xelem (j, i));
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
227 else
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
228 for (octave_idx_type j = 0; j < r_nc; j++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
229 for (octave_idx_type i = j+1; i < r_nr; i++)
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
230 tmp.xelem (j, i) = std::conj (tmp.xelem (i, j));
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
231 }
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
232
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
233 retval = tmp;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
234
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
235 return retval;
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
236 }
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
237
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
238 namespace math
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
239 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
240 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
241 T
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
242 chol2inv (const T& r)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
243 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
244 return chol2inv_internal (r);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
245 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
246
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
247 // Compute the inverse of a matrix using the Cholesky factorization.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
248 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
249 T
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
250 chol<T>::inverse (void) const
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
251 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
252 return chol2inv_internal (chol_mat, is_upper);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
253 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
254
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
255 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
256 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
257 chol<T>::set (const T& R)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
258 {
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23475
diff changeset
259 if (! R.issquare ())
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
260 (*current_liboctave_error_handler) ("chol: requires square matrix");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
261
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
262 chol_mat = R;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
263 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
264
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
265 #if ! defined (HAVE_QRUPDATE)
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
266
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
267 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
268 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
269 chol<T>::update (const VT& u)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
270 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
271 warn_qrupdate_once ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
272
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
273 octave_idx_type n = chol_mat.rows ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
274
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
275 if (u.numel () != n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
276 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
277
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
278 init (chol_mat.hermitian () * chol_mat + T (u) * T (u).hermitian (),
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
279 true, false);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
280 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
281
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
282 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
283 bool
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
284 singular (const T& a)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
285 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
286 static typename T::element_type zero (0);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
287 for (octave_idx_type i = 0; i < a.rows (); i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
288 if (a(i,i) == zero) return true;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
289 return false;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
290 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
291
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
292 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
293 octave_idx_type
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
294 chol<T>::downdate (const VT& u)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
295 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
296 warn_qrupdate_once ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
297
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
298 octave_idx_type info = -1;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
299
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
300 octave_idx_type n = chol_mat.rows ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
301
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
302 if (u.numel () != n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
303 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
304
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
305 if (singular (chol_mat))
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
306 info = 2;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
307 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
308 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
309 info = init (chol_mat.hermitian () * chol_mat
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
310 - T (u) * T (u).hermitian (), true, false);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
311 if (info) info = 1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
312 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
313
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
314 return info;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
315 }
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
316
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
317 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
318 octave_idx_type
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
319 chol<T>::insert_sym (const VT& u, octave_idx_type j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
320 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
321 static typename T::element_type zero (0);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
322
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
323 warn_qrupdate_once ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
324
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
325 octave_idx_type info = -1;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
326
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
327 octave_idx_type n = chol_mat.rows ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
328
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
329 if (u.numel () != n + 1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
330 (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
331 if (j < 0 || j > n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
332 (*current_liboctave_error_handler) ("cholinsert: index out of range");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
333
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
334 if (singular (chol_mat))
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
335 info = 2;
23708
750e42a35adc Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents: 23696
diff changeset
336 else if (std::imag (u(j)) != zero)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
337 info = 3;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
338 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
339 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
340 T a = chol_mat.hermitian () * chol_mat;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
341 T a1 (n+1, n+1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
342 for (octave_idx_type k = 0; k < n+1; k++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
343 for (octave_idx_type l = 0; l < n+1; l++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
344 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
345 if (l == j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
346 a1(k, l) = u(k);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
347 else if (k == j)
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
348 a1(k, l) = math::conj (u(l));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
349 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
350 a1(k, l) = a(k < j ? k : k-1, l < j ? l : l-1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
351 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
352 info = init (a1, true, false);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
353 if (info) info = 1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
354 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
355
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
356 return info;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
357 }
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
358
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
359 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
360 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
361 chol<T>::delete_sym (octave_idx_type j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
362 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
363 warn_qrupdate_once ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
364
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
365 octave_idx_type n = chol_mat.rows ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
366
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
367 if (j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
368 (*current_liboctave_error_handler) ("choldelete: index out of range");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
369
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
370 T a = chol_mat.hermitian () * chol_mat;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
371 a.delete_elements (1, idx_vector (j));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
372 a.delete_elements (0, idx_vector (j));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
373 init (a, true, false);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
374 }
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
375
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
376 template <typename T>
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
377 void
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
378 chol<T>::shift_sym (octave_idx_type i, octave_idx_type j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
379 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
380 warn_qrupdate_once ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
381
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
382 octave_idx_type n = chol_mat.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
383
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
384 if (i < 0 || i > n-1 || j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
385 (*current_liboctave_error_handler) ("cholshift: index out of range");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
386
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
387 T a = chol_mat.hermitian () * chol_mat;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
388 Array<octave_idx_type> p (dim_vector (n, 1));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
389 for (octave_idx_type k = 0; k < n; k++) p(k) = k;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
390 if (i < j)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
391 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
392 for (octave_idx_type k = i; k < j; k++) p(k) = k+1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
393 p(j) = i;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
394 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
395 else if (j < i)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
396 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
397 p(j) = i;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
398 for (octave_idx_type k = j+1; k < i+1; k++) p(k) = k-1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
399 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
400
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
401 init (a.index (idx_vector (p), idx_vector (p)), true, false);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
402 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
403
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
404 #endif
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
405
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
406 // Specializations.
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
407
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
408 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
409 OCTAVE_API octave_idx_type
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
410 chol<Matrix>::init (const Matrix& a, bool upper, bool calc_cond)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
411 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
412 octave_idx_type a_nr = a.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
413 octave_idx_type a_nc = a.cols ();
1944
8cb4d3008c76 [project @ 1996-02-14 00:45:04 by jwe]
jwe
parents: 1882
diff changeset
414
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
415 if (a_nr != a_nc)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
416 (*current_liboctave_error_handler) ("chol: requires square matrix");
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
417
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
418 F77_INT n = to_f77_int (a_nc);
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
419 F77_INT info;
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
420
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
421 is_upper = upper;
20462
5ce959c55cc0 Propagate 'lower' in chol(a, 'lower') to underlying library function.
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
parents: 20232
diff changeset
422
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
423 chol_mat.clear (n, n);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
424 if (is_upper)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
425 for (octave_idx_type j = 0; j < n; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
426 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
427 for (octave_idx_type i = 0; i <= j; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
428 chol_mat.xelem (i, j) = a(i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
429 for (octave_idx_type i = j+1; i < n; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
430 chol_mat.xelem (i, j) = 0.0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
431 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
432 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
433 for (octave_idx_type j = 0; j < n; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
434 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
435 for (octave_idx_type i = 0; i < j; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
436 chol_mat.xelem (i, j) = 0.0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
437 for (octave_idx_type i = j; i < n; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
438 chol_mat.xelem (i, j) = a(i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
439 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
440 double *h = chol_mat.fortran_vec ();
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
441
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
442 // Calculate the norm of the matrix, for later use.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
443 double anorm = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
444 if (calc_cond)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
445 anorm = xnorm (a, 1);
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
446
20462
5ce959c55cc0 Propagate 'lower' in chol(a, 'lower') to underlying library function.
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
parents: 20232
diff changeset
447 if (is_upper)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
448 F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n, h, n, info
20628
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
449 F77_CHAR_ARG_LEN (1)));
20462
5ce959c55cc0 Propagate 'lower' in chol(a, 'lower') to underlying library function.
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
parents: 20232
diff changeset
450 else
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
451 F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 ("L", 1), n, h, n, info
20628
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
452 F77_CHAR_ARG_LEN (1)));
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
453
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
454 xrcond = 0.0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
455 if (info > 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
456 chol_mat.resize (info - 1, info - 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
457 else if (calc_cond)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
458 {
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
459 F77_INT dpocon_info = 0;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
460
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
461 // Now calculate the condition number for non-singular matrix.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
462 Array<double> z (dim_vector (3*n, 1));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
463 double *pz = z.fortran_vec ();
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
464 OCTAVE_LOCAL_BUFFER (F77_INT, iz, n);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
465 if (is_upper)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
466 F77_XFCN (dpocon, DPOCON, (F77_CONST_CHAR_ARG2 ("U", 1), n, h,
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
467 n, anorm, xrcond, pz, iz, dpocon_info
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
468 F77_CHAR_ARG_LEN (1)));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
469 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
470 F77_XFCN (dpocon, DPOCON, (F77_CONST_CHAR_ARG2 ("L", 1), n, h,
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
471 n, anorm, xrcond, pz, iz, dpocon_info
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
472 F77_CHAR_ARG_LEN (1)));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
473
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
474 if (dpocon_info != 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
475 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
476 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
477
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
478 return info;
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
479 }
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
480
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
481 #if defined (HAVE_QRUPDATE)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
482
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
483 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
484 OCTAVE_API void
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
485 chol<Matrix>::update (const ColumnVector& u)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
486 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
487 F77_INT n = to_f77_int (chol_mat.rows ());
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
488
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
489 if (u.numel () != n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
490 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
491
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
492 ColumnVector utmp = u;
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
493
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
494 OCTAVE_LOCAL_BUFFER (double, w, n);
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
495
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
496 F77_XFCN (dch1up, DCH1UP, (n, chol_mat.fortran_vec (), n,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
497 utmp.fortran_vec (), w));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
498 }
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
499
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
500 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
501 OCTAVE_API octave_idx_type
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
502 chol<Matrix>::downdate (const ColumnVector& u)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
503 {
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
504 F77_INT info = -1;
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
505
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
506 F77_INT n = to_f77_int (chol_mat.rows ());
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
507
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
508 if (u.numel () != n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
509 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
510
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
511 ColumnVector utmp = u;
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
512
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
513 OCTAVE_LOCAL_BUFFER (double, w, n);
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
514
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
515 F77_XFCN (dch1dn, DCH1DN, (n, chol_mat.fortran_vec (), n,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
516 utmp.fortran_vec (), w, info));
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
517
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
518 return info;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
519 }
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
520
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
521 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
522 OCTAVE_API octave_idx_type
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
523 chol<Matrix>::insert_sym (const ColumnVector& u, octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
524 {
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
525 F77_INT info = -1;
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
526
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
527 F77_INT n = to_f77_int (chol_mat.rows ());
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
528 F77_INT j = to_f77_int (j_arg);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
529
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
530 if (u.numel () != n + 1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
531 (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
532 if (j < 0 || j > n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
533 (*current_liboctave_error_handler) ("cholinsert: index out of range");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
534
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
535 ColumnVector utmp = u;
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
536
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
537 OCTAVE_LOCAL_BUFFER (double, w, n);
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
538
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
539 chol_mat.resize (n+1, n+1);
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
540 F77_INT ldcm = to_f77_int (chol_mat.rows ());
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
541
22969
023026207910 * chol.cc: Fix thinko in previous change.
John W. Eaton <jwe@octave.org>
parents: 22942
diff changeset
542 F77_XFCN (dchinx, DCHINX, (n, chol_mat.fortran_vec (), ldcm,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
543 j + 1, utmp.fortran_vec (), w, info));
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
544
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
545 return info;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
546 }
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
547
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
548 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
549 OCTAVE_API void
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
550 chol<Matrix>::delete_sym (octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
551 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
552 F77_INT n = to_f77_int (chol_mat.rows ());
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
553 F77_INT j = to_f77_int (j_arg);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
554
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
555 if (j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
556 (*current_liboctave_error_handler) ("choldelete: index out of range");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
557
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
558 OCTAVE_LOCAL_BUFFER (double, w, n);
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
559
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
560 F77_XFCN (dchdex, DCHDEX, (n, chol_mat.fortran_vec (), n, j + 1, w));
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
561
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
562 chol_mat.resize (n-1, n-1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
563 }
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
564
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
565 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
566 OCTAVE_API void
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
567 chol<Matrix>::shift_sym (octave_idx_type i_arg, octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
568 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
569 F77_INT n = to_f77_int (chol_mat.rows ());
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
570 F77_INT i = to_f77_int (i_arg);
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
571 F77_INT j = to_f77_int (j_arg);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
572
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
573 if (i < 0 || i > n-1 || j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
574 (*current_liboctave_error_handler) ("cholshift: index out of range");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
575
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
576 OCTAVE_LOCAL_BUFFER (double, w, 2*n);
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
577
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
578 F77_XFCN (dchshx, DCHSHX, (n, chol_mat.fortran_vec (), n,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
579 i + 1, j + 1, w));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
580 }
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
581
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
582 #endif
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
583
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
584 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
585 OCTAVE_API octave_idx_type
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
586 chol<FloatMatrix>::init (const FloatMatrix& a, bool upper, bool calc_cond)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
587 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
588 octave_idx_type a_nr = a.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
589 octave_idx_type a_nc = a.cols ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
590
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
591 if (a_nr != a_nc)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
592 (*current_liboctave_error_handler) ("chol: requires square matrix");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
593
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
594 F77_INT n = to_f77_int (a_nc);
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
595 F77_INT info;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
596
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
597 is_upper = upper;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
598
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
599 chol_mat.clear (n, n);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
600 if (is_upper)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
601 for (octave_idx_type j = 0; j < n; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
602 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
603 for (octave_idx_type i = 0; i <= j; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
604 chol_mat.xelem (i, j) = a(i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
605 for (octave_idx_type i = j+1; i < n; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
606 chol_mat.xelem (i, j) = 0.0f;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
607 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
608 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
609 for (octave_idx_type j = 0; j < n; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
610 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
611 for (octave_idx_type i = 0; i < j; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
612 chol_mat.xelem (i, j) = 0.0f;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
613 for (octave_idx_type i = j; i < n; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
614 chol_mat.xelem (i, j) = a(i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
615 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
616 float *h = chol_mat.fortran_vec ();
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
617
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
618 // Calculate the norm of the matrix, for later use.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
619 float anorm = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
620 if (calc_cond)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
621 anorm = xnorm (a, 1);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
622
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
623 if (is_upper)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
624 F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n, h, n, info
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
625 F77_CHAR_ARG_LEN (1)));
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
626 else
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
627 F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 ("L", 1), n, h, n, info
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
628 F77_CHAR_ARG_LEN (1)));
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
629
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
630 xrcond = 0.0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
631 if (info > 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
632 chol_mat.resize (info - 1, info - 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
633 else if (calc_cond)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
634 {
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
635 F77_INT spocon_info = 0;
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
636
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
637 // Now calculate the condition number for non-singular matrix.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
638 Array<float> z (dim_vector (3*n, 1));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
639 float *pz = z.fortran_vec ();
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
640 OCTAVE_LOCAL_BUFFER (F77_INT, iz, n);
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
641 if (is_upper)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
642 F77_XFCN (spocon, SPOCON, (F77_CONST_CHAR_ARG2 ("U", 1), n, h,
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
643 n, anorm, xrcond, pz, iz, spocon_info
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
644 F77_CHAR_ARG_LEN (1)));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
645 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
646 F77_XFCN (spocon, SPOCON, (F77_CONST_CHAR_ARG2 ("L", 1), n, h,
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
647 n, anorm, xrcond, pz, iz, spocon_info
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
648 F77_CHAR_ARG_LEN (1)));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
649
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
650 if (spocon_info != 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
651 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
652 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
653
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
654 return info;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
655 }
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
656
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
657 #if defined (HAVE_QRUPDATE)
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
658
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
659 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
660 OCTAVE_API void
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
661 chol<FloatMatrix>::update (const FloatColumnVector& u)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
662 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
663 F77_INT n = to_f77_int (chol_mat.rows ());
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
664
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
665 if (u.numel () != n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
666 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
667
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
668 FloatColumnVector utmp = u;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
669
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
670 OCTAVE_LOCAL_BUFFER (float, w, n);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
671
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
672 F77_XFCN (sch1up, SCH1UP, (n, chol_mat.fortran_vec (), n,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
673 utmp.fortran_vec (), w));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
674 }
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
675
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
676 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
677 OCTAVE_API octave_idx_type
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
678 chol<FloatMatrix>::downdate (const FloatColumnVector& u)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
679 {
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
680 F77_INT info = -1;
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
681
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
682 F77_INT n = to_f77_int (chol_mat.rows ());
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
683
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
684 if (u.numel () != n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
685 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
686
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
687 FloatColumnVector utmp = u;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
688
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
689 OCTAVE_LOCAL_BUFFER (float, w, n);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
690
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
691 F77_XFCN (sch1dn, SCH1DN, (n, chol_mat.fortran_vec (), n,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
692 utmp.fortran_vec (), w, info));
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
693
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
694 return info;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
695 }
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
696
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
697 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
698 OCTAVE_API octave_idx_type
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
699 chol<FloatMatrix>::insert_sym (const FloatColumnVector& u,
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
700 octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
701 {
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
702 F77_INT info = -1;
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
703
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
704 F77_INT n = to_f77_int (chol_mat.rows ());
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
705 F77_INT j = to_f77_int (j_arg);
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
706
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
707 if (u.numel () != n + 1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
708 (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
709 if (j < 0 || j > n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
710 (*current_liboctave_error_handler) ("cholinsert: index out of range");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
711
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
712 FloatColumnVector utmp = u;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
713
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
714 OCTAVE_LOCAL_BUFFER (float, w, n);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
715
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
716 chol_mat.resize (n+1, n+1);
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
717 F77_INT ldcm = to_f77_int (chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
718
22969
023026207910 * chol.cc: Fix thinko in previous change.
John W. Eaton <jwe@octave.org>
parents: 22942
diff changeset
719 F77_XFCN (schinx, SCHINX, (n, chol_mat.fortran_vec (), ldcm,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
720 j + 1, utmp.fortran_vec (), w, info));
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
721
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
722 return info;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
723 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
724
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
725 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
726 OCTAVE_API void
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
727 chol<FloatMatrix>::delete_sym (octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
728 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
729 F77_INT n = to_f77_int (chol_mat.rows ());
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
730 F77_INT j = to_f77_int (j_arg);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
731
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
732 if (j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
733 (*current_liboctave_error_handler) ("choldelete: index out of range");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
734
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
735 OCTAVE_LOCAL_BUFFER (float, w, n);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
736
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
737 F77_XFCN (schdex, SCHDEX, (n, chol_mat.fortran_vec (), n,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
738 j + 1, w));
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
739
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
740 chol_mat.resize (n-1, n-1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
741 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
742
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
743 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
744 OCTAVE_API void
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
745 chol<FloatMatrix>::shift_sym (octave_idx_type i_arg, octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
746 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
747 F77_INT n = to_f77_int (chol_mat.rows ());
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
748 F77_INT i = to_f77_int (i_arg);
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
749 F77_INT j = to_f77_int (j_arg);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
750
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
751 if (i < 0 || i > n-1 || j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
752 (*current_liboctave_error_handler) ("cholshift: index out of range");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
753
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
754 OCTAVE_LOCAL_BUFFER (float, w, 2*n);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
755
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
756 F77_XFCN (schshx, SCHSHX, (n, chol_mat.fortran_vec (), n,
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
757 i + 1, j + 1, w));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
758 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
759
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
760 #endif
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
761
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
762 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
763 OCTAVE_API octave_idx_type
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
764 chol<ComplexMatrix>::init (const ComplexMatrix& a, bool upper, bool calc_cond)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
765 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
766 octave_idx_type a_nr = a.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
767 octave_idx_type a_nc = a.cols ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
768
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
769 if (a_nr != a_nc)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
770 (*current_liboctave_error_handler) ("chol: requires square matrix");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
771
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
772 F77_INT n = to_f77_int (a_nc);
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
773 F77_INT info;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
774
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
775 is_upper = upper;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
776
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
777 chol_mat.clear (n, n);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
778 if (is_upper)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
779 for (octave_idx_type j = 0; j < n; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
780 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
781 for (octave_idx_type i = 0; i <= j; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
782 chol_mat.xelem (i, j) = a(i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
783 for (octave_idx_type i = j+1; i < n; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
784 chol_mat.xelem (i, j) = 0.0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
785 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
786 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
787 for (octave_idx_type j = 0; j < n; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
788 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
789 for (octave_idx_type i = 0; i < j; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
790 chol_mat.xelem (i, j) = 0.0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
791 for (octave_idx_type i = j; i < n; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
792 chol_mat.xelem (i, j) = a(i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
793 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
794 Complex *h = chol_mat.fortran_vec ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
795
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
796 // Calculate the norm of the matrix, for later use.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
797 double anorm = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
798 if (calc_cond)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
799 anorm = xnorm (a, 1);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
800
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
801 if (is_upper)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
802 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
803 F77_DBLE_CMPLX_ARG (h), n, info
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
804 F77_CHAR_ARG_LEN (1)));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
805 else
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
806 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 ("L", 1), n,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
807 F77_DBLE_CMPLX_ARG (h), n, info
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
808 F77_CHAR_ARG_LEN (1)));
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
809
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
810 xrcond = 0.0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
811 if (info > 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
812 chol_mat.resize (info - 1, info - 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
813 else if (calc_cond)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
814 {
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
815 F77_INT zpocon_info = 0;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
816
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
817 // Now calculate the condition number for non-singular matrix.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
818 Array<Complex> z (dim_vector (2*n, 1));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
819 Complex *pz = z.fortran_vec ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
820 Array<double> rz (dim_vector (n, 1));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
821 double *prz = rz.fortran_vec ();
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
822 F77_XFCN (zpocon, ZPOCON, (F77_CONST_CHAR_ARG2 ("U", 1), n,
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
823 F77_DBLE_CMPLX_ARG (h), n, anorm, xrcond,
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
824 F77_DBLE_CMPLX_ARG (pz), prz, zpocon_info
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
825 F77_CHAR_ARG_LEN (1)));
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
826
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
827 if (zpocon_info != 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
828 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
829 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
830
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
831 return info;
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
832 }
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
833
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
834 #if defined (HAVE_QRUPDATE)
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
835
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
836 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
837 OCTAVE_API void
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
838 chol<ComplexMatrix>::update (const ComplexColumnVector& u)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
839 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
840 F77_INT n = to_f77_int (chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
841
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
842 if (u.numel () != n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
843 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
844
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
845 ComplexColumnVector utmp = u;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
846
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
847 OCTAVE_LOCAL_BUFFER (double, rw, n);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
848
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
849 F77_XFCN (zch1up, ZCH1UP, (n,
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
850 F77_DBLE_CMPLX_ARG (chol_mat.fortran_vec ()),
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
851 n,
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
852 F77_DBLE_CMPLX_ARG (utmp.fortran_vec ()),
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
853 rw));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
854 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
855
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
856 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
857 OCTAVE_API octave_idx_type
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
858 chol<ComplexMatrix>::downdate (const ComplexColumnVector& u)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
859 {
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
860 F77_INT info = -1;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
861
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
862 F77_INT n = to_f77_int (chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
863
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
864 if (u.numel () != n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
865 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
866
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
867 ComplexColumnVector utmp = u;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
868
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
869 OCTAVE_LOCAL_BUFFER (double, rw, n);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
870
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
871 F77_XFCN (zch1dn, ZCH1DN, (n,
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
872 F77_DBLE_CMPLX_ARG (chol_mat.fortran_vec ()),
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
873 n,
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
874 F77_DBLE_CMPLX_ARG (utmp.fortran_vec ()),
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
875 rw, info));
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
876
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
877 return info;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
878 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
879
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
880 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
881 OCTAVE_API octave_idx_type
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
882 chol<ComplexMatrix>::insert_sym (const ComplexColumnVector& u,
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
883 octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
884 {
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
885 F77_INT info = -1;
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
886
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
887 F77_INT n = to_f77_int (chol_mat.rows ());
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
888 F77_INT j = to_f77_int (j_arg);
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
889
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
890 if (u.numel () != n + 1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
891 (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
892 if (j < 0 || j > n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
893 (*current_liboctave_error_handler) ("cholinsert: index out of range");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
894
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
895 ComplexColumnVector utmp = u;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
896
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
897 OCTAVE_LOCAL_BUFFER (double, rw, n);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
898
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
899 chol_mat.resize (n+1, n+1);
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
900 F77_INT ldcm = to_f77_int (chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
901
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
902 F77_XFCN (zchinx, ZCHINX, (n,
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
903 F77_DBLE_CMPLX_ARG (chol_mat.fortran_vec ()),
22969
023026207910 * chol.cc: Fix thinko in previous change.
John W. Eaton <jwe@octave.org>
parents: 22942
diff changeset
904 ldcm, j + 1,
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
905 F77_DBLE_CMPLX_ARG (utmp.fortran_vec ()),
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
906 rw, info));
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
907
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
908 return info;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
909 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
910
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
911 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
912 OCTAVE_API void
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
913 chol<ComplexMatrix>::delete_sym (octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
914 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
915 F77_INT n = to_f77_int (chol_mat.rows ());
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
916 F77_INT j = to_f77_int (j_arg);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
917
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
918 if (j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
919 (*current_liboctave_error_handler) ("choldelete: index out of range");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
920
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
921 OCTAVE_LOCAL_BUFFER (double, rw, n);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
922
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
923 F77_XFCN (zchdex, ZCHDEX, (n,
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
924 F77_DBLE_CMPLX_ARG (chol_mat.fortran_vec ()),
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
925 n, j + 1, rw));
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
926
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
927 chol_mat.resize (n-1, n-1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
928 }
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
929
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
930 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
931 OCTAVE_API void
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
932 chol<ComplexMatrix>::shift_sym (octave_idx_type i_arg,
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
933 octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
934 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
935 F77_INT n = to_f77_int (chol_mat.rows ());
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
936 F77_INT i = to_f77_int (i_arg);
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
937 F77_INT j = to_f77_int (j_arg);
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
938
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
939 if (i < 0 || i > n-1 || j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
940 (*current_liboctave_error_handler) ("cholshift: index out of range");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
941
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
942 OCTAVE_LOCAL_BUFFER (Complex, w, n);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
943 OCTAVE_LOCAL_BUFFER (double, rw, n);
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
944
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
945 F77_XFCN (zchshx, ZCHSHX, (n,
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
946 F77_DBLE_CMPLX_ARG (chol_mat.fortran_vec ()),
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
947 n, i + 1, j + 1,
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
948 F77_DBLE_CMPLX_ARG (w), rw));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
949 }
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
950
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
951 #endif
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
952
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
953 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
954 OCTAVE_API octave_idx_type
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
955 chol<FloatComplexMatrix>::init (const FloatComplexMatrix& a, bool upper,
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
956 bool calc_cond)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
957 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
958 octave_idx_type a_nr = a.rows ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
959 octave_idx_type a_nc = a.cols ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
960
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
961 if (a_nr != a_nc)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
962 (*current_liboctave_error_handler) ("chol: requires square matrix");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
963
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
964 F77_INT n = to_f77_int (a_nc);
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
965 F77_INT info;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
966
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
967 is_upper = upper;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
968
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
969 chol_mat.clear (n, n);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
970 if (is_upper)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
971 for (octave_idx_type j = 0; j < n; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
972 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
973 for (octave_idx_type i = 0; i <= j; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
974 chol_mat.xelem (i, j) = a(i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
975 for (octave_idx_type i = j+1; i < n; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
976 chol_mat.xelem (i, j) = 0.0f;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
977 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
978 else
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
979 for (octave_idx_type j = 0; j < n; j++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
980 {
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
981 for (octave_idx_type i = 0; i < j; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
982 chol_mat.xelem (i, j) = 0.0f;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
983 for (octave_idx_type i = j; i < n; i++)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
984 chol_mat.xelem (i, j) = a(i, j);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
985 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
986 FloatComplex *h = chol_mat.fortran_vec ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
987
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
988 // Calculate the norm of the matrix, for later use.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
989 float anorm = 0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
990 if (calc_cond)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
991 anorm = xnorm (a, 1);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
992
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
993 if (is_upper)
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
994 F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1),
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
995 n, F77_CMPLX_ARG (h), n, info
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
996 F77_CHAR_ARG_LEN (1)));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
997 else
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
998 F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 ("L", 1),
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
999 n, F77_CMPLX_ARG (h), n, info
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1000 F77_CHAR_ARG_LEN (1)));
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1001
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1002 xrcond = 0.0;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1003 if (info > 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1004 chol_mat.resize (info - 1, info - 1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1005 else if (calc_cond)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1006 {
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1007 F77_INT cpocon_info = 0;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1008
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1009 // Now calculate the condition number for non-singular matrix.
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1010 Array<FloatComplex> z (dim_vector (2*n, 1));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1011 FloatComplex *pz = z.fortran_vec ();
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1012 Array<float> rz (dim_vector (n, 1));
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1013 float *prz = rz.fortran_vec ();
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1014 F77_XFCN (cpocon, CPOCON, (F77_CONST_CHAR_ARG2 ("U", 1), n,
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1015 F77_CMPLX_ARG (h), n, anorm, xrcond,
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1016 F77_CMPLX_ARG (pz), prz, cpocon_info
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1017 F77_CHAR_ARG_LEN (1)));
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1018
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1019 if (cpocon_info != 0)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1020 info = -1;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1021 }
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1022
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1023 return info;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1024 }
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1025
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1026 #if defined (HAVE_QRUPDATE)
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1027
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1028 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
1029 OCTAVE_API void
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1030 chol<FloatComplexMatrix>::update (const FloatComplexColumnVector& u)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1031 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
1032 F77_INT n = to_f77_int (chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1033
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1034 if (u.numel () != n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1035 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1036
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1037 FloatComplexColumnVector utmp = u;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1038
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1039 OCTAVE_LOCAL_BUFFER (float, rw, n);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1040
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1041 F77_XFCN (cch1up, CCH1UP, (n, F77_CMPLX_ARG (chol_mat.fortran_vec ()),
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1042 n, F77_CMPLX_ARG (utmp.fortran_vec ()), rw));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1043 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1044
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1045 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
1046 OCTAVE_API octave_idx_type
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1047 chol<FloatComplexMatrix>::downdate (const FloatComplexColumnVector& u)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1048 {
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1049 F77_INT info = -1;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1050
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
1051 F77_INT n = to_f77_int (chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1052
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1053 if (u.numel () != n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1054 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1055
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1056 FloatComplexColumnVector utmp = u;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1057
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1058 OCTAVE_LOCAL_BUFFER (float, rw, n);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1059
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1060 F77_XFCN (cch1dn, CCH1DN, (n, F77_CMPLX_ARG (chol_mat.fortran_vec ()),
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1061 n, F77_CMPLX_ARG (utmp.fortran_vec ()),
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1062 rw, info));
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1063
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1064 return info;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1065 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1066
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1067 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
1068 OCTAVE_API octave_idx_type
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1069 chol<FloatComplexMatrix>::insert_sym (const FloatComplexColumnVector& u,
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1070 octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1071 {
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1072 F77_INT info = -1;
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
1073 F77_INT j = to_f77_int (j_arg);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1074
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
1075 F77_INT n = to_f77_int (chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1076
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1077 if (u.numel () != n + 1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1078 (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1079 if (j < 0 || j > n)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1080 (*current_liboctave_error_handler) ("cholinsert: index out of range");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1081
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1082 FloatComplexColumnVector utmp = u;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1083
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1084 OCTAVE_LOCAL_BUFFER (float, rw, n);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1085
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1086 chol_mat.resize (n+1, n+1);
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
1087 F77_INT ldcm = to_f77_int (chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1088
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1089 F77_XFCN (cchinx, CCHINX, (n, F77_CMPLX_ARG (chol_mat.fortran_vec ()),
22969
023026207910 * chol.cc: Fix thinko in previous change.
John W. Eaton <jwe@octave.org>
parents: 22942
diff changeset
1090 ldcm, j + 1,
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1091 F77_CMPLX_ARG (utmp.fortran_vec ()),
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1092 rw, info));
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1093
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1094 return info;
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1095 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1096
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1097 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
1098 OCTAVE_API void
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1099 chol<FloatComplexMatrix>::delete_sym (octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1100 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
1101 F77_INT n = to_f77_int (chol_mat.rows ());
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
1102 F77_INT j = to_f77_int (j_arg);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1103
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1104 if (j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1105 (*current_liboctave_error_handler) ("choldelete: index out of range");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1106
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1107 OCTAVE_LOCAL_BUFFER (float, rw, n);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1108
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1109 F77_XFCN (cchdex, CCHDEX, (n, F77_CMPLX_ARG (chol_mat.fortran_vec ()),
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1110 n, j + 1, rw));
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1111
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1112 chol_mat.resize (n-1, n-1);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1113 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1114
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1115 template <>
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
1116 OCTAVE_API void
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1117 chol<FloatComplexMatrix>::shift_sym (octave_idx_type i_arg,
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1118 octave_idx_type j_arg)
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1119 {
23696
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
1120 F77_INT n = to_f77_int (chol_mat.rows ());
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
1121 F77_INT i = to_f77_int (i_arg);
08036a7f3660 remove octave:: namespace tag from symbols used inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 23593
diff changeset
1122 F77_INT j = to_f77_int (j_arg);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1123
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1124 if (i < 0 || i > n-1 || j < 0 || j > n-1)
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1125 (*current_liboctave_error_handler) ("cholshift: index out of range");
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1126
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1127 OCTAVE_LOCAL_BUFFER (FloatComplex, w, n);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1128 OCTAVE_LOCAL_BUFFER (float, rw, n);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1129
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22329
diff changeset
1130 F77_XFCN (cchshx, CCHSHX, (n, F77_CMPLX_ARG (chol_mat.fortran_vec ()),
22942
7627ebcf194d use F77_INT instead of octave_idx_type for liboctave chol classes
John W. Eaton <jwe@octave.org>
parents: 22927
diff changeset
1131 n, i + 1, j + 1, F77_CMPLX_ARG (w), rw));
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1132 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1133
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1134 #endif
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1135
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1136 // Instantiations we need.
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1137
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1138 template class chol<Matrix>;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1139
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1140 template class chol<FloatMatrix>;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1141
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1142 template class chol<ComplexMatrix>;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1143
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1144 template class chol<FloatComplexMatrix>;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1145
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
1146 template OCTAVE_API Matrix
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1147 chol2inv<Matrix> (const Matrix& r);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1148
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
1149 template OCTAVE_API ComplexMatrix
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1150 chol2inv<ComplexMatrix> (const ComplexMatrix& r);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1151
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
1152 template OCTAVE_API FloatMatrix
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1153 chol2inv<FloatMatrix> (const FloatMatrix& r);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1154
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
1155 template OCTAVE_API FloatComplexMatrix
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1156 chol2inv<FloatComplexMatrix> (const FloatComplexMatrix& r);
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1157 }
22317
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22274
diff changeset
1158 }