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