GNU Octave  4.0.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-2015 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 prod (int dim) const;
93  intNDArray sum (int dim) const;
94  NDArray dsum (int dim) const;
95  intNDArray cumsum (int dim) const;
96 
97  intNDArray diff (octave_idx_type order = 1, int dim = -1) const;
98 
99  intNDArray abs (void) const;
100  intNDArray signum (void) const;
101 
102  intNDArray squeeze (void) const
103  { return intNDArray<T> (MArray<T>::squeeze ()); }
104 
105  intNDArray transpose (void) const
106  { return intNDArray<T> (MArray<T>::transpose ()); }
107 
108  intNDArray concat (const intNDArray<T>& rb,
110 
111  intNDArray& insert (const intNDArray<T>& a,
113  intNDArray& insert (const intNDArray<T>& a,
115 
117  const dim_vector& dimensions,
118  int start_dimension = 0);
119 
121  const dim_vector& dimensions);
122 };
123 
124 // i/o
125 
126 template <class T>
127 std::ostream& operator << (std::ostream& os, const intNDArray<T>& a);
128 
129 template <class T>
130 std::istream& operator >> (std::istream& is, intNDArray<T>& a);
131 
132 #endif
dim_vector dimensions
Definition: Array.h:127
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:178
intNDArray(T val)
Definition: intNDArray.h:40
intNDArray transpose(void) const
Definition: intNDArray.h:105
NDArray cumsum(int dim=-1) const
Definition: dNDArray.cc:659
const octave_base_value const Array< octave_idx_type > & ra_idx
MArray squeeze(void) const
Definition: MArray.h:81
NDArray & operator=(const NDArray &a)
Definition: dNDArray.h:67
NDArray prod(int dim=-1) const
Definition: dNDArray.cc:665
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:664
MArray< T > transpose(void) const
Definition: MArray.h:83
Definition: MArray.h:36
intNDArray(const Array< U > &a)
Definition: intNDArray.h:48
void changesign(void)
Definition: MArray.cc:208
intNDArray & changesign(void)
Definition: intNDArray.h:71
bool any_element_not_one_or_zero(void) const
Definition: dNDArray.cc:576
double signum(double x)
Definition: lo-mappers.cc:80
bool any_element_is_nan(void) const
Definition: intNDArray.h:64
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
Definition: Array-util.cc:59
intNDArray(const MArray< U > &a)
Definition: intNDArray.h:51
NDArray & insert(const NDArray &a, octave_idx_type r, octave_idx_type c)
Definition: dNDArray.cc:807
intNDArray(const dim_vector &dv)
Definition: intNDArray.h:42
NDArray cummax(int dim=-1) const
Definition: dNDArray.cc:713
intNDArray(const dim_vector &dv, T val)
Definition: intNDArray.h:44
intNDArray squeeze(void) const
Definition: intNDArray.h:102
intNDArray(void)
Definition: intNDArray.h:38
intNDArray(const intNDArray< U > &a)
Definition: intNDArray.h:54
Handles the reference counting for all the derived classes.
Definition: Array.h:45
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:233
boolNDArray all(int dim=-1) const
Definition: dNDArray.cc:641
NDArray cummin(int dim=-1) const
Definition: dNDArray.cc:725
NDArray sum(int dim=-1) const
Definition: dNDArray.cc:671
boolNDArray any(int dim=-1) const
Definition: dNDArray.cc:647
NDArray diag(octave_idx_type k=0) const
Definition: dNDArray.cc:860
T element_type
Definition: Array.h:118
std::istream & operator>>(std::istream &is, intNDArray< T > &a)
Definition: intNDArray.cc:156
octave_value operator!(const octave_value &a)
Definition: ov.h:1293
T abs(T x)
Definition: pr-output.cc:3062
MArray< T > & operator=(const MArray< T > &a)
Definition: MArray.h:65
NDArray diff(octave_idx_type order=1, int dim=-1) const
Definition: dNDArray.cc:737
Array< double > index(const idx_vector &i) const
Indexing without resizing.
charNDArray min(char d, const charNDArray &m)
Definition: chNDArray.cc:210