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-m-cm.h"
00028 #include "mx-cm-m.h"
00029 #include "mx-nda-cnda.h"
00030 #include "mx-cnda-nda.h"
00031
00032 #include "gripes.h"
00033 #include "oct-obj.h"
00034 #include "ov.h"
00035 #include "ov-re-mat.h"
00036 #include "ov-flt-re-mat.h"
00037 #include "ov-cx-mat.h"
00038 #include "ov-flt-cx-mat.h"
00039 #include "ov-typeinfo.h"
00040 #include "ops.h"
00041 #include "xdiv.h"
00042 #include "xpow.h"
00043
00044
00045
00046 DEFNDBINOP_OP (add, matrix, complex_matrix, array, complex_array, +)
00047 DEFNDBINOP_OP (sub, matrix, complex_matrix, array, complex_array, -)
00048
00049 DEFBINOP_OP (mul, matrix, complex_matrix, *)
00050
00051 DEFBINOP (trans_mul, matrix, complex_matrix)
00052 {
00053 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&);
00054
00055 Matrix m1 = v1.matrix_value ();
00056 ComplexMatrix m2 = v2.complex_matrix_value ();
00057
00058 return ComplexMatrix (xgemm (m1, real (m2), blas_trans, blas_no_trans),
00059 xgemm (m1, imag (m2), blas_trans, blas_no_trans));
00060 }
00061
00062 DEFBINOP (div, matrix, complex_matrix)
00063 {
00064 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&);
00065 MatrixType typ = v2.matrix_type ();
00066
00067 ComplexMatrix ret = xdiv (v1.matrix_value (),
00068 v2.complex_matrix_value (), typ);
00069
00070 v2.matrix_type (typ);
00071 return ret;
00072 }
00073
00074 DEFBINOPX (pow, matrix, complex_matrix)
00075 {
00076 error ("can't do A ^ B for A and B both matrices");
00077 return octave_value ();
00078 }
00079
00080 DEFBINOP (ldiv, matrix, complex_matrix)
00081 {
00082 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&);
00083 MatrixType typ = v1.matrix_type ();
00084
00085 ComplexMatrix ret = xleftdiv (v1.matrix_value (),
00086 v2.complex_matrix_value (), typ);
00087
00088 v1.matrix_type (typ);
00089 return ret;
00090 }
00091
00092 DEFBINOP (trans_ldiv, matrix, complex_matrix)
00093 {
00094 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&);
00095 MatrixType typ = v1.matrix_type ();
00096
00097 ComplexMatrix ret = xleftdiv (v1.matrix_value (),
00098 v2.complex_matrix_value (), typ, blas_trans);
00099
00100 v1.matrix_type (typ);
00101 return ret;
00102 }
00103
00104 DEFNDCMPLXCMPOP_FN (lt, matrix, complex_matrix, array, complex_array, mx_el_lt)
00105 DEFNDCMPLXCMPOP_FN (le, matrix, complex_matrix, array, complex_array, mx_el_le)
00106 DEFNDCMPLXCMPOP_FN (eq, matrix, complex_matrix, array, complex_array, mx_el_eq)
00107 DEFNDCMPLXCMPOP_FN (ge, matrix, complex_matrix, array, complex_array, mx_el_ge)
00108 DEFNDCMPLXCMPOP_FN (gt, matrix, complex_matrix, array, complex_array, mx_el_gt)
00109 DEFNDCMPLXCMPOP_FN (ne, matrix, complex_matrix, array, complex_array, mx_el_ne)
00110
00111 DEFNDBINOP_FN (el_mul, matrix, complex_matrix, array, complex_array, product)
00112 DEFNDBINOP_FN (el_div, matrix, complex_matrix, array, complex_array, quotient)
00113 DEFNDBINOP_FN (el_pow, matrix, complex_matrix, array, complex_array, elem_xpow)
00114
00115 DEFBINOP (el_ldiv, matrix, complex_matrix)
00116 {
00117 CAST_BINOP_ARGS (const octave_matrix&, const octave_complex_matrix&);
00118
00119 return quotient (v2.complex_array_value (), v1.array_value ());
00120 }
00121
00122 DEFNDBINOP_FN (el_and, matrix, complex_matrix, array, complex_array, mx_el_and)
00123 DEFNDBINOP_FN (el_or, matrix, complex_matrix, array, complex_array, mx_el_or)
00124
00125 DEFNDCATOP_FN (m_cm, matrix, complex_matrix, array, complex_array, concat)
00126
00127 DEFCONV (complex_matrix_conv, matrix, complex_matrix)
00128 {
00129 CAST_CONV_ARG (const octave_matrix&);
00130
00131 return new octave_complex_matrix (ComplexNDArray (v.array_value ()));
00132 }
00133
00134 void
00135 install_m_cm_ops (void)
00136 {
00137 INSTALL_BINOP (op_add, octave_matrix, octave_complex_matrix, add);
00138 INSTALL_BINOP (op_sub, octave_matrix, octave_complex_matrix, sub);
00139 INSTALL_BINOP (op_mul, octave_matrix, octave_complex_matrix, mul);
00140 INSTALL_BINOP (op_div, octave_matrix, octave_complex_matrix, div);
00141 INSTALL_BINOP (op_pow, octave_matrix, octave_complex_matrix, pow);
00142 INSTALL_BINOP (op_ldiv, octave_matrix, octave_complex_matrix, ldiv);
00143 INSTALL_BINOP (op_lt, octave_matrix, octave_complex_matrix, lt);
00144 INSTALL_BINOP (op_le, octave_matrix, octave_complex_matrix, le);
00145 INSTALL_BINOP (op_eq, octave_matrix, octave_complex_matrix, eq);
00146 INSTALL_BINOP (op_ge, octave_matrix, octave_complex_matrix, ge);
00147 INSTALL_BINOP (op_gt, octave_matrix, octave_complex_matrix, gt);
00148 INSTALL_BINOP (op_ne, octave_matrix, octave_complex_matrix, ne);
00149 INSTALL_BINOP (op_el_mul, octave_matrix, octave_complex_matrix, el_mul);
00150 INSTALL_BINOP (op_el_div, octave_matrix, octave_complex_matrix, el_div);
00151 INSTALL_BINOP (op_el_pow, octave_matrix, octave_complex_matrix, el_pow);
00152 INSTALL_BINOP (op_el_ldiv, octave_matrix, octave_complex_matrix, el_ldiv);
00153 INSTALL_BINOP (op_el_and, octave_matrix, octave_complex_matrix, el_and);
00154 INSTALL_BINOP (op_el_or, octave_matrix, octave_complex_matrix, el_or);
00155 INSTALL_BINOP (op_trans_mul, octave_matrix, octave_complex_matrix, trans_mul);
00156 INSTALL_BINOP (op_herm_mul, octave_matrix, octave_complex_matrix, trans_mul);
00157 INSTALL_BINOP (op_trans_ldiv, octave_matrix, octave_complex_matrix, trans_ldiv);
00158 INSTALL_BINOP (op_herm_ldiv, octave_matrix, octave_complex_matrix, trans_ldiv);
00159
00160 INSTALL_CATOP (octave_matrix, octave_complex_matrix, m_cm);
00161
00162 INSTALL_ASSIGNCONV (octave_matrix, octave_complex_matrix, octave_complex_matrix);
00163 INSTALL_ASSIGNCONV (octave_float_matrix, octave_complex_matrix, octave_float_complex_matrix);
00164
00165 INSTALL_WIDENOP (octave_matrix, octave_complex_matrix, complex_matrix_conv);
00166 }