GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
intNDArray.h
Go to the documentation of this file.
1////////////////////////////////////////////////////////////////////////
2//
3// Copyright (C) 2004-2025 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
36template <typename T>
37class intNDArray : public MArray<T>
38{
39public:
40
41 using typename MArray<T>::element_type;
42
43 intNDArray () = default;
44
45 intNDArray (const intNDArray<T>& a) = default;
46
47 intNDArray& operator = (const intNDArray<T>& a) = default;
48
49 ~intNDArray () = default;
50
51 intNDArray (T val) : MArray<T> (dim_vector (1, 1), val) { }
52
53 intNDArray (const dim_vector& dv) : MArray<T> (dv) { }
54
55 intNDArray (const dim_vector& dv, T val)
56 : MArray<T> (dv, val) { }
57
58 template <typename U>
59 intNDArray (const Array<U>& a) : MArray<T> (a) { }
60
61 template <typename U>
62 intNDArray (const MArray<U>& a) : MArray<T> (a) { }
63
64 template <typename U>
65 intNDArray (const intNDArray<U>& a) : MArray<T> (a) { }
66
68
69 bool any_element_is_nan () const { return false; }
71
73
75
77 {
79 return *this;
80 }
81
82 // FIXME: this is not quite the right thing.
83
84 OCTAVE_API boolNDArray all (int dim = -1) const;
85 OCTAVE_API boolNDArray any (int dim = -1) const;
86
87 OCTAVE_API intNDArray max (int dim = -1) const;
89 max (Array<octave_idx_type>& index, int dim = -1) const;
90 OCTAVE_API intNDArray min (int dim = -1) const;
92 min (Array<octave_idx_type>& index, int dim = -1) const;
93
94 OCTAVE_API intNDArray cummax (int dim = -1) const;
96 cummax (Array<octave_idx_type>& index, int dim = -1) const;
97 OCTAVE_API intNDArray cummin (int dim = -1) const;
99 cummin (Array<octave_idx_type>& index, int dim = -1) const;
100
101 OCTAVE_API intNDArray prod (int dim) const;
102 OCTAVE_API intNDArray sum (int dim) const;
103 OCTAVE_API NDArray dsum (int dim) const;
104 OCTAVE_API intNDArray cumsum (int dim) const;
105
106 OCTAVE_API intNDArray diff (octave_idx_type order = 1, int dim = -1) const;
107
108 OCTAVE_API intNDArray abs () const;
110
112 { return intNDArray<T> (MArray<T>::squeeze ()); }
113
116
119
124
125 static OCTAVE_API void
127 const dim_vector& dimensions, int start_dimension = 0);
128
131};
132
133// i/o
134
135template <typename T>
136OCTAVE_API std::ostream&
137operator << (std::ostream& os, const intNDArray<T>& a);
138
139template <typename T>
140OCTAVE_API std::istream&
141operator >> (std::istream& is, intNDArray<T>& a);
142
143#endif
N Dimensional Array with copy-on-write semantics.
Definition Array.h:130
Array< T, Alloc > index(const octave::idx_vector &i) const
Indexing without resizing.
T element_type
Definition Array.h:234
Template for N-dimensional array classes with like-type math operators.
Definition MArray.h:61
void changesign()
Definition MArray.cc:217
Vector representing the dimensions (size) of an Array.
Definition dim-vector.h:90
boolNDArray any(int dim=-1) const
Definition intNDArray.cc:91
intNDArray & insert(const intNDArray< T > &a, octave_idx_type r, octave_idx_type c)
intNDArray max(int dim=-1) const
intNDArray(T val)
Definition intNDArray.h:51
static void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension=0)
Definition intNDArray.cc:98
~intNDArray()=default
intNDArray sum(int dim) const
intNDArray(const dim_vector &dv)
Definition intNDArray.h:53
boolNDArray operator!() const
Definition intNDArray.cc:39
intNDArray & changesign()
Definition intNDArray.h:76
intNDArray()=default
intNDArray min(int dim=-1) const
intNDArray abs() const
boolNDArray all(int dim=-1) const
Definition intNDArray.cc:84
bool any_element_not_one_or_zero() const
Definition intNDArray.cc:51
intNDArray concat(const intNDArray< T > &rb, const Array< octave_idx_type > &ra_idx)
intNDArray cummin(int dim=-1) const
intNDArray prod(int dim) const
intNDArray diag(octave_idx_type k=0) const
Definition intNDArray.cc:68
intNDArray(const dim_vector &dv, T val)
Definition intNDArray.h:55
bool any_element_is_nan() const
Definition intNDArray.h:69
intNDArray(const Array< U > &a)
Definition intNDArray.h:59
intNDArray signum() const
intNDArray(const intNDArray< T > &a)=default
NDArray dsum(int dim) const
static octave_idx_type compute_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions)
intNDArray squeeze() const
Definition intNDArray.h:111
intNDArray transpose() const
Definition intNDArray.h:114
intNDArray cummax(int dim=-1) const
intNDArray(const intNDArray< U > &a)
Definition intNDArray.h:65
intNDArray cumsum(int dim) const
intNDArray diff(octave_idx_type order=1, int dim=-1) const
intNDArray(const MArray< U > &a)
Definition intNDArray.h:62
intNDArray & operator=(const intNDArray< T > &a)=default
std::istream & operator>>(std::istream &is, intNDArray< T > &a)
std::ostream & operator<<(std::ostream &os, const intNDArray< T > &a)
#define OCTAVE_API
Definition main.in.cc:55
const octave_base_value const Array< octave_idx_type > & ra_idx