op-cm-m.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 "mx-cm-m.h"
00028 #include "mx-m-cm.h"
00029 #include "mx-cnda-nda.h"
00030 #include "mx-nda-cnda.h"
00031 
00032 #include "gripes.h"
00033 #include "oct-obj.h"
00034 #include "ov.h"
00035 #include "ov-cx-mat.h"
00036 #include "ov-re-mat.h"
00037 #include "ov-typeinfo.h"
00038 #include "ops.h"
00039 #include "xdiv.h"
00040 #include "xpow.h"
00041 
00042 // complex matrix by matrix ops.
00043 
00044 DEFNDBINOP_OP (add, complex_matrix, matrix, complex_array, array, +)
00045 DEFNDBINOP_OP (sub, complex_matrix, matrix, complex_array, array, -)
00046 
00047 DEFBINOP_OP (mul, complex_matrix, matrix, *)
00048 
00049 DEFBINOP (mul_trans, complex_matrix, matrix)
00050 {
00051   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&);
00052 
00053   ComplexMatrix m1 = v1.complex_matrix_value ();
00054   Matrix m2 = v2.matrix_value ();
00055 
00056   return ComplexMatrix (xgemm (real (m1), m2, blas_no_trans, blas_trans),
00057                         xgemm (imag (m1), m2, blas_no_trans, blas_trans));
00058 }
00059 
00060 DEFBINOP (div, complex_matrix, matrix)
00061 {
00062   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&);
00063   MatrixType typ = v2.matrix_type ();
00064 
00065   ComplexMatrix ret = xdiv (v1.complex_matrix_value (),
00066                             v2.matrix_value (), typ);
00067 
00068   v2.matrix_type (typ);
00069   return ret;
00070 }
00071 
00072 
00073 DEFBINOPX (pow, complex_matrix, matrix)
00074 {
00075   error ("can't do A ^ B for A and B both matrices");
00076   return octave_value ();
00077 }
00078 
00079 DEFBINOP (ldiv, complex_matrix, matrix)
00080 {
00081   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&);
00082   MatrixType typ = v1.matrix_type ();
00083 
00084   ComplexMatrix ret = xleftdiv (v1.complex_matrix_value (),
00085                                 v2.matrix_value (), typ);
00086 
00087   v1.matrix_type (typ);
00088   return ret;
00089 }
00090 
00091 DEFNDCMPLXCMPOP_FN (lt, complex_matrix, matrix, complex_array, array, mx_el_lt)
00092 DEFNDCMPLXCMPOP_FN (le, complex_matrix, matrix, complex_array, array, mx_el_le)
00093 DEFNDCMPLXCMPOP_FN (eq, complex_matrix, matrix, complex_array, array, mx_el_eq)
00094 DEFNDCMPLXCMPOP_FN (ge, complex_matrix, matrix, complex_array, array, mx_el_ge)
00095 DEFNDCMPLXCMPOP_FN (gt, complex_matrix, matrix, complex_array, array, mx_el_gt)
00096 DEFNDCMPLXCMPOP_FN (ne, complex_matrix, matrix, complex_array, array, mx_el_ne)
00097 
00098 DEFNDBINOP_FN (el_mul, complex_matrix, matrix, complex_array, array, product)
00099 DEFNDBINOP_FN (el_div, complex_matrix, matrix, complex_array, array, quotient)
00100 DEFNDBINOP_FN (el_pow, complex_matrix, matrix, complex_array, array, elem_xpow)
00101 
00102 DEFBINOP (el_ldiv, complex_matrix, matrix)
00103 {
00104   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_matrix&);
00105 
00106   return quotient (v2.array_value (), v1.complex_array_value ());
00107 }
00108 
00109 DEFNDBINOP_FN (el_and, complex_matrix, matrix, complex_array, array, mx_el_and)
00110 DEFNDBINOP_FN (el_or,  complex_matrix, matrix, complex_array, array, mx_el_or)
00111 
00112 DEFNDCATOP_FN (cm_m, complex_matrix, matrix, complex_array, array, concat)
00113 
00114 DEFNDASSIGNOP_FN (assign, complex_matrix, matrix, complex_array, assign)
00115 
00116 void
00117 install_cm_m_ops (void)
00118 {
00119   INSTALL_BINOP (op_add, octave_complex_matrix, octave_matrix, add);
00120   INSTALL_BINOP (op_sub, octave_complex_matrix, octave_matrix, sub);
00121   INSTALL_BINOP (op_mul, octave_complex_matrix, octave_matrix, mul);
00122   INSTALL_BINOP (op_div, octave_complex_matrix, octave_matrix, div);
00123   INSTALL_BINOP (op_pow, octave_complex_matrix, octave_matrix, pow);
00124   INSTALL_BINOP (op_ldiv, octave_complex_matrix, octave_matrix, ldiv);
00125   INSTALL_BINOP (op_lt, octave_complex_matrix, octave_matrix, lt);
00126   INSTALL_BINOP (op_le, octave_complex_matrix, octave_matrix, le);
00127   INSTALL_BINOP (op_eq, octave_complex_matrix, octave_matrix, eq);
00128   INSTALL_BINOP (op_ge, octave_complex_matrix, octave_matrix, ge);
00129   INSTALL_BINOP (op_gt, octave_complex_matrix, octave_matrix, gt);
00130   INSTALL_BINOP (op_ne, octave_complex_matrix, octave_matrix, ne);
00131   INSTALL_BINOP (op_el_mul, octave_complex_matrix, octave_matrix, el_mul);
00132   INSTALL_BINOP (op_el_div, octave_complex_matrix, octave_matrix, el_div);
00133   INSTALL_BINOP (op_el_pow, octave_complex_matrix, octave_matrix, el_pow);
00134   INSTALL_BINOP (op_el_ldiv, octave_complex_matrix, octave_matrix, el_ldiv);
00135   INSTALL_BINOP (op_el_and, octave_complex_matrix, octave_matrix, el_and);
00136   INSTALL_BINOP (op_el_or, octave_complex_matrix, octave_matrix, el_or);
00137   INSTALL_BINOP (op_mul_trans, octave_complex_matrix, octave_matrix, mul_trans);
00138   INSTALL_BINOP (op_mul_herm, octave_complex_matrix, octave_matrix, mul_trans);
00139 
00140   INSTALL_CATOP (octave_complex_matrix, octave_matrix, cm_m);
00141 
00142   INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_matrix, assign);
00143 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines