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