annotate liboctave/MatrixType.cc @ 10521:4d1fc073fbb7

add some missing copyright stmts
author Jaroslav Hajek <highegg@gmail.com>
date Wed, 14 Apr 2010 12:23:13 +0200
parents bdf5d85cfc5e
children 0e05ed9f2a62
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
8920
eb63fbe60fab update copyright notices
John W. Eaton <jwe@octave.org>
parents: 8377
diff changeset
3 Copyright (C) 2006, 2007, 2008 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"
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
33 #include "CMatrix.h"
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
34 #include "dSparse.h"
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
35 #include "CSparse.h"
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
36 #include "oct-spparms.h"
8377
25bc2d31e1bf improve OCTAVE_LOCAL_BUFFER
Jaroslav Hajek <highegg@gmail.com>
parents: 7798
diff changeset
37 #include "oct-locbuf.h"
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
38
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
39 // FIXME There is a large code duplication here
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
40
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
41 MatrixType::MatrixType (void)
6460
fa6312d93730 [project @ 2007-03-26 21:23:00 by dbateman]
dbateman
parents: 6452
diff changeset
42 : typ (MatrixType::Unknown),
fa6312d93730 [project @ 2007-03-26 21:23:00 by dbateman]
dbateman
parents: 6452
diff changeset
43 sp_bandden (octave_sparse_params::get_bandden()),
fa6312d93730 [project @ 2007-03-26 21:23:00 by dbateman]
dbateman
parents: 6452
diff changeset
44 bandden (0), upper_band (0),
6452
7e90124eddba [project @ 2007-03-24 22:18:14 by dbateman]
dbateman
parents: 6027
diff changeset
45 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
46
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
47 MatrixType::MatrixType (const MatrixType &a)
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
48 : typ (a.typ), sp_bandden (a.sp_bandden), bandden (a.bandden),
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
49 upper_band (a.upper_band), lower_band (a.lower_band),
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
50 dense (a.dense), full (a.full), nperm (a.nperm)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
51 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
52 if (nperm != 0)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
53 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
54 perm = new octave_idx_type [nperm];
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
55 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
56 perm[i] = a.perm[i];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
57 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
58 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
59
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
60 template<class T>
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
61 MatrixType::matrix_type
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
62 matrix_real_probe (const MArray<T>& a)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
63 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
64 MatrixType::matrix_type typ;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
65 octave_idx_type nrows = a.rows ();
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
66 octave_idx_type ncols = a.cols ();
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
67
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
68 const T zero = 0;
5997
49dfdb54bb2b [project @ 2006-09-23 13:29:18 by dbateman]
dbateman
parents: 5996
diff changeset
69
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
70 if (ncols == nrows)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
71 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
72 bool upper = true;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
73 bool lower = true;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
74 bool hermitian = true;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
75
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
76 // do the checks for lower/upper/hermitian all in one pass.
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
77 ColumnVector diag(ncols);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
78
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
79 for (octave_idx_type j = 0;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
80 j < ncols && upper; j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
81 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
82 T d = a.elem (j,j);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
83 upper = upper && (d != zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
84 lower = lower && (d != zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
85 hermitian = hermitian && (d > zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
86 diag(j) = d;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
87 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
88
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
89 for (octave_idx_type j = 0;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
90 j < ncols && (upper || lower || hermitian); j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
91 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
92 for (octave_idx_type i = 0; i < j; i++)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
93 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
94 double aij = a.elem (i,j), aji = a.elem (j,i);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
95 lower = lower && (aij == zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
96 upper = upper && (aji == zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
97 hermitian = hermitian && (aij == aji
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
98 && aij*aij < diag(i)*diag(j));
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
99 }
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
100 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
101
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
102 if (upper)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
103 typ = MatrixType::Upper;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
104 else if (lower)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
105 typ = MatrixType::Lower;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
106 else if (hermitian)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
107 typ = MatrixType::Hermitian;
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
108 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
109 typ = MatrixType::Full;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
110 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
111 else
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
112 typ = MatrixType::Rectangular;
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
113
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
114 return typ;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
115 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
116
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
117 template<class T>
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
118 MatrixType::matrix_type
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
119 matrix_complex_probe (const MArray<T>& a)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
120 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
121 MatrixType::matrix_type typ;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
122 octave_idx_type nrows = a.rows ();
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
123 octave_idx_type ncols = a.cols ();
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
124
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
125 const typename T::value_type zero = 0;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
126
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
127 if (ncols == nrows)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
128 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
129 bool upper = true;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
130 bool lower = true;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
131 bool hermitian = true;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
132
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
133 // do the checks for lower/upper/hermitian all in one pass.
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
134 ColumnVector diag(ncols);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
135
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
136 for (octave_idx_type j = 0;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
137 j < ncols && upper; j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
138 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
139 T d = a.elem (j,j);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
140 upper = upper && (d != zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
141 lower = lower && (d != zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
142 hermitian = hermitian && (d.real() > zero && d.imag() == zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
143 diag (j) = d.real();
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
144 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
145
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
146 for (octave_idx_type j = 0;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
147 j < ncols && (upper || lower || hermitian); j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
148 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
149 for (octave_idx_type i = 0; i < j; i++)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
150 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
151 T aij = a.elem (i,j), aji = a.elem (j,i);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
152 lower = lower && (aij == zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
153 upper = upper && (aji == zero);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
154 hermitian = hermitian && (aij == std::conj (aji)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
155 && std::norm (aij) < diag(i)*diag(j));
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
156 }
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
157 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
158
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
159
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
160 if (upper)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
161 typ = MatrixType::Upper;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
162 else if (lower)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
163 typ = MatrixType::Lower;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
164 else if (hermitian)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
165 typ = MatrixType::Hermitian;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
166 else if (ncols == nrows)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
167 typ = MatrixType::Full;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
168 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
169 else
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
170 typ = MatrixType::Rectangular;
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
171
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
172 return typ;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
173 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
174
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
175 MatrixType::MatrixType (const Matrix &a)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
176 : typ (MatrixType::Unknown),
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
177 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
178 dense (false), full (true), nperm (0), perm (0)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
179 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
180 typ = matrix_real_probe (a);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
181 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
182
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
183 MatrixType::MatrixType (const ComplexMatrix &a)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
184 : typ (MatrixType::Unknown),
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
185 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
186 dense (false), full (true), nperm (0), perm (0)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
187 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
188 typ = matrix_complex_probe (a);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
189 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
190
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
191
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
192 MatrixType::MatrixType (const FloatMatrix &a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
193 : typ (MatrixType::Unknown),
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
194 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
195 dense (false), full (true), nperm (0), perm (0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
196 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
197 typ = matrix_real_probe (a);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
198 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
199
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
200 MatrixType::MatrixType (const FloatComplexMatrix &a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
201 : typ (MatrixType::Unknown),
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
202 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
203 dense (false), full (true), nperm (0), perm (0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
204 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
205 typ = matrix_complex_probe (a);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
206 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
207
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
208 MatrixType::MatrixType (const SparseMatrix &a)
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
209 : typ (MatrixType::Unknown),
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
210 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
211 dense (false), full (false), nperm (0), perm (0)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
212 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
213 octave_idx_type nrows = a.rows ();
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
214 octave_idx_type ncols = a.cols ();
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
215 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
216 octave_idx_type nnz = a.nnz ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
217
5893
d73ffe42f2c8 [project @ 2006-07-16 07:48:19 by jwe]
jwe
parents: 5892
diff changeset
218 if (octave_sparse_params::get_key ("spumoni") != 0.)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
219 (*current_liboctave_warning_handler)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
220 ("Calculating Sparse Matrix Type");
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
221
6460
fa6312d93730 [project @ 2007-03-26 21:23:00 by dbateman]
dbateman
parents: 6452
diff changeset
222 sp_bandden = octave_sparse_params::get_bandden();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
223 bool maybe_hermitian = false;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
224 typ = MatrixType::Full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
225
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
226 if (nnz == nm)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
227 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
228 matrix_type tmp_typ = MatrixType::Diagonal;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
229 octave_idx_type i;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
230 // Maybe the matrix is diagonal
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
231 for (i = 0; i < nm; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
232 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
233 if (a.cidx(i+1) != a.cidx(i) + 1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
234 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
235 tmp_typ = MatrixType::Full;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
236 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
237 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
238 if (a.ridx(i) != i)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
239 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
240 tmp_typ = MatrixType::Permuted_Diagonal;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
241 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
242 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
243 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
244
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
245 if (tmp_typ == MatrixType::Permuted_Diagonal)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
246 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
247 std::vector<bool> found (nrows);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
248
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
249 for (octave_idx_type j = 0; j < i; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
250 found [j] = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
251 for (octave_idx_type j = i; j < nrows; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
252 found [j] = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
253
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
254 for (octave_idx_type j = i; j < nm; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
255 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
256 if ((a.cidx(j+1) > a.cidx(j) + 1) ||
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
257 ((a.cidx(j+1) == a.cidx(j) + 1) && found [a.ridx(j)]))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
258 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
259 tmp_typ = MatrixType::Full;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
260 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
261 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
262 found [a.ridx(j)] = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
263 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
264 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
265 typ = tmp_typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
266 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
267
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
268 if (typ == MatrixType::Full)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
269 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
270 // Search for banded, upper and lower triangular matrices
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
271 bool singular = false;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
272 upper_band = 0;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
273 lower_band = 0;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
274 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
275 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
276 bool zero_on_diagonal = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
277 if (j < nrows)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
278 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
279 zero_on_diagonal = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
280 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
281 if (a.ridx(i) == j)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
282 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
283 zero_on_diagonal = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
284 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
285 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
286 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
287
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
288 if (zero_on_diagonal)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
289 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
290 singular = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
291 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
292 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
293
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
294 if (a.cidx(j+1) != a.cidx(j))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
295 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
296 octave_idx_type ru = a.ridx(a.cidx(j));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
297 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
298
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
299 if (j - ru > upper_band)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
300 upper_band = j - ru;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
301
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
302 if (rl - j > lower_band)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
303 lower_band = rl - j;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
304 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
305 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
306
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
307 if (!singular)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
308 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
309 bandden = double (nnz) /
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
310 (double (ncols) * (double (lower_band) +
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
311 double (upper_band)) -
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
312 0.5 * double (upper_band + 1) * double (upper_band) -
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
313 0.5 * double (lower_band + 1) * double (lower_band));
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
314
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
315 if (nrows == ncols && sp_bandden != 1. && bandden > sp_bandden)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
316 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
317 if (upper_band == 1 && lower_band == 1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
318 typ = MatrixType::Tridiagonal;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
319 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
320 typ = MatrixType::Banded;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
321
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
322 octave_idx_type nnz_in_band =
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
323 (upper_band + lower_band + 1) * nrows -
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
324 (1 + upper_band) * upper_band / 2 -
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
325 (1 + lower_band) * lower_band / 2;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
326 if (nnz_in_band == nnz)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
327 dense = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
328 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
329 dense = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
330 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
331 else if (upper_band == 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
332 typ = MatrixType::Lower;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
333 else if (lower_band == 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
334 typ = MatrixType::Upper;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
335
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
336 if (upper_band == lower_band && nrows == ncols)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
337 maybe_hermitian = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
338 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
339
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
340 if (typ == MatrixType::Full)
10314
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 // Search for a permuted triangular matrix, and test if
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
343 // permutation is singular
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
344
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
345 // FIXME
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
346 // Perhaps this should be based on a dmperm algorithm
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
347 bool found = false;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
348
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
349 nperm = ncols;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
350 perm = new octave_idx_type [ncols];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
351
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
352 for (octave_idx_type i = 0; i < ncols; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
353 perm [i] = -1;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
354
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
355 for (octave_idx_type i = 0; i < nm; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
356 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
357 found = false;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
358
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
359 for (octave_idx_type j = 0; j < ncols; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
360 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
361 if ((a.cidx(j+1) - a.cidx(j)) > 0 &&
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
362 (a.ridx(a.cidx(j+1)-1) == i))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
363 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
364 perm [i] = j;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
365 found = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
366 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
367 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
368 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
369
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
370 if (!found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
371 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
372 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
373
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
374 if (found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
375 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
376 typ = MatrixType::Permuted_Upper;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
377 if (ncols > nrows)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
378 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
379 octave_idx_type k = nrows;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
380 for (octave_idx_type i = 0; i < ncols; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
381 if (perm [i] == -1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
382 perm[i] = k++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
383 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
384 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
385 else if (a.cidx(nm) == a.cidx(ncols))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
386 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
387 nperm = nrows;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
388 delete [] perm;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
389 perm = new octave_idx_type [nrows];
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
390 OCTAVE_LOCAL_BUFFER (octave_idx_type, tmp, nrows);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
391
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
392 for (octave_idx_type i = 0; i < nrows; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
393 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
394 perm [i] = -1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
395 tmp [i] = -1;
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 for (octave_idx_type j = 0; j < ncols; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
399 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
400 perm [a.ridx(i)] = j;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
401
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
402 found = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
403 for (octave_idx_type i = 0; i < nm; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
404 if (perm[i] == -1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
405 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
406 found = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
407 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
408 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
409 else
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 tmp[perm[i]] = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
412 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
413
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
414 if (found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
415 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
416 octave_idx_type k = ncols;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
417 for (octave_idx_type i = 0; i < nrows; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
418 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
419 if (tmp[i] == -1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
420 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
421 if (k < nrows)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
422 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
423 perm[k++] = i;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
424 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
425 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
426 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
427 found = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
428 break;
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 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
431 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
432 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
433
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
434 if (found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
435 typ = MatrixType::Permuted_Lower;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
436 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
437 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
438 delete [] perm;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
439 nperm = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
440 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
441 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
442 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
443 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
444 delete [] perm;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
445 nperm = 0;
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 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
448
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
449 // FIXME
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
450 // Disable lower under-determined and upper over-determined problems
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
451 // as being detected, and force to treat as singular. As this seems
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
452 // to cause issues
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
453 if (((typ == MatrixType::Lower || typ == MatrixType::Permuted_Lower)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
454 && nrows > ncols) ||
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
455 ((typ == MatrixType::Upper || typ == MatrixType::Permuted_Upper)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
456 && nrows < ncols))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
457 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
458 typ = MatrixType::Rectangular;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
459 if (typ == MatrixType::Permuted_Upper ||
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
460 typ == MatrixType::Permuted_Lower)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
461 delete [] perm;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
462 nperm = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
463 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
464
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
465 if (typ == MatrixType::Full && ncols != nrows)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
466 typ = MatrixType::Rectangular;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
467
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
468 if (maybe_hermitian && (typ == MatrixType::Full ||
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
469 typ == MatrixType::Tridiagonal ||
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
470 typ == MatrixType::Banded))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
471 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
472 bool is_herm = true;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
473
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
474 // first, check whether the diagonal is positive & extract it
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
475 ColumnVector diag (ncols);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
476
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
477 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
478 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
479 is_herm = false;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
480 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
481 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
482 if (a.ridx(i) == j)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
483 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
484 double d = a.data(i);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
485 is_herm = d > 0.;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
486 diag(j) = d;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
487 break;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
488 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
489 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
490 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
491
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
492
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
493 // next, check symmetry and 2x2 positiveness
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
494
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
495 for (octave_idx_type j = 0; is_herm && j < ncols; j++)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
496 for (octave_idx_type i = a.cidx(j); is_herm && i < a.cidx(j+1); i++)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
497 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
498 octave_idx_type k = a.ridx(i);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
499 is_herm = k == j;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
500 if (is_herm)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
501 continue;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
502 double d = a.data(i);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
503 if (d*d < diag(j)*diag(k))
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
504 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
505 for (octave_idx_type l = a.cidx(k); l < a.cidx(k+1); l++)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
506 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
507 if (a.ridx(l) == j)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
508 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
509 is_herm = a.data(l) == 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 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
515
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
516 if (is_herm)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
517 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
518 if (typ == MatrixType::Full)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
519 typ = MatrixType::Hermitian;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
520 else if (typ == MatrixType::Banded)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
521 typ = MatrixType::Banded_Hermitian;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
522 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
523 typ = MatrixType::Tridiagonal_Hermitian;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
524 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
525 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
526 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
527 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
528
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
529 MatrixType::MatrixType (const SparseComplexMatrix &a)
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
530 : typ (MatrixType::Unknown),
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
531 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
532 dense (false), full (false), nperm (0), perm (0)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
533 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
534 octave_idx_type nrows = a.rows ();
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
535 octave_idx_type ncols = a.cols ();
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
536 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
537 octave_idx_type nnz = a.nnz ();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
538
5996
bd0507994409 [project @ 2006-09-22 19:38:52 by dbateman]
dbateman
parents: 5893
diff changeset
539 if (octave_sparse_params::get_key ("spumoni") != 0.)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
540 (*current_liboctave_warning_handler)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
541 ("Calculating Sparse Matrix Type");
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
542
6460
fa6312d93730 [project @ 2007-03-26 21:23:00 by dbateman]
dbateman
parents: 6452
diff changeset
543 sp_bandden = octave_sparse_params::get_bandden();
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
544 bool maybe_hermitian = false;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
545 typ = MatrixType::Full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
546
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
547 if (nnz == nm)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
548 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
549 matrix_type tmp_typ = MatrixType::Diagonal;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
550 octave_idx_type i;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
551 // Maybe the matrix is diagonal
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
552 for (i = 0; i < nm; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
553 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
554 if (a.cidx(i+1) != a.cidx(i) + 1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
555 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
556 tmp_typ = MatrixType::Full;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
557 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
558 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
559 if (a.ridx(i) != i)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
560 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
561 tmp_typ = MatrixType::Permuted_Diagonal;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
562 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
563 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
564 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
565
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
566 if (tmp_typ == MatrixType::Permuted_Diagonal)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
567 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
568 std::vector<bool> found (nrows);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
569
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
570 for (octave_idx_type j = 0; j < i; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
571 found [j] = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
572 for (octave_idx_type j = i; j < nrows; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
573 found [j] = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
574
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
575 for (octave_idx_type j = i; j < nm; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
576 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
577 if ((a.cidx(j+1) > a.cidx(j) + 1) ||
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
578 ((a.cidx(j+1) == a.cidx(j) + 1) && found [a.ridx(j)]))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
579 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
580 tmp_typ = MatrixType::Full;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
581 break;
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 found [a.ridx(j)] = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
584 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
585 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
586 typ = tmp_typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
587 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
588
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
589 if (typ == MatrixType::Full)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
590 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
591 // Search for banded, upper and lower triangular matrices
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
592 bool singular = false;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
593 upper_band = 0;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
594 lower_band = 0;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
595 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
596 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
597 bool zero_on_diagonal = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
598 if (j < nrows)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
599 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
600 zero_on_diagonal = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
601 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
602 if (a.ridx(i) == j)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
603 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
604 zero_on_diagonal = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
605 break;
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
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
609 if (zero_on_diagonal)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
610 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
611 singular = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
612 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
613 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
614
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
615 if (a.cidx(j+1) != a.cidx(j))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
616 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
617 octave_idx_type ru = a.ridx(a.cidx(j));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
618 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
619
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
620 if (j - ru > upper_band)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
621 upper_band = j - ru;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
622
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
623 if (rl - j > lower_band)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
624 lower_band = rl - j;
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 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
627
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
628 if (!singular)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
629 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
630 bandden = double (nnz) /
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
631 (double (ncols) * (double (lower_band) +
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
632 double (upper_band)) -
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
633 0.5 * double (upper_band + 1) * double (upper_band) -
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
634 0.5 * double (lower_band + 1) * double (lower_band));
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
635
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
636 if (nrows == ncols && sp_bandden != 1. && bandden > sp_bandden)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
637 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
638 if (upper_band == 1 && lower_band == 1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
639 typ = MatrixType::Tridiagonal;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
640 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
641 typ = MatrixType::Banded;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
642
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
643 octave_idx_type nnz_in_band =
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
644 (upper_band + lower_band + 1) * nrows -
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
645 (1 + upper_band) * upper_band / 2 -
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
646 (1 + lower_band) * lower_band / 2;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
647 if (nnz_in_band == nnz)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
648 dense = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
649 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
650 dense = false;
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 else if (upper_band == 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
653 typ = MatrixType::Lower;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
654 else if (lower_band == 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
655 typ = MatrixType::Upper;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
656
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
657 if (upper_band == lower_band && nrows == ncols)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
658 maybe_hermitian = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
659 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
660
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
661 if (typ == MatrixType::Full)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
662 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
663 // Search for a permuted triangular matrix, and test if
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
664 // permutation is singular
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
665
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
666 // FIXME
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
667 // Perhaps this should be based on a dmperm algorithm
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
668 bool found = false;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
669
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
670 nperm = ncols;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
671 perm = new octave_idx_type [ncols];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
672
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
673 for (octave_idx_type i = 0; i < ncols; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
674 perm [i] = -1;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
675
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
676 for (octave_idx_type i = 0; i < nm; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
677 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
678 found = false;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
679
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
680 for (octave_idx_type j = 0; j < ncols; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
681 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
682 if ((a.cidx(j+1) - a.cidx(j)) > 0 &&
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
683 (a.ridx(a.cidx(j+1)-1) == i))
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 perm [i] = j;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
686 found = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
687 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
688 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
689 }
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 if (!found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
692 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
693 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
694
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
695 if (found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
696 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
697 typ = MatrixType::Permuted_Upper;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
698 if (ncols > nrows)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
699 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
700 octave_idx_type k = nrows;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
701 for (octave_idx_type i = 0; i < ncols; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
702 if (perm [i] == -1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
703 perm[i] = k++;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
704 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
705 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
706 else if (a.cidx(nm) == a.cidx(ncols))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
707 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
708 nperm = nrows;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
709 delete [] perm;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
710 perm = new octave_idx_type [nrows];
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
711 OCTAVE_LOCAL_BUFFER (octave_idx_type, tmp, nrows);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
712
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
713 for (octave_idx_type i = 0; i < nrows; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
714 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
715 perm [i] = -1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
716 tmp [i] = -1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
717 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
718
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
719 for (octave_idx_type j = 0; j < ncols; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
720 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
721 perm [a.ridx(i)] = j;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
722
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
723 found = true;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
724 for (octave_idx_type i = 0; i < nm; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
725 if (perm[i] == -1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
726 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
727 found = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
728 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
729 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
730 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
731 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
732 tmp[perm[i]] = 1;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
733 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
734
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
735 if (found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
736 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
737 octave_idx_type k = ncols;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
738 for (octave_idx_type i = 0; i < nrows; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
739 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
740 if (tmp[i] == -1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
741 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
742 if (k < nrows)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
743 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
744 perm[k++] = i;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
745 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
746 else
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 }
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 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
754
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
755 if (found)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
756 typ = MatrixType::Permuted_Lower;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
757 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
758 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
759 delete [] perm;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
760 nperm = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
761 }
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 else
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 delete [] perm;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
766 nperm = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
767 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
768 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
769
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
770 // FIXME
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
771 // Disable lower under-determined and upper over-determined problems
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
772 // as being detected, and force to treat as singular. As this seems
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
773 // to cause issues
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
774 if (((typ == MatrixType::Lower || typ == MatrixType::Permuted_Lower)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
775 && nrows > ncols) ||
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
776 ((typ == MatrixType::Upper || typ == MatrixType::Permuted_Upper)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
777 && nrows < ncols))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
778 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
779 typ = MatrixType::Rectangular;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
780 if (typ == MatrixType::Permuted_Upper ||
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
781 typ == MatrixType::Permuted_Lower)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
782 delete [] perm;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
783 nperm = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
784 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
786 if (typ == MatrixType::Full && ncols != nrows)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
787 typ = MatrixType::Rectangular;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
788
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
789 if (maybe_hermitian && (typ == MatrixType::Full ||
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
790 typ == MatrixType::Tridiagonal ||
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
791 typ == MatrixType::Banded))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
792 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
793 bool is_herm = true;
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
794
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
795 // first, check whether the diagonal is positive & extract it
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
796 ColumnVector diag (ncols);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
797
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
798 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
799 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
800 is_herm = false;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
801 for (octave_idx_type i = a.cidx(j); i < a.cidx(j+1); i++)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
802 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
803 if (a.ridx(i) == j)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
804 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
805 Complex d = a.data(i);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
806 is_herm = d.real() > 0. && d.imag() == 0.;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
807 diag(j) = d.real();
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
808 break;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
809 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
810 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
811 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
812
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
813 // next, check symmetry and 2x2 positiveness
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 for (octave_idx_type j = 0; is_herm && j < ncols; j++)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
816 for (octave_idx_type i = a.cidx(j); is_herm && i < a.cidx(j+1); i++)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
817 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
818 octave_idx_type k = a.ridx(i);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
819 is_herm = k == j;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
820 if (is_herm)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
821 continue;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
822 Complex d = a.data(i);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
823 if (std::norm (d) < diag(j)*diag(k))
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
824 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
825 d = std::conj (d);
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
826 for (octave_idx_type l = a.cidx(k); l < a.cidx(k+1); l++)
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
827 {
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
828 if (a.ridx(l) == j)
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 is_herm = a.data(l) == d;
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
831 break;
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 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
834 }
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
835 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
836
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
837
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
838 if (is_herm)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
839 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
840 if (typ == MatrixType::Full)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
841 typ = MatrixType::Hermitian;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
842 else if (typ == MatrixType::Banded)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
843 typ = MatrixType::Banded_Hermitian;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
844 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
845 typ = MatrixType::Tridiagonal_Hermitian;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
846 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
847 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
848 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
849 }
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
850 MatrixType::MatrixType (const matrix_type t, bool _full)
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
851 : typ (MatrixType::Unknown),
6460
fa6312d93730 [project @ 2007-03-26 21:23:00 by dbateman]
dbateman
parents: 6452
diff changeset
852 sp_bandden (octave_sparse_params::get_bandden()),
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
853 bandden (0), upper_band (0), lower_band (0),
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
854 dense (false), full (_full), nperm (0), perm (0)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
855 {
7798
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
856 if (t == MatrixType::Unknown || t == MatrixType::Full
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
857 || t == MatrixType::Diagonal || t == MatrixType::Permuted_Diagonal
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
858 || t == MatrixType::Upper || t == MatrixType::Lower
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
859 || t == MatrixType::Tridiagonal || t == MatrixType::Tridiagonal_Hermitian
42c42c640108 improved matrix_type check
Jaroslav Hajek <highegg@gmail.com>
parents: 7789
diff changeset
860 || t == MatrixType::Rectangular)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
861 typ = t;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
862 else
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
863 (*current_liboctave_warning_handler) ("Invalid matrix type");
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
864 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
865
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
866 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
867 const octave_idx_type *p, bool _full)
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
868 : typ (MatrixType::Unknown),
6460
fa6312d93730 [project @ 2007-03-26 21:23:00 by dbateman]
dbateman
parents: 6452
diff changeset
869 sp_bandden (octave_sparse_params::get_bandden()),
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
870 bandden (0), upper_band (0), lower_band (0),
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
871 dense (false), full (_full), nperm (0), perm (0)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
872 {
6027
068e52f1c005 [project @ 2006-10-03 20:07:56 by jwe]
jwe
parents: 5997
diff changeset
873 if ((t == MatrixType::Permuted_Upper || t == MatrixType::Permuted_Lower) &&
068e52f1c005 [project @ 2006-10-03 20:07:56 by jwe]
jwe
parents: 5997
diff changeset
874 np > 0 && p != 0)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
875 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
876 typ = t;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
877 nperm = np;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
878 perm = new octave_idx_type [nperm];
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
879 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
880 perm[i] = p[i];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
881 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
882 else
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
883 (*current_liboctave_warning_handler) ("Invalid matrix type");
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 ku,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
887 const octave_idx_type kl, bool _full)
5892
13aa80fc7839 [project @ 2006-07-15 18:15:58 by jwe]
jwe
parents: 5785
diff changeset
888 : typ (MatrixType::Unknown),
6460
fa6312d93730 [project @ 2007-03-26 21:23:00 by dbateman]
dbateman
parents: 6452
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 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
893 if (t == MatrixType::Banded || t == MatrixType::Banded_Hermitian)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
894 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
895 typ = t;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
896 upper_band = ku;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
897 lower_band = kl;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
898 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
899 else
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
900 (*current_liboctave_warning_handler) ("Invalid sparse matrix type");
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
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
903 MatrixType::~MatrixType (void)
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 if (nperm != 0)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
906 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
907 delete [] perm;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
908 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
909 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
910
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
911 MatrixType&
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
912 MatrixType::operator = (const MatrixType& a)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
913 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
914 if (this != &a)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
915 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
916 typ = a.typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
917 sp_bandden = a.sp_bandden;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
918 bandden = a.bandden;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
919 upper_band = a.upper_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
920 lower_band = a.lower_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
921 dense = a.dense;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
922 full = a.full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
923 nperm = a.nperm;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
924
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
925 if (nperm != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
926 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
927 perm = new octave_idx_type [nperm];
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
928 for (octave_idx_type i = 0; i < nperm; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
929 perm[i] = a.perm[i];
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
930 }
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
931 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
932
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
933 return *this;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
934 }
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 int
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
937 MatrixType::type (bool quiet)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
938 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
939 if (typ != MatrixType::Unknown && (full ||
6460
fa6312d93730 [project @ 2007-03-26 21:23:00 by dbateman]
dbateman
parents: 6452
diff changeset
940 sp_bandden == octave_sparse_params::get_bandden()))
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
941 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
942 if (!quiet &&
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
943 octave_sparse_params::get_key ("spumoni") != 0.)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
944 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
945 ("Using Cached Matrix Type");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
946
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
947 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
948 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
949
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
950 if (typ != MatrixType::Unknown &&
5893
d73ffe42f2c8 [project @ 2006-07-16 07:48:19 by jwe]
jwe
parents: 5892
diff changeset
951 octave_sparse_params::get_key ("spumoni") != 0.)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
952 (*current_liboctave_warning_handler)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
953 ("Invalidating Matrix Type");
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
954
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
955 typ = MatrixType::Unknown;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
956
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
957 return typ;
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
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
960 int
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
961 MatrixType::type (const SparseMatrix &a)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
962 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
963 if (typ != MatrixType::Unknown && (full ||
6460
fa6312d93730 [project @ 2007-03-26 21:23:00 by dbateman]
dbateman
parents: 6452
diff changeset
964 sp_bandden == octave_sparse_params::get_bandden()))
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
965 {
5893
d73ffe42f2c8 [project @ 2006-07-16 07:48:19 by jwe]
jwe
parents: 5892
diff changeset
966 if (octave_sparse_params::get_key ("spumoni") != 0.)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
967 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
968 ("Using Cached Matrix Type");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
969
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
970 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
971 }
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 MatrixType tmp_typ (a);
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
974 typ = tmp_typ.typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
975 sp_bandden = tmp_typ.sp_bandden;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
976 bandden = tmp_typ.bandden;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
977 upper_band = tmp_typ.upper_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
978 lower_band = tmp_typ.lower_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
979 dense = tmp_typ.dense;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
980 full = tmp_typ.full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
981 nperm = tmp_typ.nperm;
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 if (nperm != 0)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
984 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
985 perm = new octave_idx_type [nperm];
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
986 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
987 perm[i] = tmp_typ.perm[i];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
988 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
989
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
990 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
991 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
992
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
993 int
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
994 MatrixType::type (const SparseComplexMatrix &a)
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 if (typ != MatrixType::Unknown && (full ||
6460
fa6312d93730 [project @ 2007-03-26 21:23:00 by dbateman]
dbateman
parents: 6452
diff changeset
997 sp_bandden == octave_sparse_params::get_bandden()))
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
998 {
5893
d73ffe42f2c8 [project @ 2006-07-16 07:48:19 by jwe]
jwe
parents: 5892
diff changeset
999 if (octave_sparse_params::get_key ("spumoni") != 0.)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1000 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1001 ("Using Cached Matrix Type");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1002
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1003 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1004 }
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 MatrixType tmp_typ (a);
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1007 typ = tmp_typ.typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1008 sp_bandden = tmp_typ.sp_bandden;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1009 bandden = tmp_typ.bandden;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1010 upper_band = tmp_typ.upper_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1011 lower_band = tmp_typ.lower_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1012 dense = tmp_typ.dense;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1013 full = tmp_typ.full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1014 nperm = tmp_typ.nperm;
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 if (nperm != 0)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1017 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1018 perm = new octave_idx_type [nperm];
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1019 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
1020 perm[i] = tmp_typ.perm[i];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1021 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1022
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1023 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1024 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1025
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1026 int
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1027 MatrixType::type (const Matrix &a)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1028 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1029 if (typ != MatrixType::Unknown)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1030 {
5893
d73ffe42f2c8 [project @ 2006-07-16 07:48:19 by jwe]
jwe
parents: 5892
diff changeset
1031 if (octave_sparse_params::get_key ("spumoni") != 0.)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1032 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1033 ("Using Cached Matrix Type");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1034
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1035 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1036 }
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 MatrixType tmp_typ (a);
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1039 typ = tmp_typ.typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1040 full = tmp_typ.full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1041 nperm = tmp_typ.nperm;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1042
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1043 if (nperm != 0)
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 perm = new octave_idx_type [nperm];
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1046 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
1047 perm[i] = tmp_typ.perm[i];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1048 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1049
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1050 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1051 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1052
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1053 int
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1054 MatrixType::type (const ComplexMatrix &a)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1055 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1056 if (typ != MatrixType::Unknown)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1057 {
5893
d73ffe42f2c8 [project @ 2006-07-16 07:48:19 by jwe]
jwe
parents: 5892
diff changeset
1058 if (octave_sparse_params::get_key ("spumoni") != 0.)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1059 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1060 ("Using Cached Matrix Type");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1061
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1062 return typ;
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
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1065 MatrixType tmp_typ (a);
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1066 typ = tmp_typ.typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1067 full = tmp_typ.full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1068 nperm = tmp_typ.nperm;
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 if (nperm != 0)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1071 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1072 perm = new octave_idx_type [nperm];
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1073 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
1074 perm[i] = tmp_typ.perm[i];
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1075 }
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 return typ;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1078 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1079
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1080 int
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1081 MatrixType::type (const FloatMatrix &a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1082 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1083 if (typ != MatrixType::Unknown)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1084 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1085 if (octave_sparse_params::get_key ("spumoni") != 0.)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1086 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1087 ("Using Cached Matrix Type");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1088
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1089 return typ;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1090 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1091
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1092 MatrixType tmp_typ (a);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1093 typ = tmp_typ.typ;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1094 full = tmp_typ.full;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1095 nperm = tmp_typ.nperm;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1096
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1097 if (nperm != 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1098 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1099 perm = new octave_idx_type [nperm];
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1100 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
1101 perm[i] = tmp_typ.perm[i];
7789
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
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1104 return typ;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1105 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1106
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1107 int
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1108 MatrixType::type (const FloatComplexMatrix &a)
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 if (typ != MatrixType::Unknown)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1111 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1112 if (octave_sparse_params::get_key ("spumoni") != 0.)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1113 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1114 ("Using Cached Matrix Type");
7789
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 return typ;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1117 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1118
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1119 MatrixType tmp_typ (a);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1120 typ = tmp_typ.typ;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1121 full = tmp_typ.full;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1122 nperm = tmp_typ.nperm;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1123
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1124 if (nperm != 0)
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 perm = new octave_idx_type [nperm];
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1127 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
1128 perm[i] = tmp_typ.perm[i];
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1129 }
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 return typ;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1132 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1133
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1134 void
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1135 MatrixType::info () const
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1136 {
5893
d73ffe42f2c8 [project @ 2006-07-16 07:48:19 by jwe]
jwe
parents: 5892
diff changeset
1137 if (octave_sparse_params::get_key ("spumoni") != 0.)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1138 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1139 if (typ == MatrixType::Unknown)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1140 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1141 ("Unknown Matrix Type");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1142 else if (typ == MatrixType::Diagonal)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1143 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1144 ("Diagonal Sparse Matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1145 else if (typ == MatrixType::Permuted_Diagonal)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1146 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1147 ("Permuted Diagonal Sparse Matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1148 else if (typ == MatrixType::Upper)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1149 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1150 ("Upper Triangular Matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1151 else if (typ == MatrixType::Lower)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1152 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1153 ("Lower Triangular Matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1154 else if (typ == MatrixType::Permuted_Upper)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1155 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1156 ("Permuted Upper Triangular Matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1157 else if (typ == MatrixType::Permuted_Lower)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1158 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1159 ("Permuted Lower Triangular Matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1160 else if (typ == MatrixType::Banded)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1161 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1162 ("Banded Sparse Matrix %d-1-%d (Density %f)", lower_band,
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1163 upper_band, bandden);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1164 else if (typ == MatrixType::Banded_Hermitian)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1165 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1166 ("Banded Hermitian/Symmetric Sparse Matrix %d-1-%d (Density %f)",
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1167 lower_band, upper_band, bandden);
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1168 else if (typ == MatrixType::Hermitian)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1169 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1170 ("Hermitian/Symmetric Matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1171 else if (typ == MatrixType::Tridiagonal)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1172 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1173 ("Tridiagonal Sparse Matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1174 else if (typ == MatrixType::Tridiagonal_Hermitian)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1175 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1176 ("Hermitian/Symmetric Tridiagonal Sparse Matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1177 else if (typ == MatrixType::Rectangular)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1178 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1179 ("Rectangular/Singular Matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1180 else if (typ == MatrixType::Full)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1181 (*current_liboctave_warning_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1182 ("Full Matrix");
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1183 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1184 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1185
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1186 void
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1187 MatrixType::mark_as_symmetric (void)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1188 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1189 if (typ == MatrixType::Tridiagonal ||
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1190 typ == MatrixType::Tridiagonal_Hermitian)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1191 typ = MatrixType::Tridiagonal_Hermitian;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1192 else if (typ == MatrixType::Banded ||
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1193 typ == MatrixType::Banded_Hermitian)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1194 typ = MatrixType::Banded_Hermitian;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1195 else if (typ == MatrixType::Full || typ == MatrixType::Hermitian ||
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1196 typ == MatrixType::Unknown)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1197 typ = MatrixType::Hermitian;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1198 else
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1199 (*current_liboctave_error_handler)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1200 ("Can not mark current matrix type as symmetric");
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1201 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1202
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1203 void
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1204 MatrixType::mark_as_unsymmetric (void)
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 if (typ == MatrixType::Tridiagonal ||
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1207 typ == MatrixType::Tridiagonal_Hermitian)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1208 typ = MatrixType::Tridiagonal;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1209 else if (typ == MatrixType::Banded ||
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1210 typ == MatrixType::Banded_Hermitian)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1211 typ = MatrixType::Banded;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1212 else if (typ == MatrixType::Full || typ == MatrixType::Hermitian ||
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
1213 typ == MatrixType::Unknown)
5785
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1214 typ = MatrixType::Full;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1215 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1216
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1217 void
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1218 MatrixType::mark_as_permuted (const octave_idx_type np, const octave_idx_type *p)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1219 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1220 nperm = np;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1221 perm = new octave_idx_type [nperm];
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1222 for (octave_idx_type i = 0; i < nperm; i++)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1223 perm[i] = p[i];
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1224
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1225 if (typ == MatrixType::Diagonal || typ == MatrixType::Permuted_Diagonal)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1226 typ = MatrixType::Permuted_Diagonal;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1227 else if (typ == MatrixType::Upper || typ == MatrixType::Permuted_Upper)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1228 typ = MatrixType::Permuted_Upper;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1229 else if (typ == MatrixType::Lower || typ == MatrixType::Permuted_Lower)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1230 typ = MatrixType::Permuted_Lower;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1231 else
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1232 (*current_liboctave_error_handler)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1233 ("Can not mark current matrix type as symmetric");
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
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1237 MatrixType::mark_as_unpermuted (void)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1238 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1239 if (nperm)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1240 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1241 nperm = 0;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1242 delete [] perm;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1243 }
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::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::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::Lower;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1251 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1252
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1253 MatrixType
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1254 MatrixType::transpose (void) const
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 MatrixType retval (*this);
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1257 if (typ == MatrixType::Upper)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1258 retval.typ = MatrixType::Lower;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1259 else if (typ == MatrixType::Permuted_Upper)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1260 retval.typ = MatrixType::Permuted_Lower;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1261 else if (typ == MatrixType::Lower)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1262 retval.typ = MatrixType::Upper;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1263 else if (typ == MatrixType::Permuted_Lower)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1264 retval.typ = MatrixType::Permuted_Upper;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1265 else if (typ == MatrixType::Banded)
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1266 {
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1267 retval.upper_band = lower_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1268 retval.lower_band = upper_band;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1269 }
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1270
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1271 return retval;
6b9cec830d72 [project @ 2006-05-03 19:32:46 by dbateman]
dbateman
parents:
diff changeset
1272 }