annotate liboctave/numeric/CmplxCHOL.cc @ 21202:f7121e111991

maint: indent #ifdef blocks in liboctave and src directories. * Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc, Array-f.cc, Array-fC.cc, Array-i.cc, Array-idx-vec.cc, Array-s.cc, Array-str.cc, Array-util.cc, Array-voidp.cc, Array.cc, CColVector.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc, CRowVector.cc, CSparse.cc, CSparse.h, DiagArray2.cc, MArray-C.cc, MArray-d.cc, MArray-f.cc, MArray-fC.cc, MArray-i.cc, MArray-s.cc, MArray.cc, MDiagArray2.cc, MSparse-C.cc, MSparse-d.cc, MSparse.h, MatrixType.cc, PermMatrix.cc, Range.cc, Sparse-C.cc, Sparse-b.cc, Sparse-d.cc, Sparse.cc, boolMatrix.cc, boolNDArray.cc, boolSparse.cc, chMatrix.cc, chNDArray.cc, dColVector.cc, dDiagMatrix.cc, dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc, dSparse.h, dim-vector.cc, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc, fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc, fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc, int16NDArray.cc, int32NDArray.cc, int64NDArray.cc, int8NDArray.cc, intNDArray.cc, uint16NDArray.cc, uint32NDArray.cc, uint64NDArray.cc, uint8NDArray.cc, blaswrap.c, cquit.c, f77-extern.cc, f77-fcn.c, f77-fcn.h, lo-error.c, quit.cc, quit.h, CmplxAEPBAL.cc, CmplxCHOL.cc, CmplxGEPBAL.cc, CmplxHESS.cc, CmplxLU.cc, CmplxQR.cc, CmplxQRP.cc, CmplxSCHUR.cc, CmplxSVD.cc, CollocWt.cc, DASPK.cc, DASRT.cc, DASSL.cc, EIG.cc, LSODE.cc, ODES.cc, Quad.cc, base-lu.cc, base-qr.cc, dbleAEPBAL.cc, dbleCHOL.cc, dbleGEPBAL.cc, dbleHESS.cc, dbleLU.cc, dbleQR.cc, dbleQRP.cc, dbleSCHUR.cc, dbleSVD.cc, eigs-base.cc, fCmplxAEPBAL.cc, fCmplxCHOL.cc, fCmplxGEPBAL.cc, fCmplxHESS.cc, fCmplxLU.cc, fCmplxQR.cc, fCmplxQRP.cc, fCmplxSCHUR.cc, fCmplxSVD.cc, fEIG.cc, floatAEPBAL.cc, floatCHOL.cc, floatGEPBAL.cc, floatHESS.cc, floatLU.cc, floatQR.cc, floatQRP.cc, floatSCHUR.cc, floatSVD.cc, lo-mappers.cc, lo-specfun.cc, oct-convn.cc, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-rand.cc, oct-spparms.cc, randgamma.c, randmtzig.c, randpoisson.c, sparse-chol.cc, sparse-dmsolve.cc, sparse-lu.cc, sparse-qr.cc, mx-defs.h, dir-ops.cc, file-ops.cc, file-stat.cc, lo-sysdep.cc, mach-info.cc, oct-env.cc, oct-group.cc, oct-openmp.h, oct-passwd.cc, oct-syscalls.cc, oct-time.cc, oct-uname.cc, pathlen.h, sysdir.h, syswait.h, cmd-edit.cc, cmd-hist.cc, data-conv.cc, f2c-main.c, glob-match.cc, lo-array-errwarn.cc, lo-array-gripes.cc, lo-cutils.c, lo-cutils.h, lo-ieee.cc, lo-math.h, lo-regexp.cc, lo-utils.cc, oct-base64.cc, oct-glob.cc, oct-inttypes.cc, oct-inttypes.h, oct-locbuf.cc, oct-mutex.cc, oct-refcount.h, oct-rl-edit.c, oct-rl-hist.c, oct-shlib.cc, oct-sort.cc, pathsearch.cc, singleton-cleanup.cc, sparse-sort.cc, sparse-util.cc, statdefs.h, str-vec.cc, unwind-prot.cc, url-transfer.cc, display-available.h, main-cli.cc, main-gui.cc, main.in.cc, mkoctfile.in.cc, octave-config.in.cc, shared-fcns.h: indent #ifdef blocks in liboctave and src directories.
author Rik <rik@octave.org>
date Sat, 06 Feb 2016 06:40:13 -0800
parents a223cce1daa4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
1 /*
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
2
19697
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 17769
diff changeset
3 Copyright (C) 1994-2015 John W. Eaton
11523
fd0a3ac60b0e update copyright notices
John W. Eaton <jwe@octave.org>
parents: 11518
diff changeset
4 Copyright (C) 2008-2009 Jaroslav Hajek
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
5
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
6 This file is part of Octave.
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
7
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
8 Octave is free software; you can redistribute it and/or modify it
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
9 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6486
diff changeset
10 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6486
diff changeset
11 option) any later version.
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
12
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
13 Octave is distributed in the hope that it will be useful, but WITHOUT
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
16 for more details.
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
17
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
18 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6486
diff changeset
19 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6486
diff changeset
20 <http://www.gnu.org/licenses/>.
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
21
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
22 */
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
23
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
24 #ifdef HAVE_CONFIG_H
21202
f7121e111991 maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents: 21174
diff changeset
25 # include <config.h>
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
26 #endif
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
27
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
28 #include <vector>
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
29
6486
e978a9233cf6 [project @ 2007-04-04 15:16:46 by jwe]
jwe
parents: 5340
diff changeset
30 #include "dMatrix.h"
e978a9233cf6 [project @ 2007-04-04 15:16:46 by jwe]
jwe
parents: 5340
diff changeset
31 #include "dRowVector.h"
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
32 #include "CmplxCHOL.h"
1847
2ffe49eb95a5 [project @ 1996-02-03 12:47:55 by jwe]
jwe
parents: 1368
diff changeset
33 #include "f77-fcn.h"
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
34 #include "lo-error.h"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 7725
diff changeset
35 #include "oct-locbuf.h"
9862
c0aeedd8fb86 improve chol Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 8562
diff changeset
36 #include "oct-norm.h"
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
37 #ifndef HAVE_QRUPDATE
21202
f7121e111991 maint: indent #ifdef blocks in liboctave and src directories.
Rik <rik@octave.org>
parents: 21174
diff changeset
38 # include "dbleQR.h"
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
39 #endif
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
40
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
41 extern "C"
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
42 {
4552
6f3382e08a52 [project @ 2003-10-27 20:38:02 by jwe]
jwe
parents: 4192
diff changeset
43 F77_RET_T
11518
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
44 F77_FUNC (zpotrf, ZPOTRF) (F77_CONST_CHAR_ARG_DECL,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
45 const octave_idx_type&, Complex*,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
46 const octave_idx_type&, octave_idx_type&
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
47 F77_CHAR_ARG_LEN_DECL);
5340
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
48 F77_RET_T
11518
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
49 F77_FUNC (zpotri, ZPOTRI) (F77_CONST_CHAR_ARG_DECL,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
50 const octave_idx_type&, Complex*,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
51 const octave_idx_type&, octave_idx_type&
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
52 F77_CHAR_ARG_LEN_DECL);
6486
e978a9233cf6 [project @ 2007-04-04 15:16:46 by jwe]
jwe
parents: 5340
diff changeset
53
e978a9233cf6 [project @ 2007-04-04 15:16:46 by jwe]
jwe
parents: 5340
diff changeset
54 F77_RET_T
11518
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
55 F77_FUNC (zpocon, ZPOCON) (F77_CONST_CHAR_ARG_DECL,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
56 const octave_idx_type&, Complex*,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
57 const octave_idx_type&, const double&,
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
58 double&, Complex*, double*, octave_idx_type&
141b3fb5cef7 style fixes
John W. Eaton <jwe@octave.org>
parents: 11495
diff changeset
59 F77_CHAR_ARG_LEN_DECL);
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
60 #ifdef HAVE_QRUPDATE
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
61
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
62 F77_RET_T
11495
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
63 F77_FUNC (zch1up, ZCH1UP) (const octave_idx_type&, Complex*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
64 const octave_idx_type&, Complex*, double*);
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
65
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
66 F77_RET_T
11495
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
67 F77_FUNC (zch1dn, ZCH1DN) (const octave_idx_type&, Complex*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
68 const octave_idx_type&, Complex*, double*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
69 octave_idx_type&);
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
70
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
71 F77_RET_T
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
72 F77_FUNC (zchinx, ZCHINX) (const octave_idx_type&, Complex*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
73 const octave_idx_type&, const octave_idx_type&,
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
74 Complex*, double*, octave_idx_type&);
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
75
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
76 F77_RET_T
11495
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
77 F77_FUNC (zchdex, ZCHDEX) (const octave_idx_type&, Complex*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
78 const octave_idx_type&, const octave_idx_type&,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
79 double*);
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
80
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
81 F77_RET_T
11495
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
82 F77_FUNC (zchshx, ZCHSHX) (const octave_idx_type&, Complex*,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
83 const octave_idx_type&, const octave_idx_type&,
8a5e980da6aa style fixes
John W. Eaton <jwe@octave.org>
parents: 10350
diff changeset
84 const octave_idx_type&, Complex*, double*);
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
85 #endif
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
86 }
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
87
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
88 octave_idx_type
20462
5ce959c55cc0 Propagate 'lower' in chol(a, 'lower') to underlying library function.
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
parents: 20232
diff changeset
89 ComplexCHOL::init (const ComplexMatrix& a, bool upper, bool calc_cond)
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
90 {
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
91 octave_idx_type a_nr = a.rows ();
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
92 octave_idx_type a_nc = a.cols ();
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
93
1944
8cb4d3008c76 [project @ 1996-02-14 00:45:04 by jwe]
jwe
parents: 1882
diff changeset
94 if (a_nr != a_nc)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
95 (*current_liboctave_error_handler) ("ComplexCHOL requires square matrix");
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
96
5275
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
97 octave_idx_type n = a_nc;
23b37da9fd5b [project @ 2005-04-08 16:07:35 by jwe]
jwe
parents: 5105
diff changeset
98 octave_idx_type info;
1944
8cb4d3008c76 [project @ 1996-02-14 00:45:04 by jwe]
jwe
parents: 1882
diff changeset
99
20462
5ce959c55cc0 Propagate 'lower' in chol(a, 'lower') to underlying library function.
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
parents: 20232
diff changeset
100 is_upper = upper;
5ce959c55cc0 Propagate 'lower' in chol(a, 'lower') to underlying library function.
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
parents: 20232
diff changeset
101
9862
c0aeedd8fb86 improve chol Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 8562
diff changeset
102 chol_mat.clear (n, n);
20462
5ce959c55cc0 Propagate 'lower' in chol(a, 'lower') to underlying library function.
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
parents: 20232
diff changeset
103 if (is_upper)
20628
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
104 for (octave_idx_type j = 0; j < n; j++)
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
105 {
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
106 for (octave_idx_type i = 0; i <= j; i++)
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
107 chol_mat.xelem (i, j) = a(i, j);
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
108 for (octave_idx_type i = j+1; i < n; i++)
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
109 chol_mat.xelem (i, j) = 0.0;
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
110 }
20462
5ce959c55cc0 Propagate 'lower' in chol(a, 'lower') to underlying library function.
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
parents: 20232
diff changeset
111 else
20628
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
112 for (octave_idx_type j = 0; j < n; j++)
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
113 {
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
114 for (octave_idx_type i = 0; i < j; i++)
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
115 chol_mat.xelem (i, j) = 0.0;
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
116 for (octave_idx_type i = j; i < n; i++)
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
117 chol_mat.xelem (i, j) = a(i, j);
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
118 }
1944
8cb4d3008c76 [project @ 1996-02-14 00:45:04 by jwe]
jwe
parents: 1882
diff changeset
119 Complex *h = chol_mat.fortran_vec ();
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
120
6486
e978a9233cf6 [project @ 2007-04-04 15:16:46 by jwe]
jwe
parents: 5340
diff changeset
121 // Calculate the norm of the matrix, for later use.
e978a9233cf6 [project @ 2007-04-04 15:16:46 by jwe]
jwe
parents: 5340
diff changeset
122 double anorm = 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
123 if (calc_cond)
9862
c0aeedd8fb86 improve chol Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 8562
diff changeset
124 anorm = xnorm (a, 1);
6486
e978a9233cf6 [project @ 2007-04-04 15:16:46 by jwe]
jwe
parents: 5340
diff changeset
125
20462
5ce959c55cc0 Propagate 'lower' in chol(a, 'lower') to underlying library function.
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
parents: 20232
diff changeset
126 if (is_upper)
20628
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
127 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n, h, n, info
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
128 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
129 else
20628
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
130 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 ("L", 1), n, h, n, info
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
131 F77_CHAR_ARG_LEN (1)));
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
132
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
133 xrcond = 0.0;
9862
c0aeedd8fb86 improve chol Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 8562
diff changeset
134 if (info > 0)
c0aeedd8fb86 improve chol Matlab compatibility
Jaroslav Hajek <highegg@gmail.com>
parents: 8562
diff changeset
135 chol_mat.resize (info - 1, info - 1);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
136 else if (calc_cond)
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
137 {
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
138 octave_idx_type zpocon_info = 0;
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
139
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
140 // Now calculate the condition number for non-singular matrix.
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
141 Array<Complex> z (dim_vector (2*n, 1));
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
142 Complex *pz = z.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
143 Array<double> rz (dim_vector (n, 1));
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
144 double *prz = rz.fortran_vec ();
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
145 F77_XFCN (zpocon, ZPOCON, (F77_CONST_CHAR_ARG2 ("U", 1), n, h,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
146 n, anorm, xrcond, pz, prz, zpocon_info
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
147 F77_CHAR_ARG_LEN (1)));
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
148
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
149 if (zpocon_info != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
150 info = -1;
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
151 }
1944
8cb4d3008c76 [project @ 1996-02-14 00:45:04 by jwe]
jwe
parents: 1882
diff changeset
152
8cb4d3008c76 [project @ 1996-02-14 00:45:04 by jwe]
jwe
parents: 1882
diff changeset
153 return info;
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
154 }
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
155
5340
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
156 static ComplexMatrix
20462
5ce959c55cc0 Propagate 'lower' in chol(a, 'lower') to underlying library function.
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
parents: 20232
diff changeset
157 chol2inv_internal (const ComplexMatrix& r, bool is_upper = true)
5340
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
158 {
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
159 ComplexMatrix retval;
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
160
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
161 octave_idx_type r_nr = r.rows ();
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
162 octave_idx_type r_nc = r.cols ();
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
163
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
164 if (r_nr != r_nc)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
165 (*current_liboctave_error_handler) ("chol2inv requires square matrix");
5340
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
166
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
167 octave_idx_type n = r_nc;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
168 octave_idx_type info;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
169
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
170 ComplexMatrix tmp = r;
5340
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
171
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
172 if (is_upper)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
173 F77_XFCN (zpotri, ZPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
174 tmp.fortran_vec (), n, info
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
175 F77_CHAR_ARG_LEN (1)));
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
176 else
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
177 F77_XFCN (zpotri, ZPOTRI, (F77_CONST_CHAR_ARG2 ("L", 1), n,
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
178 tmp.fortran_vec (), n, info
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
179 F77_CHAR_ARG_LEN (1)));
5340
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
180
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
181 // If someone thinks of a more graceful way of doing this (or
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
182 // faster for that matter :-)), please let me know!
5340
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
183
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
184 if (n > 1)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
185 {
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
186 if (is_upper)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
187 for (octave_idx_type j = 0; j < r_nc; j++)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
188 for (octave_idx_type i = j+1; i < r_nr; i++)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
189 tmp.xelem (i, j) = tmp.xelem (j, i);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
190 else
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
191 for (octave_idx_type j = 0; j < r_nc; j++)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
192 for (octave_idx_type i = j+1; i < r_nr; i++)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
193 tmp.xelem (j, i) = tmp.xelem (i, j);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
194 }
5340
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
195
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
196 retval = tmp;
5340
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
197
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
198 return retval;
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
199 }
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
200
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
201 // Compute the inverse of a matrix using the Cholesky factorization.
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
202 ComplexMatrix
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
203 ComplexCHOL::inverse (void) const
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
204 {
20462
5ce959c55cc0 Propagate 'lower' in chol(a, 'lower') to underlying library function.
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
parents: 20232
diff changeset
205 return chol2inv_internal (chol_mat, is_upper);
5340
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
206 }
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
207
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
208 void
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
209 ComplexCHOL::set (const ComplexMatrix& R)
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
210 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
211 if (R.is_square ())
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
212 chol_mat = R;
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
213 else
7559
07522d7dcdf8 fixes to QR and Cholesky updating code
Jaroslav Hajek <highegg@gmail.com>
parents: 7554
diff changeset
214 (*current_liboctave_error_handler) ("CHOL requires square matrix");
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
215 }
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
216
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
217 #ifdef HAVE_QRUPDATE
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
218
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
219 void
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
220 ComplexCHOL::update (const ComplexColumnVector& u)
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
221 {
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
222 octave_idx_type n = chol_mat.rows ();
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
223
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
224 if (u.numel () != n)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
225 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
226
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
227 ComplexColumnVector utmp = u;
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
228
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
229 OCTAVE_LOCAL_BUFFER (double, rw, n);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
230
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
231 F77_XFCN (zch1up, ZCH1UP, (n, chol_mat.fortran_vec (), chol_mat.rows (),
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
232 utmp.fortran_vec (), rw));
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
233 }
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
234
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
235 octave_idx_type
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
236 ComplexCHOL::downdate (const ComplexColumnVector& u)
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
237 {
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
238 octave_idx_type info = -1;
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
239
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
240 octave_idx_type n = chol_mat.rows ();
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
241
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
242 if (u.numel () != n)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
243 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
244
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
245 ComplexColumnVector utmp = u;
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
246
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
247 OCTAVE_LOCAL_BUFFER (double, rw, n);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
248
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
249 F77_XFCN (zch1dn, ZCH1DN, (n, chol_mat.fortran_vec (), chol_mat.rows (),
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
250 utmp.fortran_vec (), rw, info));
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
251
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
252 return info;
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
253 }
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
254
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
255 octave_idx_type
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
256 ComplexCHOL::insert_sym (const ComplexColumnVector& u, octave_idx_type j)
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
257 {
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
258 octave_idx_type info = -1;
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
259
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
260 octave_idx_type n = chol_mat.rows ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
261
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
262 if (u.numel () != n + 1)
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
263 (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
264 if (j < 0 || j > n)
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
265 (*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
266
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
267 ComplexColumnVector utmp = u;
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
268
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
269 OCTAVE_LOCAL_BUFFER (double, rw, n);
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
270
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
271 chol_mat.resize (n+1, n+1);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
272
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
273 F77_XFCN (zchinx, ZCHINX, (n, chol_mat.fortran_vec (), chol_mat.rows (),
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
274 j + 1, utmp.fortran_vec (), rw, info));
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
275
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
276 return info;
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
277 }
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
278
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
279 void
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
280 ComplexCHOL::delete_sym (octave_idx_type j)
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
281 {
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
282 octave_idx_type n = chol_mat.rows ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
283
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
284 if (j < 0 || j > n-1)
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
285 (*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
286
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
287 OCTAVE_LOCAL_BUFFER (double, rw, n);
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
288
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
289 F77_XFCN (zchdex, ZCHDEX, (n, chol_mat.fortran_vec (), chol_mat.rows (),
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
290 j + 1, rw));
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
291
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
292 chol_mat.resize (n-1, n-1);
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
293 }
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
294
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
295 void
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
296 ComplexCHOL::shift_sym (octave_idx_type i, octave_idx_type j)
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
297 {
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
298 octave_idx_type n = chol_mat.rows ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
299
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
300 if (i < 0 || i > n-1 || j < 0 || j > n-1)
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
301 (*current_liboctave_error_handler) ("cholshift: index out of range");
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
302
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
303 OCTAVE_LOCAL_BUFFER (Complex, w, n);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
304 OCTAVE_LOCAL_BUFFER (double, rw, n);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
305
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
306 F77_XFCN (zchshx, ZCHSHX, (n, chol_mat.fortran_vec (), chol_mat.rows (),
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
307 i + 1, j + 1, w, rw));
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
308 }
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
309
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
310 #else
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
311
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
312 void
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
313 ComplexCHOL::update (const ComplexColumnVector& u)
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
314 {
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
315 warn_qrupdate_once ();
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
316
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
317 octave_idx_type n = chol_mat.rows ();
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
318
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
319 if (u.numel () != n)
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
320 (*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
321
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
322 init (chol_mat.hermitian () * chol_mat
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
323 + ComplexMatrix (u) * ComplexMatrix (u).hermitian (), true, false);
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
324 }
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
325
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
326 static bool
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
327 singular (const ComplexMatrix& a)
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
328 {
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
329 for (octave_idx_type i = 0; i < a.rows (); i++)
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
330 if (a(i,i) == 0.0) return true;
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
331 return false;
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
332 }
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
333
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
334 octave_idx_type
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
335 ComplexCHOL::downdate (const ComplexColumnVector& u)
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
336 {
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
337 warn_qrupdate_once ();
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
338
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
339 octave_idx_type info = -1;
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
340
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
341 octave_idx_type n = chol_mat.rows ();
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
342
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
343 if (u.numel () != n)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
344 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
345
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
346 if (singular (chol_mat))
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
347 info = 2;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
348 else
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
349 {
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
350 info = init (chol_mat.hermitian () * chol_mat
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
351 - ComplexMatrix (u) * ComplexMatrix (u).hermitian (),
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
352 true, false);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
353 if (info) info = 1;
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
354 }
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
355
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
356 return info;
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
357 }
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
358
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
359 octave_idx_type
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
360 ComplexCHOL::insert_sym (const ComplexColumnVector& u, octave_idx_type j)
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
361 {
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
362 warn_qrupdate_once ();
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
363
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
364 octave_idx_type info = -1;
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
365
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
366 octave_idx_type n = chol_mat.rows ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
367
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 19697
diff changeset
368 if (u.numel () != n + 1)
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
369 (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
370 if (j < 0 || j > n)
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
371 (*current_liboctave_error_handler) ("cholinsert: index out of range");
21174
a223cce1daa4 strip trailing space from source files we maintain
John W. Eaton <jwe@octave.org>
parents: 21136
diff changeset
372
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
373 if (singular (chol_mat))
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
374 info = 2;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
375 else if (u(j).imag () != 0.0)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
376 info = 3;
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
377 else
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
378 {
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
379 ComplexMatrix a = chol_mat.hermitian () * chol_mat;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
380 ComplexMatrix a1 (n+1, n+1);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
381 for (octave_idx_type k = 0; k < n+1; k++)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
382 for (octave_idx_type l = 0; l < n+1; l++)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
383 {
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
384 if (l == j)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
385 a1(k, l) = u(k);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
386 else if (k == j)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
387 a1(k, l) = std::conj (u(l));
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
388 else
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
389 a1(k, l) = a(k < j ? k : k-1, l < j ? l : l-1);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
390 }
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
391 info = init (a1, true, false);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
392 if (info) info = 1;
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
393 }
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
394
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
395 return info;
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
396 }
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
397
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
398 void
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
399 ComplexCHOL::delete_sym (octave_idx_type j)
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
400 {
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
401 warn_qrupdate_once ();
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
402
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
403 octave_idx_type n = chol_mat.rows ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
404
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
405 if (j < 0 || j > n-1)
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
406 (*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
407
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
408 ComplexMatrix a = chol_mat.hermitian () * chol_mat;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
409 a.delete_elements (1, idx_vector (j));
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
410 a.delete_elements (0, idx_vector (j));
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
411 init (a, true, false);
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
412 }
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
413
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
414 void
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
415 ComplexCHOL::shift_sym (octave_idx_type i, octave_idx_type j)
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
416 {
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
417 warn_qrupdate_once ();
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
418
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
419 octave_idx_type n = chol_mat.rows ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
420
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
421 if (i < 0 || i > n-1 || j < 0 || j > n-1)
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
422 (*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
423
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
424 ComplexMatrix a = chol_mat.hermitian () * chol_mat;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
425 Array<octave_idx_type> p (dim_vector (n, 1));
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
426 for (octave_idx_type k = 0; k < n; k++) p(k) = k;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
427 if (i < j)
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
428 {
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
429 for (octave_idx_type k = i; k < j; k++) p(k) = k+1;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
430 p(j) = i;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
431 }
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
432 else if (j < i)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
433 {
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
434 p(j) = i;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
435 for (octave_idx_type k = j+1; k < i+1; k++) p(k) = k-1;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
436 }
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
437
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20629
diff changeset
438 init (a.index (idx_vector (p), idx_vector (p)), true, false);
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
439 }
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
440
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
441 #endif
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
442
5340
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
443 ComplexMatrix
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
444 chol2inv (const ComplexMatrix& r)
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
445 {
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
446 return chol2inv_internal (r);
15843d76156d [project @ 2005-05-06 16:26:58 by jwe]
jwe
parents: 5307
diff changeset
447 }