Mercurial > octave
annotate liboctave/numeric/lu.cc @ 21724:aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
* configure.ac, Doxyfile.in, make_int.cc, Backend.cc, BaseControl.cc,
ButtonControl.cc, Canvas.cc, CheckBoxControl.cc, Container.cc,
ContextMenu.cc, EditControl.cc, Figure.cc, FigureWindow.cc,
GLCanvas.cc, KeyMap.cc, ListBoxControl.cc, Logger.cc, Menu.cc,
MouseModeActionGroup.cc, Object.cc, ObjectFactory.cc,
ObjectProxy.cc, Panel.cc, PopupMenuControl.cc, PushButtonControl.cc,
PushTool.cc, QtHandlesUtils.cc, RadioButtonControl.cc,
SliderControl.cc, TextControl.cc, TextEdit.cc,
ToggleButtonControl.cc, ToggleTool.cc, ToolBar.cc, __init_qt__.cc,
annotation-dialog.cc, gl-select.cc, module.mk, color-picker.cc,
dialog.cc, documentation-dock-widget.cc, files-dock-widget.cc,
find-files-dialog.cc, find-files-model.cc, history-dock-widget.cc,
liboctgui-build-info.in.cc, file-editor-tab.cc, file-editor.cc,
find-dialog.cc, marker.cc, marker.h, octave-qscintilla.cc,
octave-txt-lexer.cc, main-window.cc, octave-cmd.cc,
octave-dock-widget.cc, octave-gui.cc, octave-interpreter.cc,
octave-qt-link.cc, parser.cc, webinfo.cc, resource-manager.cc,
settings-dialog.cc, shortcut-manager.cc, terminal-dock-widget.cc,
thread-manager.cc, welcome-wizard.cc, workspace-model.cc,
workspace-view.cc, build-env.in.cc, Cell.cc, __contourc__.cc,
__dispatch__.cc, __dsearchn__.cc, __ichol__.cc, __ilu__.cc,
__lin_interpn__.cc, __luinc__.cc, __magick_read__.cc,
__pchip_deriv__.cc, __qp__.cc, balance.cc, besselj.cc, betainc.cc,
bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h,
cdisplay.c, cdisplay.h, cellfun.cc, coct-hdf5-types.c, colloc.cc,
comment-list.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc,
debug.cc, defaults.cc, defaults.in.h, defun.cc, det.cc, dirfns.cc,
display.cc, dlmread.cc, dot.cc, dynamic-ld.cc, eig.cc, ellipj.cc,
error.cc, errwarn.cc, event-queue.cc, fft.cc, fft2.cc, fftn.cc,
file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, gammainc.cc,
gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc,
gl-render.cc, gl2ps-print.cc, graphics.cc, gripes.cc, hash.cc,
help.cc, hess.cc, hex2num.cc, input.cc, inv.cc, jit-ir.cc, jit-ir.h,
jit-typeinfo.cc, jit-typeinfo.h, jit-util.cc, jit-util.h, kron.cc,
load-path.cc, load-save.cc, lookup.cc, ls-ascii-helper.cc,
ls-hdf5.cc, ls-mat-ascii.cc, ls-mat4.cc, ls-mat5.cc,
ls-oct-binary.cc, ls-oct-text.cc, ls-oct-text.h, ls-utils.cc,
lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex.cc, mex.h,
mexproto.h, mgorth.cc, nproc.cc, oct-errno.in.cc, oct-fstrm.cc,
oct-hdf5-types.cc, oct-hdf5-types.h, oct-hist.cc, oct-iostrm.cc,
oct-lvalue.cc, oct-map.cc, oct-prcstrm.cc, oct-procbuf.cc,
oct-stdstrm.h, oct-stream.cc, oct-strstrm.cc, oct-tex-lexer.in.ll,
oct-tex-parser.in.yy, octave-link.cc, ordschur.cc, pager.cc,
pinv.cc, pr-output.cc, procstream.cc, profiler.cc, psi.cc,
pt-jit.cc, pt-jit.h, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc,
regexp.cc, schur.cc, sighandlers.cc, sighandlers.h, siglist.c,
siglist.h, sparse-xdiv.cc, sparse-xpow.cc, sparse.cc, spparms.cc,
sqrtm.cc, str2double.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc,
sylvester.cc, symtab.cc, syscalls.cc, sysdep.cc, text-renderer.cc,
time.cc, toplev.cc, tril.cc, tsearch.cc, txt-eng.cc, typecast.cc,
urlwrite.cc, utils.cc, variables.cc, xdiv.cc, xgl2ps.c, xnorm.cc,
xpow.cc, zfstream.cc, zfstream.h, __delaunayn__.cc, __eigs__.cc,
__fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc,
__init_gnuplot__.cc, __osmesa_print__.cc, __voronoi__.cc, amd.cc,
audiodevinfo.cc, audioread.cc, ccolamd.cc, chol.cc, colamd.cc,
convhulln.cc, dmperm.cc, fftw.cc, qr.cc, symbfact.cc, symrcm.cc,
liboctinterp-build-info.in.cc, mkbuiltins, mkops, ov-base.cc,
ov-bool-mat.cc, ov-bool-sparse.cc, ov-bool.cc, ov-builtin.cc,
ov-cell.cc, ov-ch-mat.cc, ov-class.cc, ov-classdef.cc, ov-colon.cc,
ov-complex.cc, ov-cs-list.cc, ov-cx-diag.cc, ov-cx-mat.cc,
ov-cx-sparse.cc, ov-dld-fcn.cc, ov-fcn-handle.cc, ov-fcn-inline.cc,
ov-fcn.cc, 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-int16.cc,
ov-int32.cc, ov-int64.cc, ov-int8.cc, ov-java.cc, ov-lazy-idx.cc,
ov-mex-fcn.cc, ov-null-mat.cc, ov-oncleanup.cc, ov-perm.cc,
ov-range.cc, ov-re-diag.cc, ov-re-mat.cc, ov-re-sparse.cc,
ov-scalar.cc, ov-str-mat.cc, ov-struct.cc, ov-typeinfo.cc,
ov-uint16.cc, ov-uint32.cc, ov-uint64.cc, ov-uint8.cc,
ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ovl.cc, octave.cc, octave.h,
op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc,
op-bm-sbm.cc, op-cdm-cdm.cc, op-cdm-cm.cc, op-cdm-dm.cc,
op-cdm-m.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cdm.cc,
op-cm-cm.cc, op-cm-cs.cc, op-cm-dm.cc, op-cm-m.cc, op-cm-s.cc,
op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc,
op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-cdm.cc, op-dm-cm.cc,
op-dm-dm.cc, op-dm-m.cc, op-dm-scm.cc, op-dm-sm.cc,
op-dm-template.cc, op-dms-template.cc, op-double-conv.cc,
op-fcdm-fcdm.cc, op-fcdm-fcm.cc, op-fcdm-fdm.cc, op-fcdm-fm.cc,
op-fcm-fcdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fdm.cc,
op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc,
op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fcdm.cc, op-fdm-fcm.cc,
op-fdm-fdm.cc, op-fdm-fm.cc, op-float-conv.cc, op-fm-fcdm.cc,
op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fdm.cc, op-fm-fm.cc, op-fm-fs.cc,
op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc,
op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc,
op-int-conv.cc, op-m-cdm.cc, op-m-cm.cc, op-m-cs.cc, op-m-dm.cc,
op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-pm-pm.cc,
op-pm-scm.cc, op-pm-sm.cc, op-pm-template.cc, op-range.cc,
op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc,
op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc,
op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc,
op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc,
op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc,
op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc,
lex.ll, oct-parse.in.yy, pt-arg-list.cc, pt-array-list.cc,
pt-assign.cc, pt-binop.cc, pt-bp.cc, pt-cbinop.cc, pt-cell.cc,
pt-check.cc, pt-classdef.cc, pt-cmd.cc, pt-colon.cc, pt-const.cc,
pt-decl.cc, pt-eval.cc, pt-except.cc, pt-exp.cc, pt-fcn-handle.cc,
pt-funcall.cc, pt-id.cc, pt-idx.cc, pt-jump.cc, pt-loop.cc,
pt-loop.h, pt-mat.cc, pt-misc.cc, pt-pr-code.cc, pt-select.cc,
pt-stmt.cc, pt-unop.cc, pt.cc, token.cc, Array-jit.cc, Array-tc.cc,
version.cc, Array-C.cc, Array-b.cc, Array-ch.cc, Array-d.cc,
Array-f.cc, Array-fC.cc, Array-i.cc, Array-idx-vec.cc, Array-s.cc,
Array-str.cc, Array-util.cc, Array-voidp.cc, Array.cc,
CColVector.cc, CDiagMatrix.cc, CMatrix.cc, CNDArray.cc,
CRowVector.cc, CSparse.cc, MArray-C.cc, MArray-d.cc, MArray-f.cc,
MArray-fC.cc, MArray-i.cc, MArray-s.cc, MSparse-C.cc, MSparse-d.cc,
MatrixType.cc, PermMatrix.cc, Range.cc, Sparse-C.cc, Sparse-b.cc,
Sparse-d.cc, boolMatrix.cc, boolNDArray.cc, boolSparse.cc,
chMatrix.cc, chNDArray.cc, dColVector.cc, dDiagMatrix.cc,
dMatrix.cc, dNDArray.cc, dRowVector.cc, dSparse.cc, dim-vector.cc,
dim-vector.h, fCColVector.cc, fCDiagMatrix.cc, fCMatrix.cc,
fCNDArray.cc, fCRowVector.cc, fColVector.cc, fDiagMatrix.cc,
fMatrix.cc, fNDArray.cc, fRowVector.cc, idx-vector.cc,
int16NDArray.cc, int32NDArray.cc, int64NDArray.cc, int8NDArray.cc,
uint16NDArray.cc, uint32NDArray.cc, uint64NDArray.cc,
uint8NDArray.cc, Faddeeva.cc, blaswrap.c, cquit.c, f77-extern.cc,
f77-fcn.c, f77-fcn.h, lo-error.c, lo-error.h, quit.cc, quit.h,
liboctave-build-info.in.cc, CollocWt.cc, DASPK.cc, DASRT.cc,
DASSL.cc, EIG.cc, LSODE.cc, ODES.cc, Quad.cc, aepbalance.cc,
chol.cc, eigs-base.cc, fEIG.cc, gepbalance.cc, hess.cc,
lo-mappers.cc, lo-specfun.cc, lu.cc, oct-convn.cc, oct-fftw.cc,
oct-norm.cc, oct-rand.cc, oct-spparms.cc, qr.cc, qrp.cc,
randmtzig.cc, randpoisson.cc, schur.cc, sparse-chol.cc,
sparse-dmsolve.cc, sparse-lu.cc, sparse-qr.cc, svd.cc, mk-ops.awk,
mx-defs.h, dir-ops.cc, file-ops.cc, file-stat.cc, lo-sysdep.cc,
mach-info.cc, oct-env.cc, oct-group.cc, oct-passwd.cc,
oct-syscalls.cc, oct-time.cc, oct-uname.cc, pathlen.h, syswait.h,
cmd-edit.cc, cmd-hist.cc, data-conv.cc, f2c-main.c, glob-match.cc,
kpse.cc, lo-array-errwarn.cc, lo-array-gripes.cc, lo-cutils.c,
lo-cutils.h, lo-ieee.cc, lo-ieee.h, lo-regexp.cc, lo-utils.cc,
oct-base64.cc, oct-glob.cc, oct-inttypes.cc, oct-inttypes.h,
oct-locbuf.cc, oct-mutex.cc, oct-rl-edit.c, oct-rl-edit.h,
oct-rl-hist.c, oct-rl-hist.h, oct-shlib.cc, oct-sort.cc,
pathsearch.cc, singleton-cleanup.cc, sparse-sort.cc, sparse-util.cc,
statdefs.h, str-vec.cc, unwind-prot.cc, url-transfer.cc,
acinclude.m4, display-available.c, display-available.h, main-cli.cc,
main-gui.cc, main.in.cc, mkoctfile.in.cc, octave-build-info.in.cc,
octave-config.in.cc, shared-fcns.h:
Use "#if ..." consistently instead of "#ifdef" and "#ifndef".
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 17 May 2016 12:09:30 -0400 |
parents | 40de9f8f23a6 |
children | 59cadee1c74b |
rev | line source |
---|---|
1991 | 1 /* |
2 | |
19697
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
18849
diff
changeset
|
3 Copyright (C) 1996-2015 John W. Eaton |
10521
4d1fc073fbb7
add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
4 Copyright (C) 2009 VZLU Prague |
1991 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1991 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1991 | 21 |
22 */ | |
23 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
24 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21271
diff
changeset
|
25 # include "config.h" |
1991 | 26 #endif |
27 | |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
28 #include "CColVector.h" |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
29 #include "CMatrix.h" |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
30 #include "dColVector.h" |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
31 #include "dMatrix.h" |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
32 #include "f77-fcn.h" |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
33 #include "fCColVector.h" |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
34 #include "fCMatrix.h" |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
35 #include "fColVector.h" |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
36 #include "fMatrix.h" |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
37 #include "lo-error.h" |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
38 #include "lu.h" |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
39 #include "oct-locbuf.h" |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
40 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
41 extern "C" |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
42 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
43 F77_RET_T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
44 F77_FUNC (dgetrf, DGETRF) (const octave_idx_type&, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
45 double*, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
46 octave_idx_type*, octave_idx_type&); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
47 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
48 #if defined (HAVE_QRUPDATE_LUU) |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
49 F77_RET_T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
50 F77_FUNC (dlu1up, DLU1UP) (const octave_idx_type&, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
51 double *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
52 double *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
53 double *, double *); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
54 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
55 F77_RET_T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
56 F77_FUNC (dlup1up, DLUP1UP) (const octave_idx_type&, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
57 double *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
58 double *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
59 octave_idx_type *, const double *, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
60 const double *, double *); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
61 #endif |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
62 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
63 F77_RET_T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
64 F77_FUNC (sgetrf, SGETRF) (const octave_idx_type&, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
65 float*, const octave_idx_type&, octave_idx_type*, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
66 octave_idx_type&); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
67 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
68 #if defined (HAVE_QRUPDATE_LUU) |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
69 F77_RET_T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
70 F77_FUNC (slu1up, SLU1UP) (const octave_idx_type&, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
71 float *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
72 float *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
73 float *, float *); |
1991 | 74 |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
75 F77_RET_T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
76 F77_FUNC (slup1up, SLUP1UP) (const octave_idx_type&, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
77 float *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
78 float *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
79 octave_idx_type *, const float *, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
80 const float *, float *); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
81 #endif |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
82 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
83 F77_RET_T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
84 F77_FUNC (zgetrf, ZGETRF) (const octave_idx_type&, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
85 Complex*, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
86 octave_idx_type*, octave_idx_type&); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
87 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
88 #if defined (HAVE_QRUPDATE_LUU) |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
89 F77_RET_T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
90 F77_FUNC (zlu1up, ZLU1UP) (const octave_idx_type&, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
91 Complex *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
92 Complex *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
93 Complex *, Complex *); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
94 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
95 F77_RET_T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
96 F77_FUNC (zlup1up, ZLUP1UP) (const octave_idx_type&, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
97 Complex *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
98 Complex *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
99 octave_idx_type *, const Complex *, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
100 const Complex *, Complex *); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
101 #endif |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
102 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
103 F77_RET_T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
104 F77_FUNC (cgetrf, CGETRF) (const octave_idx_type&, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
105 FloatComplex*, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
106 octave_idx_type*, octave_idx_type&); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
107 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
108 #if defined (HAVE_QRUPDATE_LUU) |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
109 F77_RET_T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
110 F77_FUNC (clu1up, CLU1UP) (const octave_idx_type&, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
111 FloatComplex *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
112 FloatComplex *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
113 FloatComplex *, FloatComplex *); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
114 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
115 F77_RET_T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
116 F77_FUNC (clup1up, CLUP1UP) (const octave_idx_type&, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
117 FloatComplex *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
118 FloatComplex *, const octave_idx_type&, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
119 octave_idx_type *, const FloatComplex *, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
120 const FloatComplex *, FloatComplex *); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
121 #endif |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
122 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
123 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
124 template <typename T> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
125 lu<T>::lu (const T& l, const T& u, |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
126 const PermMatrix& p) |
18849
aa9ca67f09fb
make all permutation matrices column permutations (bug #42418)
David Spies <dnspies@gmail.com>
parents:
17769
diff
changeset
|
127 : a_fact (u), l_fact (l), ipvt (p.transpose ().col_perm_vec ()) |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
128 { |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
129 if (l.columns () != u.rows ()) |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
130 (*current_liboctave_error_handler) ("lu: dimension mismatch"); |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
131 } |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
132 |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
133 template <typename T> |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
134 bool |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
135 lu<T>::packed (void) const |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
136 { |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
137 return l_fact.dims () == dim_vector (); |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
138 } |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
139 |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
140 template <typename T> |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
141 void |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
142 lu<T>::unpack (void) |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
143 { |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
144 if (packed ()) |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
145 { |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
146 l_fact = L (); |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
147 a_fact = U (); // FIXME: sub-optimal |
9697
51c17bd18563
omission in base-lu::unpack
Jaroslav Hajek <highegg@gmail.com>
parents:
9694
diff
changeset
|
148 ipvt = getp (); |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
149 } |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
150 } |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
151 |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
152 template <typename T> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
153 T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
154 lu<T>::L (void) const |
1991 | 155 { |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
156 if (packed ()) |
1991 | 157 { |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
158 octave_idx_type a_nr = a_fact.rows (); |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
159 octave_idx_type a_nc = a_fact.cols (); |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
160 octave_idx_type mn = (a_nr < a_nc ? a_nr : a_nc); |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
161 |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
162 T l (a_nr, mn, ELT_T (0.0)); |
4811 | 163 |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
164 for (octave_idx_type i = 0; i < a_nr; i++) |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
165 { |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
166 if (i < a_nc) |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
167 l.xelem (i, i) = 1.0; |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
168 |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
169 for (octave_idx_type j = 0; j < (i < a_nc ? i : a_nc); j++) |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
170 l.xelem (i, j) = a_fact.xelem (i, j); |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
171 } |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
172 |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
173 return l; |
1991 | 174 } |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
175 else |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
176 return l_fact; |
1991 | 177 } |
178 | |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
179 template <typename T> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
180 T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
181 lu<T>::U (void) const |
1991 | 182 { |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
183 if (packed ()) |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
184 { |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
185 octave_idx_type a_nr = a_fact.rows (); |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
186 octave_idx_type a_nc = a_fact.cols (); |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
187 octave_idx_type mn = (a_nr < a_nc ? a_nr : a_nc); |
1991 | 188 |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
189 T u (mn, a_nc, ELT_T (0.0)); |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
190 |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
191 for (octave_idx_type i = 0; i < mn; i++) |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
192 { |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
193 for (octave_idx_type j = i; j < a_nc; j++) |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
194 u.xelem (i, j) = a_fact.xelem (i, j); |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
195 } |
4329 | 196 |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
197 return u; |
1991 | 198 } |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
199 else |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
200 return a_fact; |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
201 } |
1991 | 202 |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
203 template <typename T> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
204 T |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
205 lu<T>::Y (void) const |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
206 { |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
207 if (! packed ()) |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
208 (*current_liboctave_error_handler) |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
209 ("lu: Y () not implemented for unpacked form"); |
21136
7cac4e7458f2
maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents:
20232
diff
changeset
|
210 |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
211 return a_fact; |
1991 | 212 } |
213 | |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
214 template <typename T> |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7515
diff
changeset
|
215 Array<octave_idx_type> |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
216 lu<T>::getp (void) const |
1991 | 217 { |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
218 if (packed ()) |
1991 | 219 { |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
220 octave_idx_type a_nr = a_fact.rows (); |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
221 |
11570
57632dea2446
attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
222 Array<octave_idx_type> pvt (dim_vector (a_nr, 1)); |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
223 |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
224 for (octave_idx_type i = 0; i < a_nr; i++) |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
225 pvt.xelem (i) = i; |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
226 |
20232
a9574e3c6e9e
Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents:
19697
diff
changeset
|
227 for (octave_idx_type i = 0; i < ipvt.numel (); i++) |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
228 { |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
229 octave_idx_type k = ipvt.xelem (i); |
1991 | 230 |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
231 if (k != i) |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
232 { |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
233 octave_idx_type tmp = pvt.xelem (k); |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
234 pvt.xelem (k) = pvt.xelem (i); |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
235 pvt.xelem (i) = tmp; |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
236 } |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
237 } |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
238 |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
239 return pvt; |
1991 | 240 } |
9694
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
241 else |
50db3c5175b5
allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
242 return ipvt; |
1991 | 243 } |
244 | |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
245 template <typename T> |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7515
diff
changeset
|
246 PermMatrix |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
247 lu<T>::P (void) const |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7515
diff
changeset
|
248 { |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7515
diff
changeset
|
249 return PermMatrix (getp (), false); |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7515
diff
changeset
|
250 } |
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7515
diff
changeset
|
251 |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
252 template <typename T> |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
253 ColumnVector |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
254 lu<T>::P_vec (void) const |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
255 { |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
256 octave_idx_type a_nr = a_fact.rows (); |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
257 |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7515
diff
changeset
|
258 ColumnVector p (a_nr); |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
259 |
8367
445d27d79f4e
support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
7515
diff
changeset
|
260 Array<octave_idx_type> pvt = getp (); |
7515
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
261 |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
262 for (octave_idx_type i = 0; i < a_nr; i++) |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
263 p.xelem (i) = static_cast<double> (pvt.xelem (i) + 1); |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
264 |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
265 return p; |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
266 } |
f3c00dc0912b
Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
267 |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
268 template <typename T> |
9715
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9697
diff
changeset
|
269 bool |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
270 lu<T>::regular (void) const |
9715
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9697
diff
changeset
|
271 { |
13217
08ba694723f5
fix warnings for unused but set variables
John W. Eaton <jwe@octave.org>
parents:
11590
diff
changeset
|
272 bool retval = true; |
08ba694723f5
fix warnings for unused but set variables
John W. Eaton <jwe@octave.org>
parents:
11590
diff
changeset
|
273 |
9715
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9697
diff
changeset
|
274 octave_idx_type k = std::min (a_fact.rows (), a_fact.columns ()); |
13217
08ba694723f5
fix warnings for unused but set variables
John W. Eaton <jwe@octave.org>
parents:
11590
diff
changeset
|
275 |
9715
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9697
diff
changeset
|
276 for (octave_idx_type i = 0; i < k; i++) |
13217
08ba694723f5
fix warnings for unused but set variables
John W. Eaton <jwe@octave.org>
parents:
11590
diff
changeset
|
277 { |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
278 if (a_fact(i, i) == ELT_T ()) |
13217
08ba694723f5
fix warnings for unused but set variables
John W. Eaton <jwe@octave.org>
parents:
11590
diff
changeset
|
279 { |
08ba694723f5
fix warnings for unused but set variables
John W. Eaton <jwe@octave.org>
parents:
11590
diff
changeset
|
280 retval = false; |
08ba694723f5
fix warnings for unused but set variables
John W. Eaton <jwe@octave.org>
parents:
11590
diff
changeset
|
281 break; |
08ba694723f5
fix warnings for unused but set variables
John W. Eaton <jwe@octave.org>
parents:
11590
diff
changeset
|
282 } |
08ba694723f5
fix warnings for unused but set variables
John W. Eaton <jwe@octave.org>
parents:
11590
diff
changeset
|
283 } |
9715
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9697
diff
changeset
|
284 |
13217
08ba694723f5
fix warnings for unused but set variables
John W. Eaton <jwe@octave.org>
parents:
11590
diff
changeset
|
285 return retval; |
9715
9f27172fbd1e
auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents:
9697
diff
changeset
|
286 } |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
287 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
288 #if ! defined (HAVE_QRUPDATE_LUU) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
289 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
290 template <typename T> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
291 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
292 lu<T>::update (const VT&, const VT&) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
293 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
294 (*current_liboctave_error_handler) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
295 ("luupdate: support for qrupdate with LU updates " |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
296 "was unavailable or disabled when liboctave was built"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
297 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
298 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
299 template <typename T> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
300 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
301 lu<T>::update (const T&, const T&) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
302 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
303 (*current_liboctave_error_handler) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
304 ("luupdate: support for qrupdate with LU updates " |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
305 "was unavailable or disabled when liboctave was built"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
306 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
307 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
308 template <typename T> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
309 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
310 lu<T>::update_piv (const VT&, const VT&) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
311 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
312 (*current_liboctave_error_handler) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
313 ("luupdate: support for qrupdate with LU updates " |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
314 "was unavailable or disabled when liboctave was built"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
315 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
316 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
317 template <typename T> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
318 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
319 lu<T>::update_piv (const T&, const T&) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
320 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
321 (*current_liboctave_error_handler) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
322 ("luupdate: support for qrupdate with LU updates " |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
323 "was unavailable or disabled when liboctave was built"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
324 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
325 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
326 #endif |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
327 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
328 // Specializations. |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
329 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
330 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
331 lu<Matrix>::lu (const Matrix& a) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
332 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
333 octave_idx_type a_nr = a.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
334 octave_idx_type a_nc = a.cols (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
335 octave_idx_type mn = (a_nr < a_nc ? a_nr : a_nc); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
336 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
337 ipvt.resize (dim_vector (mn, 1)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
338 octave_idx_type *pipvt = ipvt.fortran_vec (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
339 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
340 a_fact = a; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
341 double *tmp_data = a_fact.fortran_vec (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
342 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
343 octave_idx_type info = 0; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
344 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
345 F77_XFCN (dgetrf, DGETRF, (a_nr, a_nc, tmp_data, a_nr, pipvt, info)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
346 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
347 for (octave_idx_type i = 0; i < mn; i++) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
348 pipvt[i] -= 1; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
349 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
350 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
351 #if defined (HAVE_QRUPDATE_LUU) |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
352 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
353 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
354 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
355 lu<Matrix>::update (const ColumnVector& u, const ColumnVector& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
356 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
357 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
358 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
359 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
360 Matrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
361 Matrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
362 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
363 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
364 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
365 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
366 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
367 if (u.numel () != m || v.numel () != n) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
368 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
369 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
370 ColumnVector utmp = u; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
371 ColumnVector vtmp = v; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
372 F77_XFCN (dlu1up, DLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
373 utmp.fortran_vec (), vtmp.fortran_vec ())); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
374 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
375 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
376 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
377 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
378 lu<Matrix>::update (const Matrix& u, const Matrix& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
379 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
380 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
381 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
382 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
383 Matrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
384 Matrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
385 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
386 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
387 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
388 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
389 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
390 if (u.rows () != m || v.rows () != n || u.cols () != v.cols ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
391 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
392 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
393 for (volatile octave_idx_type i = 0; i < u.cols (); i++) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
394 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
395 ColumnVector utmp = u.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
396 ColumnVector vtmp = v.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
397 F77_XFCN (dlu1up, DLU1UP, (m, n, l.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
398 m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
399 utmp.fortran_vec (), vtmp.fortran_vec ())); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
400 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
401 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
402 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
403 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
404 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
405 lu<Matrix>::update_piv (const ColumnVector& u, const ColumnVector& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
406 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
407 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
408 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
409 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
410 Matrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
411 Matrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
412 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
413 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
414 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
415 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
416 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
417 if (u.numel () != m || v.numel () != n) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
418 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
419 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
420 ColumnVector utmp = u; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
421 ColumnVector vtmp = v; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
422 OCTAVE_LOCAL_BUFFER (double, w, m); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
423 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
424 F77_XFCN (dlup1up, DLUP1UP, (m, n, l.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
425 m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
426 ipvt.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
427 utmp.data (), vtmp.data (), w)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
428 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
429 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
430 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
431 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
432 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
433 lu<Matrix>::update_piv (const Matrix& u, const Matrix& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
434 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
435 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
436 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
437 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
438 Matrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
439 Matrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
440 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
441 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
442 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
443 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
444 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
445 if (u.rows () != m || v.rows () != n || u.cols () != v.cols ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
446 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
447 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
448 OCTAVE_LOCAL_BUFFER (double, w, m); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
449 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
450 for (volatile octave_idx_type i = 0; i < u.cols (); i++) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
451 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
452 ColumnVector utmp = u.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
453 ColumnVector vtmp = v.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
454 F77_XFCN (dlup1up, DLUP1UP, (m, n, l.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
455 m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
456 ipvt.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
457 utmp.data (), vtmp.data (), w)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
458 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
459 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
460 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
461 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
462 #endif |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
463 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
464 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
465 lu<FloatMatrix>::lu (const FloatMatrix& a) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
466 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
467 octave_idx_type a_nr = a.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
468 octave_idx_type a_nc = a.cols (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
469 octave_idx_type mn = (a_nr < a_nc ? a_nr : a_nc); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
470 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
471 ipvt.resize (dim_vector (mn, 1)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
472 octave_idx_type *pipvt = ipvt.fortran_vec (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
473 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
474 a_fact = a; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
475 float *tmp_data = a_fact.fortran_vec (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
476 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
477 octave_idx_type info = 0; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
478 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
479 F77_XFCN (sgetrf, SGETRF, (a_nr, a_nc, tmp_data, a_nr, pipvt, info)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
480 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
481 for (octave_idx_type i = 0; i < mn; i++) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
482 pipvt[i] -= 1; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
483 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
484 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
485 #if defined (HAVE_QRUPDATE_LUU) |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
486 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
487 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
488 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
489 lu<FloatMatrix>::update (const FloatColumnVector& u, const FloatColumnVector& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
490 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
491 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
492 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
493 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
494 FloatMatrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
495 FloatMatrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
496 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
497 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
498 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
499 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
500 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
501 if (u.numel () != m || v.numel () != n) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
502 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
503 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
504 FloatColumnVector utmp = u; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
505 FloatColumnVector vtmp = v; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
506 F77_XFCN (slu1up, SLU1UP, (m, n, l.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
507 m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
508 utmp.fortran_vec (), vtmp.fortran_vec ())); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
509 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
510 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
511 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
512 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
513 lu<FloatMatrix>::update (const FloatMatrix& u, const FloatMatrix& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
514 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
515 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
516 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
517 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
518 FloatMatrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
519 FloatMatrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
520 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
521 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
522 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
523 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
524 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
525 if (u.rows () != m || v.rows () != n || u.cols () != v.cols ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
526 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
527 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
528 for (volatile octave_idx_type i = 0; i < u.cols (); i++) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
529 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
530 FloatColumnVector utmp = u.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
531 FloatColumnVector vtmp = v.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
532 F77_XFCN (slu1up, SLU1UP, (m, n, l.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
533 m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
534 utmp.fortran_vec (), vtmp.fortran_vec ())); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
535 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
536 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
537 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
538 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
539 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
540 lu<FloatMatrix>::update_piv (const FloatColumnVector& u, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
541 const FloatColumnVector& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
542 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
543 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
544 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
545 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
546 FloatMatrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
547 FloatMatrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
548 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
549 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
550 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
551 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
552 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
553 if (u.numel () != m || v.numel () != n) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
554 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
555 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
556 FloatColumnVector utmp = u; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
557 FloatColumnVector vtmp = v; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
558 OCTAVE_LOCAL_BUFFER (float, w, m); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
559 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
560 F77_XFCN (slup1up, SLUP1UP, (m, n, l.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
561 m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
562 ipvt.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
563 utmp.data (), vtmp.data (), w)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
564 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
565 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
566 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
567 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
568 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
569 lu<FloatMatrix>::update_piv (const FloatMatrix& u, const FloatMatrix& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
570 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
571 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
572 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
573 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
574 FloatMatrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
575 FloatMatrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
576 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
577 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
578 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
579 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
580 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
581 if (u.rows () != m || v.rows () != n || u.cols () != v.cols ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
582 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
583 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
584 OCTAVE_LOCAL_BUFFER (float, w, m); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
585 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
586 for (volatile octave_idx_type i = 0; i < u.cols (); i++) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
587 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
588 FloatColumnVector utmp = u.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
589 FloatColumnVector vtmp = v.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
590 F77_XFCN (slup1up, SLUP1UP, (m, n, l.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
591 m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
592 ipvt.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
593 utmp.data (), vtmp.data (), w)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
594 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
595 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
596 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
597 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
598 #endif |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
599 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
600 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
601 lu<ComplexMatrix>::lu (const ComplexMatrix& a) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
602 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
603 octave_idx_type a_nr = a.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
604 octave_idx_type a_nc = a.cols (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
605 octave_idx_type mn = (a_nr < a_nc ? a_nr : a_nc); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
606 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
607 ipvt.resize (dim_vector (mn, 1)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
608 octave_idx_type *pipvt = ipvt.fortran_vec (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
609 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
610 a_fact = a; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
611 Complex *tmp_data = a_fact.fortran_vec (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
612 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
613 octave_idx_type info = 0; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
614 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
615 F77_XFCN (zgetrf, ZGETRF, (a_nr, a_nc, tmp_data, a_nr, pipvt, info)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
616 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
617 for (octave_idx_type i = 0; i < mn; i++) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
618 pipvt[i] -= 1; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
619 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
620 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
621 #if defined (HAVE_QRUPDATE_LUU) |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
622 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
623 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
624 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
625 lu<ComplexMatrix>::update (const ComplexColumnVector& u, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
626 const ComplexColumnVector& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
627 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
628 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
629 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
630 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
631 ComplexMatrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
632 ComplexMatrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
633 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
634 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
635 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
636 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
637 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
638 if (u.numel () != m || v.numel () != n) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
639 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
640 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
641 ComplexColumnVector utmp = u; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
642 ComplexColumnVector vtmp = v; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
643 F77_XFCN (zlu1up, ZLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
644 utmp.fortran_vec (), vtmp.fortran_vec ())); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
645 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
646 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
647 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
648 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
649 lu<ComplexMatrix>::update (const ComplexMatrix& u, const ComplexMatrix& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
650 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
651 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
652 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
653 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
654 ComplexMatrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
655 ComplexMatrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
656 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
657 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
658 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
659 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
660 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
661 if (u.rows () != m || v.rows () != n || u.cols () != v.cols ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
662 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
663 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
664 for (volatile octave_idx_type i = 0; i < u.cols (); i++) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
665 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
666 ComplexColumnVector utmp = u.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
667 ComplexColumnVector vtmp = v.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
668 F77_XFCN (zlu1up, ZLU1UP, (m, n, l.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
669 m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
670 utmp.fortran_vec (), vtmp.fortran_vec ())); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
671 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
672 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
673 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
674 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
675 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
676 lu<ComplexMatrix>::update_piv (const ComplexColumnVector& u, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
677 const ComplexColumnVector& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
678 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
679 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
680 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
681 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
682 ComplexMatrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
683 ComplexMatrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
684 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
685 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
686 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
687 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
688 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
689 if (u.numel () != m || v.numel () != n) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
690 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
691 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
692 ComplexColumnVector utmp = u; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
693 ComplexColumnVector vtmp = v; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
694 OCTAVE_LOCAL_BUFFER (Complex, w, m); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
695 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
696 F77_XFCN (zlup1up, ZLUP1UP, (m, n, l.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
697 m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
698 ipvt.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
699 utmp.data (), vtmp.data (), w)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
700 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
701 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
702 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
703 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
704 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
705 lu<ComplexMatrix>::update_piv (const ComplexMatrix& u, const ComplexMatrix& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
706 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
707 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
708 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
709 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
710 ComplexMatrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
711 ComplexMatrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
712 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
713 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
714 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
715 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
716 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
717 if (u.rows () != m || v.rows () != n || u.cols () != v.cols ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
718 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
719 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
720 OCTAVE_LOCAL_BUFFER (Complex, w, m); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
721 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
722 for (volatile octave_idx_type i = 0; i < u.cols (); i++) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
723 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
724 ComplexColumnVector utmp = u.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
725 ComplexColumnVector vtmp = v.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
726 F77_XFCN (zlup1up, ZLUP1UP, (m, n, l.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
727 m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
728 ipvt.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
729 utmp.data (), vtmp.data (), w)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
730 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
731 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
732 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
733 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
734 #endif |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
735 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
736 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
737 lu<FloatComplexMatrix>::lu (const FloatComplexMatrix& a) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
738 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
739 octave_idx_type a_nr = a.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
740 octave_idx_type a_nc = a.cols (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
741 octave_idx_type mn = (a_nr < a_nc ? a_nr : a_nc); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
742 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
743 ipvt.resize (dim_vector (mn, 1)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
744 octave_idx_type *pipvt = ipvt.fortran_vec (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
745 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
746 a_fact = a; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
747 FloatComplex *tmp_data = a_fact.fortran_vec (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
748 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
749 octave_idx_type info = 0; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
750 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
751 F77_XFCN (cgetrf, CGETRF, (a_nr, a_nc, tmp_data, a_nr, pipvt, info)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
752 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
753 for (octave_idx_type i = 0; i < mn; i++) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
754 pipvt[i] -= 1; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
755 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
756 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
757 #if defined (HAVE_QRUPDATE_LUU) |
21271
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
758 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
759 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
760 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
761 lu<FloatComplexMatrix>::update (const FloatComplexColumnVector& u, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
762 const FloatComplexColumnVector& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
763 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
764 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
765 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
766 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
767 FloatComplexMatrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
768 FloatComplexMatrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
769 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
770 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
771 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
772 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
773 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
774 if (u.numel () == m && v.numel () == n) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
775 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
776 FloatComplexColumnVector utmp = u; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
777 FloatComplexColumnVector vtmp = v; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
778 F77_XFCN (clu1up, CLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
779 utmp.fortran_vec (), vtmp.fortran_vec ())); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
780 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
781 else |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
782 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
783 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
784 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
785 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
786 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
787 lu<FloatComplexMatrix>::update (const FloatComplexMatrix& u, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
788 const FloatComplexMatrix& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
789 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
790 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
791 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
792 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
793 FloatComplexMatrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
794 FloatComplexMatrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
795 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
796 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
797 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
798 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
799 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
800 if (u.rows () != m || v.rows () != n || u.cols () != v.cols ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
801 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
802 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
803 for (volatile octave_idx_type i = 0; i < u.cols (); i++) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
804 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
805 FloatComplexColumnVector utmp = u.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
806 FloatComplexColumnVector vtmp = v.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
807 F77_XFCN (clu1up, CLU1UP, (m, n, l.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
808 m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
809 utmp.fortran_vec (), vtmp.fortran_vec ())); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
810 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
811 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
812 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
813 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
814 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
815 lu<FloatComplexMatrix>::update_piv (const FloatComplexColumnVector& u, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
816 const FloatComplexColumnVector& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
817 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
818 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
819 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
820 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
821 FloatComplexMatrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
822 FloatComplexMatrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
823 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
824 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
825 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
826 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
827 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
828 if (u.numel () != m || v.numel () != n) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
829 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
830 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
831 FloatComplexColumnVector utmp = u; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
832 FloatComplexColumnVector vtmp = v; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
833 OCTAVE_LOCAL_BUFFER (FloatComplex, w, m); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
834 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
835 F77_XFCN (clup1up, CLUP1UP, (m, n, l.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
836 m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
837 ipvt.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
838 utmp.data (), vtmp.data (), w)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
839 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
840 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
841 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
842 template <> |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
843 void |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
844 lu<FloatComplexMatrix>::update_piv (const FloatComplexMatrix& u, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
845 const FloatComplexMatrix& v) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
846 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
847 if (packed ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
848 unpack (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
849 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
850 FloatComplexMatrix& l = l_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
851 FloatComplexMatrix& r = a_fact; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
852 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
853 octave_idx_type m = l.rows (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
854 octave_idx_type n = r.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
855 octave_idx_type k = l.columns (); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
856 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
857 if (u.rows () != m || v.rows () != n || u.cols () != v.cols ()) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
858 (*current_liboctave_error_handler) ("luupdate: dimensions mismatch"); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
859 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
860 OCTAVE_LOCAL_BUFFER (FloatComplex, w, m); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
861 for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
862 for (volatile octave_idx_type i = 0; i < u.cols (); i++) |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
863 { |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
864 FloatComplexColumnVector utmp = u.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
865 FloatComplexColumnVector vtmp = v.column (i); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
866 F77_XFCN (clup1up, CLUP1UP, (m, n, l.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
867 m, r.fortran_vec (), k, |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
868 ipvt.fortran_vec (), |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
869 utmp.data (), vtmp.data (), w)); |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
870 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
871 for (octave_idx_type i = 0; i < m; i++) ipvt(i) -= 1; // decrement |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
872 } |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
873 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
874 #endif |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
875 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
876 // Instantiations we need. |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
877 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
878 template class lu<Matrix>; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
879 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
880 template class lu<FloatMatrix>; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
881 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
882 template class lu<ComplexMatrix>; |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
883 |
7e67c7f82fc1
better use of templates for lu factorization classes
John W. Eaton <jwe@octave.org>
parents:
21202
diff
changeset
|
884 template class lu<FloatComplexMatrix>; |