op-fcm-fcs.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-flt-complex.h"
00033 #include "ov-complex.h"
00034 #include "ov-typeinfo.h"
00035 #include "ops.h"
00036 #include "xdiv.h"
00037 #include "xpow.h"
00038 
00039 // complex matrix by complex scalar ops.
00040 
00041 DEFNDBINOP_OP (add, float_complex_matrix, float_complex,
00042                float_complex_array, float_complex, +)
00043 DEFNDBINOP_OP (sub, float_complex_matrix, float_complex,
00044                float_complex_array, float_complex, -)
00045 DEFNDBINOP_OP (mul, float_complex_matrix, float_complex,
00046                float_complex_array, float_complex, *)
00047 
00048 DEFBINOP (div, float_complex_matrix, float_complex)
00049 {
00050   CAST_BINOP_ARGS (const octave_float_complex_matrix&,
00051                    const octave_float_complex&);
00052 
00053   FloatComplex d = v2.float_complex_value ();
00054 
00055   if (d == static_cast<float>(0.0))
00056     gripe_divide_by_zero ();
00057 
00058   return octave_value (v1.float_complex_array_value () / d);
00059 }
00060 
00061 DEFBINOP_FN (pow, float_complex_matrix, float_complex, xpow)
00062 
00063 DEFBINOP (ldiv, float_complex_matrix, float_complex)
00064 {
00065   CAST_BINOP_ARGS (const octave_float_complex_matrix&,
00066                    const octave_float_complex&);
00067 
00068   FloatComplexMatrix m1 = v1.float_complex_matrix_value ();
00069   FloatComplexMatrix m2 = v2.float_complex_matrix_value ();
00070   MatrixType typ = v1.matrix_type ();
00071 
00072   FloatComplexMatrix ret = xleftdiv (m1, m2, typ);
00073   v1.matrix_type (typ);
00074   return ret;
00075 }
00076 
00077 DEFNDCMPLXCMPOP_FN (lt, float_complex_matrix, float_complex,
00078                float_complex_array, float_complex, mx_el_lt)
00079 DEFNDCMPLXCMPOP_FN (le, float_complex_matrix, float_complex,
00080                float_complex_array, float_complex, mx_el_le)
00081 DEFNDCMPLXCMPOP_FN (eq, float_complex_matrix, float_complex,
00082                float_complex_array, float_complex, mx_el_eq)
00083 DEFNDCMPLXCMPOP_FN (ge, float_complex_matrix, float_complex,
00084                float_complex_array, float_complex, mx_el_ge)
00085 DEFNDCMPLXCMPOP_FN (gt, float_complex_matrix, float_complex,
00086                float_complex_array, float_complex, mx_el_gt)
00087 DEFNDCMPLXCMPOP_FN (ne, float_complex_matrix, float_complex,
00088                float_complex_array, float_complex, mx_el_ne)
00089 
00090 DEFNDBINOP_OP (el_mul, float_complex_matrix, float_complex,
00091                float_complex_array, float_complex, *)
00092 
00093 DEFBINOP (el_div, float_complex_matrix, float_complex)
00094 {
00095   CAST_BINOP_ARGS (const octave_float_complex_matrix&,
00096                    const octave_float_complex&);
00097 
00098   FloatComplex d = v2.float_complex_value ();
00099 
00100   if (d == static_cast<float>(0.0))
00101     gripe_divide_by_zero ();
00102 
00103   return octave_value (v1.float_complex_array_value () / d);
00104 }
00105 
00106 DEFNDBINOP_FN (el_pow, float_complex_matrix, float_complex,
00107                float_complex_array, float_complex, elem_xpow)
00108 
00109 DEFBINOP (el_ldiv, float_complex_matrix, float_complex)
00110 {
00111   CAST_BINOP_ARGS (const octave_float_complex_matrix&,
00112                    const octave_float_complex&);
00113 
00114   return x_el_div (v2.float_complex_value (), v1.float_complex_array_value ());
00115 }
00116 
00117 DEFNDBINOP_FN (el_and, float_complex_matrix, float_complex,
00118                float_complex_array, float_complex, mx_el_and)
00119 DEFNDBINOP_FN (el_or,  float_complex_matrix, float_complex,
00120                float_complex_array, float_complex, mx_el_or)
00121 
00122 DEFNDCATOP_FN (fcm_fcs, float_complex_matrix, float_complex,
00123                float_complex_array, float_complex_array, concat)
00124 
00125 DEFNDCATOP_FN (cm_fcs, complex_matrix, float_complex,
00126                float_complex_array, float_complex_array, concat)
00127 
00128 DEFNDCATOP_FN (fcm_cs, float_complex_matrix, complex,
00129                float_complex_array, float_complex_array, concat)
00130 
00131 DEFNDASSIGNOP_FN (assign, float_complex_matrix, float_complex,
00132                   float_complex, assign)
00133 DEFNDASSIGNOP_FN (dbl_assign, complex_matrix, float_complex,
00134                   complex, assign)
00135 
00136 DEFNDASSIGNOP_OP (assign_add, float_complex_matrix, float_complex_scalar,
00137                   float_complex, +=)
00138 DEFNDASSIGNOP_OP (assign_sub, float_complex_matrix, float_complex_scalar,
00139                   float_complex, -=)
00140 DEFNDASSIGNOP_OP (assign_mul, float_complex_matrix, float_complex_scalar,
00141                   float_complex, *=)
00142 DEFNDASSIGNOP_OP (assign_div, float_complex_matrix, float_complex_scalar,
00143                   float_complex, /=)
00144 
00145 void
00146 install_fcm_fcs_ops (void)
00147 {
00148   INSTALL_BINOP (op_add, octave_float_complex_matrix,
00149                  octave_float_complex, add);
00150   INSTALL_BINOP (op_sub, octave_float_complex_matrix,
00151                  octave_float_complex, sub);
00152   INSTALL_BINOP (op_mul, octave_float_complex_matrix,
00153                  octave_float_complex, mul);
00154   INSTALL_BINOP (op_div, octave_float_complex_matrix,
00155                  octave_float_complex, div);
00156   INSTALL_BINOP (op_pow, octave_float_complex_matrix,
00157                  octave_float_complex, pow);
00158   INSTALL_BINOP (op_ldiv, octave_float_complex_matrix,
00159                  octave_float_complex, ldiv);
00160   INSTALL_BINOP (op_lt, octave_float_complex_matrix, octave_float_complex, lt);
00161   INSTALL_BINOP (op_le, octave_float_complex_matrix, octave_float_complex, le);
00162   INSTALL_BINOP (op_eq, octave_float_complex_matrix, octave_float_complex, eq);
00163   INSTALL_BINOP (op_ge, octave_float_complex_matrix, octave_float_complex, ge);
00164   INSTALL_BINOP (op_gt, octave_float_complex_matrix, octave_float_complex, gt);
00165   INSTALL_BINOP (op_ne, octave_float_complex_matrix, octave_float_complex, ne);
00166   INSTALL_BINOP (op_el_mul, octave_float_complex_matrix,
00167                  octave_float_complex, el_mul);
00168   INSTALL_BINOP (op_el_div, octave_float_complex_matrix,
00169                  octave_float_complex, el_div);
00170   INSTALL_BINOP (op_el_pow, octave_float_complex_matrix,
00171                  octave_float_complex, el_pow);
00172   INSTALL_BINOP (op_el_ldiv, octave_float_complex_matrix,
00173                  octave_float_complex, el_ldiv);
00174   INSTALL_BINOP (op_el_and, octave_float_complex_matrix,
00175                  octave_float_complex, el_and);
00176   INSTALL_BINOP (op_el_or, octave_float_complex_matrix,
00177                  octave_float_complex, el_or);
00178 
00179   INSTALL_CATOP (octave_float_complex_matrix, octave_float_complex, fcm_fcs);
00180   INSTALL_CATOP (octave_complex_matrix, octave_float_complex, cm_fcs);
00181   INSTALL_CATOP (octave_float_complex_matrix, octave_complex, fcm_cs);
00182 
00183   INSTALL_ASSIGNOP (op_asn_eq, octave_float_complex_matrix,
00184                     octave_float_complex, assign);
00185   INSTALL_ASSIGNOP (op_asn_eq, octave_complex_matrix,
00186                     octave_float_complex, dbl_assign);
00187 
00188   INSTALL_ASSIGNOP (op_add_eq, octave_float_complex_matrix,
00189                     octave_float_complex_scalar, assign_add);
00190   INSTALL_ASSIGNOP (op_sub_eq, octave_float_complex_matrix,
00191                     octave_float_complex_scalar, assign_sub);
00192   INSTALL_ASSIGNOP (op_mul_eq, octave_float_complex_matrix,
00193                     octave_float_complex_scalar, assign_mul);
00194   INSTALL_ASSIGNOP (op_div_eq, octave_float_complex_matrix,
00195                     octave_float_complex_scalar, assign_div);
00196 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines