GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
intNDArray.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 2004-2021 The Octave Project Developers
4 //
5 // See the file COPYRIGHT.md in the top-level directory of this
6 // distribution or <https://octave.org/copyright/>.
7 //
8 // This file is part of Octave.
9 //
10 // Octave is free software: you can redistribute it and/or modify it
11 // under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // Octave is distributed in the hope that it will be useful, but
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU General Public License for more details.
19 //
20 // You should have received a copy of the GNU General Public License
21 // along with Octave; see the file COPYING. If not, see
22 // <https://www.gnu.org/licenses/>.
23 //
24 ////////////////////////////////////////////////////////////////////////
25 
26 #if ! defined (octave_intNDArray_h)
27 #define octave_intNDArray_h 1
28 
29 #include "octave-config.h"
30 
31 #include "MArray.h"
32 #include "boolNDArray.h"
33 
34 class NDArray;
35 
36 template <typename T>
37 class
38 intNDArray : public MArray<T>
39 {
40 public:
41 
42  using typename MArray<T>::element_type;
43 
44  intNDArray (void) = default;
45 
46  intNDArray (const intNDArray<T>& a) = default;
47 
48  intNDArray& operator = (const intNDArray<T>& a) = default;
49 
50  ~intNDArray (void) = default;
51 
52  intNDArray (T val) : MArray<T> (dim_vector (1, 1), val) { }
53 
54  intNDArray (const dim_vector& dv) : MArray<T> (dv) { }
55 
56  intNDArray (const dim_vector& dv, T val)
57  : MArray<T> (dv, val) { }
58 
59  template <typename U>
60  intNDArray (const Array<U>& a) : MArray<T> (a) { }
61 
62  template <typename U>
63  intNDArray (const MArray<U>& a) : MArray<T> (a) { }
64 
65  template <typename U>
66  intNDArray (const intNDArray<U>& a) : MArray<T> (a) { }
67 
68  boolNDArray operator ! (void) const;
69 
70  bool any_element_is_nan (void) const { return false; }
71  bool any_element_not_one_or_zero (void) const;
72 
73  intNDArray diag (octave_idx_type k = 0) const;
74 
76 
78  {
80  return *this;
81  }
82 
83  // FIXME: this is not quite the right thing.
84 
85  boolNDArray all (int dim = -1) const;
86  boolNDArray any (int dim = -1) const;
87 
88  intNDArray max (int dim = -1) const;
89  intNDArray max (Array<octave_idx_type>& index, int dim = -1) const;
90  intNDArray min (int dim = -1) const;
91  intNDArray min (Array<octave_idx_type>& index, int dim = -1) const;
92 
93  intNDArray cummax (int dim = -1) const;
94  intNDArray cummax (Array<octave_idx_type>& index, int dim = -1) const;
95  intNDArray cummin (int dim = -1) const;
96  intNDArray cummin (Array<octave_idx_type>& index, int dim = -1) const;
97 
98  intNDArray prod (int dim) const;
99  intNDArray sum (int dim) const;
100  NDArray dsum (int dim) const;
101  intNDArray cumsum (int dim) const;
102 
103  intNDArray diff (octave_idx_type order = 1, int dim = -1) const;
104 
105  intNDArray abs (void) const;
106  intNDArray signum (void) const;
107 
108  intNDArray squeeze (void) const
109  { return intNDArray<T> (MArray<T>::squeeze ()); }
110 
111  intNDArray transpose (void) const
112  { return intNDArray<T> (MArray<T>::transpose ()); }
113 
114  intNDArray concat (const intNDArray<T>& rb,
116 
117  intNDArray& insert (const intNDArray<T>& a,
119  intNDArray& insert (const intNDArray<T>& a,
121 
123  const dim_vector& dimensions,
124  int start_dimension = 0);
125 
127  const dim_vector& dimensions);
128 };
129 
130 // i/o
131 
132 template <typename T>
133 std::ostream& operator << (std::ostream& os, const intNDArray<T>& a);
134 
135 template <typename T>
136 std::istream& operator >> (std::istream& is, intNDArray<T>& a);
137 
138 #endif
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:177
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
Definition: Array-util.cc:60
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:418
charNDArray max(char d, const charNDArray &m)
Definition: chNDArray.cc:230
charNDArray min(char d, const charNDArray &m)
Definition: chNDArray.cc:207
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:128
dim_vector dimensions
Definition: Array.h:217
Array< double > index(const idx_vector &i) const
Indexing without resizing.
Definition: Array.cc:698
T element_type
Definition: Array.h:202
Template for N-dimensional array classes with like-type math operators.
Definition: MArray.h:63
void changesign(void)
Definition: MArray.cc:204
NDArray diag(octave_idx_type k=0) const
Definition: dNDArray.cc:609
NDArray diff(octave_idx_type order=1, int dim=-1) const
Definition: dNDArray.cc:491
NDArray cumsum(int dim=-1) const
Definition: dNDArray.cc:413
bool any_element_not_one_or_zero(void) const
Definition: dNDArray.cc:330
NDArray cummax(int dim=-1) const
Definition: dNDArray.cc:467
NDArray & operator=(const NDArray &a)
Definition: dNDArray.h:72
NDArray prod(int dim=-1) const
Definition: dNDArray.cc:419
NDArray cummin(int dim=-1) const
Definition: dNDArray.cc:479
boolNDArray all(int dim=-1) const
Definition: dNDArray.cc:395
NDArray & insert(const NDArray &a, octave_idx_type r, octave_idx_type c)
Definition: dNDArray.cc:556
boolNDArray any(int dim=-1) const
Definition: dNDArray.cc:401
NDArray sum(int dim=-1) const
Definition: dNDArray.cc:425
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:95
intNDArray(T val)
Definition: intNDArray.h:52
intNDArray(const dim_vector &dv)
Definition: intNDArray.h:54
intNDArray(const dim_vector &dv, T val)
Definition: intNDArray.h:56
~intNDArray(void)=default
intNDArray(const Array< U > &a)
Definition: intNDArray.h:60
intNDArray(const intNDArray< T > &a)=default
intNDArray(void)=default
intNDArray squeeze(void) const
Definition: intNDArray.h:108
bool any_element_is_nan(void) const
Definition: intNDArray.h:70
intNDArray(const intNDArray< U > &a)
Definition: intNDArray.h:66
intNDArray transpose(void) const
Definition: intNDArray.h:111
intNDArray(const MArray< U > &a)
Definition: intNDArray.h:63
intNDArray & changesign(void)
Definition: intNDArray.h:77
std::ostream & operator<<(std::ostream &os, const intNDArray< T > &a)
Definition: intNDArray.cc:145
std::istream & operator>>(std::istream &is, intNDArray< T > &a)
Definition: intNDArray.cc:157
T octave_idx_type m
Definition: mx-inlines.cc:773
octave_idx_type n
Definition: mx-inlines.cc:753
T * r
Definition: mx-inlines.cc:773
double signum(double x)
Definition: lo-mappers.h:222
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_value operator!(const octave_value &a)
Definition: ov.h:1536
static T abs(T x)
Definition: pr-output.cc:1678