annotate liboctave/numeric/sparse-dmsolve.cc @ 31249:de6fc38c78c6

Make Jacobian types offered by dlsode.f accessible by lsode (bug #31626). * liboctave/numeric/LSODE-opts.in: Add options "jacobian type", "lower jacobian subdiagonals", and "upper jacobian subdiagonals". * liboctave/numeric/LSODE.cc (file scope, lsode_j, LSODE::do_integrate (double)): Handle new configurable Jacobian types. * build-aux/mk-opts.pl: Don't implicitly convert to integer in condition.
author Olaf Till <olaf.till@uni-jena.de>
date Fri, 12 Nov 2010 08:53:05 +0100
parents 796f54d4ddbf
children 597f3ee61a48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30435
diff changeset
3 // Copyright (C) 2006-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21219
diff changeset
27 # include "config.h"
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
28 #endif
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
29
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
30 #include <algorithm>
5794
1138ced03f14 [project @ 2006-05-08 20:23:04 by jwe]
jwe
parents: 5792
diff changeset
31
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
32 #include "CMatrix.h"
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
33 #include "CSparse.h"
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
34 #include "MArray.h"
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
35 #include "MSparse.h"
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents: 5775
diff changeset
36 #include "MatrixType.h"
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
37 #include "dSparse.h"
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
38 #include "lo-error.h"
30435
1f0a2689cab2 Use forward declarations for octave_int<T> where possible (bug #59820).
Markus Mützel <markus.muetzel@gmx.de>
parents: 30394
diff changeset
39 #include "oct-inttypes-fwd.h"
21186
7f35125714b4 don't install some internal headers and template sources
John W. Eaton <jwe@octave.org>
parents: 21177
diff changeset
40 #include "oct-locbuf.h"
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
41 #include "oct-sort.h"
21186
7f35125714b4 don't install some internal headers and template sources
John W. Eaton <jwe@octave.org>
parents: 21177
diff changeset
42 #include "oct-sparse.h"
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
43 #include "quit.h"
23462
314d980bee93 maint: Add '#include "XXX.h"' to XXX.cc files.
Rik <rik@octave.org>
parents: 23433
diff changeset
44 #include "sparse-dmsolve.h"
21186
7f35125714b4 don't install some internal headers and template sources
John W. Eaton <jwe@octave.org>
parents: 21177
diff changeset
45 #include "sparse-qr.h"
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
46
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21136
diff changeset
47 template <typename T>
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
48 static MSparse<T>
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29931
diff changeset
49 dmsolve_extract (const MSparse<T>& A, const octave_idx_type *Pinv,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
50 const octave_idx_type *Q, octave_idx_type rst,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
51 octave_idx_type rend, octave_idx_type cst,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
52 octave_idx_type cend, octave_idx_type maxnz = -1,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
53 bool lazy = false)
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
54 {
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17861
diff changeset
55 octave_idx_type nr = rend - rst;
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17861
diff changeset
56 octave_idx_type nc = cend - cst;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
57
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
58 maxnz = (maxnz < 0 ? A.nnz () : maxnz);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
59
14888
4315a39da4c9 Do computations with octave_uint64 to avoid overflow
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
60 octave_idx_type nz;
4315a39da4c9 Do computations with octave_uint64 to avoid overflow
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
61
4315a39da4c9 Do computations with octave_uint64 to avoid overflow
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
62 // Cast to uint64 to handle overflow in this multiplication
4315a39da4c9 Do computations with octave_uint64 to avoid overflow
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
63 if (octave_uint64 (nr)*octave_uint64 (nc) < octave_uint64 (maxnz))
14999
1316bfc6e260 Fix think-o in 4315a39da4c9
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14888
diff changeset
64 nz = nr*nc;
14888
4315a39da4c9 Do computations with octave_uint64 to avoid overflow
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
65 else
4315a39da4c9 Do computations with octave_uint64 to avoid overflow
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
66 nz = maxnz;
4315a39da4c9 Do computations with octave_uint64 to avoid overflow
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
67
4315a39da4c9 Do computations with octave_uint64 to avoid overflow
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 14138
diff changeset
68 MSparse<T> B (nr, nc, (nz < maxnz ? nz : maxnz));
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
69
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
70 // Some sparse functions can support lazy indexing (where elements
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
71 // in the row are in no particular order), even though octave in
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21724
diff changeset
72 // general can't. For those functions that can using it is a big
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
73 // win here in terms of speed.
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
74
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
75 if (lazy)
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
76 {
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
77 nz = 0;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
78
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
79 for (octave_idx_type j = cst ; j < cend ; j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
80 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
81 octave_idx_type qq = (Q ? Q[j] : j);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
82
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
83 B.xcidx (j - cst) = nz;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
84
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
85 for (octave_idx_type p = A.cidx (qq) ; p < A.cidx (qq+1) ; p++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
86 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
87 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
88
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
89 octave_idx_type r = (Pinv ? Pinv[A.ridx (p)] : A.ridx (p));
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
90
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
91 if (r >= rst && r < rend)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
92 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
93 B.xdata (nz) = A.data (p);
21602
47c76e56a1de maint: Remove extra space between end of statement and semicolon.
Rik <rik@octave.org>
parents: 21301
diff changeset
94 B.xridx (nz++) = r - rst;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
95 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
96 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
97 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
98
21602
47c76e56a1de maint: Remove extra space between end of statement and semicolon.
Rik <rik@octave.org>
parents: 21301
diff changeset
99 B.xcidx (cend - cst) = nz;
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
100 }
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
101 else
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
102 {
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
103 OCTAVE_LOCAL_BUFFER (T, X, rend - rst);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
104
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
105 octave_sort<octave_idx_type> sort;
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
106 octave_idx_type *ri = B.xridx ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
107
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
108 nz = 0;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
109
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
110 for (octave_idx_type j = cst ; j < cend ; j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
111 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
112 octave_idx_type qq = (Q ? Q[j] : j);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
113
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
114 B.xcidx (j - cst) = nz;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
115
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
116 for (octave_idx_type p = A.cidx (qq) ; p < A.cidx (qq+1) ; p++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
117 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
118 octave_quit ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
119
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
120 octave_idx_type r = (Pinv ? Pinv[A.ridx (p)] : A.ridx (p));
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
121
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
122 if (r >= rst && r < rend)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
123 {
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
124 X[r-rst] = A.data (p);
21602
47c76e56a1de maint: Remove extra space between end of statement and semicolon.
Rik <rik@octave.org>
parents: 21301
diff changeset
125 B.xridx (nz++) = r - rst;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
126 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
127 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
128
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
129 sort.sort (ri + B.xcidx (j - cst), nz - B.xcidx (j - cst));
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
130
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
131 for (octave_idx_type p = B.cidx (j - cst); p < nz; p++)
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
132 B.xdata (p) = X[B.xridx (p)];
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
133 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
134
21602
47c76e56a1de maint: Remove extra space between end of statement and semicolon.
Rik <rik@octave.org>
parents: 21301
diff changeset
135 B.xcidx (cend - cst) = nz;
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
136 }
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
137
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
138 return B;
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
139 }
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
140
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21136
diff changeset
141 template <typename T>
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
142 static MArray<T>
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29931
diff changeset
143 dmsolve_extract (const MArray<T>& m, const octave_idx_type *,
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
144 const octave_idx_type *, octave_idx_type r1,
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
145 octave_idx_type r2, octave_idx_type c1,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
146 octave_idx_type c2)
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
147 {
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
148 r2 -= 1;
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
149 c2 -= 1;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
150
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
151 if (r1 > r2)
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
152 std::swap (r1, r2);
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
153
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
154 if (c1 > c2)
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
155 std::swap (c1, c2);
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
156
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
157 octave_idx_type new_r = r2 - r1 + 1;
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
158 octave_idx_type new_c = c2 - c1 + 1;
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
159
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
160 MArray<T> result (dim_vector (new_r, new_c));
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
161
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
162 for (octave_idx_type j = 0; j < new_c; j++)
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
163 {
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
164 for (octave_idx_type i = 0; i < new_r; i++)
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
165 result.xelem (i, j) = m.elem (r1+i, c1+j);
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
166 }
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
167
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
168 return result;
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
169 }
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
170
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21136
diff changeset
171 template <typename T>
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
172 static void
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29931
diff changeset
173 dmsolve_insert (MArray<T>& a, const MArray<T>& b, const octave_idx_type *Q,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
174 octave_idx_type r, octave_idx_type c)
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
175 {
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
176 T *ax = a.fortran_vec ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
177
29931
7faff48840eb prefer data over fortran_vec for read-only access to data
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
178 const T *bx = b.data ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
179
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
180 octave_idx_type anr = a.rows ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
181
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
182 octave_idx_type nr = b.rows ();
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
183 octave_idx_type nc = b.cols ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
184
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
185 for (octave_idx_type j = 0; j < nc; j++)
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
186 {
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
187 octave_idx_type aoff = (c + j) * anr;
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
188 octave_idx_type boff = j * nr;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
189
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
190 for (octave_idx_type i = 0; i < nr; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
191 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
192 octave_quit ();
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
193 ax[Q[r + i] + aoff] = bx[i + boff];
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
194 }
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
195 }
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
196 }
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
197
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21136
diff changeset
198 template <typename T>
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
199 static void
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29931
diff changeset
200 dmsolve_insert (MSparse<T>& a, const MSparse<T>& b, const octave_idx_type *Q,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
201 octave_idx_type r, octave_idx_type c)
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
202 {
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
203 octave_idx_type b_rows = b.rows ();
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
204 octave_idx_type b_cols = b.cols ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
205
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
206 octave_idx_type nr = a.rows ();
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
207 octave_idx_type nc = a.cols ();
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
208
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
209 OCTAVE_LOCAL_BUFFER (octave_idx_type, Qinv, nr);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
210
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
211 for (octave_idx_type i = 0; i < nr; i++)
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
212 Qinv[Q[i]] = i;
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
213
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
214 // First count the number of elements in the final array
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
215 octave_idx_type nel = a.xcidx (c) + b.nnz ();
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
216
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
217 if (c + b_cols < nc)
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
218 nel += a.xcidx (nc) - a.xcidx (c + b_cols);
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
219
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
220 for (octave_idx_type i = c; i < c + b_cols; i++)
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
221 {
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
222 for (octave_idx_type j = a.xcidx (i); j < a.xcidx (i+1); j++)
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
223 {
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
224 if (Qinv[a.xridx (j)] < r || Qinv[a.xridx (j)] >= r + b_rows)
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
225 nel++;
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
226 }
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
227 }
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
228
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
229 OCTAVE_LOCAL_BUFFER (T, X, nr);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
230
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
231 octave_sort<octave_idx_type> sort;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
232
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
233 MSparse<T> tmp (a);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
234
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
235 a = MSparse<T> (nr, nc, nel);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
236
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
237 octave_idx_type *ri = a.xridx ();
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
238
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
239 for (octave_idx_type i = 0; i < tmp.cidx (c); i++)
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
240 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
241 a.xdata (i) = tmp.xdata (i);
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
242 a.xridx (i) = tmp.xridx (i);
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
243 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
244
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
245 for (octave_idx_type i = 0; i < c + 1; i++)
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
246 a.xcidx (i) = tmp.xcidx (i);
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
247
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
248 octave_idx_type ii = a.xcidx (c);
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
249
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
250 for (octave_idx_type i = c; i < c + b_cols; i++)
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
251 {
10142
829e69ec3110 make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
252 octave_quit ();
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
253
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
254 for (octave_idx_type j = tmp.xcidx (i); j < tmp.xcidx (i+1); j++)
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
255 {
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
256 if (Qinv[tmp.xridx (j)] < r || Qinv[tmp.xridx (j)] >= r + b_rows)
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
257 {
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
258 X[tmp.xridx (j)] = tmp.xdata (j);
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
259 a.xridx (ii++) = tmp.xridx (j);
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
260 }
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
261 }
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
262
10142
829e69ec3110 make OCTAVE_QUIT a function
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
263 octave_quit ();
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
264
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
265 for (octave_idx_type j = b.cidx (i-c); j < b.cidx (i-c+1); j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
266 {
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
267 X[Q[r + b.ridx (j)]] = b.data (j);
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
268 a.xridx (ii++) = Q[r + b.ridx (j)];
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
269 }
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
270
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
271 sort.sort (ri + a.xcidx (i), ii - a.xcidx (i));
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
272
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
273 for (octave_idx_type p = a.xcidx (i); p < ii; p++)
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
274 a.xdata (p) = X[a.xridx (p)];
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
275
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
276 a.xcidx (i+1) = ii;
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
277 }
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
278
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
279 for (octave_idx_type i = c + b_cols; i < nc; i++)
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
280 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
281 for (octave_idx_type j = tmp.xcidx (i); j < tmp.cidx (i+1); j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
282 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
283 a.xdata (ii) = tmp.xdata (j);
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
284 a.xridx (ii++) = tmp.xridx (j);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
285 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
286
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
287 a.xcidx (i+1) = ii;
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
288 }
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
289 }
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
290
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21136
diff changeset
291 template <typename T, typename RT>
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
292 static void
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29931
diff changeset
293 dmsolve_permute (MArray<RT>& a, const MArray<T>& b, const octave_idx_type *p)
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
294 {
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
295 octave_idx_type b_nr = b.rows ();
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
296 octave_idx_type b_nc = b.cols ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
297
29931
7faff48840eb prefer data over fortran_vec for read-only access to data
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
298 const T *Bx = b.data ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
299
11574
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
300 a.resize (dim_vector (b_nr, b_nc));
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
301
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
302 RT *Btx = a.fortran_vec ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
303
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
304 for (octave_idx_type j = 0; j < b_nc; j++)
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
305 {
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
306 octave_idx_type off = j * b_nr;
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
307 for (octave_idx_type i = 0; i < b_nr; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
308 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
309 octave_quit ();
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
310 Btx[p[i] + off] = Bx[ i + off];
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
311 }
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
312 }
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
313 }
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
314
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21136
diff changeset
315 template <typename T, typename RT>
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
316 static void
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 29931
diff changeset
317 dmsolve_permute (MSparse<RT>& a, const MSparse<T>& b, const octave_idx_type *p)
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
318 {
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
319 octave_idx_type b_nr = b.rows ();
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
320 octave_idx_type b_nc = b.cols ();
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
321 octave_idx_type b_nz = b.nnz ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
322
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
323 octave_idx_type nz = 0;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
324
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
325 a = MSparse<RT> (b_nr, b_nc, b_nz);
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
326 octave_sort<octave_idx_type> sort;
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
327 octave_idx_type *ri = a.xridx ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
328
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
329 OCTAVE_LOCAL_BUFFER (RT, X, b_nr);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
330
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
331 a.xcidx (0) = 0;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
332
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
333 for (octave_idx_type j = 0; j < b_nc; j++)
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
334 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
335 for (octave_idx_type i = b.cidx (j); i < b.cidx (j+1); i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
336 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
337 octave_quit ();
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
338 octave_idx_type r = p[b.ridx (i)];
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
339 X[r] = b.data (i);
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
340 a.xridx (nz++) = p[b.ridx (i)];
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
341 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
342
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
343 sort.sort (ri + a.xcidx (j), nz - a.xcidx (j));
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
344
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
345 for (octave_idx_type i = a.cidx (j); i < nz; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
346 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
347 octave_quit ();
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
348 a.xdata (i) = X[a.xridx (i)];
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
349 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
350
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
351 a.xcidx (j+1) = nz;
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
352 }
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
353 }
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
354
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
355 #if defined (HAVE_CXSPARSE)
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21602
diff changeset
356
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
357 static void
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
358 solve_singularity_warning (double)
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
359 {
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
360 // Dummy singularity handler so that LU solver doesn't flag
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
361 // an error for numerically rank defficient matrices
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
362 }
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
363
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21602
diff changeset
364 #endif
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21602
diff changeset
365
21139
538b57866b90 consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents: 21136
diff changeset
366 template <typename RT, typename ST, typename T>
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
367 RT
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23391
diff changeset
368 dmsolve (const ST& a, const T& b, octave_idx_type& info)
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
369 {
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21602
diff changeset
370 RT retval;
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21602
diff changeset
371
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21691
diff changeset
372 #if defined (HAVE_CXSPARSE)
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
373
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
374 octave_idx_type nr = a.rows ();
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
375 octave_idx_type nc = a.cols ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
376
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
377 octave_idx_type b_nr = b.rows ();
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
378 octave_idx_type b_nc = b.cols ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
379
6924
be176b7e110a [project @ 2007-09-25 19:08:19 by dbateman]
dbateman
parents: 5797
diff changeset
380 if (nr < 0 || nc < 0 || nr != b_nr)
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
381 (*current_liboctave_error_handler)
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
382 ("matrix dimension mismatch in solution of minimum norm problem");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21109
diff changeset
383
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21109
diff changeset
384 if (nr == 0 || nc == 0 || b_nc == 0)
6924
be176b7e110a [project @ 2007-09-25 19:08:19 by dbateman]
dbateman
parents: 5797
diff changeset
385 retval = RT (nc, b_nc, 0.0);
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
386 else
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
387 {
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
388 octave_idx_type nnz_remaining = a.nnz ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
389
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
390 CXSPARSE_DNAME () csm;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
391
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
392 csm.m = nr;
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
393 csm.n = nc;
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
394 csm.x = nullptr;
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
395 csm.nz = -1;
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
396 csm.nzmax = a.nnz ();
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
397
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
398 // Cast away const on A, with full knowledge that CSparse won't touch it.
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
399 // Prevents the methods below from making a copy of the data.
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
400 csm.p = const_cast<octave::suitesparse_integer *>
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
401 (octave::to_suitesparse_intptr (a.cidx ()));
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
402 csm.i = const_cast<octave::suitesparse_integer *>
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
403 (octave::to_suitesparse_intptr (a.ridx ()));
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
404
5792
eb90c83b4f91 [project @ 2006-05-04 20:14:49 by dbateman]
dbateman
parents: 5785
diff changeset
405 CXSPARSE_DNAME (d) *dm = CXSPARSE_DNAME(_dmperm) (&csm, 0);
23391
209e749363a2 safe cast between SuiteSparse_long and octave_idx_type pointers (bug #50510)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
406 octave_idx_type *p = octave::to_octave_idx_type_ptr (dm->p);
209e749363a2 safe cast between SuiteSparse_long and octave_idx_type pointers (bug #50510)
John W. Eaton <jwe@octave.org>
parents: 23220
diff changeset
407 octave_idx_type *q = octave::to_octave_idx_type_ptr (dm->q);
21152
8ad3907b8fad require CXSparse 2.2 or later
John W. Eaton <jwe@octave.org>
parents: 21149
diff changeset
408
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
409 OCTAVE_LOCAL_BUFFER (octave_idx_type, pinv, nr);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
410
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
411 for (octave_idx_type i = 0; i < nr; i++)
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
412 pinv[p[i]] = i;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
413
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
414 RT btmp;
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
415 dmsolve_permute (btmp, b, pinv);
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
416 info = 0;
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
417
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
418 retval.resize (nc, b_nc);
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
419
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
420 // Leading over-determined block
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
421 if (dm->rr[2] < nr && dm->cc[3] < nc)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
422 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
423 ST m = dmsolve_extract (a, pinv, q, dm->rr[2], nr, dm->cc[3], nc,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
424 nnz_remaining, true);
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
425 nnz_remaining -= m.nnz ();
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
426 RT mtmp = octave::math::qrsolve (m, dmsolve_extract (btmp,
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
427 nullptr, nullptr,
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
428 dm->rr[2], b_nr,
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
429 0, b_nc),
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
430 info);
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
431 dmsolve_insert (retval, mtmp, q, dm->cc[3], 0);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
432
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20791
diff changeset
433 if (dm->rr[2] > 0 && ! info)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
434 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
435 m = dmsolve_extract (a, pinv, q, 0, dm->rr[2],
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
436 dm->cc[3], nc, nnz_remaining, true);
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
437 nnz_remaining -= m.nnz ();
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
438 RT ctmp = dmsolve_extract (btmp, nullptr, nullptr,
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
439 0, dm->rr[2], 0, b_nc);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
440 btmp.insert (ctmp - m * mtmp, 0, 0);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
441 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
442 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
443
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
444 // Structurally non-singular blocks
17861
870f3e12e163 maint: Use phrase "FIXME:" for problem areas in code.
Rik <rik@octave.org>
parents: 17769
diff changeset
445 // FIXME: Should use fine Dulmange-Mendelsohn decomposition here.
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20791
diff changeset
446 if (dm->rr[1] < dm->rr[2] && dm->cc[2] < dm->cc[3] && ! info)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
447 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
448 ST m = dmsolve_extract (a, pinv, q, dm->rr[1], dm->rr[2],
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
449 dm->cc[2], dm->cc[3], nnz_remaining, false);
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
450 nnz_remaining -= m.nnz ();
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
451 RT btmp2 = dmsolve_extract (btmp, nullptr, nullptr,
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
452 dm->rr[1], dm->rr[2],
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
453 0, b_nc);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
454 double rcond = 0.0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
455 MatrixType mtyp (MatrixType::Full);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
456 RT mtmp = m.solve (mtyp, btmp2, info, rcond,
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
457 solve_singularity_warning, false);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
458 if (info != 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
459 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
460 info = 0;
22317
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
461 mtmp = octave::math::qrsolve (m, btmp2, info);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
462 }
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
463
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
464 dmsolve_insert (retval, mtmp, q, dm->cc[2], 0);
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20791
diff changeset
465 if (dm->rr[1] > 0 && ! info)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
466 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
467 m = dmsolve_extract (a, pinv, q, 0, dm->rr[1], dm->cc[2],
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
468 dm->cc[3], nnz_remaining, true);
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
469 nnz_remaining -= m.nnz ();
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
470 RT ctmp = dmsolve_extract (btmp, nullptr, nullptr,
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
471 0, dm->rr[1], 0, b_nc);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
472 btmp.insert (ctmp - m * mtmp, 0, 0);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
473 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
474 }
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
475
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
476 // Trailing under-determined block
20955
77f5591878bf maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents: 20791
diff changeset
477 if (dm->rr[1] > 0 && dm->cc[2] > 0 && ! info)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
478 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
479 ST m = dmsolve_extract (a, pinv, q, 0, dm->rr[1], 0,
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
480 dm->cc[2], nnz_remaining, true);
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
481 RT mtmp = octave::math::qrsolve (m, dmsolve_extract (btmp, nullptr,
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
482 nullptr, 0,
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
483 dm->rr[1], 0,
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
484 b_nc),
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23462
diff changeset
485 info);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
486 dmsolve_insert (retval, mtmp, q, 0, 0);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
487 }
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
488
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
489 CXSPARSE_DNAME (_dfree) (dm);
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
490 }
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
491
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21602
diff changeset
492 #else
21109
bd1752782e56 Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents: 20955
diff changeset
493
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21602
diff changeset
494 octave_unused_parameter (a);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21602
diff changeset
495 octave_unused_parameter (b);
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21602
diff changeset
496 octave_unused_parameter (info);
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
497
15493
9ccf4ffb9fa2 error out when attempting sparse minimum solution and CXSparse is unavailable
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15271
diff changeset
498 (*current_liboctave_error_handler)
21109
bd1752782e56 Use err_disabled_feature, warn_disabled_feature throughout code base.
Rik <rik@octave.org>
parents: 20955
diff changeset
499 ("support for CXSparse was unavailable or disabled when liboctave was built");
21177
a10f60e13243 style fixes in liboctave/numeric directory
John W. Eaton <jwe@octave.org>
parents: 21176
diff changeset
500
5684
f39adfd0913d [project @ 2006-03-16 18:12:01 by dbateman]
dbateman
parents: 5683
diff changeset
501 #endif
21691
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21602
diff changeset
502
263d18409fdf Eliminate unused variable warnings for conditionally compiled code.
John W. Eaton <jwe@octave.org>
parents: 21602
diff changeset
503 return retval;
5683
a6bfe12c4c72 [project @ 2006-03-16 18:02:27 by dbateman]
dbateman
parents:
diff changeset
504 }
21219
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
505
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
506 // Instantiations we need.
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
507
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
508 template OCTAVE_API ComplexMatrix
21219
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
509 dmsolve<ComplexMatrix, SparseComplexMatrix, Matrix>
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
510 (const SparseComplexMatrix&, const Matrix&, octave_idx_type&);
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
511
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
512 template OCTAVE_API SparseComplexMatrix
21219
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
513 dmsolve<SparseComplexMatrix, SparseComplexMatrix, SparseMatrix>
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
514 (const SparseComplexMatrix&, const SparseMatrix&, octave_idx_type&);
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
515
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
516 template OCTAVE_API ComplexMatrix
21219
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
517 dmsolve<ComplexMatrix, SparseComplexMatrix, ComplexMatrix>
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
518 (const SparseComplexMatrix&, const ComplexMatrix&, octave_idx_type&);
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
519
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
520 template OCTAVE_API SparseComplexMatrix
21219
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
521 dmsolve<SparseComplexMatrix, SparseComplexMatrix, SparseComplexMatrix>
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
522 (const SparseComplexMatrix&, const SparseComplexMatrix&, octave_idx_type&);
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
523
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
524 template OCTAVE_API Matrix
21219
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
525 dmsolve<Matrix, SparseMatrix, Matrix>
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
526 (const SparseMatrix&, const Matrix&, octave_idx_type&);
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
527
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
528 template OCTAVE_API SparseMatrix
21219
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
529 dmsolve<SparseMatrix, SparseMatrix, SparseMatrix>
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
530 (const SparseMatrix&, const SparseMatrix&, octave_idx_type&);
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
531
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
532 template OCTAVE_API ComplexMatrix
21219
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
533 dmsolve<ComplexMatrix, SparseMatrix, ComplexMatrix>
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
534 (const SparseMatrix&, const ComplexMatrix&, octave_idx_type&);
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
535
29228
5c14f81e0937 Set API tags in files in liboctave/numeric (patch #8919).
Markus Mützel <markus.muetzel@gmx.de>
parents: 27923
diff changeset
536 template OCTAVE_API SparseComplexMatrix
21219
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
537 dmsolve<SparseComplexMatrix, SparseMatrix, SparseComplexMatrix>
ddf0a5f3a967 split interface and implementation for dmsolve
John W. Eaton <jwe@octave.org>
parents: 21202
diff changeset
538 (const SparseMatrix&, const SparseComplexMatrix&, octave_idx_type&);