GNU Octave  3.8.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-2013 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 "fMatrix.h"
28 #include "intNDArray.h"
29 
30 #include "mx-defs.h"
31 #include "mx-op-decl.h"
32 #include "bsxfun-decl.h"
33 
34 class
35 OCTAVE_API
37 {
38 public:
39 
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  FloatNDArray (const FloatMatrix& a) : MArray<float> (a) { }
52 
53  template <class U>
54  FloatNDArray (const MArray<U>& a) : MArray<float> (a) { }
55 
56  template <class U>
57  FloatNDArray (const Array<U>& a) : MArray<float> (a) { }
58 
59  template <class 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  FloatNDArray sum (int dim = -1) const;
94  NDArray dsum (int dim = -1) const;
95  FloatNDArray sumsq (int dim = -1) const;
96  FloatNDArray concat (const FloatNDArray& rb,
97  const Array<octave_idx_type>& ra_idx);
99  const Array<octave_idx_type>& ra_idx);
100  charNDArray concat (const charNDArray& rb,
101  const Array<octave_idx_type>& ra_idx);
102 
103  FloatNDArray max (int dim = -1) const;
104  FloatNDArray max (Array<octave_idx_type>& index, int dim = -1) const;
105  FloatNDArray min (int dim = -1) const;
106  FloatNDArray min (Array<octave_idx_type>& index, int dim = -1) const;
107 
108  FloatNDArray cummax (int dim = -1) const;
109  FloatNDArray cummax (Array<octave_idx_type>& index, int dim = -1) const;
110  FloatNDArray cummin (int dim = -1) const;
111  FloatNDArray cummin (Array<octave_idx_type>& index, int dim = -1) const;
112 
113  FloatNDArray diff (octave_idx_type order = 1, int dim = -1) const;
114 
115  FloatNDArray& insert (const FloatNDArray& a,
117  FloatNDArray& insert (const FloatNDArray& a,
118  const Array<octave_idx_type>& ra_idx);
119 
120  FloatNDArray abs (void) const;
121  boolNDArray isnan (void) const;
122  boolNDArray isinf (void) const;
123  boolNDArray isfinite (void) const;
124 
125  FloatComplexNDArray fourier (int dim = 1) const;
126  FloatComplexNDArray ifourier (int dim = 1) const;
127 
128  FloatComplexNDArray fourier2d (void) const;
129  FloatComplexNDArray ifourier2d (void) const;
130 
131  FloatComplexNDArray fourierNd (void) const;
132  FloatComplexNDArray ifourierNd (void) const;
133 
134  friend OCTAVE_API FloatNDArray real (const FloatComplexNDArray& a);
135  friend OCTAVE_API FloatNDArray imag (const FloatComplexNDArray& a);
136 
137  friend class FloatComplexNDArray;
138 
139  FloatMatrix matrix_value (void) const;
140 
141  FloatNDArray squeeze (void) const { return MArray<float>::squeeze (); }
142 
143  static void increment_index (Array<octave_idx_type>& ra_idx,
144  const dim_vector& dimensions,
145  int start_dimension = 0);
146 
148  const dim_vector& dimensions);
149 
150  // i/o
151 
152  friend OCTAVE_API std::ostream& operator << (std::ostream& os,
153  const FloatNDArray& a);
154  friend OCTAVE_API std::istream& operator >> (std::istream& is, FloatNDArray& a);
155 
156  FloatNDArray diag (octave_idx_type k = 0) const;
157 
159 
161  {
163  return *this;
164  }
165 
166 };
167 
168 // Publish externally used friend functions.
169 
170 extern OCTAVE_API FloatNDArray real (const FloatComplexNDArray& a);
171 extern OCTAVE_API FloatNDArray imag (const FloatComplexNDArray& a);
172 
173 MINMAX_DECLS (FloatNDArray, float, OCTAVE_API)
174 
175 NDS_CMP_OP_DECLS (FloatNDArray, float, OCTAVE_API)
176 NDS_BOOL_OP_DECLS (FloatNDArray, float, OCTAVE_API)
177 
178 SND_CMP_OP_DECLS (float, FloatNDArray, OCTAVE_API)
179 SND_BOOL_OP_DECLS (float, FloatNDArray, OCTAVE_API)
180 
181 NDND_CMP_OP_DECLS (FloatNDArray, FloatNDArray, OCTAVE_API)
182 NDND_BOOL_OP_DECLS (FloatNDArray, FloatNDArray, OCTAVE_API)
183 
184 MARRAY_FORWARD_DEFS (MArray, FloatNDArray, float)
185 
186 BSXFUN_STDOP_DECLS (FloatNDArray, OCTAVE_API)
187 BSXFUN_STDREL_DECLS (FloatNDArray, OCTAVE_API)
188 
189 BSXFUN_OP_DECL (pow, FloatNDArray, OCTAVE_API)
190 BSXFUN_OP2_DECL (pow, FloatComplexNDArray, FloatComplexNDArray,
191  FloatNDArray, OCTAVE_API)
192 BSXFUN_OP2_DECL (pow, FloatComplexNDArray, FloatNDArray,
193  FloatComplexNDArray, OCTAVE_API)
194 
195 #endif