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