GNU Octave  8.1.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-2023 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 "intNDArray-fwd.h"
32 #include "mx-fwd.h"
33 #include "MArray.h"
34 #include "boolNDArray.h"
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 
69 
70  bool any_element_is_nan (void) const { return false; }
71  OCTAVE_API bool any_element_not_one_or_zero (void) const;
72 
73  OCTAVE_API 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  OCTAVE_API boolNDArray all (int dim = -1) const;
86  OCTAVE_API boolNDArray any (int dim = -1) const;
87 
88  OCTAVE_API intNDArray max (int dim = -1) const;
90  max (Array<octave_idx_type>& index, int dim = -1) const;
91  OCTAVE_API intNDArray min (int dim = -1) const;
93  min (Array<octave_idx_type>& index, int dim = -1) const;
94 
95  OCTAVE_API intNDArray cummax (int dim = -1) const;
97  cummax (Array<octave_idx_type>& index, int dim = -1) const;
98  OCTAVE_API intNDArray cummin (int dim = -1) const;
100  cummin (Array<octave_idx_type>& index, int dim = -1) const;
101 
102  OCTAVE_API intNDArray prod (int dim) const;
103  OCTAVE_API intNDArray sum (int dim) const;
104  OCTAVE_API NDArray dsum (int dim) const;
105  OCTAVE_API intNDArray cumsum (int dim) const;
106 
107  OCTAVE_API intNDArray diff (octave_idx_type order = 1, int dim = -1) const;
108 
109  OCTAVE_API intNDArray abs (void) const;
110  OCTAVE_API intNDArray signum (void) const;
111 
112  intNDArray squeeze (void) const
113  { return intNDArray<T> (MArray<T>::squeeze ()); }
114 
115  intNDArray transpose (void) const
116  { return intNDArray<T> (MArray<T>::transpose ()); }
117 
120 
122  insert (const intNDArray<T>& a, octave_idx_type r, octave_idx_type c);
124  insert (const intNDArray<T>& a, const Array<octave_idx_type>& ra_idx);
125 
126  static OCTAVE_API void
128  const dim_vector& dimensions, int start_dimension = 0);
129 
132 };
133 
134 // i/o
135 
136 template <typename T>
137 OCTAVE_API std::ostream&
138 operator << (std::ostream& os, const intNDArray<T>& a);
139 
140 template <typename T>
141 OCTAVE_API std::istream&
142 operator >> (std::istream& is, intNDArray<T>& a);
143 
144 #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:130
T element_type
Definition: Array.h:230
Template for N-dimensional array classes with like-type math operators.
Definition: MArray.h:63
OCTARRAY_API void changesign(void)
Definition: MArray.cc:216
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:94
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:112
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:115
intNDArray(const MArray< U > &a)
Definition: intNDArray.h:63
intNDArray & changesign(void)
Definition: intNDArray.h:77
class OCTAVE_API intNDArray
OCTAVE_API std::ostream & operator<<(std::ostream &os, const intNDArray< T > &a)
Definition: intNDArray.cc:145
OCTAVE_API std::istream & operator>>(std::istream &is, intNDArray< T > &a)
Definition: intNDArray.cc:157
double signum(double x)
Definition: lo-mappers.h:229
#define OCTAVE_API
Definition: main.in.cc:55
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
const octave_base_value const Array< octave_idx_type > & ra_idx
octave_value operator!(const octave_value &a)
Definition: ov.h:1838
static T abs(T x)
Definition: pr-output.cc:1678