00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026
00027 #include "gripes.h"
00028 #include "oct-obj.h"
00029 #include "ov.h"
00030 #include "ov-complex.h"
00031 #include "ov-flt-complex.h"
00032 #include "ov-flt-cx-mat.h"
00033 #include "ov-typeinfo.h"
00034 #include "ov-null-mat.h"
00035 #include "ops.h"
00036 #include "xdiv.h"
00037 #include "xpow.h"
00038
00039
00040
00041 DEFUNOP (not, float_complex)
00042 {
00043 CAST_UNOP_ARG (const octave_float_complex&);
00044 FloatComplex x = v.float_complex_value ();
00045 if (xisnan (x))
00046 gripe_nan_to_logical_conversion ();
00047 return octave_value (x == 0.0f);
00048 }
00049
00050 DEFUNOP_OP (uplus, float_complex, )
00051 DEFUNOP_OP (uminus, float_complex, -)
00052 DEFUNOP_OP (transpose, float_complex, )
00053
00054 DEFUNOP (hermitian, float_complex)
00055 {
00056 CAST_UNOP_ARG (const octave_float_complex&);
00057
00058 return octave_value (conj (v.float_complex_value ()));
00059 }
00060
00061 DEFNCUNOP_METHOD (incr, float_complex, increment)
00062 DEFNCUNOP_METHOD (decr, float_complex, decrement)
00063
00064
00065
00066 DEFBINOP_OP (add, float_complex, float_complex, +)
00067 DEFBINOP_OP (sub, float_complex, float_complex, -)
00068 DEFBINOP_OP (mul, float_complex, float_complex, *)
00069
00070 DEFBINOP (div, float_complex, float_complex)
00071 {
00072 CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_complex&);
00073
00074 FloatComplex d = v2.float_complex_value ();
00075
00076 if (d == static_cast<float>(0.0))
00077 gripe_divide_by_zero ();
00078
00079 return octave_value (v1.float_complex_value () / d);
00080 }
00081
00082 DEFBINOP_FN (pow, float_complex, float_complex, xpow)
00083
00084 DEFBINOP (ldiv, float_complex, float_complex)
00085 {
00086 CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_complex&);
00087
00088 FloatComplex d = v1.float_complex_value ();
00089
00090 if (d == static_cast<float>(0.0))
00091 gripe_divide_by_zero ();
00092
00093 return octave_value (v2.float_complex_value () / d);
00094 }
00095
00096 DEFCMPLXCMPOP_OP (lt, float_complex, float_complex, <)
00097 DEFCMPLXCMPOP_OP (le, float_complex, float_complex, <=)
00098 DEFCMPLXCMPOP_OP (eq, float_complex, float_complex, ==)
00099 DEFCMPLXCMPOP_OP (ge, float_complex, float_complex, >=)
00100 DEFCMPLXCMPOP_OP (gt, float_complex, float_complex, >)
00101 DEFCMPLXCMPOP_OP (ne, float_complex, float_complex, !=)
00102
00103 DEFBINOP_OP (el_mul, float_complex, float_complex, *)
00104
00105 DEFBINOP (el_div, float_complex, float_complex)
00106 {
00107 CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_complex&);
00108
00109 FloatComplex d = v2.float_complex_value ();
00110
00111 if (d == static_cast<float>(0.0))
00112 gripe_divide_by_zero ();
00113
00114 return octave_value (v1.float_complex_value () / d);
00115 }
00116
00117 DEFBINOP_FN (el_pow, float_complex, float_complex, xpow)
00118
00119 DEFBINOP (el_ldiv, float_complex, float_complex)
00120 {
00121 CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_complex&);
00122
00123 FloatComplex d = v1.float_complex_value ();
00124
00125 if (d == static_cast<float>(0.0))
00126 gripe_divide_by_zero ();
00127
00128 return octave_value (v2.float_complex_value () / d);
00129 }
00130
00131 DEFBINOP (el_and, float_complex, float_complex)
00132 {
00133 CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_complex&);
00134
00135 return (v1.float_complex_value () != static_cast<float>(0.0) &&
00136 v2.float_complex_value () != static_cast<float>(0.0));
00137 }
00138
00139 DEFBINOP (el_or, float_complex, float_complex)
00140 {
00141 CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_complex&);
00142
00143 return (v1.float_complex_value () != static_cast<float>(0.0) ||
00144 v2.float_complex_value () != static_cast<float>(0.0));
00145 }
00146
00147 DEFNDCATOP_FN (fcs_fcs, float_complex, float_complex, float_complex_array,
00148 float_complex_array, concat)
00149
00150 DEFNDCATOP_FN (cs_fcs, complex, float_complex, float_complex_array,
00151 float_complex_array, concat)
00152
00153 DEFNDCATOP_FN (fcs_cs, float_complex, complex, float_complex_array,
00154 float_complex_array, concat)
00155
00156 CONVDECL (float_complex_to_complex)
00157 {
00158 CAST_CONV_ARG (const octave_float_complex&);
00159
00160 return new octave_complex_matrix (ComplexMatrix (1, 1, static_cast<Complex>(v.float_complex_value ())));
00161 }
00162
00163 void
00164 install_fcs_fcs_ops (void)
00165 {
00166 INSTALL_UNOP (op_not, octave_float_complex, not);
00167 INSTALL_UNOP (op_uplus, octave_float_complex, uplus);
00168 INSTALL_UNOP (op_uminus, octave_float_complex, uminus);
00169 INSTALL_UNOP (op_transpose, octave_float_complex, transpose);
00170 INSTALL_UNOP (op_hermitian, octave_float_complex, hermitian);
00171
00172 INSTALL_NCUNOP (op_incr, octave_float_complex, incr);
00173 INSTALL_NCUNOP (op_decr, octave_float_complex, decr);
00174
00175 INSTALL_BINOP (op_add, octave_float_complex, octave_float_complex, add);
00176 INSTALL_BINOP (op_sub, octave_float_complex, octave_float_complex, sub);
00177 INSTALL_BINOP (op_mul, octave_float_complex, octave_float_complex, mul);
00178 INSTALL_BINOP (op_div, octave_float_complex, octave_float_complex, div);
00179 INSTALL_BINOP (op_pow, octave_float_complex, octave_float_complex, pow);
00180 INSTALL_BINOP (op_ldiv, octave_float_complex, octave_float_complex, ldiv);
00181 INSTALL_BINOP (op_lt, octave_float_complex, octave_float_complex, lt);
00182 INSTALL_BINOP (op_le, octave_float_complex, octave_float_complex, le);
00183 INSTALL_BINOP (op_eq, octave_float_complex, octave_float_complex, eq);
00184 INSTALL_BINOP (op_ge, octave_float_complex, octave_float_complex, ge);
00185 INSTALL_BINOP (op_gt, octave_float_complex, octave_float_complex, gt);
00186 INSTALL_BINOP (op_ne, octave_float_complex, octave_float_complex, ne);
00187 INSTALL_BINOP (op_el_mul, octave_float_complex, octave_float_complex, el_mul);
00188 INSTALL_BINOP (op_el_div, octave_float_complex, octave_float_complex, el_div);
00189 INSTALL_BINOP (op_el_pow, octave_float_complex, octave_float_complex, el_pow);
00190 INSTALL_BINOP (op_el_ldiv, octave_float_complex, octave_float_complex, el_ldiv);
00191 INSTALL_BINOP (op_el_and, octave_float_complex, octave_float_complex, el_and);
00192 INSTALL_BINOP (op_el_or, octave_float_complex, octave_float_complex, el_or);
00193
00194 INSTALL_CATOP (octave_float_complex, octave_float_complex, fcs_fcs);
00195 INSTALL_CATOP (octave_complex, octave_float_complex, cs_fcs);
00196 INSTALL_CATOP (octave_float_complex, octave_complex, fcs_cs);
00197
00198 INSTALL_ASSIGNCONV (octave_float_complex, octave_float_complex, octave_float_complex_matrix);
00199
00200 INSTALL_ASSIGNCONV (octave_complex, octave_float_complex, octave_complex_matrix);
00201
00202 INSTALL_ASSIGNCONV (octave_float_complex, octave_null_matrix, octave_float_complex_matrix);
00203 INSTALL_ASSIGNCONV (octave_float_complex, octave_null_str, octave_float_complex_matrix);
00204 INSTALL_ASSIGNCONV (octave_float_complex, octave_null_sq_str, octave_float_complex_matrix);
00205
00206 INSTALL_CONVOP (octave_float_complex, octave_complex_matrix,
00207 float_complex_to_complex);
00208 }