Mercurial > hg > octave-nkf
annotate src/OPERATORS/op-cs-cs.cc @ 7789:82be108cc558
First attempt at single precision tyeps
* * *
corrections to qrupdate single precision routines
* * *
prefer demotion to single over promotion to double
* * *
Add single precision support to log2 function
* * *
Trivial PROJECT file update
* * *
Cache optimized hermitian/transpose methods
* * *
Add tests for tranpose/hermitian and ChangeLog entry for new transpose code
author | David Bateman <dbateman@free.fr> |
---|---|
date | Sun, 27 Apr 2008 22:34:17 +0200 |
parents | a1dbe9d80eee |
children | 283989f2da9b |
rev | line source |
---|---|
2928 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 1998, 2000, 2002, 2003, 2004, 2005, 2007 |
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" |
35 #include "ops.h" | |
36 #include "xdiv.h" | |
37 #include "xpow.h" | |
38 | |
3203 | 39 // unary complex scalar ops. |
40 | |
41 DEFUNOP (not, complex) | |
42 { | |
43 CAST_UNOP_ARG (const octave_complex&); | |
44 | |
45 return octave_value (v.complex_value () == 0.0); | |
46 } | |
47 | |
4965 | 48 DEFUNOP_OP (uplus, complex, /* no-op */) |
3203 | 49 DEFUNOP_OP (uminus, complex, -) |
50 DEFUNOP_OP (transpose, complex, /* no-op */) | |
51 | |
52 DEFUNOP (hermitian, complex) | |
53 { | |
54 CAST_UNOP_ARG (const octave_complex&); | |
55 | |
56 return octave_value (conj (v.complex_value ())); | |
57 } | |
58 | |
59 DEFNCUNOP_METHOD (incr, complex, increment) | |
60 DEFNCUNOP_METHOD (decr, complex, decrement) | |
61 | |
2928 | 62 // complex scalar by complex scalar ops. |
63 | |
64 DEFBINOP_OP (add, complex, complex, +) | |
65 DEFBINOP_OP (sub, complex, complex, -) | |
66 DEFBINOP_OP (mul, complex, complex, *) | |
67 | |
68 DEFBINOP (div, complex, complex) | |
69 { | |
70 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
71 | |
72 Complex d = v2.complex_value (); | |
73 | |
74 if (d == 0.0) | |
75 gripe_divide_by_zero (); | |
76 | |
77 return octave_value (v1.complex_value () / d); | |
78 } | |
79 | |
80 DEFBINOP_FN (pow, complex, complex, xpow) | |
81 | |
82 DEFBINOP (ldiv, complex, complex) | |
83 { | |
84 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
85 | |
86 Complex d = v1.complex_value (); | |
87 | |
88 if (d == 0.0) | |
89 gripe_divide_by_zero (); | |
90 | |
91 return octave_value (v2.complex_value () / d); | |
92 } | |
93 | |
94 DEFBINOP (lt, complex, complex) | |
95 { | |
96 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
97 | |
98 return real (v1.complex_value ()) < real (v2.complex_value ()); | |
99 } | |
100 | |
101 DEFBINOP (le, complex, complex) | |
102 { | |
103 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
104 | |
105 return real (v1.complex_value ()) <= real (v2.complex_value ()); | |
106 } | |
107 | |
108 DEFBINOP (eq, complex, complex) | |
109 { | |
110 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
111 | |
112 return v1.complex_value () == v2.complex_value (); | |
113 } | |
114 | |
115 DEFBINOP (ge, complex, complex) | |
116 { | |
117 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
118 | |
119 return real (v1.complex_value ()) >= real (v2.complex_value ()); | |
120 } | |
121 | |
122 DEFBINOP (gt, complex, complex) | |
123 { | |
124 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
125 | |
126 return real (v1.complex_value ()) > real (v2.complex_value ()); | |
127 } | |
128 | |
129 DEFBINOP (ne, complex, complex) | |
130 { | |
131 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
132 | |
133 return v1.complex_value () != v2.complex_value (); | |
134 } | |
135 | |
136 DEFBINOP_OP (el_mul, complex, complex, *) | |
137 | |
138 DEFBINOP (el_div, complex, complex) | |
139 { | |
140 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
141 | |
142 Complex d = v2.complex_value (); | |
143 | |
144 if (d == 0.0) | |
145 gripe_divide_by_zero (); | |
146 | |
147 return octave_value (v1.complex_value () / d); | |
148 } | |
149 | |
150 DEFBINOP_FN (el_pow, complex, complex, xpow) | |
151 | |
152 DEFBINOP (el_ldiv, complex, complex) | |
153 { | |
154 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
155 | |
156 Complex d = v1.complex_value (); | |
157 | |
158 if (d == 0.0) | |
159 gripe_divide_by_zero (); | |
160 | |
161 return octave_value (v2.complex_value () / d); | |
162 } | |
163 | |
164 DEFBINOP (el_and, complex, complex) | |
165 { | |
166 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
167 | |
168 return v1.complex_value () != 0.0 && v2.complex_value () != 0.0; | |
169 } | |
170 | |
171 DEFBINOP (el_or, complex, complex) | |
172 { | |
173 CAST_BINOP_ARGS (const octave_complex&, const octave_complex&); | |
174 | |
175 return v1.complex_value () != 0.0 || v2.complex_value () != 0.0; | |
176 } | |
177 | |
4915 | 178 DEFNDCATOP_FN (cs_cs, complex, complex, complex_array, complex_array, concat) |
179 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
180 CONVDECL (complex_to_float_complex) |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
181 { |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
182 CAST_CONV_ARG (const octave_complex&); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
183 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
184 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
|
185 } |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
186 |
2928 | 187 void |
188 install_cs_cs_ops (void) | |
189 { | |
3538 | 190 INSTALL_UNOP (op_not, octave_complex, not); |
4965 | 191 INSTALL_UNOP (op_uplus, octave_complex, uplus); |
3538 | 192 INSTALL_UNOP (op_uminus, octave_complex, uminus); |
193 INSTALL_UNOP (op_transpose, octave_complex, transpose); | |
194 INSTALL_UNOP (op_hermitian, octave_complex, hermitian); | |
3203 | 195 |
3538 | 196 INSTALL_NCUNOP (op_incr, octave_complex, incr); |
197 INSTALL_NCUNOP (op_decr, octave_complex, decr); | |
3203 | 198 |
3538 | 199 INSTALL_BINOP (op_add, octave_complex, octave_complex, add); |
200 INSTALL_BINOP (op_sub, octave_complex, octave_complex, sub); | |
201 INSTALL_BINOP (op_mul, octave_complex, octave_complex, mul); | |
202 INSTALL_BINOP (op_div, octave_complex, octave_complex, div); | |
203 INSTALL_BINOP (op_pow, octave_complex, octave_complex, pow); | |
204 INSTALL_BINOP (op_ldiv, octave_complex, octave_complex, ldiv); | |
205 INSTALL_BINOP (op_lt, octave_complex, octave_complex, lt); | |
206 INSTALL_BINOP (op_le, octave_complex, octave_complex, le); | |
207 INSTALL_BINOP (op_eq, octave_complex, octave_complex, eq); | |
208 INSTALL_BINOP (op_ge, octave_complex, octave_complex, ge); | |
209 INSTALL_BINOP (op_gt, octave_complex, octave_complex, gt); | |
210 INSTALL_BINOP (op_ne, octave_complex, octave_complex, ne); | |
211 INSTALL_BINOP (op_el_mul, octave_complex, octave_complex, el_mul); | |
212 INSTALL_BINOP (op_el_div, octave_complex, octave_complex, el_div); | |
213 INSTALL_BINOP (op_el_pow, octave_complex, octave_complex, el_pow); | |
214 INSTALL_BINOP (op_el_ldiv, octave_complex, octave_complex, el_ldiv); | |
215 INSTALL_BINOP (op_el_and, octave_complex, octave_complex, el_and); | |
216 INSTALL_BINOP (op_el_or, octave_complex, octave_complex, el_or); | |
2928 | 217 |
4915 | 218 INSTALL_CATOP (octave_complex, octave_complex, cs_cs); |
219 | |
2928 | 220 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
|
221 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
222 INSTALL_CONVOP (octave_complex, octave_float_complex_matrix, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
223 complex_to_float_complex); |
2928 | 224 } |
225 | |
226 /* | |
227 ;;; Local Variables: *** | |
228 ;;; mode: C++ *** | |
229 ;;; End: *** | |
230 */ |