op-bm-b.cc

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2001-2012 Cai Jianming
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-bool.h"
00031 #include "ov-bool-mat.h"
00032 #include "ov-scalar.h"
00033 #include "ov-float.h"
00034 #include "ov-re-mat.h"
00035 #include "ov-flt-re-mat.h"
00036 #include "ov-str-mat.h"
00037 #include "ov-int8.h"
00038 #include "ov-int16.h"
00039 #include "ov-int32.h"
00040 #include "ov-int64.h"
00041 #include "ov-uint8.h"
00042 #include "ov-uint16.h"
00043 #include "ov-uint32.h"
00044 #include "ov-uint64.h"
00045 #include "ov-typeinfo.h"
00046 #include "ops.h"
00047 #include "xdiv.h"
00048 #include "xpow.h"
00049 
00050 // bool matrix by bool ops.
00051 
00052 DEFNDBINOP_FN (el_and, bool_matrix, bool, bool_array, bool, mx_el_and)
00053 DEFNDBINOP_FN (el_or, bool_matrix, bool, bool_array, bool, mx_el_or)
00054 
00055 DEFNDBINOP_FN (el_not_and, bool_matrix, bool, bool_array, bool, mx_el_not_and)
00056 DEFNDBINOP_FN (el_not_or, bool_matrix, bool, bool_array, bool, mx_el_not_or)
00057 
00058 DEFNDCATOP_FN (bm_b, bool_matrix, bool, bool_array, bool_array, concat)
00059 DEFNDCATOP_FN (bm_s, bool_matrix, scalar, array, array, concat)
00060 DEFNDCATOP_FN (m_b, matrix, bool, array, array, concat)
00061 DEFNDCATOP_FN (bm_f, bool_matrix, float_scalar, float_array, float_array, concat)
00062 DEFNDCATOP_FN (fm_b, float_matrix, bool, float_array, float_array, concat)
00063 
00064 DEFNDASSIGNOP_FN (assign, bool_matrix, bool, bool_array, assign)
00065 
00066 static octave_value
00067 oct_assignop_conv_and_assign (octave_base_value& a1,
00068                               const octave_value_list& idx,
00069                               const octave_base_value& a2)
00070 {
00071   octave_bool_matrix& v1 = dynamic_cast<octave_bool_matrix&> (a1);
00072 
00073   // FIXME -- perhaps add a warning for this conversion if the values
00074   // are not all 0 or 1?
00075 
00076   boolNDArray v2 = a2.bool_array_value (true);
00077 
00078   if (! error_state)
00079     v1.assign (idx, v2);
00080 
00081   return octave_value ();
00082 }
00083 
00084 void
00085 install_bm_b_ops (void)
00086 {
00087   INSTALL_BINOP (op_el_and, octave_bool_matrix, octave_bool, el_and);
00088   INSTALL_BINOP (op_el_or, octave_bool_matrix, octave_bool, el_or);
00089   INSTALL_BINOP (op_el_not_and, octave_bool_matrix, octave_bool, el_not_and);
00090   INSTALL_BINOP (op_el_not_or, octave_bool_matrix, octave_bool, el_not_or);
00091 
00092   INSTALL_CATOP (octave_bool_matrix, octave_bool, bm_b);
00093   INSTALL_CATOP (octave_bool_matrix, octave_scalar, bm_s);
00094   INSTALL_CATOP (octave_matrix, octave_bool, m_b);
00095   INSTALL_CATOP (octave_bool_matrix, octave_float_scalar, bm_f);
00096   INSTALL_CATOP (octave_float_matrix, octave_bool, fm_b);
00097 
00098   INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_bool, assign);
00099 
00100   INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_scalar, conv_and_assign);
00101 
00102   INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_int8_scalar, conv_and_assign);
00103   INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_int16_scalar, conv_and_assign);
00104   INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_int32_scalar, conv_and_assign);
00105   INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_int64_scalar, conv_and_assign);
00106 
00107   INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_uint8_scalar, conv_and_assign);
00108   INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_uint16_scalar, conv_and_assign);
00109   INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_uint32_scalar, conv_and_assign);
00110   INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_uint64_scalar, conv_and_assign);
00111 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines