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_intNDArray_h)
00024 #define octave_intNDArray_h 1
00025
00026 #include "MArrayN.h"
00027 #include "boolNDArray.h"
00028 class NDArray;
00029
00030 template <class T>
00031 class
00032 intNDArray : public MArrayN<T>
00033 {
00034 public:
00035
00036 using MArrayN<T>::element_type;
00037
00038 intNDArray (void) : MArrayN<T> () { }
00039
00040 intNDArray (T val) : MArrayN<T> (dim_vector (1, 1), val) { }
00041
00042 intNDArray (const dim_vector& dv) : MArrayN<T> (dv) { }
00043
00044 intNDArray (const dim_vector& dv, T val)
00045 : MArrayN<T> (dv, val) { }
00046
00047 template <class U>
00048 explicit intNDArray (const Array<U>& a) : MArrayN<T> (a) { }
00049
00050 template <class U>
00051 intNDArray (const MArrayN<U>& a) : MArrayN<T> (a) { }
00052
00053 template <class U>
00054 intNDArray (const intNDArray<U>& a) : MArrayN<T> (a) { }
00055
00056 intNDArray& operator = (const intNDArray<T>& a)
00057 {
00058 MArrayN<T>::operator = (a);
00059 return *this;
00060 }
00061
00062 boolNDArray operator ! (void) const;
00063
00064 bool any_element_is_nan (void) const { return false; }
00065 bool any_element_not_one_or_zero (void) const;
00066
00067 intNDArray diag (octave_idx_type k = 0) const;
00068
00069 intNDArray& changesign (void)
00070 {
00071 MArrayN<T>::changesign ();
00072 return *this;
00073 }
00074
00075
00076
00077 boolNDArray all (int dim = -1) const;
00078 boolNDArray any (int dim = -1) const;
00079
00080 intNDArray max (int dim = 0) const;
00081 intNDArray max (Array<octave_idx_type>& index, int dim = 0) const;
00082 intNDArray min (int dim = 0) const;
00083 intNDArray min (Array<octave_idx_type>& index, int dim = 0) const;
00084
00085 intNDArray cummax (int dim = 0) const;
00086 intNDArray cummax (Array<octave_idx_type>& index, int dim = 0) const;
00087 intNDArray cummin (int dim = 0) const;
00088 intNDArray cummin (Array<octave_idx_type>& index, int dim = 0) const;
00089
00090 intNDArray sum (int dim) const;
00091 NDArray dsum (int dim) const;
00092 intNDArray cumsum (int dim) const;
00093
00094 intNDArray diff (octave_idx_type order = 1, int dim = 0) const;
00095
00096 intNDArray abs (void) const;
00097 intNDArray signum (void) const;
00098
00099 intNDArray squeeze (void) const
00100 { return intNDArray<T> (MArrayN<T>::squeeze ()); }
00101
00102 intNDArray transpose (void) const
00103 { return intNDArray<T> (MArrayN<T>::transpose ()); }
00104
00105 intNDArray concat (const intNDArray<T>& rb, const Array<octave_idx_type>& ra_idx);
00106
00107 intNDArray& insert (const intNDArray<T>& a, octave_idx_type r, octave_idx_type c);
00108 intNDArray& insert (const intNDArray<T>& a, const Array<octave_idx_type>& ra_idx);
00109
00110 static void increment_index (Array<octave_idx_type>& ra_idx,
00111 const dim_vector& dimensions,
00112 int start_dimension = 0);
00113
00114 static octave_idx_type compute_index (Array<octave_idx_type>& ra_idx,
00115 const dim_vector& dimensions);
00116
00117 static T resize_fill_value (void) { return 0; }
00118
00119 protected:
00120
00121 intNDArray (T *d, dim_vector& dv) : MArrayN<T> (d, dv) { }
00122 };
00123
00124
00125
00126 template <class T>
00127 std::ostream& operator << (std::ostream& os, const intNDArray<T>& a);
00128
00129 template <class T>
00130 std::istream& operator >> (std::istream& is, intNDArray<T>& a);
00131
00132 #endif
00133
00134
00135
00136
00137
00138