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