annotate liboctave/base-lu.cc @ 10350:12884915a8e4

merge MArray classes & improve Array interface
author Jaroslav Hajek <highegg@gmail.com>
date Sat, 23 Jan 2010 21:41:03 +0100
parents 4c0cdbe0acca
children 4d1fc073fbb7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
1 /*
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
2
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8367
diff changeset
3 Copyright (C) 1996, 1997, 2002, 2003, 2004, 2005, 2007, 2008 John W. Eaton
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
4
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
5 This file is part of Octave.
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
6
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
7 Octave is free software; you can redistribute it and/or modify it
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
9 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
10 option) any later version.
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
11
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
12 Octave is distributed in the hope that it will be useful, but WITHOUT
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
15 for more details.
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
16
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
18 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 5307
diff changeset
19 <http://www.gnu.org/licenses/>.
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
20
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
21 */
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
22
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
23 #ifdef HAVE_CONFIG_H
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
24 #include <config.h>
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
25 #endif
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
26
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
27 #include "base-lu.h"
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
28
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
29 template <class lu_type>
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
30 base_lu<lu_type>::base_lu (const lu_type& l, const lu_type& u,
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
31 const PermMatrix& p)
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
32 : a_fact (u), l_fact (l), ipvt (p.pvec ())
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
33 {
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
34 if (l.columns () != u.rows ())
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
35 (*current_liboctave_error_handler) ("lu: dimension mismatch");
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
36 }
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
37
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
38 template <class lu_type>
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
39 bool
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
40 base_lu <lu_type> :: packed (void) const
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
41 {
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
42 return l_fact.dims () == dim_vector ();
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
43 }
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
44
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
45 template <class lu_type>
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
46 void
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
47 base_lu <lu_type> :: unpack (void)
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
48 {
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
49 if (packed ())
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
50 {
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
51 l_fact = L ();
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
52 a_fact = U (); // FIXME: sub-optimal
9697
51c17bd18563 omission in base-lu::unpack
Jaroslav Hajek <highegg@gmail.com>
parents: 9694
diff changeset
53 ipvt = getp ();
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
54 }
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
55 }
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
56
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
57 template <class lu_type>
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
58 lu_type
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
59 base_lu <lu_type> :: L (void) const
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
60 {
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
61 if (packed ())
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
62 {
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
63 octave_idx_type a_nr = a_fact.rows ();
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
64 octave_idx_type a_nc = a_fact.cols ();
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
65 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
66
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
67 lu_type l (a_nr, mn, lu_elt_type (0.0));
4811
198f3712c692 [project @ 2004-03-03 19:24:33 by jwe]
jwe
parents: 4329
diff changeset
68
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
69 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
70 {
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
71 if (i < a_nc)
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
72 l.xelem (i, i) = 1.0;
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
73
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
74 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
75 l.xelem (i, j) = a_fact.xelem (i, j);
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
76 }
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
77
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
78 return l;
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
79 }
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
80 else
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
81 return l_fact;
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
82 }
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
83
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
84 template <class lu_type>
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
85 lu_type
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
86 base_lu <lu_type> :: U (void) const
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
87 {
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
88 if (packed ())
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
89 {
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
90 octave_idx_type a_nr = a_fact.rows ();
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
91 octave_idx_type a_nc = a_fact.cols ();
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
92 octave_idx_type mn = (a_nr < a_nc ? a_nr : a_nc);
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
93
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
94 lu_type u (mn, a_nc, lu_elt_type (0.0));
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
95
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
96 for (octave_idx_type i = 0; i < mn; i++)
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
97 {
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
98 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
99 u.xelem (i, j) = a_fact.xelem (i, j);
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
100 }
4329
d53c33d93440 [project @ 2003-02-18 20:00:48 by jwe]
jwe
parents: 4192
diff changeset
101
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
102 return u;
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
103 }
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
104 else
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
105 return a_fact;
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
106 }
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
107
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
108 template <class lu_type>
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
109 lu_type
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
110 base_lu <lu_type> :: Y (void) const
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
111 {
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
112 if (! packed ())
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
113 (*current_liboctave_error_handler) ("lu: Y() not implemented for unpacked form.");
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
114 return a_fact;
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
115 }
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
116
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
117 template <class lu_type>
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
118 Array<octave_idx_type>
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
119 base_lu <lu_type> :: getp (void) const
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
120 {
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
121 if (packed ())
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
122 {
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
123 octave_idx_type a_nr = a_fact.rows ();
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
124
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10158
diff changeset
125 Array<octave_idx_type> pvt (a_nr, 1);
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
126
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
127 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
128 pvt.xelem (i) = i;
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
129
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
130 for (octave_idx_type i = 0; i < ipvt.length(); i++)
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 octave_idx_type k = ipvt.xelem (i);
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
133
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
134 if (k != i)
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
135 {
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
136 octave_idx_type tmp = pvt.xelem (k);
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
137 pvt.xelem (k) = pvt.xelem (i);
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
138 pvt.xelem (i) = tmp;
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
139 }
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
140 }
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
141
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
142 return pvt;
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
143 }
9694
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
144 else
50db3c5175b5 allow unpacked form of LU
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
145 return ipvt;
1991
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
146 }
413f6a81868f [project @ 1996-03-03 00:40:53 by jwe]
jwe
parents:
diff changeset
147
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
148 template <class lu_type>
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
149 PermMatrix
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
150 base_lu <lu_type> :: P (void) const
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
151 {
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
152 return PermMatrix (getp (), false);
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
153 }
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
154
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
155 template <class lu_type>
7515
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
156 ColumnVector
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
157 base_lu <lu_type> :: P_vec (void) const
7515
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
158 {
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
159 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
160
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
161 ColumnVector p (a_nr);
7515
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
162
8367
445d27d79f4e support permutation matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents: 7515
diff changeset
163 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
164
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
165 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
166 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
167
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
168 return p;
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
169 }
f3c00dc0912b Eliminate the rest of the dispatched sparse functions
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
170
9715
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
171 template <class lu_type>
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
172 bool
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
173 base_lu<lu_type>::regular (void) const
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
174 {
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
175 octave_idx_type k = std::min (a_fact.rows (), a_fact.columns ());
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
176 bool retval = true;
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
177 for (octave_idx_type i = 0; i < k; i++)
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
178 if (a_fact(i, i) == lu_elt_type ())
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
179 {
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
180 retval = false;
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
181 break;
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
182 }
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
183
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
184 return true;
9f27172fbd1e auto-set MatrixType from certain functions
Jaroslav Hajek <highegg@gmail.com>
parents: 9697
diff changeset
185 }