intNDArray.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 2004-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_intNDArray_h)
00024 #define octave_intNDArray_h 1
00025 
00026 #include "MArray.h"
00027 #include "boolNDArray.h"
00028 class NDArray;
00029 
00030 template <class T>
00031 class
00032 intNDArray : public MArray<T>
00033 {
00034 public:
00035 
00036   using typename MArray<T>::element_type;
00037 
00038   intNDArray (void) : MArray<T> () { }
00039 
00040   intNDArray (T val) : MArray<T> (dim_vector (1, 1), val) { }
00041 
00042   intNDArray (const dim_vector& dv) : MArray<T> (dv) { }
00043 
00044   intNDArray (const dim_vector& dv, T val)
00045     : MArray<T> (dv, val) { }
00046 
00047   template <class U>
00048   intNDArray (const Array<U>& a) : MArray<T> (a) { }
00049 
00050   template <class U>
00051   intNDArray (const MArray<U>& a) : MArray<T> (a) { }
00052 
00053   template <class U>
00054   intNDArray (const intNDArray<U>& a) : MArray<T> (a) { }
00055 
00056   intNDArray& operator = (const intNDArray<T>& a)
00057     {
00058       MArray<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       MArray<T>::changesign ();
00072       return *this;
00073     }
00074 
00075   // FIXME -- this is not quite the right thing.
00076 
00077   boolNDArray all (int dim = -1) const;
00078   boolNDArray any (int dim = -1) const;
00079 
00080   intNDArray max (int dim = -1) const;
00081   intNDArray max (Array<octave_idx_type>& index, int dim = -1) const;
00082   intNDArray min (int dim = -1) const;
00083   intNDArray min (Array<octave_idx_type>& index, int dim = -1) const;
00084 
00085   intNDArray cummax (int dim = -1) const;
00086   intNDArray cummax (Array<octave_idx_type>& index, int dim = -1) const;
00087   intNDArray cummin (int dim = -1) const;
00088   intNDArray cummin (Array<octave_idx_type>& index, int dim = -1) 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 = -1) const;
00095 
00096   intNDArray abs (void) const;
00097   intNDArray signum (void) const;
00098 
00099   intNDArray squeeze (void) const
00100     { return intNDArray<T> (MArray<T>::squeeze ()); }
00101 
00102   intNDArray transpose (void) const
00103     { return intNDArray<T> (MArray<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 };
00120 
00121 // i/o
00122 
00123 template <class T>
00124 std::ostream& operator << (std::ostream& os, const intNDArray<T>& a);
00125 
00126 template <class T>
00127 std::istream& operator >> (std::istream& is, intNDArray<T>& a);
00128 
00129 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines