Mercurial > octave
annotate liboctave/numeric/lu.cc @ 22133:59cadee1c74b
new macros for F77 data types
* f77-fcn.h (F77_DBLE, F77_REAL, F77_DBLE_CMPLX, F77_CMPLX, F77_INT,
F77_INT4, F77_LOGICAL): New macros.
* fortrandemo.cc, __pchip_deriv__.cc, dot.cc, interpreter.cc,
ordschur.cc, qz.cc, CColVector.cc, CMatrix.cc, CNDArray.cc,
CRowVector.cc, CSparse.cc, dColVector.cc, dMatrix.cc, dNDArray.cc,
dRowVector.cc, dSparse.cc, fCColVector.cc, fCMatrix.cc,
fCNDArray.cc, fCRowVector.cc, fColVector.cc, fMatrix.cc,
fNDArray.cc, fRowVector.cc, DASPK.cc, DASRT.cc, DASSL.cc, EIG.cc,
LSODE.cc, Quad.cc, aepbalance.cc, chol.cc, eigs-base.cc, fEIG.cc,
gepbalance.cc, hess.cc, lo-specfun.cc, lu.cc, oct-convn.cc,
oct-rand.cc, qr.cc, qrp.cc, randpoisson.cc, schur.cc, svd.cc:
Use new macros in declarations of Fortran subroutines.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 17 Jul 2016 12:42:37 -0400 |
parents | aba2e6293dd8 |
children | 407c66ae1e20 |
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 |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
44 F77_FUNC (dgetrf, DGETRF) (const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
45 F77_DBLE*, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
46 F77_INT*, F77_INT&); |
21271
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 |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
50 F77_FUNC (dlu1up, DLU1UP) (const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
51 F77_DBLE *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
52 F77_DBLE *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
53 F77_DBLE *, F77_DBLE *); |
21271
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 |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
56 F77_FUNC (dlup1up, DLUP1UP) (const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
57 F77_DBLE *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
58 F77_DBLE *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
59 F77_INT *, const F77_DBLE *, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
60 const F77_DBLE *, F77_DBLE *); |
21271
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 |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
64 F77_FUNC (sgetrf, SGETRF) (const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
65 F77_REAL*, const F77_INT&, F77_INT*, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
66 F77_INT&); |
21271
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 |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
70 F77_FUNC (slu1up, SLU1UP) (const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
71 F77_REAL *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
72 F77_REAL *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
73 F77_REAL *, F77_REAL *); |
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 |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
76 F77_FUNC (slup1up, SLUP1UP) (const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
77 F77_REAL *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
78 F77_REAL *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
79 F77_INT *, const F77_REAL *, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
80 const F77_REAL *, F77_REAL *); |
21271
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 |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
84 F77_FUNC (zgetrf, ZGETRF) (const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
85 F77_DBLE_CMPLX*, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
86 F77_INT*, F77_INT&); |
21271
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 |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
90 F77_FUNC (zlu1up, ZLU1UP) (const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
91 F77_DBLE_CMPLX *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
92 F77_DBLE_CMPLX *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
93 F77_DBLE_CMPLX *, F77_DBLE_CMPLX *); |
21271
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 |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
96 F77_FUNC (zlup1up, ZLUP1UP) (const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
97 F77_DBLE_CMPLX *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
98 F77_DBLE_CMPLX *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
99 F77_INT *, const F77_DBLE_CMPLX *, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
100 const F77_DBLE_CMPLX *, F77_DBLE_CMPLX *); |
21271
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 |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
104 F77_FUNC (cgetrf, CGETRF) (const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
105 F77_CMPLX*, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
106 F77_INT*, F77_INT&); |
21271
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 |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
110 F77_FUNC (clu1up, CLU1UP) (const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
111 F77_CMPLX *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
112 F77_CMPLX *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
113 F77_CMPLX *, F77_CMPLX *); |
21271
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 |
22133
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
116 F77_FUNC (clup1up, CLUP1UP) (const F77_INT&, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
117 F77_CMPLX *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
118 F77_CMPLX *, const F77_INT&, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
119 F77_INT *, const F77_CMPLX *, |
59cadee1c74b
new macros for F77 data types
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
120 const F77_CMPLX *, F77_CMPLX *); |
21271
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>; |