Mercurial > octave
annotate libinterp/operators/op-cs-cs.cc @ 27919:1891570abac8
update Octave Project Developers copyright for the new year
In files that have the "Octave Project Developers" copyright notice,
update for 2020.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 06 Jan 2020 22:29:51 -0500 |
parents | b442ec6dda5c |
children | bd51beb6205e |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
27919
1891570abac8
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
27918
diff
changeset
|
3 Copyright (C) 1996-2020 The Octave Project Developers |
27918
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26596
diff
changeset
|
4 |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26596
diff
changeset
|
5 See the file COPYRIGHT.md in the top-level directory of this distribution |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26596
diff
changeset
|
6 or <https://octave.org/COPYRIGHT.html/>. |
b442ec6dda5c
use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents:
26596
diff
changeset
|
7 |
2928 | 8 |
9 This file is part of Octave. | |
10 | |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
11 Octave is free software: you can redistribute it and/or modify it |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
12 under the terms of the GNU General Public License as published by |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
13 the Free Software Foundation, either version 3 of the License, or |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
14 (at your option) any later version. |
2928 | 15 |
22755
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
16 Octave is distributed in the hope that it will be useful, but |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
17 WITHOUT ANY WARRANTY; without even the implied warranty of |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3a2b891d0b33
maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents:
22407
diff
changeset
|
19 GNU General Public License for more details. |
2928 | 20 |
21 You should have received a copy of the GNU General Public License | |
7016 | 22 along with Octave; see the file COPYING. If not, see |
24534
194eb4bd202b
maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents:
23220
diff
changeset
|
23 <https://www.gnu.org/licenses/>. |
2928 | 24 |
25 */ | |
26 | |
21724
aba2e6293dd8
use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents:
21647
diff
changeset
|
27 #if defined (HAVE_CONFIG_H) |
21301
40de9f8f23a6
Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents:
21200
diff
changeset
|
28 # include "config.h" |
2928 | 29 #endif |
30 | |
9551
19d298e6f7e5
make ! operator check for NaNs, simplify implementations in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
31 #include "Array-util.h" |
19d298e6f7e5
make ! operator check for NaNs, simplify implementations in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
32 |
20940
48b2ad5ee801
maint: Rename oct-obj.[cc|h] to ovl.[cc|h] for clarity.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
33 #include "ovl.h" |
2928 | 34 #include "ov.h" |
35 #include "ov-complex.h" | |
36 #include "ov-cx-mat.h" | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
37 #include "ov-flt-cx-mat.h" |
2928 | 38 #include "ov-typeinfo.h" |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
39 #include "ov-null-mat.h" |
2928 | 40 #include "ops.h" |
41 #include "xdiv.h" | |
42 #include "xpow.h" | |
43 | |
3203 | 44 // unary complex scalar ops. |
45 | |
46 DEFUNOP (not, complex) | |
47 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
48 const octave_complex& v = dynamic_cast<const octave_complex&> (a); |
9551
19d298e6f7e5
make ! operator check for NaNs, simplify implementations in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
49 Complex x = v.complex_value (); |
21782
2aef506f3fec
use namespace for lo-mappers.h functions
John W. Eaton <jwe@octave.org>
parents:
21724
diff
changeset
|
50 if (octave::math::isnan (x)) |
22327
d0562b3159c7
move more classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents:
22323
diff
changeset
|
51 octave::err_nan_to_logical_conversion (); |
21024
6176560b03d9
maint: Remove return stmts after gripe function calls.
Rik <rik@octave.org>
parents:
20940
diff
changeset
|
52 |
9551
19d298e6f7e5
make ! operator check for NaNs, simplify implementations in liboctave
Jaroslav Hajek <highegg@gmail.com>
parents:
8920
diff
changeset
|
53 return octave_value (x == 0.0); |
3203 | 54 } |
55 | |
4965 | 56 DEFUNOP_OP (uplus, complex, /* no-op */) |
3203 | 57 DEFUNOP_OP (uminus, complex, -) |
58 DEFUNOP_OP (transpose, complex, /* no-op */) | |
59 | |
60 DEFUNOP (hermitian, complex) | |
61 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
62 const octave_complex& v = dynamic_cast<const octave_complex&> (a); |
3203 | 63 |
64 return octave_value (conj (v.complex_value ())); | |
65 } | |
66 | |
67 DEFNCUNOP_METHOD (incr, complex, increment) | |
68 DEFNCUNOP_METHOD (decr, complex, decrement) | |
69 | |
2928 | 70 // complex scalar by complex scalar ops. |
71 | |
72 DEFBINOP_OP (add, complex, complex, +) | |
73 DEFBINOP_OP (sub, complex, complex, -) | |
74 DEFBINOP_OP (mul, complex, complex, *) | |
75 | |
76 DEFBINOP (div, complex, complex) | |
77 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
78 const octave_complex& v1 = dynamic_cast<const octave_complex&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
79 const octave_complex& v2 = dynamic_cast<const octave_complex&> (a2); |
2928 | 80 |
26596
cc0d942d0e20
Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26376
diff
changeset
|
81 return octave_value (v1.complex_value () / v2.complex_value ()); |
2928 | 82 } |
83 | |
84 DEFBINOP_FN (pow, complex, complex, xpow) | |
85 | |
86 DEFBINOP (ldiv, complex, complex) | |
87 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
88 const octave_complex& v1 = dynamic_cast<const octave_complex&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
89 const octave_complex& v2 = dynamic_cast<const octave_complex&> (a2); |
2928 | 90 |
26596
cc0d942d0e20
Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26376
diff
changeset
|
91 return octave_value (v2.complex_value () / v1.complex_value ()); |
2928 | 92 } |
93 | |
9588
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9579
diff
changeset
|
94 DEFCMPLXCMPOP_OP (lt, complex, complex, <) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9579
diff
changeset
|
95 DEFCMPLXCMPOP_OP (le, complex, complex, <=) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9579
diff
changeset
|
96 DEFCMPLXCMPOP_OP (eq, complex, complex, ==) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9579
diff
changeset
|
97 DEFCMPLXCMPOP_OP (ge, complex, complex, >=) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9579
diff
changeset
|
98 DEFCMPLXCMPOP_OP (gt, complex, complex, >) |
319e2ab9b8ae
warn about the complex comparison ops
Jaroslav Hajek <highegg@gmail.com>
parents:
9579
diff
changeset
|
99 DEFCMPLXCMPOP_OP (ne, complex, complex, !=) |
2928 | 100 |
101 DEFBINOP_OP (el_mul, complex, complex, *) | |
102 | |
103 DEFBINOP (el_div, complex, complex) | |
104 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
105 const octave_complex& v1 = dynamic_cast<const octave_complex&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
106 const octave_complex& v2 = dynamic_cast<const octave_complex&> (a2); |
2928 | 107 |
26596
cc0d942d0e20
Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26376
diff
changeset
|
108 return octave_value (v1.complex_value () / v2.complex_value ()); |
2928 | 109 } |
110 | |
111 DEFBINOP_FN (el_pow, complex, complex, xpow) | |
112 | |
113 DEFBINOP (el_ldiv, complex, complex) | |
114 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
115 const octave_complex& v1 = dynamic_cast<const octave_complex&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
116 const octave_complex& v2 = dynamic_cast<const octave_complex&> (a2); |
2928 | 117 |
26596
cc0d942d0e20
Remove inconsistent warning "Octave:divide-by-zero" (bug #46650).
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents:
26376
diff
changeset
|
118 return octave_value (v2.complex_value () / v1.complex_value ()); |
2928 | 119 } |
120 | |
121 DEFBINOP (el_and, complex, complex) | |
122 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
123 const octave_complex& v1 = dynamic_cast<const octave_complex&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
124 const octave_complex& v2 = dynamic_cast<const octave_complex&> (a2); |
2928 | 125 |
126 return v1.complex_value () != 0.0 && v2.complex_value () != 0.0; | |
127 } | |
128 | |
129 DEFBINOP (el_or, complex, complex) | |
130 { | |
21647
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
131 const octave_complex& v1 = dynamic_cast<const octave_complex&> (a1); |
66cae7a6dc47
eliminate some macros for operator definitions
John W. Eaton <jwe@octave.org>
parents:
21301
diff
changeset
|
132 const octave_complex& v2 = dynamic_cast<const octave_complex&> (a2); |
2928 | 133 |
134 return v1.complex_value () != 0.0 || v2.complex_value () != 0.0; | |
135 } | |
136 | |
4915 | 137 DEFNDCATOP_FN (cs_cs, complex, complex, complex_array, complex_array, concat) |
138 | |
2928 | 139 void |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
140 install_cs_cs_ops (octave::type_info& ti) |
2928 | 141 { |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
142 INSTALL_UNOP_TI (ti, op_not, octave_complex, not); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
143 INSTALL_UNOP_TI (ti, op_uplus, octave_complex, uplus); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
144 INSTALL_UNOP_TI (ti, op_uminus, octave_complex, uminus); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
145 INSTALL_UNOP_TI (ti, op_transpose, octave_complex, transpose); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
146 INSTALL_UNOP_TI (ti, op_hermitian, octave_complex, hermitian); |
3203 | 147 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
148 INSTALL_NCUNOP_TI (ti, op_incr, octave_complex, incr); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
149 INSTALL_NCUNOP_TI (ti, op_decr, octave_complex, decr); |
3203 | 150 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
151 INSTALL_BINOP_TI (ti, op_add, octave_complex, octave_complex, add); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
152 INSTALL_BINOP_TI (ti, op_sub, octave_complex, octave_complex, sub); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
153 INSTALL_BINOP_TI (ti, op_mul, octave_complex, octave_complex, mul); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
154 INSTALL_BINOP_TI (ti, op_div, octave_complex, octave_complex, div); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
155 INSTALL_BINOP_TI (ti, op_pow, octave_complex, octave_complex, pow); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
156 INSTALL_BINOP_TI (ti, op_ldiv, octave_complex, octave_complex, ldiv); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
157 INSTALL_BINOP_TI (ti, op_lt, octave_complex, octave_complex, lt); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
158 INSTALL_BINOP_TI (ti, op_le, octave_complex, octave_complex, le); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
159 INSTALL_BINOP_TI (ti, op_eq, octave_complex, octave_complex, eq); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
160 INSTALL_BINOP_TI (ti, op_ge, octave_complex, octave_complex, ge); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
161 INSTALL_BINOP_TI (ti, op_gt, octave_complex, octave_complex, gt); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
162 INSTALL_BINOP_TI (ti, op_ne, octave_complex, octave_complex, ne); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
163 INSTALL_BINOP_TI (ti, op_el_mul, octave_complex, octave_complex, el_mul); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
164 INSTALL_BINOP_TI (ti, op_el_div, octave_complex, octave_complex, el_div); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
165 INSTALL_BINOP_TI (ti, op_el_pow, octave_complex, octave_complex, el_pow); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
166 INSTALL_BINOP_TI (ti, op_el_ldiv, octave_complex, octave_complex, el_ldiv); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
167 INSTALL_BINOP_TI (ti, op_el_and, octave_complex, octave_complex, el_and); |
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
168 INSTALL_BINOP_TI (ti, op_el_or, octave_complex, octave_complex, el_or); |
2928 | 169 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
170 INSTALL_CATOP_TI (ti, octave_complex, octave_complex, cs_cs); |
4915 | 171 |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
172 INSTALL_ASSIGNCONV_TI (ti, octave_complex, octave_complex, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
173 octave_complex_matrix); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
174 |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
175 INSTALL_ASSIGNCONV_TI (ti, octave_complex, octave_null_matrix, |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
176 octave_complex_matrix); |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
177 INSTALL_ASSIGNCONV_TI (ti, octave_complex, octave_null_str, |
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
178 octave_complex_matrix); |
24540
46440078d73b
don't use singleton for octave_value_typeinfo
John W. Eaton <jwe@octave.org>
parents:
24534
diff
changeset
|
179 INSTALL_ASSIGNCONV_TI (ti, octave_complex, octave_null_sq_str, |
25103
078b795c5219
maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents:
25054
diff
changeset
|
180 octave_complex_matrix); |
2928 | 181 } |