op-cm-cs.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-complex.h"
00033 #include "ov-typeinfo.h"
00034 #include "ops.h"
00035 #include "xdiv.h"
00036 #include "xpow.h"
00037 
00038 // complex matrix by complex scalar ops.
00039 
00040 DEFNDBINOP_OP (add, complex_matrix, complex, complex_array, complex, +)
00041 DEFNDBINOP_OP (sub, complex_matrix, complex, complex_array, complex, -)
00042 DEFNDBINOP_OP (mul, complex_matrix, complex, complex_array, complex, *)
00043 
00044 DEFBINOP (div, complex_matrix, complex)
00045 {
00046   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&);
00047 
00048   Complex d = v2.complex_value ();
00049 
00050   if (d == 0.0)
00051     gripe_divide_by_zero ();
00052 
00053   return octave_value (v1.complex_array_value () / d);
00054 }
00055 
00056 DEFBINOP_FN (pow, complex_matrix, complex, xpow)
00057 
00058 DEFBINOP (ldiv, complex_matrix, complex)
00059 {
00060   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&);
00061 
00062   ComplexMatrix m1 = v1.complex_matrix_value ();
00063   ComplexMatrix m2 = v2.complex_matrix_value ();
00064   MatrixType typ = v1.matrix_type ();
00065 
00066   ComplexMatrix ret = xleftdiv (m1, m2, typ);
00067   v1.matrix_type (typ);
00068   return ret;
00069 }
00070 
00071 DEFNDCMPLXCMPOP_FN (lt, complex_matrix, complex, complex_array, complex, mx_el_lt)
00072 DEFNDCMPLXCMPOP_FN (le, complex_matrix, complex, complex_array, complex, mx_el_le)
00073 DEFNDCMPLXCMPOP_FN (eq, complex_matrix, complex, complex_array, complex, mx_el_eq)
00074 DEFNDCMPLXCMPOP_FN (ge, complex_matrix, complex, complex_array, complex, mx_el_ge)
00075 DEFNDCMPLXCMPOP_FN (gt, complex_matrix, complex, complex_array, complex, mx_el_gt)
00076 DEFNDCMPLXCMPOP_FN (ne, complex_matrix, complex, complex_array, complex, mx_el_ne)
00077 
00078 DEFNDBINOP_OP (el_mul, complex_matrix, complex, complex_array, complex, *)
00079 
00080 DEFBINOP (el_div, complex_matrix, complex)
00081 {
00082   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&);
00083 
00084   Complex d = v2.complex_value ();
00085 
00086   if (d == 0.0)
00087     gripe_divide_by_zero ();
00088 
00089   return octave_value (v1.complex_array_value () / d);
00090 }
00091 
00092 DEFNDBINOP_FN (el_pow, complex_matrix, complex, complex_array, complex, elem_xpow)
00093 
00094 DEFBINOP (el_ldiv, complex_matrix, complex)
00095 {
00096   CAST_BINOP_ARGS (const octave_complex_matrix&, const octave_complex&);
00097 
00098   return x_el_div (v2.complex_value (), v1.complex_array_value ());
00099 }
00100 
00101 DEFNDBINOP_FN (el_and, complex_matrix, complex, complex_array, complex, mx_el_and)
00102 DEFNDBINOP_FN (el_or,  complex_matrix, complex, complex_array, complex, mx_el_or)
00103 
00104 DEFNDCATOP_FN (cm_cs, complex_matrix, complex, complex_array, complex_array, concat)
00105 
00106 DEFNDASSIGNOP_FN (assign, complex_matrix, complex, complex, assign)
00107 DEFNDASSIGNOP_FN (sgl_assign, float_complex_matrix, complex, float_complex, assign)
00108 
00109 DEFNDASSIGNOP_OP (assign_add, complex_matrix, complex_scalar, complex, +=)
00110 DEFNDASSIGNOP_OP (assign_sub, complex_matrix, complex_scalar, complex, -=)
00111 DEFNDASSIGNOP_OP (assign_mul, complex_matrix, complex_scalar, complex, *=)
00112 DEFNDASSIGNOP_OP (assign_div, complex_matrix, complex_scalar, complex, /=)
00113 
00114 void
00115 install_cm_cs_ops (void)
00116 {
00117   INSTALL_BINOP (op_add, octave_complex_matrix, octave_complex, add);
00118   INSTALL_BINOP (op_sub, octave_complex_matrix, octave_complex, sub);
00119   INSTALL_BINOP (op_mul, octave_complex_matrix, octave_complex, mul);
00120   INSTALL_BINOP (op_div, octave_complex_matrix, octave_complex, div);
00121   INSTALL_BINOP (op_pow, octave_complex_matrix, octave_complex, pow);
00122   INSTALL_BINOP (op_ldiv, octave_complex_matrix, octave_complex, ldiv);
00123   INSTALL_BINOP (op_lt, octave_complex_matrix, octave_complex, lt);
00124   INSTALL_BINOP (op_le, octave_complex_matrix, octave_complex, le);
00125   INSTALL_BINOP (op_eq, octave_complex_matrix, octave_complex, eq);
00126   INSTALL_BINOP (op_ge, octave_complex_matrix, octave_complex, ge);
00127   INSTALL_BINOP (op_gt, octave_complex_matrix, octave_complex, gt);
00128   INSTALL_BINOP (op_ne, octave_complex_matrix, octave_complex, ne);
00129   INSTALL_BINOP (op_el_mul, octave_complex_matrix, octave_complex, el_mul);
00130   INSTALL_BINOP (op_el_div, octave_complex_matrix, octave_complex, el_div);
00131   INSTALL_BINOP (op_el_pow, octave_complex_matrix, octave_complex, el_pow);
00132   INSTALL_BINOP (op_el_ldiv, octave_complex_matrix, octave_complex, el_ldiv);
00133   INSTALL_BINOP (op_el_and, octave_complex_matrix, octave_complex, el_and);
00134   INSTALL_BINOP (op_el_or, octave_complex_matrix, octave_complex, el_or);
00135 
00136   INSTALL_CATOP (octave_complex_matrix, octave_complex, cm_cs);
00137 
00138   INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix, octave_complex, assign);
00139   INSTALL_ASSIGNOP (op_asn_eq, octave_float_complex_matrix, octave_complex, sgl_assign);
00140 
00141   INSTALL_ASSIGNOP (op_add_eq, octave_complex_matrix, octave_complex_scalar, assign_add);
00142   INSTALL_ASSIGNOP (op_sub_eq, octave_complex_matrix, octave_complex_scalar, assign_sub);
00143   INSTALL_ASSIGNOP (op_mul_eq, octave_complex_matrix, octave_complex_scalar, assign_mul);
00144   INSTALL_ASSIGNOP (op_div_eq, octave_complex_matrix, octave_complex_scalar, assign_div);
00145 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines