GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
fNDArray.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2017 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 the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 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 <http://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 
30 #include "mx-defs.h"
31 #include "mx-op-decl.h"
32 #include "bsxfun-decl.h"
33 
34 template <typename T> class intNDArray;
35 
36 class
37 OCTAVE_API
39 {
40 public:
41 
42  FloatNDArray (void) : MArray<float> () { }
43 
44  FloatNDArray (const dim_vector& dv) : MArray<float> (dv) { }
45 
46  FloatNDArray (const dim_vector& dv, float val)
47  : MArray<float> (dv, val) { }
48 
49  FloatNDArray (const FloatNDArray& a) : MArray<float> (a) { }
50 
51  template <typename U>
52  FloatNDArray (const MArray<U>& a) : MArray<float> (a) { }
53 
54  template <typename U>
55  FloatNDArray (const Array<U>& a) : MArray<float> (a) { }
56 
57  template <typename U>
58  explicit FloatNDArray (const intNDArray<U>& a) : MArray<float> (a) { }
59 
60  FloatNDArray (const charNDArray&);
61 
63  {
65  return *this;
66  }
67 
68  // unary operations
69 
70  boolNDArray operator ! (void) const;
71 
72  bool any_element_is_negative (bool = false) const;
73  bool any_element_is_positive (bool = false) const;
74  bool any_element_is_nan (void) const;
75  bool any_element_is_inf_or_nan (void) const;
76  bool any_element_not_one_or_zero (void) const;
77  bool all_elements_are_zero (void) const;
78  bool all_elements_are_int_or_inf_or_nan (void) const;
79  bool all_integers (float& max_val, float& min_val) const;
80  bool all_integers (void) const;
81  bool too_large_for_float (void) const;
82 
83  // FIXME: this is not quite the right thing.
84 
85  boolNDArray all (int dim = -1) const;
86  boolNDArray any (int dim = -1) const;
87 
88  FloatNDArray cumprod (int dim = -1) const;
89  FloatNDArray cumsum (int dim = -1) const;
90  FloatNDArray prod (int dim = -1) const;
91  NDArray dprod (int dim = -1) const;
92  FloatNDArray sum (int dim = -1) const;
93  NDArray dsum (int dim = -1) const;
94  FloatNDArray sumsq (int dim = -1) const;
95  FloatNDArray concat (const FloatNDArray& rb,
99  charNDArray concat (const charNDArray& rb,
101 
102  FloatNDArray max (int dim = -1) const;
103  FloatNDArray max (Array<octave_idx_type>& index, int dim = -1) const;
104  FloatNDArray min (int dim = -1) const;
105  FloatNDArray min (Array<octave_idx_type>& index, int dim = -1) const;
106 
107  FloatNDArray cummax (int dim = -1) const;
108  FloatNDArray cummax (Array<octave_idx_type>& index, int dim = -1) const;
109  FloatNDArray cummin (int dim = -1) const;
110  FloatNDArray cummin (Array<octave_idx_type>& index, int dim = -1) const;
111 
112  FloatNDArray diff (octave_idx_type order = 1, int dim = -1) const;
113 
118 
119  FloatNDArray abs (void) const;
120  boolNDArray isnan (void) const;
121  boolNDArray isinf (void) const;
122  boolNDArray isfinite (void) const;
123 
124  FloatComplexNDArray fourier (int dim = 1) const;
125  FloatComplexNDArray ifourier (int dim = 1) const;
126 
127  FloatComplexNDArray fourier2d (void) const;
128  FloatComplexNDArray ifourier2d (void) const;
129 
130  FloatComplexNDArray fourierNd (void) const;
131  FloatComplexNDArray ifourierNd (void) const;
132 
133  friend OCTAVE_API FloatNDArray real (const FloatComplexNDArray& a);
134  friend OCTAVE_API FloatNDArray imag (const FloatComplexNDArray& a);
135 
136  friend class FloatComplexNDArray;
137 
138  FloatNDArray squeeze (void) const { return MArray<float>::squeeze (); }
139 
141  const dim_vector& dimensions,
142  int start_dimension = 0);
143 
145  const dim_vector& dimensions);
146 
147  // i/o
148 
149  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
150  const FloatNDArray& a);
151  friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatNDArray& a);
152 
153  FloatNDArray diag (octave_idx_type k = 0) const;
154 
156 
158  {
160  return *this;
161  }
162 
163 };
164 
165 // Publish externally used friend functions.
166 
167 extern OCTAVE_API FloatNDArray real (const FloatComplexNDArray& a);
168 extern OCTAVE_API FloatNDArray imag (const FloatComplexNDArray& a);
169 
170 MINMAX_DECLS (FloatNDArray, float, OCTAVE_API)
171 
172 NDS_CMP_OP_DECLS (FloatNDArray, float, OCTAVE_API)
173 NDS_BOOL_OP_DECLS (FloatNDArray, float, OCTAVE_API)
174 
175 SND_CMP_OP_DECLS (float, FloatNDArray, OCTAVE_API)
176 SND_BOOL_OP_DECLS (float, FloatNDArray, OCTAVE_API)
177 
178 NDND_CMP_OP_DECLS (FloatNDArray, FloatNDArray, OCTAVE_API)
179 NDND_BOOL_OP_DECLS (FloatNDArray, FloatNDArray, OCTAVE_API)
180 
181 MARRAY_FORWARD_DEFS (MArray, FloatNDArray, float)
182 
183 BSXFUN_STDOP_DECLS (FloatNDArray, OCTAVE_API)
184 BSXFUN_STDREL_DECLS (FloatNDArray, OCTAVE_API)
185 
186 BSXFUN_OP_DECL (pow, FloatNDArray, OCTAVE_API)
187 BSXFUN_OP2_DECL (pow, FloatComplexNDArray, FloatComplexNDArray,
188  FloatNDArray, OCTAVE_API)
189 BSXFUN_OP2_DECL (pow, FloatComplexNDArray, FloatNDArray,
190  FloatComplexNDArray, OCTAVE_API)
191 
192 #endif
dim_vector dimensions
Definition: Array.h:214
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:176
bool any_element_not_one_or_zero(void) const
Definition: intNDArray.cc:50
const octave_base_value const Array< octave_idx_type > & ra_idx
OCTAVE_API FloatNDArray imag(const FloatComplexNDArray &a)
Definition: fNDArray.cc:748
std::istream & operator>>(std::istream &is, SparseBoolMatrix &a)
Definition: boolSparse.cc:279
MArray squeeze(void) const
Definition: MArray.h:101
#define BSXFUN_STDREL_DECLS(ARRAY, API)
Definition: bsxfun-decl.h:53
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:5068
#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:856
bool isnan(double x)
Definition: lo-mappers.cc:347
FloatNDArray & changesign(void)
Definition: fNDArray.h:157
for large enough k
Definition: lu.cc:606
#define SND_BOOL_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:199
FloatNDArray(const dim_vector &dv)
Definition: fNDArray.h:44
intNDArray & insert(const intNDArray< T > &a, octave_idx_type r, octave_idx_type c)
Definition: intNDArray.cc:124
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:655
#define NDND_BOOL_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:226
intNDArray cumsum(int dim) const
Definition: intNDArray.cc:235
FloatNDArray(const intNDArray< U > &a)
Definition: fNDArray.h:58
#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
void changesign(void)
Definition: MArray.cc:204
OCTAVE_API FloatNDArray real(const FloatComplexNDArray &a)
Definition: fNDArray.cc:742
intNDArray sum(int dim) const
Definition: intNDArray.cc:221
#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:398
intNDArray cummin(int dim=-1) const
Definition: intNDArray.cc:284
FloatComplexNDArray diag(octave_idx_type k=0) const
Definition: fCNDArray.cc:830
#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:856
intNDArray diff(octave_idx_type order=1, int dim=-1) const
Definition: intNDArray.cc:298
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
Definition: Array-util.cc:59
nd deftypefn *octave_map m
Definition: ov-struct.cc:2058
FloatNDArray(void)
Definition: fNDArray.h:42
NDArray dsum(int dim) const
Definition: intNDArray.cc:228
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
FloatNDArray squeeze(void) const
Definition: fNDArray.h:138
FloatNDArray(const dim_vector &dv, float val)
Definition: fNDArray.h:46
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
bool isinf(double x)
Definition: lo-mappers.cc:387
intNDArray cummax(int dim=-1) const
Definition: intNDArray.cc:270
N Dimensional Array with copy-on-write semantics.
Definition: Array.h:126
intNDArray & operator=(const intNDArray< T > &a)
Definition: intNDArray.h:58
bool any_element_is_nan(void) const
Definition: intNDArray.h:66
OCTAVE_EXPORT octave_value_list return the value of the option it must match the dimension of the state and the relative tolerance must also be a vector of the same length tem it must match the dimension of the state and the absolute tolerance must also be a vector of the same length The local error test applied at each integration step is xample roup abs(local error in x(i))<
boolNDArray all(int dim=-1) const
Definition: intNDArray.cc:83
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
FloatNDArray(const Array< U > &a)
Definition: fNDArray.h:55
#define BSXFUN_OP2_DECL(OP, ARRAY, ARRAY1, ARRAY2, API)
Definition: bsxfun-decl.h:32
FloatNDArray(const FloatNDArray &a)
Definition: fNDArray.h:49
#define BSXFUN_STDOP_DECLS(ARRAY, API)
Definition: bsxfun-decl.h:38
octave_value operator!(const octave_value &a)
Definition: ov.h:1484
intNDArray prod(int dim) const
Definition: intNDArray.cc:214
write the output to stdout if nargout is
Definition: load-save.cc:1576
#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
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:1491
dim_vector dv
Definition: sub2ind.cc:263
MArray< T > & operator=(const MArray< T > &a)
Definition: MArray.h:85
#define BSXFUN_OP_DECL(OP, ARRAY, API)
Definition: bsxfun-decl.h:29
Array< T > index(const idx_vector &i) const
Indexing without resizing.
Definition: Array.cc:718
FloatNDArray(const MArray< U > &a)
Definition: fNDArray.h:52