GNU Octave  4.0.0
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-2015 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 "MArray.h"
27 #include "intNDArray.h"
28 
29 #include "mx-defs.h"
30 #include "mx-op-decl.h"
31 #include "bsxfun-decl.h"
32 
33 class
34 OCTAVE_API
36 {
37 public:
38 
39  FloatNDArray (void) : MArray<float> () { }
40 
41  FloatNDArray (const dim_vector& dv) : MArray<float> (dv) { }
42 
43  FloatNDArray (const dim_vector& dv, float val)
44  : MArray<float> (dv, val) { }
45 
46  FloatNDArray (const FloatNDArray& a) : MArray<float> (a) { }
47 
48  template <class U>
49  FloatNDArray (const MArray<U>& a) : MArray<float> (a) { }
50 
51  template <class U>
52  FloatNDArray (const Array<U>& a) : MArray<float> (a) { }
53 
54  template <class U>
55  explicit FloatNDArray (const intNDArray<U>& a) : MArray<float> (a) { }
56 
57  FloatNDArray (const charNDArray&);
58 
60  {
62  return *this;
63  }
64 
65  // unary operations
66 
67  boolNDArray operator ! (void) const;
68 
69  bool any_element_is_negative (bool = false) const;
70  bool any_element_is_positive (bool = false) const;
71  bool any_element_is_nan (void) const;
72  bool any_element_is_inf_or_nan (void) const;
73  bool any_element_not_one_or_zero (void) const;
74  bool all_elements_are_zero (void) const;
75  bool all_elements_are_int_or_inf_or_nan (void) const;
76  bool all_integers (float& max_val, float& min_val) const;
77  bool all_integers (void) const;
78  bool too_large_for_float (void) const;
79 
80  // FIXME: this is not quite the right thing.
81 
82  boolNDArray all (int dim = -1) const;
83  boolNDArray any (int dim = -1) const;
84 
85  FloatNDArray cumprod (int dim = -1) const;
86  FloatNDArray cumsum (int dim = -1) const;
87  FloatNDArray prod (int dim = -1) const;
88  NDArray dprod (int dim = -1) const;
89  FloatNDArray sum (int dim = -1) const;
90  NDArray dsum (int dim = -1) const;
91  FloatNDArray sumsq (int dim = -1) const;
92  FloatNDArray concat (const FloatNDArray& rb,
96  charNDArray concat (const charNDArray& rb,
98 
99  FloatNDArray max (int dim = -1) const;
100  FloatNDArray max (Array<octave_idx_type>& index, int dim = -1) const;
101  FloatNDArray min (int dim = -1) const;
102  FloatNDArray min (Array<octave_idx_type>& index, int dim = -1) const;
103 
104  FloatNDArray cummax (int dim = -1) const;
105  FloatNDArray cummax (Array<octave_idx_type>& index, int dim = -1) const;
106  FloatNDArray cummin (int dim = -1) const;
107  FloatNDArray cummin (Array<octave_idx_type>& index, int dim = -1) const;
108 
109  FloatNDArray diff (octave_idx_type order = 1, int dim = -1) const;
110 
111  FloatNDArray& insert (const FloatNDArray& a,
113  FloatNDArray& insert (const FloatNDArray& a,
115 
116  FloatNDArray abs (void) const;
117  boolNDArray isnan (void) const;
118  boolNDArray isinf (void) const;
119  boolNDArray isfinite (void) const;
120 
121  FloatComplexNDArray fourier (int dim = 1) const;
122  FloatComplexNDArray ifourier (int dim = 1) const;
123 
124  FloatComplexNDArray fourier2d (void) const;
125  FloatComplexNDArray ifourier2d (void) const;
126 
127  FloatComplexNDArray fourierNd (void) const;
128  FloatComplexNDArray ifourierNd (void) const;
129 
130  friend OCTAVE_API FloatNDArray real (const FloatComplexNDArray& a);
131  friend OCTAVE_API FloatNDArray imag (const FloatComplexNDArray& a);
132 
133  friend class FloatComplexNDArray;
134 
135  FloatNDArray squeeze (void) const { return MArray<float>::squeeze (); }
136 
138  const dim_vector& dimensions,
139  int start_dimension = 0);
140 
142  const dim_vector& dimensions);
143 
144  // i/o
145 
146  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
147  const FloatNDArray& a);
148  friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatNDArray& a);
149 
150  FloatNDArray diag (octave_idx_type k = 0) const;
151 
153 
155  {
157  return *this;
158  }
159 
160 };
161 
162 // Publish externally used friend functions.
163 
164 extern OCTAVE_API FloatNDArray real (const FloatComplexNDArray& a);
165 extern OCTAVE_API FloatNDArray imag (const FloatComplexNDArray& a);
166 
167 MINMAX_DECLS (FloatNDArray, float, OCTAVE_API)
168 
169 NDS_CMP_OP_DECLS (FloatNDArray, float, OCTAVE_API)
170 NDS_BOOL_OP_DECLS (FloatNDArray, float, OCTAVE_API)
171 
172 SND_CMP_OP_DECLS (float, FloatNDArray, OCTAVE_API)
173 SND_BOOL_OP_DECLS (float, FloatNDArray, OCTAVE_API)
174 
175 NDND_CMP_OP_DECLS (FloatNDArray, FloatNDArray, OCTAVE_API)
176 NDND_BOOL_OP_DECLS (FloatNDArray, FloatNDArray, OCTAVE_API)
177 
178 MARRAY_FORWARD_DEFS (MArray, FloatNDArray, float)
179 
180 BSXFUN_STDOP_DECLS (FloatNDArray, OCTAVE_API)
181 BSXFUN_STDREL_DECLS (FloatNDArray, OCTAVE_API)
182 
183 BSXFUN_OP_DECL (pow, FloatNDArray, OCTAVE_API)
184 BSXFUN_OP2_DECL (pow, FloatComplexNDArray, FloatComplexNDArray,
185  FloatNDArray, OCTAVE_API)
186 BSXFUN_OP2_DECL (pow, FloatComplexNDArray, FloatNDArray,
187  FloatComplexNDArray, OCTAVE_API)
188 
189 #endif
dim_vector dimensions
Definition: Array.h:127
octave_idx_type compute_index(octave_idx_type n, const dim_vector &dims)
Definition: Array-util.cc:178
const octave_base_value const Array< octave_idx_type > & ra_idx
OCTAVE_API FloatNDArray imag(const FloatComplexNDArray &a)
Definition: fNDArray.cc:770
std::istream & operator>>(std::istream &is, SparseBoolMatrix &a)
Definition: boolSparse.cc:279
MArray squeeze(void) const
Definition: MArray.h:81
#define BSXFUN_STDREL_DECLS(ARRAY, API)
Definition: bsxfun-decl.h:51
boolNDArray isinf(void) const
Definition: fCNDArray.cc:745
#define NDND_CMP_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:216
OCTAVE_API FloatNDArray max(float d, const FloatNDArray &m)
Definition: fNDArray.cc:880
FloatNDArray & changesign(void)
Definition: fNDArray.h:154
#define SND_BOOL_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:197
FloatNDArray(const dim_vector &dv)
Definition: fNDArray.h:41
bool too_large_for_float(void) const
Definition: fCNDArray.cc:583
ComplexNDArray concat(NDArray &ra, ComplexNDArray &rb, const Array< octave_idx_type > &ra_idx)
Definition: CNDArray.cc:664
#define NDND_BOOL_OP_DECLS(ND1, ND2, API)
Definition: mx-op-decl.h:224
FloatComplexNDArray & operator=(const FloatComplexNDArray &a)
Definition: fCNDArray.h:56
ComplexNDArray dsum(int dim=-1) const
Definition: fCNDArray.cc:633
bool any_element_is_inf_or_nan(void) const
Definition: fCNDArray.cc:515
FloatNDArray(const intNDArray< U > &a)
Definition: fNDArray.h:55
bool all_integers(float &max_val, float &min_val) const
Definition: fCNDArray.cc:533
#define NDS_BOOL_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:170
void changesign(void)
Definition: MArray.cc:208
OCTAVE_API FloatNDArray real(const FloatComplexNDArray &a)
Definition: fNDArray.cc:764
FloatComplexNDArray ifourierNd(void) const
Definition: fCNDArray.cc:176
boolNDArray isfinite(void) const
Definition: fCNDArray.cc:751
FloatComplexMatrix cumprod(int dim=-1) const
Definition: fCMatrix.cc:3149
#define NDS_CMP_OP_DECLS(ND, S, API)
Definition: mx-op-decl.h:162
bool any_element_is_nan(void) const
Definition: fCNDArray.cc:509
ComplexNDArray dprod(int dim=-1) const
Definition: fCNDArray.cc:621
FloatComplexNDArray diag(octave_idx_type k=0) const
Definition: fCNDArray.cc:845
FloatComplexNDArray cummin(int dim=-1) const
Definition: fCNDArray.cc:720
#define SND_CMP_OP_DECLS(S, ND, API)
Definition: mx-op-decl.h:189
FloatComplexNDArray cummax(int dim=-1) const
Definition: fCNDArray.cc:707
OCTAVE_API FloatNDArray min(float d, const FloatNDArray &m)
Definition: fNDArray.cc:880
FloatComplexMatrix & insert(const FloatMatrix &a, octave_idx_type r, octave_idx_type c)
Definition: fCMatrix.cc:403
boolMatrix any(int dim=-1) const
Definition: fCMatrix.cc:3143
FloatComplexMatrix fourier2d(void) const
Definition: fCMatrix.cc:1328
void increment_index(Array< octave_idx_type > &ra_idx, const dim_vector &dimensions, int start_dimension)
Definition: Array-util.cc:59
FloatNDArray(void)
Definition: fNDArray.h:39
FloatComplexNDArray fourierNd(void) const
Definition: fCNDArray.cc:161
octave_int< T > pow(const octave_int< T > &a, const octave_int< T > &b)
FloatComplexMatrix sum(int dim=-1) const
Definition: fCMatrix.cc:3167
FloatNDArray squeeze(void) const
Definition: fNDArray.h:135
FloatNDArray(const dim_vector &dv, float val)
Definition: fNDArray.h:43
FloatComplexMatrix sumsq(int dim=-1) const
Definition: fCMatrix.cc:3173
#define MARRAY_FORWARD_DEFS(B, R, T)
Definition: MArray-decl.h:236
FloatComplexMatrix cumsum(int dim=-1) const
Definition: fCMatrix.cc:3155
boolNDArray isnan(void) const
Definition: fCNDArray.cc:739
FloatComplexMatrix ifourier(void) const
Definition: fCMatrix.cc:1299
Handles the reference counting for all the derived classes.
Definition: Array.h:45
FloatComplexMatrix prod(int dim=-1) const
Definition: fCMatrix.cc:3161
template OCTAVE_API std::ostream & operator<<(std::ostream &, const Array< bool > &)
FloatComplexMatrix fourier(void) const
Definition: fCMatrix.cc:1270
FloatNDArray(const Array< U > &a)
Definition: fNDArray.h:52
#define BSXFUN_OP2_DECL(OP, ARRAY, ARRAY1, ARRAY2, API)
Definition: bsxfun-decl.h:30
FloatNDArray(const FloatNDArray &a)
Definition: fNDArray.h:46
#define BSXFUN_STDOP_DECLS(ARRAY, API)
Definition: bsxfun-decl.h:36
octave_value operator!(const octave_value &a)
Definition: ov.h:1293
FloatComplexMatrix ifourier2d(void) const
Definition: fCMatrix.cc:1342
#define MINMAX_DECLS(T, S, API)
Definition: mx-op-decl.h:286
FloatComplexNDArray diff(octave_idx_type order=1, int dim=-1) const
Definition: fCNDArray.cc:645
T abs(T x)
Definition: pr-output.cc:3062
boolMatrix all(int dim=-1) const
Definition: fCMatrix.cc:3137
MArray< T > & operator=(const MArray< T > &a)
Definition: MArray.h:65
#define BSXFUN_OP_DECL(OP, ARRAY, API)
Definition: bsxfun-decl.h:27
Array< FloatComplex > index(const idx_vector &i) const
Indexing without resizing.
FloatNDArray(const MArray< U > &a)
Definition: fNDArray.h:49