op-range.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-range.h"
00031 #include "ov-ch-mat.h"
00032 #include "ov-scalar.h"
00033 #include "ov-re-mat.h"
00034 #include "ov-flt-re-mat.h"
00035 #include "ov-complex.h"
00036 #include "ov-cx-mat.h"
00037 #include "ov-bool.h"
00038 #include "ov-bool-mat.h"
00039 #include "ov-typeinfo.h"
00040 #include "ov-null-mat.h"
00041 #include "ops.h"
00042 #include "xpow.h"
00043 
00044 // range unary ops.
00045 
00046 DEFUNOP (not, range)
00047 {
00048   CAST_UNOP_ARG (const octave_range&);
00049 
00050   return octave_value (! v.matrix_value());
00051 }
00052 
00053 DEFUNOP_OP (uplus, range, /* no-op */)
00054 DEFUNOP_OP (uminus, range, -)
00055 
00056 DEFUNOP (transpose, range)
00057 {
00058   CAST_UNOP_ARG (const octave_range&);
00059 
00060   return octave_value (v.matrix_value().transpose ());
00061 }
00062 
00063 DEFBINOP_OP (addrs, range, scalar, +)
00064 DEFBINOP_OP (addsr, scalar, range, +)
00065 DEFBINOP_OP (subrs, range, scalar, -)
00066 DEFBINOP_OP (subsr, scalar, range, -)
00067 DEFBINOP_OP (mulrs, range, scalar, *)
00068 DEFBINOP_OP (mulsr, scalar, range, *)
00069 
00070 DEFBINOP_FN (el_powsr, scalar, range, elem_xpow)
00071 DEFBINOP_FN (el_powcsr, complex, range, elem_xpow)
00072 
00073 DEFNDCATOP_FN (r_r, range, range, array, array, concat)
00074 DEFNDCATOP_FN (r_s, range, scalar, array, array, concat)
00075 DEFNDCATOP_FN (r_m, range, matrix, array, array, concat)
00076 DEFNDCATOP_FN (r_cs, range, complex, array, complex_array, concat)
00077 DEFNDCATOP_FN (r_cm, range, complex_matrix, array, complex_array, concat)
00078 DEFNDCATOP_FN (r_b, range, bool, array, array, concat)
00079 DEFNDCATOP_FN (r_bm, range, bool_matrix, array, array, concat)
00080 DEFNDCATOP_FN (r_chm, range, char_matrix, array, char_array, concat)
00081 DEFNDCATOP_FN (s_r, scalar, range, array, array, concat)
00082 DEFNDCATOP_FN (m_r, matrix, range, array, array, concat)
00083 DEFNDCATOP_FN (cs_r, complex, range, complex_array, array, concat)
00084 DEFNDCATOP_FN (cm_r, complex_matrix, range, complex_array, array, concat)
00085 DEFNDCATOP_FN (b_r, bool, range, array, array, concat)
00086 DEFNDCATOP_FN (bm_r, bool_matrix, range, array, array, concat)
00087 DEFNDCATOP_FN (chm_r, char_matrix, range, char_array, array, concat)
00088 
00089 CONVDECL (range_to_matrix)
00090 {
00091   CAST_CONV_ARG (const octave_range&);
00092 
00093   return new octave_matrix (v.array_value ());
00094 }
00095 
00096 void
00097 install_range_ops (void)
00098 {
00099   INSTALL_UNOP (op_not, octave_range, not);
00100   INSTALL_UNOP (op_uplus, octave_range, uplus);
00101   INSTALL_UNOP (op_uminus, octave_range, uminus);
00102   INSTALL_UNOP (op_transpose, octave_range, transpose);
00103   INSTALL_UNOP (op_hermitian, octave_range, transpose);
00104 
00105   INSTALL_BINOP (op_add, octave_range, octave_scalar, addrs);
00106   INSTALL_BINOP (op_add, octave_scalar, octave_range, addsr);
00107   INSTALL_BINOP (op_sub, octave_range, octave_scalar, subrs);
00108   INSTALL_BINOP (op_sub, octave_scalar, octave_range, subsr);
00109   INSTALL_BINOP (op_mul, octave_range, octave_scalar, mulrs);
00110   INSTALL_BINOP (op_mul, octave_scalar, octave_range, mulsr);
00111 
00112   INSTALL_BINOP (op_el_pow, octave_scalar, octave_range, el_powsr);
00113   INSTALL_BINOP (op_el_pow, octave_complex, octave_range, el_powcsr);
00114 
00115   INSTALL_CATOP (octave_range, octave_range, r_r);
00116   INSTALL_CATOP (octave_range, octave_scalar, r_s);
00117   INSTALL_CATOP (octave_range, octave_matrix, r_m);
00118   INSTALL_CATOP (octave_range, octave_complex, r_cs);
00119   INSTALL_CATOP (octave_range, octave_complex_matrix, r_cm);
00120   INSTALL_CATOP (octave_range, octave_bool, r_b);
00121   INSTALL_CATOP (octave_range, octave_bool_matrix, r_bm);
00122   INSTALL_CATOP (octave_range, octave_char_matrix, r_chm);
00123   INSTALL_CATOP (octave_scalar, octave_range, s_r);
00124   INSTALL_CATOP (octave_matrix, octave_range, m_r);
00125   INSTALL_CATOP (octave_complex, octave_range, cs_r);
00126   INSTALL_CATOP (octave_complex_matrix, octave_range, cm_r);
00127   INSTALL_CATOP (octave_bool, octave_range, b_r);
00128   INSTALL_CATOP (octave_bool_matrix, octave_range, bm_r);
00129   INSTALL_CATOP (octave_char_matrix, octave_range, chm_r);
00130 
00131   // FIXME -- this would be unneccessary if
00132   // octave_base_value::numeric_assign always tried converting lhs
00133   // before rhs.
00134 
00135   INSTALL_ASSIGNCONV (octave_range, octave_null_matrix, octave_matrix);
00136   INSTALL_ASSIGNCONV (octave_range, octave_null_str, octave_matrix);
00137   INSTALL_ASSIGNCONV (octave_range, octave_null_sq_str, octave_matrix);
00138 
00139   // However, this should probably be here just in case we need it.
00140 
00141   INSTALL_WIDENOP (octave_range, octave_matrix, range_to_matrix);
00142 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines