GNU Octave  6.2.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
fNDArray.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-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_fNDArray_h)
27 #define octave_fNDArray_h 1
28 
29 #include "octave-config.h"
30 
31 #include "MArray.h"
32 #include "bsxfun-decl.h"
33 #include "mx-defs.h"
34 #include "mx-op-decl.h"
35 
36 template <typename T> class intNDArray;
37 
38 class
39 OCTAVE_API
41 {
42 public:
43 
44  FloatNDArray (void) : MArray<float> () { }
45 
46  FloatNDArray (const dim_vector& dv) : MArray<float> (dv) { }
47 
48  FloatNDArray (const dim_vector& dv, float val)
49  : MArray<float> (dv, val) { }
50 
51  FloatNDArray (const FloatNDArray& a) : MArray<float> (a) { }
52 
53  template <typename U>
54  FloatNDArray (const MArray<U>& a) : MArray<float> (a) { }
55 
56  template <typename U>
57  FloatNDArray (const Array<U>& a) : MArray<float> (a) { }
58 
59  template <typename U>
60  explicit FloatNDArray (const intNDArray<U>& a) : MArray<float> (a) { }
61 
62  FloatNDArray (const charNDArray&);
63 
65  {
67  return *this;
68  }
69 
70  // unary operations
71 
72  boolNDArray operator ! (void) const;
73 
74  bool any_element_is_negative (bool = false) const;
75  bool any_element_is_positive (bool = false) const;
76  bool any_element_is_nan (void) const;
77  bool any_element_is_inf_or_nan (void) const;
78  bool any_element_not_one_or_zero (void) const;
79  bool all_elements_are_zero (void) const;
80  bool all_elements_are_int_or_inf_or_nan (void) const;
81  bool all_integers (float& max_val, float& min_val) const;
82  bool all_integers (void) const;
83  bool too_large_for_float (void) const;
84 
85  // FIXME: this is not quite the right thing.
86 
87  boolNDArray all (int dim = -1) const;
88  boolNDArray any (int dim = -1) const;
89 
90  FloatNDArray cumprod (int dim = -1) const;
91  FloatNDArray cumsum (int dim = -1) const;
92  FloatNDArray prod (int dim = -1) const;
93  NDArray dprod (int dim = -1) const;
94  FloatNDArray sum (int dim = -1) const;
95  NDArray dsum (int dim = -1) const;
96  FloatNDArray sumsq (int dim = -1) const;
97  FloatNDArray concat (const FloatNDArray& rb,
101  charNDArray concat (const charNDArray& rb,
103 
104  FloatNDArray max (int dim = -1) const;
105  FloatNDArray max (Array<octave_idx_type>& index, int dim = -1) const;
106  FloatNDArray min (int dim = -1) const;
107  FloatNDArray min (Array<octave_idx_type>& index, int dim = -1) const;
108 
109  FloatNDArray cummax (int dim = -1) const;
110  FloatNDArray cummax (Array<octave_idx_type>& index, int dim = -1) const;
111  FloatNDArray cummin (int dim = -1) const;
112  FloatNDArray cummin (Array<octave_idx_type>& index, int dim = -1) const;
113 
114  FloatNDArray diff (octave_idx_type order = 1, int dim = -1) const;
115 
116  FloatNDArray& insert (const FloatNDArray& a,
118  FloatNDArray& insert (const FloatNDArray& a,
120 
121  FloatNDArray abs (void) const;
122  boolNDArray isnan (void) const;
123  boolNDArray isinf (void) const;
124  boolNDArray isfinite (void) const;
125 
126  FloatComplexNDArray fourier (int dim = 1) const;
127  FloatComplexNDArray ifourier (int dim = 1) const;
128 
129  FloatComplexNDArray fourier2d (void) const;
130  FloatComplexNDArray ifourier2d (void) const;
131 
132  FloatComplexNDArray fourierNd (void) const;
133  FloatComplexNDArray ifourierNd (void) const;
134 
135  friend OCTAVE_API FloatNDArray real (const FloatComplexNDArray& a);
136  friend OCTAVE_API FloatNDArray imag (const FloatComplexNDArray& a);
137 
138  friend class FloatComplexNDArray;
139 
140  FloatNDArray squeeze (void) const { return MArray<float>::squeeze (); }
141 
143  const dim_vector& dimensions,
144  int start_dimension = 0);
145 
147  const dim_vector& dimensions);
148 
149  // i/o
150 
151  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
152  const FloatNDArray& a);
153  friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatNDArray& a);
154 
155  FloatNDArray diag (octave_idx_type k = 0) const;
156 
158 
160  {
162  return *this;
163  }
164 
165 };
166 
167 // Publish externally used friend functions.
168 
169 extern OCTAVE_API FloatNDArray real (const FloatComplexNDArray& a);
170 extern OCTAVE_API FloatNDArray imag (const FloatComplexNDArray& a);
171 
172 MINMAX_DECLS (FloatNDArray, float, OCTAVE_API)
173 
174 NDS_CMP_OP_DECLS (FloatNDArray, float, OCTAVE_API)
175 NDS_BOOL_OP_DECLS (FloatNDArray, float, OCTAVE_API)
176 
177 SND_CMP_OP_DECLS (float, FloatNDArray, OCTAVE_API)
178 SND_BOOL_OP_DECLS (float, FloatNDArray, OCTAVE_API)
179 
182 
184 
185 BSXFUN_STDOP_DECLS (FloatNDArray, OCTAVE_API)
186 BSXFUN_STDREL_DECLS (FloatNDArray, OCTAVE_API)
187 
188 BSXFUN_OP_DECL (pow, FloatNDArray, OCTAVE_API)
190  FloatNDArray, OCTAVE_API)
192  FloatComplexNDArray, OCTAVE_API)
193 
194 #endif
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
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
#define MARRAY_FORWARD_DEFS(B, R, T)
Definition: MArray.h:128
std::istream & operator>>(std::istream &is, SparseBoolMatrix &a)
Definition: boolSparse.cc:281
#define BSXFUN_STDREL_DECLS(ARRAY, API)
Definition: bsxfun-decl.h:53
#define BSXFUN_STDOP_DECLS(ARRAY, API)
Definition: bsxfun-decl.h:38
#define BSXFUN_OP2_DECL(OP, ARRAY, ARRAY1, ARRAY2, API)
Definition: bsxfun-decl.h:32
#define BSXFUN_OP_DECL(OP, ARRAY, API)
Definition: bsxfun-decl.h:29
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:128
dim_vector dimensions
Definition: Array.h:217
Array< T > index(const idx_vector &i) const
Indexing without resizing.
Definition: Array.cc:698
FloatComplexNDArray diag(octave_idx_type k=0) const
Definition: fCNDArray.cc:599
FloatNDArray(const Array< U > &a)
Definition: fNDArray.h:57
FloatNDArray(void)
Definition: fNDArray.h:44
FloatNDArray squeeze(void) const
Definition: fNDArray.h:140
FloatNDArray(const MArray< U > &a)
Definition: fNDArray.h:54
FloatNDArray & changesign(void)
Definition: fNDArray.h:159
FloatNDArray(const dim_vector &dv, float val)
Definition: fNDArray.h:48
FloatNDArray(const dim_vector &dv)
Definition: fNDArray.h:46
FloatNDArray(const intNDArray< U > &a)
Definition: fNDArray.h:60
FloatNDArray(const FloatNDArray &a)
Definition: fNDArray.h:51
void changesign(void)
Definition: MArray.cc:204
MArray< T > & operator=(const MArray< T > &a)
Definition: MArray.h:87
MArray squeeze(void) const
Definition: MArray.h:103
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:95
boolNDArray any(int dim=-1) const
Definition: intNDArray.cc:91
intNDArray & insert(const intNDArray< T > &a, octave_idx_type r, octave_idx_type c)
Definition: intNDArray.cc:125
intNDArray sum(int dim) const
Definition: intNDArray.cc:222
boolNDArray all(int dim=-1) const
Definition: intNDArray.cc:84
intNDArray cummin(int dim=-1) const
Definition: intNDArray.cc:285
intNDArray prod(int dim) const
Definition: intNDArray.cc:215
intNDArray & operator=(const intNDArray< T > &a)=default
NDArray dsum(int dim) const
Definition: intNDArray.cc:229
bool any_element_is_nan(void) const
Definition: intNDArray.h:70
bool any_element_not_one_or_zero(void) const
Definition: intNDArray.cc:51
intNDArray cummax(int dim=-1) const
Definition: intNDArray.cc:271
intNDArray cumsum(int dim) const
Definition: intNDArray.cc:236
intNDArray diff(octave_idx_type order=1, int dim=-1) const
Definition: intNDArray.cc:299
OCTAVE_API FloatNDArray real(const FloatComplexNDArray &a)
Definition: fNDArray.cc:510
OCTAVE_API FloatNDArray imag(const FloatComplexNDArray &a)
Definition: fNDArray.cc:516
OCTAVE_API FloatNDArray max(float d, const FloatNDArray &m)
Definition: fNDArray.cc:624
OCTAVE_API FloatNDArray min(float d, const FloatNDArray &m)
Definition: fNDArray.cc:624
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
#define NDND_BOOL_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:227
#define NDND_CMP_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:219
#define NDS_BOOL_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:173
#define SND_CMP_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:192
#define MINMAX_DECLS(T, S, API)
Definition: mx-op-decl.h:289
#define NDS_CMP_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:165
#define SND_BOOL_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:200
bool isfinite(double x)
Definition: lo-mappers.h:192
bool isnan(bool)
Definition: lo-mappers.h:178
bool isinf(double x)
Definition: lo-mappers.h:203
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
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