casacore
MaskArrMath.h
Go to the documentation of this file.
1 //# MaskArrMath.h: Simple mathematics done with MaskedArray's.
2 //# Copyright (C) 1993,1994,1995,1996,1999,2001
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id$
27 
28 #ifndef CASA_MASKARRMATH_H
29 #define CASA_MASKARRMATH_H
30 
31 
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/BasicMath/Math.h>
34 #include <casacore/casa/Arrays/Array.h>
35 #include <casacore/casa/Arrays/MaskedArray.h>
36 #include <casacore/casa/Arrays/IPosition.h>
37 //# Needed to get the proper Complex typedef's
38 #include <casacore/casa/BasicSL/Complex.h>
39 
40 
41 namespace casacore { //# NAMESPACE CASACORE - BEGIN
42 
43 // <summary> Mathematical operations for MaskedArrays (and with Arrays) </summary>
44 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="tMaskArrMath0 tMaskArrMath1 tMaskArrMath2 tMaskArrExcp">
45 //
46 // <prerequisite>
47 // <li> <linkto class=Array>Array</linkto>
48 // <li> <linkto class=MaskedArray>MaskedArray</linkto>
49 // </prerequisite>
50 //
51 // <etymology>
52 // MaskArrMath is short for MaskedArrayMath, which is too long by the old
53 // AIPS++ file naming conventions. This file contains global functions
54 // which perform element by element mathematical operations on masked arrays.
55 // </etymology>
56 //
57 // <synopsis>
58 // These functions perform element by element mathematical operations on
59 // masked arrays. With two arrays, they must both conform, and the result
60 // is done element by element, for those locations where the mask of the
61 // MaskedArray is True. For two MaskedArrays, the "and" of the masks is used.
62 // </synopsis>
63 //
64 // <example>
65 // <srcblock>
66 // Vector<Int> a(10);
67 // Vector<Int> b(10);
68 // Vector<Int> c(10);
69 // . . .
70 // c = a(a>0) + b(b>0);
71 // </srcblock>
72 // This example sets those elements of c where ((a>0) && (b>0)) to (a+b).
73 // Elements of c where !((a>0) && (b>0)) are unchanged. The result of
74 // this operation is a MaskedArray. The assignment from this
75 // MaskedArray to the Vector c only assigns those elements
76 // where the mask is True.
77 // </example>
78 //
79 // <example>
80 // <srcblock>
81 // Vector<Double> a(10);
82 // Vector<Double> b(10);
83 // Vector<Double> c(10);
84 // . . .
85 // c = atan2 (a, b(b>0);
86 // </srcblock>
87 // This example sets those elements of c where (b>0) to atan2 (a,b).
88 // Elements of c where !(b>0) are unchanged. The result of
89 // this operation is a MaskedArray. The assignment from this
90 // MaskedArray to the Vector c only assigns those elements
91 // where the mask is True.
92 // </example>
93 //
94 // <example>
95 // <srcblock>
96 // Vector<Int> a(10);
97 // Int result;
98 // . . .
99 // result = sum (a(a>0));
100 // </srcblock>
101 // This example sums a, for those elements of a which are greater than 0.
102 // </example>
103 //
104 // <motivation>
105 // One wants to be able to mask arrays and perform mathematical operations on
106 // those masked arrays. Since the masked arrays are only defined where
107 // the masks are True, the result must be a MaskedArray, or a simple number.
108 // </motivation>
109 //
110 // <linkfrom anchor="MaskedArray mathematical operations" classes="MaskedArray Array Vector Matrix Cube">
111 // <here>MaskedArray mathematical operations</here> -- Mathematical
112 // operations for MaskedArrays, and between MaskedArrays and Arrays.
113 // </linkfrom>
114 //
115 // <group name="MaskedArray mathematical operations">
117 // Element by element arithmetic modifying left in-place. left and other
118 // must be conformant.
119 //
120 // <thrown>
121 // <li> ArrayConformanceError
122 // </thrown>
123 //
124 // <group>
125 template<class T> const MaskedArray<T> & operator+= (const MaskedArray<T> &left, const Array<T> &other);
126 template<class T> const MaskedArray<T> & operator-= (const MaskedArray<T> &left, const Array<T> &other);
127 template<class T> const MaskedArray<T> & operator*= (const MaskedArray<T> &left, const Array<T> &other);
128 template<class T> const MaskedArray<T> & operator/= (const MaskedArray<T> &left, const Array<T> &other);
129 template<class T> Array<T> & operator+= (Array<T> &left, const MaskedArray<T> &other);
130 template<class T> Array<T> & operator-= (Array<T> &left, const MaskedArray<T> &other);
131 template<class T> Array<T> & operator*= (Array<T> &left, const MaskedArray<T> &other);
132 template<class T> Array<T> & operator/= (Array<T> &left, const MaskedArray<T> &other);
133 template<class T> const MaskedArray<T> & operator+= (const MaskedArray<T> &left, const MaskedArray<T> &other);
134 template<class T> const MaskedArray<T> & operator-= (const MaskedArray<T> &left, const MaskedArray<T> &other);
135 template<class T> const MaskedArray<T> & operator*= (const MaskedArray<T> &left, const MaskedArray<T> &other);
136 template<class T> const MaskedArray<T> & operator/= (const MaskedArray<T> &left,const MaskedArray<T> &other);
137 template<class T,class S> const MaskedArray<T> & operator/= (const MaskedArray<T> &left,const MaskedArray<S> &other);
138 // </group>
139 
140 //
141 // Element by element arithmetic modifying left in-place. The scalar "other"
142 // behaves as if it were a conformant Array to left filled with constant values.
143 // <group>
144 template<class T> const MaskedArray<T> & operator+= (const MaskedArray<T> &left,const T &other);
145 template<class T> const MaskedArray<T> & operator-= (const MaskedArray<T> &left,const T &other);
146 template<class T> const MaskedArray<T> & operator*= (const MaskedArray<T> &left,const T &other);
147 template<class T> const MaskedArray<T> & operator/= (const MaskedArray<T> &left,const T &other);
148 // </group>
149 
150 // Unary arithmetic operation.
151 //
152 // <group>
153 template<class T> MaskedArray<T> operator+(const MaskedArray<T> &a);
154 template<class T> MaskedArray<T> operator-(const MaskedArray<T> &a);
155 // </group>
156 
157 //
158 // Element by element arithmetic on MaskedArrays, returns a MaskedArray.
159 //
160 // <thrown>
161 // <li> ArrayConformanceError
162 // </thrown>
163 //
164 // <group>
165 template<class T> MaskedArray<T> operator+ (const MaskedArray<T> &left, const Array<T> &right);
166 template<class T> MaskedArray<T> operator- (const MaskedArray<T> &left, const Array<T> &right);
167 template<class T> MaskedArray<T> operator* (const MaskedArray<T> &left, const Array<T> &right);
168 template<class T> MaskedArray<T> operator/ (const MaskedArray<T> &left, const Array<T> &right);
169 template<class T> MaskedArray<T> operator+ (const Array<T> &left, const MaskedArray<T> &right);
170 template<class T> MaskedArray<T> operator- (const Array<T> &left, const MaskedArray<T> &right);
171 template<class T> MaskedArray<T> operator* (const Array<T> &left, const MaskedArray<T> &right);
172 template<class T> MaskedArray<T> operator/ (const Array<T> &left, const MaskedArray<T> &right);
173 template<class T> MaskedArray<T> operator+ (const MaskedArray<T> &left,const MaskedArray<T> &right);
174 template<class T> MaskedArray<T> operator- (const MaskedArray<T> &left,const MaskedArray<T> &right);
175 template<class T> MaskedArray<T> operator* (const MaskedArray<T> &left,const MaskedArray<T> &right);
176 template<class T> MaskedArray<T> operator/ (const MaskedArray<T> &left,const MaskedArray<T> &right);
177 // </group>
178 
179 //
180 // Element by element arithmetic between a MaskedArray and a scalar, returning
181 // a MaskedArray.
182 // <group>
183 template<class T> MaskedArray<T> operator+ (const MaskedArray<T> &left, const T &right);
184 template<class T> MaskedArray<T> operator- (const MaskedArray<T> &left, const T &right);
185 template<class T> MaskedArray<T> operator* (const MaskedArray<T> &left, const T &right);
186 template<class T> MaskedArray<T> operator/ (const MaskedArray<T> &left, const T &right);
187  MaskedArray<Complex> operator* (const MaskedArray<Complex> &left, const Float &right);
188 // </group>
189 
190 //
191 // Element by element arithmetic between a scalar and a MaskedArray, returning
192 // a MaskedArray.
193 // <group>
194 template<class T> MaskedArray<T> operator+ (const T &left, const MaskedArray<T> &right);
195 template<class T> MaskedArray<T> operator- (const T &left, const MaskedArray<T> &right);
196 template<class T> MaskedArray<T> operator* (const T &left, const MaskedArray<T> &right);
197 template<class T> MaskedArray<T> operator/ (const T &left, const MaskedArray<T> &right);
198  MaskedArray<Complex> operator* (const Float &left, const MaskedArray<Complex> &right);
199 // </group>
200 
201 //
202 // Transcendental function applied to the array on an element-by-element
203 // basis. Although a template function, this may not make sense for all
204 // numeric types.
205 // <group>
206 template<class T> MaskedArray<T> sin(const MaskedArray<T> &left);
207 template<class T> MaskedArray<T> cos(const MaskedArray<T> &left);
208 template<class T> MaskedArray<T> tan(const MaskedArray<T> &left);
209 template<class T> MaskedArray<T> asin(const MaskedArray<T> &left);
210 template<class T> MaskedArray<T> acos(const MaskedArray<T> &left);
211 template<class T> MaskedArray<T> atan(const MaskedArray<T> &left);
212 template<class T> MaskedArray<T> sinh(const MaskedArray<T> &left);
213 template<class T> MaskedArray<T> cosh(const MaskedArray<T> &left);
214 template<class T> MaskedArray<T> tanh(const MaskedArray<T> &left);
215 template<class T> MaskedArray<T> exp(const MaskedArray<T> &left);
216 template<class T> MaskedArray<T> log(const MaskedArray<T> &left);
217 template<class T> MaskedArray<T> log10(const MaskedArray<T> &left);
218 template<class T> MaskedArray<T> sqrt(const MaskedArray<T> &left);
219 template<class T> MaskedArray<T> abs(const MaskedArray<T> &left);
220 template<class T> MaskedArray<T> fabs(const MaskedArray<T> &left);
221 template<class T> MaskedArray<T> ceil(const MaskedArray<T> &left);
222 template<class T> MaskedArray<T> floor(const MaskedArray<T> &left);
223 // </group>
224 
225 // Transcendental functions requiring two arguments applied on an element-by-element
226 // basis. Although a template function, this may not make sense for all
227 // numeric types.
228 // <thrown>
229 // <li> ArrayConformanceError
230 // </thrown>
231 //
232 // <group>
233 template<class T> MaskedArray<T> atan2(const MaskedArray<T> &left, const Array<T> &right);
234 template<class T> MaskedArray<T> fmod(const MaskedArray<T> &left, const Array<T> &right);
235 template<class T> MaskedArray<T> atan2(const Array<T> &left, const MaskedArray<T> &right);
236 template<class T> MaskedArray<T> fmod(const Array<T> &left, const MaskedArray<T> &right);
237 template<class T> MaskedArray<T> atan2(const MaskedArray<T> &left,const MaskedArray<T> &right);
238 template<class T> MaskedArray<T> fmod(const MaskedArray<T> &left,const MaskedArray<T> &right);
239 template<class T> MaskedArray<T> atan2(const MaskedArray<T> &left, const T &right);
240 template<class T> MaskedArray<T> fmod(const MaskedArray<T> &left, const T &right);
241 template<class T> MaskedArray<T> atan2(const T &left, const MaskedArray<T> &right);
242 template<class T> MaskedArray<T> fmod(const T &left, const MaskedArray<T> &right);
243 template<class T, class U> MaskedArray<T> pow(const MaskedArray<T> &left, const Array<U> &right);
244 template<class T, class U> MaskedArray<T> pow(const Array<T> &left, const MaskedArray<U> &right);
245 template<class T, class U> MaskedArray<T> pow(const MaskedArray<T> &left,const MaskedArray<U> &right);
246 template<class T> MaskedArray<T> pow(const MaskedArray<T> &left, const Double &right);
247 // </group>
248 
249 //
250 // Find the minimum and maximum values of a MaskedArray.
251 // Also find the IPositions of the minimum and maximum values.
252 //
253 // <thrown>
254 // <li> ArrayError
255 // </thrown>
256 //
257 // <group>
258 template<class T> void minMax(T &minVal, T &maxVal, IPosition &minPos, IPosition &maxPos,const MaskedArray<T> &marray);
259 template<class T> void minMax(T &minVal, T &maxVal,const MaskedArray<T> &marray);
260 // </group>
261 
262 
263 //
264 // The "min" and "max" functions require that the type "T" have comparison
265 // operators.
266 // The minimum element of the array.
267 template<class T> T min(const MaskedArray<T> &left);
268 
269 
270 // Return an array that contains the minimum of "left" and "right" at each
271 // position.
272 //
273 // "left" and "right" must be conformant.
274 //
275 // <thrown>
276 // <li> ArrayError
277 // </thrown>
278 // <group>
279 template<class T> MaskedArray<T> min(const MaskedArray<T> &left, const Array<T> &right);
280 template<class T> MaskedArray<T> min(const Array<T> &left, const MaskedArray<T> &right);
281 template<class T> MaskedArray<T> min(const MaskedArray<T> &left, const MaskedArray<T> &right);
282 template<class T> MaskedArray<T> min(const T &left, const MaskedArray<T> &right);
283 template<class T> MaskedArray<T> min(const MaskedArray<T> &left, const T &right);
284 // </group>
285 
286 
287 // "result" contains the minimum of "left" and "right" at each position.
288 // "result", "left", and "right" must be conformant.
289 //
290 // <thrown>
291 // <li> ArrayConformanceError
292 // </thrown>
293 //
294 template<class T> void min(const MaskedArray<T> &result, const Array<T> &left, const Array<T> &right);
295 
296 
297 // The maximum element of the array.
298 template<class T> T max(const MaskedArray<T> &left);
299 
300 
301 // Return an array that contains the maximum of "left" and "right" at each
302 // position.
303 //
304 // "left" and "right" must be conformant.
305 // <thrown>
306 // <li> ArrayError
307 // </thrown>
308 //
309 // <group>
310 template<class T> MaskedArray<T> max(const MaskedArray<T> &left, const Array<T> &right);
311 template<class T> MaskedArray<T> max(const Array<T> &left, const MaskedArray<T> &right);
312 template<class T> MaskedArray<T> max(const MaskedArray<T> &left, const MaskedArray<T> &right);
313 template<class T> MaskedArray<T> max(const T &left, const MaskedArray<T> &right);
314 template<class T> MaskedArray<T> max(const MaskedArray<T> &left, const T &right);
315 // </group>
316 
317 
318 // "result" contains the maximum of "left" and "right" at each position.
319 // "result", "left", and "right" must be conformant.
320 //
321 // <thrown>
322 // <li> ArrayConformanceError
323 // </thrown>
324 //
325 template<class T> void max(const MaskedArray<T> &result,const Array<T> &left, const Array<T> &right);
326 
327 //
328 // Fills all elements of "array" where the mask is True with a sequence
329 // starting with "start" and incrementing by "inc" for each element
330 // where the mask is True.
331 // The first axis varies most rapidly.
332 template<class T> void indgen(MaskedArray<T> &a, T start, T inc);
333 
334 //
335 // Fills all elements of "array" where the mask is True with a sequence
336 // starting with 0 and incremented by one for each element
337 // where the mask is True.
338 // The first axis varies most rapidly.
339 template<class T> void indgen(MaskedArray<T> &a);
340 
341 //
342 // Fills all elements of "array" where the mask is True with a sequence
343 // starting with "start" and incremented by one for each element
344 // where the mask is True.
345 // The first axis varies most rapidly.
346 template<class T> void indgen(MaskedArray<T> &a, T start);
347 
348 
349 // <thrown>
350 // <li> ArrayError
351 // </thrown>
352 //
353 // Sum of every element of the MaskedArray where the Mask is True.
354 template<class T> T sum(const MaskedArray<T> &a);
355 
356 //
357 // Sum of the squares of every element of the MaskedArray where the Mask is True.
358 template<class T> T sumsquares(const MaskedArray<T> &a);
359 
360 //
361 // Product of every element of the MaskedArray where the Mask is True.
362 // This could of course easily overflow.
363 template<class T> T product(const MaskedArray<T> &a);
364 
365 //
366 // The mean of "a" is the sum of all elements of "a" divided by the number
367 // of elements of "a".
368 template<class T> T mean(const MaskedArray<T> &a);
369 
370 //
371 // The variance of "a" is the sum of (a(i) - mean(a))**2/(a.nelements() - 1).
372 // N.B. N-1, not N in the denominator).
373 template<class T> T variance(const MaskedArray<T> &a);
374 
375 //
376 // The variance of "a" is the sum of (a(i) - mean(a))**2/(a.nelements() - 1).
377 // N.B. N-1, not N in the denominator).
378 // Rather than using a computed mean, use the supplied value.
379 template<class T> T variance(const MaskedArray<T> &a, T mean);
380 
381 //
382 // The standard deviation of "a" is the sqare root of its variance.
383 template<class T> T stddev(const MaskedArray<T> &a);
384 
385 //
386 // The standard deviation of "a" is the sqare root of its variance.
387 // Rather than using a computed mean, use the supplied value.
388 template<class T> T stddev(const MaskedArray<T> &a, T mean);
389 
390 //
391 // The average deviation of "a" is the sum of abs(a(i) - mean(a))/N. (N.B.
392 // N, not N-1 in the denominator).
393 template<class T> T avdev(const MaskedArray<T> &a);
394 
395 //
396 // The average deviation of "a" is the sum of abs(a(i) - mean(a))/N. (N.B.
397 // N, not N-1 in the denominator).
398 // Rather than using a computed mean, use the supplied value.
399 template<class T> T avdev(const MaskedArray<T> &a,T mean);
400 
401 //
402 // The root-mean-square of "a" is the sqrt of sum(a*a)/N.
403 template<class T> T rms(const MaskedArray<T> &a);
404 
405 //
406 // The median of "a" is a(n/2).
407 // When a has an even number of elements and the switch takeEvenMean is set,
408 // the median is 0.5*(a(n/2) + a((n+1)/2)).
409 // According to Numerical Recipes (2nd edition) it makes little sense to take
410 // the mean when the array is large enough (> 100 elements). Therefore
411 // the default for takeEvenMean is False when the array has > 100 elements,
412 // otherwise it is True.
413 // <br>If "sorted"==True we assume the data is already sorted and we
414 // compute the median directly. Otherwise the function GenSort::kthLargest
415 // is used to find the median (kthLargest is about 6 times faster
416 // than a full quicksort).
417 // <group>
418 template<class T> inline T median(const MaskedArray<T> &a, Bool sorted=False)
419  { return median (a, sorted, (a.nelements() <= 100)); }
420 template<class T> T median(const MaskedArray<T> &a, Bool sorted,
421  Bool takeEvenMean);
422 // </group>
423 
424 // The median absolute deviation from the median. Interface is as for
425 // the median functions
426 // <group>
427 template<class T> inline T madfm(const MaskedArray<T> &a, Bool sorted=False)
428  { return madfm (a, sorted, (a.nelements() <= 100)); }
429 template<class T> T madfm(const MaskedArray<T> &a, Bool sorted,
430  Bool takeEvenMean);
431 // </group>
432 
433 
434 // Returns a MaskedArray where every element is squared.
435 template<class T> MaskedArray<T> square(const MaskedArray<T> &val);
436 
437 // Returns a MaskedArray where every element is cubed.
438 template<class T> MaskedArray<T> cube(const MaskedArray<T> &val);
439 
440 // </group>
441 
442 
443 template<typename T> class MaskedSumFunc {
444 public:
445  T operator() (const MaskedArray<T>& arr) const { return sum(arr); }
446 };
447 template<typename T> class MaskedProductFunc {
448 public:
449  T operator() (const MaskedArray<T>& arr) const { return product(arr); }
450 };
451 template<typename T> class MaskedMinFunc {
452 public:
453  T operator() (const MaskedArray<T>& arr) const { return min(arr); }
454 };
455 template<typename T> class MaskedMaxFunc {
456 public:
457  T operator() (const MaskedArray<T>& arr) const { return max(arr); }
458 };
459 template<typename T> class MaskedMeanFunc {
460 public:
461  T operator() (const MaskedArray<T>& arr) const { return mean(arr); }
462 };
463 template<typename T> class MaskedVarianceFunc {
464 public:
465  T operator() (const MaskedArray<T>& arr) const { return variance(arr); }
466 };
467 template<typename T> class MaskedStddevFunc {
468 public:
469  T operator() (const MaskedArray<T>& arr) const { return stddev(arr); }
470 };
471 template<typename T> class MaskedAvdevFunc {
472 public:
473  T operator() (const MaskedArray<T>& arr) const { return avdev(arr); }
474 };
475 template<typename T> class MaskedRmsFunc {
476 public:
477  T operator() (const MaskedArray<T>& arr) const { return rms(arr); }
478 };
479 template<typename T> class MaskedMedianFunc {
480 public:
481  explicit MaskedMedianFunc (Bool sorted=False, Bool takeEvenMean=True)
482  : itsSorted(sorted), itsTakeEvenMean(takeEvenMean) {}
483  T operator() (const MaskedArray<T>& arr) const
484  { return median(arr, itsSorted, itsTakeEvenMean); }
485 private:
489 };
490 template<typename T> class MaskedMadfmFunc {
491 public:
492  explicit MaskedMadfmFunc(Bool sorted=False, Bool takeEvenMean=True)
493  : itsSorted(sorted), itsTakeEvenMean(takeEvenMean) {}
495  { return madfm(arr, itsSorted, itsTakeEvenMean); }
496 private:
500 };
501 
502 // Apply the given ArrayMath reduction function objects
503 // to each box in the array.
504 // <example>
505 // Downsample an array by taking the mean of every [25,25] elements.
506 // <srcblock>
507 // Array<Float> downArr = boxedArrayMath(in, IPosition(2,25,25),
508 // MaskedMeanFunc<Float>());
509 // </srcblock>
510 // </example>
511 // The dimensionality of the array can be larger than the box; in that
512 // case the missing axes of the box are assumed to have length 1.
513 // A box axis length <= 0 means the full array axis.
514 template <typename T, typename FuncType>
516  const IPosition& boxSize,
517  const FuncType& funcObj);
518 
519 // Apply for each element in the array the given ArrayMath reduction function
520 // object to the box around that element. The full box is 2*halfBoxSize + 1.
521 // It can be used for arrays and boxes of any dimensionality; missing
522 // halfBoxSize values are set to 1.
523 // <example>
524 // Determine for each element in the array the median of a box
525 // with size [51,51] around that element:
526 // <srcblock>
527 // Array<Float> medians = slidingArrayMath(in, IPosition(2,25,25),
528 // MaskedMedianFunc<Float>());
529 // </srcblock>
530 // This is a potentially expensive operation. On a high-end PC it took
531 // appr. 27 seconds to get the medians for an array of [1000,1000] using
532 // a halfBoxSize of [50,50].
533 // </example>
534 // <br>The fillEdge argument determines how the edge is filled where
535 // no full boxes can be made. True means it is set to zero; False means
536 // that the edge is removed, thus the output array is smaller than the
537 // input array.
538 // <note> This brute-force method of determining the medians outperforms
539 // all kinds of smart implementations. For a vector it is about as fast
540 // as class <linkto class=MedianSlider>MedianSlider</linkto>, for a 2D array
541 // it is much, much faster.
542 // </note>
543 template <typename T, typename FuncType>
545  const IPosition& halfBoxSize,
546  const FuncType& funcObj,
547  Bool fillEdge=True);
548 
549 
550 } //# NAMESPACE CASACORE - END
551 
552 #ifndef CASACORE_NO_AUTO_TEMPLATES
553 #include <casacore/casa/Arrays/MaskArrMath.tcc>
554 #endif //# CASACORE_NO_AUTO_TEMPLATES
555 #endif
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
LatticeExprNode log10(const LatticeExprNode &expr)
Float operator()(const MaskedArray< Float > &arr) const
Definition: MaskArrMath.h:494
LatticeExprNode log(const LatticeExprNode &expr)
LatticeExprNode median(const LatticeExprNode &expr)
LatticeExprNode operator/(const LatticeExprNode &left, const LatticeExprNode &right)
T product(const TableVector< T > &tv)
Definition: TabVecMath.h:385
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
Definition: ExprNode.h:2105
LatticeExprNode sum(const LatticeExprNode &expr)
uInt nelements() const
The number of elements of this masked array.
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
MaskedMadfmFunc(Bool sorted=False, Bool takeEvenMean=True)
Definition: MaskArrMath.h:492
LatticeExprNode exp(const LatticeExprNode &expr)
TableExprNode marray(const TableExprNode &array, const TableExprNode &mask)
Form a masked array.
Definition: ExprNode.h:2111
LatticeExprNode floor(const LatticeExprNode &expr)
LatticeExprNode cos(const LatticeExprNode &expr)
Class for masking an Array for operations on that Array.
Definition: Array.h:55
Float pow(Float f1, Float f2)
Definition: math.h:90
LatticeExprNode tanh(const LatticeExprNode &expr)
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode avdev(const LatticeExprNode &expr)
double Double
Definition: aipstype.h:55
LatticeExprNode abs(const LatticeExprNode &expr)
Numerical 1-argument functions which result in a real number regardless of input expression type...
LatticeExprNode sqrt(const LatticeExprNode &expr)
LatticeExprNode tan(const LatticeExprNode &expr)
void indgen(TableVector< T > &tv, Int start, Int inc)
Definition: TabVecMath.h:400
LatticeExprNode atan(const LatticeExprNode &expr)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void minMax(T &min, T &max, const TableVector< T > &tv)
Definition: TabVecMath.h:390
T median(const MaskedArray< T > &a, Bool sorted=False)
The median of "a" is a(n/2).
Definition: MaskArrMath.h:418
MaskedArray< T > boxedArrayMath(const MaskedArray< T > &array, const IPosition &boxSize, const FuncType &funcObj)
Apply the given ArrayMath reduction function objects to each box in the array.
TableExprNode cube(const TableExprNode &node)
Definition: ExprNode.h:1527
LatticeExprNode stddev(const LatticeExprNode &expr)
float Float
Definition: aipstype.h:54
const Bool False
Definition: aipstype.h:44
template <class T, class U> class vector;
Definition: Array.h:169
LatticeExprNode atan2(const LatticeExprNode &left, const LatticeExprNode &right)
Numerical 2-argument functions.
MaskedMedianFunc(Bool sorted=False, Bool takeEvenMean=True)
Definition: MaskArrMath.h:481
LatticeExprNode operator+(const LatticeExprNode &expr)
Global functions operating on a LatticeExprNode.
LatticeExprNode fmod(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode asin(const LatticeExprNode &expr)
LatticeExprNode mean(const LatticeExprNode &expr)
TableExprNode rms(const TableExprNode &array)
Definition: ExprNode.h:1856
LatticeExprNode sinh(const LatticeExprNode &expr)
LatticeExprNode acos(const LatticeExprNode &expr)
TableExprNode square(const TableExprNode &node)
Definition: ExprNode.h:1522
Array< T > slidingArrayMath(const MaskedArray< T > &array, const IPosition &halfBoxSize, const FuncType &funcObj, Bool fillEdge=True)
Apply for each element in the array the given ArrayMath reduction function object to the box around t...
LatticeExprNode operator-(const LatticeExprNode &expr)
T madfm(const MaskedArray< T > &a, Bool sorted=False)
The median absolute deviation from the median.
Definition: MaskArrMath.h:427
T operator()(const MaskedArray< T > &arr) const
Definition: MaskArrMath.h:445
LatticeExprNode variance(const LatticeExprNode &expr)
LatticeExprNode ceil(const LatticeExprNode &expr)
const Bool True
Definition: aipstype.h:43
this file contains all the compiler specific defines
Definition: mainpage.dox:28
MVBaseline operator*(const RotMatrix &left, const MVBaseline &right)
Rotate a Baseline vector with rotation matrix and other multiplications.
LatticeExprNode cosh(const LatticeExprNode &expr)
LatticeExprNode sin(const LatticeExprNode &expr)
Numerical 1-argument functions.