op-bm-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-mat.h"
00033 #include "boolMatrix.h"
00034 #include "ov-scalar.h"
00035 #include "ops.h"
00036 
00037 #include "ov-re-sparse.h"
00038 #include "ov-bool-sparse.h"
00039 #include "smx-bm-sbm.h"
00040 #include "smx-sbm-bm.h"
00041 
00042 // bool matrix by sparse bool matrix ops.
00043 
00044 DEFBINOP_FN (eq, bool_matrix, sparse_bool_matrix, mx_el_eq)
00045 DEFBINOP_FN (ne, bool_matrix, sparse_bool_matrix, mx_el_ne)
00046 
00047 DEFBINOP_FN (el_and, bool_matrix, sparse_bool_matrix, mx_el_and)
00048 DEFBINOP_FN (el_or,  bool_matrix, sparse_bool_matrix, mx_el_or)
00049 
00050 DEFCATOP (bm_sbm, bool_matrix, sparse_bool_matrix)
00051 {
00052   CAST_BINOP_ARGS (octave_bool_matrix&, const octave_sparse_bool_matrix&);
00053   SparseBoolMatrix tmp (v1.bool_matrix_value ());
00054   return octave_value (tmp. concat (v2.sparse_bool_matrix_value (),
00055                                     ra_idx));
00056 }
00057 
00058 DEFCATOP (m_sbm, matrix, sparse_bool_matrix)
00059 {
00060   CAST_BINOP_ARGS (octave_matrix&, const octave_sparse_bool_matrix&);
00061   SparseMatrix tmp (v1.matrix_value ());
00062   return octave_value (tmp. concat (v2.sparse_matrix_value (), ra_idx));
00063 }
00064 
00065 DEFCATOP (bm_sm, bool_matrix, sparse_matrix)
00066 {
00067   CAST_BINOP_ARGS (octave_bool_matrix&, const octave_sparse_matrix&);
00068   SparseMatrix tmp (v1.matrix_value ());
00069   return octave_value (tmp. concat (v2.sparse_matrix_value (), ra_idx));
00070 }
00071 
00072 DEFCONV (sparse_bool_matrix_conv, bool_matrix, sparse_bool_matrix)
00073 {
00074   CAST_CONV_ARG (const octave_bool_matrix&);
00075   return new octave_sparse_bool_matrix
00076     (SparseBoolMatrix (v.bool_matrix_value ()));
00077 }
00078 
00079 DEFNDASSIGNOP_FN (assign, bool_matrix, sparse_bool_matrix, bool_array, assign)
00080 
00081 void
00082 install_bm_sbm_ops (void)
00083 {
00084   INSTALL_BINOP (op_eq, octave_bool_matrix, octave_sparse_bool_matrix, eq);
00085   INSTALL_BINOP (op_ne, octave_bool_matrix, octave_sparse_bool_matrix, ne);
00086 
00087   INSTALL_BINOP (op_el_and, octave_bool_matrix, octave_sparse_bool_matrix,
00088                  el_and);
00089   INSTALL_BINOP (op_el_or, octave_bool_matrix, octave_sparse_bool_matrix,
00090                  el_or);
00091 
00092   INSTALL_CATOP (octave_bool_matrix, octave_sparse_bool_matrix, bm_sbm);
00093   INSTALL_CATOP (octave_bool_matrix, octave_sparse_matrix, bm_sm);
00094   INSTALL_CATOP (octave_matrix, octave_sparse_bool_matrix, m_sbm);
00095 
00096   INSTALL_ASSIGNOP (op_asn_eq, octave_bool_matrix, octave_sparse_bool_matrix,
00097                     assign)
00098   INSTALL_ASSIGNCONV (octave_bool_matrix, octave_sparse_bool_matrix,
00099                       octave_bool_matrix);
00100 
00101   INSTALL_WIDENOP (octave_bool_matrix, octave_sparse_bool_matrix,
00102                    sparse_bool_matrix_conv);
00103 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines