boolNDArray.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2003-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 #if !defined (octave_boolNDArray_h)
00024 #define octave_boolNDArray_h 1
00025 
00026 #include "Array.h"
00027 
00028 #include "mx-defs.h"
00029 #include "mx-op-decl.h"
00030 #include "bsxfun-decl.h"
00031 
00032 #include "boolMatrix.h"
00033 
00034 
00035 class
00036 OCTAVE_API
00037 boolNDArray : public Array<bool>
00038 {
00039 public:
00040 
00041   typedef boolMatrix matrix_type;
00042 
00043   boolNDArray (void) : Array<bool> () { }
00044 
00045   boolNDArray (const dim_vector& dv) : Array<bool> (dv) { }
00046 
00047   boolNDArray (const dim_vector& dv, const bool& val)
00048     : Array<bool> (dv, val) { }
00049 
00050   boolNDArray (const boolNDArray& a) : Array<bool> (a) { }
00051 
00052   boolNDArray (const boolMatrix& a) : Array<bool> (a) { }
00053 
00054   boolNDArray (const Array<bool>& a) : Array<bool> (a) { }
00055 
00056   boolNDArray& operator = (const boolNDArray& a)
00057     {
00058       Array<bool>::operator = (a);
00059       return *this;
00060     }
00061 
00062   // unary operations
00063 
00064   boolNDArray operator ! (void) const;
00065 
00066   boolNDArray& invert (void);
00067 
00068   bool any_element_is_nan (void) const { return false; }
00069 
00070   // FIXME -- this is not quite the right thing.
00071 
00072   boolNDArray all (int dim = -1) const;
00073   boolNDArray any (int dim = -1) const;
00074 
00075   NDArray sum (int dim = -1) const;
00076   NDArray cumsum (int dim = -1) const;
00077 
00078   boolNDArray concat (const boolNDArray& rb, const Array<octave_idx_type>& ra_idx);
00079 
00080   boolNDArray& insert (const boolNDArray& a, octave_idx_type r, octave_idx_type c);
00081   boolNDArray& insert (const boolNDArray& a, const Array<octave_idx_type>& ra_idx);
00082 
00083   boolMatrix matrix_value (void) const;
00084 
00085   boolNDArray squeeze (void) const { return Array<bool>::squeeze (); }
00086 
00087   static void increment_index (Array<octave_idx_type>& ra_idx,
00088                                const dim_vector& dimensions,
00089                                int start_dimension = 0);
00090 
00091   static octave_idx_type compute_index (Array<octave_idx_type>& ra_idx,
00092                             const dim_vector& dimensions);
00093 
00094   // i/o
00095 
00096   // friend std::ostream& operator << (std::ostream& os, const NDArray& a);
00097   // friend std::istream& operator >> (std::istream& is, NDArray& a);
00098 
00099   static bool resize_fill_value (void) { return false; }
00100 
00101   //  bool all_elements_are_real (void) const;
00102   //  bool all_integers (double& max_val, double& min_val) const;
00103 
00104   boolNDArray diag (octave_idx_type k = 0) const;
00105 
00106 };
00107 
00108 NDND_BOOL_OP_DECLS (boolNDArray, boolNDArray, OCTAVE_API)
00109 NDND_CMP_OP_DECLS (boolNDArray, boolNDArray, OCTAVE_API)
00110 
00111 NDS_BOOL_OP_DECLS (boolNDArray, bool, OCTAVE_API)
00112 NDS_CMP_OP_DECLS (boolNDArray, bool, OCTAVE_API)
00113 
00114 SND_BOOL_OP_DECLS (bool, boolNDArray, OCTAVE_API)
00115 SND_CMP_OP_DECLS (bool, boolNDArray, OCTAVE_API)
00116 
00117 extern OCTAVE_API boolNDArray&
00118 mx_el_and_assign (boolNDArray& m, const boolNDArray& a);
00119 extern OCTAVE_API boolNDArray&
00120 mx_el_or_assign (boolNDArray& m, const boolNDArray& a);
00121 
00122 BSXFUN_OP_DECL (and, boolNDArray, OCTAVE_API);
00123 BSXFUN_OP_DECL (or, boolNDArray, OCTAVE_API);
00124 
00125 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines