GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
intNDArray.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2004-2013 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_intNDArray_h)
24 #define octave_intNDArray_h 1
25 
26 #include "MArray.h"
27 #include "boolNDArray.h"
28 class NDArray;
29 
30 template <class T>
31 class
32 intNDArray : public MArray<T>
33 {
34 public:
35 
36  using typename MArray<T>::element_type;
37 
38  intNDArray (void) : MArray<T> () { }
39 
40  intNDArray (T val) : MArray<T> (dim_vector (1, 1), val) { }
41 
42  intNDArray (const dim_vector& dv) : MArray<T> (dv) { }
43 
44  intNDArray (const dim_vector& dv, T val)
45  : MArray<T> (dv, val) { }
46 
47  template <class U>
48  intNDArray (const Array<U>& a) : MArray<T> (a) { }
49 
50  template <class U>
51  intNDArray (const MArray<U>& a) : MArray<T> (a) { }
52 
53  template <class U>
54  intNDArray (const intNDArray<U>& a) : MArray<T> (a) { }
55 
57  {
59  return *this;
60  }
61 
62  boolNDArray operator ! (void) const;
63 
64  bool any_element_is_nan (void) const { return false; }
65  bool any_element_not_one_or_zero (void) const;
66 
67  intNDArray diag (octave_idx_type k = 0) const;
68 
70 
72  {
74  return *this;
75  }
76 
77  // FIXME: this is not quite the right thing.
78 
79  boolNDArray all (int dim = -1) const;
80  boolNDArray any (int dim = -1) const;
81 
82  intNDArray max (int dim = -1) const;
83  intNDArray max (Array<octave_idx_type>& index, int dim = -1) const;
84  intNDArray min (int dim = -1) const;
85  intNDArray min (Array<octave_idx_type>& index, int dim = -1) const;
86 
87  intNDArray cummax (int dim = -1) const;
88  intNDArray cummax (Array<octave_idx_type>& index, int dim = -1) const;
89  intNDArray cummin (int dim = -1) const;
90  intNDArray cummin (Array<octave_idx_type>& index, int dim = -1) const;
91 
92  intNDArray sum (int dim) const;
93  NDArray dsum (int dim) const;
94  intNDArray cumsum (int dim) const;
95 
96  intNDArray diff (octave_idx_type order = 1, int dim = -1) const;
97 
98  intNDArray abs (void) const;
99  intNDArray signum (void) const;
100 
101  intNDArray squeeze (void) const
102  { return intNDArray<T> (MArray<T>::squeeze ()); }
103 
104  intNDArray transpose (void) const
105  { return intNDArray<T> (MArray<T>::transpose ()); }
106 
107  intNDArray concat (const intNDArray<T>& rb,
108  const Array<octave_idx_type>& ra_idx);
109 
110  intNDArray& insert (const intNDArray<T>& a,
112  intNDArray& insert (const intNDArray<T>& a,
113  const Array<octave_idx_type>& ra_idx);
114 
115  static void increment_index (Array<octave_idx_type>& ra_idx,
116  const dim_vector& dimensions,
117  int start_dimension = 0);
118 
120  const dim_vector& dimensions);
121 };
122 
123 // i/o
124 
125 template <class T>
126 std::ostream& operator << (std::ostream& os, const intNDArray<T>& a);
127 
128 template <class T>
129 std::istream& operator >> (std::istream& is, intNDArray<T>& a);
130 
131 #endif