GNU Octave  9.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
fNDArray.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 //
3 // Copyright (C) 1996-2024 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 "intNDArray-fwd.h"
32 #include "MArray.h"
33 #include "bsxfun-decl.h"
34 #include "mx-defs.h"
35 #include "mx-op-decl.h"
36 
37 class
40 {
41 public:
42 
43  FloatNDArray () : MArray<float> () { }
44 
45  FloatNDArray (const dim_vector& dv) : MArray<float> (dv) { }
46 
47  FloatNDArray (const dim_vector& dv, float val)
48  : MArray<float> (dv, val) { }
49 
50  FloatNDArray (const FloatNDArray& a) : MArray<float> (a) { }
51 
52  template <typename U>
53  FloatNDArray (const MArray<U>& a) : MArray<float> (a) { }
54 
55  template <typename U>
56  FloatNDArray (const Array<U>& a) : MArray<float> (a) { }
57 
58  template <typename U>
59  explicit FloatNDArray (const intNDArray<U>& a) : MArray<float> (a) { }
60 
62 
63  FloatNDArray& operator = (const FloatNDArray& a)
64  {
66  return *this;
67  }
68 
69  ~FloatNDArray () = default;
70 
71  // unary operations
72 
74 
75  OCTAVE_API bool any_element_is_negative (bool = false) const;
76  OCTAVE_API bool any_element_is_positive (bool = false) const;
77  OCTAVE_API bool any_element_is_nan () const;
78  OCTAVE_API bool any_element_is_inf_or_nan () const;
79  OCTAVE_API bool any_element_not_one_or_zero () const;
80  OCTAVE_API bool all_elements_are_zero () const;
81  OCTAVE_API bool all_elements_are_int_or_inf_or_nan () const;
82  OCTAVE_API bool all_integers (float& max_val, float& min_val) const;
83  OCTAVE_API bool all_integers () const;
84  OCTAVE_API bool too_large_for_float () const;
85 
86  // FIXME: this is not quite the right thing.
87 
88  OCTAVE_API boolNDArray all (int dim = -1) const;
89  OCTAVE_API boolNDArray any (int dim = -1) const;
90 
91  OCTAVE_API FloatNDArray cumprod (int dim = -1) const;
92  OCTAVE_API FloatNDArray cumsum (int dim = -1) const;
93  OCTAVE_API FloatNDArray prod (int dim = -1) const;
94  OCTAVE_API NDArray dprod (int dim = -1) const;
95  OCTAVE_API FloatNDArray sum (int dim = -1) const;
96  OCTAVE_API NDArray dsum (int dim = -1) const;
97  OCTAVE_API FloatNDArray sumsq (int dim = -1) const;
103  concat (const charNDArray& rb, const Array<octave_idx_type>& ra_idx);
104 
105  OCTAVE_API FloatNDArray max (int dim = -1) const;
107  max (Array<octave_idx_type>& index, int dim = -1) const;
108  OCTAVE_API FloatNDArray min (int dim = -1) const;
110  min (Array<octave_idx_type>& index, int dim = -1) const;
111 
112  OCTAVE_API FloatNDArray cummax (int dim = -1) const;
114  cummax (Array<octave_idx_type>& index, int dim = -1) const;
115  OCTAVE_API FloatNDArray cummin (int dim = -1) const;
117  cummin (Array<octave_idx_type>& index, int dim = -1) const;
118 
119  OCTAVE_API FloatNDArray diff (octave_idx_type order = 1, int dim = -1) const;
120 
122  insert (const FloatNDArray& a, octave_idx_type r, octave_idx_type c);
124  insert (const FloatNDArray& a, const Array<octave_idx_type>& ra_idx);
125 
126  OCTAVE_API FloatNDArray abs () const;
127  OCTAVE_API boolNDArray isnan () const;
128  OCTAVE_API boolNDArray isinf () const;
130 
131  OCTAVE_API FloatComplexNDArray fourier (int dim = 1) const;
132  OCTAVE_API FloatComplexNDArray ifourier (int dim = 1) const;
133 
134  OCTAVE_API FloatComplexNDArray fourier2d () const;
135  OCTAVE_API FloatComplexNDArray ifourier2d () const;
136 
137  OCTAVE_API FloatComplexNDArray fourierNd () const;
138  OCTAVE_API FloatComplexNDArray ifourierNd () const;
139 
142 
143  friend class FloatComplexNDArray;
144 
146 
147  static OCTAVE_API void
149  const dim_vector& dimensions, int start_dimension = 0);
150 
153 
154  // i/o
155 
156  friend OCTAVE_API std::ostream&
157  operator << (std::ostream& os, const FloatNDArray& a);
158  friend OCTAVE_API std::istream&
159  operator >> (std::istream& is, FloatNDArray& a);
160 
162 
164 
166  {
168  return *this;
169  }
170 
171 };
172 
173 // Publish externally used friend functions.
174 
177 
179 
182 
185 
188 
190 
193 
199 
200 #endif
template 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:130
std::istream & operator>>(std::istream &is, SparseBoolMatrix &a)
Definition: boolSparse.cc:279
#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:130
FloatComplexNDArray diag(octave_idx_type k=0) const
Definition: fCNDArray.cc:600
FloatNDArray(const Array< U > &a)
Definition: fNDArray.h:56
FloatNDArray(const MArray< U > &a)
Definition: fNDArray.h:53
FloatNDArray()
Definition: fNDArray.h:43
FloatNDArray & changesign()
Definition: fNDArray.h:165
FloatNDArray(const dim_vector &dv, float val)
Definition: fNDArray.h:47
FloatNDArray squeeze() const
Definition: fNDArray.h:145
~FloatNDArray()=default
FloatNDArray(const dim_vector &dv)
Definition: fNDArray.h:45
FloatNDArray(const intNDArray< U > &a)
Definition: fNDArray.h:59
FloatNDArray(const FloatNDArray &a)
Definition: fNDArray.h:50
MArray< T > & operator=(const MArray< T > &a)
Definition: MArray.h:81
MArray squeeze() const
Definition: MArray.h:97
void changesign()
Definition: MArray.cc:217
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:94
FloatNDArray min(float d, const FloatNDArray &m)
Definition: fNDArray.cc:624
FloatNDArray max(float d, const FloatNDArray &m)
Definition: fNDArray.cc:624
FloatNDArray imag(const FloatComplexNDArray &a)
Definition: fNDArray.cc:516
FloatNDArray real(const FloatComplexNDArray &a)
Definition: fNDArray.cc:510
bool isfinite(double x)
Definition: lo-mappers.h:192
bool isinf(double x)
Definition: lo-mappers.h:203
bool isnan(bool)
Definition: lo-mappers.h:178
bool too_large_for_float(double x)
Definition: lo-utils.cc:56
#define OCTAVE_API
Definition: main.cc:55
T octave_idx_type m
Definition: mx-inlines.cc:781
octave_idx_type n
Definition: mx-inlines.cc:761
T * r
Definition: mx-inlines.cc:781
#define NDND_BOOL_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:226
#define NDND_CMP_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:218
#define NDS_BOOL_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:172
#define SND_CMP_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:191
#define MINMAX_DECLS(T, S, API)
Definition: mx-op-decl.h:288
#define NDS_CMP_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:164
#define SND_BOOL_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:199
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:1633
template int8_t abs(int8_t)