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