op-fm-fcm.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-fcm.h"
00028 #include "mx-fcm-fm.h"
00029 #include "mx-fnda-fcnda.h"
00030 #include "mx-fcnda-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-typeinfo.h"
00040 #include "ops.h"
00041 #include "xdiv.h"
00042 #include "xpow.h"
00043 
00044 // matrix by complex matrix ops.
00045 
00046 DEFNDBINOP_OP (add, float_matrix, float_complex_matrix, float_array,
00047                float_complex_array, +)
00048 DEFNDBINOP_OP (sub, float_matrix, float_complex_matrix, float_array,
00049                float_complex_array, -)
00050 
00051 DEFBINOP_OP (mul, float_matrix, float_complex_matrix, *)
00052 
00053 DEFBINOP (trans_mul, float_matrix, float_complex_matrix)
00054 {
00055   CAST_BINOP_ARGS (const octave_float_matrix&, const octave_float_complex_matrix&);
00056 
00057   FloatMatrix m1 = v1.float_matrix_value ();
00058   FloatComplexMatrix m2 = v2.float_complex_matrix_value ();
00059 
00060   return FloatComplexMatrix (xgemm (m1, real (m2), blas_trans, blas_no_trans),
00061                              xgemm (m1, imag (m2), blas_trans, blas_no_trans));
00062 }
00063 
00064 DEFBINOP (div, float_matrix, float_complex_matrix)
00065 {
00066   CAST_BINOP_ARGS (const octave_float_matrix&,
00067                    const octave_float_complex_matrix&);
00068   MatrixType typ = v2.matrix_type ();
00069 
00070   FloatComplexMatrix ret = xdiv (v1.float_matrix_value (),
00071                                  v2.float_complex_matrix_value (), typ);
00072 
00073   v2.matrix_type (typ);
00074   return ret;
00075 }
00076 
00077 DEFBINOPX (pow, float_matrix, float_complex_matrix)
00078 {
00079   error ("can't do A ^ B for A and B both matrices");
00080   return octave_value ();
00081 }
00082 
00083 DEFBINOP (ldiv, float_matrix, float_complex_matrix)
00084 {
00085   CAST_BINOP_ARGS (const octave_float_matrix&,
00086                    const octave_float_complex_matrix&);
00087   MatrixType typ = v1.matrix_type ();
00088 
00089   FloatComplexMatrix ret = xleftdiv (v1.float_matrix_value (),
00090                                 v2.float_complex_matrix_value (), typ);
00091 
00092   v1.matrix_type (typ);
00093   return ret;
00094 }
00095 
00096 DEFBINOP (trans_ldiv, float_matrix, float_complex_matrix)
00097 {
00098   CAST_BINOP_ARGS (const octave_float_matrix&,
00099                    const octave_float_complex_matrix&);
00100   MatrixType typ = v1.matrix_type ();
00101 
00102   FloatComplexMatrix ret = xleftdiv (v1.float_matrix_value (),
00103                          v2.float_complex_matrix_value (), typ, blas_trans);
00104 
00105   v1.matrix_type (typ);
00106   return ret;
00107 }
00108 
00109 DEFNDCMPLXCMPOP_FN (lt, float_matrix, float_complex_matrix, float_array,
00110                float_complex_array, mx_el_lt)
00111 DEFNDCMPLXCMPOP_FN (le, float_matrix, float_complex_matrix, float_array,
00112                float_complex_array, mx_el_le)
00113 DEFNDCMPLXCMPOP_FN (eq, float_matrix, float_complex_matrix, float_array,
00114                float_complex_array, mx_el_eq)
00115 DEFNDCMPLXCMPOP_FN (ge, float_matrix, float_complex_matrix, float_array,
00116                float_complex_array, mx_el_ge)
00117 DEFNDCMPLXCMPOP_FN (gt, float_matrix, float_complex_matrix, float_array,
00118                float_complex_array, mx_el_gt)
00119 DEFNDCMPLXCMPOP_FN (ne, float_matrix, float_complex_matrix, float_array,
00120                float_complex_array, mx_el_ne)
00121 
00122 DEFNDBINOP_FN (el_mul, float_matrix, float_complex_matrix, float_array,
00123                float_complex_array, product)
00124 DEFNDBINOP_FN (el_div, float_matrix, float_complex_matrix, float_array,
00125                float_complex_array, quotient)
00126 DEFNDBINOP_FN (el_pow, float_matrix, float_complex_matrix, float_array,
00127                float_complex_array, elem_xpow)
00128 
00129 DEFBINOP (el_ldiv, float_matrix, float_complex_matrix)
00130 {
00131   CAST_BINOP_ARGS (const octave_float_matrix&,
00132                    const octave_float_complex_matrix&);
00133 
00134   return quotient (v2.float_complex_array_value (), v1.float_array_value ());
00135 }
00136 
00137 DEFNDBINOP_FN (el_and, float_matrix, float_complex_matrix, float_array,
00138                float_complex_array, mx_el_and)
00139 DEFNDBINOP_FN (el_or,  float_matrix, float_complex_matrix, float_array,
00140                float_complex_array, mx_el_or)
00141 
00142 DEFNDCATOP_FN (fm_fcm, float_matrix, float_complex_matrix, float_array,
00143                float_complex_array, concat)
00144 
00145 DEFNDCATOP_FN (m_fcm, matrix, float_complex_matrix, float_array,
00146                float_complex_array, concat)
00147 
00148 DEFNDCATOP_FN (fm_cm, float_matrix, complex_matrix, float_array,
00149                float_complex_array, concat)
00150 
00151 DEFCONV (float_complex_matrix_conv, float_matrix, float_complex_matrix)
00152 {
00153   CAST_CONV_ARG (const octave_float_matrix&);
00154 
00155   return new octave_float_complex_matrix (FloatComplexNDArray (v.float_array_value ()));
00156 }
00157 
00158 void
00159 install_fm_fcm_ops (void)
00160 {
00161   INSTALL_BINOP (op_add, octave_float_matrix, octave_float_complex_matrix, add);
00162   INSTALL_BINOP (op_sub, octave_float_matrix, octave_float_complex_matrix, sub);
00163   INSTALL_BINOP (op_mul, octave_float_matrix, octave_float_complex_matrix, mul);
00164   INSTALL_BINOP (op_div, octave_float_matrix, octave_float_complex_matrix, div);
00165   INSTALL_BINOP (op_pow, octave_float_matrix, octave_float_complex_matrix, pow);
00166   INSTALL_BINOP (op_ldiv, octave_float_matrix,
00167                  octave_float_complex_matrix, ldiv);
00168   INSTALL_BINOP (op_lt, octave_float_matrix, octave_float_complex_matrix, lt);
00169   INSTALL_BINOP (op_le, octave_float_matrix, octave_float_complex_matrix, le);
00170   INSTALL_BINOP (op_eq, octave_float_matrix, octave_float_complex_matrix, eq);
00171   INSTALL_BINOP (op_ge, octave_float_matrix, octave_float_complex_matrix, ge);
00172   INSTALL_BINOP (op_gt, octave_float_matrix, octave_float_complex_matrix, gt);
00173   INSTALL_BINOP (op_ne, octave_float_matrix, octave_float_complex_matrix, ne);
00174   INSTALL_BINOP (op_el_mul, octave_float_matrix,
00175                  octave_float_complex_matrix, el_mul);
00176   INSTALL_BINOP (op_el_div, octave_float_matrix,
00177                  octave_float_complex_matrix, el_div);
00178   INSTALL_BINOP (op_el_pow, octave_float_matrix,
00179                  octave_float_complex_matrix, el_pow);
00180   INSTALL_BINOP (op_el_ldiv, octave_float_matrix,
00181                  octave_float_complex_matrix, el_ldiv);
00182   INSTALL_BINOP (op_el_and, octave_float_matrix,
00183                  octave_float_complex_matrix, el_and);
00184   INSTALL_BINOP (op_el_or, octave_float_matrix,
00185                  octave_float_complex_matrix, el_or);
00186   INSTALL_BINOP (op_trans_mul, octave_float_matrix,
00187                  octave_float_complex_matrix, trans_mul);
00188   INSTALL_BINOP (op_herm_mul, octave_float_matrix,
00189                  octave_float_complex_matrix, trans_mul);
00190   INSTALL_BINOP (op_trans_ldiv, octave_float_matrix,
00191                  octave_float_complex_matrix, trans_ldiv);
00192   INSTALL_BINOP (op_herm_ldiv, octave_float_matrix,
00193                  octave_float_complex_matrix, trans_ldiv);
00194 
00195   INSTALL_CATOP (octave_float_matrix, octave_float_complex_matrix, fm_fcm);
00196   INSTALL_CATOP (octave_matrix, octave_float_complex_matrix, m_fcm);
00197   INSTALL_CATOP (octave_float_matrix, octave_complex_matrix, fm_cm);
00198 
00199   INSTALL_ASSIGNCONV (octave_float_matrix, octave_float_complex_matrix,
00200                       octave_float_complex_matrix);
00201   INSTALL_ASSIGNCONV (octave_matrix, octave_float_complex_matrix,
00202                       octave_complex_matrix);
00203 
00204   INSTALL_WIDENOP (octave_float_matrix, octave_float_complex_matrix,
00205                    float_complex_matrix_conv);
00206 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines