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 "mx-s-cm.h"
00028 #include "mx-cm-s.h"
00029 #include "mx-s-cnda.h"
00030 #include "mx-cnda-s.h"
00031
00032 #include "gripes.h"
00033 #include "oct-obj.h"
00034 #include "ov.h"
00035 #include "ov-scalar.h"
00036 #include "ov-float.h"
00037 #include "ov-cx-mat.h"
00038 #include "ov-flt-cx-mat.h"
00039 #include "ov-re-mat.h"
00040 #include "ov-typeinfo.h"
00041 #include "ops.h"
00042 #include "xdiv.h"
00043 #include "xpow.h"
00044
00045
00046
00047 DEFNDBINOP_OP (add, scalar, complex_matrix, scalar, complex_array, +)
00048 DEFNDBINOP_OP (sub, scalar, complex_matrix, scalar, complex_array, -)
00049 DEFNDBINOP_OP (mul, scalar, complex_matrix, scalar, complex_array, *)
00050
00051 DEFBINOP (div, scalar, complex_matrix)
00052 {
00053 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&);
00054
00055 Matrix m1 = v1.matrix_value ();
00056 ComplexMatrix m2 = v2.complex_matrix_value ();
00057 MatrixType typ = v2.matrix_type ();
00058
00059 ComplexMatrix ret = xdiv (m1, m2, typ);
00060
00061 v2.matrix_type (typ);
00062 return ret;
00063 }
00064
00065 DEFBINOP_FN (pow, scalar, complex_matrix, xpow)
00066
00067 DEFBINOP (ldiv, scalar, complex_matrix)
00068 {
00069 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&);
00070
00071 double d = v1.double_value ();
00072
00073 if (d == 0.0)
00074 gripe_divide_by_zero ();
00075
00076 return octave_value (v2.complex_array_value () / d);
00077 }
00078
00079 DEFNDCMPLXCMPOP_FN (lt, scalar, complex_matrix, scalar, complex_array, mx_el_lt)
00080 DEFNDCMPLXCMPOP_FN (le, scalar, complex_matrix, scalar, complex_array, mx_el_le)
00081 DEFNDCMPLXCMPOP_FN (eq, scalar, complex_matrix, scalar, complex_array, mx_el_eq)
00082 DEFNDCMPLXCMPOP_FN (ge, scalar, complex_matrix, scalar, complex_array, mx_el_ge)
00083 DEFNDCMPLXCMPOP_FN (gt, scalar, complex_matrix, scalar, complex_array, mx_el_gt)
00084 DEFNDCMPLXCMPOP_FN (ne, scalar, complex_matrix, scalar, complex_array, mx_el_ne)
00085
00086 DEFNDBINOP_OP (el_mul, scalar, complex_matrix, scalar, complex_array, *)
00087 DEFNDBINOP_FN (el_div, scalar, complex_matrix, scalar, complex_array, x_el_div)
00088 DEFNDBINOP_FN (el_pow, scalar, complex_matrix, scalar, complex_array, elem_xpow)
00089
00090 DEFBINOP (el_ldiv, scalar, complex_matrix)
00091 {
00092 CAST_BINOP_ARGS (const octave_scalar&, const octave_complex_matrix&);
00093
00094 double d = v1.double_value ();
00095
00096 if (d == 0.0)
00097 gripe_divide_by_zero ();
00098
00099 return octave_value (v2.complex_array_value () / d);
00100 }
00101
00102 DEFNDBINOP_FN (el_and, scalar, complex_matrix, scalar, complex_array, mx_el_and)
00103 DEFNDBINOP_FN (el_or, scalar, complex_matrix, scalar, complex_array, mx_el_or)
00104
00105 DEFNDCATOP_FN (s_cm, scalar, complex_matrix, array, complex_array, concat)
00106
00107 DEFCONV (complex_matrix_conv, scalar, complex_matrix)
00108 {
00109 CAST_CONV_ARG (const octave_scalar&);
00110
00111 return new octave_complex_matrix (ComplexMatrix (v.matrix_value ()));
00112 }
00113
00114 void
00115 install_s_cm_ops (void)
00116 {
00117 INSTALL_BINOP (op_add, octave_scalar, octave_complex_matrix, add);
00118 INSTALL_BINOP (op_sub, octave_scalar, octave_complex_matrix, sub);
00119 INSTALL_BINOP (op_mul, octave_scalar, octave_complex_matrix, mul);
00120 INSTALL_BINOP (op_div, octave_scalar, octave_complex_matrix, div);
00121 INSTALL_BINOP (op_pow, octave_scalar, octave_complex_matrix, pow);
00122 INSTALL_BINOP (op_ldiv, octave_scalar, octave_complex_matrix, ldiv);
00123 INSTALL_BINOP (op_lt, octave_scalar, octave_complex_matrix, lt);
00124 INSTALL_BINOP (op_le, octave_scalar, octave_complex_matrix, le);
00125 INSTALL_BINOP (op_eq, octave_scalar, octave_complex_matrix, eq);
00126 INSTALL_BINOP (op_ge, octave_scalar, octave_complex_matrix, ge);
00127 INSTALL_BINOP (op_gt, octave_scalar, octave_complex_matrix, gt);
00128 INSTALL_BINOP (op_ne, octave_scalar, octave_complex_matrix, ne);
00129 INSTALL_BINOP (op_el_mul, octave_scalar, octave_complex_matrix, el_mul);
00130 INSTALL_BINOP (op_el_div, octave_scalar, octave_complex_matrix, el_div);
00131 INSTALL_BINOP (op_el_pow, octave_scalar, octave_complex_matrix, el_pow);
00132 INSTALL_BINOP (op_el_ldiv, octave_scalar, octave_complex_matrix, el_ldiv);
00133 INSTALL_BINOP (op_el_and, octave_scalar, octave_complex_matrix, el_and);
00134 INSTALL_BINOP (op_el_or, octave_scalar, octave_complex_matrix, el_or);
00135
00136 INSTALL_CATOP (octave_scalar, octave_complex_matrix, s_cm);
00137
00138 INSTALL_ASSIGNCONV (octave_scalar, octave_complex_matrix, octave_complex_matrix);
00139 INSTALL_ASSIGNCONV (octave_float_scalar, octave_complex_matrix, octave_float_complex_matrix);
00140
00141 INSTALL_WIDENOP (octave_scalar, octave_complex_matrix, complex_matrix_conv);
00142 }