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