op-fcs-fm.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-flt-complex.h"
00037 #include "ov-cx-mat.h"
00038 #include "ov-flt-cx-mat.h"
00039 #include "ov-flt-re-mat.h"
00040 #include "ov-re-mat.h"
00041 #include "ov-typeinfo.h"
00042 #include "ops.h"
00043 #include "xdiv.h"
00044 #include "xpow.h"
00045 
00046 // complex scalar by matrix ops.
00047 
00048 DEFNDBINOP_OP (add, float_complex, float_matrix, float_complex, float_array, +)
00049 DEFNDBINOP_OP (sub, float_complex, float_matrix, float_complex, float_array, -)
00050 DEFNDBINOP_OP (mul, float_complex, float_matrix, float_complex, float_array, *)
00051 
00052 DEFBINOP (div, float_complex, float_matrix)
00053 {
00054   CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_matrix&);
00055 
00056   FloatComplexMatrix m1 = v1.float_complex_matrix_value ();
00057   FloatMatrix m2 = v2.float_matrix_value ();
00058   MatrixType typ = v2.matrix_type ();
00059 
00060   FloatComplexMatrix ret = xdiv (m1, m2, typ);
00061 
00062   v2.matrix_type (typ);
00063   return ret;
00064 }
00065 
00066 DEFBINOP_FN (pow, float_complex, float_matrix, xpow)
00067 
00068 DEFBINOP (ldiv, float_complex, float_matrix)
00069 {
00070   CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_matrix&);
00071 
00072   FloatComplex d = v1.float_complex_value ();
00073 
00074   if (d == static_cast<float>(0.0))
00075     gripe_divide_by_zero ();
00076 
00077   return octave_value (v2.float_array_value () / d);
00078 }
00079 
00080 DEFNDCMPLXCMPOP_FN (lt, float_complex, float_matrix, float_complex,
00081                float_array, mx_el_lt)
00082 DEFNDCMPLXCMPOP_FN (le, float_complex, float_matrix, float_complex,
00083                float_array, mx_el_le)
00084 DEFNDCMPLXCMPOP_FN (eq, float_complex, float_matrix, float_complex,
00085                float_array, mx_el_eq)
00086 DEFNDCMPLXCMPOP_FN (ge, float_complex, float_matrix, float_complex,
00087                float_array, mx_el_ge)
00088 DEFNDCMPLXCMPOP_FN (gt, float_complex, float_matrix, float_complex,
00089                float_array, mx_el_gt)
00090 DEFNDCMPLXCMPOP_FN (ne, float_complex, float_matrix, float_complex,
00091                float_array, mx_el_ne)
00092 
00093 DEFNDBINOP_OP (el_mul, float_complex, float_matrix, float_complex,
00094                float_array, *)
00095 DEFNDBINOP_FN (el_div, float_complex, float_matrix, float_complex,
00096                float_array, x_el_div)
00097 DEFNDBINOP_FN (el_pow, float_complex, float_matrix, float_complex,
00098                float_array, elem_xpow)
00099 
00100 DEFBINOP (el_ldiv, float_complex, float_matrix)
00101 {
00102   CAST_BINOP_ARGS (const octave_float_complex&, const octave_float_matrix&);
00103 
00104   FloatComplex d = v1.float_complex_value ();
00105 
00106   if (d == static_cast<float>(0.0))
00107     gripe_divide_by_zero ();
00108 
00109   return octave_value (v2.float_array_value () / d);
00110 }
00111 
00112 DEFNDBINOP_FN (el_and, float_complex, float_matrix, float_complex,
00113                float_array, mx_el_and)
00114 DEFNDBINOP_FN (el_or,  float_complex, float_matrix, float_complex,
00115                float_array, mx_el_or)
00116 
00117 DEFNDCATOP_FN (fcs_fm, float_complex, float_matrix, float_complex_array,
00118                float_array, concat)
00119 
00120 DEFNDCATOP_FN (cs_fm, complex, float_matrix, float_complex_array,
00121                float_array, concat)
00122 
00123 DEFNDCATOP_FN (fcs_m, float_complex, matrix, float_complex_array,
00124                float_array, concat)
00125 
00126 void
00127 install_fcs_fm_ops (void)
00128 {
00129   INSTALL_BINOP (op_add, octave_float_complex, octave_float_matrix, add);
00130   INSTALL_BINOP (op_sub, octave_float_complex, octave_float_matrix, sub);
00131   INSTALL_BINOP (op_mul, octave_float_complex, octave_float_matrix, mul);
00132   INSTALL_BINOP (op_div, octave_float_complex, octave_float_matrix, div);
00133   INSTALL_BINOP (op_pow, octave_float_complex, octave_float_matrix, pow);
00134   INSTALL_BINOP (op_ldiv, octave_float_complex, octave_float_matrix, ldiv);
00135   INSTALL_BINOP (op_lt, octave_float_complex, octave_float_matrix, lt);
00136   INSTALL_BINOP (op_le, octave_float_complex, octave_float_matrix, le);
00137   INSTALL_BINOP (op_eq, octave_float_complex, octave_float_matrix, eq);
00138   INSTALL_BINOP (op_ge, octave_float_complex, octave_float_matrix, ge);
00139   INSTALL_BINOP (op_gt, octave_float_complex, octave_float_matrix, gt);
00140   INSTALL_BINOP (op_ne, octave_float_complex, octave_float_matrix, ne);
00141   INSTALL_BINOP (op_el_mul, octave_float_complex, octave_float_matrix, el_mul);
00142   INSTALL_BINOP (op_el_div, octave_float_complex, octave_float_matrix, el_div);
00143   INSTALL_BINOP (op_el_pow, octave_float_complex, octave_float_matrix, el_pow);
00144   INSTALL_BINOP (op_el_ldiv, octave_float_complex, octave_float_matrix, el_ldiv);
00145   INSTALL_BINOP (op_el_and, octave_float_complex, octave_float_matrix, el_and);
00146   INSTALL_BINOP (op_el_or, octave_float_complex, octave_float_matrix, el_or);
00147 
00148   INSTALL_CATOP (octave_float_complex, octave_float_matrix, fcs_fm);
00149   INSTALL_CATOP (octave_complex, octave_float_matrix, cs_fm);
00150   INSTALL_CATOP (octave_float_complex, octave_matrix, fcs_m);
00151 
00152   INSTALL_ASSIGNCONV (octave_float_complex, octave_float_matrix,
00153                       octave_float_complex_matrix);
00154   INSTALL_ASSIGNCONV (octave_complex, octave_float_matrix,
00155                       octave_complex_matrix);
00156 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines