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