Mercurial > hg > octave-nkf
annotate src/OPERATORS/op-cs-cs.cc @ 8920:eb63fbe60fab
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 07 Mar 2009 10:41:27 -0500 |
parents | 283989f2da9b |
children | 19d298e6f7e5 |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2007, 2008 |
7017 | 4 John W. Eaton |
2928 | 5 |
6 This file is part of Octave. | |
7 | |
8 Octave is free software; you can redistribute it and/or modify it | |
9 under the terms of the GNU General Public License as published by the | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
2928 | 12 |
13 Octave is distributed in the hope that it will be useful, but WITHOUT | |
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
16 for more details. | |
17 | |
18 You should have received a copy of the GNU General Public License | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
2928 | 21 |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 #include <config.h> | |
26 #endif | |
27 | |
28 #include "gripes.h" | |
4055 | 29 #include "oct-obj.h" |
2928 | 30 #include "ov.h" |
31 #include "ov-complex.h" | |
32 #include "ov-cx-mat.h" | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
33 #include "ov-flt-cx-mat.h" |
2928 | 34 #include "ov-typeinfo.h" |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
35 #include "ov-null-mat.h" |
2928 | 36 #include "ops.h" |
37 #include "xdiv.h" | |
38 #include "xpow.h" | |
39 | |
3203 | 40 // unary complex scalar ops. |
41 | |
42 DEFUNOP (not, complex) | |
43 { | |
44 CAST_UNOP_ARG (const octave_complex&); | |
45 | |
46 return octave_value (v.complex_value () == 0.0); | |
47 } | |
48 | |
4965 | 49 DEFUNOP_OP (uplus, complex, /* no-op */) |
3203 | 50 DEFUNOP_OP (uminus, complex, -) |
51 DEFUNOP_OP (transpose, complex, /* no-op */) | |
52 | |
53 DEFUNOP (hermitian, complex) | |
54 { | |
55 CAST_UNOP_ARG (const octave_complex&); | |
56 | |
57 return octave_value (conj (v.complex_value ())); | |
58 } | |
59 | |
60 DEFNCUNOP_METHOD (incr, complex, increment) | |
61 DEFNCUNOP_METHOD (decr, complex, decrement) | |
62 | |
2928 | 63 // complex scalar by complex scalar ops. |
64 | |
65 DEFBINOP_OP (add, complex, complex, +) | |
66 DEFBINOP_OP (sub, complex, complex, -) | |
67 DEFBINOP_OP (mul, complex, complex, *) | |
68 | |
69 DEFBINOP (div, complex, complex) | |
70 { | |
71 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
72 | |
73 Complex d = v2.complex_value (); | |
74 | |
75 if (d == 0.0) | |
76 gripe_divide_by_zero (); | |
77 | |
78 return octave_value (v1.complex_value () / d); | |
79 } | |
80 | |
81 DEFBINOP_FN (pow, complex, complex, xpow) | |
82 | |
83 DEFBINOP (ldiv, complex, complex) | |
84 { | |
85 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
86 | |
87 Complex d = v1.complex_value (); | |
88 | |
89 if (d == 0.0) | |
90 gripe_divide_by_zero (); | |
91 | |
92 return octave_value (v2.complex_value () / d); | |
93 } | |
94 | |
95 DEFBINOP (lt, complex, complex) | |
96 { | |
97 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
98 | |
99 return real (v1.complex_value ()) < real (v2.complex_value ()); | |
100 } | |
101 | |
102 DEFBINOP (le, complex, complex) | |
103 { | |
104 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
105 | |
106 return real (v1.complex_value ()) <= real (v2.complex_value ()); | |
107 } | |
108 | |
109 DEFBINOP (eq, complex, complex) | |
110 { | |
111 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
112 | |
113 return v1.complex_value () == v2.complex_value (); | |
114 } | |
115 | |
116 DEFBINOP (ge, complex, complex) | |
117 { | |
118 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
119 | |
120 return real (v1.complex_value ()) >= real (v2.complex_value ()); | |
121 } | |
122 | |
123 DEFBINOP (gt, complex, complex) | |
124 { | |
125 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
126 | |
127 return real (v1.complex_value ()) > real (v2.complex_value ()); | |
128 } | |
129 | |
130 DEFBINOP (ne, complex, complex) | |
131 { | |
132 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
133 | |
134 return v1.complex_value () != v2.complex_value (); | |
135 } | |
136 | |
137 DEFBINOP_OP (el_mul, complex, complex, *) | |
138 | |
139 DEFBINOP (el_div, complex, complex) | |
140 { | |
141 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
142 | |
143 Complex d = v2.complex_value (); | |
144 | |
145 if (d == 0.0) | |
146 gripe_divide_by_zero (); | |
147 | |
148 return octave_value (v1.complex_value () / d); | |
149 } | |
150 | |
151 DEFBINOP_FN (el_pow, complex, complex, xpow) | |
152 | |
153 DEFBINOP (el_ldiv, complex, complex) | |
154 { | |
155 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
156 | |
157 Complex d = v1.complex_value (); | |
158 | |
159 if (d == 0.0) | |
160 gripe_divide_by_zero (); | |
161 | |
162 return octave_value (v2.complex_value () / d); | |
163 } | |
164 | |
165 DEFBINOP (el_and, complex, complex) | |
166 { | |
167 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
168 | |
169 return v1.complex_value () != 0.0 && v2.complex_value () != 0.0; | |
170 } | |
171 | |
172 DEFBINOP (el_or, complex, complex) | |
173 { | |
174 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
175 | |
176 return v1.complex_value () != 0.0 || v2.complex_value () != 0.0; | |
177 } | |
178 | |
4915 | 179 DEFNDCATOP_FN (cs_cs, complex, complex, complex_array, complex_array, concat) |
180 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
181 CONVDECL (complex_to_float_complex) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
182 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
183 CAST_CONV_ARG (const octave_complex&); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
184 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
185 return new octave_float_complex_matrix (FloatComplexMatrix (1, 1, static_cast<FloatComplex>(v.complex_value ()))); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
186 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
187 |
2928 | 188 void |
189 install_cs_cs_ops (void) | |
190 { | |
3538 | 191 INSTALL_UNOP (op_not, octave_complex, not); |
4965 | 192 INSTALL_UNOP (op_uplus, octave_complex, uplus); |
3538 | 193 INSTALL_UNOP (op_uminus, octave_complex, uminus); |
194 INSTALL_UNOP (op_transpose, octave_complex, transpose); | |
195 INSTALL_UNOP (op_hermitian, octave_complex, hermitian); | |
3203 | 196 |
3538 | 197 INSTALL_NCUNOP (op_incr, octave_complex, incr); |
198 INSTALL_NCUNOP (op_decr, octave_complex, decr); | |
3203 | 199 |
3538 | 200 INSTALL_BINOP (op_add, octave_complex, octave_complex, add); |
201 INSTALL_BINOP (op_sub, octave_complex, octave_complex, sub); | |
202 INSTALL_BINOP (op_mul, octave_complex, octave_complex, mul); | |
203 INSTALL_BINOP (op_div, octave_complex, octave_complex, div); | |
204 INSTALL_BINOP (op_pow, octave_complex, octave_complex, pow); | |
205 INSTALL_BINOP (op_ldiv, octave_complex, octave_complex, ldiv); | |
206 INSTALL_BINOP (op_lt, octave_complex, octave_complex, lt); | |
207 INSTALL_BINOP (op_le, octave_complex, octave_complex, le); | |
208 INSTALL_BINOP (op_eq, octave_complex, octave_complex, eq); | |
209 INSTALL_BINOP (op_ge, octave_complex, octave_complex, ge); | |
210 INSTALL_BINOP (op_gt, octave_complex, octave_complex, gt); | |
211 INSTALL_BINOP (op_ne, octave_complex, octave_complex, ne); | |
212 INSTALL_BINOP (op_el_mul, octave_complex, octave_complex, el_mul); | |
213 INSTALL_BINOP (op_el_div, octave_complex, octave_complex, el_div); | |
214 INSTALL_BINOP (op_el_pow, octave_complex, octave_complex, el_pow); | |
215 INSTALL_BINOP (op_el_ldiv, octave_complex, octave_complex, el_ldiv); | |
216 INSTALL_BINOP (op_el_and, octave_complex, octave_complex, el_and); | |
217 INSTALL_BINOP (op_el_or, octave_complex, octave_complex, el_or); | |
2928 | 218 |
4915 | 219 INSTALL_CATOP (octave_complex, octave_complex, cs_cs); |
220 | |
2928 | 221 INSTALL_ASSIGNCONV (octave_complex, octave_complex, octave_complex_matrix); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
222 |
8150
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
223 INSTALL_ASSIGNCONV (octave_complex, octave_null_matrix, octave_complex_matrix); |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
224 INSTALL_ASSIGNCONV (octave_complex, octave_null_str, octave_complex_matrix); |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
225 INSTALL_ASSIGNCONV (octave_complex, octave_null_sq_str, octave_complex_matrix); |
283989f2da9b
make null assignment matlab compatible
Jaroslav Hajek <highegg@gmail.com>
parents:
7789
diff
changeset
|
226 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
227 INSTALL_CONVOP (octave_complex, octave_float_complex_matrix, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
228 complex_to_float_complex); |
2928 | 229 } |
230 | |
231 /* | |
232 ;;; Local Variables: *** | |
233 ;;; mode: C++ *** | |
234 ;;; End: *** | |
235 */ |