00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
00031 #include "boolMatrix.h"
00032
00033 class
00034 OCTAVE_API
00035 boolNDArray : public Array<bool>
00036 {
00037 public:
00038
00039 typedef boolMatrix matrix_type;
00040
00041 boolNDArray (void) : Array<bool> () { }
00042
00043 boolNDArray (const dim_vector& dv) : Array<bool> (dv) { }
00044
00045 boolNDArray (const dim_vector& dv, const bool& val)
00046 : Array<bool> (dv, val) { }
00047
00048 boolNDArray (const boolNDArray& a) : Array<bool> (a) { }
00049
00050 boolNDArray (const boolMatrix& a) : Array<bool> (a) { }
00051
00052 boolNDArray (const Array<bool>& a) : Array<bool> (a) { }
00053
00054 boolNDArray& operator = (const boolNDArray& a)
00055 {
00056 Array<bool>::operator = (a);
00057 return *this;
00058 }
00059
00060
00061
00062 boolNDArray operator ! (void) const;
00063
00064 boolNDArray& invert (void);
00065
00066 bool any_element_is_nan (void) const { return false; }
00067
00068
00069
00070 boolNDArray all (int dim = -1) const;
00071 boolNDArray any (int dim = -1) const;
00072
00073 NDArray sum (int dim = -1) const;
00074 NDArray cumsum (int dim = -1) const;
00075
00076 boolNDArray concat (const boolNDArray& rb, const Array<octave_idx_type>& ra_idx);
00077
00078 boolNDArray& insert (const boolNDArray& a, octave_idx_type r, octave_idx_type c);
00079 boolNDArray& insert (const boolNDArray& a, const Array<octave_idx_type>& ra_idx);
00080
00081 boolMatrix matrix_value (void) const;
00082
00083 boolNDArray squeeze (void) const { return Array<bool>::squeeze (); }
00084
00085 static void increment_index (Array<octave_idx_type>& ra_idx,
00086 const dim_vector& dimensions,
00087 int start_dimension = 0);
00088
00089 static octave_idx_type compute_index (Array<octave_idx_type>& ra_idx,
00090 const dim_vector& dimensions);
00091
00092
00093
00094
00095
00096
00097 static bool resize_fill_value (void) { return false; }
00098
00099
00100
00101
00102 octave_idx_type nnz (void) const
00103 {
00104 octave_idx_type retval = 0;
00105
00106 const bool *d = this->data ();
00107
00108 octave_idx_type nel = this->numel ();
00109
00110 for (octave_idx_type i = 0; i < nel; i++)
00111 {
00112 if (d[i])
00113 retval++;
00114 }
00115
00116 return retval;
00117 }
00118
00119 boolNDArray diag (octave_idx_type k = 0) const;
00120
00121 private:
00122
00123 boolNDArray (bool *d, dim_vector& dv) : Array<bool> (d, dv) { }
00124 };
00125
00126 NDND_BOOL_OP_DECLS (boolNDArray, boolNDArray, OCTAVE_API)
00127 NDND_CMP_OP_DECLS (boolNDArray, boolNDArray, OCTAVE_API)
00128
00129 NDS_BOOL_OP_DECLS (boolNDArray, bool, OCTAVE_API)
00130 NDS_CMP_OP_DECLS (boolNDArray, bool, OCTAVE_API)
00131
00132 SND_BOOL_OP_DECLS (bool, boolNDArray, OCTAVE_API)
00133 SND_CMP_OP_DECLS (bool, boolNDArray, OCTAVE_API)
00134
00135 extern OCTAVE_API boolNDArray&
00136 mx_el_and_assign (boolNDArray& m, const boolNDArray& a);
00137 extern OCTAVE_API boolNDArray&
00138 mx_el_or_assign (boolNDArray& m, const boolNDArray& a);
00139
00140 #endif
00141
00142
00143
00144
00145
00146