annotate liboctave/array/MatrixType.cc @ 20595:c1a6c31ac29a

eliminate more simple uses of error_state * ov-classdef.cc: Eliminate simple uses of error_state.
author John W. Eaton <jwe@octave.org>
date Tue, 06 Oct 2015 00:20:02 -0400
parents 17d647821d61
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1 /*
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
2
19731
4197fc428c7d maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents: 19444
diff changeset
3 Copyright (C) 2006-2015 David Bateman
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
4 Copyright (C) 2006 Andy Adler
10521
4d1fc073fbb7 add some missing copyright stmts
Jaroslav Hajek <highegg@gmail.com>
parents: 10506
diff changeset
5 Copyright (C) 2009 VZLU Prague
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
6
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6460
diff changeset
7 This file is part of Octave.
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6460
diff changeset
8
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
9 Octave is free software; you can redistribute it and/or modify it
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6460
diff changeset
11 Free Software Foundation; either version 3 of the License, or (at your
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6460
diff changeset
12 option) any later version.
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
13
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
14 Octave is distributed in the hope that it will be useful, but WITHOUT
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
17 for more details.
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
18
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6460
diff changeset
20 along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6460
diff changeset
21 <http://www.gnu.org/licenses/>.
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
22
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
23 */
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
24
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
25 #ifdef HAVE_CONFIG_H
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
26 #include <config.h>
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
27 #endif
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
28
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
29 #include <vector>
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
30
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
31 #include "MatrixType.h"
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
32 #include "dMatrix.h"
19303
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 18710
diff changeset
33 #include "fMatrix.h"
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
34 #include "CMatrix.h"
19303
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 18710
diff changeset
35 #include "fCMatrix.h"
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
36 #include "dSparse.h"
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
37 #include "CSparse.h"
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
38 #include "oct-spparms.h"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 7798
diff changeset
39 #include "oct-locbuf.h"
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
40
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
41 static void
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
42 warn_cached (void)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
43 {
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
44 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
45 ("Octave:matrix-type-info", "using cached matrix type");
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
46 }
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
47
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
48 static void
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
49 warn_invalid (void)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
50 {
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
51 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
52 ("Octave:matrix-type-info", "invalid matrix type");
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
53 }
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
54
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
55 static void
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
56 warn_calculating_sparse_type (void)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
57 {
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
58 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
59 ("Octave:matrix-type-info", "calculating sparse matrix type");
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
60 }
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
61
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
62 // FIXME: There is a large code duplication here
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
63
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
64 MatrixType::MatrixType (void)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
65 : typ (MatrixType::Unknown),
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
66 sp_bandden (octave_sparse_params::get_bandden ()),
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
67 bandden (0), upper_band (0),
6452
7e90124eddba [project @ 2007-03-24 22:18:14 by dbateman]
dbateman
parents: 6027
diff changeset
68 lower_band (0), dense (false), full (false), nperm (0), perm (0) { }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
69
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
70 MatrixType::MatrixType (const MatrixType &a)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
71 : typ (a.typ), sp_bandden (a.sp_bandden), bandden (a.bandden),
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
72 upper_band (a.upper_band), lower_band (a.lower_band),
11501
331fcc41ca23 data member initialization fixes
John W. Eaton <jwe@octave.org>
parents: 10713
diff changeset
73 dense (a.dense), full (a.full), nperm (a.nperm), perm (0)
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
74 {
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
75 if (nperm != 0)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
76 {
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
77 perm = new octave_idx_type [nperm];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
78 for (octave_idx_type i = 0; i < nperm; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
79 perm[i] = a.perm[i];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
80 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
81 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
82
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
83 template<class T>
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
84 MatrixType::matrix_type
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
85 matrix_real_probe (const MArray<T>& a)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
86 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
87 MatrixType::matrix_type typ;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
88 octave_idx_type nrows = a.rows ();
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
89 octave_idx_type ncols = a.cols ();
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
90
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
91 const T zero = 0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
92
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
93 if (ncols == nrows)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
94 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
95 bool upper = true;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
96 bool lower = true;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
97 bool hermitian = true;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
98
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
99 // 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
100 OCTAVE_LOCAL_BUFFER (T, diag, ncols);
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
101
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
102 for (octave_idx_type j = 0;
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
103 j < ncols && upper; j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
104 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
105 T d = a.elem (j,j);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
106 upper = upper && (d != zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
107 lower = lower && (d != zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
108 hermitian = hermitian && (d > zero);
10713
0e05ed9f2a62 improve some MatrixType code
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
109 diag[j] = d;
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
110 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
111
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
112 for (octave_idx_type j = 0;
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
113 j < ncols && (upper || lower || hermitian); j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
114 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
115 for (octave_idx_type i = 0; i < j; i++)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
116 {
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
117 double aij = a.elem (i,j);
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
118 double aji = a.elem (j,i);
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
119 lower = lower && (aij == zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
120 upper = upper && (aji == zero);
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
121 hermitian = hermitian && (aij == aji
10713
0e05ed9f2a62 improve some MatrixType code
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
122 && aij*aij < diag[i]*diag[j]);
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
123 }
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
124 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
125
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
126 if (upper)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
127 typ = MatrixType::Upper;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
128 else if (lower)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
129 typ = MatrixType::Lower;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
130 else if (hermitian)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
131 typ = MatrixType::Hermitian;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
132 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
133 typ = MatrixType::Full;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
134 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
135 else
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
136 typ = MatrixType::Rectangular;
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
137
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
138 return typ;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
139 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
140
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
141 template<class T>
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
142 MatrixType::matrix_type
10713
0e05ed9f2a62 improve some MatrixType code
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
143 matrix_complex_probe (const MArray<std::complex<T> >& a)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
144 {
18710
5bd1ca29c5f0 Clean up questionable code bits identified by clang sanitize.
Rik <rik@octave.org>
parents: 18084
diff changeset
145 MatrixType::matrix_type typ = MatrixType::Unknown;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
146 octave_idx_type nrows = a.rows ();
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
147 octave_idx_type ncols = a.cols ();
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
148
10713
0e05ed9f2a62 improve some MatrixType code
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
149 const T zero = 0;
0e05ed9f2a62 improve some MatrixType code
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
150 // get the real type
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
151
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
152 if (ncols == nrows)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
153 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
154 bool upper = true;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
155 bool lower = true;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
156 bool hermitian = true;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
157
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
158 // 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
159 OCTAVE_LOCAL_BUFFER (T, diag, ncols);
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
160
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
161 for (octave_idx_type j = 0;
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
162 j < ncols && upper; j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
163 {
10713
0e05ed9f2a62 improve some MatrixType code
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
164 std::complex<T> d = a.elem (j,j);
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
165 upper = upper && (d != zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
166 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
167 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
168 diag[j] = d.real ();
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
169 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
170
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
171 for (octave_idx_type j = 0;
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
172 j < ncols && (upper || lower || hermitian); j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
173 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
174 for (octave_idx_type i = 0; i < j; i++)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
175 {
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
176 std::complex<T> aij = a.elem (i,j);
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 17769
diff changeset
177 std::complex<T> aji = a.elem (j,i);
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
178 lower = lower && (aij == zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
179 upper = upper && (aji == zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
180 hermitian = hermitian && (aij == std::conj (aji)
10713
0e05ed9f2a62 improve some MatrixType code
Jaroslav Hajek <highegg@gmail.com>
parents: 10521
diff changeset
181 && std::norm (aij) < diag[i]*diag[j]);
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
182 }
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
183 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
184
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
185
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
186 if (upper)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
187 typ = MatrixType::Upper;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
188 else if (lower)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
189 typ = MatrixType::Lower;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
190 else if (hermitian)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
191 typ = MatrixType::Hermitian;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
192 else if (ncols == nrows)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
193 typ = MatrixType::Full;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
194 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
195 else
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
196 typ = MatrixType::Rectangular;
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
197
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
198 return typ;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
199 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
200
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
201 MatrixType::MatrixType (const Matrix &a)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
202 : typ (MatrixType::Unknown),
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
203 sp_bandden (0), bandden (0), upper_band (0), lower_band (0),
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
204 dense (false), full (true), nperm (0), perm (0)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
205 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
206 typ = matrix_real_probe (a);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
207 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
208
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
209 MatrixType::MatrixType (const ComplexMatrix &a)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
210 : typ (MatrixType::Unknown),
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
211 sp_bandden (0), bandden (0), upper_band (0), lower_band (0),
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
212 dense (false), full (true), nperm (0), perm (0)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
213 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
214 typ = matrix_complex_probe (a);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
215 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
216
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
217
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
218 MatrixType::MatrixType (const FloatMatrix &a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
219 : typ (MatrixType::Unknown),
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
220 sp_bandden (0), bandden (0), upper_band (0), lower_band (0),
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
221 dense (false), full (true), nperm (0), perm (0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
222 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
223 typ = matrix_real_probe (a);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
224 }
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 MatrixType::MatrixType (const FloatComplexMatrix &a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
227 : typ (MatrixType::Unknown),
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
228 sp_bandden (0), bandden (0), upper_band (0), lower_band (0),
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
229 dense (false), full (true), nperm (0), perm (0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
230 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
231 typ = matrix_complex_probe (a);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
232 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
233
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
234 MatrixType::MatrixType (const SparseMatrix &a)
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
235 : typ (MatrixType::Unknown),
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
236 sp_bandden (0), bandden (0), upper_band (0), lower_band (0),
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
237 dense (false), full (false), nperm (0), perm (0)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
238 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
239 octave_idx_type nrows = a.rows ();
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
240 octave_idx_type ncols = a.cols ();
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
241 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
242 octave_idx_type nnz = a.nnz ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
243
5893
d73ffe42f2c8 [project @ 2006-07-16 07:48:19 by jwe]
jwe
parents: 5892
diff changeset
244 if (octave_sparse_params::get_key ("spumoni") != 0.)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
245 warn_calculating_sparse_type ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
246
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
247 sp_bandden = octave_sparse_params::get_bandden ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
248 bool maybe_hermitian = false;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
249 typ = MatrixType::Full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
250
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
251 if (nnz == nm)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
252 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
253 matrix_type tmp_typ = MatrixType::Diagonal;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
254 octave_idx_type i;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
255 // Maybe the matrix is diagonal
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
256 for (i = 0; i < nm; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
257 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
258 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
259 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
260 tmp_typ = MatrixType::Full;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
261 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
262 }
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
263 if (a.ridx (i) != i)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
264 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
265 tmp_typ = MatrixType::Permuted_Diagonal;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
266 break;
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 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
269
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
270 if (tmp_typ == MatrixType::Permuted_Diagonal)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
271 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
272 std::vector<bool> found (nrows);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
273
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
274 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
275 found[j] = true;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
276 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
277 found[j] = false;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
278
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
279 for (octave_idx_type j = i; j < nm; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
280 {
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
281 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: 19731
diff changeset
282 || ((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
283 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
284 tmp_typ = MatrixType::Full;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
285 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
286 }
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
287 found[a.ridx (j)] = true;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
288 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
289 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
290 typ = tmp_typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
291 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
292
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
293 if (typ == MatrixType::Full)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
294 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
295 // Search for banded, upper and lower triangular matrices
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
296 bool singular = false;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
297 upper_band = 0;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
298 lower_band = 0;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
299 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
300 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
301 bool zero_on_diagonal = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
302 if (j < nrows)
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 zero_on_diagonal = true;
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
305 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
306 if (a.ridx (i) == j)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
307 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
308 zero_on_diagonal = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
309 break;
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 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
312
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
313 if (zero_on_diagonal)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
314 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
315 singular = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
316 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
317 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
318
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
319 if (a.cidx (j+1) != a.cidx (j))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
320 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
321 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
322 octave_idx_type rl = a.ridx (a.cidx (j+1)-1);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
323
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
324 if (j - ru > upper_band)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
325 upper_band = j - ru;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
326
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
327 if (rl - j > lower_band)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
328 lower_band = rl - j;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
329 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
330 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
331
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
332 if (!singular)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
333 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
334 bandden = double (nnz) /
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
335 (double (ncols) * (double (lower_band) +
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
336 double (upper_band)) -
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
337 0.5 * double (upper_band + 1) * double (upper_band) -
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
338 0.5 * double (lower_band + 1) * double (lower_band));
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
339
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
340 if (nrows == ncols && sp_bandden != 1. && bandden > sp_bandden)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
341 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
342 if (upper_band == 1 && lower_band == 1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
343 typ = MatrixType::Tridiagonal;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
344 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
345 typ = MatrixType::Banded;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
346
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
347 octave_idx_type nnz_in_band =
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
348 (upper_band + lower_band + 1) * nrows -
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
349 (1 + upper_band) * upper_band / 2 -
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
350 (1 + lower_band) * lower_band / 2;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
351 if (nnz_in_band == nnz)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
352 dense = true;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
353 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
354 dense = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
355 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
356 else if (upper_band == 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
357 typ = MatrixType::Lower;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
358 else if (lower_band == 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
359 typ = MatrixType::Upper;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
360
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
361 if (upper_band == lower_band && nrows == ncols)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
362 maybe_hermitian = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
363 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
364
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
365 if (typ == MatrixType::Full)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
366 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
367 // Search for a permuted triangular matrix, and test if
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
368 // permutation is singular
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
369
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
370 // 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
371 bool found = false;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
372
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
373 nperm = ncols;
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
374 perm = new octave_idx_type [ncols];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
375
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
376 for (octave_idx_type i = 0; i < ncols; i++)
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
377 perm[i] = -1;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
378
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
379 for (octave_idx_type i = 0; i < nm; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
380 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
381 found = false;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
382
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
383 for (octave_idx_type j = 0; j < ncols; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
384 {
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
385 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: 19731
diff changeset
386 && (a.ridx (a.cidx (j+1)-1) == i))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
387 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
388 perm[i] = j;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
389 found = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
390 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
391 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
392 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
393
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
394 if (!found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
395 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
396 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
397
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
398 if (found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
399 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
400 typ = MatrixType::Permuted_Upper;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
401 if (ncols > nrows)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
402 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
403 octave_idx_type k = nrows;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
404 for (octave_idx_type i = 0; i < ncols; i++)
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
405 if (perm[i] == -1)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
406 perm[i] = k++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
407 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
408 }
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
409 else if (a.cidx (nm) == a.cidx (ncols))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
410 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
411 nperm = nrows;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
412 delete [] perm;
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
413 perm = new octave_idx_type [nrows];
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
414 OCTAVE_LOCAL_BUFFER (octave_idx_type, tmp, nrows);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
415
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
416 for (octave_idx_type i = 0; i < nrows; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
417 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
418 perm[i] = -1;
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
419 tmp[i] = -1;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
420 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
421
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
422 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
423 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
424 perm[a.ridx (i)] = j;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
425
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
426 found = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
427 for (octave_idx_type i = 0; i < nm; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
428 if (perm[i] == -1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
429 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
430 found = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
431 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
432 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
433 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
434 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
435 tmp[perm[i]] = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
436 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
437
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
438 if (found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
439 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
440 octave_idx_type k = ncols;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
441 for (octave_idx_type i = 0; i < nrows; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
442 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
443 if (tmp[i] == -1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
444 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
445 if (k < nrows)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
446 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
447 perm[k++] = 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 else
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 found = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
452 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
453 }
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 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
456 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
457
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
458 if (found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
459 typ = MatrixType::Permuted_Lower;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
460 else
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 delete [] perm;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
463 nperm = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
464 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
465 }
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 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
468 delete [] perm;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
469 nperm = 0;
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 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
472
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
473 // 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
474 // 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
475 // as this seems to cause issues.
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
476 if (((typ == MatrixType::Lower || typ == MatrixType::Permuted_Lower)
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
477 && nrows > ncols)
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
478 || ((typ == MatrixType::Upper || typ == MatrixType::Permuted_Upper)
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
479 && nrows < ncols))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
480 {
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
481 if (typ == MatrixType::Permuted_Upper
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
482 || typ == MatrixType::Permuted_Lower)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
483 delete [] perm;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
484 nperm = 0;
14097
4804ad4ce0de Plug memory leak in Matrixtype for sparse permuted matrices.
Rik <octave@nomad.inbox5.com>
parents: 12564
diff changeset
485 typ = MatrixType::Rectangular;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
486 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
487
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
488 if (typ == MatrixType::Full && ncols != nrows)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
489 typ = MatrixType::Rectangular;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
490
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
491 if (maybe_hermitian && (typ == MatrixType::Full
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
492 || typ == MatrixType::Tridiagonal
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
493 || typ == MatrixType::Banded))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
494 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
495 bool is_herm = true;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
496
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
497 // first, check whether the diagonal is positive & extract it
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
498 ColumnVector diag (ncols);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
499
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
500 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
501 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
502 is_herm = false;
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
503 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
504 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
505 if (a.ridx (i) == j)
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
506 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
507 double d = a.data (i);
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
508 is_herm = d > 0.;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
509 diag(j) = d;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
510 break;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
511 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
512 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
513 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
514
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
515
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
516 // next, check symmetry and 2x2 positiveness
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
517
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
518 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
519 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
520 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
521 octave_idx_type k = a.ridx (i);
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
522 is_herm = k == j;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
523 if (is_herm)
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
524 continue;
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
525 double d = a.data (i);
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
526 if (d*d < diag(j)*diag(k))
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
527 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
528 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
529 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
530 if (a.ridx (l) == j)
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
531 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
532 is_herm = a.data (l) == d;
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
533 break;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
534 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
535 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
536 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
537 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
538
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
539 if (is_herm)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
540 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
541 if (typ == MatrixType::Full)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
542 typ = MatrixType::Hermitian;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
543 else if (typ == MatrixType::Banded)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
544 typ = MatrixType::Banded_Hermitian;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
545 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
546 typ = MatrixType::Tridiagonal_Hermitian;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
547 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
548 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
549 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
550 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
551
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
552 MatrixType::MatrixType (const SparseComplexMatrix &a)
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
553 : typ (MatrixType::Unknown),
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
554 sp_bandden (0), bandden (0), upper_band (0), lower_band (0),
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
555 dense (false), full (false), nperm (0), perm (0)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
556 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
557 octave_idx_type nrows = a.rows ();
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
558 octave_idx_type ncols = a.cols ();
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
559 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
560 octave_idx_type nnz = a.nnz ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
561
5996
bd0507994409 [project @ 2006-09-22 19:38:52 by dbateman]
dbateman
parents: 5893
diff changeset
562 if (octave_sparse_params::get_key ("spumoni") != 0.)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
563 warn_calculating_sparse_type ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
564
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
565 sp_bandden = octave_sparse_params::get_bandden ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
566 bool maybe_hermitian = false;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
567 typ = MatrixType::Full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
568
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
569 if (nnz == nm)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
570 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
571 matrix_type tmp_typ = MatrixType::Diagonal;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
572 octave_idx_type i;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
573 // Maybe the matrix is diagonal
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
574 for (i = 0; i < nm; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
575 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
576 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
577 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
578 tmp_typ = MatrixType::Full;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
579 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
580 }
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
581 if (a.ridx (i) != i)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
582 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
583 tmp_typ = MatrixType::Permuted_Diagonal;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
584 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
585 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
586 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
587
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
588 if (tmp_typ == MatrixType::Permuted_Diagonal)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
589 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
590 std::vector<bool> found (nrows);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
591
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
592 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
593 found[j] = true;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
594 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
595 found[j] = false;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
596
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
597 for (octave_idx_type j = i; j < nm; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
598 {
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
599 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: 19731
diff changeset
600 || ((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
601 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
602 tmp_typ = MatrixType::Full;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
603 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
604 }
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
605 found[a.ridx (j)] = true;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
606 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
607 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
608 typ = tmp_typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
609 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
610
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
611 if (typ == MatrixType::Full)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
612 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
613 // Search for banded, upper and lower triangular matrices
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
614 bool singular = false;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
615 upper_band = 0;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
616 lower_band = 0;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
617 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
618 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
619 bool zero_on_diagonal = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
620 if (j < nrows)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
621 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
622 zero_on_diagonal = true;
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
623 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
624 if (a.ridx (i) == j)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
625 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
626 zero_on_diagonal = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
627 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
628 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
629 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
630
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
631 if (zero_on_diagonal)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
632 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
633 singular = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
634 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
635 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
636
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
637 if (a.cidx (j+1) != a.cidx (j))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
638 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
639 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
640 octave_idx_type rl = a.ridx (a.cidx (j+1)-1);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
641
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
642 if (j - ru > upper_band)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
643 upper_band = j - ru;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
644
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
645 if (rl - j > lower_band)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
646 lower_band = rl - j;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
647 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
648 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
649
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
650 if (!singular)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
651 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
652 bandden = double (nnz) /
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
653 (double (ncols) * (double (lower_band) +
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
654 double (upper_band)) -
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
655 0.5 * double (upper_band + 1) * double (upper_band) -
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
656 0.5 * double (lower_band + 1) * double (lower_band));
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
657
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
658 if (nrows == ncols && sp_bandden != 1. && bandden > sp_bandden)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
659 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
660 if (upper_band == 1 && lower_band == 1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
661 typ = MatrixType::Tridiagonal;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
662 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
663 typ = MatrixType::Banded;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
664
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
665 octave_idx_type nnz_in_band =
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
666 (upper_band + lower_band + 1) * nrows -
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
667 (1 + upper_band) * upper_band / 2 -
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
668 (1 + lower_band) * lower_band / 2;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
669 if (nnz_in_band == nnz)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
670 dense = true;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
671 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
672 dense = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
673 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
674 else if (upper_band == 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
675 typ = MatrixType::Lower;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
676 else if (lower_band == 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
677 typ = MatrixType::Upper;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
678
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
679 if (upper_band == lower_band && nrows == ncols)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
680 maybe_hermitian = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
681 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
682
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
683 if (typ == MatrixType::Full)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
684 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
685 // Search for a permuted triangular matrix, and test if
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
686 // permutation is singular
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
687
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
688 // 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
689 bool found = false;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
690
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
691 nperm = ncols;
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
692 perm = new octave_idx_type [ncols];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
693
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
694 for (octave_idx_type i = 0; i < ncols; i++)
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
695 perm[i] = -1;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
696
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
697 for (octave_idx_type i = 0; i < nm; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
698 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
699 found = false;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
700
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
701 for (octave_idx_type j = 0; j < ncols; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
702 {
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
703 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: 19731
diff changeset
704 && (a.ridx (a.cidx (j+1)-1) == i))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
705 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
706 perm[i] = j;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
707 found = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
708 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
709 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
710 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
711
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
712 if (!found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
713 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
714 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
715
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
716 if (found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
717 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
718 typ = MatrixType::Permuted_Upper;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
719 if (ncols > nrows)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
720 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
721 octave_idx_type k = nrows;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
722 for (octave_idx_type i = 0; i < ncols; i++)
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
723 if (perm[i] == -1)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
724 perm[i] = k++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
725 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
726 }
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
727 else if (a.cidx (nm) == a.cidx (ncols))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
728 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
729 nperm = nrows;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
730 delete [] perm;
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
731 perm = new octave_idx_type [nrows];
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
732 OCTAVE_LOCAL_BUFFER (octave_idx_type, tmp, nrows);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
733
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
734 for (octave_idx_type i = 0; i < nrows; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
735 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
736 perm[i] = -1;
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
737 tmp[i] = -1;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
738 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
739
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
740 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
741 for (octave_idx_type i = a.cidx (j); i < a.cidx (j+1); i++)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
742 perm[a.ridx (i)] = j;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
743
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
744 found = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
745 for (octave_idx_type i = 0; i < nm; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
746 if (perm[i] == -1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
747 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
748 found = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
749 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
750 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
751 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
752 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
753 tmp[perm[i]] = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
754 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
755
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
756 if (found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
757 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
758 octave_idx_type k = ncols;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
759 for (octave_idx_type i = 0; i < nrows; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
760 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
761 if (tmp[i] == -1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
762 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
763 if (k < nrows)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
764 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
765 perm[k++] = i;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
766 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
767 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
768 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
769 found = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
770 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
771 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
772 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
773 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
774 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
775
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
776 if (found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
777 typ = MatrixType::Permuted_Lower;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
778 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
779 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
780 delete [] perm;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
781 nperm = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
782 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
783 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
784 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
785 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
786 delete [] perm;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
787 nperm = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
788 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
789 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
790
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
791 // 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
792 // 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
793 // as this seems to cause issues.
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
794 if (((typ == MatrixType::Lower || typ == MatrixType::Permuted_Lower)
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
795 && nrows > ncols)
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
796 || ((typ == MatrixType::Upper || typ == MatrixType::Permuted_Upper)
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
797 && nrows < ncols))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
798 {
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
799 if (typ == MatrixType::Permuted_Upper
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
800 || typ == MatrixType::Permuted_Lower)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
801 delete [] perm;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
802 nperm = 0;
14097
4804ad4ce0de Plug memory leak in Matrixtype for sparse permuted matrices.
Rik <octave@nomad.inbox5.com>
parents: 12564
diff changeset
803 typ = MatrixType::Rectangular;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
804 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
805
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
806 if (typ == MatrixType::Full && ncols != nrows)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
807 typ = MatrixType::Rectangular;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
808
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
809 if (maybe_hermitian && (typ == MatrixType::Full
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
810 || typ == MatrixType::Tridiagonal
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
811 || typ == MatrixType::Banded))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
812 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
813 bool is_herm = true;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
814
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
815 // first, check whether the diagonal is positive & extract it
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
816 ColumnVector diag (ncols);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
817
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
818 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
819 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
820 is_herm = false;
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
821 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
822 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
823 if (a.ridx (i) == j)
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
824 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
825 Complex d = a.data (i);
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
826 is_herm = d.real () > 0. && d.imag () == 0.;
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
827 diag(j) = d.real ();
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
828 break;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
829 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
830 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
831 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
832
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
833 // next, check symmetry and 2x2 positiveness
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
834
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
835 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
836 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
837 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
838 octave_idx_type k = a.ridx (i);
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
839 is_herm = k == j;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
840 if (is_herm)
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
841 continue;
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
842 Complex d = a.data (i);
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
843 if (std::norm (d) < diag(j)*diag(k))
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
844 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
845 d = std::conj (d);
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
846 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
847 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
848 if (a.ridx (l) == j)
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
849 {
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
850 is_herm = a.data (l) == d;
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
851 break;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
852 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
853 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
854 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
855 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
856
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
857
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
858 if (is_herm)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
859 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
860 if (typ == MatrixType::Full)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
861 typ = MatrixType::Hermitian;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
862 else if (typ == MatrixType::Banded)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
863 typ = MatrixType::Banded_Hermitian;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
864 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
865 typ = MatrixType::Tridiagonal_Hermitian;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
866 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
867 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
868 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
869 }
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
870 MatrixType::MatrixType (const matrix_type t, bool _full)
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
871 : typ (MatrixType::Unknown),
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
872 sp_bandden (octave_sparse_params::get_bandden ()),
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
873 bandden (0), upper_band (0), lower_band (0),
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
874 dense (false), full (_full), nperm (0), perm (0)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
875 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
876 if (t == MatrixType::Unknown || t == MatrixType::Full
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
877 || t == MatrixType::Diagonal || t == MatrixType::Permuted_Diagonal
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
878 || t == MatrixType::Upper || t == MatrixType::Lower
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
879 || t == MatrixType::Tridiagonal || t == MatrixType::Tridiagonal_Hermitian
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
880 || t == MatrixType::Rectangular)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
881 typ = t;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
882 else
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
883 warn_invalid ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
884 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
885
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
886 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
887 const octave_idx_type *p, bool _full)
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
888 : typ (MatrixType::Unknown),
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
889 sp_bandden (octave_sparse_params::get_bandden ()),
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
890 bandden (0), upper_band (0), lower_band (0),
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
891 dense (false), full (_full), nperm (0), perm (0)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
892 {
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
893 if ((t == MatrixType::Permuted_Upper || t == MatrixType::Permuted_Lower)
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
894 && np > 0 && p != 0)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
895 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
896 typ = t;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
897 nperm = np;
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
898 perm = new octave_idx_type [nperm];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
899 for (octave_idx_type i = 0; i < nperm; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
900 perm[i] = p[i];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
901 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
902 else
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
903 warn_invalid ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
904 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
905
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
906 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
907 const octave_idx_type kl, bool _full)
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
908 : typ (MatrixType::Unknown),
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
909 sp_bandden (octave_sparse_params::get_bandden ()),
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
910 bandden (0), upper_band (0), lower_band (0),
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
911 dense (false), full (_full), nperm (0), perm (0)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
912 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
913 if (t == MatrixType::Banded || t == MatrixType::Banded_Hermitian)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
914 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
915 typ = t;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
916 upper_band = ku;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
917 lower_band = kl;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
918 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
919 else
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
920 warn_invalid ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
921 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
922
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
923 MatrixType::~MatrixType (void)
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
924 {
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
925 if (nperm != 0)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
926 {
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
927 delete [] perm;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
928 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
929 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
930
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
931 MatrixType&
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
932 MatrixType::operator = (const MatrixType& a)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
933 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
934 if (this != &a)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
935 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
936 typ = a.typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
937 sp_bandden = a.sp_bandden;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
938 bandden = a.bandden;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
939 upper_band = a.upper_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
940 lower_band = a.lower_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
941 dense = a.dense;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
942 full = a.full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
943
12564
61cd086e9aeb Correct slight logical mistake in memleak patch (bug #32804)
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12563
diff changeset
944 if (nperm)
61cd086e9aeb Correct slight logical mistake in memleak patch (bug #32804)
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12563
diff changeset
945 {
61cd086e9aeb Correct slight logical mistake in memleak patch (bug #32804)
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12563
diff changeset
946 delete[] perm;
61cd086e9aeb Correct slight logical mistake in memleak patch (bug #32804)
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12563
diff changeset
947 }
61cd086e9aeb Correct slight logical mistake in memleak patch (bug #32804)
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 12563
diff changeset
948
12563
681bb733f4f4 MatrixType:: plug memory leak (bug #32804).
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
949 if (a.nperm != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
950 {
12563
681bb733f4f4 MatrixType:: plug memory leak (bug #32804).
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
951 perm = new octave_idx_type [a.nperm];
681bb733f4f4 MatrixType:: plug memory leak (bug #32804).
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
952 for (octave_idx_type i = 0; i < a.nperm; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
953 perm[i] = a.perm[i];
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
954 }
12563
681bb733f4f4 MatrixType:: plug memory leak (bug #32804).
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
955
681bb733f4f4 MatrixType:: plug memory leak (bug #32804).
Jordi Gutiérrez Hermoso <jordigh@gmail.com>
parents: 11586
diff changeset
956 nperm = a.nperm;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
957 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
958
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
959 return *this;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
960 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
961
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
962 int
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
963 MatrixType::type (bool quiet)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
964 {
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
965 if (typ != MatrixType::Unknown
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
966 && (full || sp_bandden == octave_sparse_params::get_bandden ()))
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
967 {
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
968 if (!quiet && octave_sparse_params::get_key ("spumoni") != 0.)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
969 warn_cached ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
970
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
971 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
972 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
973
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
974 if (typ != MatrixType::Unknown
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
975 && octave_sparse_params::get_key ("spumoni") != 0.)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
976 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
977 ("Octave:matrix-type-info", "invalidating matrix type");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
978
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
979 typ = MatrixType::Unknown;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
980
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
981 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
982 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
983
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
984 int
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
985 MatrixType::type (const SparseMatrix &a)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
986 {
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
987 if (typ != MatrixType::Unknown
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
988 && (full || sp_bandden == octave_sparse_params::get_bandden ()))
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
989 {
5893
d73ffe42f2c8 [project @ 2006-07-16 07:48:19 by jwe]
jwe
parents: 5892
diff changeset
990 if (octave_sparse_params::get_key ("spumoni") != 0.)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
991 warn_cached ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
992
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
993 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
994 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
995
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
996 MatrixType tmp_typ (a);
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
997 typ = tmp_typ.typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
998 sp_bandden = tmp_typ.sp_bandden;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
999 bandden = tmp_typ.bandden;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1000 upper_band = tmp_typ.upper_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1001 lower_band = tmp_typ.lower_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1002 dense = tmp_typ.dense;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1003 full = tmp_typ.full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1004 nperm = tmp_typ.nperm;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1005
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1006 if (nperm != 0)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1007 {
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
1008 perm = new octave_idx_type [nperm];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1009 for (octave_idx_type i = 0; i < nperm; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1010 perm[i] = tmp_typ.perm[i];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1011 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1012
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1013 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1014 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1015
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1016 int
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1017 MatrixType::type (const SparseComplexMatrix &a)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1018 {
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1019 if (typ != MatrixType::Unknown
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1020 && (full || sp_bandden == octave_sparse_params::get_bandden ()))
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1021 {
5893
d73ffe42f2c8 [project @ 2006-07-16 07:48:19 by jwe]
jwe
parents: 5892
diff changeset
1022 if (octave_sparse_params::get_key ("spumoni") != 0.)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1023 warn_cached ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1024
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1025 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1026 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1027
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1028 MatrixType tmp_typ (a);
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1029 typ = tmp_typ.typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1030 sp_bandden = tmp_typ.sp_bandden;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1031 bandden = tmp_typ.bandden;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1032 upper_band = tmp_typ.upper_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1033 lower_band = tmp_typ.lower_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1034 dense = tmp_typ.dense;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1035 full = tmp_typ.full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1036 nperm = tmp_typ.nperm;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1037
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1038 if (nperm != 0)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1039 {
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
1040 perm = new octave_idx_type [nperm];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1041 for (octave_idx_type i = 0; i < nperm; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1042 perm[i] = tmp_typ.perm[i];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1043 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1044
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1045 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1046 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1047
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1048 int
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1049 MatrixType::type (const Matrix &a)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1050 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1051 if (typ != MatrixType::Unknown)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1052 {
5893
d73ffe42f2c8 [project @ 2006-07-16 07:48:19 by jwe]
jwe
parents: 5892
diff changeset
1053 if (octave_sparse_params::get_key ("spumoni") != 0.)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1054 warn_cached ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1055
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1056 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1057 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1058
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1059 MatrixType tmp_typ (a);
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1060 typ = tmp_typ.typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1061 full = tmp_typ.full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1062 nperm = tmp_typ.nperm;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1063
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1064 if (nperm != 0)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1065 {
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
1066 perm = new octave_idx_type [nperm];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1067 for (octave_idx_type i = 0; i < nperm; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1068 perm[i] = tmp_typ.perm[i];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1069 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1070
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1071 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1072 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1073
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1074 int
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1075 MatrixType::type (const ComplexMatrix &a)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1076 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1077 if (typ != MatrixType::Unknown)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1078 {
5893
d73ffe42f2c8 [project @ 2006-07-16 07:48:19 by jwe]
jwe
parents: 5892
diff changeset
1079 if (octave_sparse_params::get_key ("spumoni") != 0.)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1080 warn_cached ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1081
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1082 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1083 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1084
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1085 MatrixType tmp_typ (a);
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1086 typ = tmp_typ.typ;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1087 full = tmp_typ.full;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1088 nperm = tmp_typ.nperm;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1089
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1090 if (nperm != 0)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1091 {
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
1092 perm = new octave_idx_type [nperm];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1093 for (octave_idx_type i = 0; i < nperm; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1094 perm[i] = tmp_typ.perm[i];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1095 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1096
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1097 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1098 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1099
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1100 int
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1101 MatrixType::type (const FloatMatrix &a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1102 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1103 if (typ != MatrixType::Unknown)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1104 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1105 if (octave_sparse_params::get_key ("spumoni") != 0.)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1106 warn_cached ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1107
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1108 return typ;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1109 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1110
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1111 MatrixType tmp_typ (a);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1112 typ = tmp_typ.typ;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1113 full = tmp_typ.full;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1114 nperm = tmp_typ.nperm;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1115
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1116 if (nperm != 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1117 {
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
1118 perm = new octave_idx_type [nperm];
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1119 for (octave_idx_type i = 0; i < nperm; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1120 perm[i] = tmp_typ.perm[i];
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1121 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1122
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1123 return typ;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1124 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1125
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1126 int
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1127 MatrixType::type (const FloatComplexMatrix &a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1128 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1129 if (typ != MatrixType::Unknown)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1130 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1131 if (octave_sparse_params::get_key ("spumoni") != 0.)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1132 warn_cached ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1133
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1134 return typ;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1135 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1136
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1137 MatrixType tmp_typ (a);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1138 typ = tmp_typ.typ;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1139 full = tmp_typ.full;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1140 nperm = tmp_typ.nperm;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1141
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1142 if (nperm != 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1143 {
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
1144 perm = new octave_idx_type [nperm];
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1145 for (octave_idx_type i = 0; i < nperm; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1146 perm[i] = tmp_typ.perm[i];
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1147 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1148
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1149 return typ;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1150 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1151
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1152 void
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1153 MatrixType::info () const
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1154 {
5893
d73ffe42f2c8 [project @ 2006-07-16 07:48:19 by jwe]
jwe
parents: 5892
diff changeset
1155 if (octave_sparse_params::get_key ("spumoni") != 0.)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1156 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1157 if (typ == MatrixType::Unknown)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1158 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1159 ("Octave:matrix-type-info", "unknown matrix type");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1160 else if (typ == MatrixType::Diagonal)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1161 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1162 ("Octave:matrix-type-info", "diagonal sparse matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1163 else if (typ == MatrixType::Permuted_Diagonal)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1164 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1165 ("Octave:matrix-type-info", "permuted diagonal sparse matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1166 else if (typ == MatrixType::Upper)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1167 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1168 ("Octave:matrix-type-info", "upper triangular matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1169 else if (typ == MatrixType::Lower)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1170 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1171 ("Octave:matrix-type-info", "lower triangular matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1172 else if (typ == MatrixType::Permuted_Upper)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1173 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1174 ("Octave:matrix-type-info", "permuted upper triangular matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1175 else if (typ == MatrixType::Permuted_Lower)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1176 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1177 ("Octave:matrix-type-info", "permuted lower triangular Matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1178 else if (typ == MatrixType::Banded)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1179 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1180 ("Octave:matrix-type-info",
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1181 "banded sparse matrix %d-1-%d (density %f)",
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1182 lower_band, upper_band, bandden);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1183 else if (typ == MatrixType::Banded_Hermitian)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1184 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1185 ("Octave:matrix-type-info",
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1186 "banded hermitian/symmetric sparse matrix %d-1-%d (density %f)",
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1187 lower_band, upper_band, bandden);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1188 else if (typ == MatrixType::Hermitian)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1189 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1190 ("Octave:matrix-type-info", "hermitian/symmetric matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1191 else if (typ == MatrixType::Tridiagonal)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1192 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1193 ("Octave:matrix-type-info", "tridiagonal sparse matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1194 else if (typ == MatrixType::Tridiagonal_Hermitian)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1195 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1196 ("Octave:matrix-type-info",
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1197 "hermitian/symmetric tridiagonal sparse matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1198 else if (typ == MatrixType::Rectangular)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1199 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1200 ("Octave:matrix-type-info", "rectangular/singular matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1201 else if (typ == MatrixType::Full)
19444
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1202 (*current_liboctave_warning_with_id_handler)
95c533ed464b use warning IDs for all warnings in liboctave
John W. Eaton <jwe@octave.org>
parents: 19303
diff changeset
1203 ("Octave:matrix-type-info", "full matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1204 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1205 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1206
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1207 void
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1208 MatrixType::mark_as_symmetric (void)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1209 {
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
1210 if (typ == MatrixType::Tridiagonal
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
1211 || typ == MatrixType::Tridiagonal_Hermitian)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1212 typ = MatrixType::Tridiagonal_Hermitian;
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
1213 else if (typ == MatrixType::Banded || typ == MatrixType::Banded_Hermitian)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1214 typ = MatrixType::Banded_Hermitian;
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
1215 else if (typ == MatrixType::Full || typ == MatrixType::Hermitian
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
1216 || typ == MatrixType::Unknown)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1217 typ = MatrixType::Hermitian;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1218 else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1219 (*current_liboctave_error_handler)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1220 ("Can not mark current matrix type as symmetric");
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1221 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1222
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1223 void
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1224 MatrixType::mark_as_unsymmetric (void)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1225 {
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
1226 if (typ == MatrixType::Tridiagonal
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
1227 || typ == MatrixType::Tridiagonal_Hermitian)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1228 typ = MatrixType::Tridiagonal;
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
1229 else if (typ == MatrixType::Banded || typ == MatrixType::Banded_Hermitian)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1230 typ = MatrixType::Banded;
19898
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
1231 else if (typ == MatrixType::Full || typ == MatrixType::Hermitian
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19731
diff changeset
1232 || typ == MatrixType::Unknown)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1233 typ = MatrixType::Full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1234 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1235
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1236 void
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1237 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
1238 const octave_idx_type *p)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1239 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1240 nperm = np;
15020
560317fd5977 maint: Cuddle open bracket used for indexing C++ arrays in source code.
Rik <rik@octave.org>
parents: 15018
diff changeset
1241 perm = new octave_idx_type [nperm];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1242 for (octave_idx_type i = 0; i < nperm; i++)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1243 perm[i] = p[i];
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1244
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1245 if (typ == MatrixType::Diagonal || typ == MatrixType::Permuted_Diagonal)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1246 typ = MatrixType::Permuted_Diagonal;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1247 else if (typ == MatrixType::Upper || typ == MatrixType::Permuted_Upper)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1248 typ = MatrixType::Permuted_Upper;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1249 else if (typ == MatrixType::Lower || typ == MatrixType::Permuted_Lower)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1250 typ = MatrixType::Permuted_Lower;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1251 else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1252 (*current_liboctave_error_handler)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1253 ("Can not mark current matrix type as symmetric");
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1254 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1255
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1256 void
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1257 MatrixType::mark_as_unpermuted (void)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1258 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1259 if (nperm)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1260 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1261 nperm = 0;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1262 delete [] perm;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1263 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1264
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1265 if (typ == MatrixType::Diagonal || typ == MatrixType::Permuted_Diagonal)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1266 typ = MatrixType::Diagonal;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1267 else if (typ == MatrixType::Upper || typ == MatrixType::Permuted_Upper)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1268 typ = MatrixType::Upper;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1269 else if (typ == MatrixType::Lower || typ == MatrixType::Permuted_Lower)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1270 typ = MatrixType::Lower;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1271 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1272
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1273 MatrixType
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1274 MatrixType::transpose (void) const
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1275 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1276 MatrixType retval (*this);
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1277 if (typ == MatrixType::Upper)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1278 retval.typ = MatrixType::Lower;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1279 else if (typ == MatrixType::Permuted_Upper)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1280 retval.typ = MatrixType::Permuted_Lower;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1281 else if (typ == MatrixType::Lower)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1282 retval.typ = MatrixType::Upper;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1283 else if (typ == MatrixType::Permuted_Lower)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1284 retval.typ = MatrixType::Permuted_Upper;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1285 else if (typ == MatrixType::Banded)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1286 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1287 retval.upper_band = lower_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1288 retval.lower_band = upper_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1289 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1290
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1291 return retval;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1292 }