annotate liboctave/numeric/chol.cc @ 31607:aac27ad79be6 stable

maint: Re-indent code after switch to using namespace macros. * build-env.h, build-env.in.cc, Cell.h, __betainc__.cc, __eigs__.cc, __ftp__.cc, __ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __magick_read__.cc, __pchip_deriv__.cc, amd.cc, base-text-renderer.cc, base-text-renderer.h, besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc, dasrt.cc, data.cc, debug.cc, defaults.cc, defaults.h, det.cc, display.cc, display.h, dlmread.cc, dynamic-ld.cc, dynamic-ld.h, ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h, event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, fft.cc, fft2.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, gsvd.cc, gtk-manager.cc, gtk-manager.h, help.cc, help.h, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, inv.cc, jsondecode.cc, jsonencode.cc, latex-text-renderer.cc, latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-hdf5.cc, ls-mat4.cc, ls-mat5.cc, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex.cc, mexproto.h, mxarray.h, mxtypes.in.h, oct-errno.in.cc, oct-hdf5-types.cc, oct-hist.cc, oct-hist.h, oct-map.cc, oct-map.h, oct-opengl.h, oct-prcstrm.h, oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.h, octave-default-image.h, ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-output.cc, psi.cc, qr.cc, quadcc.cc, rand.cc, regexp.cc, settings.cc, settings.h, sighandlers.cc, sighandlers.h, sparse-xpow.cc, sqrtm.cc, stack-frame.cc, stack-frame.h, stream-euler.cc, strfns.cc, svd.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, sysdep.cc, sysdep.h, text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, typecast.cc, url-handle-manager.cc, url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, xdiv.cc, __delaunayn__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audioread.cc, convhulln.cc, gzip.cc, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc, cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h, cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h, cdef-utils.cc, cdef-utils.h, ov-base-diag.cc, ov-base-int.cc, ov-base-mat.cc, ov-base-mat.h, ov-base-scalar.cc, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-bool-mat.h, ov-bool-sparse.cc, ov-bool.cc, ov-builtin.h, ov-cell.cc, ov-ch-mat.cc, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-complex.cc, ov-cx-diag.cc, ov-cx-mat.cc, ov-cx-sparse.cc, ov-dld-fcn.cc, ov-dld-fcn.h, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h, ov-float.cc, ov-flt-complex.cc, ov-flt-cx-diag.cc, ov-flt-cx-mat.cc, ov-flt-re-diag.cc, ov-flt-re-mat.cc, ov-flt-re-mat.h, ov-intx.h, ov-java.cc, ov-lazy-idx.cc, ov-legacy-range.cc, ov-magic-int.cc, ov-mex-fcn.cc, ov-mex-fcn.h, ov-null-mat.cc, ov-perm.cc, ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-mat.h, ov-re-sparse.cc, ov-scalar.cc, ov-str-mat.cc, ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, ovl.h, octave.cc, octave.h, op-b-sbm.cc, op-bm-sbm.cc, op-cs-scm.cc, op-fm-fcm.cc, op-fs-fcm.cc, op-s-scm.cc, op-scm-cs.cc, op-scm-s.cc, op-sm-cs.cc, ops.h, anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, filepos.h, lex.h, oct-lvalue.cc, oct-lvalue.h, parse.h, profiler.cc, profiler.h, pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h, pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-walk.cc, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h, range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc, chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h, base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h, file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc, lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h, oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h, oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h: Re-indent code after switch to using namespace macros.
author Rik <rik@octave.org>
date Thu, 01 Dec 2022 18:02:15 -0800
parents e88a07dec498
children 597f3ee61a48
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 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30394
diff changeset
3 // Copyright (C) 1994-2022 The Octave Project Developers
27923
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
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30564
diff changeset
50 OCTAVE_BEGIN_NAMESPACE(octave)
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30564
diff changeset
51
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
52 static Matrix
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
53 chol2inv_internal (const Matrix& r, bool is_upper = true)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
54 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
55 Matrix retval;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
56
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
57 octave_idx_type r_nr = r.rows ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
58 octave_idx_type r_nc = r.cols ();
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
59
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
60 if (r_nr != r_nc)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
61 (*current_liboctave_error_handler) ("chol2inv requires square matrix");
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
62
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
63 F77_INT n = to_f77_int (r_nc);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
64 F77_INT info;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
65
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
66 Matrix tmp = r;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
67 double *v = tmp.fortran_vec ();
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
68
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
69 if (is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
70 F77_XFCN (dpotri, DPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
71 v, n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
72 F77_CHAR_ARG_LEN (1)));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
73 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
74 F77_XFCN (dpotri, DPOTRI, (F77_CONST_CHAR_ARG2 ("L", 1), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
75 v, n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
76 F77_CHAR_ARG_LEN (1)));
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
77
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
78 // FIXME: Should we check info exit value and possibly report an error?
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
79
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
80 // If someone thinks of a more graceful way of doing this
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
81 // (or faster for that matter :-)), please let me know!
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
82
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
83 if (n > 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
84 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
85 if (is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
86 for (octave_idx_type j = 0; j < r_nc; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
87 for (octave_idx_type i = j+1; i < r_nr; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
88 tmp.xelem (i, j) = tmp.xelem (j, i);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
89 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
90 for (octave_idx_type j = 0; j < r_nc; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
91 for (octave_idx_type i = j+1; i < r_nr; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
92 tmp.xelem (j, i) = tmp.xelem (i, j);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
93 }
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
94
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
95 retval = tmp;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
96
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
97 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
98 }
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
99
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
100 static FloatMatrix
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
101 chol2inv_internal (const FloatMatrix& r, bool is_upper = true)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
102 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
103 FloatMatrix retval;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
104
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
105 octave_idx_type r_nr = r.rows ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
106 octave_idx_type r_nc = r.cols ();
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
107
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
108 if (r_nr != r_nc)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
109 (*current_liboctave_error_handler) ("chol2inv requires square matrix");
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
110
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
111 F77_INT n = to_f77_int (r_nc);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
112 F77_INT info;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
113
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
114 FloatMatrix tmp = r;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
115 float *v = tmp.fortran_vec ();
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
116
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
117 if (is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
118 F77_XFCN (spotri, SPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
119 v, n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
120 F77_CHAR_ARG_LEN (1)));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
121 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
122 F77_XFCN (spotri, SPOTRI, (F77_CONST_CHAR_ARG2 ("L", 1), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
123 v, n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
124 F77_CHAR_ARG_LEN (1)));
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
125
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
126 // FIXME: Should we check info exit value and possibly report an error?
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
127
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
128 // If someone thinks of a more graceful way of doing this (or
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
129 // faster for that matter :-)), please let me know!
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
130
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
131 if (n > 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
132 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
133 if (is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
134 for (octave_idx_type j = 0; j < r_nc; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
135 for (octave_idx_type i = j+1; i < r_nr; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
136 tmp.xelem (i, j) = tmp.xelem (j, i);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
137 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
138 for (octave_idx_type j = 0; j < r_nc; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
139 for (octave_idx_type i = j+1; i < r_nr; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
140 tmp.xelem (j, i) = tmp.xelem (i, j);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
141 }
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
142
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
143 retval = tmp;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
144
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
145 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
146 }
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
147
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
148 static ComplexMatrix
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
149 chol2inv_internal (const ComplexMatrix& r, bool is_upper = true)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
150 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
151 ComplexMatrix retval;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
152
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
153 octave_idx_type r_nr = r.rows ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
154 octave_idx_type r_nc = r.cols ();
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
155
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
156 if (r_nr != r_nc)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
157 (*current_liboctave_error_handler) ("chol2inv requires square matrix");
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
158
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
159 F77_INT n = to_f77_int (r_nc);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
160 F77_INT info;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
161
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
162 ComplexMatrix tmp = r;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
163
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
164 if (is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
165 F77_XFCN (zpotri, ZPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
166 F77_DBLE_CMPLX_ARG (tmp.fortran_vec ()), n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
167 F77_CHAR_ARG_LEN (1)));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
168 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
169 F77_XFCN (zpotri, ZPOTRI, (F77_CONST_CHAR_ARG2 ("L", 1), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
170 F77_DBLE_CMPLX_ARG (tmp.fortran_vec ()), n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
171 F77_CHAR_ARG_LEN (1)));
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
172
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
173 // If someone thinks of a more graceful way of doing this (or
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
174 // faster for that matter :-)), please let me know!
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
175
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
176 if (n > 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
177 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
178 if (is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
179 for (octave_idx_type j = 0; j < r_nc; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
180 for (octave_idx_type i = j+1; i < r_nr; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
181 tmp.xelem (i, j) = std::conj (tmp.xelem (j, i));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
182 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
183 for (octave_idx_type j = 0; j < r_nc; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
184 for (octave_idx_type i = j+1; i < r_nr; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
185 tmp.xelem (j, i) = std::conj (tmp.xelem (i, j));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
186 }
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
187
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
188 retval = tmp;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
189
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
190 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
191 }
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
192
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
193 static FloatComplexMatrix
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
194 chol2inv_internal (const FloatComplexMatrix& r, bool is_upper = true)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
195 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
196 FloatComplexMatrix retval;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
197
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
198 octave_idx_type r_nr = r.rows ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
199 octave_idx_type r_nc = r.cols ();
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
200
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
201 if (r_nr != r_nc)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
202 (*current_liboctave_error_handler) ("chol2inv requires square matrix");
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
203
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
204 F77_INT n = to_f77_int (r_nc);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
205 F77_INT info;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
206
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
207 FloatComplexMatrix tmp = r;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
208
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
209 if (is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
210 F77_XFCN (cpotri, CPOTRI, (F77_CONST_CHAR_ARG2 ("U", 1), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
211 F77_CMPLX_ARG (tmp.fortran_vec ()), n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
212 F77_CHAR_ARG_LEN (1)));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
213 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
214 F77_XFCN (cpotri, CPOTRI, (F77_CONST_CHAR_ARG2 ("L", 1), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
215 F77_CMPLX_ARG (tmp.fortran_vec ()), n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
216 F77_CHAR_ARG_LEN (1)));
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
217
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
218 // If someone thinks of a more graceful way of doing this (or
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
219 // faster for that matter :-)), please let me know!
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
220
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
221 if (n > 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
222 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
223 if (is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
224 for (octave_idx_type j = 0; j < r_nc; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
225 for (octave_idx_type i = j+1; i < r_nr; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
226 tmp.xelem (i, j) = std::conj (tmp.xelem (j, i));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
227 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
228 for (octave_idx_type j = 0; j < r_nc; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
229 for (octave_idx_type i = j+1; i < r_nr; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
230 tmp.xelem (j, i) = std::conj (tmp.xelem (i, j));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
231 }
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
232
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
233 retval = tmp;
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
234
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
235 return retval;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
236 }
27101
097774bed4ed move some static functions inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 26385
diff changeset
237
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30564
diff changeset
238 OCTAVE_BEGIN_NAMESPACE(math)
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30564
diff changeset
239
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
240 template <typename T>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
241 T
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
242 chol2inv (const T& r)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
243 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
244 return chol2inv_internal (r);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
245 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
246
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
247 // Compute the inverse of a matrix using the Cholesky factorization.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
248 template <typename T>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
249 T
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
250 chol<T>::inverse (void) const
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
251 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
252 return chol2inv_internal (m_chol_mat, m_is_upper);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
253 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
254
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
255 template <typename T>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
256 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
257 chol<T>::set (const T& R)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
258 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
259 if (! R.issquare ())
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
262 m_chol_mat = R;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
267 template <typename T>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
268 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
269 chol<T>::update (const VT& u)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
270 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
273 octave_idx_type n = m_chol_mat.rows ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
274
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
275 if (u.numel () != n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
276 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
277
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
278 init (m_chol_mat.hermitian () * m_chol_mat + T (u) * T (u).hermitian (),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
279 true, false);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
280 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
281
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
282 template <typename T>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
283 bool
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
284 singular (const T& a)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
285 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
286 static typename T::element_type zero (0);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
287 for (octave_idx_type i = 0; i < a.rows (); i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
288 if (a(i, i) == zero) return true;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
289 return false;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
290 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
291
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
292 template <typename T>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
293 octave_idx_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
294 chol<T>::downdate (const VT& u)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
295 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
296 warn_qrupdate_once ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
297
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
300 octave_idx_type n = m_chol_mat.rows ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
301
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
302 if (u.numel () != n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
303 (*current_liboctave_error_handler) ("cholupdate: dimension mismatch");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
304
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
305 if (singular (m_chol_mat))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
306 info = 2;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
307 else
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
308 {
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
309 info = init (m_chol_mat.hermitian () * m_chol_mat
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
310 - T (u) * T (u).hermitian (), true, false);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
311 if (info) info = 1;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
312 }
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
313
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
314 return info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
315 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
316
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
317 template <typename T>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
318 octave_idx_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
319 chol<T>::insert_sym (const VT& u, octave_idx_type j)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
320 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
327 octave_idx_type n = m_chol_mat.rows ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
328
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
329 if (u.numel () != n + 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
330 (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
331 if (j < 0 || j > n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
334 if (singular (m_chol_mat))
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
335 info = 2;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
336 else if (std::imag (u(j)) != zero)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
337 info = 3;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
338 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
339 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
340 T a = m_chol_mat.hermitian () * m_chol_mat;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
341 T a1 (n+1, n+1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
342 for (octave_idx_type k = 0; k < n+1; k++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
343 for (octave_idx_type l = 0; l < n+1; l++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
344 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
345 if (l == j)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
346 a1(k, l) = u(k);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
347 else if (k == j)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
348 a1(k, l) = math::conj (u(l));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
349 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
350 a1(k, l) = a(k < j ? k : k-1, l < j ? l : l-1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
351 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
352 info = init (a1, true, false);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
353 if (info) info = 1;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
354 }
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
355
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
356 return info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
357 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
358
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
359 template <typename T>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
360 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
361 chol<T>::delete_sym (octave_idx_type j)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
362 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
365 octave_idx_type n = m_chol_mat.rows ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
366
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
367 if (j < 0 || j > n-1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
368 (*current_liboctave_error_handler) ("choldelete: index out of range");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
369
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
370 T a = m_chol_mat.hermitian () * m_chol_mat;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
371 a.delete_elements (1, idx_vector (j));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
372 a.delete_elements (0, idx_vector (j));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
373 init (a, true, false);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
374 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
375
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
376 template <typename T>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
377 void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
378 chol<T>::shift_sym (octave_idx_type i, octave_idx_type j)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
379 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
380 warn_qrupdate_once ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
381
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
382 octave_idx_type n = m_chol_mat.rows ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
383
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
384 if (i < 0 || i > n-1 || j < 0 || j > n-1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
385 (*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
386
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
387 T a = m_chol_mat.hermitian () * m_chol_mat;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
388 Array<octave_idx_type> p (dim_vector (n, 1));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
389 for (octave_idx_type k = 0; k < n; k++) p(k) = k;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
390 if (i < j)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
391 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
392 for (octave_idx_type k = i; k < j; k++) p(k) = k+1;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
393 p(j) = i;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
394 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
395 else if (j < i)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
396 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
397 p(j) = i;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
398 for (octave_idx_type k = j+1; k < i+1; k++) p(k) = k-1;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
399 }
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
400
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
401 init (a.index (idx_vector (p), idx_vector (p)), true, false);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
406 // Specializations.
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
407
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
408 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
409 OCTAVE_API octave_idx_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
410 chol<Matrix>::init (const Matrix& a, bool upper, bool calc_cond)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
411 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
412 octave_idx_type a_nr = a.rows ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
413 octave_idx_type a_nc = a.cols ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
414
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
415 if (a_nr != a_nc)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
416 (*current_liboctave_error_handler) ("chol: requires square matrix");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
417
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
418 F77_INT n = to_f77_int (a_nc);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
419 F77_INT info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
420
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
421 m_is_upper = upper;
1944
8cb4d3008c76 [project @ 1996-02-14 00:45:04 by jwe]
jwe
parents: 1882
diff changeset
422
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
423 m_chol_mat.clear (n, n);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
424 if (m_is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
425 for (octave_idx_type j = 0; j < n; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
426 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
427 for (octave_idx_type i = 0; i <= j; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
428 m_chol_mat.xelem (i, j) = a(i, j);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
429 for (octave_idx_type i = j+1; i < n; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
430 m_chol_mat.xelem (i, j) = 0.0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
431 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
432 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
433 for (octave_idx_type j = 0; j < n; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
434 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
435 for (octave_idx_type i = 0; i < j; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
436 m_chol_mat.xelem (i, j) = 0.0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
437 for (octave_idx_type i = j; i < n; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
438 m_chol_mat.xelem (i, j) = a(i, j);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
439 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
440 double *h = m_chol_mat.fortran_vec ();
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
441
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
442 // Calculate the norm of the matrix, for later use.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
443 double anorm = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
444 if (calc_cond)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
445 anorm = octave::xnorm (a, 1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
446
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
447 if (m_is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
448 F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n, h, n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
449 F77_CHAR_ARG_LEN (1)));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
450 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
451 F77_XFCN (dpotrf, DPOTRF, (F77_CONST_CHAR_ARG2 ("L", 1), n, h, n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
452 F77_CHAR_ARG_LEN (1)));
457
3d4b4f0fa5ba [project @ 1994-06-06 00:33:33 by jwe]
jwe
parents:
diff changeset
453
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
454 m_rcond = 0.0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
455 if (info > 0)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
456 m_chol_mat.resize (info - 1, info - 1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
457 else if (calc_cond)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
458 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
459 F77_INT dpocon_info = 0;
20462
5ce959c55cc0 Propagate 'lower' in chol(a, 'lower') to underlying library function.
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
parents: 20232
diff changeset
460
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
461 // Now calculate the condition number for non-singular matrix.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
462 Array<double> z (dim_vector (3*n, 1));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
463 double *pz = z.fortran_vec ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
464 OCTAVE_LOCAL_BUFFER (F77_INT, iz, n);
30032
e156fce82e00 maint: use "m_" prefix for member variables for chol class.
Rik <rik@octave.org>
parents: 29874
diff changeset
465 if (m_is_upper)
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
466 F77_XFCN (dpocon, DPOCON, (F77_CONST_CHAR_ARG2 ("U", 1), n, h,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
467 n, anorm, m_rcond, pz, iz, dpocon_info
20628
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
468 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
469 else
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
470 F77_XFCN (dpocon, DPOCON, (F77_CONST_CHAR_ARG2 ("L", 1), n, h,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
471 n, anorm, m_rcond, pz, iz, dpocon_info
20628
48fedd8fbff7 maint: Apply Octave coding style to Cholesky classes
Mike Miller <mtmiller@octave.org>
parents: 20531
diff changeset
472 F77_CHAR_ARG_LEN (1)));
7482
29980c6b8604 don't check f77_exception_encountered
John W. Eaton <jwe@octave.org>
parents: 7017
diff changeset
473
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
474 if (dpocon_info != 0)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
475 info = -1;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
476 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
477
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
478 return info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
483 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
484 OCTAVE_API void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
485 chol<Matrix>::update (const ColumnVector& u)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
486 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
487 F77_INT n = to_f77_int (m_chol_mat.rows ());
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
488
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
489 if (u.numel () != n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
492 ColumnVector utmp = u;
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
493
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
496 F77_XFCN (dch1up, DCH1UP, (n, m_chol_mat.fortran_vec (), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
497 utmp.fortran_vec (), w));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
498 }
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
499
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
500 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
501 OCTAVE_API octave_idx_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
502 chol<Matrix>::downdate (const ColumnVector& u)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
503 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
504 F77_INT info = -1;
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
505
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
506 F77_INT n = to_f77_int (m_chol_mat.rows ());
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
507
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
508 if (u.numel () != n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
511 ColumnVector utmp = u;
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
512
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
515 F77_XFCN (dch1dn, DCH1DN, (n, m_chol_mat.fortran_vec (), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
516 utmp.fortran_vec (), w, info));
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
517
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
518 return info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
519 }
7554
40574114c514 implement Cholesky factorization updating
Jaroslav Hajek <highegg@gmail.com>
parents: 7482
diff changeset
520
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
521 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
522 OCTAVE_API octave_idx_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
523 chol<Matrix>::insert_sym (const ColumnVector& u, octave_idx_type j_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
524 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
525 F77_INT info = -1;
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
526
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
527 F77_INT n = to_f77_int (m_chol_mat.rows ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
530 if (u.numel () != n + 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
531 (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
532 if (j < 0 || j > n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
535 ColumnVector utmp = u;
8547
d66c9b6e506a imported patch qrupdate.diff
Jaroslav Hajek <highegg@gmail.com>
parents: 8377
diff changeset
536
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
539 m_chol_mat.resize (n+1, n+1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
540 F77_INT ldcm = to_f77_int (m_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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
542 F77_XFCN (dchinx, DCHINX, (n, m_chol_mat.fortran_vec (), ldcm,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
545 return info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
546 }
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
547
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
548 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
549 OCTAVE_API void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
550 chol<Matrix>::delete_sym (octave_idx_type j_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
551 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
552 F77_INT n = to_f77_int (m_chol_mat.rows ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
555 if (j < 0 || j > n-1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
560 F77_XFCN (dchdex, DCHDEX, (n, m_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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
562 m_chol_mat.resize (n-1, n-1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
563 }
7700
efccca5f2ad7 more QR & Cholesky updating functions
Jaroslav Hajek <highegg@gmail.com>
parents: 7559
diff changeset
564
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
565 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
566 OCTAVE_API void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
567 chol<Matrix>::shift_sym (octave_idx_type i_arg, octave_idx_type j_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
568 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
569 F77_INT n = to_f77_int (m_chol_mat.rows ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
570 F77_INT i = to_f77_int (i_arg);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
573 if (i < 0 || i > n-1 || j < 0 || j > n-1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
578 F77_XFCN (dchshx, DCHSHX, (n, m_chol_mat.fortran_vec (), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
579 i + 1, j + 1, w));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
584 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
585 OCTAVE_API octave_idx_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
586 chol<FloatMatrix>::init (const FloatMatrix& a, bool upper, bool calc_cond)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
587 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
588 octave_idx_type a_nr = a.rows ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
589 octave_idx_type a_nc = a.cols ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
590
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
591 if (a_nr != a_nc)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
592 (*current_liboctave_error_handler) ("chol: requires square matrix");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
593
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
594 F77_INT n = to_f77_int (a_nc);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
595 F77_INT info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
596
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
597 m_is_upper = upper;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
598
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
599 m_chol_mat.clear (n, n);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
600 if (m_is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
601 for (octave_idx_type j = 0; j < n; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
602 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
603 for (octave_idx_type i = 0; i <= j; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
604 m_chol_mat.xelem (i, j) = a(i, j);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
605 for (octave_idx_type i = j+1; i < n; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
606 m_chol_mat.xelem (i, j) = 0.0f;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
607 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
608 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
609 for (octave_idx_type j = 0; j < n; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
610 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
611 for (octave_idx_type i = 0; i < j; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
612 m_chol_mat.xelem (i, j) = 0.0f;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
613 for (octave_idx_type i = j; i < n; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
614 m_chol_mat.xelem (i, j) = a(i, j);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
615 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
616 float *h = m_chol_mat.fortran_vec ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
617
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
618 // Calculate the norm of the matrix, for later use.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
619 float anorm = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
620 if (calc_cond)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
621 anorm = octave::xnorm (a, 1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
622
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
623 if (m_is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
624 F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n, h, n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
625 F77_CHAR_ARG_LEN (1)));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
626 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
627 F77_XFCN (spotrf, SPOTRF, (F77_CONST_CHAR_ARG2 ("L", 1), n, h, n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
628 F77_CHAR_ARG_LEN (1)));
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
629
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
630 m_rcond = 0.0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
631 if (info > 0)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
632 m_chol_mat.resize (info - 1, info - 1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
633 else if (calc_cond)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
634 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
635 F77_INT spocon_info = 0;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
636
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
637 // Now calculate the condition number for non-singular matrix.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
638 Array<float> z (dim_vector (3*n, 1));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
639 float *pz = z.fortran_vec ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
640 OCTAVE_LOCAL_BUFFER (F77_INT, iz, n);
30032
e156fce82e00 maint: use "m_" prefix for member variables for chol class.
Rik <rik@octave.org>
parents: 29874
diff changeset
641 if (m_is_upper)
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
642 F77_XFCN (spocon, SPOCON, (F77_CONST_CHAR_ARG2 ("U", 1), n, h,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
643 n, anorm, m_rcond, pz, iz, spocon_info
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
644 F77_CHAR_ARG_LEN (1)));
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
645 else
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
646 F77_XFCN (spocon, SPOCON, (F77_CONST_CHAR_ARG2 ("L", 1), n, h,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
647 n, anorm, m_rcond, pz, iz, spocon_info
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
648 F77_CHAR_ARG_LEN (1)));
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
649
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
650 if (spocon_info != 0)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
651 info = -1;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
652 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
653
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
654 return info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
655 }
21269
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
659 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
660 OCTAVE_API void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
661 chol<FloatMatrix>::update (const FloatColumnVector& u)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
662 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
663 F77_INT n = to_f77_int (m_chol_mat.rows ());
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
664
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
665 if (u.numel () != n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
672 F77_XFCN (sch1up, SCH1UP, (n, m_chol_mat.fortran_vec (), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
673 utmp.fortran_vec (), w));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
674 }
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
675
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
676 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
677 OCTAVE_API octave_idx_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
678 chol<FloatMatrix>::downdate (const FloatColumnVector& u)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
679 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
682 F77_INT n = to_f77_int (m_chol_mat.rows ());
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
683
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
684 if (u.numel () != n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
691 F77_XFCN (sch1dn, SCH1DN, (n, m_chol_mat.fortran_vec (), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
694 return info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
695 }
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
696
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
697 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
698 OCTAVE_API octave_idx_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
699 chol<FloatMatrix>::insert_sym (const FloatColumnVector& u,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
700 octave_idx_type j_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
701 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
704 F77_INT n = to_f77_int (m_chol_mat.rows ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
707 if (u.numel () != n + 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
708 (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
709 if (j < 0 || j > n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
716 m_chol_mat.resize (n+1, n+1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
717 F77_INT ldcm = to_f77_int (m_chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
718
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
719 F77_XFCN (schinx, SCHINX, (n, m_chol_mat.fortran_vec (), ldcm,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
722 return info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
723 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
724
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
725 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
726 OCTAVE_API void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
727 chol<FloatMatrix>::delete_sym (octave_idx_type j_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
728 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
729 F77_INT n = to_f77_int (m_chol_mat.rows ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
732 if (j < 0 || j > n-1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
737 F77_XFCN (schdex, SCHDEX, (n, m_chol_mat.fortran_vec (), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
740 m_chol_mat.resize (n-1, n-1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
741 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
742
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
743 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
744 OCTAVE_API void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
745 chol<FloatMatrix>::shift_sym (octave_idx_type i_arg, octave_idx_type j_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
746 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
747 F77_INT n = to_f77_int (m_chol_mat.rows ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
748 F77_INT i = to_f77_int (i_arg);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
751 if (i < 0 || i > n-1 || j < 0 || j > n-1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
756 F77_XFCN (schshx, SCHSHX, (n, m_chol_mat.fortran_vec (), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
757 i + 1, j + 1, w));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
762 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
763 OCTAVE_API octave_idx_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
764 chol<ComplexMatrix>::init (const ComplexMatrix& a, bool upper, bool calc_cond)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
765 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
766 octave_idx_type a_nr = a.rows ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
769 if (a_nr != a_nc)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
772 F77_INT n = to_f77_int (a_nc);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
775 m_is_upper = upper;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
776
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
777 m_chol_mat.clear (n, n);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
778 if (m_is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
779 for (octave_idx_type j = 0; j < n; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
780 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
781 for (octave_idx_type i = 0; i <= j; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
782 m_chol_mat.xelem (i, j) = a(i, j);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
783 for (octave_idx_type i = j+1; i < n; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
784 m_chol_mat.xelem (i, j) = 0.0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
785 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
786 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
787 for (octave_idx_type j = 0; j < n; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
788 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
789 for (octave_idx_type i = 0; i < j; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
790 m_chol_mat.xelem (i, j) = 0.0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
791 for (octave_idx_type i = j; i < n; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
792 m_chol_mat.xelem (i, j) = a(i, j);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
793 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
794 Complex *h = m_chol_mat.fortran_vec ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
795
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
796 // Calculate the norm of the matrix, for later use.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
797 double anorm = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
798 if (calc_cond)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
799 anorm = octave::xnorm (a, 1);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
800
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
801 if (m_is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
802 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
803 F77_DBLE_CMPLX_ARG (h), n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
804 F77_CHAR_ARG_LEN (1)));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
805 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
806 F77_XFCN (zpotrf, ZPOTRF, (F77_CONST_CHAR_ARG2 ("L", 1), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
807 F77_DBLE_CMPLX_ARG (h), n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
810 m_rcond = 0.0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
811 if (info > 0)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
812 m_chol_mat.resize (info - 1, info - 1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
813 else if (calc_cond)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
814 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
817 // Now calculate the condition number for non-singular matrix.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
818 Array<Complex> z (dim_vector (2*n, 1));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
819 Complex *pz = z.fortran_vec ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
820 Array<double> rz (dim_vector (n, 1));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
821 double *prz = rz.fortran_vec ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
822 F77_XFCN (zpocon, ZPOCON, (F77_CONST_CHAR_ARG2 ("U", 1), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
823 F77_DBLE_CMPLX_ARG (h), n, anorm, m_rcond,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
824 F77_DBLE_CMPLX_ARG (pz), prz, zpocon_info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
827 if (zpocon_info != 0)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
828 info = -1;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
829 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
830
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
831 return info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
832 }
8562
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
836 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
837 OCTAVE_API void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
838 chol<ComplexMatrix>::update (const ComplexColumnVector& u)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
839 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
840 F77_INT n = to_f77_int (m_chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
841
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
842 if (u.numel () != n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
849 F77_XFCN (zch1up, ZCH1UP, (n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
850 F77_DBLE_CMPLX_ARG (m_chol_mat.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
851 n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
852 F77_DBLE_CMPLX_ARG (utmp.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
853 rw));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
854 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
855
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
856 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
857 OCTAVE_API octave_idx_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
858 chol<ComplexMatrix>::downdate (const ComplexColumnVector& u)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
859 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
862 F77_INT n = to_f77_int (m_chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
863
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
864 if (u.numel () != n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
871 F77_XFCN (zch1dn, ZCH1DN, (n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
872 F77_DBLE_CMPLX_ARG (m_chol_mat.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
873 n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
874 F77_DBLE_CMPLX_ARG (utmp.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
877 return info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
878 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
879
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
880 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
881 OCTAVE_API octave_idx_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
882 chol<ComplexMatrix>::insert_sym (const ComplexColumnVector& u,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
883 octave_idx_type j_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
884 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
887 F77_INT n = to_f77_int (m_chol_mat.rows ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
890 if (u.numel () != n + 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
891 (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
892 if (j < 0 || j > n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
899 m_chol_mat.resize (n+1, n+1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
900 F77_INT ldcm = to_f77_int (m_chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
901
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
902 F77_XFCN (zchinx, ZCHINX, (n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
903 F77_DBLE_CMPLX_ARG (m_chol_mat.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
904 ldcm, j + 1,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
905 F77_DBLE_CMPLX_ARG (utmp.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
908 return info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
909 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
910
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
911 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
912 OCTAVE_API void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
913 chol<ComplexMatrix>::delete_sym (octave_idx_type j_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
914 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
915 F77_INT n = to_f77_int (m_chol_mat.rows ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
918 if (j < 0 || j > n-1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
923 F77_XFCN (zchdex, ZCHDEX, (n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
924 F77_DBLE_CMPLX_ARG (m_chol_mat.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
927 m_chol_mat.resize (n-1, n-1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
928 }
8562
a6edd5c23cb5 use replacement methods if qrupdate is not available
Jaroslav Hajek <highegg@gmail.com>
parents: 8547
diff changeset
929
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
930 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
931 OCTAVE_API void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
932 chol<ComplexMatrix>::shift_sym (octave_idx_type i_arg,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
933 octave_idx_type j_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
934 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
935 F77_INT n = to_f77_int (m_chol_mat.rows ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
936 F77_INT i = to_f77_int (i_arg);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
939 if (i < 0 || i > n-1 || j < 0 || j > n-1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
942 OCTAVE_LOCAL_BUFFER (Complex, w, n);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
945 F77_XFCN (zchshx, ZCHSHX, (n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
946 F77_DBLE_CMPLX_ARG (m_chol_mat.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
947 n, i + 1, j + 1,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
948 F77_DBLE_CMPLX_ARG (w), rw));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
953 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
954 OCTAVE_API octave_idx_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
955 chol<FloatComplexMatrix>::init (const FloatComplexMatrix& a, bool upper,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
956 bool calc_cond)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
957 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
958 octave_idx_type a_nr = a.rows ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
961 if (a_nr != a_nc)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
964 F77_INT n = to_f77_int (a_nc);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
967 m_is_upper = upper;
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
968
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
969 m_chol_mat.clear (n, n);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
970 if (m_is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
971 for (octave_idx_type j = 0; j < n; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
972 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
973 for (octave_idx_type i = 0; i <= j; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
974 m_chol_mat.xelem (i, j) = a(i, j);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
975 for (octave_idx_type i = j+1; i < n; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
976 m_chol_mat.xelem (i, j) = 0.0f;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
977 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
978 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
979 for (octave_idx_type j = 0; j < n; j++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
980 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
981 for (octave_idx_type i = 0; i < j; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
982 m_chol_mat.xelem (i, j) = 0.0f;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
983 for (octave_idx_type i = j; i < n; i++)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
984 m_chol_mat.xelem (i, j) = a(i, j);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
985 }
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
986 FloatComplex *h = m_chol_mat.fortran_vec ();
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
987
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
988 // Calculate the norm of the matrix, for later use.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
989 float anorm = 0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
990 if (calc_cond)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
991 anorm = octave::xnorm (a, 1);
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
992
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
993 if (m_is_upper)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
994 F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 ("U", 1),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
995 n, F77_CMPLX_ARG (h), n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
996 F77_CHAR_ARG_LEN (1)));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
997 else
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
998 F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 ("L", 1),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
999 n, F77_CMPLX_ARG (h), n, info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1002 m_rcond = 0.0;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1003 if (info > 0)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1004 m_chol_mat.resize (info - 1, info - 1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1005 else if (calc_cond)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1006 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1009 // Now calculate the condition number for non-singular matrix.
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1010 Array<FloatComplex> z (dim_vector (2*n, 1));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1011 FloatComplex *pz = z.fortran_vec ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1012 Array<float> rz (dim_vector (n, 1));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1013 float *prz = rz.fortran_vec ();
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1014 F77_XFCN (cpocon, CPOCON, (F77_CONST_CHAR_ARG2 ("U", 1), n,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1015 F77_CMPLX_ARG (h), n, anorm, m_rcond,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1016 F77_CMPLX_ARG (pz), prz, cpocon_info
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1019 if (cpocon_info != 0)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1020 info = -1;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1021 }
22329
7f3c7a8bd131 maint: Indent namespaces in liboctave/numeric files.
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1022
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1023 return info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1024 }
21269
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1028 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1029 OCTAVE_API void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1030 chol<FloatComplexMatrix>::update (const FloatComplexColumnVector& u)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1031 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1032 F77_INT n = to_f77_int (m_chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1033
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1034 if (u.numel () != n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1041 F77_XFCN (cch1up, CCH1UP, (n, F77_CMPLX_ARG (m_chol_mat.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1042 n, F77_CMPLX_ARG (utmp.fortran_vec ()), rw));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1043 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1044
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1045 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1046 OCTAVE_API octave_idx_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1047 chol<FloatComplexMatrix>::downdate (const FloatComplexColumnVector& u)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1048 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1051 F77_INT n = to_f77_int (m_chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1052
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1053 if (u.numel () != n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1060 F77_XFCN (cch1dn, CCH1DN, (n, F77_CMPLX_ARG (m_chol_mat.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1061 n, F77_CMPLX_ARG (utmp.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1064 return info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1065 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1066
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1067 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1068 OCTAVE_API octave_idx_type
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1069 chol<FloatComplexMatrix>::insert_sym (const FloatComplexColumnVector& u,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1070 octave_idx_type j_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1071 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1072 F77_INT info = -1;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1075 F77_INT n = to_f77_int (m_chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1076
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1077 if (u.numel () != n + 1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1078 (*current_liboctave_error_handler) ("cholinsert: dimension mismatch");
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1079 if (j < 0 || j > n)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1086 m_chol_mat.resize (n+1, n+1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1087 F77_INT ldcm = to_f77_int (m_chol_mat.rows ());
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1088
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1089 F77_XFCN (cchinx, CCHINX, (n, F77_CMPLX_ARG (m_chol_mat.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1090 ldcm, j + 1,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1091 F77_CMPLX_ARG (utmp.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1094 return info;
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1095 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1096
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1097 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1098 OCTAVE_API void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1099 chol<FloatComplexMatrix>::delete_sym (octave_idx_type j_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1100 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1101 F77_INT n = to_f77_int (m_chol_mat.rows ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1104 if (j < 0 || j > n-1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1109 F77_XFCN (cchdex, CCHDEX, (n, F77_CMPLX_ARG (m_chol_mat.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1112 m_chol_mat.resize (n-1, n-1);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1113 }
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
1114
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1115 template <>
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1116 OCTAVE_API void
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1117 chol<FloatComplexMatrix>::shift_sym (octave_idx_type i_arg,
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1118 octave_idx_type j_arg)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1119 {
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1120 F77_INT n = to_f77_int (m_chol_mat.rows ());
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1121 F77_INT i = to_f77_int (i_arg);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1124 if (i < 0 || i > n-1 || j < 0 || j > n-1)
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1127 OCTAVE_LOCAL_BUFFER (FloatComplex, w, n);
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1130 F77_XFCN (cchshx, CCHSHX, (n, F77_CMPLX_ARG (m_chol_mat.fortran_vec ()),
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1131 n, i + 1, j + 1, F77_CMPLX_ARG (w), rw));
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1146 template OCTAVE_API Matrix
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1149 template OCTAVE_API ComplexMatrix
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1152 template OCTAVE_API FloatMatrix
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
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
31607
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1155 template OCTAVE_API FloatComplexMatrix
aac27ad79be6 maint: Re-indent code after switch to using namespace macros.
Rik <rik@octave.org>
parents: 31605
diff changeset
1156 chol2inv<FloatComplexMatrix> (const FloatComplexMatrix& r);
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30564
diff changeset
1157
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30564
diff changeset
1158 OCTAVE_END_NAMESPACE(math)
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 30564
diff changeset
1159 OCTAVE_END_NAMESPACE(octave)