annotate libinterp/octave-value/ov-flt-cx-diag.cc @ 29358:0a5b15007766 stable

update Octave Project Developers copyright for the new year In files that have the "Octave Project Developers" copyright notice, update for 2021.
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2021 09:52:15 -0500
parents bd51beb6205e
children 75dff8f2de2e
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) 2008-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 ////////////////////////////////////////////////////////////////////////
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-cx-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-flt-re-diag.h"
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
35 #include "ov-flt-complex.h"
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
36 #include "ov-flt-cx-mat.h"
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
37 #include "ls-utils.h"
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
38
22022
278fc29b69ca maint: Eliminate unnecessary double newline blocks (only whitespace changes).
Rik <rik@octave.org>
parents: 21739
diff changeset
39
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
40 template class octave_base_diag<FloatComplexDiagMatrix, FloatComplexMatrix>;
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
41
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
42 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_float_complex_diag_matrix,
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
43 "float complex diagonal matrix", "single");
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
44
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
45 static octave_base_value *
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
46 default_numeric_conversion_function (const octave_base_value& a)
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
47 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 26399
diff changeset
48 const octave_float_complex_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
49 = dynamic_cast<const octave_float_complex_diag_matrix&> (a);
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
50
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
51 return new octave_float_complex_matrix (v.float_complex_matrix_value ());
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
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
54 octave_base_value::type_conv_info
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
55 octave_float_complex_diag_matrix::numeric_conversion_function (void) const
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
56 {
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
57 return octave_base_value::type_conv_info (default_numeric_conversion_function,
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
58 octave_float_complex_matrix::static_type_id ());
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
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
61 octave_base_value *
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
62 octave_float_complex_diag_matrix::try_narrowing_conversion (void)
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
63 {
23457
21baad6b35c4 maint: Use C++11 nullptr rather than 0 or NULL when possible.
Rik <rik@octave.org>
parents: 23220
diff changeset
64 octave_base_value *retval = nullptr;
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
65
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
66 if (matrix.nelem () == 1)
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
67 {
10815
0eb323b71957 simplify narrowing of diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 10315
diff changeset
68 retval = new octave_float_complex (matrix (0, 0));
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
69 octave_base_value *rv2 = retval->try_narrowing_conversion ();
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
70 if (rv2)
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
71 {
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
72 delete retval;
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
73 retval = rv2;
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
74 }
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 else if (matrix.all_elements_are_real ())
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
77 {
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
78 return new octave_float_diag_matrix (::real (matrix));
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
79 }
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
80
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
81 return retval;
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
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
84 DiagMatrix
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
85 octave_float_complex_diag_matrix::diag_matrix_value (bool force_conversion) const
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
86 {
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
87 DiagMatrix retval;
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 if (! force_conversion)
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 20555
diff changeset
90 warn_implicit_conversion ("Octave:imag-to-real",
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 20555
diff changeset
91 type_name (), "real matrix");
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
92
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
93 retval = ::real (matrix);
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 return retval;
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
96 }
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
97
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
98 FloatDiagMatrix
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
99 octave_float_complex_diag_matrix::float_diag_matrix_value (bool force_conversion) const
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
100 {
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
101 DiagMatrix retval;
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
102
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
103 if (! force_conversion)
21100
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 20555
diff changeset
104 warn_implicit_conversion ("Octave:imag-to-real",
e39e05d90788 Switch gripe_XXX to either err_XXX or warn_XXX naming scheme.
Rik <rik@octave.org>
parents: 20555
diff changeset
105 type_name (), "real matrix");
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
106
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
107 retval = ::real (matrix);
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
108
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
109 return retval;
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
110 }
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
111
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
112 ComplexDiagMatrix
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
113 octave_float_complex_diag_matrix::complex_diag_matrix_value (bool) const
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
114 {
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
115 return ComplexDiagMatrix (matrix);
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
116 }
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
117
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
118 FloatComplexDiagMatrix
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
119 octave_float_complex_diag_matrix::float_complex_diag_matrix_value (bool) const
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
120 {
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
121 return matrix;
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
122 }
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
123
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
124 octave_value
22296
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
125 octave_float_complex_diag_matrix::as_double (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
126 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
127 return ComplexDiagMatrix (matrix);
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
128 }
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 octave_value
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
131 octave_float_complex_diag_matrix::as_single (void) const
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
132 {
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
133 return matrix;
8b18f46f6427 revamp double, single, int type conversions
John W. Eaton <jwe@octave.org>
parents: 22022
diff changeset
134 }
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 octave_value
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
137 octave_float_complex_diag_matrix::map (unary_mapper_t umap) const
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
138 {
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
139 switch (umap)
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
140 {
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
141 case umap_abs:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
142 return matrix.abs ();
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
143 case umap_real:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
144 return ::real (matrix);
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
145 case umap_conj:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
146 return ::conj (matrix);
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
147 case umap_imag:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
148 return ::imag (matrix);
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
149 case umap_sqrt:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
150 {
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
151 FloatComplexColumnVector tmp = matrix.extract_diag ().map<FloatComplex>
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
152 (std::sqrt);
9812
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
153 FloatComplexDiagMatrix retval (tmp);
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
154 retval.resize (matrix.rows (), matrix.columns ());
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
155 return retval;
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
156 }
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
157 default:
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
158 return to_dense ().map (umap);
f80c566bc751 improve unary mapper system
Jaroslav Hajek <highegg@gmail.com>
parents: 8920
diff changeset
159 }
8366
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
160 }
8b1a2555c4e2 implement diagonal matrix objects
Jaroslav Hajek <highegg@gmail.com>
parents:
diff changeset
161
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
162 bool
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
163 octave_float_complex_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
164 bool /* save_as_floats */)
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
165 {
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
166
18100
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17787
diff changeset
167 int32_t r = matrix.rows ();
6a71e5030df5 Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
Rik <rik@octave.org>
parents: 17787
diff changeset
168 int32_t c = matrix.cols ();
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
169 os.write (reinterpret_cast<char *> (&r), 4);
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
170 os.write (reinterpret_cast<char *> (&c), 4);
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
171
15448
0a0912a9ab6e Replace deprecated DiagArray2<T>::diag calls with DiagArray2<T>::extract_diag
Jordi Gutiérrez Hermoso <jordigh@octave.org>
parents: 15195
diff changeset
172 FloatComplexMatrix m = FloatComplexMatrix (matrix.extract_diag ());
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
173 save_type st = LS_FLOAT;
17787
175b392e91fe Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents: 17744
diff changeset
174 if (matrix.length () > 4096) // FIXME: make this configurable.
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
175 {
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
176 float max_val, min_val;
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
177 if (m.all_integers (max_val, min_val))
10315
57a59eae83cc untabify src C++ source files
John W. Eaton <jwe@octave.org>
parents: 9812
diff changeset
178 st = 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
179 }
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
180
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
181 const FloatComplex *mtmp = m.data ();
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
182 write_floats (os, reinterpret_cast<const float *> (mtmp), st, 2 * m.numel ());
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 return true;
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
185 }
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
186
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
187 bool
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
188 octave_float_complex_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
189 octave::mach_info::float_format fmt)
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
190 {
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
191 int32_t r, c;
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
192 char tmp;
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
193 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
194 && is.read (reinterpret_cast<char *> (&c), 4)
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
195 && is.read (reinterpret_cast<char *> (&tmp), 1)))
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
196 return false;
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
197 if (swap)
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 swap_bytes<4> (&r);
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
200 swap_bytes<4> (&c);
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
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
203 FloatComplexDiagMatrix m (r, c);
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
204 FloatComplex *re = m.fortran_vec ();
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
205 octave_idx_type len = m.length ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
206 read_floats (is, reinterpret_cast<float *> (re),
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
207 static_cast<save_type> (tmp), 2 * len, swap, fmt);
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
208
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
209 if (! is)
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
210 return false;
20555
f90c8372b7ba eliminate many more simple uses of error_state
John W. Eaton <jwe@octave.org>
parents: 19697
diff changeset
211
8381
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
212 matrix = m;
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
213
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
214 return true;
ad896677a2e2 implement binary saving of diag & perm matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8366
diff changeset
215 }
8398
d95282fa0579 allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8381
diff changeset
216
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
217 bool
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
218 octave_float_complex_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
219 FloatComplex& x) const
d95282fa0579 allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8381
diff changeset
220 {
d95282fa0579 allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8381
diff changeset
221 bool retval = val.is_complex_scalar () || val.is_real_scalar ();
d95282fa0579 allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8381
diff changeset
222 if (retval)
d95282fa0579 allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8381
diff changeset
223 x = val.float_complex_value ();
d95282fa0579 allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8381
diff changeset
224 return retval;
d95282fa0579 allow element assignment to diagonal matrices
Jaroslav Hajek <highegg@gmail.com>
parents: 8381
diff changeset
225 }