boolSparse.h

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 #if !defined (octave_boolSparse_h)
00025 #define octave_boolSparse_h 1
00026 
00027 #include "Sparse.h"
00028 #include "MSparse-defs.h"
00029 #include "Sparse-op-defs.h"
00030 
00031 class SparseMatrix;
00032 
00033 class
00034 OCTAVE_API
00035 SparseBoolMatrix : public Sparse<bool>
00036 {
00037 public:
00038 
00039   SparseBoolMatrix (void) : Sparse<bool> () { }
00040 
00041   SparseBoolMatrix (octave_idx_type r, octave_idx_type c) : Sparse<bool> (r, c) { }
00042 
00043   explicit SparseBoolMatrix (octave_idx_type r, octave_idx_type c, bool val)
00044     : Sparse<bool> (r, c, val) { }
00045 
00046   SparseBoolMatrix (const dim_vector& dv, octave_idx_type nz = 0) :
00047     Sparse<bool> (dv, nz) { }
00048 
00049   SparseBoolMatrix (const Sparse<bool>& a) : Sparse<bool> (a) { }
00050 
00051   SparseBoolMatrix (const SparseBoolMatrix& a) : Sparse<bool> (a) { }
00052 
00053   SparseBoolMatrix (const SparseBoolMatrix& a, const dim_vector& dv)
00054     : Sparse<bool> (a, dv) { }
00055 
00056   explicit SparseBoolMatrix (const boolMatrix& a) : Sparse<bool> (a) { }
00057 
00058   explicit SparseBoolMatrix (const boolNDArray& a) : Sparse<bool> (a) { }
00059 
00060   explicit SparseBoolMatrix (const PermMatrix& a) : Sparse<bool> (a) { };
00061 
00062   SparseBoolMatrix (const Array<bool>& a, const idx_vector& r,
00063                     const idx_vector& c, octave_idx_type nr = -1,
00064                     octave_idx_type nc = -1, bool sum_terms = true,
00065                     octave_idx_type nzm = -1)
00066     : Sparse<bool> (a, r, c, nr, nc, sum_terms, nzm) { }
00067 
00068   SparseBoolMatrix (octave_idx_type r, octave_idx_type c, octave_idx_type num_nz) : Sparse<bool> (r, c, num_nz) { }
00069 
00070   SparseBoolMatrix& operator = (const SparseBoolMatrix& a)
00071     {
00072       Sparse<bool>::operator = (a);
00073       return *this;
00074     }
00075 
00076   bool operator == (const SparseBoolMatrix& a) const;
00077   bool operator != (const SparseBoolMatrix& a) const;
00078 
00079   SparseBoolMatrix transpose (void) const
00080     { return Sparse<bool>::transpose (); }
00081 
00082   // destructive insert/delete/reorder operations
00083 
00084   SparseBoolMatrix& insert (const SparseBoolMatrix& a, octave_idx_type r, octave_idx_type c);
00085 
00086   SparseBoolMatrix& insert (const SparseBoolMatrix& a, const Array<octave_idx_type>& indx);
00087 
00088   SparseBoolMatrix concat (const SparseBoolMatrix& rb,
00089                            const Array<octave_idx_type>& ra_idx);
00090 
00091   SparseBoolMatrix diag (octave_idx_type k = 0) const;
00092 
00093   boolMatrix matrix_value (void) const;
00094 
00095   SparseBoolMatrix squeeze (void) const;
00096 
00097   SparseBoolMatrix index (const idx_vector& i, bool resize_ok) const;
00098 
00099   SparseBoolMatrix index (const idx_vector& i, const idx_vector& j, bool resize_ok) const;
00100 
00101   SparseBoolMatrix reshape (const dim_vector& new_dims) const;
00102 
00103   SparseBoolMatrix permute (const Array<octave_idx_type>& vec, bool inv = false) const;
00104 
00105   SparseBoolMatrix ipermute (const Array<octave_idx_type>& vec) const;
00106 
00107   // unary operations
00108 
00109   SparseBoolMatrix operator ! (void) const;
00110 
00111   // other operations
00112 
00113   SparseBoolMatrix all (int dim = -1) const;
00114   SparseBoolMatrix any (int dim = -1) const;
00115   SparseMatrix sum (int dim = -1) const;
00116 
00117   // i/o
00118 
00119   friend OCTAVE_API std::ostream& operator << (std::ostream& os, const SparseBoolMatrix& a);
00120   friend OCTAVE_API std::istream& operator >> (std::istream& is, SparseBoolMatrix& a);
00121 };
00122 
00123 SPARSE_SMS_EQNE_OP_DECLS (SparseBoolMatrix, bool, OCTAVE_API)
00124 SPARSE_SMS_BOOL_OP_DECLS (SparseBoolMatrix, bool, OCTAVE_API)
00125 
00126 SPARSE_SSM_EQNE_OP_DECLS (bool, SparseBoolMatrix, OCTAVE_API)
00127 SPARSE_SSM_BOOL_OP_DECLS (bool, SparseBoolMatrix, OCTAVE_API)
00128 
00129 SPARSE_SMSM_EQNE_OP_DECLS (SparseBoolMatrix, SparseBoolMatrix, OCTAVE_API)
00130 SPARSE_SMSM_BOOL_OP_DECLS (SparseBoolMatrix, SparseBoolMatrix, OCTAVE_API)
00131 
00132 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines