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-cx-mat.h"
00031 #include "ov-flt-cx-mat.h"
00032 #include "ov-typeinfo.h"
00033 #include "ov-null-mat.h"
00034 #include "ops.h"
00035 #include "xdiv.h"
00036 #include "xpow.h"
00037
00038
00039
00040 DEFNDUNOP_OP (not, float_complex_matrix, float_complex_array, !)
00041 DEFNDUNOP_OP (uplus, float_complex_matrix, float_complex_array, )
00042 DEFNDUNOP_OP (uminus, float_complex_matrix, float_complex_array, -)
00043
00044 DEFUNOP (transpose, float_complex_matrix)
00045 {
00046 CAST_UNOP_ARG (const octave_float_complex_matrix&);
00047
00048 if (v.ndims () > 2)
00049 {
00050 error ("transpose not defined for N-d objects");
00051 return octave_value ();
00052 }
00053 else
00054 return octave_value (v.float_complex_matrix_value().transpose ());
00055 }
00056
00057 DEFUNOP (hermitian, float_complex_matrix)
00058 {
00059 CAST_UNOP_ARG (const octave_float_complex_matrix&);
00060
00061 if (v.ndims () > 2)
00062 {
00063 error ("complex-conjugate transpose not defined for N-d objects");
00064 return octave_value ();
00065 }
00066 else
00067 return octave_value (v.float_complex_matrix_value().hermitian ());
00068 }
00069
00070 DEFNCUNOP_METHOD (incr, float_complex_matrix, increment)
00071 DEFNCUNOP_METHOD (decr, float_complex_matrix, decrement)
00072 DEFNCUNOP_METHOD (changesign, float_complex_matrix, changesign)
00073
00074
00075
00076 DEFNDBINOP_OP (add, float_complex_matrix, float_complex_matrix,
00077 float_complex_array, float_complex_array, +)
00078 DEFNDBINOP_OP (sub, float_complex_matrix, float_complex_matrix,
00079 float_complex_array, float_complex_array, -)
00080
00081 DEFBINOP_OP (mul, float_complex_matrix, float_complex_matrix, *)
00082
00083 DEFBINOP (div, float_complex_matrix, float_complex_matrix)
00084 {
00085 CAST_BINOP_ARGS (const octave_float_complex_matrix&,
00086 const octave_float_complex_matrix&);
00087 MatrixType typ = v2.matrix_type ();
00088
00089 FloatComplexMatrix ret = xdiv (v1.float_complex_matrix_value (),
00090 v2.float_complex_matrix_value (), typ);
00091
00092 v2.matrix_type (typ);
00093 return ret;
00094 }
00095
00096 DEFBINOPX (pow, float_complex_matrix, float_complex_matrix)
00097 {
00098 error ("can't do A ^ B for A and B both matrices");
00099 return octave_value ();
00100 }
00101
00102 DEFBINOP (ldiv, float_complex_matrix, float_complex_matrix)
00103 {
00104 CAST_BINOP_ARGS (const octave_float_complex_matrix&,
00105 const octave_float_complex_matrix&);
00106 MatrixType typ = v1.matrix_type ();
00107
00108 FloatComplexMatrix ret = xleftdiv (v1.float_complex_matrix_value (),
00109 v2.float_complex_matrix_value (), typ);
00110
00111 v1.matrix_type (typ);
00112 return ret;
00113 }
00114
00115 DEFBINOP (trans_mul, float_complex_matrix, float_complex_matrix)
00116 {
00117 CAST_BINOP_ARGS (const octave_float_complex_matrix&, const octave_float_complex_matrix&);
00118 return octave_value(xgemm (v1.float_complex_matrix_value (),
00119 v2.float_complex_matrix_value (),
00120 blas_trans, blas_no_trans));
00121 }
00122
00123 DEFBINOP (mul_trans, float_complex_matrix, float_complex_matrix)
00124 {
00125 CAST_BINOP_ARGS (const octave_float_complex_matrix&, const octave_float_complex_matrix&);
00126 return octave_value(xgemm (v1.float_complex_matrix_value (),
00127 v2.float_complex_matrix_value (),
00128 blas_no_trans, blas_trans));
00129 }
00130
00131 DEFBINOP (herm_mul, float_complex_matrix, float_complex_matrix)
00132 {
00133 CAST_BINOP_ARGS (const octave_float_complex_matrix&, const octave_float_complex_matrix&);
00134 return octave_value(xgemm (v1.float_complex_matrix_value (),
00135 v2.float_complex_matrix_value (),
00136 blas_conj_trans, blas_no_trans));
00137 }
00138
00139 DEFBINOP (mul_herm, float_complex_matrix, float_complex_matrix)
00140 {
00141 CAST_BINOP_ARGS (const octave_float_complex_matrix&, const octave_float_complex_matrix&);
00142 return octave_value(xgemm (v1.float_complex_matrix_value (),
00143 v2.float_complex_matrix_value (),
00144 blas_no_trans, blas_conj_trans));
00145 }
00146
00147 DEFBINOP (trans_ldiv, float_complex_matrix, float_complex_matrix)
00148 {
00149 CAST_BINOP_ARGS (const octave_float_complex_matrix&,
00150 const octave_float_complex_matrix&);
00151 MatrixType typ = v1.matrix_type ();
00152
00153 FloatComplexMatrix ret = xleftdiv (v1.float_complex_matrix_value (),
00154 v2.float_complex_matrix_value (), typ, blas_trans);
00155
00156 v1.matrix_type (typ);
00157 return ret;
00158 }
00159
00160 DEFBINOP (herm_ldiv, float_complex_matrix, float_complex_matrix)
00161 {
00162 CAST_BINOP_ARGS (const octave_float_complex_matrix&,
00163 const octave_float_complex_matrix&);
00164 MatrixType typ = v1.matrix_type ();
00165
00166 FloatComplexMatrix ret = xleftdiv (v1.float_complex_matrix_value (),
00167 v2.float_complex_matrix_value (), typ, blas_conj_trans);
00168
00169 v1.matrix_type (typ);
00170 return ret;
00171 }
00172
00173 DEFNDCMPLXCMPOP_FN (lt, float_complex_matrix, float_complex_matrix,
00174 float_complex_array, float_complex_array, mx_el_lt)
00175 DEFNDCMPLXCMPOP_FN (le, float_complex_matrix, float_complex_matrix,
00176 float_complex_array, float_complex_array, mx_el_le)
00177 DEFNDCMPLXCMPOP_FN (eq, float_complex_matrix, float_complex_matrix,
00178 float_complex_array, float_complex_array, mx_el_eq)
00179 DEFNDCMPLXCMPOP_FN (ge, float_complex_matrix, float_complex_matrix,
00180 float_complex_array, float_complex_array, mx_el_ge)
00181 DEFNDCMPLXCMPOP_FN (gt, float_complex_matrix, float_complex_matrix,
00182 float_complex_array, float_complex_array, mx_el_gt)
00183 DEFNDCMPLXCMPOP_FN (ne, float_complex_matrix, float_complex_matrix,
00184 float_complex_array, float_complex_array, mx_el_ne)
00185
00186 DEFNDBINOP_FN (el_mul, float_complex_matrix, float_complex_matrix,
00187 float_complex_array, float_complex_array, product)
00188 DEFNDBINOP_FN (el_div, float_complex_matrix, float_complex_matrix,
00189 float_complex_array, float_complex_array, quotient)
00190 DEFNDBINOP_FN (el_pow, float_complex_matrix, float_complex_matrix,
00191 float_complex_array, float_complex_array, elem_xpow)
00192
00193 DEFBINOP (el_ldiv, float_complex_matrix, float_complex_matrix)
00194 {
00195 CAST_BINOP_ARGS (const octave_float_complex_matrix&,
00196 const octave_float_complex_matrix&);
00197
00198 return octave_value (quotient (v2.float_complex_array_value (), v1.float_complex_array_value ()));
00199 }
00200
00201 DEFNDBINOP_FN (el_and, float_complex_matrix, float_complex_matrix,
00202 float_complex_array, float_complex_array, mx_el_and)
00203 DEFNDBINOP_FN (el_or, float_complex_matrix, float_complex_matrix,
00204 float_complex_array, float_complex_array, mx_el_or)
00205
00206 DEFNDCATOP_FN (fcm_fcm, float_complex_matrix, float_complex_matrix,
00207 float_complex_array, float_complex_array, concat)
00208
00209 DEFNDCATOP_FN (cm_fcm, complex_matrix, float_complex_matrix,
00210 float_complex_array, float_complex_array, concat)
00211
00212 DEFNDCATOP_FN (fcm_cm, float_complex_matrix, complex_matrix,
00213 float_complex_array, float_complex_array, concat)
00214
00215 DEFNDASSIGNOP_FN (assign, float_complex_matrix, float_complex_matrix,
00216 float_complex_array, assign)
00217 DEFNDASSIGNOP_FN (dbl_clx_assign, float_complex_matrix, complex_matrix,
00218 float_complex_array, assign)
00219 DEFNDASSIGNOP_FN (dbl_assign, float_complex_matrix, matrix,
00220 float_complex_array, assign)
00221
00222 DEFNULLASSIGNOP_FN (null_assign, float_complex_matrix, delete_elements)
00223
00224 DEFNDASSIGNOP_OP (assign_add, float_complex_matrix,
00225 float_complex_matrix, float_complex_array, +=)
00226 DEFNDASSIGNOP_OP (assign_sub, float_complex_matrix,
00227 float_complex_matrix, float_complex_array, -=)
00228 DEFNDASSIGNOP_FNOP (assign_el_mul, float_complex_matrix, float_complex_matrix,
00229 float_complex_array, product_eq)
00230 DEFNDASSIGNOP_FNOP (assign_el_div, float_complex_matrix, float_complex_matrix,
00231 float_complex_array, quotient_eq)
00232
00233 CONVDECL (float_complex_matrix_to_complex_matrix)
00234 {
00235 CAST_CONV_ARG (const octave_float_complex_matrix&);
00236
00237 return new octave_complex_matrix (ComplexNDArray (v.float_complex_array_value ()));
00238 }
00239
00240 void
00241 install_fcm_fcm_ops (void)
00242 {
00243 INSTALL_UNOP (op_not, octave_float_complex_matrix, not);
00244 INSTALL_UNOP (op_uplus, octave_float_complex_matrix, uplus);
00245 INSTALL_UNOP (op_uminus, octave_float_complex_matrix, uminus);
00246 INSTALL_UNOP (op_transpose, octave_float_complex_matrix, transpose);
00247 INSTALL_UNOP (op_hermitian, octave_float_complex_matrix, hermitian);
00248
00249 INSTALL_NCUNOP (op_incr, octave_float_complex_matrix, incr);
00250 INSTALL_NCUNOP (op_decr, octave_float_complex_matrix, decr);
00251 INSTALL_NCUNOP (op_uminus, octave_float_complex_matrix, changesign);
00252
00253 INSTALL_BINOP (op_add, octave_float_complex_matrix,
00254 octave_float_complex_matrix, add);
00255 INSTALL_BINOP (op_sub, octave_float_complex_matrix,
00256 octave_float_complex_matrix, sub);
00257 INSTALL_BINOP (op_mul, octave_float_complex_matrix,
00258 octave_float_complex_matrix, mul);
00259 INSTALL_BINOP (op_div, octave_float_complex_matrix,
00260 octave_float_complex_matrix, div);
00261 INSTALL_BINOP (op_pow, octave_float_complex_matrix,
00262 octave_float_complex_matrix, pow);
00263 INSTALL_BINOP (op_ldiv, octave_float_complex_matrix,
00264 octave_float_complex_matrix, ldiv);
00265 INSTALL_BINOP (op_trans_mul, octave_float_complex_matrix,
00266 octave_float_complex_matrix, trans_mul);
00267 INSTALL_BINOP (op_mul_trans, octave_float_complex_matrix,
00268 octave_float_complex_matrix, mul_trans);
00269 INSTALL_BINOP (op_herm_mul, octave_float_complex_matrix,
00270 octave_float_complex_matrix, herm_mul);
00271 INSTALL_BINOP (op_mul_herm, octave_float_complex_matrix,
00272 octave_float_complex_matrix, mul_herm);
00273 INSTALL_BINOP (op_trans_ldiv, octave_float_complex_matrix,
00274 octave_float_complex_matrix, trans_ldiv);
00275 INSTALL_BINOP (op_herm_ldiv, octave_float_complex_matrix,
00276 octave_float_complex_matrix, herm_ldiv);
00277
00278 INSTALL_BINOP (op_lt, octave_float_complex_matrix,
00279 octave_float_complex_matrix, lt);
00280 INSTALL_BINOP (op_le, octave_float_complex_matrix,
00281 octave_float_complex_matrix, le);
00282 INSTALL_BINOP (op_eq, octave_float_complex_matrix,
00283 octave_float_complex_matrix, eq);
00284 INSTALL_BINOP (op_ge, octave_float_complex_matrix,
00285 octave_float_complex_matrix, ge);
00286 INSTALL_BINOP (op_gt, octave_float_complex_matrix,
00287 octave_float_complex_matrix, gt);
00288 INSTALL_BINOP (op_ne, octave_float_complex_matrix,
00289 octave_float_complex_matrix, ne);
00290 INSTALL_BINOP (op_el_mul, octave_float_complex_matrix,
00291 octave_float_complex_matrix, el_mul);
00292 INSTALL_BINOP (op_el_div, octave_float_complex_matrix,
00293 octave_float_complex_matrix, el_div);
00294 INSTALL_BINOP (op_el_pow, octave_float_complex_matrix,
00295 octave_float_complex_matrix, el_pow);
00296 INSTALL_BINOP (op_el_ldiv, octave_float_complex_matrix,
00297 octave_float_complex_matrix, el_ldiv);
00298 INSTALL_BINOP (op_el_and, octave_float_complex_matrix,
00299 octave_float_complex_matrix, el_and);
00300 INSTALL_BINOP (op_el_or, octave_float_complex_matrix,
00301 octave_float_complex_matrix, el_or);
00302
00303 INSTALL_CATOP (octave_float_complex_matrix,
00304 octave_float_complex_matrix, fcm_fcm);
00305 INSTALL_CATOP (octave_complex_matrix,
00306 octave_float_complex_matrix, cm_fcm);
00307 INSTALL_CATOP (octave_float_complex_matrix,
00308 octave_complex_matrix, fcm_cm);
00309
00310 INSTALL_ASSIGNOP (op_asn_eq, octave_float_complex_matrix,
00311 octave_float_complex_matrix, assign);
00312 INSTALL_ASSIGNOP (op_asn_eq, octave_float_complex_matrix,
00313 octave_complex_matrix, dbl_clx_assign);
00314 INSTALL_ASSIGNOP (op_asn_eq, octave_float_complex_matrix,
00315 octave_matrix, dbl_assign);
00316
00317 INSTALL_ASSIGNOP (op_asn_eq, octave_float_complex_matrix,
00318 octave_null_matrix, null_assign);
00319 INSTALL_ASSIGNOP (op_asn_eq, octave_float_complex_matrix,
00320 octave_null_str, null_assign);
00321 INSTALL_ASSIGNOP (op_asn_eq, octave_float_complex_matrix,
00322 octave_null_sq_str, null_assign);
00323
00324 INSTALL_ASSIGNOP (op_add_eq, octave_float_complex_matrix,
00325 octave_float_complex_matrix, assign_add);
00326 INSTALL_ASSIGNOP (op_sub_eq, octave_float_complex_matrix,
00327 octave_float_complex_matrix, assign_sub);
00328 INSTALL_ASSIGNOP (op_el_mul_eq, octave_float_complex_matrix,
00329 octave_float_complex_matrix, assign_el_mul);
00330 INSTALL_ASSIGNOP (op_el_div_eq, octave_float_complex_matrix,
00331 octave_float_complex_matrix, assign_el_div);
00332
00333 INSTALL_CONVOP (octave_float_complex_matrix, octave_complex_matrix,
00334 float_complex_matrix_to_complex_matrix);
00335 }