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-cx-mat.h"
00033 #include "ov-flt-cx-mat.h"
00034 #include "ov-float.h"
00035 #include "ov-scalar.h"
00036 #include "ov-typeinfo.h"
00037 #include "ops.h"
00038 #include "xdiv.h"
00039 #include "xpow.h"
00040
00041
00042
00043 DEFBINOP_OP (add, float_complex, float_scalar, +)
00044 DEFBINOP_OP (sub, float_complex, float_scalar, -)
00045 DEFBINOP_OP (mul, float_complex, float_scalar, *)
00046
00047 DEFBINOP (div, float_complex, float)
00048 {
00049 CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_scalar&);
00050
00051 float d = v2.float_value ();
00052
00053 if (d == 0.0)
00054 gripe_divide_by_zero ();
00055
00056 return octave_value (v1.float_complex_value () / d);
00057 }
00058
00059 DEFBINOP_FN (pow, float_complex, float_scalar, xpow)
00060
00061 DEFBINOP (ldiv, float_complex, float)
00062 {
00063 CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_scalar&);
00064
00065 FloatComplex d = v1.float_complex_value ();
00066
00067 if (d == static_cast<float>(0.0))
00068 gripe_divide_by_zero ();
00069
00070 return octave_value (v2.float_value () / d);
00071 }
00072
00073 DEFCMPLXCMPOP_OP (lt, float_complex, float_scalar, <)
00074 DEFCMPLXCMPOP_OP (le, float_complex, float_scalar, <=)
00075 DEFCMPLXCMPOP_OP (eq, float_complex, float_scalar, ==)
00076 DEFCMPLXCMPOP_OP (ge, float_complex, float_scalar, >=)
00077 DEFCMPLXCMPOP_OP (gt, float_complex, float_scalar, >)
00078 DEFCMPLXCMPOP_OP (ne, float_complex, float_scalar, !=)
00079
00080 DEFBINOP_OP (el_mul, float_complex, float_scalar, *)
00081
00082 DEFBINOP (el_div, float_complex, float)
00083 {
00084 CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_scalar&);
00085
00086 float d = v2.float_value ();
00087
00088 if (d == 0.0)
00089 gripe_divide_by_zero ();
00090
00091 return octave_value (v1.float_complex_value () / d);
00092 }
00093
00094 DEFBINOP_FN (el_pow, float_complex, float_scalar, xpow)
00095
00096 DEFBINOP (el_ldiv, float_complex, float)
00097 {
00098 CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_scalar&);
00099
00100 FloatComplex d = v1.float_complex_value ();
00101
00102 if (d == static_cast<float>(0.0))
00103 gripe_divide_by_zero ();
00104
00105 return octave_value (v2.float_value () / d);
00106 }
00107
00108 DEFBINOP (el_and, float_complex, float)
00109 {
00110 CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_scalar&);
00111
00112 return (v1.float_complex_value () != static_cast<float>(0.0) &&
00113 v2.float_value ());
00114 }
00115
00116 DEFBINOP (el_or, float_complex, float)
00117 {
00118 CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_scalar&);
00119
00120 return (v1.float_complex_value () != static_cast<float>(0.0) ||
00121 v2.float_value ());
00122 }
00123
00124 DEFNDCATOP_FN (fcs_fs, float_complex, float_scalar, float_complex_array,
00125 float_array, concat)
00126
00127 DEFNDCATOP_FN (cs_fs, complex, float_scalar, float_complex_array,
00128 float_array, concat)
00129
00130 DEFNDCATOP_FN (fcs_s, float_complex, scalar, float_complex_array,
00131 float_array, concat)
00132
00133 void
00134 install_fcs_fs_ops (void)
00135 {
00136 INSTALL_BINOP (op_add, octave_float_complex, octave_float_scalar, add);
00137 INSTALL_BINOP (op_sub, octave_float_complex, octave_float_scalar, sub);
00138 INSTALL_BINOP (op_mul, octave_float_complex, octave_float_scalar, mul);
00139 INSTALL_BINOP (op_div, octave_float_complex, octave_float_scalar, div);
00140 INSTALL_BINOP (op_pow, octave_float_complex, octave_float_scalar, pow);
00141 INSTALL_BINOP (op_ldiv, octave_float_complex, octave_float_scalar, ldiv);
00142 INSTALL_BINOP (op_lt, octave_float_complex, octave_float_scalar, lt);
00143 INSTALL_BINOP (op_le, octave_float_complex, octave_float_scalar, le);
00144 INSTALL_BINOP (op_eq, octave_float_complex, octave_float_scalar, eq);
00145 INSTALL_BINOP (op_ge, octave_float_complex, octave_float_scalar, ge);
00146 INSTALL_BINOP (op_gt, octave_float_complex, octave_float_scalar, gt);
00147 INSTALL_BINOP (op_ne, octave_float_complex, octave_float_scalar, ne);
00148 INSTALL_BINOP (op_el_mul, octave_float_complex, octave_float_scalar, el_mul);
00149 INSTALL_BINOP (op_el_div, octave_float_complex, octave_float_scalar, el_div);
00150 INSTALL_BINOP (op_el_pow, octave_float_complex, octave_float_scalar, el_pow);
00151 INSTALL_BINOP (op_el_ldiv, octave_float_complex, octave_float_scalar, el_ldiv);
00152 INSTALL_BINOP (op_el_and, octave_float_complex, octave_float_scalar, el_and);
00153 INSTALL_BINOP (op_el_or, octave_float_complex, octave_float_scalar, el_or);
00154
00155 INSTALL_CATOP (octave_float_complex, octave_float_scalar, fcs_fs);
00156 INSTALL_CATOP (octave_complex, octave_float_scalar, cs_fs);
00157 INSTALL_CATOP (octave_float_complex, octave_scalar, fcs_s);
00158
00159 INSTALL_ASSIGNCONV (octave_float_complex, octave_float_scalar,
00160 octave_float_complex_matrix);
00161 INSTALL_ASSIGNCONV (octave_complex, octave_float_scalar,
00162 octave_complex_matrix);
00163 }