Mercurial > octave
annotate libinterp/octave-value/ov-flt-re-diag.cc @ 30564:796f54d4ddbf stable
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2021.
In all .txi and .texi files except gpl.txi and gpl.texi in the
doc/liboctave and doc/interpreter directories, change the copyright
to "Octave Project Developers", the same as used for other source
files. Update copyright notices for 2022 (not done since 2019). For
gpl.txi and gpl.texi, change the copyright notice to be "Free Software
Foundation, Inc." and leave the date at 2007 only because this file
only contains the text of the GPL, not anything created by the Octave
Project Developers.
Add Paul Thomas to contributors.in.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Dec 2021 18:22:40 -0500 |
parents | 2dca5c25237d |
children | 83f9f8bda883 |
rev | line source |
---|---|
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
1 //////////////////////////////////////////////////////////////////////// |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
2 // |
30564
796f54d4ddbf
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30138
diff
changeset
|
3 // Copyright (C) 2008-2022 The Octave Project Developers |
27923
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
4 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
5 // See the file COPYRIGHT.md in the top-level directory of this |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
6 // distribution or <https://octave.org/copyright/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
7 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
8 // This file is part of Octave. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
9 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
10 // Octave is free software: you can redistribute it and/or modify it |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
11 // under the terms of the GNU General Public License as published by |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
12 // the Free Software Foundation, either version 3 of the License, or |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
13 // (at your option) any later version. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
14 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
15 // Octave is distributed in the hope that it will be useful, but |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
16 // WITHOUT ANY WARRANTY; without even the implied warranty of |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
18 // GNU General Public License for more details. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
19 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
20 // You should have received a copy of the GNU General Public License |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
21 // along with Octave; see the file COPYING. If not, see |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
22 // <https://www.gnu.org/licenses/>. |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
23 // |
bd51beb6205e
update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents:
27919
diff
changeset
|
24 //////////////////////////////////////////////////////////////////////// |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
25 |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
26 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
27 # include "config.h" |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
28 #endif |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
29 |
8381
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
30 #include "byte-swap.h" |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
31 |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
32 #include "ov-flt-re-diag.h" |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
33 #include "ov-base-diag.cc" |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
34 #include "ov-float.h" |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
35 #include "ov-flt-re-mat.h" |
8381
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
36 #include "ls-utils.h" |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
37 |
22022
278fc29b69ca
maint: Eliminate unnecessary double newline blocks (only whitespace changes).
Rik <rik@octave.org>
parents:
21782
diff
changeset
|
38 |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
39 template class octave_base_diag<FloatDiagMatrix, FloatMatrix>; |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
40 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
41 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_float_diag_matrix, |
30138
2dca5c25237d
undo matrix -> m_matrix changes in type names and error messages
John W. Eaton <jwe@octave.org>
parents:
30135
diff
changeset
|
42 "float diagonal matrix", "single"); |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
43 |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
44 static octave_base_value * |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
45 default_numeric_conversion_function (const octave_base_value& a) |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
46 { |
27277
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26399
diff
changeset
|
47 const octave_float_diag_matrix& v |
db687716fed6
style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents:
26399
diff
changeset
|
48 = dynamic_cast<const octave_float_diag_matrix&> (a); |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
49 |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
50 return new octave_float_matrix (v.float_matrix_value ()); |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
51 } |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
52 |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
53 octave_base_value::type_conv_info |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
54 octave_float_diag_matrix::numeric_conversion_function (void) const |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
55 { |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
56 return octave_base_value::type_conv_info (default_numeric_conversion_function, |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
57 octave_float_matrix::static_type_id ()); |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
58 } |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
59 |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
60 octave_base_value * |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
61 octave_float_diag_matrix::try_narrowing_conversion (void) |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
62 { |
23457
21baad6b35c4
maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
63 octave_base_value *retval = nullptr; |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
64 |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
65 if (m_matrix.nelem () == 1) |
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
66 retval = new octave_float_scalar (m_matrix (0, 0)); |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
67 |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
68 return retval; |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
69 } |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
70 |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
71 DiagMatrix |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
72 octave_float_diag_matrix::diag_matrix_value (bool) const |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
73 { |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
74 return DiagMatrix (m_matrix); |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
75 } |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
76 |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
77 FloatDiagMatrix |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
78 octave_float_diag_matrix::float_diag_matrix_value (bool) const |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
79 { |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
80 return m_matrix; |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
81 } |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
82 |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
83 ComplexDiagMatrix |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
84 octave_float_diag_matrix::complex_diag_matrix_value (bool) const |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
85 { |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
86 return ComplexDiagMatrix (m_matrix); |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
87 } |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
88 |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
89 FloatComplexDiagMatrix |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
90 octave_float_diag_matrix::float_complex_diag_matrix_value (bool) const |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
91 { |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
92 return FloatComplexDiagMatrix (m_matrix); |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
93 } |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
94 |
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
95 octave_value |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
96 octave_float_diag_matrix::as_double (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
97 { |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
98 return DiagMatrix (m_matrix); |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
99 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
100 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
101 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
102 octave_float_diag_matrix::as_single (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
103 { |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
104 return m_matrix; |
22296
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
105 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
106 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
107 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
108 octave_float_diag_matrix::as_int8 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
109 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
110 return int8_array_value (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
111 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
112 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
113 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
114 octave_float_diag_matrix::as_int16 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
115 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
116 return int16_array_value (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
117 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
118 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
119 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
120 octave_float_diag_matrix::as_int32 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
121 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
122 return int32_array_value (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
123 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
124 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
125 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
126 octave_float_diag_matrix::as_int64 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
127 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
128 return int64_array_value (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
129 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
130 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
131 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
132 octave_float_diag_matrix::as_uint8 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
133 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
134 return uint8_array_value (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
135 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
136 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
137 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
138 octave_float_diag_matrix::as_uint16 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
139 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
140 return uint16_array_value (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
141 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
142 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
143 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
144 octave_float_diag_matrix::as_uint32 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
145 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
146 return uint32_array_value (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
147 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
148 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
149 octave_value |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
150 octave_float_diag_matrix::as_uint64 (void) const |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
151 { |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
152 return uint64_array_value (); |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
153 } |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
154 |
8b18f46f6427
revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents:
22022
diff
changeset
|
155 octave_value |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
156 octave_float_diag_matrix::map (unary_mapper_t umap) const |
8366
8b1a2555c4e2
implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff
changeset
|
157 { |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
158 switch (umap) |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
159 { |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
160 case umap_abs: |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
161 return m_matrix.abs (); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
162 case umap_real: |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
163 case umap_conj: |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
164 return m_matrix; |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
165 case umap_imag: |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
166 return DiagMatrix (m_matrix.rows (), m_matrix.cols (), 0.0); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
167 case umap_sqrt: |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
168 { |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
169 FloatComplexColumnVector tmp = m_matrix.extract_diag ().map<FloatComplex> |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21739
diff
changeset
|
170 (octave::math::rc_sqrt); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
171 FloatComplexDiagMatrix retval (tmp); |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
172 retval.resize (m_matrix.rows (), m_matrix.columns ()); |
9812
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
173 return retval; |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
174 } |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
175 default: |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
176 return to_dense ().map (umap); |
f80c566bc751
improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
177 } |
8834
8dd69187c4a2
specialize sqrt for diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
178 } |
8dd69187c4a2
specialize sqrt for diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8677
diff
changeset
|
179 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
180 bool |
8677
095ae5e0a831
eliminte some compiler warnings
John W. Eaton <jwe@octave.org>
parents:
8650
diff
changeset
|
181 octave_float_diag_matrix::save_binary (std::ostream& os, |
26399
586413770c7f
pass save_as_floats by value in octave_value save_binary functions
John W. Eaton <jwe@octave.org>
parents:
26376
diff
changeset
|
182 bool /* save_as_floats*/) |
8381
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
183 { |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
184 |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
185 int32_t r = m_matrix.rows (); |
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
186 int32_t c = m_matrix.cols (); |
8381
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
187 os.write (reinterpret_cast<char *> (&r), 4); |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
188 os.write (reinterpret_cast<char *> (&c), 4); |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
189 |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
190 FloatMatrix m = FloatMatrix (m_matrix.extract_diag ()); |
8381
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
191 save_type st = LS_FLOAT; |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
192 if (m_matrix.length () > 8192) // FIXME: make this configurable. |
8381
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
193 { |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
194 float max_val, min_val; |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
195 if (m.all_integers (max_val, min_val)) |
30006
75dff8f2de2e
move some load-save utilities to octave namespace
John W. Eaton <jwe@octave.org>
parents:
29358
diff
changeset
|
196 st = octave::get_save_type (max_val, min_val); |
8381
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
197 } |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
198 |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
199 const float *mtmp = m.data (); |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
200 write_floats (os, mtmp, st, m.numel ()); |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
201 |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
202 return true; |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
203 } |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
204 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
205 bool |
8381
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
206 octave_float_diag_matrix::load_binary (std::istream& is, bool swap, |
21739
c4ab2e54f100
use namespace for oct_mach_info class
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
207 octave::mach_info::float_format fmt) |
8381
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
208 { |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
209 int32_t r, c; |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
210 char tmp; |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
211 if (! (is.read (reinterpret_cast<char *> (&r), 4) |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
212 && is.read (reinterpret_cast<char *> (&c), 4) |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
213 && is.read (reinterpret_cast<char *> (&tmp), 1))) |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
214 return false; |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
215 if (swap) |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
216 { |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
217 swap_bytes<4> (&r); |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
218 swap_bytes<4> (&c); |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
219 } |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
220 |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
221 FloatDiagMatrix m (r, c); |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
222 float *re = m.fortran_vec (); |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
223 octave_idx_type len = m.length (); |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
224 read_floats (is, re, static_cast<save_type> (tmp), len, swap, fmt); |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
225 |
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
226 if (! is) |
8381
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
227 return false; |
20555
f90c8372b7ba
eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents:
19697
diff
changeset
|
228 |
30135
606652e9f446
maint: use "m_" prefix for member variables in class octave_base_diag.
Rik <rik@octave.org>
parents:
30006
diff
changeset
|
229 m_matrix = m; |
8381
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
230 |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
231 return true; |
ad896677a2e2
implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8366
diff
changeset
|
232 } |
8398
d95282fa0579
allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8381
diff
changeset
|
233 |
11586
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
234 bool |
12df7854fa7c
strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
235 octave_float_diag_matrix::chk_valid_scalar (const octave_value& val, |
8398
d95282fa0579
allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8381
diff
changeset
|
236 float& x) const |
d95282fa0579
allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8381
diff
changeset
|
237 { |
d95282fa0579
allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8381
diff
changeset
|
238 bool retval = val.is_real_scalar (); |
d95282fa0579
allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8381
diff
changeset
|
239 if (retval) |
d95282fa0579
allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8381
diff
changeset
|
240 x = val.float_value (); |
d95282fa0579
allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8381
diff
changeset
|
241 return retval; |
d95282fa0579
allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents:
8381
diff
changeset
|
242 } |