Mercurial > octave
annotate liboctave/array/MatrixType.cc @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | f3f3e3793fb5 |
children | 597f3ee61a48 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30394
diff
changeset
|
3 // Copyright (C) 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 //////////////////////////////////////////////////////////////////////// |
5785 | 25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21202
diff
changeset
|
27 # include "config.h" |
5785 | 28 #endif |
29 | |
26569
0e77df67b522
Add static compile-time checking of printf functions in liboctave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26435
diff
changeset
|
30 #include <cinttypes> |
5785 | 31 #include <vector> |
32 | |
33 #include "MatrixType.h" | |
34 #include "dMatrix.h" | |
19269
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
18676
diff
changeset
|
35 #include "fMatrix.h" |
5785 | 36 #include "CMatrix.h" |
19269
65554f5847ac
don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents:
18676
diff
changeset
|
37 #include "fCMatrix.h" |
5785 | 38 #include "dSparse.h" |
39 #include "CSparse.h" | |
40 #include "oct-spparms.h" | |
8377
25bc2d31e1bf
improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents:
7798
diff
changeset
|
41 #include "oct-locbuf.h" |
5785 | 42 |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
43 static void |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
44 warn_cached (void) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
45 { |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
46 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
47 ("Octave:matrix-type-info", "using cached matrix type"); |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
48 } |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
49 |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
50 static void |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
51 warn_invalid (void) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
52 { |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
53 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
54 ("Octave:matrix-type-info", "invalid matrix type"); |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
55 } |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
56 |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
57 static void |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
58 warn_calculating_sparse_type (void) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
59 { |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
60 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
61 ("Octave:matrix-type-info", "calculating sparse matrix type"); |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
62 } |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
63 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
64 // FIXME: There is a large code duplication here |
5785 | 65 |
5892 | 66 MatrixType::MatrixType (void) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
67 : m_type (MatrixType::Unknown), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
68 m_sp_bandden (octave::sparse_params::get_bandden ()), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
69 m_bandden (0), m_upper_band (0), m_lower_band (0), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
70 m_dense (false), m_full (false), m_nperm (0), m_perm (nullptr) { } |
5785 | 71 |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
72 MatrixType::MatrixType (const MatrixType& a) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
73 : m_type (a.m_type), m_sp_bandden (a.m_sp_bandden), m_bandden (a.m_bandden), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
74 m_upper_band (a.m_upper_band), m_lower_band (a.m_lower_band), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
75 m_dense (a.m_dense), m_full (a.m_full), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
76 m_nperm (a.m_nperm), m_perm (nullptr) |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
77 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
78 if (m_nperm != 0) |
5785 | 79 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
80 m_perm = new octave_idx_type [m_nperm]; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
81 for (octave_idx_type i = 0; i < m_nperm; i++) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
82 m_perm[i] = a.m_perm[i]; |
5785 | 83 } |
84 } | |
85 | |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
20955
diff
changeset
|
86 template <typename T> |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
87 MatrixType::matrix_type |
10350
12884915a8e4
merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents:
10314
diff
changeset
|
88 matrix_real_probe (const MArray<T>& a) |
5785 | 89 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
90 MatrixType::matrix_type m_type; |
5785 | 91 octave_idx_type nrows = a.rows (); |
92 octave_idx_type ncols = a.cols (); | |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
93 |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
94 const T zero = 0; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
95 |
5785 | 96 if (ncols == nrows) |
97 { | |
98 bool upper = true; | |
99 bool lower = true; | |
100 bool hermitian = true; | |
101 | |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
102 // do the checks for lower/upper/hermitian all in one pass. |
15022
e47b4e8c2714
maint: Use space after OCTAVE_LOCAL_BUFFER invocation in liboctave source code.
Rik <rik@octave.org>
parents:
15020
diff
changeset
|
103 OCTAVE_LOCAL_BUFFER (T, diag, ncols); |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
104 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
105 for (octave_idx_type j = 0; |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
106 j < ncols && upper; j++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
107 { |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30085
diff
changeset
|
108 T d = a.elem (j, j); |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
109 upper = upper && (d != zero); |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
110 lower = lower && (d != zero); |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
111 hermitian = hermitian && (d > zero); |
10713
0e05ed9f2a62
improve some MatrixType code
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
112 diag[j] = d; |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
113 } |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
114 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
115 for (octave_idx_type j = 0; |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
116 j < ncols && (upper || lower || hermitian); j++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
117 { |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
118 for (octave_idx_type i = 0; i < j; i++) |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
119 { |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30085
diff
changeset
|
120 T aij = a.elem (i, j); |
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30085
diff
changeset
|
121 T aji = a.elem (j, i); |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
122 lower = lower && (aij == zero); |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
123 upper = upper && (aji == zero); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
124 hermitian = hermitian && (aij == aji |
10713
0e05ed9f2a62
improve some MatrixType code
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
125 && aij*aij < diag[i]*diag[j]); |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
126 } |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
127 } |
5785 | 128 |
129 if (upper) | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
130 m_type = MatrixType::Upper; |
5785 | 131 else if (lower) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
132 m_type = MatrixType::Lower; |
5785 | 133 else if (hermitian) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
134 m_type = MatrixType::Hermitian; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
135 else |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
136 m_type = MatrixType::Full; |
5785 | 137 } |
138 else | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
139 m_type = MatrixType::Rectangular; |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
140 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
141 return m_type; |
5785 | 142 } |
143 | |
21139
538b57866b90
consistently use "typename" intead of "class" in template declarations
John W. Eaton <jwe@octave.org>
parents:
20955
diff
changeset
|
144 template <typename T> |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
145 MatrixType::matrix_type |
23534
b6498c088fca
maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents:
23433
diff
changeset
|
146 matrix_complex_probe (const MArray<std::complex<T>>& a) |
5785 | 147 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
148 MatrixType::matrix_type m_type = MatrixType::Unknown; |
5785 | 149 octave_idx_type nrows = a.rows (); |
150 octave_idx_type ncols = a.cols (); | |
151 | |
10713
0e05ed9f2a62
improve some MatrixType code
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
152 const T zero = 0; |
0e05ed9f2a62
improve some MatrixType code
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
153 // get the real type |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
154 |
5785 | 155 if (ncols == nrows) |
156 { | |
157 bool upper = true; | |
158 bool lower = true; | |
159 bool hermitian = true; | |
160 | |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
161 // do the checks for lower/upper/hermitian all in one pass. |
15022
e47b4e8c2714
maint: Use space after OCTAVE_LOCAL_BUFFER invocation in liboctave source code.
Rik <rik@octave.org>
parents:
15020
diff
changeset
|
162 OCTAVE_LOCAL_BUFFER (T, diag, ncols); |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
163 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
164 for (octave_idx_type j = 0; |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
165 j < ncols && upper; j++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
166 { |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30085
diff
changeset
|
167 std::complex<T> d = a.elem (j, j); |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
168 upper = upper && (d != zero); |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
169 lower = lower && (d != zero); |
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
|
170 hermitian = hermitian && (d.real () > zero && d.imag () == zero); |
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
|
171 diag[j] = d.real (); |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
172 } |
5785 | 173 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
174 for (octave_idx_type j = 0; |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
175 j < ncols && (upper || lower || hermitian); j++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
176 { |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
177 for (octave_idx_type i = 0; i < j; i++) |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
178 { |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30085
diff
changeset
|
179 std::complex<T> aij = a.elem (i, j); |
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30085
diff
changeset
|
180 std::complex<T> aji = a.elem (j, i); |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
181 lower = lower && (aij == zero); |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
182 upper = upper && (aji == zero); |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22246
diff
changeset
|
183 hermitian = hermitian && (aij == octave::math::conj (aji) |
10713
0e05ed9f2a62
improve some MatrixType code
Jaroslav Hajek <highegg@gmail.com>
parents:
10521
diff
changeset
|
184 && std::norm (aij) < diag[i]*diag[j]); |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
185 } |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
186 } |
5785 | 187 |
188 if (upper) | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
189 m_type = MatrixType::Upper; |
5785 | 190 else if (lower) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
191 m_type = MatrixType::Lower; |
5785 | 192 else if (hermitian) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
193 m_type = MatrixType::Hermitian; |
26435
590643c853bd
MatrixType.cc: Fix static analyzer detected issues (bug #55347).
Rik <rik@octave.org>
parents:
26376
diff
changeset
|
194 else |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
195 m_type = MatrixType::Full; |
5785 | 196 } |
197 else | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
198 m_type = MatrixType::Rectangular; |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
199 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
200 return m_type; |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
201 } |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
202 |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
203 MatrixType::MatrixType (const Matrix& a) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
204 : m_type (MatrixType::Unknown), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
205 m_sp_bandden (0), m_bandden (0), m_upper_band (0), m_lower_band (0), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
206 m_dense (false), m_full (true), m_nperm (0), m_perm (nullptr) |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
207 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
208 m_type = matrix_real_probe (a); |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
209 } |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
210 |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
211 MatrixType::MatrixType (const ComplexMatrix& a) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
212 : m_type (MatrixType::Unknown), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
213 m_sp_bandden (0), m_bandden (0), m_upper_band (0), m_lower_band (0), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
214 m_dense (false), m_full (true), m_nperm (0), m_perm (nullptr) |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
215 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
216 m_type = matrix_complex_probe (a); |
5785 | 217 } |
218 | |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
219 MatrixType::MatrixType (const FloatMatrix& a) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
220 : m_type (MatrixType::Unknown), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
221 m_sp_bandden (0), m_bandden (0), m_upper_band (0), m_lower_band (0), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
222 m_dense (false), m_full (true), m_nperm (0), m_perm (nullptr) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
223 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
224 m_type = matrix_real_probe (a); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
225 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
226 |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
227 MatrixType::MatrixType (const FloatComplexMatrix& a) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
228 : m_type (MatrixType::Unknown), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
229 m_sp_bandden (0), m_bandden (0), m_upper_band (0), m_lower_band (0), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
230 m_dense (false), m_full (true), m_nperm (0), m_perm (nullptr) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
231 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
232 m_type = matrix_complex_probe (a); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
233 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
234 |
22246
fa917f1f0faf
MatrixType: remove duplicate code for SparseMatrix and ComplexSparseMatrix.
Carnë Draug <carandraug@octave.org>
parents:
22241
diff
changeset
|
235 |
fa917f1f0faf
MatrixType: remove duplicate code for SparseMatrix and ComplexSparseMatrix.
Carnë Draug <carandraug@octave.org>
parents:
22241
diff
changeset
|
236 template <typename T> |
fa917f1f0faf
MatrixType: remove duplicate code for SparseMatrix and ComplexSparseMatrix.
Carnë Draug <carandraug@octave.org>
parents:
22241
diff
changeset
|
237 MatrixType::MatrixType (const MSparse<T>& a) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
238 : m_type (MatrixType::Unknown), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
239 m_sp_bandden (0), m_bandden (0), m_upper_band (0), m_lower_band (0), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
240 m_dense (false), m_full (false), m_nperm (0), m_perm (nullptr) |
5785 | 241 { |
242 octave_idx_type nrows = a.rows (); | |
243 octave_idx_type ncols = a.cols (); | |
244 octave_idx_type nm = (ncols < nrows ? ncols : nrows); | |
10506
bdf5d85cfc5e
replace nzmax by nnz where appropriate in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
10350
diff
changeset
|
245 octave_idx_type nnz = a.nnz (); |
5785 | 246 |
29872
df2cdf42a909
update coding style for octave_sparse_params class
John W. Eaton <jwe@octave.org>
parents:
29603
diff
changeset
|
247 if (octave::sparse_params::get_key ("spumoni") != 0.) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
248 warn_calculating_sparse_type (); |
5785 | 249 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
250 m_sp_bandden = octave::sparse_params::get_bandden (); |
5785 | 251 bool maybe_hermitian = false; |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
252 m_type = MatrixType::Full; |
5785 | 253 |
254 if (nnz == nm) | |
255 { | |
256 matrix_type tmp_typ = MatrixType::Diagonal; | |
257 octave_idx_type i; | |
258 // Maybe the matrix is diagonal | |
259 for (i = 0; i < nm; i++) | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
260 { |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
261 if (a.cidx (i+1) != a.cidx (i) + 1) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
262 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
263 tmp_typ = MatrixType::Full; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
264 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
265 } |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
266 if (a.ridx (i) != i) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
267 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
268 tmp_typ = MatrixType::Permuted_Diagonal; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
269 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
270 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
271 } |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
272 |
5785 | 273 if (tmp_typ == MatrixType::Permuted_Diagonal) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
274 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
275 std::vector<bool> found (nrows); |
5785 | 276 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
277 for (octave_idx_type j = 0; j < i; j++) |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
278 found[j] = true; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
279 for (octave_idx_type j = i; j < nrows; j++) |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
280 found[j] = false; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
281 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
282 for (octave_idx_type j = i; j < nm; j++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
283 { |
19864
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
284 if ((a.cidx (j+1) > a.cidx (j) + 1) |
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
285 || ((a.cidx (j+1) == a.cidx (j) + 1) && found[a.ridx (j)])) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
286 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
287 tmp_typ = MatrixType::Full; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
288 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
289 } |
15020
560317fd5977
maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents:
15018
diff
changeset
|
290 found[a.ridx (j)] = true; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
291 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
292 } |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
293 m_type = tmp_typ; |
5785 | 294 } |
295 | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
296 if (m_type == MatrixType::Full) |
5785 | 297 { |
298 // Search for banded, upper and lower triangular matrices | |
299 bool singular = false; | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
300 m_upper_band = 0; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
301 m_lower_band = 0; |
5785 | 302 for (octave_idx_type j = 0; j < ncols; j++) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
303 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
304 bool zero_on_diagonal = false; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
305 if (j < nrows) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
306 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
307 zero_on_diagonal = true; |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
308 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) |
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
309 if (a.ridx (i) == j) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
310 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
311 zero_on_diagonal = false; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
312 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
313 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
314 } |
5785 | 315 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
316 if (zero_on_diagonal) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
317 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
318 singular = true; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
319 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
320 } |
5785 | 321 |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
322 if (a.cidx (j+1) != a.cidx (j)) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
323 { |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
324 octave_idx_type ru = a.ridx (a.cidx (j)); |
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
325 octave_idx_type rl = a.ridx (a.cidx (j+1)-1); |
5785 | 326 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
327 if (j - ru > m_upper_band) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
328 m_upper_band = j - ru; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
329 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
330 if (rl - j > m_lower_band) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
331 m_lower_band = rl - j; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
332 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
333 } |
5785 | 334 |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
19864
diff
changeset
|
335 if (! singular) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
336 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
337 m_bandden = double (nnz) / |
30394
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30085
diff
changeset
|
338 (double (ncols) * (double (m_lower_band) + |
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30085
diff
changeset
|
339 double (m_upper_band)) - |
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30085
diff
changeset
|
340 0.5 * double (m_upper_band + 1) * double (m_upper_band) - |
f3f3e3793fb5
maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents:
30085
diff
changeset
|
341 0.5 * double (m_lower_band + 1) * double (m_lower_band)); |
5785 | 342 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
343 if (nrows == ncols && m_sp_bandden != 1. && m_bandden > m_sp_bandden) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
344 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
345 if (m_upper_band == 1 && m_lower_band == 1) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
346 m_type = MatrixType::Tridiagonal; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
347 else |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
348 m_type = MatrixType::Banded; |
5785 | 349 |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26569
diff
changeset
|
350 octave_idx_type nnz_in_band |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
351 = ((m_upper_band + m_lower_band + 1) * nrows |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
352 - (1 + m_upper_band) * m_upper_band / 2 |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
353 - (1 + m_lower_band) * m_lower_band / 2); |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26569
diff
changeset
|
354 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
355 if (nnz_in_band == nnz) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
356 m_dense = true; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
357 else |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
358 m_dense = false; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
359 } |
22241
71d86e88589f
chol2inv: fix support for sparse matrices by fixing MatrixType (bug #36437)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
22022
diff
changeset
|
360 |
71d86e88589f
chol2inv: fix support for sparse matrices by fixing MatrixType (bug #36437)
Barbara Locsi <locsi.barbara@gmail.com>
parents:
22022
diff
changeset
|
361 // If a matrix is Banded but also Upper/Lower, set to the latter. |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
362 if (m_upper_band == 0) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
363 m_type = MatrixType::Lower; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
364 else if (m_lower_band == 0) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
365 m_type = MatrixType::Upper; |
5785 | 366 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
367 if (m_upper_band == m_lower_band && nrows == ncols) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
368 maybe_hermitian = true; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
369 } |
5785 | 370 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
371 if (m_type == MatrixType::Full) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
372 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
373 // Search for a permuted triangular matrix, and test if |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
374 // permutation is singular |
5785 | 375 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
376 // FIXME: Perhaps this should be based on a dmperm algorithm? |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
377 bool found = false; |
5785 | 378 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
379 m_nperm = ncols; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
380 m_perm = new octave_idx_type [ncols]; |
5785 | 381 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
382 for (octave_idx_type i = 0; i < ncols; i++) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
383 m_perm[i] = -1; |
5785 | 384 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
385 for (octave_idx_type i = 0; i < nm; i++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
386 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
387 found = false; |
5785 | 388 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
389 for (octave_idx_type j = 0; j < ncols; j++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
390 { |
19864
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
391 if ((a.cidx (j+1) - a.cidx (j)) > 0 |
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
392 && (a.ridx (a.cidx (j+1)-1) == i)) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
393 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
394 m_perm[i] = j; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
395 found = true; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
396 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
397 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
398 } |
5785 | 399 |
20955
77f5591878bf
maint: Use '! expr' rather than '!expr' to conform to coding guidelines.
Rik <rik@octave.org>
parents:
19864
diff
changeset
|
400 if (! found) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
401 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
402 } |
5785 | 403 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
404 if (found) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
405 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
406 m_type = MatrixType::Permuted_Upper; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
407 if (ncols > nrows) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
408 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
409 octave_idx_type k = nrows; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
410 for (octave_idx_type i = 0; i < ncols; i++) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
411 if (m_perm[i] == -1) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
412 m_perm[i] = k++; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
413 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
414 } |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
415 else if (a.cidx (nm) == a.cidx (ncols)) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
416 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
417 m_nperm = nrows; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
418 delete [] m_perm; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
419 m_perm = new octave_idx_type [nrows]; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
420 OCTAVE_LOCAL_BUFFER (octave_idx_type, tmp, nrows); |
5785 | 421 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
422 for (octave_idx_type i = 0; i < nrows; i++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
423 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
424 m_perm[i] = -1; |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
425 tmp[i] = -1; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
426 } |
5785 | 427 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
428 for (octave_idx_type j = 0; j < ncols; j++) |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
429 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
430 m_perm[a.ridx (i)] = j; |
5785 | 431 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
432 found = true; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
433 for (octave_idx_type i = 0; i < nm; i++) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
434 if (m_perm[i] == -1) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
435 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
436 found = false; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
437 break; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
438 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
439 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
440 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
441 tmp[m_perm[i]] = 1; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
442 } |
5785 | 443 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
444 if (found) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
445 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
446 octave_idx_type k = ncols; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
447 for (octave_idx_type i = 0; i < nrows; i++) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
448 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
449 if (tmp[i] == -1) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
450 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
451 if (k < nrows) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
452 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
453 m_perm[k++] = i; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
454 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
455 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
456 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
457 found = false; |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
458 break; |
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 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
461 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
462 } |
5785 | 463 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
464 if (found) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
465 m_type = MatrixType::Permuted_Lower; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
466 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
467 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
468 delete [] m_perm; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
469 m_nperm = 0; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
470 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
471 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
472 else |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
473 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
474 delete [] m_perm; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
475 m_nperm = 0; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
476 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
477 } |
5785 | 478 |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
479 // FIXME: Disable lower under-determined and upper over-determined |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
480 // problems as being detected, and force to treat as singular |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
481 // as this seems to cause issues. |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
482 if (((m_type == MatrixType::Lower |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
483 || m_type == MatrixType::Permuted_Lower) |
19864
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
484 && nrows > ncols) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
485 || ((m_type == MatrixType::Upper |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
486 || m_type == MatrixType::Permuted_Upper) |
19864
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
487 && nrows < ncols)) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
488 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
489 if (m_type == MatrixType::Permuted_Upper |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
490 || m_type == MatrixType::Permuted_Lower) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
491 delete [] m_perm; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
492 m_nperm = 0; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
493 m_type = MatrixType::Rectangular; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
494 } |
5785 | 495 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
496 if (m_type == MatrixType::Full && ncols != nrows) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
497 m_type = MatrixType::Rectangular; |
5785 | 498 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
499 if (maybe_hermitian && (m_type == MatrixType::Full |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
500 || m_type == MatrixType::Tridiagonal |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
501 || m_type == MatrixType::Banded)) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
502 { |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
503 bool is_herm = true; |
5785 | 504 |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
505 // first, check whether the diagonal is positive & extract it |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
506 ColumnVector diag (ncols); |
5785 | 507 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
508 for (octave_idx_type j = 0; is_herm && j < ncols; j++) |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
509 { |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
510 is_herm = false; |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
511 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++) |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
512 { |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
513 if (a.ridx (i) == j) |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
514 { |
22246
fa917f1f0faf
MatrixType: remove duplicate code for SparseMatrix and ComplexSparseMatrix.
Carnë Draug <carandraug@octave.org>
parents:
22241
diff
changeset
|
515 T d = a.data (i); |
23708
750e42a35adc
Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents:
23534
diff
changeset
|
516 is_herm = (std::real (d) > 0.0 |
750e42a35adc
Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents:
23534
diff
changeset
|
517 && std::imag (d) == 0.0); |
750e42a35adc
Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents:
23534
diff
changeset
|
518 diag(j) = std::real (d); |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
519 break; |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
520 } |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
521 } |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
522 } |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
523 |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
524 // next, check symmetry and 2x2 positiveness |
5785 | 525 |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
526 for (octave_idx_type j = 0; is_herm && j < ncols; j++) |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
527 for (octave_idx_type i = a.cidx (j); is_herm && i < a.cidx (j+1); i++) |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
528 { |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
529 octave_idx_type k = a.ridx (i); |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
530 is_herm = k == j; |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
531 if (is_herm) |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
532 continue; |
5785 | 533 |
22246
fa917f1f0faf
MatrixType: remove duplicate code for SparseMatrix and ComplexSparseMatrix.
Carnë Draug <carandraug@octave.org>
parents:
22241
diff
changeset
|
534 T d = a.data (i); |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
535 if (std::norm (d) < diag(j)*diag(k)) |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
536 { |
22274
edcad35c364f
don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents:
22246
diff
changeset
|
537 d = octave::math::conj (d); |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
538 for (octave_idx_type l = a.cidx (k); l < a.cidx (k+1); l++) |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
539 { |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
540 if (a.ridx (l) == j) |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
541 { |
15018
3d8ace26c5b4
maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents:
14846
diff
changeset
|
542 is_herm = a.data (l) == d; |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
543 break; |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
544 } |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
545 } |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
546 } |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
547 } |
5785 | 548 |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
549 if (is_herm) |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
550 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
551 if (m_type == MatrixType::Full) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
552 m_type = MatrixType::Hermitian; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
553 else if (m_type == MatrixType::Banded) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
554 m_type = MatrixType::Banded_Hermitian; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
555 else |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
556 m_type = MatrixType::Tridiagonal_Hermitian; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
557 } |
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
558 } |
5785 | 559 } |
560 } | |
22246
fa917f1f0faf
MatrixType: remove duplicate code for SparseMatrix and ComplexSparseMatrix.
Carnë Draug <carandraug@octave.org>
parents:
22241
diff
changeset
|
561 |
fa917f1f0faf
MatrixType: remove duplicate code for SparseMatrix and ComplexSparseMatrix.
Carnë Draug <carandraug@octave.org>
parents:
22241
diff
changeset
|
562 |
5892 | 563 MatrixType::MatrixType (const matrix_type t, bool _full) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
564 : m_type (MatrixType::Unknown), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
565 m_sp_bandden (octave::sparse_params::get_bandden ()), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
566 m_bandden (0), m_upper_band (0), m_lower_band (0), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
567 m_dense (false), m_full (_full), m_nperm (0), m_perm (nullptr) |
5785 | 568 { |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
569 if (t == MatrixType::Unknown || t == MatrixType::Full |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
570 || t == MatrixType::Diagonal || t == MatrixType::Permuted_Diagonal |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
571 || t == MatrixType::Upper || t == MatrixType::Lower |
7798
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
572 || t == MatrixType::Tridiagonal || t == MatrixType::Tridiagonal_Hermitian |
42c42c640108
improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
573 || t == MatrixType::Rectangular) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
574 m_type = t; |
5785 | 575 else |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
576 warn_invalid (); |
5785 | 577 } |
578 | |
579 MatrixType::MatrixType (const matrix_type t, const octave_idx_type np, | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
580 const octave_idx_type *p, bool _full) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
581 : m_type (MatrixType::Unknown), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
582 m_sp_bandden (octave::sparse_params::get_bandden ()), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
583 m_bandden (0), m_upper_band (0), m_lower_band (0), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
584 m_dense (false), m_full (_full), m_nperm (0), m_perm (nullptr) |
5785 | 585 { |
19864
17d647821d61
maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
586 if ((t == MatrixType::Permuted_Upper || t == MatrixType::Permuted_Lower) |
23795
980f39c3ab90
Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents:
23708
diff
changeset
|
587 && np > 0 && p != nullptr) |
5785 | 588 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
589 m_type = t; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
590 m_nperm = np; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
591 m_perm = new octave_idx_type [m_nperm]; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
592 for (octave_idx_type i = 0; i < m_nperm; i++) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
593 m_perm[i] = p[i]; |
5785 | 594 } |
595 else | |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
596 warn_invalid (); |
5785 | 597 } |
598 | |
599 MatrixType::MatrixType (const matrix_type t, const octave_idx_type ku, | |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
600 const octave_idx_type kl, bool _full) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
601 : m_type (MatrixType::Unknown), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
602 m_sp_bandden (octave::sparse_params::get_bandden ()), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
603 m_bandden (0), m_upper_band (0), m_lower_band (0), |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
604 m_dense (false), m_full (_full), m_nperm (0), m_perm (nullptr) |
5785 | 605 { |
606 if (t == MatrixType::Banded || t == MatrixType::Banded_Hermitian) | |
607 { | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
608 m_type = t; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
609 m_upper_band = ku; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
610 m_lower_band = kl; |
5785 | 611 } |
612 else | |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
613 warn_invalid (); |
5785 | 614 } |
615 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
616 MatrixType::~MatrixType (void) |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
617 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
618 if (m_nperm != 0) |
5785 | 619 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
620 delete [] m_perm; |
5785 | 621 } |
622 } | |
623 | |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
624 MatrixType& |
5785 | 625 MatrixType::operator = (const MatrixType& a) |
626 { | |
627 if (this != &a) | |
628 { | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
629 m_type = a.m_type; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
630 m_sp_bandden = a.m_sp_bandden; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
631 m_bandden = a.m_bandden; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
632 m_upper_band = a.m_upper_band; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
633 m_lower_band = a.m_lower_band; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
634 m_dense = a.m_dense; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
635 m_full = a.m_full; |
5785 | 636 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
637 if (m_nperm) |
12564
61cd086e9aeb
Correct slight logical mistake in memleak patch (bug #32804)
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12563
diff
changeset
|
638 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
639 delete[] m_perm; |
12564
61cd086e9aeb
Correct slight logical mistake in memleak patch (bug #32804)
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12563
diff
changeset
|
640 } |
61cd086e9aeb
Correct slight logical mistake in memleak patch (bug #32804)
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
12563
diff
changeset
|
641 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
642 if (a.m_nperm != 0) |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
643 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
644 m_perm = new octave_idx_type [a.m_nperm]; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
645 for (octave_idx_type i = 0; i < a.m_nperm; i++) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
646 m_perm[i] = a.m_perm[i]; |
10314
07ebe522dac2
untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents:
10158
diff
changeset
|
647 } |
12563
681bb733f4f4
MatrixType:: plug memory leak (bug #32804).
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents:
11586
diff
changeset
|
648 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
649 m_nperm = a.m_nperm; |
5785 | 650 } |
651 | |
652 return *this; | |
653 } | |
654 | |
655 int | |
656 MatrixType::type (bool quiet) | |
657 { | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
658 if (m_type != MatrixType::Unknown |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
659 && (m_full || m_sp_bandden == octave::sparse_params::get_bandden ())) |
5785 | 660 { |
29872
df2cdf42a909
update coding style for octave_sparse_params class
John W. Eaton <jwe@octave.org>
parents:
29603
diff
changeset
|
661 if (! quiet && octave::sparse_params::get_key ("spumoni") != 0.) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
662 warn_cached (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
663 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
664 return m_type; |
5785 | 665 } |
666 | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
667 if (m_type != MatrixType::Unknown |
29872
df2cdf42a909
update coding style for octave_sparse_params class
John W. Eaton <jwe@octave.org>
parents:
29603
diff
changeset
|
668 && octave::sparse_params::get_key ("spumoni") != 0.) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
669 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
670 ("Octave:matrix-type-info", "invalidating matrix type"); |
5785 | 671 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
672 m_type = MatrixType::Unknown; |
5785 | 673 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
674 return m_type; |
5785 | 675 } |
676 | |
677 int | |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
678 MatrixType::type (const SparseMatrix& a) |
5785 | 679 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
680 if (m_type != MatrixType::Unknown |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
681 && (m_full || m_sp_bandden == octave::sparse_params::get_bandden ())) |
5785 | 682 { |
29872
df2cdf42a909
update coding style for octave_sparse_params class
John W. Eaton <jwe@octave.org>
parents:
29603
diff
changeset
|
683 if (octave::sparse_params::get_key ("spumoni") != 0.) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
684 warn_cached (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
685 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
686 return m_type; |
5785 | 687 } |
688 | |
689 MatrixType tmp_typ (a); | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
690 m_type = tmp_typ.m_type; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
691 m_sp_bandden = tmp_typ.m_sp_bandden; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
692 m_bandden = tmp_typ.m_bandden; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
693 m_upper_band = tmp_typ.m_upper_band; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
694 m_lower_band = tmp_typ.m_lower_band; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
695 m_dense = tmp_typ.m_dense; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
696 m_full = tmp_typ.m_full; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
697 m_nperm = tmp_typ.m_nperm; |
5785 | 698 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
699 if (m_nperm != 0) |
5785 | 700 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
701 m_perm = new octave_idx_type [m_nperm]; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
702 for (octave_idx_type i = 0; i < m_nperm; i++) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
703 m_perm[i] = tmp_typ.m_perm[i]; |
5785 | 704 } |
705 | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
706 return m_type; |
5785 | 707 } |
708 | |
709 int | |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
710 MatrixType::type (const SparseComplexMatrix& a) |
5785 | 711 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
712 if (m_type != MatrixType::Unknown |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
713 && (m_full || m_sp_bandden == octave::sparse_params::get_bandden ())) |
5785 | 714 { |
29872
df2cdf42a909
update coding style for octave_sparse_params class
John W. Eaton <jwe@octave.org>
parents:
29603
diff
changeset
|
715 if (octave::sparse_params::get_key ("spumoni") != 0.) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
716 warn_cached (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
717 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
718 return m_type; |
5785 | 719 } |
720 | |
721 MatrixType tmp_typ (a); | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
722 m_type = tmp_typ.m_type; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
723 m_sp_bandden = tmp_typ.m_sp_bandden; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
724 m_bandden = tmp_typ.m_bandden; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
725 m_upper_band = tmp_typ.m_upper_band; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
726 m_lower_band = tmp_typ.m_lower_band; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
727 m_dense = tmp_typ.m_dense; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
728 m_full = tmp_typ.m_full; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
729 m_nperm = tmp_typ.m_nperm; |
5785 | 730 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
731 if (m_nperm != 0) |
5785 | 732 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
733 m_perm = new octave_idx_type [m_nperm]; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
734 for (octave_idx_type i = 0; i < m_nperm; i++) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
735 m_perm[i] = tmp_typ.m_perm[i]; |
5785 | 736 } |
737 | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
738 return m_type; |
5785 | 739 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
740 |
5785 | 741 int |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
742 MatrixType::type (const Matrix& a) |
5785 | 743 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
744 if (m_type != MatrixType::Unknown) |
5785 | 745 { |
29872
df2cdf42a909
update coding style for octave_sparse_params class
John W. Eaton <jwe@octave.org>
parents:
29603
diff
changeset
|
746 if (octave::sparse_params::get_key ("spumoni") != 0.) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
747 warn_cached (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
748 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
749 return m_type; |
5785 | 750 } |
751 | |
752 MatrixType tmp_typ (a); | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
753 m_type = tmp_typ.m_type; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
754 m_full = tmp_typ.m_full; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
755 m_nperm = tmp_typ.m_nperm; |
5785 | 756 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
757 if (m_nperm != 0) |
5785 | 758 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
759 m_perm = new octave_idx_type [m_nperm]; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
760 for (octave_idx_type i = 0; i < m_nperm; i++) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
761 m_perm[i] = tmp_typ.m_perm[i]; |
5785 | 762 } |
763 | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
764 return m_type; |
5785 | 765 } |
766 | |
767 int | |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
768 MatrixType::type (const ComplexMatrix& a) |
5785 | 769 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
770 if (m_type != MatrixType::Unknown) |
5785 | 771 { |
29872
df2cdf42a909
update coding style for octave_sparse_params class
John W. Eaton <jwe@octave.org>
parents:
29603
diff
changeset
|
772 if (octave::sparse_params::get_key ("spumoni") != 0.) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
773 warn_cached (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
774 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
775 return m_type; |
5785 | 776 } |
777 | |
778 MatrixType tmp_typ (a); | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
779 m_type = tmp_typ.m_type; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
780 m_full = tmp_typ.m_full; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
781 m_nperm = tmp_typ.m_nperm; |
5785 | 782 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
783 if (m_nperm != 0) |
5785 | 784 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
785 m_perm = new octave_idx_type [m_nperm]; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
786 for (octave_idx_type i = 0; i < m_nperm; i++) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
787 m_perm[i] = tmp_typ.m_perm[i]; |
5785 | 788 } |
789 | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
790 return m_type; |
5785 | 791 } |
792 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
793 int |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
794 MatrixType::type (const FloatMatrix& a) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
795 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
796 if (m_type != MatrixType::Unknown) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
797 { |
29872
df2cdf42a909
update coding style for octave_sparse_params class
John W. Eaton <jwe@octave.org>
parents:
29603
diff
changeset
|
798 if (octave::sparse_params::get_key ("spumoni") != 0.) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
799 warn_cached (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
800 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
801 return m_type; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
802 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
803 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
804 MatrixType tmp_typ (a); |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
805 m_type = tmp_typ.m_type; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
806 m_full = tmp_typ.m_full; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
807 m_nperm = tmp_typ.m_nperm; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
808 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
809 if (m_nperm != 0) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
810 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
811 m_perm = new octave_idx_type [m_nperm]; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
812 for (octave_idx_type i = 0; i < m_nperm; i++) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
813 m_perm[i] = tmp_typ.m_perm[i]; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
814 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
815 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
816 return m_type; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
817 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
818 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
819 int |
23433
c9fab0bc983e
maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
820 MatrixType::type (const FloatComplexMatrix& a) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
821 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
822 if (m_type != MatrixType::Unknown) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
823 { |
29872
df2cdf42a909
update coding style for octave_sparse_params class
John W. Eaton <jwe@octave.org>
parents:
29603
diff
changeset
|
824 if (octave::sparse_params::get_key ("spumoni") != 0.) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
825 warn_cached (); |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
826 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
827 return m_type; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
828 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
829 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
830 MatrixType tmp_typ (a); |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
831 m_type = tmp_typ.m_type; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
832 m_full = tmp_typ.m_full; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
833 m_nperm = tmp_typ.m_nperm; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
834 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
835 if (m_nperm != 0) |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
836 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
837 m_perm = new octave_idx_type [m_nperm]; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
838 for (octave_idx_type i = 0; i < m_nperm; i++) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
839 m_perm[i] = tmp_typ.m_perm[i]; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
840 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
841 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
842 return m_type; |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
843 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
844 |
5785 | 845 void |
846 MatrixType::info () const | |
847 { | |
29872
df2cdf42a909
update coding style for octave_sparse_params class
John W. Eaton <jwe@octave.org>
parents:
29603
diff
changeset
|
848 if (octave::sparse_params::get_key ("spumoni") != 0.) |
5785 | 849 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
850 if (m_type == MatrixType::Unknown) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
851 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
852 ("Octave:matrix-type-info", "unknown matrix type"); |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
853 else if (m_type == MatrixType::Diagonal) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
854 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
855 ("Octave:matrix-type-info", "diagonal sparse matrix"); |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
856 else if (m_type == MatrixType::Permuted_Diagonal) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
857 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
858 ("Octave:matrix-type-info", "permuted diagonal sparse matrix"); |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
859 else if (m_type == MatrixType::Upper) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
860 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
861 ("Octave:matrix-type-info", "upper triangular matrix"); |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
862 else if (m_type == MatrixType::Lower) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
863 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
864 ("Octave:matrix-type-info", "lower triangular matrix"); |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
865 else if (m_type == MatrixType::Permuted_Upper) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
866 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
867 ("Octave:matrix-type-info", "permuted upper triangular matrix"); |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
868 else if (m_type == MatrixType::Permuted_Lower) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
869 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
870 ("Octave:matrix-type-info", "permuted lower triangular Matrix"); |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
871 else if (m_type == MatrixType::Banded) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
872 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
873 ("Octave:matrix-type-info", |
26569
0e77df67b522
Add static compile-time checking of printf functions in liboctave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26435
diff
changeset
|
874 "banded sparse matrix %" OCTAVE_IDX_TYPE_FORMAT "-1-" |
0e77df67b522
Add static compile-time checking of printf functions in liboctave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26435
diff
changeset
|
875 "%" OCTAVE_IDX_TYPE_FORMAT " (density %f)", |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
876 m_lower_band, m_upper_band, m_bandden); |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
877 else if (m_type == MatrixType::Banded_Hermitian) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
878 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
879 ("Octave:matrix-type-info", |
26569
0e77df67b522
Add static compile-time checking of printf functions in liboctave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26435
diff
changeset
|
880 "banded hermitian/symmetric sparse matrix %" OCTAVE_IDX_TYPE_FORMAT |
0e77df67b522
Add static compile-time checking of printf functions in liboctave.
Markus Mützel <markus.muetzel@gmx.de>
parents:
26435
diff
changeset
|
881 "-1-%" OCTAVE_IDX_TYPE_FORMAT " (density %f)", |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
882 m_lower_band, m_upper_band, m_bandden); |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
883 else if (m_type == MatrixType::Hermitian) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
884 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
885 ("Octave:matrix-type-info", "hermitian/symmetric matrix"); |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
886 else if (m_type == MatrixType::Tridiagonal) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
887 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
888 ("Octave:matrix-type-info", "tridiagonal sparse matrix"); |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
889 else if (m_type == MatrixType::Tridiagonal_Hermitian) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
890 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
891 ("Octave:matrix-type-info", |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
892 "hermitian/symmetric tridiagonal sparse matrix"); |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
893 else if (m_type == MatrixType::Rectangular) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
894 (*current_liboctave_warning_with_id_handler) |
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
895 ("Octave:matrix-type-info", "rectangular/singular matrix"); |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
896 else if (m_type == MatrixType::Full) |
19410
95c533ed464b
use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents:
19269
diff
changeset
|
897 (*current_liboctave_warning_with_id_handler) |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
898 ("Octave:matrix-type-info", "m_full matrix"); |
5785 | 899 } |
900 } | |
901 | |
902 void | |
903 MatrixType::mark_as_symmetric (void) | |
904 { | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
905 if (m_type == MatrixType::Tridiagonal |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
906 || m_type == MatrixType::Tridiagonal_Hermitian) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
907 m_type = MatrixType::Tridiagonal_Hermitian; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
908 else if (m_type == MatrixType::Banded |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
909 || m_type == MatrixType::Banded_Hermitian) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
910 m_type = MatrixType::Banded_Hermitian; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
911 else if (m_type == MatrixType::Full || m_type == MatrixType::Hermitian |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
912 || m_type == MatrixType::Unknown) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
913 m_type = MatrixType::Hermitian; |
5785 | 914 else |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
915 (*current_liboctave_error_handler) |
5785 | 916 ("Can not mark current matrix type as symmetric"); |
917 } | |
918 | |
919 void | |
920 MatrixType::mark_as_unsymmetric (void) | |
921 { | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
922 if (m_type == MatrixType::Tridiagonal |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
923 || m_type == MatrixType::Tridiagonal_Hermitian) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
924 m_type = MatrixType::Tridiagonal; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
925 else if (m_type == MatrixType::Banded |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
926 || m_type == MatrixType::Banded_Hermitian) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
927 m_type = MatrixType::Banded; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
928 else if (m_type == MatrixType::Full || m_type == MatrixType::Hermitian |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
929 || m_type == MatrixType::Unknown) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
930 m_type = MatrixType::Full; |
5785 | 931 } |
932 | |
933 void | |
17769
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
934 MatrixType::mark_as_permuted (const octave_idx_type np, |
49a5a4be04a1
maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
935 const octave_idx_type *p) |
5785 | 936 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
937 m_nperm = np; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
938 m_perm = new octave_idx_type [m_nperm]; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
939 for (octave_idx_type i = 0; i < m_nperm; i++) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
940 m_perm[i] = p[i]; |
5785 | 941 |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
942 if (m_type == MatrixType::Diagonal |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
943 || m_type == MatrixType::Permuted_Diagonal) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
944 m_type = MatrixType::Permuted_Diagonal; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
945 else if (m_type == MatrixType::Upper || m_type == MatrixType::Permuted_Upper) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
946 m_type = MatrixType::Permuted_Upper; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
947 else if (m_type == MatrixType::Lower || m_type == MatrixType::Permuted_Lower) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
948 m_type = MatrixType::Permuted_Lower; |
5785 | 949 else |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
950 (*current_liboctave_error_handler) |
5785 | 951 ("Can not mark current matrix type as symmetric"); |
952 } | |
953 | |
954 void | |
955 MatrixType::mark_as_unpermuted (void) | |
956 { | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
957 if (m_nperm) |
5785 | 958 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
959 m_nperm = 0; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
960 delete [] m_perm; |
5785 | 961 } |
962 | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
963 if (m_type == MatrixType::Diagonal |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
964 || m_type == MatrixType::Permuted_Diagonal) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
965 m_type = MatrixType::Diagonal; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
966 else if (m_type == MatrixType::Upper || m_type == MatrixType::Permuted_Upper) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
967 m_type = MatrixType::Upper; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
968 else if (m_type == MatrixType::Lower || m_type == MatrixType::Permuted_Lower) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
969 m_type = MatrixType::Lower; |
5785 | 970 } |
971 | |
972 MatrixType | |
973 MatrixType::transpose (void) const | |
974 { | |
975 MatrixType retval (*this); | |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
976 if (m_type == MatrixType::Upper) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
977 retval.m_type = MatrixType::Lower; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
978 else if (m_type == MatrixType::Permuted_Upper) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
979 retval.m_type = MatrixType::Permuted_Lower; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
980 else if (m_type == MatrixType::Lower) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
981 retval.m_type = MatrixType::Upper; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
982 else if (m_type == MatrixType::Permuted_Lower) |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
983 retval.m_type = MatrixType::Permuted_Upper; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
984 else if (m_type == MatrixType::Banded) |
5785 | 985 { |
30085
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
986 retval.m_upper_band = m_lower_band; |
46001ac1b6b1
maint: use "m_" prefix for member variables in class MatrixType.
Rik <rik@octave.org>
parents:
29872
diff
changeset
|
987 retval.m_lower_band = m_upper_band; |
5785 | 988 } |
989 | |
990 return retval; | |
991 } | |
22275
e70183e8264f
* MatrixType.cc: Instantiate template constructors we need.
John W. Eaton <jwe@octave.org>
parents:
22274
diff
changeset
|
992 |
e70183e8264f
* MatrixType.cc: Instantiate template constructors we need.
John W. Eaton <jwe@octave.org>
parents:
22274
diff
changeset
|
993 // Instantiate MatrixType template constructors that we need. |
e70183e8264f
* MatrixType.cc: Instantiate template constructors we need.
John W. Eaton <jwe@octave.org>
parents:
22274
diff
changeset
|
994 |
e70183e8264f
* MatrixType.cc: Instantiate template constructors we need.
John W. Eaton <jwe@octave.org>
parents:
22274
diff
changeset
|
995 template MatrixType::MatrixType (const MSparse<double>&); |
e70183e8264f
* MatrixType.cc: Instantiate template constructors we need.
John W. Eaton <jwe@octave.org>
parents:
22274
diff
changeset
|
996 template MatrixType::MatrixType (const MSparse<Complex>&); |