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