GNU Octave  4.4.1
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-2018 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software: you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <https://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if ! defined (octave_fNDArray_h)
24 #define octave_fNDArray_h 1
25 
26 #include "octave-config.h"
27 
28 #include "MArray.h"
29 #include "bsxfun-decl.h"
30 #include "mx-defs.h"
31 #include "mx-op-decl.h"
32 
33 template <typename T> class intNDArray;
34 
35 class
36 OCTAVE_API
38 {
39 public:
40 
41  FloatNDArray (void) : MArray<float> () { }
42 
44 
45  FloatNDArray (const dim_vector& dv, float val)
46  : MArray<float> (dv, val) { }
47 
49 
50  template <typename U>
51  FloatNDArray (const MArray<U>& a) : MArray<float> (a) { }
52 
53  template <typename U>
54  FloatNDArray (const Array<U>& a) : MArray<float> (a) { }
55 
56  template <typename U>
57  explicit FloatNDArray (const intNDArray<U>& a) : MArray<float> (a) { }
58 
59  FloatNDArray (const charNDArray&);
60 
62  {
64  return *this;
65  }
66 
67  // unary operations
68 
69  boolNDArray operator ! (void) const;
70 
71  bool any_element_is_negative (bool = false) const;
72  bool any_element_is_positive (bool = false) const;
73  bool any_element_is_nan (void) const;
74  bool any_element_is_inf_or_nan (void) const;
75  bool any_element_not_one_or_zero (void) const;
76  bool all_elements_are_zero (void) const;
77  bool all_elements_are_int_or_inf_or_nan (void) const;
78  bool all_integers (float& max_val, float& min_val) const;
79  bool all_integers (void) const;
80  bool too_large_for_float (void) const;
81 
82  // FIXME: this is not quite the right thing.
83 
84  boolNDArray all (int dim = -1) const;
85  boolNDArray any (int dim = -1) const;
86 
87  FloatNDArray cumprod (int dim = -1) const;
88  FloatNDArray cumsum (int dim = -1) const;
89  FloatNDArray prod (int dim = -1) const;
90  NDArray dprod (int dim = -1) const;
91  FloatNDArray sum (int dim = -1) const;
92  NDArray dsum (int dim = -1) const;
93  FloatNDArray sumsq (int dim = -1) const;
94  FloatNDArray concat (const FloatNDArray& rb,
98  charNDArray concat (const charNDArray& rb,
100 
101  FloatNDArray max (int dim = -1) const;
102  FloatNDArray max (Array<octave_idx_type>& index, int dim = -1) const;
103  FloatNDArray min (int dim = -1) const;
104  FloatNDArray min (Array<octave_idx_type>& index, int dim = -1) const;
105 
106  FloatNDArray cummax (int dim = -1) const;
107  FloatNDArray cummax (Array<octave_idx_type>& index, int dim = -1) const;
108  FloatNDArray cummin (int dim = -1) const;
109  FloatNDArray cummin (Array<octave_idx_type>& index, int dim = -1) const;
110 
111  FloatNDArray diff (octave_idx_type order = 1, int dim = -1) const;
112 
117 
118  FloatNDArray abs (void) const;
119  boolNDArray isnan (void) const;
120  boolNDArray isinf (void) const;
121  boolNDArray isfinite (void) const;
122 
123  FloatComplexNDArray fourier (int dim = 1) const;
124  FloatComplexNDArray ifourier (int dim = 1) const;
125 
126  FloatComplexNDArray fourier2d (void) const;
127  FloatComplexNDArray ifourier2d (void) const;
128 
129  FloatComplexNDArray fourierNd (void) const;
130  FloatComplexNDArray ifourierNd (void) const;
131 
132  friend OCTAVE_API FloatNDArray real (const FloatComplexNDArray& a);
133  friend OCTAVE_API FloatNDArray imag (const FloatComplexNDArray& a);
134 
135  friend class FloatComplexNDArray;
136 
137  FloatNDArray squeeze (void) const { return MArray<float>::squeeze (); }
138 
140  const dim_vector& dimensions,
141  int start_dimension = 0);
142 
144  const dim_vector& dimensions);
145 
146  // i/o
147 
148  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
149  const FloatNDArray& a);
150  friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatNDArray& a);
151 
152  FloatNDArray diag (octave_idx_type k = 0) const;
153 
155 
157  {
159  return *this;
160  }
161 
162 };
163 
164 // Publish externally used friend functions.
165 
166 extern OCTAVE_API FloatNDArray real (const FloatComplexNDArray& a);
167 extern OCTAVE_API FloatNDArray imag (const FloatComplexNDArray& a);
168 
169 MINMAX_DECLS (FloatNDArray, float, OCTAVE_API)
170 
171 NDS_CMP_OP_DECLS (FloatNDArray, float, OCTAVE_API)
172 NDS_BOOL_OP_DECLS (FloatNDArray, float, OCTAVE_API)
173 
174 SND_CMP_OP_DECLS (float, FloatNDArray, OCTAVE_API)
175 SND_BOOL_OP_DECLS (float, FloatNDArray, OCTAVE_API)
176 
179 
181 
182 BSXFUN_STDOP_DECLS (FloatNDArray, OCTAVE_API)
183 BSXFUN_STDREL_DECLS (FloatNDArray, OCTAVE_API)
184 
185 BSXFUN_OP_DECL (pow, FloatNDArray, OCTAVE_API)
187  FloatNDArray, OCTAVE_API)
189  FloatComplexNDArray, OCTAVE_API)
190 
191 #endif
dim_vector dimensions
Definition: Array.h:216
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:175
intNDArray cummin(int dim=-1) const
Definition: intNDArray.cc:283
intNDArray cumsum(int dim) const
Definition: intNDArray.cc:234
bool any_element_is_nan(void) const
Definition: intNDArray.h:67
const octave_base_value const Array< octave_idx_type > & ra_idx
OCTAVE_API FloatNDArray imag(const FloatComplexNDArray &a)
Definition: fNDArray.cc:746
intNDArray diff(octave_idx_type order=1, int dim=-1) const
Definition: intNDArray.cc:297
std::istream & operator>>(std::istream &is, SparseBoolMatrix &a)
Definition: boolSparse.cc:279
#define BSXFUN_STDREL_DECLS(ARRAY, API)
Definition: bsxfun-decl.h:51
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:4986
#define NDND_CMP_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:218
OCTAVE_API FloatNDArray max(float d, const FloatNDArray &m)
Definition: fNDArray.cc:854
FloatNDArray & changesign(void)
Definition: fNDArray.h:156
void changesign(void)
Definition: MArray.cc:204
for large enough k
Definition: lu.cc:617
#define SND_BOOL_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:199
bool isnan(bool)
Definition: lo-mappers.h:187
FloatNDArray(const dim_vector &dv)
Definition: fNDArray.h:43
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:653
#define NDND_BOOL_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:226
bool isinf(double x)
Definition: lo-mappers.h:225
intNDArray sum(int dim) const
Definition: intNDArray.cc:220
FloatComplexNDArray diag(octave_idx_type k=0) const
Definition: fCNDArray.cc:828
static T abs(T x)
Definition: pr-output.cc:1696
the second is matched to the second specifier and placed in the second column and so forth If there are more words than specifiers then the process is repeated until all words have been processed or the limit imposed by any(non-whitespace) text in the format that is not one of these specifiers is considered a literal. If there is a literal between two format specifiers then that same literal must appear in the input stream between the matching words. The following specifiers are valid
Definition: file-io.cc:1499
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
Definition: file-io.cc:587
FloatNDArray(const intNDArray< U > &a)
Definition: fNDArray.h:57
#define MARRAY_FORWARD_DEFS(B, R, T)
Definition: MArray.h:126
#define NDS_BOOL_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:172
OCTAVE_API FloatNDArray real(const FloatComplexNDArray &a)
Definition: fNDArray.cc:740
FloatNDArray squeeze(void) const
Definition: fNDArray.h:137
#define NDS_CMP_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:164
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:400
#define SND_CMP_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:191
OCTAVE_API FloatNDArray min(float d, const FloatNDArray &m)
Definition: fNDArray.cc:854
Array< T > index(const idx_vector &i) const
Indexing without resizing.
Definition: Array.cc:697
bool any_element_not_one_or_zero(void) const
Definition: intNDArray.cc:49
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
Definition: Array-util.cc:58
FloatNDArray(void)
Definition: fNDArray.h:41
intNDArray & insert(const intNDArray< T > &a, octave_idx_type r, octave_idx_type c)
Definition: intNDArray.cc:123
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
FloatNDArray(const dim_vector &dv, float val)
Definition: fNDArray.h:45
intNDArray cummax(int dim=-1) const
Definition: intNDArray.cc:269
NDArray dsum(int dim) const
Definition: intNDArray.cc:227
MArray< T > & operator=(const MArray< T > &a)
Definition: MArray.h:85
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:125
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
bool isfinite(double x)
Definition: lo-mappers.h:201
MArray squeeze(void) const
Definition: MArray.h:101
FloatNDArray(const Array< U > &a)
Definition: fNDArray.h:54
#define BSXFUN_OP2_DECL(OP, ARRAY, ARRAY1, ARRAY2, API)
Definition: bsxfun-decl.h:30
FloatNDArray(const FloatNDArray &a)
Definition: fNDArray.h:48
#define BSXFUN_STDOP_DECLS(ARRAY, API)
Definition: bsxfun-decl.h:36
octave_value operator!(const octave_value &a)
Definition: ov.h:1573
intNDArray prod(int dim) const
Definition: intNDArray.cc:213
intNDArray & operator=(const intNDArray< T > &a)
Definition: intNDArray.h:59
boolNDArray all(int dim=-1) const
Definition: intNDArray.cc:82
write the output to stdout if nargout is
Definition: load-save.cc:1612
#define MINMAX_DECLS(T, S, API)
Definition: mx-op-decl.h:288
Vector representing the dimensions (size) of an Array.
Definition: dim-vector.h:87
dim_vector dv
Definition: sub2ind.cc:263
octave::stream os
Definition: file-io.cc:627
#define BSXFUN_OP_DECL(OP, ARRAY, API)
Definition: bsxfun-decl.h:27
FloatNDArray(const MArray< U > &a)
Definition: fNDArray.h:51