annotate liboctave/array/fCMatrix.cc @ 30554:117ebe363f56 stable

Fix handling of scalar exceptional values in inv() (bug #61689) * inv.cc (Finv): Pass "true" rather than '1' to inverse() function to match 'bool' argument. Pass 5th argument of true to inverse() to force calculation of condition number. Rename variable "rcond_plus_one_eq_one" to "is_singular" for clarity. Use isnan() to also catch singular matrices with NaN as reciprocal condition number. Don't emit warning for inverse of a scalar which thereby matches '/' and '\' operators. Add many BIST tests for various exceptional value inputs. * CMatrix.cc, dMatrix.cc, fCMatrix.cc, fMatrix.cc (inverse): Expand if conditional for MatrixType::Diagonal to check input parameter "calc_cond" and use an if/else tree to determine the reciprocal condition number (rcond) for a scalar.
author Rik <rik@octave.org>
date Sat, 25 Dec 2021 19:16:44 -0800
parents f3f3e3793fb5
children 796f54d4ddbf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3 // Copyright (C) 1994-2021 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21723
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21273
diff changeset
27 # include "config.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
28 #endif
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
29
23443
3f1bf237908b maint: Eliminate <cfloat.h> header from liboctave files.
Rik <rik@octave.org>
parents: 23433
diff changeset
30 #include <algorithm>
3f1bf237908b maint: Eliminate <cfloat.h> header from liboctave files.
Rik <rik@octave.org>
parents: 23433
diff changeset
31 #include <complex>
25438
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25237
diff changeset
32 #include <istream>
23443
3f1bf237908b maint: Eliminate <cfloat.h> header from liboctave files.
Rik <rik@octave.org>
parents: 23433
diff changeset
33 #include <limits>
25438
cb1606f78f6b prefer <istream>, <ostream>, or <iosfwd> to <iostream> where possible
John W. Eaton <jwe@octave.org>
parents: 25237
diff changeset
34 #include <ostream>
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
35
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
36 #include "Array-util.h"
9523
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9469
diff changeset
37 #include "DET.h"
19269
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 19065
diff changeset
38 #include "boolMatrix.h"
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 19065
diff changeset
39 #include "chMatrix.h"
21269
3c8a3d35661a better use of templates for Cholesky factorization
John W. Eaton <jwe@octave.org>
parents: 21266
diff changeset
40 #include "chol.h"
23443
3f1bf237908b maint: Eliminate <cfloat.h> header from liboctave files.
Rik <rik@octave.org>
parents: 23433
diff changeset
41 #include "fCColVector.h"
3f1bf237908b maint: Eliminate <cfloat.h> header from liboctave files.
Rik <rik@octave.org>
parents: 23433
diff changeset
42 #include "fCDiagMatrix.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
43 #include "fCMatrix.h"
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 19269
diff changeset
44 #include "fCNDArray.h"
19269
65554f5847ac don't include oct-locbuf.h in header files unnecessarily
John W. Eaton <jwe@octave.org>
parents: 19065
diff changeset
45 #include "fCRowVector.h"
22322
93b3cdd36854 move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents: 22317
diff changeset
46 #include "lo-blas-proto.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
47 #include "lo-error.h"
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
48 #include "lo-ieee.h"
22322
93b3cdd36854 move most f77 function decls to separate header files
John W. Eaton <jwe@octave.org>
parents: 22317
diff changeset
49 #include "lo-lapack-proto.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
50 #include "lo-mappers.h"
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
51 #include "lo-utils.h"
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
52 #include "mx-fcm-fdm.h"
9523
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9469
diff changeset
53 #include "mx-fcm-fs.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
54 #include "mx-fdm-fcm.h"
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
55 #include "mx-inlines.cc"
8774
b756ce0002db split implementation and interface in mx-op-defs and MArray-defs
Jaroslav Hajek <highegg@gmail.com>
parents: 8743
diff changeset
56 #include "mx-op-defs.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
57 #include "oct-cmplx.h"
9523
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9469
diff changeset
58 #include "oct-fftw.h"
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9469
diff changeset
59 #include "oct-locbuf.h"
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
60 #include "oct-norm.h"
23443
3f1bf237908b maint: Eliminate <cfloat.h> header from liboctave files.
Rik <rik@octave.org>
parents: 23433
diff changeset
61 #include "schur.h"
3f1bf237908b maint: Eliminate <cfloat.h> header from liboctave files.
Rik <rik@octave.org>
parents: 23433
diff changeset
62 #include "svd.h"
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
63
21723
bae585228161 use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents: 21721
diff changeset
64 static const FloatComplex FloatComplex_NaN_result (octave::numeric_limits<float>::NaN (),
bae585228161 use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents: 21721
diff changeset
65 octave::numeric_limits<float>::NaN ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
66
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
67 // FloatComplex Matrix class
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
68
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
69 FloatComplexMatrix::FloatComplexMatrix (const FloatMatrix& a)
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 19269
diff changeset
70 : FloatComplexNDArray (a)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22402
diff changeset
71 { }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
72
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
73 FloatComplexMatrix::FloatComplexMatrix (const FloatRowVector& rv)
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 19269
diff changeset
74 : FloatComplexNDArray (rv)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22402
diff changeset
75 { }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
76
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
77 FloatComplexMatrix::FloatComplexMatrix (const FloatColumnVector& cv)
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 19269
diff changeset
78 : FloatComplexNDArray (cv)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22402
diff changeset
79 { }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
80
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
81 FloatComplexMatrix::FloatComplexMatrix (const FloatDiagMatrix& a)
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 19269
diff changeset
82 : FloatComplexNDArray (a.dims (), 0.0)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
83 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
84 for (octave_idx_type i = 0; i < a.length (); i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
85 elem (i, i) = a.elem (i, i);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
86 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
87
19391
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
88 FloatComplexMatrix::FloatComplexMatrix (const MDiagArray2<float>& a)
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
89 : FloatComplexNDArray (a.dims (), 0.0)
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
90 {
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
91 for (octave_idx_type i = 0; i < a.length (); i++)
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
92 elem (i, i) = a.elem (i, i);
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
93 }
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
94
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
95 FloatComplexMatrix::FloatComplexMatrix (const DiagArray2<float>& a)
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
96 : FloatComplexNDArray (a.dims (), 0.0)
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
97 {
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
98 for (octave_idx_type i = 0; i < a.length (); i++)
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
99 elem (i, i) = a.elem (i, i);
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
100 }
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
101
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
102 FloatComplexMatrix::FloatComplexMatrix (const FloatComplexRowVector& rv)
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 19269
diff changeset
103 : FloatComplexNDArray (rv)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22402
diff changeset
104 { }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
105
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
106 FloatComplexMatrix::FloatComplexMatrix (const FloatComplexColumnVector& cv)
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 19269
diff changeset
107 : FloatComplexNDArray (cv)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22402
diff changeset
108 { }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
109
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
110 FloatComplexMatrix::FloatComplexMatrix (const FloatComplexDiagMatrix& a)
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 19269
diff changeset
111 : FloatComplexNDArray (a.dims (), 0.0)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
112 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
113 for (octave_idx_type i = 0; i < a.length (); i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
114 elem (i, i) = a.elem (i, i);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
115 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
116
19391
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
117 FloatComplexMatrix::FloatComplexMatrix (const MDiagArray2<FloatComplex>& a)
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
118 : FloatComplexNDArray (a.dims (), 0.0)
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
119 {
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
120 for (octave_idx_type i = 0; i < a.length (); i++)
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
121 elem (i, i) = a.elem (i, i);
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
122 }
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
123
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
124 FloatComplexMatrix::FloatComplexMatrix (const DiagArray2<FloatComplex>& a)
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
125 : FloatComplexNDArray (a.dims (), 0.0)
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
126 {
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
127 for (octave_idx_type i = 0; i < a.length (); i++)
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
128 elem (i, i) = a.elem (i, i);
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
129 }
385499581a5e allow disabling of permutation and diagonal matrices
John W. Eaton <jwe@octave.org>
parents: 19321
diff changeset
130
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
131 // FIXME: could we use a templated mixed-type copy function
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
132 // here?
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
133
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
134 FloatComplexMatrix::FloatComplexMatrix (const boolMatrix& a)
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 19269
diff changeset
135 : FloatComplexNDArray (a)
22417
48c00363dc74 maint: Use '{ }' for empty function bodies in C++.
Rik <rik@octave.org>
parents: 22402
diff changeset
136 { }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
137
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
138 FloatComplexMatrix::FloatComplexMatrix (const charMatrix& a)
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 19269
diff changeset
139 : FloatComplexNDArray (a.dims (), 0.0)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
140 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
141 for (octave_idx_type i = 0; i < a.rows (); i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
142 for (octave_idx_type j = 0; j < a.cols (); j++)
8956
d91fa4b20bbb ensure nonnegative char -> real conversion
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
143 elem (i, j) = static_cast<unsigned char> (a.elem (i, j));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
144 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
145
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
146 FloatComplexMatrix::FloatComplexMatrix (const FloatMatrix& re,
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
147 const FloatMatrix& im)
19320
d0c73e23a505 Change inheritance tree so that <T>Matrix inherit from <T>NDArray.
Carnë Draug <carandraug@octave.org>
parents: 19269
diff changeset
148 : FloatComplexNDArray (re.dims ())
9663
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
149 {
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
150 if (im.rows () != rows () || im.cols () != cols ())
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
151 (*current_liboctave_error_handler) ("complex: internal error");
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
152
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
153 octave_idx_type nel = numel ();
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
154 for (octave_idx_type i = 0; i < nel; i++)
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
155 xelem (i) = FloatComplex (re(i), im(i));
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
156 }
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
157
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
158 bool
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
159 FloatComplexMatrix::operator == (const FloatComplexMatrix& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
160 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
161 if (rows () != a.rows () || cols () != a.cols ())
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
162 return false;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
163
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
164 return mx_inline_equal (numel (), data (), a.data ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
165 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
166
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
167 bool
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
168 FloatComplexMatrix::operator != (const FloatComplexMatrix& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
169 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
170 return !(*this == a);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
171 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
172
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
173 bool
23594
af5b813503cb maint: Deprecate is_hermitian and replace with ishermitian.
Rik <rik@octave.org>
parents: 23593
diff changeset
174 FloatComplexMatrix::ishermitian (void) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
175 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
176 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
177 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
178
23593
a8361bc2361a maint: Deprecate is_square and replace with issquare.
Rik <rik@octave.org>
parents: 23561
diff changeset
179 if (issquare () && nr > 0)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
180 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
181 for (octave_idx_type i = 0; i < nr; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
182 for (octave_idx_type j = i; j < nc; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
183 if (elem (i, j) != conj (elem (j, i)))
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
184 return false;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
185
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
186 return true;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
187 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
188
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
189 return false;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
190 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
191
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
192 // destructive insert/delete/reorder operations
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
193
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
194 FloatComplexMatrix&
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
195 FloatComplexMatrix::insert (const FloatMatrix& a,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
196 octave_idx_type r, octave_idx_type c)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
197 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
198 octave_idx_type a_nr = a.rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
199 octave_idx_type a_nc = a.cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
200
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
201 if (r < 0 || r + a_nr > rows () || c < 0 || c + a_nc > cols ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
202 (*current_liboctave_error_handler) ("range error for insert");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
203
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
204 if (a_nr >0 && a_nc > 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
205 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
206 make_unique ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
207
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
208 for (octave_idx_type j = 0; j < a_nc; j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
209 for (octave_idx_type i = 0; i < a_nr; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
210 xelem (r+i, c+j) = a.elem (i, j);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
211 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
212
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
213 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
214 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
215
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
216 FloatComplexMatrix&
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
217 FloatComplexMatrix::insert (const FloatRowVector& a,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
218 octave_idx_type r, octave_idx_type c)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
219 {
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
220 octave_idx_type a_len = a.numel ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
221
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
222 if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
223 (*current_liboctave_error_handler) ("range error for insert");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
224
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
225 if (a_len > 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
226 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
227 make_unique ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
228
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
229 for (octave_idx_type i = 0; i < a_len; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
230 xelem (r, c+i) = a.elem (i);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
231 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
232
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
233 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
234 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
235
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
236 FloatComplexMatrix&
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
237 FloatComplexMatrix::insert (const FloatColumnVector& a,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
238 octave_idx_type r, octave_idx_type c)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
239 {
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
240 octave_idx_type a_len = a.numel ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
241
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
242 if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
243 (*current_liboctave_error_handler) ("range error for insert");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
244
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
245 if (a_len > 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
246 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
247 make_unique ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
248
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
249 for (octave_idx_type i = 0; i < a_len; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
250 xelem (r+i, c) = a.elem (i);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
251 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
252
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
253 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
254 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
255
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
256 FloatComplexMatrix&
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
257 FloatComplexMatrix::insert (const FloatDiagMatrix& a,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
258 octave_idx_type r, octave_idx_type c)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
259 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
260 octave_idx_type a_nr = a.rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
261 octave_idx_type a_nc = a.cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
262
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
263 if (r < 0 || r + a_nr > rows () || c < 0 || c + a_nc > cols ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
264 (*current_liboctave_error_handler) ("range error for insert");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
265
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
266 fill (0.0, r, c, r + a_nr - 1, c + a_nc - 1);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
267
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
268 octave_idx_type a_len = a.length ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
269
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
270 if (a_len > 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
271 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
272 make_unique ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
273
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
274 for (octave_idx_type i = 0; i < a_len; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
275 xelem (r+i, c+i) = a.elem (i, i);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
276 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
277
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
278 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
279 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
280
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
281 FloatComplexMatrix&
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
282 FloatComplexMatrix::insert (const FloatComplexMatrix& a,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
283 octave_idx_type r, octave_idx_type c)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
284 {
10350
12884915a8e4 merge MArray classes & improve Array interface
Jaroslav Hajek <highegg@gmail.com>
parents: 10314
diff changeset
285 Array<FloatComplex>::insert (a, r, c);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
286 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
287 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
288
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
289 FloatComplexMatrix&
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
290 FloatComplexMatrix::insert (const FloatComplexRowVector& a,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
291 octave_idx_type r, octave_idx_type c)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
292 {
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
293 octave_idx_type a_len = a.numel ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
294 if (r < 0 || r >= rows () || c < 0 || c + a_len > cols ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
295 (*current_liboctave_error_handler) ("range error for insert");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
296
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
297 for (octave_idx_type i = 0; i < a_len; i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
298 elem (r, c+i) = a.elem (i);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
299
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
300 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
301 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
302
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
303 FloatComplexMatrix&
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
304 FloatComplexMatrix::insert (const FloatComplexColumnVector& a,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
305 octave_idx_type r, octave_idx_type c)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
306 {
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
307 octave_idx_type a_len = a.numel ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
308
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
309 if (r < 0 || r + a_len > rows () || c < 0 || c >= cols ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
310 (*current_liboctave_error_handler) ("range error for insert");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
311
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
312 if (a_len > 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
313 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
314 make_unique ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
315
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
316 for (octave_idx_type i = 0; i < a_len; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
317 xelem (r+i, c) = a.elem (i);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
318 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
319
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
320 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
321 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
322
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
323 FloatComplexMatrix&
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
324 FloatComplexMatrix::insert (const FloatComplexDiagMatrix& a,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
325 octave_idx_type r, octave_idx_type c)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
326 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
327 octave_idx_type a_nr = a.rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
328 octave_idx_type a_nc = a.cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
329
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
330 if (r < 0 || r + a_nr > rows () || c < 0 || c + a_nc > cols ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
331 (*current_liboctave_error_handler) ("range error for insert");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
332
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
333 fill (0.0, r, c, r + a_nr - 1, c + a_nc - 1);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
334
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
335 octave_idx_type a_len = a.length ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
336
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
337 if (a_len > 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
338 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
339 make_unique ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
340
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
341 for (octave_idx_type i = 0; i < a_len; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
342 xelem (r+i, c+i) = a.elem (i, i);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
343 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
344
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
345 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
346 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
347
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
348 FloatComplexMatrix&
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
349 FloatComplexMatrix::fill (float val)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
350 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
351 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
352 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
353
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
354 if (nr > 0 && nc > 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
355 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
356 make_unique ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
357
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
358 for (octave_idx_type j = 0; j < nc; j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
359 for (octave_idx_type i = 0; i < nr; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
360 xelem (i, j) = val;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
361 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
362
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
363 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
364 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
365
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
366 FloatComplexMatrix&
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
367 FloatComplexMatrix::fill (const FloatComplex& val)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
368 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
369 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
370 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
371
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
372 if (nr > 0 && nc > 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
373 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
374 make_unique ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
375
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
376 for (octave_idx_type j = 0; j < nc; j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
377 for (octave_idx_type i = 0; i < nr; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
378 xelem (i, j) = val;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
379 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
380
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
381 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
382 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
383
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
384 FloatComplexMatrix&
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
385 FloatComplexMatrix::fill (float val, octave_idx_type r1, octave_idx_type c1,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
386 octave_idx_type r2, octave_idx_type c2)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
387 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
388 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
389 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
390
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
391 if (r1 < 0 || r2 < 0 || c1 < 0 || c2 < 0
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
392 || r1 >= nr || r2 >= nr || c1 >= nc || c2 >= nc)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
393 (*current_liboctave_error_handler) ("range error for fill");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
394
17663
7975d75f933c Use std::swap in liboctave instead of temporary variable.
Rik <rik@octave.org>
parents: 16300
diff changeset
395 if (r1 > r2) { std::swap (r1, r2); }
7975d75f933c Use std::swap in liboctave instead of temporary variable.
Rik <rik@octave.org>
parents: 16300
diff changeset
396 if (c1 > c2) { std::swap (c1, c2); }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
397
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
398 if (r2 >= r1 && c2 >= c1)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
399 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
400 make_unique ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
401
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
402 for (octave_idx_type j = c1; j <= c2; j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
403 for (octave_idx_type i = r1; i <= r2; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
404 xelem (i, j) = val;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
405 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
406
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
407 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
408 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
409
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
410 FloatComplexMatrix&
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
411 FloatComplexMatrix::fill (const FloatComplex& val,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
412 octave_idx_type r1, octave_idx_type c1,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
413 octave_idx_type r2, octave_idx_type c2)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
414 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
415 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
416 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
417
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
418 if (r1 < 0 || r2 < 0 || c1 < 0 || c2 < 0
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
419 || r1 >= nr || r2 >= nr || c1 >= nc || c2 >= nc)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
420 (*current_liboctave_error_handler) ("range error for fill");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
421
17663
7975d75f933c Use std::swap in liboctave instead of temporary variable.
Rik <rik@octave.org>
parents: 16300
diff changeset
422 if (r1 > r2) { std::swap (r1, r2); }
7975d75f933c Use std::swap in liboctave instead of temporary variable.
Rik <rik@octave.org>
parents: 16300
diff changeset
423 if (c1 > c2) { std::swap (c1, c2); }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
424
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
425 if (r2 >= r1 && c2 >=c1)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
426 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
427 make_unique ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
428
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
429 for (octave_idx_type j = c1; j <= c2; j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
430 for (octave_idx_type i = r1; i <= r2; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
431 xelem (i, j) = val;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
432 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
433
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
434 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
435 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
436
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
437 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
438 FloatComplexMatrix::append (const FloatMatrix& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
439 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
440 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
441 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
442 if (nr != a.rows ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
443 (*current_liboctave_error_handler) ("row dimension mismatch for append");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
444
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
445 octave_idx_type nc_insert = nc;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
446 FloatComplexMatrix retval (nr, nc + a.cols ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
447 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
448 retval.insert (a, 0, nc_insert);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
449 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
450 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
451
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
452 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
453 FloatComplexMatrix::append (const FloatRowVector& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
454 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
455 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
456 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
457 if (nr != 1)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
458 (*current_liboctave_error_handler) ("row dimension mismatch for append");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
459
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
460 octave_idx_type nc_insert = nc;
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
461 FloatComplexMatrix retval (nr, nc + a.numel ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
462 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
463 retval.insert (a, 0, nc_insert);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
464 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
465 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
466
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
467 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
468 FloatComplexMatrix::append (const FloatColumnVector& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
469 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
470 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
471 octave_idx_type nc = cols ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
472 if (nr != a.numel ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
473 (*current_liboctave_error_handler) ("row dimension mismatch for append");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
474
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
475 octave_idx_type nc_insert = nc;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
476 FloatComplexMatrix retval (nr, nc + 1);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
477 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
478 retval.insert (a, 0, nc_insert);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
479 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
480 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
481
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
482 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
483 FloatComplexMatrix::append (const FloatDiagMatrix& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
484 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
485 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
486 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
487 if (nr != a.rows ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
488 (*current_liboctave_error_handler) ("row dimension mismatch for append");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
489
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
490 octave_idx_type nc_insert = nc;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
491 FloatComplexMatrix retval (nr, nc + a.cols ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
492 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
493 retval.insert (a, 0, nc_insert);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
494 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
495 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
496
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
497 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
498 FloatComplexMatrix::append (const FloatComplexMatrix& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
499 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
500 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
501 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
502 if (nr != a.rows ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
503 (*current_liboctave_error_handler) ("row dimension mismatch for append");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
504
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
505 octave_idx_type nc_insert = nc;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
506 FloatComplexMatrix retval (nr, nc + a.cols ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
507 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
508 retval.insert (a, 0, nc_insert);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
509 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
510 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
511
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
512 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
513 FloatComplexMatrix::append (const FloatComplexRowVector& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
514 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
515 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
516 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
517 if (nr != 1)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
518 (*current_liboctave_error_handler) ("row dimension mismatch for append");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
519
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
520 octave_idx_type nc_insert = nc;
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
521 FloatComplexMatrix retval (nr, nc + a.numel ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
522 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
523 retval.insert (a, 0, nc_insert);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
524 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
525 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
526
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
527 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
528 FloatComplexMatrix::append (const FloatComplexColumnVector& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
529 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
530 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
531 octave_idx_type nc = cols ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
532 if (nr != a.numel ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
533 (*current_liboctave_error_handler) ("row dimension mismatch for append");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
534
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
535 octave_idx_type nc_insert = nc;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
536 FloatComplexMatrix retval (nr, nc + 1);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
537 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
538 retval.insert (a, 0, nc_insert);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
539 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
540 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
541
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
542 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
543 FloatComplexMatrix::append (const FloatComplexDiagMatrix& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
544 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
545 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
546 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
547 if (nr != a.rows ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
548 (*current_liboctave_error_handler) ("row dimension mismatch for append");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
549
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
550 octave_idx_type nc_insert = nc;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
551 FloatComplexMatrix retval (nr, nc + a.cols ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
552 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
553 retval.insert (a, 0, nc_insert);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
554 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
555 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
556
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
557 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
558 FloatComplexMatrix::stack (const FloatMatrix& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
559 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
560 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
561 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
562 if (nc != a.cols ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
563 (*current_liboctave_error_handler) ("column dimension mismatch for stack");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
564
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
565 octave_idx_type nr_insert = nr;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
566 FloatComplexMatrix retval (nr + a.rows (), nc);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
567 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
568 retval.insert (a, nr_insert, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
569 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
570 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
571
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
572 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
573 FloatComplexMatrix::stack (const FloatRowVector& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
574 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
575 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
576 octave_idx_type nc = cols ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
577 if (nc != a.numel ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
578 (*current_liboctave_error_handler) ("column dimension mismatch for stack");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
579
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
580 octave_idx_type nr_insert = nr;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
581 FloatComplexMatrix retval (nr + 1, nc);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
582 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
583 retval.insert (a, nr_insert, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
584 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
585 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
586
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
587 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
588 FloatComplexMatrix::stack (const FloatColumnVector& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
589 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
590 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
591 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
592 if (nc != 1)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
593 (*current_liboctave_error_handler) ("column dimension mismatch for stack");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
594
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
595 octave_idx_type nr_insert = nr;
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
596 FloatComplexMatrix retval (nr + a.numel (), nc);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
597 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
598 retval.insert (a, nr_insert, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
599 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
600 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
601
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
602 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
603 FloatComplexMatrix::stack (const FloatDiagMatrix& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
604 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
605 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
606 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
607 if (nc != a.cols ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
608 (*current_liboctave_error_handler) ("column dimension mismatch for stack");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
609
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
610 octave_idx_type nr_insert = nr;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
611 FloatComplexMatrix retval (nr + a.rows (), nc);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
612 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
613 retval.insert (a, nr_insert, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
614 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
615 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
616
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
617 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
618 FloatComplexMatrix::stack (const FloatComplexMatrix& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
619 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
620 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
621 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
622 if (nc != a.cols ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
623 (*current_liboctave_error_handler) ("column dimension mismatch for stack");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
624
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
625 octave_idx_type nr_insert = nr;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
626 FloatComplexMatrix retval (nr + a.rows (), nc);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
627 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
628 retval.insert (a, nr_insert, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
629 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
630 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
631
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
632 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
633 FloatComplexMatrix::stack (const FloatComplexRowVector& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
634 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
635 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
636 octave_idx_type nc = cols ();
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
637 if (nc != a.numel ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
638 (*current_liboctave_error_handler) ("column dimension mismatch for stack");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
639
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
640 octave_idx_type nr_insert = nr;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
641 FloatComplexMatrix retval (nr + 1, nc);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
642 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
643 retval.insert (a, nr_insert, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
644 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
645 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
646
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
647 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
648 FloatComplexMatrix::stack (const FloatComplexColumnVector& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
649 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
650 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
651 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
652 if (nc != 1)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
653 (*current_liboctave_error_handler) ("column dimension mismatch for stack");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
654
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
655 octave_idx_type nr_insert = nr;
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
656 FloatComplexMatrix retval (nr + a.numel (), nc);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
657 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
658 retval.insert (a, nr_insert, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
659 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
660 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
661
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
662 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
663 FloatComplexMatrix::stack (const FloatComplexDiagMatrix& a) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
664 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
665 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
666 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
667 if (nc != a.cols ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
668 (*current_liboctave_error_handler) ("column dimension mismatch for stack");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
669
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
670 octave_idx_type nr_insert = nr;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
671 FloatComplexMatrix retval (nr + a.rows (), nc);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
672 retval.insert (*this, 0, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
673 retval.insert (a, nr_insert, 0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
674 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
675 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
676
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
677 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
678 conj (const FloatComplexMatrix& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
679 {
23534
b6498c088fca maint: Don't write '> >' for declaration of templates that use templates.
Rik <rik@octave.org>
parents: 23461
diff changeset
680 return do_mx_unary_map<FloatComplex, FloatComplex, std::conj<float>> (a);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
681 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
682
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
683 // resize is the destructive equivalent for this one
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
684
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
685 FloatComplexMatrix
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
686 FloatComplexMatrix::extract (octave_idx_type r1, octave_idx_type c1,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
687 octave_idx_type r2, octave_idx_type c2) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
688 {
17663
7975d75f933c Use std::swap in liboctave instead of temporary variable.
Rik <rik@octave.org>
parents: 16300
diff changeset
689 if (r1 > r2) { std::swap (r1, r2); }
7975d75f933c Use std::swap in liboctave instead of temporary variable.
Rik <rik@octave.org>
parents: 16300
diff changeset
690 if (c1 > c2) { std::swap (c1, c2); }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
691
29569
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
692 return index (octave::idx_vector (r1, r2+1), octave::idx_vector (c1, c2+1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
693 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
694
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
695 FloatComplexMatrix
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
696 FloatComplexMatrix::extract_n (octave_idx_type r1, octave_idx_type c1,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
697 octave_idx_type nr, octave_idx_type nc) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
698 {
29569
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
699 return index (octave::idx_vector (r1, r1 + nr), octave::idx_vector (c1, c1 + nc));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
700 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
701
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
702 // extract row or column i.
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
703
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
704 FloatComplexRowVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
705 FloatComplexMatrix::row (octave_idx_type i) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
706 {
29569
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
707 return index (octave::idx_vector (i), octave::idx_vector::colon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
708 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
709
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
710 FloatComplexColumnVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
711 FloatComplexMatrix::column (octave_idx_type i) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
712 {
29569
29a1f8fd8ee6 move idx_vector classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 29359
diff changeset
713 return index (octave::idx_vector::colon, octave::idx_vector (i));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
714 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
715
24300
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
716 // Local function to calculate the 1-norm.
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
717 static
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
718 float
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
719 norm1 (const FloatComplexMatrix& a)
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
720 {
24311
0643533930e7 Return NaN arrays for left division operator when operands contain NaNs (bug #52516).
Rik <rik@octave.org>
parents: 24301
diff changeset
721 float anorm = 0.0;
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
722 FloatRowVector colsum = a.abs ().sum ().row (0);
24300
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
723
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
724 for (octave_idx_type i = 0; i < colsum.numel (); i++)
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
725 {
24311
0643533930e7 Return NaN arrays for left division operator when operands contain NaNs (bug #52516).
Rik <rik@octave.org>
parents: 24301
diff changeset
726 float sum = colsum.xelem (i);
0643533930e7 Return NaN arrays for left division operator when operands contain NaNs (bug #52516).
Rik <rik@octave.org>
parents: 24301
diff changeset
727 if (octave::math::isinf (sum) || octave::math::isnan (sum))
24300
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
728 {
24311
0643533930e7 Return NaN arrays for left division operator when operands contain NaNs (bug #52516).
Rik <rik@octave.org>
parents: 24301
diff changeset
729 anorm = sum; // Pass Inf or NaN to output
24300
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
730 break;
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
731 }
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
732 else
24311
0643533930e7 Return NaN arrays for left division operator when operands contain NaNs (bug #52516).
Rik <rik@octave.org>
parents: 24301
diff changeset
733 anorm = std::max (anorm, sum);
24300
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
734 }
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
735
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
736 return anorm;
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
737 }
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
738
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
739 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
740 FloatComplexMatrix::inverse (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
741 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
742 octave_idx_type info;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
743 float rcon;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
744 MatrixType mattype (*this);
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
745 return inverse (mattype, info, rcon, 0, 0);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
746 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
747
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
748 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
749 FloatComplexMatrix::inverse (octave_idx_type& info) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
750 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
751 float rcon;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
752 MatrixType mattype (*this);
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
753 return inverse (mattype, info, rcon, 0, 0);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
754 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
755
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
756 FloatComplexMatrix
21719
ff054947d132 use bool instead of int for some logical flags
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
757 FloatComplexMatrix::inverse (octave_idx_type& info, float& rcon, bool force,
ff054947d132 use bool instead of int for some logical flags
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
758 bool calc_cond) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
759 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
760 MatrixType mattype (*this);
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
761 return inverse (mattype, info, rcon, force, calc_cond);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
762 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
763
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
764 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
765 FloatComplexMatrix::inverse (MatrixType& mattype) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
766 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
767 octave_idx_type info;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
768 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
769 return inverse (mattype, info, rcon, 0, 0);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
770 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
771
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
772 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
773 FloatComplexMatrix::inverse (MatrixType& mattype, octave_idx_type& info) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
774 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
775 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
776 return inverse (mattype, info, rcon, 0, 0);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
777 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
778
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
779 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
780 FloatComplexMatrix::tinverse (MatrixType& mattype, octave_idx_type& info,
21719
ff054947d132 use bool instead of int for some logical flags
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
781 float& rcon, bool force, bool calc_cond) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
782 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
783 FloatComplexMatrix retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
784
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
785 F77_INT nr = octave::to_f77_int (rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
786 F77_INT nc = octave::to_f77_int (cols ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
787
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
788 if (nr != nc || nr == 0 || nc == 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
789 (*current_liboctave_error_handler) ("inverse requires square matrix");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
790
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
791 int typ = mattype.type ();
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
792 char uplo = (typ == MatrixType::Lower ? 'L' : 'U');
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
793 char udiag = 'N';
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
794 retval = *this;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
795 FloatComplex *tmp_data = retval.fortran_vec ();
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
796
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
797 F77_INT tmp_info = 0;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
798
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
799 F77_XFCN (ctrtri, CTRTRI, (F77_CONST_CHAR_ARG2 (&uplo, 1),
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
800 F77_CONST_CHAR_ARG2 (&udiag, 1),
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
801 nr, F77_CMPLX_ARG (tmp_data), nr, tmp_info
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
802 F77_CHAR_ARG_LEN (1)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
803 F77_CHAR_ARG_LEN (1)));
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
804
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
805 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
806
24291
cf33c1b910b7 maint: Correct typo in comment "Throw-away" => "Throw away"
Rik <rik@octave.org>
parents: 24251
diff changeset
807 // Throw away extra info LAPACK gives so as to not change output.
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
808 rcon = 0.0;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
809 if (info != 0)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
810 info = -1;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
811 else if (calc_cond)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
812 {
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
813 F77_INT ztrcon_info = 0;
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
814 char job = '1';
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
815
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
816 OCTAVE_LOCAL_BUFFER (FloatComplex, cwork, 2*nr);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
817 OCTAVE_LOCAL_BUFFER (float, rwork, nr);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
818
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
819 F77_XFCN (ctrcon, CTRCON, (F77_CONST_CHAR_ARG2 (&job, 1),
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
820 F77_CONST_CHAR_ARG2 (&uplo, 1),
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
821 F77_CONST_CHAR_ARG2 (&udiag, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
822 nr, F77_CMPLX_ARG (tmp_data), nr, rcon,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
823 F77_CMPLX_ARG (cwork), rwork, ztrcon_info
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
824 F77_CHAR_ARG_LEN (1)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
825 F77_CHAR_ARG_LEN (1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
826 F77_CHAR_ARG_LEN (1)));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
827
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
828 if (ztrcon_info != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
829 info = -1;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
830 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
831
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
832 if (info == -1 && ! force)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
833 retval = *this; // Restore matrix contents.
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
834
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
835 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
836 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
837
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
838 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
839 FloatComplexMatrix::finverse (MatrixType& mattype, octave_idx_type& info,
21719
ff054947d132 use bool instead of int for some logical flags
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
840 float& rcon, bool force, bool calc_cond) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
841 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
842 FloatComplexMatrix retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
843
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
844 F77_INT nr = octave::to_f77_int (rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
845 F77_INT nc = octave::to_f77_int (cols ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
846
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
847 if (nr != nc)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
848 (*current_liboctave_error_handler) ("inverse requires square matrix");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
849
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
850 Array<F77_INT> ipvt (dim_vector (nr, 1));
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
851 F77_INT *pipvt = ipvt.fortran_vec ();
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
852
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
853 retval = *this;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
854 FloatComplex *tmp_data = retval.fortran_vec ();
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
855
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
856 Array<FloatComplex> z (dim_vector (1, 1));
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
857 F77_INT lwork = -1;
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
858
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
859 // Query the optimum work array size.
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
860
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
861 F77_INT tmp_info = 0;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
862
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
863 F77_XFCN (cgetri, CGETRI, (nc, F77_CMPLX_ARG (tmp_data), nr, pipvt,
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
864 F77_CMPLX_ARG (z.fortran_vec ()), lwork,
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
865 tmp_info));
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
866
23708
750e42a35adc Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents: 23594
diff changeset
867 lwork = static_cast<F77_INT> (std::real (z(0)));
24035
bc0aa7e18c96 fix possible array bounds error when calculating inverse (bug #49235)
Mike Miller <mtmiller@octave.org>
parents: 23807
diff changeset
868 lwork = (lwork < 2 * nc ? 2 * nc : lwork);
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
869 z.resize (dim_vector (lwork, 1));
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
870 FloatComplex *pz = z.fortran_vec ();
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
871
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
872 info = 0;
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
873 tmp_info = 0;
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
874
24300
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
875 // Calculate norm of the matrix (always, see bug #45577) for later use.
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
876 float anorm = norm1 (retval);
22085
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
877
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
878 // Work around bug #45577, LAPACK crashes Octave if norm is NaN
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
879 // and bug #46330, segfault with matrices containing Inf & NaN
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
880 if (octave::math::isnan (anorm) || octave::math::isinf (anorm))
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
881 info = -1;
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
882 else
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
883 {
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
884 F77_XFCN (cgetrf, CGETRF, (nc, nc, F77_CMPLX_ARG (tmp_data), nr, pipvt,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
885 tmp_info));
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
886
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
887 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
888 }
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
889
24291
cf33c1b910b7 maint: Correct typo in comment "Throw-away" => "Throw away"
Rik <rik@octave.org>
parents: 24251
diff changeset
890 // Throw away extra info LAPACK gives so as to not change output.
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
891 rcon = 0.0;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
892 if (info != 0)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
893 info = -1;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
894 else if (calc_cond)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
895 {
24035
bc0aa7e18c96 fix possible array bounds error when calculating inverse (bug #49235)
Mike Miller <mtmiller@octave.org>
parents: 23807
diff changeset
896 F77_INT cgecon_info = 0;
bc0aa7e18c96 fix possible array bounds error when calculating inverse (bug #49235)
Mike Miller <mtmiller@octave.org>
parents: 23807
diff changeset
897
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
898 // Now calculate the condition number for non-singular matrix.
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
899 char job = '1';
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
900 Array<float> rz (dim_vector (2 * nc, 1));
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
901 float *prz = rz.fortran_vec ();
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
902 F77_XFCN (cgecon, CGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
903 nc, F77_CMPLX_ARG (tmp_data), nr, anorm,
24035
bc0aa7e18c96 fix possible array bounds error when calculating inverse (bug #49235)
Mike Miller <mtmiller@octave.org>
parents: 23807
diff changeset
904 rcon, F77_CMPLX_ARG (pz), prz, cgecon_info
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
905 F77_CHAR_ARG_LEN (1)));
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
906
24035
bc0aa7e18c96 fix possible array bounds error when calculating inverse (bug #49235)
Mike Miller <mtmiller@octave.org>
parents: 23807
diff changeset
907 if (cgecon_info != 0)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
908 info = -1;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
909 }
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
910
23560
286d85b43bdc Fix crash when inverting complex matrices with NaNs (bug #51198).
Sébastien Villemot <sebastien@debian.org>
parents: 23219
diff changeset
911 if ((info == -1 && ! force)
286d85b43bdc Fix crash when inverting complex matrices with NaNs (bug #51198).
Sébastien Villemot <sebastien@debian.org>
parents: 23219
diff changeset
912 || octave::math::isnan (anorm) || octave::math::isinf (anorm))
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
913 retval = *this; // Restore contents.
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
914 else
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
915 {
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
916 F77_INT zgetri_info = 0;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
917
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
918 F77_XFCN (cgetri, CGETRI, (nc, F77_CMPLX_ARG (tmp_data), nr, pipvt,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
919 F77_CMPLX_ARG (pz), lwork, zgetri_info));
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
920
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
921 if (zgetri_info != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
922 info = -1;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
923 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
924
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
925 if (info != 0)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
926 mattype.mark_as_rectangular ();
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
927
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
928 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
929 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
930
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
931 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
932 FloatComplexMatrix::inverse (MatrixType& mattype, octave_idx_type& info,
21719
ff054947d132 use bool instead of int for some logical flags
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
933 float& rcon, bool force, bool calc_cond) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
934 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
935 int typ = mattype.type (false);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
936 FloatComplexMatrix ret;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
937
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
938 if (typ == MatrixType::Unknown)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
939 typ = mattype.type (*this);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
940
30554
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
941 if (typ == MatrixType::Diagonal) // a scalar is classified as Diagonal.
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
942 {
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
943 FloatComplex scalar = this->elem (0);
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
944 float real = std::real (scalar);
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
945 float imag = std::imag (scalar);
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
946
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
947 if (real == 0 && imag == 0)
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
948 ret = FloatComplexMatrix (1, 1,
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
949 FloatComplex (octave::numeric_limits<float>::Inf (), 0.0));
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
950 else
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
951 ret = FloatComplex (1, 0) / (*this);
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
952
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
953 if (calc_cond)
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
954 {
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
955 if (octave::math::isfinite (real) && octave::math::isfinite (imag)
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
956 && (real != 0 || imag != 0))
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
957 rcon = 1.0f;
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
958 else if (octave::math::isinf (real) || octave::math::isinf (imag)
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
959 || (real == 0 && imag == 0))
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
960 rcon = 0.0f;
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
961 else
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
962 rcon = octave::numeric_limits<float>::NaN ();
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
963 }
117ebe363f56 Fix handling of scalar exceptional values in inv() (bug #61689)
Rik <rik@octave.org>
parents: 30394
diff changeset
964 }
30313
98400baa509f Return Inf for inv(0) for compatibility with division operator and Matlab (bug #52285).
Rik <rik@octave.org>
parents: 30073
diff changeset
965 else if (typ == MatrixType::Upper || typ == MatrixType::Lower)
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
966 ret = tinverse (mattype, info, rcon, force, calc_cond);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
967 else
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
968 {
23594
af5b813503cb maint: Deprecate is_hermitian and replace with ishermitian.
Rik <rik@octave.org>
parents: 23593
diff changeset
969 if (mattype.ishermitian ())
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
970 {
22317
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22274
diff changeset
971 octave::math::chol<FloatComplexMatrix> chol (*this, info, true, calc_cond);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
972 if (info == 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
973 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
974 if (calc_cond)
14846
460a3c6d8bf1 maint: Use Octave coding convention for cuddled parenthis in function calls with empty argument lists.
Rik <octave@nomad.inbox5.com>
parents: 14557
diff changeset
975 rcon = chol.rcond ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
976 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
977 rcon = 1.0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
978 ret = chol.inverse ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
979 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
980 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
981 mattype.mark_as_unsymmetric ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
982 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
983
23594
af5b813503cb maint: Deprecate is_hermitian and replace with ishermitian.
Rik <rik@octave.org>
parents: 23593
diff changeset
984 if (! mattype.ishermitian ())
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
985 ret = finverse (mattype, info, rcon, force, calc_cond);
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
986
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
987 if ((calc_cond || mattype.ishermitian ()) && rcon == 0.0)
22849
1d242ae72240 Return 0 for special case of scalar Inf input to inverse (bug #49690).
Rik <rik@octave.org>
parents: 22848
diff changeset
988 {
30313
98400baa509f Return Inf for inv(0) for compatibility with division operator and Matlab (bug #52285).
Rik <rik@octave.org>
parents: 30073
diff changeset
989 ret = FloatComplexMatrix (rows (), columns (),
98400baa509f Return Inf for inv(0) for compatibility with division operator and Matlab (bug #52285).
Rik <rik@octave.org>
parents: 30073
diff changeset
990 FloatComplex (octave::numeric_limits<float>::Inf (), 0.0));
22849
1d242ae72240 Return 0 for special case of scalar Inf input to inverse (bug #49690).
Rik <rik@octave.org>
parents: 22848
diff changeset
991 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
992 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
993
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
994 return ret;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
995 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
996
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
997 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
998 FloatComplexMatrix::pseudo_inverse (float tol) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
999 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1000 FloatComplexMatrix retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1001
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
1002 octave::math::svd<FloatComplexMatrix> result
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
1003 (*this, octave::math::svd<FloatComplexMatrix>::Type::economy);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1004
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1005 FloatDiagMatrix S = result.singular_values ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1006 FloatComplexMatrix U = result.left_singular_matrix ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1007 FloatComplexMatrix V = result.right_singular_matrix ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1008
15448
0a0912a9ab6e Replace deprecated DiagArray2<T>::diag calls with DiagArray2<T>::extract_diag
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15383
diff changeset
1009 FloatColumnVector sigma = S.extract_diag ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1010
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
1011 octave_idx_type r = sigma.numel () - 1;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1012 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1013 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1014
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1015 if (tol <= 0.0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1016 {
24196
2b769c242188 Use std::max to simplify calculating pinv tolerance.
Rik <rik@octave.org>
parents: 24195
diff changeset
1017 tol = std::max (nr, nc) * sigma.elem (0)
2b769c242188 Use std::max to simplify calculating pinv tolerance.
Rik <rik@octave.org>
parents: 24195
diff changeset
1018 * std::numeric_limits<float>::epsilon ();
24195
d3dc76efb38b Return correct value for pinv of zero vectors and scalars (bug #51246).
Rik <rik@octave.org>
parents: 24035
diff changeset
1019
d3dc76efb38b Return correct value for pinv of zero vectors and scalars (bug #51246).
Rik <rik@octave.org>
parents: 24035
diff changeset
1020 if (tol == 0)
d3dc76efb38b Return correct value for pinv of zero vectors and scalars (bug #51246).
Rik <rik@octave.org>
parents: 24035
diff changeset
1021 tol = std::numeric_limits<float>::min ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1022 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1023
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1024 while (r >= 0 && sigma.elem (r) < tol)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1025 r--;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1026
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1027 if (r < 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1028 retval = FloatComplexMatrix (nc, nr, 0.0);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1029 else
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1030 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1031 FloatComplexMatrix Ur = U.extract (0, 0, nr-1, r);
21751
b571fc85953f maint: Use two spaces after period to indicate sentence break.
Rik <rik@octave.org>
parents: 21724
diff changeset
1032 FloatDiagMatrix D = FloatDiagMatrix (sigma.extract (0, r)).inverse ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1033 FloatComplexMatrix Vr = V.extract (0, 0, nc-1, r);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1034 retval = Vr * D * Ur.hermitian ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1035 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1036
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1037 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1038 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1039
9523
0ce82753dd72 more configure changes for libraries
John W. Eaton <jwe@octave.org>
parents: 9469
diff changeset
1040 #if defined (HAVE_FFTW)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1041
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1042 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1043 FloatComplexMatrix::fourier (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1044 {
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1045 std::size_t nr = rows ();
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1046 std::size_t nc = cols ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1047
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1048 FloatComplexMatrix retval (nr, nc);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1049
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1050 std::size_t npts, nsamples;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1051
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1052 if (nr == 1 || nc == 1)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1053 {
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
1054 npts = (nr > nc ? nr : nc);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1055 nsamples = 1;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1056 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1057 else
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1058 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1059 npts = nr;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1060 nsamples = nc;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1061 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1062
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1063 const FloatComplex *in (data ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1064 FloatComplex *out (retval.fortran_vec ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1065
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22988
diff changeset
1066 octave::fftw::fft (in, out, npts, nsamples);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1067
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1068 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1069 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1070
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1071 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1072 FloatComplexMatrix::ifourier (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1073 {
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1074 std::size_t nr = rows ();
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1075 std::size_t nc = cols ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1076
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1077 FloatComplexMatrix retval (nr, nc);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1078
29654
d13d090cb03a use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1079 std::size_t npts, nsamples;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1080
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1081 if (nr == 1 || nc == 1)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1082 {
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
1083 npts = (nr > nc ? nr : nc);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1084 nsamples = 1;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1085 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1086 else
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1087 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1088 npts = nr;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1089 nsamples = nc;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1090 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1091
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1092 const FloatComplex *in (data ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1093 FloatComplex *out (retval.fortran_vec ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1094
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22988
diff changeset
1095 octave::fftw::ifft (in, out, npts, nsamples);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1096
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1097 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1098 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1099
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1100 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1101 FloatComplexMatrix::fourier2d (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1102 {
20218
b2100e1659ac maint: Use cuddled parentheses when indexing dimension_vectors.
Rik <rik@octave.org>
parents: 19864
diff changeset
1103 dim_vector dv (rows (), cols ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1104
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1105 FloatComplexMatrix retval (rows (), cols ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1106 const FloatComplex *in (data ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1107 FloatComplex *out (retval.fortran_vec ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1108
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22988
diff changeset
1109 octave::fftw::fftNd (in, out, 2, dv);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1110
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1111 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1112 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1113
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1114 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1115 FloatComplexMatrix::ifourier2d (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1116 {
20218
b2100e1659ac maint: Use cuddled parentheses when indexing dimension_vectors.
Rik <rik@octave.org>
parents: 19864
diff changeset
1117 dim_vector dv (rows (), cols ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1118
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1119 FloatComplexMatrix retval (rows (), cols ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1120 const FloatComplex *in (data ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1121 FloatComplex *out (retval.fortran_vec ());
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1122
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22988
diff changeset
1123 octave::fftw::ifftNd (in, out, 2, dv);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1124
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1125 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1126 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1127
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1128 #else
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1129
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1130 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1131 FloatComplexMatrix::fourier (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1132 {
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1133 (*current_liboctave_error_handler)
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1134 ("support for FFTW was unavailable or disabled when liboctave was built");
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1135
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1136 return FloatComplexMatrix ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1137 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1138
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1139 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1140 FloatComplexMatrix::ifourier (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1141 {
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1142 (*current_liboctave_error_handler)
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1143 ("support for FFTW was unavailable or disabled when liboctave was built");
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1144
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1145 return FloatComplexMatrix ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1146 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1147
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1148 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1149 FloatComplexMatrix::fourier2d (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1150 {
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1151 (*current_liboctave_error_handler)
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1152 ("support for FFTW was unavailable or disabled when liboctave was built");
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1153
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1154 return FloatComplexMatrix ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1155 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1156
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1157 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1158 FloatComplexMatrix::ifourier2d (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1159 {
25586
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1160 (*current_liboctave_error_handler)
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1161 ("support for FFTW was unavailable or disabled when liboctave was built");
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1162
59f4fda5c548 remove fftpack sources
John W. Eaton <jwe@octave.org>
parents: 25438
diff changeset
1163 return FloatComplexMatrix ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1164 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1165
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1166 #endif
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1167
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1168 FloatComplexDET
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1169 FloatComplexMatrix::determinant (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1170 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1171 octave_idx_type info;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1172 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1173 return determinant (info, rcon, 0);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1174 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1175
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1176 FloatComplexDET
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1177 FloatComplexMatrix::determinant (octave_idx_type& info) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1178 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1179 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1180 return determinant (info, rcon, 0);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1181 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1182
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1183 FloatComplexDET
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1184 FloatComplexMatrix::determinant (octave_idx_type& info, float& rcon,
21719
ff054947d132 use bool instead of int for some logical flags
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1185 bool calc_cond) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1186 {
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1187 MatrixType mattype (*this);
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1188 return determinant (mattype, info, rcon, calc_cond);
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1189 }
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1190
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1191 FloatComplexDET
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1192 FloatComplexMatrix::determinant (MatrixType& mattype,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1193 octave_idx_type& info, float& rcon,
21719
ff054947d132 use bool instead of int for some logical flags
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
1194 bool calc_cond) const
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1195 {
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1196 FloatComplexDET retval (1.0);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1197
13828
f1b023fd098d always initialize info and rcon in Matrix determinant methods
John W. Eaton <jwe@octave.org>
parents: 13107
diff changeset
1198 info = 0;
f1b023fd098d always initialize info and rcon in Matrix determinant methods
John W. Eaton <jwe@octave.org>
parents: 13107
diff changeset
1199 rcon = 0.0;
f1b023fd098d always initialize info and rcon in Matrix determinant methods
John W. Eaton <jwe@octave.org>
parents: 13107
diff changeset
1200
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1201 F77_INT nr = octave::to_f77_int (rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1202 F77_INT nc = octave::to_f77_int (cols ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1203
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1204 if (nr != nc)
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1205 (*current_liboctave_error_handler) ("matrix must be square");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1206
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1207 volatile int typ = mattype.type ();
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1208
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1209 // Even though the matrix is marked as singular (Rectangular), we may
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1210 // still get a useful number from the LU factorization, because it always
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1211 // completes.
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1212
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1213 if (typ == MatrixType::Unknown)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1214 typ = mattype.type (*this);
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1215 else if (typ == MatrixType::Rectangular)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1216 typ = MatrixType::Full;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1217
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1218 if (typ == MatrixType::Lower || typ == MatrixType::Upper)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1219 {
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1220 for (F77_INT i = 0; i < nc; i++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30313
diff changeset
1221 retval *= elem (i, i);
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1222 }
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1223 else if (typ == MatrixType::Hermitian)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1224 {
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1225 FloatComplexMatrix atmp = *this;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1226 FloatComplex *tmp_data = atmp.fortran_vec ();
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1227
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1228 float anorm;
24300
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
1229 if (calc_cond)
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
1230 anorm = norm1 (*this);
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1231
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1232 F77_INT tmp_info = 0;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1233
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1234 char job = 'L';
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1235 F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1236 F77_CMPLX_ARG (tmp_data), nr, tmp_info
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1237 F77_CHAR_ARG_LEN (1)));
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1238
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1239 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1240
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1241 if (info != 0)
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1242 {
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1243 rcon = 0.0;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1244 mattype.mark_as_unsymmetric ();
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1245 typ = MatrixType::Full;
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1246 }
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1247 else
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1248 {
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1249 if (calc_cond)
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1250 {
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1251 Array<FloatComplex> z (dim_vector (2 * nc, 1));
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1252 FloatComplex *pz = z.fortran_vec ();
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1253 Array<float> rz (dim_vector (nc, 1));
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1254 float *prz = rz.fortran_vec ();
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1255
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1256 F77_XFCN (cpocon, CPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1257 nr, F77_CMPLX_ARG (tmp_data), nr, anorm,
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1258 rcon, F77_CMPLX_ARG (pz), prz, tmp_info
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1259 F77_CHAR_ARG_LEN (1)));
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1260
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1261 info = tmp_info;
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1262
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1263 if (info != 0)
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1264 rcon = 0.0;
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1265 }
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1266
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1267 for (F77_INT i = 0; i < nc; i++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30313
diff changeset
1268 retval *= atmp(i, i);
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1269
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1270 retval = retval.square ();
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1271 }
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1272 }
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1273 else if (typ != MatrixType::Full)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1274 (*current_liboctave_error_handler) ("det: invalid dense matrix type");
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1275
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1276 if (typ == MatrixType::Full)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1277 {
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1278 Array<F77_INT> ipvt (dim_vector (nr, 1));
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1279 F77_INT *pipvt = ipvt.fortran_vec ();
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1280
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1281 FloatComplexMatrix atmp = *this;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1282 FloatComplex *tmp_data = atmp.fortran_vec ();
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1283
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1284 info = 0;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1285
24300
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
1286 // Calculate norm of the matrix (always, see bug #45577) for later use.
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
1287 float anorm = norm1 (*this);
22085
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1288
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1289 F77_INT tmp_info = 0;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1290
22085
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1291 // Work around bug #45577, LAPACK crashes Octave if norm is NaN
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1292 if (octave::math::isnan (anorm))
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1293 info = -1;
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1294 else
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1295 {
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
1296 F77_XFCN (cgetrf, CGETRF, (nr, nr, F77_CMPLX_ARG (tmp_data), nr, pipvt,
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
1297 tmp_info));
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1298
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1299 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1300 }
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1301
24300
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
1302 // Throw away extra info LAPACK gives so as to not change output.
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1303 rcon = 0.0;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1304 if (info != 0)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1305 {
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1306 info = -1;
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1307 retval = FloatComplexDET ();
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1308 }
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1309 else
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1310 {
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1311 if (calc_cond)
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1312 {
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1313 // Now calc the condition number for non-singular matrix.
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1314 char job = '1';
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1315 Array<FloatComplex> z (dim_vector (2 * nc, 1));
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1316 FloatComplex *pz = z.fortran_vec ();
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1317 Array<float> rz (dim_vector (2 * nc, 1));
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1318 float *prz = rz.fortran_vec ();
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1319
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1320 F77_XFCN (cgecon, CGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1321 nc, F77_CMPLX_ARG (tmp_data), nr, anorm,
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1322 rcon, F77_CMPLX_ARG (pz), prz, tmp_info
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1323 F77_CHAR_ARG_LEN (1)));
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1324
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1325 info = tmp_info;
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1326 }
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1327
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1328 if (info != 0)
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1329 {
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1330 info = -1;
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1331 retval = FloatComplexDET ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1332 }
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1333 else
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1334 {
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1335 for (F77_INT i = 0; i < nc; i++)
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1336 {
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30313
diff changeset
1337 FloatComplex c = atmp(i, i);
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1338 retval *= (ipvt(i) != (i+1)) ? -c : c;
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1339 }
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1340 }
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1341 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1342 }
8336
9813c07ca946 make det take advantage of matrix type
Jaroslav Hajek <highegg@gmail.com>
parents: 8335
diff changeset
1343
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1344 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1345 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1346
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1347 float
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1348 FloatComplexMatrix::rcond (void) const
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1349 {
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1350 MatrixType mattype (*this);
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1351 return rcond (mattype);
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1352 }
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1353
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1354 float
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1355 FloatComplexMatrix::rcond (MatrixType& mattype) const
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1356 {
21723
bae585228161 use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents: 21721
diff changeset
1357 float rcon = octave::numeric_limits<float>::NaN ();
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1358 F77_INT nr = octave::to_f77_int (rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1359 F77_INT nc = octave::to_f77_int (cols ());
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1360
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1361 if (nr != nc)
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1362 (*current_liboctave_error_handler) ("matrix must be square");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1363
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1364 if (nr == 0 || nc == 0)
21723
bae585228161 use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents: 21721
diff changeset
1365 rcon = octave::numeric_limits<float>::Inf ();
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1366 else
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1367 {
16300
23c5f90f92cd eliminate some variable might be clobbered by 'longjmp' or 'vfork' warnings
John W. Eaton <jwe@octave.org>
parents: 15448
diff changeset
1368 volatile int typ = mattype.type ();
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1369
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1370 if (typ == MatrixType::Unknown)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1371 typ = mattype.type (*this);
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1372
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1373 // Only calculate the condition number for LU/Cholesky
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1374 if (typ == MatrixType::Upper)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1375 {
29931
7faff48840eb prefer data over fortran_vec for read-only access to data
John W. Eaton <jwe@octave.org>
parents: 29902
diff changeset
1376 const FloatComplex *tmp_data = data ();
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1377 F77_INT info = 0;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1378 char norm = '1';
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1379 char uplo = 'U';
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1380 char dia = 'N';
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1381
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1382 Array<FloatComplex> z (dim_vector (2 * nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1383 FloatComplex *pz = z.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1384 Array<float> rz (dim_vector (nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1385 float *prz = rz.fortran_vec ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1386
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1387 F77_XFCN (ctrcon, CTRCON, (F77_CONST_CHAR_ARG2 (&norm, 1),
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1388 F77_CONST_CHAR_ARG2 (&uplo, 1),
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1389 F77_CONST_CHAR_ARG2 (&dia, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1390 nr, F77_CONST_CMPLX_ARG (tmp_data), nr, rcon,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1391 F77_CMPLX_ARG (pz), prz, info
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1392 F77_CHAR_ARG_LEN (1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1393 F77_CHAR_ARG_LEN (1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1394 F77_CHAR_ARG_LEN (1)));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1395
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1396 if (info != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1397 rcon = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1398 }
22777
4a31bd79d7e8 maint: Correct spacing around if and opening parentheses of condition.
Rik <rik@octave.org>
parents: 22755
diff changeset
1399 else if (typ == MatrixType::Permuted_Upper)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1400 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1401 ("permuted triangular matrix not implemented");
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1402 else if (typ == MatrixType::Lower)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1403 {
29931
7faff48840eb prefer data over fortran_vec for read-only access to data
John W. Eaton <jwe@octave.org>
parents: 29902
diff changeset
1404 const FloatComplex *tmp_data = data ();
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1405 F77_INT info = 0;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1406 char norm = '1';
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1407 char uplo = 'L';
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1408 char dia = 'N';
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1409
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1410 Array<FloatComplex> z (dim_vector (2 * nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1411 FloatComplex *pz = z.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1412 Array<float> rz (dim_vector (nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1413 float *prz = rz.fortran_vec ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1414
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1415 F77_XFCN (ctrcon, CTRCON, (F77_CONST_CHAR_ARG2 (&norm, 1),
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1416 F77_CONST_CHAR_ARG2 (&uplo, 1),
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1417 F77_CONST_CHAR_ARG2 (&dia, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1418 nr, F77_CONST_CMPLX_ARG (tmp_data), nr, rcon,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1419 F77_CMPLX_ARG (pz), prz, info
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1420 F77_CHAR_ARG_LEN (1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1421 F77_CHAR_ARG_LEN (1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1422 F77_CHAR_ARG_LEN (1)));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1423
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1424 if (info != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1425 rcon = 0.0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1426 }
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1427 else if (typ == MatrixType::Permuted_Lower)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1428 (*current_liboctave_error_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1429 ("permuted triangular matrix not implemented");
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1430 else if (typ == MatrixType::Full || typ == MatrixType::Hermitian)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1431 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1432 float anorm = -1.0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1433
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1434 if (typ == MatrixType::Hermitian)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1435 {
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1436 F77_INT info = 0;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1437 char job = 'L';
15382
197774b411ec rcond: use new copy of data for full factorization if positive definite cholesky factorization fails (bug #37336)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1438
197774b411ec rcond: use new copy of data for full factorization if positive definite cholesky factorization fails (bug #37336)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1439 FloatComplexMatrix atmp = *this;
197774b411ec rcond: use new copy of data for full factorization if positive definite cholesky factorization fails (bug #37336)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1440 FloatComplex *tmp_data = atmp.fortran_vec ();
197774b411ec rcond: use new copy of data for full factorization if positive definite cholesky factorization fails (bug #37336)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1441
24300
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
1442 anorm = norm1 (atmp);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1443
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1444 F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1445 F77_CMPLX_ARG (tmp_data), nr, info
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1446 F77_CHAR_ARG_LEN (1)));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1447
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1448 if (info != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1449 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1450 rcon = 0.0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1451
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1452 mattype.mark_as_unsymmetric ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1453 typ = MatrixType::Full;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1454 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1455 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1456 {
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1457 Array<FloatComplex> z (dim_vector (2 * nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1458 FloatComplex *pz = z.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1459 Array<float> rz (dim_vector (nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1460 float *prz = rz.fortran_vec ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1461
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1462 F77_XFCN (cpocon, CPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1463 nr, F77_CMPLX_ARG (tmp_data), nr, anorm,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1464 rcon, F77_CMPLX_ARG (pz), prz, info
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1465 F77_CHAR_ARG_LEN (1)));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1466
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1467 if (info != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1468 rcon = 0.0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1469 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1470 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1471
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1472 if (typ == MatrixType::Full)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1473 {
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1474 F77_INT info = 0;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1475
15382
197774b411ec rcond: use new copy of data for full factorization if positive definite cholesky factorization fails (bug #37336)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1476 FloatComplexMatrix atmp = *this;
197774b411ec rcond: use new copy of data for full factorization if positive definite cholesky factorization fails (bug #37336)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1477 FloatComplex *tmp_data = atmp.fortran_vec ();
197774b411ec rcond: use new copy of data for full factorization if positive definite cholesky factorization fails (bug #37336)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1478
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1479 Array<F77_INT> ipvt (dim_vector (nr, 1));
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1480 F77_INT *pipvt = ipvt.fortran_vec ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1481
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1482 if (anorm < 0.0)
24300
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
1483 anorm = norm1 (atmp);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1484
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1485 Array<FloatComplex> z (dim_vector (2 * nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1486 FloatComplex *pz = z.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1487 Array<float> rz (dim_vector (2 * nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1488 float *prz = rz.fortran_vec ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1489
22085
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1490 // Work around bug #45577, LAPACK crashes Octave if norm is NaN
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1491 if (octave::math::isnan (anorm))
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1492 info = -1;
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1493 else
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1494 F77_XFCN (cgetrf, CGETRF, (nr, nr, F77_CMPLX_ARG (tmp_data),
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1495 nr, pipvt, info));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1496
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1497 if (info != 0)
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1498 {
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1499 rcon = 0.0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1500 mattype.mark_as_rectangular ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1501 }
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1502 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1503 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1504 char job = '1';
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1505 F77_XFCN (cgecon, CGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1506 nc, F77_CMPLX_ARG (tmp_data), nr, anorm,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1507 rcon, F77_CMPLX_ARG (pz), prz, info
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1508 F77_CHAR_ARG_LEN (1)));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1509
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1510 if (info != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1511 rcon = 0.0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1512 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1513 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1514 }
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1515 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1516 rcon = 0.0;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1517 }
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1518
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1519 return rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1520 }
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1521
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1522 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1523 FloatComplexMatrix::utsolve (MatrixType& mattype, const FloatComplexMatrix& b,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1524 octave_idx_type& info, float& rcon,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1525 solve_singularity_handler sing_handler,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1526 bool calc_cond, blas_trans_type transt) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1527 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1528 FloatComplexMatrix retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1529
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1530 F77_INT nr = octave::to_f77_int (rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1531 F77_INT nc = octave::to_f77_int (cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1532
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1533 F77_INT b_nr = octave::to_f77_int (b.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1534 F77_INT b_nc = octave::to_f77_int (b.cols ());
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1535
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1536 if (nr != b_nr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1537 (*current_liboctave_error_handler)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1538 ("matrix dimension mismatch solution of linear equations");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1539
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1540 if (nr == 0 || nc == 0 || b_nc == 0)
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1541 retval = FloatComplexMatrix (nc, b_nc, FloatComplex (0.0, 0.0));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1542 else
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1543 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1544 volatile int typ = mattype.type ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1545
19864
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
1546 if (typ == MatrixType::Permuted_Upper || typ == MatrixType::Upper)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1547 {
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1548 rcon = 1.0;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1549 info = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1550
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1551 if (typ == MatrixType::Permuted_Upper)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1552 (*current_liboctave_error_handler)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1553 ("permuted triangular matrix not implemented");
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1554 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1555 {
29931
7faff48840eb prefer data over fortran_vec for read-only access to data
John W. Eaton <jwe@octave.org>
parents: 29902
diff changeset
1556 const FloatComplex *tmp_data = data ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1557
19446
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1558 retval = b;
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1559 FloatComplex *result = retval.fortran_vec ();
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1560
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1561 char uplo = 'U';
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1562 char trans = get_blas_char (transt);
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1563 char dia = 'N';
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1564
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1565 F77_INT tmp_info = 0;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1566
19446
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1567 F77_XFCN (ctrtrs, CTRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1568 F77_CONST_CHAR_ARG2 (&trans, 1),
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1569 F77_CONST_CHAR_ARG2 (&dia, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1570 nr, b_nc, F77_CONST_CMPLX_ARG (tmp_data), nr,
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1571 F77_CMPLX_ARG (result), nr, tmp_info
19446
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1572 F77_CHAR_ARG_LEN (1)
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1573 F77_CHAR_ARG_LEN (1)
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1574 F77_CHAR_ARG_LEN (1)));
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1575
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1576 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1577
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1578 if (calc_cond)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1579 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1580 char norm = '1';
19457
cb35d695713c avoid shadowed variable warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 19446
diff changeset
1581 uplo = 'U';
cb35d695713c avoid shadowed variable warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 19446
diff changeset
1582 dia = 'N';
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1583
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1584 Array<FloatComplex> z (dim_vector (2 * nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1585 FloatComplex *pz = z.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1586 Array<float> rz (dim_vector (nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1587 float *prz = rz.fortran_vec ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1588
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1589 F77_XFCN (ctrcon, CTRCON, (F77_CONST_CHAR_ARG2 (&norm, 1),
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1590 F77_CONST_CHAR_ARG2 (&uplo, 1),
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1591 F77_CONST_CHAR_ARG2 (&dia, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1592 nr, F77_CONST_CMPLX_ARG (tmp_data), nr, rcon,
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1593 F77_CMPLX_ARG (pz), prz, tmp_info
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1594 F77_CHAR_ARG_LEN (1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1595 F77_CHAR_ARG_LEN (1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1596 F77_CHAR_ARG_LEN (1)));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1597
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1598 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1599
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1600 if (info != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1601 info = -2;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1602
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1603 volatile float rcond_plus_one = rcon + 1.0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1604
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1605 if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1606 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1607 info = -2;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1608
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1609 if (sing_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1610 sing_handler (rcon);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1611 else
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1612 octave::warn_singular_matrix (rcon);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1613 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1614 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1615 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1616 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1617 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1618 (*current_liboctave_error_handler) ("incorrect matrix type");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1619 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1620
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1621 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1622 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1623
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1624 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1625 FloatComplexMatrix::ltsolve (MatrixType& mattype, const FloatComplexMatrix& b,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1626 octave_idx_type& info, float& rcon,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1627 solve_singularity_handler sing_handler,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1628 bool calc_cond, blas_trans_type transt) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1629 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1630 FloatComplexMatrix retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1631
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1632 F77_INT nr = octave::to_f77_int (rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1633 F77_INT nc = octave::to_f77_int (cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1634
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1635 F77_INT b_nr = octave::to_f77_int (b.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1636 F77_INT b_nc = octave::to_f77_int (b.cols ());
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1637
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1638 if (nr != b_nr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1639 (*current_liboctave_error_handler)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1640 ("matrix dimension mismatch solution of linear equations");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1641
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1642 if (nr == 0 || nc == 0 || b_nc == 0)
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1643 retval = FloatComplexMatrix (nc, b_nc, FloatComplex (0.0, 0.0));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1644 else
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1645 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1646 volatile int typ = mattype.type ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1647
19864
17d647821d61 maint: More cleanup of C++ code to follow Octave coding conventions.
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
1648 if (typ == MatrixType::Permuted_Lower || typ == MatrixType::Lower)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1649 {
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1650 rcon = 1.0;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1651 info = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1652
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1653 if (typ == MatrixType::Permuted_Lower)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1654 (*current_liboctave_error_handler)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1655 ("permuted triangular matrix not implemented");
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1656 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1657 {
29931
7faff48840eb prefer data over fortran_vec for read-only access to data
John W. Eaton <jwe@octave.org>
parents: 29902
diff changeset
1658 const FloatComplex *tmp_data = data ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1659
19446
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1660 retval = b;
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1661 FloatComplex *result = retval.fortran_vec ();
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1662
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1663 char uplo = 'L';
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1664 char trans = get_blas_char (transt);
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1665 char dia = 'N';
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1666
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1667 F77_INT tmp_info = 0;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1668
19446
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1669 F77_XFCN (ctrtrs, CTRTRS, (F77_CONST_CHAR_ARG2 (&uplo, 1),
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1670 F77_CONST_CHAR_ARG2 (&trans, 1),
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1671 F77_CONST_CHAR_ARG2 (&dia, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1672 nr, b_nc, F77_CONST_CMPLX_ARG (tmp_data), nr,
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1673 F77_CMPLX_ARG (result), nr, tmp_info
19446
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1674 F77_CHAR_ARG_LEN (1)
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1675 F77_CHAR_ARG_LEN (1)
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1676 F77_CHAR_ARG_LEN (1)));
0b4915fcd2eb don't skip solution of singular upper/lower triangular systems
John W. Eaton <jwe@octave.org>
parents: 19434
diff changeset
1677
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1678 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1679
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1680 if (calc_cond)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1681 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1682 char norm = '1';
19457
cb35d695713c avoid shadowed variable warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 19446
diff changeset
1683 uplo = 'L';
cb35d695713c avoid shadowed variable warnings from GCC
John W. Eaton <jwe@octave.org>
parents: 19446
diff changeset
1684 dia = 'N';
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1685
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1686 Array<FloatComplex> z (dim_vector (2 * nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1687 FloatComplex *pz = z.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1688 Array<float> rz (dim_vector (nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1689 float *prz = rz.fortran_vec ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1690
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1691 F77_XFCN (ctrcon, CTRCON, (F77_CONST_CHAR_ARG2 (&norm, 1),
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1692 F77_CONST_CHAR_ARG2 (&uplo, 1),
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1693 F77_CONST_CHAR_ARG2 (&dia, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1694 nr, F77_CONST_CMPLX_ARG (tmp_data), nr, rcon,
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1695 F77_CMPLX_ARG (pz), prz, tmp_info
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1696 F77_CHAR_ARG_LEN (1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1697 F77_CHAR_ARG_LEN (1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1698 F77_CHAR_ARG_LEN (1)));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1699
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1700 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1701
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1702 if (info != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1703 info = -2;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1704
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1705 volatile float rcond_plus_one = rcon + 1.0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1706
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1707 if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1708 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1709 info = -2;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1710
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1711 if (sing_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1712 sing_handler (rcon);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1713 else
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1714 octave::warn_singular_matrix (rcon);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1715 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1716 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1717 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1718 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1719 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1720 (*current_liboctave_error_handler) ("incorrect matrix type");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1721 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1722
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1723 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1724 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1725
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1726 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1727 FloatComplexMatrix::fsolve (MatrixType& mattype, const FloatComplexMatrix& b,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1728 octave_idx_type& info, float& rcon,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1729 solve_singularity_handler sing_handler,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1730 bool calc_cond) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1731 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1732 FloatComplexMatrix retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1733
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1734 F77_INT nr = octave::to_f77_int (rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1735 F77_INT nc = octave::to_f77_int (cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1736
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1737 F77_INT b_nr = octave::to_f77_int (b.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
1738 F77_INT b_nc = octave::to_f77_int (b.cols ());
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1739
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1740 if (nr != nc || nr != b_nr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1741 (*current_liboctave_error_handler)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1742 ("matrix dimension mismatch solution of linear equations");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
1743
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1744 if (nr == 0 || b_nc == 0)
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1745 retval = FloatComplexMatrix (nc, b_nc, FloatComplex (0.0, 0.0));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1746 else
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1747 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1748 volatile int typ = mattype.type ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1749
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1750 // Calculate the norm of the matrix for later use when determining rcon.
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1751 float anorm = -1.0;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1752
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1753 if (typ == MatrixType::Hermitian)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1754 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1755 info = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1756 char job = 'L';
15382
197774b411ec rcond: use new copy of data for full factorization if positive definite cholesky factorization fails (bug #37336)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1757
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1758 FloatComplexMatrix atmp = *this;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1759 FloatComplex *tmp_data = atmp.fortran_vec ();
15382
197774b411ec rcond: use new copy of data for full factorization if positive definite cholesky factorization fails (bug #37336)
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
1760
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1761 // The norm of the matrix for later use when determining rcon.
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1762 if (calc_cond)
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1763 anorm = norm1 (atmp);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1764
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1765 F77_INT tmp_info = 0;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1766
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1767 F77_XFCN (cpotrf, CPOTRF, (F77_CONST_CHAR_ARG2 (&job, 1), nr,
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1768 F77_CMPLX_ARG (tmp_data), nr, tmp_info
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1769 F77_CHAR_ARG_LEN (1)));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1770
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1771 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1772
24291
cf33c1b910b7 maint: Correct typo in comment "Throw-away" => "Throw away"
Rik <rik@octave.org>
parents: 24251
diff changeset
1773 // Throw away extra info LAPACK gives so as to not change output.
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1774 rcon = 0.0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1775 if (info != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1776 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1777 info = -2;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1778
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1779 mattype.mark_as_unsymmetric ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1780 typ = MatrixType::Full;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1781 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1782 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1783 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1784 if (calc_cond)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1785 {
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1786 Array<FloatComplex> z (dim_vector (2 * nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1787 FloatComplex *pz = z.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1788 Array<float> rz (dim_vector (nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1789 float *prz = rz.fortran_vec ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1790
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1791 F77_XFCN (cpocon, CPOCON, (F77_CONST_CHAR_ARG2 (&job, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1792 nr, F77_CMPLX_ARG (tmp_data), nr, anorm,
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1793 rcon, F77_CMPLX_ARG (pz), prz, tmp_info
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1794 F77_CHAR_ARG_LEN (1)));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1795
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1796 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1797
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1798 if (info != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1799 info = -2;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1800
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1801 volatile float rcond_plus_one = rcon + 1.0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1802
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1803 if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1804 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1805 info = -2;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1806
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1807 if (sing_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1808 sing_handler (rcon);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1809 else
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1810 octave::warn_singular_matrix (rcon);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1811 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1812 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1813
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1814 if (info == 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1815 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1816 retval = b;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1817 FloatComplex *result = retval.fortran_vec ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1818
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1819 F77_XFCN (cpotrs, CPOTRS, (F77_CONST_CHAR_ARG2 (&job, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1820 nr, b_nc, F77_CMPLX_ARG (tmp_data), nr,
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1821 F77_CMPLX_ARG (result), b_nr, tmp_info
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1822 F77_CHAR_ARG_LEN (1)));
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1823
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1824 info = tmp_info;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1825 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1826 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1827 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1828 mattype.mark_as_unsymmetric ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1829 typ = MatrixType::Full;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1830 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1831 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1832 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1833
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1834 if (typ == MatrixType::Full)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1835 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1836 info = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1837
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1838 Array<F77_INT> ipvt (dim_vector (nr, 1));
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1839 F77_INT *pipvt = ipvt.fortran_vec ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1840
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1841 FloatComplexMatrix atmp = *this;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1842 FloatComplex *tmp_data = atmp.fortran_vec ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1843
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1844 Array<FloatComplex> z (dim_vector (2 * nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1845 FloatComplex *pz = z.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
1846 Array<float> rz (dim_vector (2 * nc, 1));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1847 float *prz = rz.fortran_vec ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1848
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1849 // Calculate the norm of the matrix, for later use.
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1850 if (calc_cond && anorm < 0.0)
24300
117107eed917 Calculate 1-norm of matrices to assess whether NaN or Inf are present (bug #39000).
Rik <rik@octave.org>
parents: 23560
diff changeset
1851 anorm = norm1 (atmp);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1852
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1853 F77_INT tmp_info = 0;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1854
22085
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1855 // Work around bug #45577, LAPACK crashes Octave if norm is NaN
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1856 // and bug #46330, segfault with matrices containing Inf & NaN
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1857 if (octave::math::isnan (anorm) || octave::math::isinf (anorm))
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1858 info = -2;
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1859 else
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1860 {
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1861 F77_XFCN (cgetrf, CGETRF, (nr, nr, F77_CMPLX_ARG (tmp_data),
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1862 nr, pipvt, tmp_info));
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1863
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1864 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1865 }
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1866
24291
cf33c1b910b7 maint: Correct typo in comment "Throw-away" => "Throw away"
Rik <rik@octave.org>
parents: 24251
diff changeset
1867 // Throw away extra info LAPACK gives so as to not change output.
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1868 rcon = 0.0;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1869 if (info != 0)
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1870 {
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1871 info = -2;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1872
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1873 if (sing_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1874 sing_handler (rcon);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1875 else
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1876 octave::warn_singular_matrix ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1877
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1878 mattype.mark_as_rectangular ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1879 }
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1880 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1881 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1882 if (calc_cond)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1883 {
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
1884 // Calculate the condition number for non-singular matrix.
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1885 char job = '1';
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1886 F77_XFCN (cgecon, CGECON, (F77_CONST_CHAR_ARG2 (&job, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1887 nc, F77_CMPLX_ARG (tmp_data), nr, anorm,
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1888 rcon, F77_CMPLX_ARG (pz), prz, tmp_info
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1889 F77_CHAR_ARG_LEN (1)));
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1890
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1891 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1892
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1893 if (info != 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1894 info = -2;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1895
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1896 volatile float rcond_plus_one = rcon + 1.0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1897
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
1898 if (rcond_plus_one == 1.0 || octave::math::isnan (rcon))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1899 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1900 if (sing_handler)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1901 sing_handler (rcon);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1902 else
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
1903 octave::warn_singular_matrix (rcon);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1904 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1905 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1906
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1907 if (info == 0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1908 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1909 retval = b;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1910 FloatComplex *result = retval.fortran_vec ();
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1911
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1912 char job = 'N';
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1913 F77_XFCN (cgetrs, CGETRS, (F77_CONST_CHAR_ARG2 (&job, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
1914 nr, b_nc, F77_CMPLX_ARG (tmp_data), nr,
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1915 pipvt, F77_CMPLX_ARG (result), b_nr, tmp_info
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1916 F77_CHAR_ARG_LEN (1)));
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1917
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1918 info = tmp_info;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1919 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1920 else
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1921 mattype.mark_as_rectangular ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1922 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
1923 }
22085
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1924
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1925 if (octave::math::isinf (anorm))
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1926 {
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
1927 retval = FloatComplexMatrix (b_nr, b_nc,
22085
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1928 FloatComplex (0, 0));
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1929 mattype.mark_as_full ();
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
1930 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1931 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
1932
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1933 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1934 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1935
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1936 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1937 FloatComplexMatrix::solve (MatrixType& mattype, const FloatMatrix& b) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1938 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1939 octave_idx_type info;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1940 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
1941 return solve (mattype, b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1942 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1943
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1944 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1945 FloatComplexMatrix::solve (MatrixType& mattype, const FloatMatrix& b,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1946 octave_idx_type& info) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1947 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1948 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
1949 return solve (mattype, b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1950 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1951
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1952 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1953 FloatComplexMatrix::solve (MatrixType& mattype, const FloatMatrix& b,
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1954 octave_idx_type& info, float& rcon) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1955 {
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
1956 return solve (mattype, b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1957 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1958
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1959 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1960 FloatComplexMatrix::solve (MatrixType& mattype, const FloatMatrix& b,
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1961 octave_idx_type& info, float& rcon,
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1962 solve_singularity_handler sing_handler,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1963 bool singular_fallback, blas_trans_type transt) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1964 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1965 FloatComplexMatrix tmp (b);
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1966 return solve (mattype, tmp, info, rcon, sing_handler, singular_fallback,
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1967 transt);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1968 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1969
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1970 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1971 FloatComplexMatrix::solve (MatrixType& mattype,
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1972 const FloatComplexMatrix& b) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1973 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1974 octave_idx_type info;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1975 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
1976 return solve (mattype, b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1977 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1978
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1979 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1980 FloatComplexMatrix::solve (MatrixType& mattype, const FloatComplexMatrix& b,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1981 octave_idx_type& info) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1982 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
1983 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
1984 return solve (mattype, b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1985 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1986
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1987 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1988 FloatComplexMatrix::solve (MatrixType& mattype, const FloatComplexMatrix& b,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1989 octave_idx_type& info, float& rcon) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1990 {
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
1991 return solve (mattype, b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1992 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1993
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
1994 FloatComplexMatrix
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1995 FloatComplexMatrix::solve (MatrixType& mattype, const FloatComplexMatrix& b,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1996 octave_idx_type& info, float& rcon,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
1997 solve_singularity_handler sing_handler,
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1998 bool singular_fallback,
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
1999 blas_trans_type transt) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2000 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2001 FloatComplexMatrix retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2002 int typ = mattype.type ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2003
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2004 if (typ == MatrixType::Unknown)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2005 typ = mattype.type (*this);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2006
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2007 // Only calculate the condition number for LU/Cholesky
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2008 if (typ == MatrixType::Upper || typ == MatrixType::Permuted_Upper)
19434
aee5fea8a03e compute condition number when solving triangular systems (bug #43875)
John W. Eaton <jwe@octave.org>
parents: 19408
diff changeset
2009 retval = utsolve (mattype, b, info, rcon, sing_handler, true, transt);
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2010 else if (typ == MatrixType::Lower
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2011 || typ == MatrixType::Permuted_Lower)
19434
aee5fea8a03e compute condition number when solving triangular systems (bug #43875)
John W. Eaton <jwe@octave.org>
parents: 19408
diff changeset
2012 retval = ltsolve (mattype, b, info, rcon, sing_handler, true, transt);
9661
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9658
diff changeset
2013 else if (transt == blas_trans)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2014 return transpose ().solve (mattype, b, info, rcon, sing_handler,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2015 singular_fallback);
9661
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9658
diff changeset
2016 else if (transt == blas_conj_trans)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2017 retval = hermitian ().solve (mattype, b, info, rcon, sing_handler,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2018 singular_fallback);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2019 else if (typ == MatrixType::Full || typ == MatrixType::Hermitian)
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2020 retval = fsolve (mattype, b, info, rcon, sing_handler, true);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2021 else if (typ != MatrixType::Rectangular)
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
2022 (*current_liboctave_error_handler) ("unknown matrix type");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2023
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2024 // Rectangular or one of the above solvers flags a singular matrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2025 if (singular_fallback && mattype.type () == MatrixType::Rectangular)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2026 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2027 octave_idx_type rank;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2028 retval = lssolve (b, info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2029 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2030
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2031 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2032 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2033
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2034 FloatComplexColumnVector
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2035 FloatComplexMatrix::solve (MatrixType& mattype,
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2036 const FloatColumnVector& b) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2037 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2038 octave_idx_type info;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2039 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2040 return solve (mattype, FloatComplexColumnVector (b), info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2041 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2042
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2043 FloatComplexColumnVector
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2044 FloatComplexMatrix::solve (MatrixType& mattype, const FloatColumnVector& b,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2045 octave_idx_type& info) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2046 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2047 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2048 return solve (mattype, FloatComplexColumnVector (b), info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2049 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2050
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2051 FloatComplexColumnVector
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2052 FloatComplexMatrix::solve (MatrixType& mattype, const FloatColumnVector& b,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2053 octave_idx_type& info, float& rcon) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2054 {
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2055 return solve (mattype, FloatComplexColumnVector (b), info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2056 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2057
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2058 FloatComplexColumnVector
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2059 FloatComplexMatrix::solve (MatrixType& mattype, const FloatColumnVector& b,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2060 octave_idx_type& info, float& rcon,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2061 solve_singularity_handler sing_handler,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2062 blas_trans_type transt) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2063 {
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2064 return solve (mattype, FloatComplexColumnVector (b), info, rcon,
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2065 sing_handler, transt);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2066 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2067
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2068 FloatComplexColumnVector
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2069 FloatComplexMatrix::solve (MatrixType& mattype,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2070 const FloatComplexColumnVector& b) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2071 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2072 octave_idx_type info;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2073 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2074 return solve (mattype, b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2075 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2076
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2077 FloatComplexColumnVector
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2078 FloatComplexMatrix::solve (MatrixType& mattype,
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2079 const FloatComplexColumnVector& b,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2080 octave_idx_type& info) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2081 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2082 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2083 return solve (mattype, b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2084 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2085
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2086 FloatComplexColumnVector
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2087 FloatComplexMatrix::solve (MatrixType& mattype,
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2088 const FloatComplexColumnVector& b,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2089 octave_idx_type& info, float& rcon) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2090 {
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2091 return solve (mattype, b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2092 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2093
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2094 FloatComplexColumnVector
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2095 FloatComplexMatrix::solve (MatrixType& mattype,
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2096 const FloatComplexColumnVector& b,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2097 octave_idx_type& info, float& rcon,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2098 solve_singularity_handler sing_handler,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2099 blas_trans_type transt) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2100 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2101
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2102 FloatComplexMatrix tmp (b);
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
2103 tmp = solve (mattype, tmp, info, rcon, sing_handler, true, transt);
15018
3d8ace26c5b4 maint: Use Octave coding conventions for cuddled parentheses in liboctave/.
Rik <rik@octave.org>
parents: 14846
diff changeset
2104 return tmp.column (static_cast<octave_idx_type> (0));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2105 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2106
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2107 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2108 FloatComplexMatrix::solve (const FloatMatrix& b) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2109 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2110 octave_idx_type info;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2111 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2112 return solve (b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2113 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2114
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2115 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2116 FloatComplexMatrix::solve (const FloatMatrix& b, octave_idx_type& info) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2117 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2118 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2119 return solve (b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2120 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2121
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2122 FloatComplexMatrix
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2123 FloatComplexMatrix::solve (const FloatMatrix& b, octave_idx_type& info,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2124 float& rcon) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2125 {
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2126 return solve (b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2127 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2128
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2129 FloatComplexMatrix
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2130 FloatComplexMatrix::solve (const FloatMatrix& b, octave_idx_type& info,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2131 float& rcon,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2132 solve_singularity_handler sing_handler,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2133 blas_trans_type transt) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2134 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2135 FloatComplexMatrix tmp (b);
9661
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9658
diff changeset
2136 return solve (tmp, info, rcon, sing_handler, transt);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2137 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2138
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2139 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2140 FloatComplexMatrix::solve (const FloatComplexMatrix& b) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2141 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2142 octave_idx_type info;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2143 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2144 return solve (b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2145 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2146
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2147 FloatComplexMatrix
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2148 FloatComplexMatrix::solve (const FloatComplexMatrix& b,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2149 octave_idx_type& info) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2150 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2151 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2152 return solve (b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2153 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2154
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2155 FloatComplexMatrix
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2156 FloatComplexMatrix::solve (const FloatComplexMatrix& b, octave_idx_type& info,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2157 float& rcon) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2158 {
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2159 return solve (b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2160 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2161
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2162 FloatComplexMatrix
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2163 FloatComplexMatrix::solve (const FloatComplexMatrix& b, octave_idx_type& info,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2164 float& rcon,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2165 solve_singularity_handler sing_handler,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2166 blas_trans_type transt) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2167 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2168 MatrixType mattype (*this);
9661
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9658
diff changeset
2169 return solve (mattype, b, info, rcon, sing_handler, true, transt);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2170 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2171
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2172 FloatComplexColumnVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2173 FloatComplexMatrix::solve (const FloatColumnVector& b) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2174 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2175 octave_idx_type info;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2176 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2177 return solve (FloatComplexColumnVector (b), info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2178 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2179
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2180 FloatComplexColumnVector
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2181 FloatComplexMatrix::solve (const FloatColumnVector& b,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2182 octave_idx_type& info) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2183 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2184 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2185 return solve (FloatComplexColumnVector (b), info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2186 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2187
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2188 FloatComplexColumnVector
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
2189 FloatComplexMatrix::solve (const FloatColumnVector& b, octave_idx_type& info,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2190 float& rcon) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2191 {
23798
771310737137 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23796
diff changeset
2192 return solve (FloatComplexColumnVector (b), info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2193 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2194
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2195 FloatComplexColumnVector
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
2196 FloatComplexMatrix::solve (const FloatColumnVector& b, octave_idx_type& info,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2197 float& rcon,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2198 solve_singularity_handler sing_handler,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2199 blas_trans_type transt) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2200 {
9661
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9658
diff changeset
2201 return solve (FloatComplexColumnVector (b), info, rcon, sing_handler, transt);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2202 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2203
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2204 FloatComplexColumnVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2205 FloatComplexMatrix::solve (const FloatComplexColumnVector& b) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2206 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2207 octave_idx_type info;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2208 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2209 return solve (b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2210 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2211
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2212 FloatComplexColumnVector
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2213 FloatComplexMatrix::solve (const FloatComplexColumnVector& b,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2214 octave_idx_type& info) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2215 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2216 float rcon;
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2217 return solve (b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2218 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2219
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2220 FloatComplexColumnVector
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2221 FloatComplexMatrix::solve (const FloatComplexColumnVector& b,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2222 octave_idx_type& info,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2223 float& rcon) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2224 {
23796
4f12819a634f Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23708
diff changeset
2225 return solve (b, info, rcon, nullptr);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2226 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2227
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2228 FloatComplexColumnVector
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2229 FloatComplexMatrix::solve (const FloatComplexColumnVector& b,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2230 octave_idx_type& info,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2231 float& rcon,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2232 solve_singularity_handler sing_handler,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2233 blas_trans_type transt) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2234 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2235 MatrixType mattype (*this);
9661
afcf852256d2 optimize / and '\ for triangular matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 9658
diff changeset
2236 return solve (mattype, b, info, rcon, sing_handler, transt);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2237 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2238
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2239 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2240 FloatComplexMatrix::lssolve (const FloatMatrix& b) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2241 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2242 octave_idx_type info;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2243 octave_idx_type rank;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2244 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2245 return lssolve (FloatComplexMatrix (b), info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2246 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2247
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2248 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2249 FloatComplexMatrix::lssolve (const FloatMatrix& b, octave_idx_type& info) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2250 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2251 octave_idx_type rank;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2252 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2253 return lssolve (FloatComplexMatrix (b), info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2254 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2255
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2256 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2257 FloatComplexMatrix::lssolve (const FloatMatrix& b, octave_idx_type& info,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2258 octave_idx_type& rank) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2259 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2260 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2261 return lssolve (FloatComplexMatrix (b), info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2262 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2263
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2264 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2265 FloatComplexMatrix::lssolve (const FloatMatrix& b, octave_idx_type& info,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2266 octave_idx_type& rank, float& rcon) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2267 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2268 return lssolve (FloatComplexMatrix (b), info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2269 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2270
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2271 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2272 FloatComplexMatrix::lssolve (const FloatComplexMatrix& b) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2273 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2274 octave_idx_type info;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2275 octave_idx_type rank;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2276 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2277 return lssolve (b, info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2278 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2279
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2280 FloatComplexMatrix
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2281 FloatComplexMatrix::lssolve (const FloatComplexMatrix& b,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2282 octave_idx_type& info) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2283 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2284 octave_idx_type rank;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2285 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2286 return lssolve (b, info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2287 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2288
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2289 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2290 FloatComplexMatrix::lssolve (const FloatComplexMatrix& b, octave_idx_type& info,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2291 octave_idx_type& rank) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2292 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2293 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2294 return lssolve (b, info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2295 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2296
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2297 FloatComplexMatrix
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
2298 FloatComplexMatrix::lssolve (const FloatComplexMatrix& b, octave_idx_type& info,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2299 octave_idx_type& rank, float& rcon) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2300 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2301 FloatComplexMatrix retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2302
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
2303 F77_INT m = octave::to_f77_int (rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
2304 F77_INT n = octave::to_f77_int (cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
2305
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
2306 F77_INT b_nr = octave::to_f77_int (b.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
2307 F77_INT b_nc = octave::to_f77_int (b.cols ());
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
2308 F77_INT nrhs = b_nc; // alias for code readability
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2309
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2310 if (m != b_nr)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2311 (*current_liboctave_error_handler)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2312 ("matrix dimension mismatch solution of linear equations");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
2313
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2314 if (m == 0 || n == 0 || b_nc == 0)
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2315 retval = FloatComplexMatrix (n, b_nc, FloatComplex (0.0, 0.0));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2316 else
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2317 {
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2318 volatile F77_INT minmn = (m < n ? m : n);
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
2319 F77_INT maxmn = (m > n ? m : n);
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2320 rcon = -1.0;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2321
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2322 if (m != n)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2323 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2324 retval = FloatComplexMatrix (maxmn, nrhs);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2325
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2326 for (F77_INT j = 0; j < nrhs; j++)
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2327 for (F77_INT i = 0; i < m; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2328 retval.elem (i, j) = b.elem (i, j);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2329 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2330 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2331 retval = b;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2332
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2333 FloatComplexMatrix atmp = *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2334 FloatComplex *tmp_data = atmp.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2335
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2336 FloatComplex *pretval = retval.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2337 Array<float> s (dim_vector (minmn, 1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2338 float *ps = s.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2339
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2340 // Ask ZGELSD what the dimension of WORK should be.
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2341 F77_INT lwork = -1;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2342
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2343 Array<FloatComplex> work (dim_vector (1, 1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2344
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2345 F77_INT smlsiz;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2346 F77_FUNC (xilaenv, XILAENV) (9, F77_CONST_CHAR_ARG2 ("CGELSD", 6),
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2347 F77_CONST_CHAR_ARG2 (" ", 1),
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2348 0, 0, 0, 0, smlsiz
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2349 F77_CHAR_ARG_LEN (6)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2350 F77_CHAR_ARG_LEN (1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2351
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2352 F77_INT mnthr;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2353 F77_FUNC (xilaenv, XILAENV) (6, F77_CONST_CHAR_ARG2 ("CGELSD", 6),
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2354 F77_CONST_CHAR_ARG2 (" ", 1),
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2355 m, n, nrhs, -1, mnthr
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2356 F77_CHAR_ARG_LEN (6)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2357 F77_CHAR_ARG_LEN (1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2358
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2359 // We compute the size of rwork and iwork because ZGELSD in
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2360 // older versions of LAPACK does not return them on a query
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2361 // call.
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2362 float dminmn = static_cast<float> (minmn);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2363 float dsmlsizp1 = static_cast<float> (smlsiz+1);
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2364 float tmp = octave::math::log2 (dminmn / dsmlsizp1);
18847
ff4da3c8ed16 use gnulib log2 modules (bug #42583)
John W. Eaton <jwe@octave.org>
parents: 18115
diff changeset
2365
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2366 F77_INT nlvl = static_cast<F77_INT> (tmp) + 1;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2367 if (nlvl < 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2368 nlvl = 0;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2369
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2370 F77_INT lrwork = minmn*(10 + 2*smlsiz + 8*nlvl)
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
2371 + 3*smlsiz*nrhs
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
2372 + std::max ((smlsiz+1)*(smlsiz+1),
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
2373 n*(1+nrhs) + 2*nrhs);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2374 if (lrwork < 1)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2375 lrwork = 1;
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2376 Array<float> rwork (dim_vector (lrwork, 1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2377 float *prwork = rwork.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2378
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2379 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2380 if (liwork < 1)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2381 liwork = 1;
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2382 Array<F77_INT> iwork (dim_vector (liwork, 1));
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23443
diff changeset
2383 F77_INT *piwork = iwork.fortran_vec ();
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2384
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2385 F77_INT tmp_info = 0;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2386 F77_INT tmp_rank = 0;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2387
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
2388 F77_XFCN (cgelsd, CGELSD, (m, n, nrhs, F77_CMPLX_ARG (tmp_data), m,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
2389 F77_CMPLX_ARG (pretval), maxmn,
22972
8bc5d69a96f3 * fCMatrix.cc: Fix omission from previous change.
John W. Eaton <jwe@octave.org>
parents: 22971
diff changeset
2390 ps, rcon, tmp_rank, F77_CMPLX_ARG (work.fortran_vec ()),
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2391 lwork, prwork, piwork, tmp_info));
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2392
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2393 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2394 rank = tmp_rank;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2395
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2396 // The workspace query is broken in at least LAPACK 3.0.0
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2397 // through 3.1.1 when n >= mnthr. The obtuse formula below
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2398 // should provide sufficient workspace for ZGELSD to operate
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2399 // efficiently.
10813
2c2d4a2f1047 fix workspace bug workaround for xGELSD (since 7486:6a6d2abe51ff)
Jaroslav Hajek <highegg@gmail.com>
parents: 10806
diff changeset
2400 if (n > m && n >= mnthr)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2401 {
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2402 F77_INT addend = m;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2403
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2404 if (2*m-4 > addend)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2405 addend = 2*m-4;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2406
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2407 if (nrhs > addend)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2408 addend = nrhs;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2409
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2410 if (n-3*m > addend)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2411 addend = n-3*m;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2412
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2413 const F77_INT lworkaround = 4*m + m*m + addend;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2414
23708
750e42a35adc Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents: 23594
diff changeset
2415 if (std::real (work(0)) < lworkaround)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2416 work(0) = lworkaround;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2417 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2418 else if (m >= n)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2419 {
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2420 F77_INT lworkaround = 2*m + m*nrhs;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2421
23708
750e42a35adc Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents: 23594
diff changeset
2422 if (std::real (work(0)) < lworkaround)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2423 work(0) = lworkaround;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2424 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2425
23708
750e42a35adc Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents: 23594
diff changeset
2426 lwork = static_cast<F77_INT> (std::real (work(0)));
11574
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
2427 work.resize (dim_vector (lwork, 1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2428
25774
f5ea7511c405 Avoid calculating norm of matrix when not requested in liboctave Matrix classes.
Rik <rik@octave.org>
parents: 25586
diff changeset
2429 float anorm = norm1 (*this);
22598
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2430
24311
0643533930e7 Return NaN arrays for left division operator when operands contain NaNs (bug #52516).
Rik <rik@octave.org>
parents: 24301
diff changeset
2431 if (octave::math::isinf (anorm))
22598
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2432 {
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2433 rcon = 0.0;
24311
0643533930e7 Return NaN arrays for left division operator when operands contain NaNs (bug #52516).
Rik <rik@octave.org>
parents: 24301
diff changeset
2434 retval = FloatComplexMatrix (n, b_nc, 0.0);
0643533930e7 Return NaN arrays for left division operator when operands contain NaNs (bug #52516).
Rik <rik@octave.org>
parents: 24301
diff changeset
2435 }
0643533930e7 Return NaN arrays for left division operator when operands contain NaNs (bug #52516).
Rik <rik@octave.org>
parents: 24301
diff changeset
2436 else if (octave::math::isnan (anorm))
0643533930e7 Return NaN arrays for left division operator when operands contain NaNs (bug #52516).
Rik <rik@octave.org>
parents: 24301
diff changeset
2437 {
0643533930e7 Return NaN arrays for left division operator when operands contain NaNs (bug #52516).
Rik <rik@octave.org>
parents: 24301
diff changeset
2438 rcon = octave::numeric_limits<float>::NaN ();
0643533930e7 Return NaN arrays for left division operator when operands contain NaNs (bug #52516).
Rik <rik@octave.org>
parents: 24301
diff changeset
2439 retval = FloatComplexMatrix (n, b_nc,
0643533930e7 Return NaN arrays for left division operator when operands contain NaNs (bug #52516).
Rik <rik@octave.org>
parents: 24301
diff changeset
2440 octave::numeric_limits<float>::NaN ());
22598
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2441 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2442 else
22598
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2443 {
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2444 F77_XFCN (cgelsd, CGELSD, (m, n, nrhs, F77_CMPLX_ARG (tmp_data),
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2445 m, F77_CMPLX_ARG (pretval),
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2446 maxmn, ps, rcon, tmp_rank,
22598
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2447 F77_CMPLX_ARG (work.fortran_vec ()),
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2448 lwork, prwork, piwork, tmp_info));
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2449
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2450 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2451 rank = tmp_rank;
22598
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2452
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2453 if (s.elem (0) == 0.0)
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2454 rcon = 0.0;
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2455 else
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2456 rcon = s.elem (minmn - 1) / s.elem (0);
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2457
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2458 retval.resize (n, nrhs);
5aa8f199e328 avoid invalid BLAS calls that then invoke xerbla (bug #39000)
Avinoam Kalma <a.kalma@gmail.com>
parents: 22417
diff changeset
2459 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2460 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2461
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2462 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2463 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2464
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2465 FloatComplexColumnVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2466 FloatComplexMatrix::lssolve (const FloatColumnVector& b) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2467 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2468 octave_idx_type info;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2469 octave_idx_type rank;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2470 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2471 return lssolve (FloatComplexColumnVector (b), info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2472 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2473
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2474 FloatComplexColumnVector
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2475 FloatComplexMatrix::lssolve (const FloatColumnVector& b,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2476 octave_idx_type& info) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2477 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2478 octave_idx_type rank;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2479 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2480 return lssolve (FloatComplexColumnVector (b), info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2481 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2482
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2483 FloatComplexColumnVector
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
2484 FloatComplexMatrix::lssolve (const FloatColumnVector& b, octave_idx_type& info,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2485 octave_idx_type& rank) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2486 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2487 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2488 return lssolve (FloatComplexColumnVector (b), info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2489 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2490
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2491 FloatComplexColumnVector
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
2492 FloatComplexMatrix::lssolve (const FloatColumnVector& b, octave_idx_type& info,
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2493 octave_idx_type& rank, float& rcon) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2494 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2495 return lssolve (FloatComplexColumnVector (b), info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2496 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2497
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2498 FloatComplexColumnVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2499 FloatComplexMatrix::lssolve (const FloatComplexColumnVector& b) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2500 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2501 octave_idx_type info;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2502 octave_idx_type rank;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2503 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2504 return lssolve (b, info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2505 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2506
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2507 FloatComplexColumnVector
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2508 FloatComplexMatrix::lssolve (const FloatComplexColumnVector& b,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2509 octave_idx_type& info) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2510 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2511 octave_idx_type rank;
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2512 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2513 return lssolve (b, info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2514 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2515
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2516 FloatComplexColumnVector
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2517 FloatComplexMatrix::lssolve (const FloatComplexColumnVector& b,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2518 octave_idx_type& info,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2519 octave_idx_type& rank) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2520 {
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2521 float rcon;
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2522 return lssolve (b, info, rank, rcon);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2523
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2524 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2525
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2526 FloatComplexColumnVector
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2527 FloatComplexMatrix::lssolve (const FloatComplexColumnVector& b,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2528 octave_idx_type& info,
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2529 octave_idx_type& rank, float& rcon) const
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2530 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2531 FloatComplexColumnVector retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2532
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2533 F77_INT nrhs = 1;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2534
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
2535 F77_INT m = octave::to_f77_int (rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
2536 F77_INT n = octave::to_f77_int (cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
2537
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
2538 F77_INT b_nel = octave::to_f77_int (b.numel ());
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2539
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2540 if (m != b_nel)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2541 (*current_liboctave_error_handler)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2542 ("matrix dimension mismatch solution of linear equations");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
2543
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2544 if (m == 0 || n == 0)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2545 retval = FloatComplexColumnVector (n, FloatComplex (0.0, 0.0));
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2546 else
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2547 {
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2548 volatile F77_INT minmn = (m < n ? m : n);
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
2549 F77_INT maxmn = (m > n ? m : n);
7797
f42c6f8d6d8e Extend rcond function to single precision types
David Bateman <dbateman@free.fr>
parents: 7789
diff changeset
2550 rcon = -1.0;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2551
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2552 if (m != n)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2553 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2554 retval = FloatComplexColumnVector (maxmn);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2555
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2556 for (F77_INT i = 0; i < m; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2557 retval.elem (i) = b.elem (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2558 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2559 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2560 retval = b;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2561
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2562 FloatComplexMatrix atmp = *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2563 FloatComplex *tmp_data = atmp.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2564
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2565 FloatComplex *pretval = retval.fortran_vec ();
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2566 Array<float> s (dim_vector (minmn, 1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2567 float *ps = s.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2568
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2569 // Ask ZGELSD what the dimension of WORK should be.
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2570 F77_INT lwork = -1;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2571
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2572 Array<FloatComplex> work (dim_vector (1, 1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2573
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2574 F77_INT smlsiz;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2575 F77_FUNC (xilaenv, XILAENV) (9, F77_CONST_CHAR_ARG2 ("CGELSD", 6),
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2576 F77_CONST_CHAR_ARG2 (" ", 1),
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2577 0, 0, 0, 0, smlsiz
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2578 F77_CHAR_ARG_LEN (6)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2579 F77_CHAR_ARG_LEN (1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2580
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2581 // We compute the size of rwork and iwork because ZGELSD in
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2582 // older versions of LAPACK does not return them on a query
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2583 // call.
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2584 float dminmn = static_cast<float> (minmn);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2585 float dsmlsizp1 = static_cast<float> (smlsiz+1);
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2586 float tmp = octave::math::log2 (dminmn / dsmlsizp1);
18847
ff4da3c8ed16 use gnulib log2 modules (bug #42583)
John W. Eaton <jwe@octave.org>
parents: 18115
diff changeset
2587
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2588 F77_INT nlvl = static_cast<F77_INT> (tmp) + 1;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2589 if (nlvl < 0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2590 nlvl = 0;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2591
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2592 F77_INT lrwork = minmn*(10 + 2*smlsiz + 8*nlvl)
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
2593 + 3*smlsiz*nrhs + (smlsiz+1)*(smlsiz+1);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2594 if (lrwork < 1)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2595 lrwork = 1;
11570
57632dea2446 attempt better backward compatibility for Array constructors
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
2596 Array<float> rwork (dim_vector (lrwork, 1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2597 float *prwork = rwork.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2598
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2599 F77_INT liwork = 3 * minmn * nlvl + 11 * minmn;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2600 if (liwork < 1)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2601 liwork = 1;
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2602 Array<F77_INT> iwork (dim_vector (liwork, 1));
23449
c763214a8260 maint: Use convention 'int *x' for naming pointers.
Rik <rik@octave.org>
parents: 23443
diff changeset
2603 F77_INT *piwork = iwork.fortran_vec ();
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2604
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2605 F77_INT tmp_info = 0;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2606 F77_INT tmp_rank = 0;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2607
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
2608 F77_XFCN (cgelsd, CGELSD, (m, n, nrhs, F77_CMPLX_ARG (tmp_data), m,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
2609 F77_CMPLX_ARG (pretval), maxmn,
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2610 ps, rcon, tmp_rank, F77_CMPLX_ARG (work.fortran_vec ()),
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2611 lwork, prwork, piwork, tmp_info));
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2612
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2613 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2614 rank = tmp_rank;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2615
23708
750e42a35adc Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents: 23594
diff changeset
2616 lwork = static_cast<F77_INT> (std::real (work(0)));
11574
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
2617 work.resize (dim_vector (lwork, 1));
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2618 rwork.resize (dim_vector (static_cast<F77_INT> (rwork(0)), 1));
11574
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
2619 iwork.resize (dim_vector (iwork(0), 1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2620
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
2621 F77_XFCN (cgelsd, CGELSD, (m, n, nrhs, F77_CMPLX_ARG (tmp_data), m,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
2622 F77_CMPLX_ARG (pretval),
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2623 maxmn, ps, rcon, tmp_rank,
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
2624 F77_CMPLX_ARG (work.fortran_vec ()), lwork,
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2625 prwork, piwork, tmp_info));
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2626
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2627 info = tmp_info;
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
2628 rank = tmp_rank;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2629
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2630 if (rank < minmn)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2631 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2632 if (s.elem (0) == 0.0)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2633 rcon = 0.0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2634 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2635 rcon = s.elem (minmn - 1) / s.elem (0);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2636
22848
a3bd04422a87 don't pass two dimensions to column vector resize method
John W. Eaton <jwe@octave.org>
parents: 22777
diff changeset
2637 retval.resize (n);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2638 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2639 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2640
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2641 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2642 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2643
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2644 // column vector by row vector -> matrix operations
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2645
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2646 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2647 operator * (const FloatColumnVector& v, const FloatComplexRowVector& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2648 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2649 FloatComplexColumnVector tmp (v);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2650 return tmp * a;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2651 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2652
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2653 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2654 operator * (const FloatComplexColumnVector& a, const FloatRowVector& b)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2655 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2656 FloatComplexRowVector tmp (b);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2657 return a * tmp;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2658 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2659
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2660 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2661 operator * (const FloatComplexColumnVector& v, const FloatComplexRowVector& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2662 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2663 FloatComplexMatrix retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2664
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
2665 F77_INT len = octave::to_f77_int (v.numel ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2666
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2667 if (len != 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2668 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
2669 F77_INT a_len = octave::to_f77_int (a.numel ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2670
9359
be6867ba8104 avoid useless zero initialization when doing matrix multiply
Jaroslav Hajek <highegg@gmail.com>
parents: 9227
diff changeset
2671 retval = FloatComplexMatrix (len, a_len);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2672 FloatComplex *c = retval.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2673
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2674 F77_XFCN (cgemm, CGEMM, (F77_CONST_CHAR_ARG2 ("N", 1),
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2675 F77_CONST_CHAR_ARG2 ("N", 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
2676 len, a_len, 1, 1.0, F77_CONST_CMPLX_ARG (v.data ()), len,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
2677 F77_CONST_CMPLX_ARG (a.data ()), 1, 0.0, F77_CMPLX_ARG (c), len
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2678 F77_CHAR_ARG_LEN (1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2679 F77_CHAR_ARG_LEN (1)));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2680 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2681
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2682 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2683 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2684
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2685 // matrix by diagonal matrix -> matrix operations
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2686
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2687 FloatComplexMatrix&
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2688 FloatComplexMatrix::operator += (const FloatDiagMatrix& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2689 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2690 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2691 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2692
22978
03819d65cc1d use correct dimensions for liboctave += and -= matrix operators
John W. Eaton <jwe@octave.org>
parents: 22600
diff changeset
2693 octave_idx_type a_nr = a.rows ();
03819d65cc1d use correct dimensions for liboctave += and -= matrix operators
John W. Eaton <jwe@octave.org>
parents: 22600
diff changeset
2694 octave_idx_type a_nc = a.cols ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2695
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2696 if (nr != a_nr || nc != a_nc)
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2697 octave::err_nonconformant ("operator +=", nr, nc, a_nr, a_nc);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2698
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2699 for (octave_idx_type i = 0; i < a.length (); i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2700 elem (i, i) += a.elem (i, i);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2701
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2702 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2703 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2704
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2705 FloatComplexMatrix&
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2706 FloatComplexMatrix::operator -= (const FloatDiagMatrix& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2707 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2708 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2709 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2710
22978
03819d65cc1d use correct dimensions for liboctave += and -= matrix operators
John W. Eaton <jwe@octave.org>
parents: 22600
diff changeset
2711 octave_idx_type a_nr = a.rows ();
03819d65cc1d use correct dimensions for liboctave += and -= matrix operators
John W. Eaton <jwe@octave.org>
parents: 22600
diff changeset
2712 octave_idx_type a_nc = a.cols ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2713
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2714 if (nr != a_nr || nc != a_nc)
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2715 octave::err_nonconformant ("operator -=", nr, nc, a_nr, a_nc);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2716
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2717 for (octave_idx_type i = 0; i < a.length (); i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2718 elem (i, i) -= a.elem (i, i);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2719
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2720 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2721 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2722
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2723 FloatComplexMatrix&
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2724 FloatComplexMatrix::operator += (const FloatComplexDiagMatrix& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2725 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2726 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2727 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2728
22978
03819d65cc1d use correct dimensions for liboctave += and -= matrix operators
John W. Eaton <jwe@octave.org>
parents: 22600
diff changeset
2729 octave_idx_type a_nr = a.rows ();
03819d65cc1d use correct dimensions for liboctave += and -= matrix operators
John W. Eaton <jwe@octave.org>
parents: 22600
diff changeset
2730 octave_idx_type a_nc = a.cols ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2731
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2732 if (nr != a_nr || nc != a_nc)
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2733 octave::err_nonconformant ("operator +=", nr, nc, a_nr, a_nc);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2734
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2735 for (octave_idx_type i = 0; i < a.length (); i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2736 elem (i, i) += a.elem (i, i);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2737
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2738 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2739 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2740
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2741 FloatComplexMatrix&
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2742 FloatComplexMatrix::operator -= (const FloatComplexDiagMatrix& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2743 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2744 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2745 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2746
22978
03819d65cc1d use correct dimensions for liboctave += and -= matrix operators
John W. Eaton <jwe@octave.org>
parents: 22600
diff changeset
2747 octave_idx_type a_nr = a.rows ();
03819d65cc1d use correct dimensions for liboctave += and -= matrix operators
John W. Eaton <jwe@octave.org>
parents: 22600
diff changeset
2748 octave_idx_type a_nc = a.cols ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2749
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2750 if (nr != a_nr || nc != a_nc)
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2751 octave::err_nonconformant ("operator -=", nr, nc, a_nr, a_nc);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2752
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2753 for (octave_idx_type i = 0; i < a.length (); i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2754 elem (i, i) -= a.elem (i, i);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2755
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2756 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2757 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2758
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2759 // matrix by matrix -> matrix operations
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2760
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2761 FloatComplexMatrix&
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2762 FloatComplexMatrix::operator += (const FloatMatrix& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2763 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2764 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2765 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2766
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2767 octave_idx_type a_nr = a.rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2768 octave_idx_type a_nc = a.cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2769
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2770 if (nr != a_nr || nc != a_nc)
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2771 octave::err_nonconformant ("operator +=", nr, nc, a_nr, a_nc);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2772
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2773 if (nr == 0 || nc == 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2774 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2775
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2776 FloatComplex *d = fortran_vec (); // Ensures only 1 reference to my privates!
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2777
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
2778 mx_inline_add2 (numel (), d, a.data ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2779 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2780 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2781
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2782 FloatComplexMatrix&
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2783 FloatComplexMatrix::operator -= (const FloatMatrix& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2784 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2785 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2786 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2787
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2788 octave_idx_type a_nr = a.rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2789 octave_idx_type a_nc = a.cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2790
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2791 if (nr != a_nr || nc != a_nc)
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
2792 octave::err_nonconformant ("operator -=", nr, nc, a_nr, a_nc);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2793
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2794 if (nr == 0 || nc == 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2795 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2796
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
2797 FloatComplex *d = fortran_vec (); // Ensures only 1 reference to my privates!
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2798
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
2799 mx_inline_sub2 (numel (), d, a.data ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2800 return *this;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2801 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2802
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2803 // unary operations
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2804
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2805 boolMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2806 FloatComplexMatrix::all (int dim) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2807 {
19321
3746b92739f7 Replace some duplicated code and count on methods implemented on base classes.
Carnë Draug <carandraug@octave.org>
parents: 19320
diff changeset
2808 return FloatComplexNDArray::all (dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2809 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2810
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2811 boolMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2812 FloatComplexMatrix::any (int dim) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2813 {
19321
3746b92739f7 Replace some duplicated code and count on methods implemented on base classes.
Carnë Draug <carandraug@octave.org>
parents: 19320
diff changeset
2814 return FloatComplexNDArray::any (dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2815 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2816
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2817 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2818 FloatComplexMatrix::cumprod (int dim) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2819 {
19321
3746b92739f7 Replace some duplicated code and count on methods implemented on base classes.
Carnë Draug <carandraug@octave.org>
parents: 19320
diff changeset
2820 return FloatComplexNDArray::cumprod (dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2821 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2822
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2823 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2824 FloatComplexMatrix::cumsum (int dim) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2825 {
19321
3746b92739f7 Replace some duplicated code and count on methods implemented on base classes.
Carnë Draug <carandraug@octave.org>
parents: 19320
diff changeset
2826 return FloatComplexNDArray::cumsum (dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2827 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2828
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2829 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2830 FloatComplexMatrix::prod (int dim) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2831 {
19321
3746b92739f7 Replace some duplicated code and count on methods implemented on base classes.
Carnë Draug <carandraug@octave.org>
parents: 19320
diff changeset
2832 return FloatComplexNDArray::prod (dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2833 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2834
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2835 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2836 FloatComplexMatrix::sum (int dim) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2837 {
19321
3746b92739f7 Replace some duplicated code and count on methods implemented on base classes.
Carnë Draug <carandraug@octave.org>
parents: 19320
diff changeset
2838 return FloatComplexNDArray::sum (dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2839 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2840
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2841 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2842 FloatComplexMatrix::sumsq (int dim) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2843 {
19321
3746b92739f7 Replace some duplicated code and count on methods implemented on base classes.
Carnë Draug <carandraug@octave.org>
parents: 19320
diff changeset
2844 return FloatComplexNDArray::sumsq (dim);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2845 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2846
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2847 FloatMatrix FloatComplexMatrix::abs (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2848 {
19321
3746b92739f7 Replace some duplicated code and count on methods implemented on base classes.
Carnë Draug <carandraug@octave.org>
parents: 19320
diff changeset
2849 return FloatComplexNDArray::abs ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2850 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2851
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2852 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2853 FloatComplexMatrix::diag (octave_idx_type k) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2854 {
19321
3746b92739f7 Replace some duplicated code and count on methods implemented on base classes.
Carnë Draug <carandraug@octave.org>
parents: 19320
diff changeset
2855 return FloatComplexNDArray::diag (k);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2856 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2857
14557
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2858 FloatComplexDiagMatrix
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2859 FloatComplexMatrix::diag (octave_idx_type m, octave_idx_type n) const
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2860 {
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2861 FloatComplexDiagMatrix retval;
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2862
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2863 octave_idx_type nr = rows ();
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2864 octave_idx_type nc = cols ();
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2865
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2866 if (nr == 1 || nc == 1)
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2867 retval = FloatComplexDiagMatrix (*this, m, n);
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2868 else
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
2869 (*current_liboctave_error_handler) ("diag: expecting vector argument");
14557
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2870
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2871 return retval;
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2872 }
e8e86ae3abbc make diag (x, m, n) return a proper diagonal matrix object (bug #36099)
John W. Eaton <jwe@octave.org>
parents: 14427
diff changeset
2873
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2874 bool
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2875 FloatComplexMatrix::row_is_real_only (octave_idx_type i) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2876 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2877 bool retval = true;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2878
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2879 octave_idx_type nc = columns ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2880
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2881 for (octave_idx_type j = 0; j < nc; j++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2882 {
23708
750e42a35adc Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents: 23594
diff changeset
2883 if (std::imag (elem (i, j)) != 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2884 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2885 retval = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2886 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2887 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2888 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2889
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
2890 return retval;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2891 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2892
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2893 bool
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2894 FloatComplexMatrix::column_is_real_only (octave_idx_type j) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2895 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2896 bool retval = true;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2897
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2898 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2899
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2900 for (octave_idx_type i = 0; i < nr; i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2901 {
23708
750e42a35adc Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents: 23594
diff changeset
2902 if (std::imag (elem (i, j)) != 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2903 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2904 retval = false;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2905 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2906 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2907 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2908
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
2909 return retval;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2910 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2911
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2912 FloatComplexColumnVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2913 FloatComplexMatrix::row_min (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2914 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2915 Array<octave_idx_type> dummy_idx;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2916 return row_min (dummy_idx);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2917 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2918
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2919 FloatComplexColumnVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2920 FloatComplexMatrix::row_min (Array<octave_idx_type>& idx_arg) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2921 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2922 FloatComplexColumnVector result;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2923
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2924 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2925 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2926
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2927 if (nr > 0 && nc > 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2928 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2929 result.resize (nr);
11574
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
2930 idx_arg.resize (dim_vector (nr, 1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2931
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2932 for (octave_idx_type i = 0; i < nr; i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2933 {
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2934 bool real_only = row_is_real_only (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2935
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2936 octave_idx_type idx_j;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2937
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2938 FloatComplex tmp_min;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2939
21723
bae585228161 use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents: 21721
diff changeset
2940 float abs_min = octave::numeric_limits<float>::NaN ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2941
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2942 for (idx_j = 0; idx_j < nc; idx_j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2943 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2944 tmp_min = elem (i, idx_j);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2945
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2946 if (! octave::math::isnan (tmp_min))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2947 {
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
2948 abs_min = (real_only ? tmp_min.real ()
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
2949 : std::abs (tmp_min));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2950 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2951 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2952 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2953
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2954 for (octave_idx_type j = idx_j+1; j < nc; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2955 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2956 FloatComplex tmp = elem (i, j);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2957
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2958 if (octave::math::isnan (tmp))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2959 continue;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2960
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
2961 float abs_tmp = (real_only ? tmp.real () : std::abs (tmp));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2962
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2963 if (abs_tmp < abs_min)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2964 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2965 idx_j = j;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2966 tmp_min = tmp;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2967 abs_min = abs_tmp;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2968 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2969 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2970
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
2971 if (octave::math::isnan (tmp_min))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2972 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2973 result.elem (i) = FloatComplex_NaN_result;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2974 idx_arg.elem (i) = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2975 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2976 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2977 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2978 result.elem (i) = tmp_min;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2979 idx_arg.elem (i) = idx_j;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
2980 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2981 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2982 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2983
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2984 return result;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2985 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2986
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2987 FloatComplexColumnVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2988 FloatComplexMatrix::row_max (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2989 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2990 Array<octave_idx_type> dummy_idx;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2991 return row_max (dummy_idx);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2992 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2993
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2994 FloatComplexColumnVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2995 FloatComplexMatrix::row_max (Array<octave_idx_type>& idx_arg) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2996 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2997 FloatComplexColumnVector result;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2998
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
2999 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3000 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3001
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3002 if (nr > 0 && nc > 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3003 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3004 result.resize (nr);
11574
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
3005 idx_arg.resize (dim_vector (nr, 1));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3006
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3007 for (octave_idx_type i = 0; i < nr; i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3008 {
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3009 bool real_only = row_is_real_only (i);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3010
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3011 octave_idx_type idx_j;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3012
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3013 FloatComplex tmp_max;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3014
21723
bae585228161 use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents: 21721
diff changeset
3015 float abs_max = octave::numeric_limits<float>::NaN ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3016
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3017 for (idx_j = 0; idx_j < nc; idx_j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3018 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3019 tmp_max = elem (i, idx_j);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3020
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3021 if (! octave::math::isnan (tmp_max))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3022 {
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
3023 abs_max = (real_only ? tmp_max.real ()
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
3024 : std::abs (tmp_max));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3025 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3026 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3027 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3028
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3029 for (octave_idx_type j = idx_j+1; j < nc; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3030 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3031 FloatComplex tmp = elem (i, j);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3032
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3033 if (octave::math::isnan (tmp))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3034 continue;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3035
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
3036 float abs_tmp = (real_only ? tmp.real () : std::abs (tmp));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3037
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3038 if (abs_tmp > abs_max)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3039 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3040 idx_j = j;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3041 tmp_max = tmp;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3042 abs_max = abs_tmp;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3043 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3044 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3045
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3046 if (octave::math::isnan (tmp_max))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3047 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3048 result.elem (i) = FloatComplex_NaN_result;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3049 idx_arg.elem (i) = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3050 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3051 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3052 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3053 result.elem (i) = tmp_max;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3054 idx_arg.elem (i) = idx_j;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3055 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3056 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3057 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3058
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3059 return result;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3060 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3061
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3062 FloatComplexRowVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3063 FloatComplexMatrix::column_min (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3064 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3065 Array<octave_idx_type> dummy_idx;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3066 return column_min (dummy_idx);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3067 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3068
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3069 FloatComplexRowVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3070 FloatComplexMatrix::column_min (Array<octave_idx_type>& idx_arg) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3071 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3072 FloatComplexRowVector result;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3073
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3074 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3075 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3076
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3077 if (nr > 0 && nc > 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3078 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3079 result.resize (nc);
11574
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
3080 idx_arg.resize (dim_vector (1, nc));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3081
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3082 for (octave_idx_type j = 0; j < nc; j++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3083 {
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3084 bool real_only = column_is_real_only (j);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3085
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3086 octave_idx_type idx_i;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3087
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3088 FloatComplex tmp_min;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3089
21723
bae585228161 use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents: 21721
diff changeset
3090 float abs_min = octave::numeric_limits<float>::NaN ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3091
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3092 for (idx_i = 0; idx_i < nr; idx_i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3093 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3094 tmp_min = elem (idx_i, j);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3095
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3096 if (! octave::math::isnan (tmp_min))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3097 {
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
3098 abs_min = (real_only ? tmp_min.real ()
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
3099 : std::abs (tmp_min));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3100 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3101 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3102 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3103
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3104 for (octave_idx_type i = idx_i+1; i < nr; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3105 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3106 FloatComplex tmp = elem (i, j);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3107
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3108 if (octave::math::isnan (tmp))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3109 continue;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3110
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
3111 float abs_tmp = (real_only ? tmp.real () : std::abs (tmp));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3112
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3113 if (abs_tmp < abs_min)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3114 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3115 idx_i = i;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3116 tmp_min = tmp;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3117 abs_min = abs_tmp;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3118 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3119 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3120
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3121 if (octave::math::isnan (tmp_min))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3122 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3123 result.elem (j) = FloatComplex_NaN_result;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3124 idx_arg.elem (j) = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3125 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3126 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3127 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3128 result.elem (j) = tmp_min;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3129 idx_arg.elem (j) = idx_i;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3130 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3131 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3132 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3133
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3134 return result;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3135 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3136
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3137 FloatComplexRowVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3138 FloatComplexMatrix::column_max (void) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3139 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3140 Array<octave_idx_type> dummy_idx;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3141 return column_max (dummy_idx);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3142 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3143
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3144 FloatComplexRowVector
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3145 FloatComplexMatrix::column_max (Array<octave_idx_type>& idx_arg) const
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3146 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3147 FloatComplexRowVector result;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3148
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3149 octave_idx_type nr = rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3150 octave_idx_type nc = cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3151
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3152 if (nr > 0 && nc > 0)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3153 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3154 result.resize (nc);
11574
a83bad07f7e3 attempt better backward compatibility for Array resize functions
John W. Eaton <jwe@octave.org>
parents: 11570
diff changeset
3155 idx_arg.resize (dim_vector (1, nc));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3156
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3157 for (octave_idx_type j = 0; j < nc; j++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3158 {
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3159 bool real_only = column_is_real_only (j);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3160
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3161 octave_idx_type idx_i;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3162
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3163 FloatComplex tmp_max;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3164
21723
bae585228161 use namespace for numeric_limits
John W. Eaton <jwe@octave.org>
parents: 21721
diff changeset
3165 float abs_max = octave::numeric_limits<float>::NaN ();
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3166
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3167 for (idx_i = 0; idx_i < nr; idx_i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3168 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3169 tmp_max = elem (idx_i, j);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3170
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3171 if (! octave::math::isnan (tmp_max))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3172 {
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
3173 abs_max = (real_only ? tmp_max.real ()
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
3174 : std::abs (tmp_max));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3175 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3176 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3177 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3178
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3179 for (octave_idx_type i = idx_i+1; i < nr; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3180 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3181 FloatComplex tmp = elem (i, j);
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3182
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3183 if (octave::math::isnan (tmp))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3184 continue;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3185
23450
855122b993da maint: Wrap tertiary operator in parentheses "(COND ? x : y)".
Rik <rik@octave.org>
parents: 23449
diff changeset
3186 float abs_tmp = (real_only ? tmp.real () : std::abs (tmp));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3187
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3188 if (abs_tmp > abs_max)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3189 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3190 idx_i = i;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3191 tmp_max = tmp;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3192 abs_max = abs_tmp;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3193 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3194 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3195
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3196 if (octave::math::isnan (tmp_max))
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3197 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3198 result.elem (j) = FloatComplex_NaN_result;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3199 idx_arg.elem (j) = 0;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3200 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3201 else
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3202 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3203 result.elem (j) = tmp_max;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3204 idx_arg.elem (j) = idx_i;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3205 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3206 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3207 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3208
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3209 return result;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3210 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3211
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3212 // i/o
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3213
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3214 std::ostream&
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3215 operator << (std::ostream& os, const FloatComplexMatrix& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3216 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3217 for (octave_idx_type i = 0; i < a.rows (); i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3218 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3219 for (octave_idx_type j = 0; j < a.cols (); j++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3220 {
23807
336f89b6208b Use character literals 'c' rather than string literals "c" when possible.
Rik <rik@octave.org>
parents: 23798
diff changeset
3221 os << ' ';
28628
83172e1c77f2 refactor octave_read_* and octave_write_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3222 octave::write_value<Complex> (os, a.elem (i, j));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3223 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3224 os << "\n";
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3225 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3226 return os;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3227 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3228
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3229 std::istream&
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3230 operator >> (std::istream& is, FloatComplexMatrix& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3231 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3232 octave_idx_type nr = a.rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3233 octave_idx_type nc = a.cols ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3234
8999
dc07bc4157b8 allow empty matrices in stream input operators
Jaroslav Hajek <highegg@gmail.com>
parents: 8956
diff changeset
3235 if (nr > 0 && nc > 0)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3236 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3237 FloatComplex tmp;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3238 for (octave_idx_type i = 0; i < nr; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3239 for (octave_idx_type j = 0; j < nc; j++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3240 {
28628
83172e1c77f2 refactor octave_read_* and octave_write_* functions
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3241 tmp = octave::read_value<FloatComplex> (is);
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3242 if (is)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3243 a.elem (i, j) = tmp;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3244 else
21169
40051830f89b maint: Replace more instances of goto in liboctave with other constructs.
Rik <rik@octave.org>
parents: 21136
diff changeset
3245 return is;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3246 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3247 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3248
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3249 return is;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3250 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3251
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3252 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3253 Givens (const FloatComplex& x, const FloatComplex& y)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3254 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3255 float cc;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3256 FloatComplex cs, temp_r;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
3257
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
3258 F77_FUNC (clartg, CLARTG) (F77_CONST_CMPLX_ARG (&x), F77_CONST_CMPLX_ARG (&y),
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
3259 cc, F77_CMPLX_ARG (&cs), F77_CMPLX_ARG (&temp_r));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3260
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3261 FloatComplexMatrix g (2, 2);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3262
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3263 g.elem (0, 0) = cc;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3264 g.elem (1, 1) = cc;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3265 g.elem (0, 1) = cs;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3266 g.elem (1, 0) = -conj (cs);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3267
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3268 return g;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3269 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3270
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3271 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3272 Sylvester (const FloatComplexMatrix& a, const FloatComplexMatrix& b,
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3273 const FloatComplexMatrix& c)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3274 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3275 FloatComplexMatrix retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3276
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
3277 // FIXME: need to check that a, b, and c are all the same
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3278 // size.
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3279
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3280 // Compute Schur decompositions
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3281
22317
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22274
diff changeset
3282 octave::math::schur<FloatComplexMatrix> as (a, "U");
6ca3acf5fad8 move some new numeric classes to namespace octave::math
John W. Eaton <jwe@octave.org>
parents: 22274
diff changeset
3283 octave::math::schur<FloatComplexMatrix> bs (b, "U");
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
3284
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3285 // Transform c to new coordinates.
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3286
30073
1e277c6b6626 maint: rename schur member function from "unitary_matrix" to "unitary_schur_matrix"
Rik <rik@octave.org>
parents: 29931
diff changeset
3287 FloatComplexMatrix ua = as.unitary_schur_matrix ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3288 FloatComplexMatrix sch_a = as.schur_matrix ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3289
30073
1e277c6b6626 maint: rename schur member function from "unitary_matrix" to "unitary_schur_matrix"
Rik <rik@octave.org>
parents: 29931
diff changeset
3290 FloatComplexMatrix ub = bs.unitary_schur_matrix ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3291 FloatComplexMatrix sch_b = bs.schur_matrix ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
3292
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3293 FloatComplexMatrix cx = ua.hermitian () * c * ub;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3294
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3295 // Solve the sylvester equation, back-transform, and return the
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3296 // solution.
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3297
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
3298 F77_INT a_nr = octave::to_f77_int (a.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
3299 F77_INT b_nr = octave::to_f77_int (b.rows ());
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3300
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3301 float scale;
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
3302 F77_INT info;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3303
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3304 FloatComplex *pa = sch_a.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3305 FloatComplex *pb = sch_b.fortran_vec ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3306 FloatComplex *px = cx.fortran_vec ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
3307
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3308 F77_XFCN (ctrsyl, CTRSYL, (F77_CONST_CHAR_ARG2 ("N", 1),
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3309 F77_CONST_CHAR_ARG2 ("N", 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
3310 1, a_nr, b_nr, F77_CMPLX_ARG (pa), a_nr, F77_CMPLX_ARG (pb),
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
3311 b_nr, F77_CMPLX_ARG (px), a_nr, scale, info
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3312 F77_CHAR_ARG_LEN (1)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3313 F77_CHAR_ARG_LEN (1)));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3314
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
3315 // FIXME: check info?
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3316
19065
d20c81d3cd21 Deprecate syl, add new function sylvester.
Rik <rik@octave.org>
parents: 18850
diff changeset
3317 retval = ua * cx * ub.hermitian ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3318
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3319 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3320 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3321
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3322 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3323 operator * (const FloatComplexMatrix& m, const FloatMatrix& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3324 {
9663
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
3325 if (m.columns () > std::min (m.rows (), a.columns ()) / 10)
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
3326 return FloatComplexMatrix (real (m) * a, imag (m) * a);
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
3327 else
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
3328 return m * FloatComplexMatrix (a);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3329 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3330
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3331 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3332 operator * (const FloatMatrix& m, const FloatComplexMatrix& a)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3333 {
9663
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
3334 if (a.rows () > std::min (m.rows (), a.columns ()) / 10)
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
3335 return FloatComplexMatrix (m * real (a), m * imag (a));
7e5b4de5fbfe improve mixed real x complex ops
Jaroslav Hajek <highegg@gmail.com>
parents: 9661
diff changeset
3336 else
18115
0fa235a252a5 fix cut and paste error in Matrix by ComplexMatrix multiplication operator
John W. Eaton <jwe@octave.org>
parents: 17769
diff changeset
3337 return FloatComplexMatrix (m) * a;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3338 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3339
14427
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3340 /*
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3341
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3342 ## Simple Dot Product, Matrix-Vector, and Matrix-Matrix Unit tests
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3343 %!assert (single ([1+i 2+i 3+i]) * single ([ 4+i ; 5+i ; 6+i]), single (29+21i), 5e-7)
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3344 %!assert (single ([1+i 2+i ; 3+i 4+i]) * single ([5+i ; 6+i]), single ([15 + 14i ; 37 + 18i]), 5e-7)
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3345 %!assert (single ([1+i 2+i ; 3+i 4+i ]) * single ([5+i 6+i ; 7+i 8+i]), single ([17 + 15i 20 + 17i; 41 + 19i 48 + 21i]), 5e-7)
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3346 %!assert (single ([1 i])*single ([i 0])', single (-i))
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3347
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3348 ## Test some simple identities
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3349 %!shared M, cv, rv
14427
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3350 %! M = single (randn (10,10))+ i*single (rand (10,10));
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3351 %! cv = single (randn (10,1))+ i*single (rand (10,1));
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3352 %! rv = single (randn (1,10))+ i*single (rand (1,10));
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3353 %!assert ([M*cv,M*cv], M*[cv,cv], 5e-6)
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3354 %!assert ([M.'*cv,M.'*cv], M.'*[cv,cv], 5e-6)
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3355 %!assert ([M'*cv,M'*cv], M'*[cv,cv], 5e-6)
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3356 %!assert ([rv*M;rv*M], [rv;rv]*M, 5e-6)
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3357 %!assert ([rv*M.';rv*M.'], [rv;rv]*M.', 5e-6)
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3358 %!assert ([rv*M';rv*M'], [rv;rv]*M', 5e-6)
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3359 %!assert (2*rv*cv, [rv,rv]*[cv;cv], 5e-6)
d07e989686b0 Use Octave coding conventions in liboctave %!test blocks
Rik <octave@nomad.inbox5.com>
parents: 14138
diff changeset
3360
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3361 */
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3362
11516
53edbf95fbb6 avoid GCC warnings
John W. Eaton <jwe@octave.org>
parents: 11130
diff changeset
3363 static char
7804
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3364 get_blas_trans_arg (bool trans, bool conj)
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3365 {
11516
53edbf95fbb6 avoid GCC warnings
John W. Eaton <jwe@octave.org>
parents: 11130
diff changeset
3366 return trans ? (conj ? 'C' : 'T') : 'N';
7804
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3367 }
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3368
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3369 // the general GEMM operation
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3370
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3371 FloatComplexMatrix
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
3372 xgemm (const FloatComplexMatrix& a, const FloatComplexMatrix& b,
9665
1dba57e9d08d use blas_trans_type for xgemm
Jaroslav Hajek <highegg@gmail.com>
parents: 9663
diff changeset
3373 blas_trans_type transa, blas_trans_type transb)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3374 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3375 FloatComplexMatrix retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3376
18084
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 18083
diff changeset
3377 bool tra = transa != blas_no_trans;
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 18083
diff changeset
3378 bool trb = transb != blas_no_trans;
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 18083
diff changeset
3379 bool cja = transa == blas_conj_trans;
8e056300994b Follow coding convention of defining and initializing only 1 variable per line in liboctave.
Rik <rik@octave.org>
parents: 18083
diff changeset
3380 bool cjb = transb == blas_conj_trans;
9665
1dba57e9d08d use blas_trans_type for xgemm
Jaroslav Hajek <highegg@gmail.com>
parents: 9663
diff changeset
3381
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
3382 F77_INT a_nr = octave::to_f77_int (tra ? a.cols () : a.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
3383 F77_INT a_nc = octave::to_f77_int (tra ? a.rows () : a.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
3384
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
3385 F77_INT b_nr = octave::to_f77_int (trb ? b.cols () : b.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
3386 F77_INT b_nc = octave::to_f77_int (trb ? b.rows () : b.cols ());
7804
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3387
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3388 if (a_nc != b_nr)
22327
d0562b3159c7 move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22323
diff changeset
3389 octave::err_nonconformant ("operator *", a_nr, a_nc, b_nr, b_nc);
21120
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3390
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3391 if (a_nr == 0 || a_nc == 0 || b_nc == 0)
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3392 retval = FloatComplexMatrix (a_nr, b_nc, 0.0);
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3393 else if (a.data () == b.data () && a_nr == b_nc && tra != trb)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3394 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
3395 F77_INT lda = octave::to_f77_int (a.rows ());
21120
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3396
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3397 // FIXME: looking at the reference BLAS, it appears that it
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3398 // should not be necessary to initialize the output matrix if
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3399 // BETA is 0 in the call to CHERK, but ATLAS appears to
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3400 // use the result matrix before zeroing the elements.
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3401
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3402 retval = FloatComplexMatrix (a_nr, b_nc, 0.0);
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3403 FloatComplex *c = retval.fortran_vec ();
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3404
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3405 const char ctra = get_blas_trans_arg (tra, cja);
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3406 if (cja || cjb)
7804
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3407 {
21120
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3408 F77_XFCN (cherk, CHERK, (F77_CONST_CHAR_ARG2 ("U", 1),
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3409 F77_CONST_CHAR_ARG2 (&ctra, 1),
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3410 a_nr, a_nc, 1.0,
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
3411 F77_CONST_CMPLX_ARG (a.data ()), lda, 0.0, F77_CMPLX_ARG (c), a_nr
21120
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3412 F77_CHAR_ARG_LEN (1)
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3413 F77_CHAR_ARG_LEN (1)));
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
3414 for (F77_INT j = 0; j < a_nr; j++)
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
3415 for (F77_INT i = 0; i < j; i++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30313
diff changeset
3416 retval.xelem (j, i) = octave::math::conj (retval.xelem (i, j));
7804
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3417 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3418 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3419 {
21120
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3420 F77_XFCN (csyrk, CSYRK, (F77_CONST_CHAR_ARG2 ("U", 1),
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3421 F77_CONST_CHAR_ARG2 (&ctra, 1),
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3422 a_nr, a_nc, 1.0,
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
3423 F77_CONST_CMPLX_ARG (a.data ()), lda, 0.0, F77_CMPLX_ARG (c), a_nr
21120
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3424 F77_CHAR_ARG_LEN (1)
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3425 F77_CHAR_ARG_LEN (1)));
22971
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
3426 for (F77_INT j = 0; j < a_nr; j++)
d244af1d0bc7 use F77_INT instead of octave_idx_type for liboctave Matrix classes
John W. Eaton <jwe@octave.org>
parents: 22849
diff changeset
3427 for (F77_INT i = 0; i < j; i++)
30394
f3f3e3793fb5 maint: style check C++ files in liboctave/ ahead of 7.1 release.
Rik <rik@octave.org>
parents: 30313
diff changeset
3428 retval.xelem (j, i) = retval.xelem (i, j);
21120
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3429
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3430 }
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3431
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3432 }
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3433 else
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3434 {
22988
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
3435 F77_INT lda = octave::to_f77_int (a.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
3436 F77_INT tda = octave::to_f77_int (a.cols ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
3437 F77_INT ldb = octave::to_f77_int (b.rows ());
cd33c785e80e put to_f77_int inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22981
diff changeset
3438 F77_INT tdb = octave::to_f77_int (b.cols ());
21120
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3439
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3440 retval = FloatComplexMatrix (a_nr, b_nc, 0.0);
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3441 FloatComplex *c = retval.fortran_vec ();
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3442
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3443 if (b_nc == 1 && a_nr == 1)
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3444 {
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3445 if (cja == cjb)
7804
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3446 {
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
3447 F77_FUNC (xcdotu, XCDOTU) (a_nc, F77_CONST_CMPLX_ARG (a.data ()), 1,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
3448 F77_CONST_CMPLX_ARG (b.data ()), 1,
22145
cf5145769e37 * fCMatrix.cc (xgemm): Fix thinko in cset 407c66ae1e20.
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
3449 F77_CMPLX_ARG (c));
22274
edcad35c364f don't rely on std:: overloads of arg, conj, imag, and real for real args
John W. Eaton <jwe@octave.org>
parents: 22261
diff changeset
3450 if (cja) *c = octave::math::conj (*c);
7804
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3451 }
21120
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3452 else if (cja)
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
3453 F77_FUNC (xcdotc, XCDOTC) (a_nc, F77_CONST_CMPLX_ARG (a.data ()), 1,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
3454 F77_CONST_CMPLX_ARG (b.data ()), 1,
22145
cf5145769e37 * fCMatrix.cc (xgemm): Fix thinko in cset 407c66ae1e20.
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
3455 F77_CMPLX_ARG (c));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3456 else
22402
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
3457 F77_FUNC (xcdotc, XCDOTC) (a_nc, F77_CONST_CMPLX_ARG (b.data ()), 1,
4caa7b28d183 maint: Style check C++ code in liboctave/
Rik <rik@octave.org>
parents: 22327
diff changeset
3458 F77_CONST_CMPLX_ARG (a.data ()), 1,
22145
cf5145769e37 * fCMatrix.cc (xgemm): Fix thinko in cset 407c66ae1e20.
John W. Eaton <jwe@octave.org>
parents: 22135
diff changeset
3459 F77_CMPLX_ARG (c));
21120
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3460 }
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3461 else if (b_nc == 1 && ! cjb)
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3462 {
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3463 const char ctra = get_blas_trans_arg (tra, cja);
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3464 F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 (&ctra, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
3465 lda, tda, 1.0, F77_CONST_CMPLX_ARG (a.data ()), lda,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
3466 F77_CONST_CMPLX_ARG (b.data ()), 1, 0.0, F77_CMPLX_ARG (c), 1
21120
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3467 F77_CHAR_ARG_LEN (1)));
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3468 }
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3469 else if (a_nr == 1 && ! cja && ! cjb)
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3470 {
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3471 const char crevtrb = get_blas_trans_arg (! trb, cjb);
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3472 F77_XFCN (cgemv, CGEMV, (F77_CONST_CHAR_ARG2 (&crevtrb, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
3473 ldb, tdb, 1.0, F77_CONST_CMPLX_ARG (b.data ()), ldb,
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
3474 F77_CONST_CMPLX_ARG (a.data ()), 1, 0.0, F77_CMPLX_ARG (c), 1
21120
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3475 F77_CHAR_ARG_LEN (1)));
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3476 }
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3477 else
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3478 {
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3479 const char ctra = get_blas_trans_arg (tra, cja);
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3480 const char ctrb = get_blas_trans_arg (trb, cjb);
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3481 F77_XFCN (cgemm, CGEMM, (F77_CONST_CHAR_ARG2 (&ctra, 1),
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3482 F77_CONST_CHAR_ARG2 (&ctrb, 1),
22135
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
3483 a_nr, b_nc, a_nc, 1.0, F77_CONST_CMPLX_ARG (a.data ()),
407c66ae1e20 reduce warnings from GCC's link-time optimization feature (bug #48531)
John W. Eaton <jwe@octave.org>
parents: 22133
diff changeset
3484 lda, F77_CONST_CMPLX_ARG (b.data ()), ldb, 0.0, F77_CMPLX_ARG (c), a_nr
21120
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3485 F77_CHAR_ARG_LEN (1)
499b851fbfae Replace pattern if/err_XXX/else/code with if/err_XXX/ code.
Rik <rik@octave.org>
parents: 21112
diff changeset
3486 F77_CHAR_ARG_LEN (1)));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3487 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3488 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3489
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3490 return retval;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3491 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3492
7804
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3493 FloatComplexMatrix
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3494 operator * (const FloatComplexMatrix& a, const FloatComplexMatrix& b)
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3495 {
9665
1dba57e9d08d use blas_trans_type for xgemm
Jaroslav Hajek <highegg@gmail.com>
parents: 9663
diff changeset
3496 return xgemm (a, b);
7804
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3497 }
a0c550b22e61 compound ops for float matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 7797
diff changeset
3498
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
3499 // FIXME: it would be nice to share code among the min/max
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3500 // functions below.
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3501
22197
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22145
diff changeset
3502 #define EMPTY_RETURN_CHECK(T) \
e43d83253e28 refill multi-line macro definitions
John W. Eaton <jwe@octave.org>
parents: 22145
diff changeset
3503 if (nr == 0 || nc == 0) \
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3504 return T (nr, nc);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3505
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3506 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3507 min (const FloatComplex& c, const FloatComplexMatrix& m)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3508 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3509 octave_idx_type nr = m.rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3510 octave_idx_type nc = m.columns ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3511
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3512 EMPTY_RETURN_CHECK (FloatComplexMatrix);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3513
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3514 FloatComplexMatrix result (nr, nc);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3515
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3516 for (octave_idx_type j = 0; j < nc; j++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3517 for (octave_idx_type i = 0; i < nr; i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3518 {
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3519 octave_quit ();
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3520 result(i, j) = octave::math::min (c, m(i, j));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3521 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3522
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3523 return result;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3524 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3525
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3526 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3527 min (const FloatComplexMatrix& m, const FloatComplex& c)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3528 {
22085
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
3529 return min (c, m);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3530 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3531
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3532 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3533 min (const FloatComplexMatrix& a, const FloatComplexMatrix& b)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3534 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3535 octave_idx_type nr = a.rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3536 octave_idx_type nc = a.columns ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3537
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3538 if (nr != b.rows () || nc != b.columns ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
3539 (*current_liboctave_error_handler)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
3540 ("two-arg min requires same size arguments");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3541
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3542 EMPTY_RETURN_CHECK (FloatComplexMatrix);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3543
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3544 FloatComplexMatrix result (nr, nc);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3545
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3546 for (octave_idx_type j = 0; j < nc; j++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3547 {
21719
ff054947d132 use bool instead of int for some logical flags
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3548 bool columns_are_real_only = true;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3549 for (octave_idx_type i = 0; i < nr; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3550 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3551 octave_quit ();
23708
750e42a35adc Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents: 23594
diff changeset
3552 if (std::imag (a(i, j)) != 0.0 || std::imag (b(i, j)) != 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3553 {
21719
ff054947d132 use bool instead of int for some logical flags
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3554 columns_are_real_only = false;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3555 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3556 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3557 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3558
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3559 if (columns_are_real_only)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3560 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3561 for (octave_idx_type i = 0; i < nr; i++)
23708
750e42a35adc Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents: 23594
diff changeset
3562 result(i, j) = octave::math::min (std::real (a(i, j)),
750e42a35adc Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents: 23594
diff changeset
3563 std::real (b(i, j)));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3564 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3565 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3566 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3567 for (octave_idx_type i = 0; i < nr; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3568 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3569 octave_quit ();
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3570 result(i, j) = octave::math::min (a(i, j), b(i, j));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3571 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3572 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3573 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3574
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3575 return result;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3576 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3577
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3578 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3579 max (const FloatComplex& c, const FloatComplexMatrix& m)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3580 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3581 octave_idx_type nr = m.rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3582 octave_idx_type nc = m.columns ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3583
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3584 EMPTY_RETURN_CHECK (FloatComplexMatrix);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3585
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3586 FloatComplexMatrix result (nr, nc);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3587
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3588 for (octave_idx_type j = 0; j < nc; j++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3589 for (octave_idx_type i = 0; i < nr; i++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3590 {
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3591 octave_quit ();
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3592 result(i, j) = octave::math::max (c, m(i, j));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3593 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3594
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3595 return result;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3596 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3597
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3598 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3599 max (const FloatComplexMatrix& m, const FloatComplex& c)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3600 {
22085
bf5fbf347aaf Avoid segfault with complex matrices using LAPACK (bug #46330).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 22022
diff changeset
3601 return max (c, m);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3602 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3603
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3604 FloatComplexMatrix
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3605 max (const FloatComplexMatrix& a, const FloatComplexMatrix& b)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3606 {
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3607 octave_idx_type nr = a.rows ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3608 octave_idx_type nc = a.columns ();
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3609
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3610 if (nr != b.rows () || nc != b.columns ())
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
3611 (*current_liboctave_error_handler)
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 21129
diff changeset
3612 ("two-arg max requires same size arguments");
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3613
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3614 EMPTY_RETURN_CHECK (FloatComplexMatrix);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3615
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3616 FloatComplexMatrix result (nr, nc);
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3617
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3618 for (octave_idx_type j = 0; j < nc; j++)
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3619 {
21719
ff054947d132 use bool instead of int for some logical flags
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3620 bool columns_are_real_only = true;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3621 for (octave_idx_type i = 0; i < nr; i++)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3622 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3623 octave_quit ();
23708
750e42a35adc Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents: 23594
diff changeset
3624 if (std::imag (a(i, j)) != 0.0 || std::imag (b(i, j)) != 0.0)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3625 {
21719
ff054947d132 use bool instead of int for some logical flags
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
3626 columns_are_real_only = false;
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3627 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3628 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3629 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3630
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3631 if (columns_are_real_only)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3632 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3633 for (octave_idx_type i = 0; i < nr; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3634 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3635 octave_quit ();
23708
750e42a35adc Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents: 23594
diff changeset
3636 result(i, j) = octave::math::max (std::real (a(i, j)),
750e42a35adc Use imag, real, arg from std library for Complex types.
Rik <rik@octave.org>
parents: 23594
diff changeset
3637 std::real (b(i, j)));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3638 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3639 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3640 else
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3641 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3642 for (octave_idx_type i = 0; i < nr; i++)
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3643 {
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3644 octave_quit ();
21782
2aef506f3fec use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
3645 result(i, j) = octave::math::max (a(i, j), b(i, j));
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3646 }
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10213
diff changeset
3647 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3648 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3649
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3650 return result;
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3651 }
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3652
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
3653 FloatComplexMatrix linspace (const FloatComplexColumnVector& x1,
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11574
diff changeset
3654 const FloatComplexColumnVector& x2,
9653
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3655 octave_idx_type n)
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3656
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3657 {
20232
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
3658 octave_idx_type m = x1.numel ();
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
3659
a9574e3c6e9e Deprecate Array::length() and Sparse::length() in favour of ::numel().
Carnë Draug <carandraug@octave.org>
parents: 20218
diff changeset
3660 if (x2.numel () != m)
17769
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
3661 (*current_liboctave_error_handler)
49a5a4be04a1 maint: Use GNU style coding conventions for code in liboctave/
Rik <rik@octave.org>
parents: 17744
diff changeset
3662 ("linspace: vectors must be of equal length");
9653
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3663
27666
3e8faed1b7d8 Remove wrapper template class NoAlias<T> (bug #56752)
Carlo de Falco <carlo.defalco@polimi.it>
parents: 27180
diff changeset
3664 FloatComplexMatrix retval;
9653
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3665
20466
16b9ec39ff46 Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents: 20232
diff changeset
3666 if (n < 1)
16b9ec39ff46 Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents: 20232
diff changeset
3667 {
16b9ec39ff46 Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents: 20232
diff changeset
3668 retval.clear (m, 0);
16b9ec39ff46 Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents: 20232
diff changeset
3669 return retval;
16b9ec39ff46 Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents: 20232
diff changeset
3670 }
16b9ec39ff46 Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents: 20232
diff changeset
3671
9653
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3672 retval.clear (m, n);
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3673 for (octave_idx_type i = 0; i < m; i++)
27666
3e8faed1b7d8 Remove wrapper template class NoAlias<T> (bug #56752)
Carlo de Falco <carlo.defalco@polimi.it>
parents: 27180
diff changeset
3674 retval.xelem (i, 0) = x1(i);
9653
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3675
20466
16b9ec39ff46 Return empty matrix when linspace called with 0 points (bug #45820)
Rik <rik@octave.org>
parents: 20232
diff changeset
3676 // The last column is unused so temporarily store delta there
27666
3e8faed1b7d8 Remove wrapper template class NoAlias<T> (bug #56752)
Carlo de Falco <carlo.defalco@polimi.it>
parents: 27180
diff changeset
3677 FloatComplex *delta = &retval.xelem (0, n-1);
9653
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3678 for (octave_idx_type i = 0; i < m; i++)
25237
ca022a8c4015 linspace: handle ranges with equal Inf endpoints (bug #53489)
Maor Shutman <maorus12@gmail.com>
parents: 25103
diff changeset
3679 delta[i] = (x1(i) == x2(i)) ? 0 : (x2(i) - x1(i)) / (n - 1.0f);
9653
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3680
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3681 for (octave_idx_type j = 1; j < n-1; j++)
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3682 for (octave_idx_type i = 0; i < m; i++)
27666
3e8faed1b7d8 Remove wrapper template class NoAlias<T> (bug #56752)
Carlo de Falco <carlo.defalco@polimi.it>
parents: 27180
diff changeset
3683 retval.xelem (i, j) = x1(i) + static_cast<float> (j)*delta[i];
9653
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3684
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3685 for (octave_idx_type i = 0; i < m; i++)
27666
3e8faed1b7d8 Remove wrapper template class NoAlias<T> (bug #56752)
Carlo de Falco <carlo.defalco@polimi.it>
parents: 27180
diff changeset
3686 retval.xelem (i, n-1) = x2(i);
9653
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3687
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3688 return retval;
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3689 }
e087d7c77ff9 improve linspace in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9601
diff changeset
3690
9578
7dafdb8b062f refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents: 9553
diff changeset
3691 MS_CMP_OPS (FloatComplexMatrix, FloatComplex)
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9528
diff changeset
3692 MS_BOOL_OPS (FloatComplexMatrix, FloatComplex)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3693
9578
7dafdb8b062f refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents: 9553
diff changeset
3694 SM_CMP_OPS (FloatComplex, FloatComplexMatrix)
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9528
diff changeset
3695 SM_BOOL_OPS (FloatComplex, FloatComplexMatrix)
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
diff changeset
3696
9578
7dafdb8b062f refactor comparison ops implementations
Jaroslav Hajek <highegg@gmail.com>
parents: 9553
diff changeset
3697 MM_CMP_OPS (FloatComplexMatrix, FloatComplexMatrix)
9550
3d6a9aea2aea refactor binary & bool ops in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents: 9528
diff changeset
3698 MM_BOOL_OPS (FloatComplexMatrix, FloatComplexMatrix)