op-b-sbm.cc

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2004-2012 David Bateman
00004 Copyright (C) 1998-2004 Andy Adler
00005 
00006 This file is part of Octave.
00007 
00008 Octave is free software; you can redistribute it and/or modify it
00009 under the terms of the GNU General Public License as published by the
00010 Free Software Foundation; either version 3 of the License, or (at your
00011 option) any later version.
00012 
00013 Octave is distributed in the hope that it will be useful, but WITHOUT
00014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00015 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00016 for more details.
00017 
00018 You should have received a copy of the GNU General Public License
00019 along with Octave; see the file COPYING.  If not, see
00020 <http://www.gnu.org/licenses/>.
00021 
00022 */
00023 
00024 #ifdef HAVE_CONFIG_H
00025 #include <config.h>
00026 #endif
00027 
00028 #include "gripes.h"
00029 #include "oct-obj.h"
00030 #include "ov.h"
00031 #include "ov-typeinfo.h"
00032 #include "ov-bool.h"
00033 #include "ov-bool-mat.h"
00034 #include "ov-scalar.h"
00035 #include "ops.h"
00036 
00037 #include "ov-re-sparse.h"
00038 #include "ov-bool-sparse.h"
00039 
00040 // bool by sparse bool matrix ops.
00041 
00042 DEFBINOP_FN (ne, bool, sparse_bool_matrix, mx_el_ne)
00043 DEFBINOP_FN (eq, bool, sparse_bool_matrix, mx_el_eq)
00044 
00045 DEFBINOP_FN (el_and, bool, sparse_bool_matrix, mx_el_and)
00046 DEFBINOP_FN (el_or, bool, sparse_bool_matrix, mx_el_or)
00047 
00048 DEFCATOP (b_sbm, bool, sparse_bool_matrix)
00049 {
00050   CAST_BINOP_ARGS (octave_bool&, const octave_sparse_bool_matrix&);
00051   SparseBoolMatrix tmp (1, 1, v1.bool_value ());
00052   return octave_value (tmp. concat (v2.sparse_bool_matrix_value (),
00053                                     ra_idx));
00054 }
00055 
00056 DEFCATOP (b_sm, bool, sparse_matrix)
00057 {
00058   CAST_BINOP_ARGS (octave_bool&, const octave_sparse_matrix&);
00059   SparseMatrix tmp (1, 1, v1.scalar_value ());
00060   return octave_value (tmp. concat (v2.sparse_matrix_value (), ra_idx));
00061 }
00062 
00063 DEFCATOP (s_sbm, scalar, sparse_bool_matrix)
00064 {
00065   CAST_BINOP_ARGS (octave_scalar&, const octave_sparse_bool_matrix&);
00066   SparseMatrix tmp (1, 1, v1.scalar_value ());
00067   return octave_value(tmp. concat (v2.sparse_matrix_value (), ra_idx));
00068 }
00069 
00070 DEFCONV (sparse_bool_matrix_conv, bool, sparse_bool_matrix)
00071 {
00072   CAST_CONV_ARG (const octave_bool&);
00073 
00074   return new octave_sparse_bool_matrix
00075     (SparseBoolMatrix (1, 1, v.bool_value ()));
00076 }
00077 
00078 void
00079 install_b_sbm_ops (void)
00080 {
00081   INSTALL_BINOP (op_eq, octave_bool, octave_sparse_bool_matrix, eq);
00082   INSTALL_BINOP (op_ne, octave_bool, octave_sparse_bool_matrix, ne);
00083 
00084   INSTALL_BINOP (op_el_and, octave_bool, octave_sparse_bool_matrix, el_and);
00085   INSTALL_BINOP (op_el_or, octave_bool, octave_sparse_bool_matrix, el_or);
00086 
00087   INSTALL_CATOP (octave_bool, octave_sparse_bool_matrix, b_sbm);
00088   INSTALL_CATOP (octave_bool, octave_sparse_matrix, b_sm);
00089   INSTALL_CATOP (octave_scalar, octave_sparse_bool_matrix, s_sbm);
00090 
00091   INSTALL_ASSIGNCONV (octave_bool, octave_sparse_bool_matrix,
00092                       octave_bool_matrix);
00093 
00094   INSTALL_WIDENOP (octave_bool, octave_sparse_bool_matrix, sparse_bool_matrix_conv);
00095 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines