op-cm-cm.cc

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1996-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
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 // unary complex matrix ops.
00039 
00040 DEFNDUNOP_OP (not, complex_matrix, complex_array, !)
00041 DEFNDUNOP_OP (uplus, complex_matrix, complex_array, /* no-op */)
00042 DEFNDUNOP_OP (uminus, complex_matrix, complex_array, -)
00043 
00044 DEFUNOP (transpose, complex_matrix)
00045 {
00046   CAST_UNOP_ARG (const octave_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.complex_matrix_value().transpose ());
00055 }
00056 
00057 DEFUNOP (hermitian, complex_matrix)
00058 {
00059   CAST_UNOP_ARG (const octave_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.complex_matrix_value().hermitian ());
00068 }
00069 
00070 DEFNCUNOP_METHOD (incr, complex_matrix, increment)
00071 DEFNCUNOP_METHOD (decr, complex_matrix, decrement)
00072 DEFNCUNOP_METHOD (changesign, complex_matrix, changesign)
00073 
00074 // complex matrix by complex matrix ops.
00075 
00076 DEFNDBINOP_OP (add, complex_matrix, complex_matrix, complex_array, complex_array, +)
00077 DEFNDBINOP_OP (sub, complex_matrix, complex_matrix, complex_array, complex_array, -)
00078 
00079 DEFBINOP_OP (mul, complex_matrix, complex_matrix, *)
00080 
00081 DEFBINOP (div, complex_matrix, complex_matrix)
00082 {
00083   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&);
00084   MatrixType typ = v2.matrix_type ();
00085 
00086   ComplexMatrix ret = xdiv (v1.complex_matrix_value (),
00087                             v2.complex_matrix_value (), typ);
00088 
00089   v2.matrix_type (typ);
00090   return ret;
00091 }
00092 
00093 DEFBINOPX (pow, complex_matrix, complex_matrix)
00094 {
00095   error ("can't do A ^ B for A and B both matrices");
00096   return octave_value ();
00097 }
00098 
00099 DEFBINOP (ldiv, complex_matrix, complex_matrix)
00100 {
00101   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&);
00102   MatrixType typ = v1.matrix_type ();
00103 
00104   ComplexMatrix ret = xleftdiv (v1.complex_matrix_value (),
00105                                 v2.complex_matrix_value (), typ);
00106 
00107   v1.matrix_type (typ);
00108   return ret;
00109 }
00110 
00111 DEFBINOP (trans_mul, complex_matrix, complex_matrix)
00112 {
00113   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&);
00114   return octave_value(xgemm (v1.complex_matrix_value (),
00115                              v2.complex_matrix_value (),
00116                              blas_trans, blas_no_trans));
00117 }
00118 
00119 DEFBINOP (mul_trans, complex_matrix, complex_matrix)
00120 {
00121   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&);
00122   return octave_value(xgemm (v1.complex_matrix_value (),
00123                              v2.complex_matrix_value (),
00124                              blas_no_trans, blas_trans));
00125 }
00126 
00127 DEFBINOP (herm_mul, complex_matrix, complex_matrix)
00128 {
00129   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&);
00130   return octave_value(xgemm (v1.complex_matrix_value (),
00131                              v2.complex_matrix_value (),
00132                              blas_conj_trans, blas_no_trans));
00133 }
00134 
00135 DEFBINOP (mul_herm, complex_matrix, complex_matrix)
00136 {
00137   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&);
00138   return octave_value(xgemm (v1.complex_matrix_value (),
00139                              v2.complex_matrix_value (),
00140                              blas_no_trans, blas_conj_trans));
00141 }
00142 
00143 DEFBINOP (trans_ldiv, complex_matrix, complex_matrix)
00144 {
00145   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&);
00146   MatrixType typ = v1.matrix_type ();
00147 
00148   ComplexMatrix ret = xleftdiv (v1.complex_matrix_value (),
00149                                 v2.complex_matrix_value (), typ, blas_trans);
00150 
00151   v1.matrix_type (typ);
00152   return ret;
00153 }
00154 
00155 DEFBINOP (herm_ldiv, complex_matrix, complex_matrix)
00156 {
00157   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&);
00158   MatrixType typ = v1.matrix_type ();
00159 
00160   ComplexMatrix ret = xleftdiv (v1.complex_matrix_value (),
00161                                 v2.complex_matrix_value (), typ, blas_conj_trans);
00162 
00163   v1.matrix_type (typ);
00164   return ret;
00165 }
00166 
00167 DEFNDCMPLXCMPOP_FN (lt, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_lt)
00168 DEFNDCMPLXCMPOP_FN (le, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_le)
00169 DEFNDCMPLXCMPOP_FN (eq, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_eq)
00170 DEFNDCMPLXCMPOP_FN (ge, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_ge)
00171 DEFNDCMPLXCMPOP_FN (gt, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_gt)
00172 DEFNDCMPLXCMPOP_FN (ne, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_ne)
00173 
00174 DEFNDBINOP_FN (el_mul, complex_matrix, complex_matrix, complex_array, complex_array, product)
00175 DEFNDBINOP_FN (el_div, complex_matrix, complex_matrix, complex_array, complex_array, quotient)
00176 DEFNDBINOP_FN (el_pow, complex_matrix, complex_matrix, complex_array, complex_array, elem_xpow)
00177 
00178 DEFBINOP (el_ldiv, complex_matrix, complex_matrix)
00179 {
00180   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex_matrix&);
00181 
00182   return octave_value (quotient (v2.complex_array_value (), v1.complex_array_value ()));
00183 }
00184 
00185 DEFNDBINOP_FN (el_and, complex_matrix, complex_matrix, complex_array, complex_array, mx_el_and)
00186 DEFNDBINOP_FN (el_or,  complex_matrix, complex_matrix, complex_array, complex_array, mx_el_or)
00187 
00188 DEFNDCATOP_FN (cm_cm, complex_matrix, complex_matrix, complex_array, complex_array, concat)
00189 
00190 DEFNDASSIGNOP_FN (assign, complex_matrix, complex_matrix, complex_array, assign)
00191 
00192 DEFNULLASSIGNOP_FN (null_assign, complex_matrix, delete_elements)
00193 
00194 DEFNDASSIGNOP_OP (assign_add, complex_matrix, complex_matrix, complex_array, +=)
00195 DEFNDASSIGNOP_OP (assign_sub, complex_matrix, complex_matrix, complex_array, -=)
00196 DEFNDASSIGNOP_FNOP (assign_el_mul, complex_matrix, complex_matrix, complex_array, product_eq)
00197 DEFNDASSIGNOP_FNOP (assign_el_div, complex_matrix, complex_matrix, complex_array, quotient_eq)
00198 
00199 CONVDECL (complex_matrix_to_float_complex_matrix)
00200 {
00201   CAST_CONV_ARG (const octave_complex_matrix&);
00202 
00203   return new octave_float_complex_matrix (FloatComplexNDArray (v.complex_array_value ()));
00204 }
00205 
00206 void
00207 install_cm_cm_ops (void)
00208 {
00209   INSTALL_UNOP (op_not, octave_complex_matrix, not);
00210   INSTALL_UNOP (op_uplus, octave_complex_matrix, uplus);
00211   INSTALL_UNOP (op_uminus, octave_complex_matrix, uminus);
00212   INSTALL_UNOP (op_transpose, octave_complex_matrix, transpose);
00213   INSTALL_UNOP (op_hermitian, octave_complex_matrix, hermitian);
00214 
00215   INSTALL_NCUNOP (op_incr, octave_complex_matrix, incr);
00216   INSTALL_NCUNOP (op_decr, octave_complex_matrix, decr);
00217   INSTALL_NCUNOP (op_uminus, octave_complex_matrix, changesign);
00218 
00219   INSTALL_BINOP (op_add, octave_complex_matrix, octave_complex_matrix, add);
00220   INSTALL_BINOP (op_sub, octave_complex_matrix, octave_complex_matrix, sub);
00221   INSTALL_BINOP (op_mul, octave_complex_matrix, octave_complex_matrix, mul);
00222   INSTALL_BINOP (op_div, octave_complex_matrix, octave_complex_matrix, div);
00223   INSTALL_BINOP (op_pow, octave_complex_matrix, octave_complex_matrix, pow);
00224   INSTALL_BINOP (op_ldiv, octave_complex_matrix, octave_complex_matrix, ldiv);
00225   INSTALL_BINOP (op_trans_mul, octave_complex_matrix, octave_complex_matrix, trans_mul);
00226   INSTALL_BINOP (op_mul_trans, octave_complex_matrix, octave_complex_matrix, mul_trans);
00227   INSTALL_BINOP (op_herm_mul, octave_complex_matrix, octave_complex_matrix, herm_mul);
00228   INSTALL_BINOP (op_mul_herm, octave_complex_matrix, octave_complex_matrix, mul_herm);
00229   INSTALL_BINOP (op_trans_ldiv, octave_complex_matrix, octave_complex_matrix, trans_ldiv);
00230   INSTALL_BINOP (op_herm_ldiv, octave_complex_matrix, octave_complex_matrix, herm_ldiv);
00231 
00232   INSTALL_BINOP (op_lt, octave_complex_matrix, octave_complex_matrix, lt);
00233   INSTALL_BINOP (op_le, octave_complex_matrix, octave_complex_matrix, le);
00234   INSTALL_BINOP (op_eq, octave_complex_matrix, octave_complex_matrix, eq);
00235   INSTALL_BINOP (op_ge, octave_complex_matrix, octave_complex_matrix, ge);
00236   INSTALL_BINOP (op_gt, octave_complex_matrix, octave_complex_matrix, gt);
00237   INSTALL_BINOP (op_ne, octave_complex_matrix, octave_complex_matrix, ne);
00238   INSTALL_BINOP (op_el_mul, octave_complex_matrix, octave_complex_matrix, el_mul);
00239   INSTALL_BINOP (op_el_div, octave_complex_matrix, octave_complex_matrix, el_div);
00240   INSTALL_BINOP (op_el_pow, octave_complex_matrix, octave_complex_matrix, el_pow);
00241   INSTALL_BINOP (op_el_ldiv, octave_complex_matrix, octave_complex_matrix, el_ldiv);
00242   INSTALL_BINOP (op_el_and, octave_complex_matrix, octave_complex_matrix, el_and);
00243   INSTALL_BINOP (op_el_or, octave_complex_matrix, octave_complex_matrix, el_or);
00244 
00245   INSTALL_CATOP (octave_complex_matrix, octave_complex_matrix, cm_cm);
00246 
00247   INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_complex_matrix, assign);
00248 
00249   INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_null_matrix, null_assign);
00250   INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_null_str, null_assign);
00251   INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_null_sq_str, null_assign);
00252 
00253   INSTALL_ASSIGNOP (op_add_eq, octave_complex_matrix, octave_complex_matrix, assign_add);
00254   INSTALL_ASSIGNOP (op_sub_eq, octave_complex_matrix, octave_complex_matrix, assign_sub);
00255   INSTALL_ASSIGNOP (op_el_mul_eq, octave_complex_matrix, octave_complex_matrix, assign_el_mul);
00256   INSTALL_ASSIGNOP (op_el_div_eq, octave_complex_matrix, octave_complex_matrix, assign_el_div);
00257 
00258   INSTALL_CONVOP (octave_complex_matrix, octave_float_complex_matrix,
00259                   complex_matrix_to_float_complex_matrix);
00260 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines