Mercurial > hg > octave-lyh
annotate src/OPERATORS/op-s-cs.cc @ 8920:eb63fbe60fab
update copyright notices
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 07 Mar 2009 10:41:27 -0500 |
parents | 82be108cc558 |
children | 3ee9029931b3 |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1996, 1997, 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-scalar.h" | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
32 #include "ov-float.h" |
2928 | 33 #include "ov-complex.h" |
34 #include "ov-cx-mat.h" | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
35 #include "ov-flt-cx-mat.h" |
2928 | 36 #include "ov-typeinfo.h" |
37 #include "ops.h" | |
38 #include "xdiv.h" | |
39 #include "xpow.h" | |
40 | |
41 // scalar by complex scalar ops. | |
42 | |
43 DEFBINOP_OP (add, scalar, complex, +) | |
44 DEFBINOP_OP (sub, scalar, complex, -) | |
45 DEFBINOP_OP (mul, scalar, complex, *) | |
46 | |
47 DEFBINOP (div, scalar, complex) | |
48 { | |
49 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); | |
50 | |
51 Complex d = v2.complex_value (); | |
52 | |
53 if (d == 0.0) | |
54 gripe_divide_by_zero (); | |
55 | |
56 return octave_value (v1.double_value () / d); | |
57 } | |
58 | |
59 DEFBINOP_FN (pow, scalar, complex, xpow) | |
60 | |
61 DEFBINOP (ldiv, scalar, complex) | |
62 { | |
63 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); | |
64 | |
65 double d = v1.double_value (); | |
66 | |
67 if (d == 0.0) | |
68 gripe_divide_by_zero (); | |
69 | |
70 return octave_value (v2.complex_value () / d); | |
71 } | |
72 | |
73 DEFBINOP (lt, scalar, complex) | |
74 { | |
75 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); | |
76 | |
77 return v1.double_value () < real (v2.complex_value ()); | |
78 } | |
79 | |
80 DEFBINOP (le, scalar, complex) | |
81 { | |
82 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); | |
83 | |
84 return v1.double_value () <= real (v2.complex_value ()); | |
85 } | |
86 | |
87 DEFBINOP (eq, scalar, complex) | |
88 { | |
89 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); | |
90 | |
91 return v1.double_value () == v2.complex_value (); | |
92 } | |
93 | |
94 DEFBINOP (ge, scalar, complex) | |
95 { | |
96 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); | |
97 | |
98 return v1.double_value () >= real (v2.complex_value ()); | |
99 } | |
100 | |
101 DEFBINOP (gt, scalar, complex) | |
102 { | |
103 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); | |
104 | |
105 return v1.double_value () > real (v2.complex_value ()); | |
106 } | |
107 | |
108 DEFBINOP (ne, scalar, complex) | |
109 { | |
110 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); | |
111 | |
112 return v1.double_value () != v2.complex_value (); | |
113 } | |
114 | |
115 DEFBINOP_OP (el_mul, scalar, complex, *) | |
116 | |
117 DEFBINOP (el_div, scalar, complex) | |
118 { | |
119 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); | |
120 | |
121 Complex d = v2.complex_value (); | |
122 | |
123 if (d == 0.0) | |
124 gripe_divide_by_zero (); | |
125 | |
126 return octave_value (v1.double_value () / d); | |
127 } | |
128 | |
129 DEFBINOP_FN (el_pow, scalar, complex, xpow) | |
130 | |
131 DEFBINOP (el_ldiv, scalar, complex) | |
132 { | |
133 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); | |
134 | |
135 double d = v1.double_value (); | |
136 | |
137 if (d == 0.0) | |
138 gripe_divide_by_zero (); | |
139 | |
140 return octave_value (v2.complex_value () / d); | |
141 } | |
142 | |
143 DEFBINOP (el_and, scalar, complex) | |
144 { | |
145 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); | |
146 | |
147 return octave_value (v1.double_value () && (v2.complex_value () != 0.0)); | |
148 } | |
149 | |
150 DEFBINOP (el_or, scalar, complex) | |
151 { | |
152 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex&); | |
153 | |
154 return octave_value (v1.double_value () || (v2.complex_value () != 0.0)); | |
155 } | |
156 | |
4915 | 157 DEFNDCATOP_FN (s_cs, scalar, complex, array, complex_array, concat) |
158 | |
2928 | 159 void |
160 install_s_cs_ops (void) | |
161 { | |
3538 | 162 INSTALL_BINOP (op_add, octave_scalar, octave_complex, add); |
163 INSTALL_BINOP (op_sub, octave_scalar, octave_complex, sub); | |
164 INSTALL_BINOP (op_mul, octave_scalar, octave_complex, mul); | |
165 INSTALL_BINOP (op_div, octave_scalar, octave_complex, div); | |
166 INSTALL_BINOP (op_pow, octave_scalar, octave_complex, pow); | |
167 INSTALL_BINOP (op_ldiv, octave_scalar, octave_complex, ldiv); | |
168 INSTALL_BINOP (op_lt, octave_scalar, octave_complex, lt); | |
169 INSTALL_BINOP (op_le, octave_scalar, octave_complex, le); | |
170 INSTALL_BINOP (op_eq, octave_scalar, octave_complex, eq); | |
171 INSTALL_BINOP (op_ge, octave_scalar, octave_complex, ge); | |
172 INSTALL_BINOP (op_gt, octave_scalar, octave_complex, gt); | |
173 INSTALL_BINOP (op_ne, octave_scalar, octave_complex, ne); | |
174 INSTALL_BINOP (op_el_mul, octave_scalar, octave_complex, el_mul); | |
175 INSTALL_BINOP (op_el_div, octave_scalar, octave_complex, el_div); | |
176 INSTALL_BINOP (op_el_pow, octave_scalar, octave_complex, el_pow); | |
177 INSTALL_BINOP (op_el_ldiv, octave_scalar, octave_complex, el_ldiv); | |
178 INSTALL_BINOP (op_el_and, octave_scalar, octave_complex, el_and); | |
179 INSTALL_BINOP (op_el_or, octave_scalar, octave_complex, el_or); | |
2928 | 180 |
4915 | 181 INSTALL_CATOP (octave_scalar, octave_complex, s_cs); |
182 | |
2928 | 183 INSTALL_ASSIGNCONV (octave_scalar, octave_complex, octave_complex_matrix); |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
184 INSTALL_ASSIGNCONV (octave_float_scalar, octave_complex, octave_float_complex_matrix); |
2928 | 185 } |
186 | |
187 /* | |
188 ;;; Local Variables: *** | |
189 ;;; mode: C++ *** | |
190 ;;; End: *** | |
191 */ |