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
37// tMaskArrMath2 tMaskArrExcp">
38//
39// <prerequisite>
40// <li> <linkto class=Array>Array</linkto>
41// <li> <linkto class=MaskedArray>MaskedArray</linkto>
42// </prerequisite>
43//
44// <etymology>
45// MaskArrMath is short for MaskedArrayMath, which is too long by the old
46// AIPS++ file naming conventions. This file contains global functions
47// which perform element by element mathematical operations on masked arrays.
48// </etymology>
49//
50// <synopsis>
51// These functions perform element by element mathematical operations on
52// masked arrays. With two arrays, they must both conform, and the result
53// is done element by element, for those locations where the mask of the
54// MaskedArray is true. For two MaskedArrays, the "and" of the masks is used.
55// </synopsis>
56//
57// <example>
58// <srcblock>
59// Vector<int> a(10);
60// Vector<int> b(10);
61// Vector<int> c(10);
62// . . .
63// c = a(a>0) + b(b>0);
64// </srcblock>
65// This example sets those elements of c where ((a>0) && (b>0)) to (a+b).
66// Elements of c where !((a>0) && (b>0)) are unchanged. The result of
67// this operation is a MaskedArray. The assignment from this
68// MaskedArray to the Vector c only assigns those elements
69// where the mask is true.
70// </example>
71//
72// <example>
73// <srcblock>
74// Vector<double> a(10);
75// Vector<double> b(10);
76// Vector<double> c(10);
77// . . .
78// c = atan2 (a, b(b>0);
79// </srcblock>
80// This example sets those elements of c where (b>0) to atan2 (a,b).
81// Elements of c where !(b>0) are unchanged. The result of
82// this operation is a MaskedArray. The assignment from this
83// MaskedArray to the Vector c only assigns those elements
84// where the mask is true.
85// </example>
86//
87// <example>
88// <srcblock>
89// Vector<int> a(10);
90// int result;
91// . . .
92// result = sum (a(a>0));
93// </srcblock>
94// This example sums a, for those elements of a which are greater than 0.
95// </example>
96//
97// <motivation>
98// One wants to be able to mask arrays and perform mathematical operations on
99// those masked arrays. Since the masked arrays are only defined where
100// the masks are true, the result must be a MaskedArray, or a simple number.
101// </motivation>
102//
103// <linkfrom anchor="MaskedArray mathematical operations" classes="MaskedArray Array Vector Matrix
104// 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>
120const MaskedArray<T> &operator+=(const MaskedArray<T> &left, const Array<T> &other);
121template <class T>
122const MaskedArray<T> &operator-=(const MaskedArray<T> &left, const Array<T> &other);
123template <class T>
124const MaskedArray<T> &operator*=(const MaskedArray<T> &left, const Array<T> &other);
125template <class T>
126const MaskedArray<T> &operator/=(const MaskedArray<T> &left, const Array<T> &other);
127template <class T>
129template <class T>
131template <class T>
133template <class T>
135template <class T>
136const MaskedArray<T> &operator+=(const MaskedArray<T> &left, const MaskedArray<T> &other);
137template <class T>
138const MaskedArray<T> &operator-=(const MaskedArray<T> &left, const MaskedArray<T> &other);
139template <class T>
140const MaskedArray<T> &operator*=(const MaskedArray<T> &left, const MaskedArray<T> &other);
141template <class T>
142const MaskedArray<T> &operator/=(const MaskedArray<T> &left, const MaskedArray<T> &other);
143template <class T, class S>
144const MaskedArray<T> &operator/=(const MaskedArray<T> &left, const MaskedArray<S> &other);
145// </group>
146
147//
148// Element by element arithmetic modifying left in-place. The scalar "other"
149// behaves as if it were a conformant Array to left filled with constant values.
150// <group>
151template <class T>
152const MaskedArray<T> &operator+=(const MaskedArray<T> &left, const T &other);
153template <class T>
154const MaskedArray<T> &operator-=(const MaskedArray<T> &left, const T &other);
155template <class T>
156const MaskedArray<T> &operator*=(const MaskedArray<T> &left, const T &other);
157template <class T>
158const MaskedArray<T> &operator/=(const MaskedArray<T> &left, const T &other);
159// </group>
160
161// Unary arithmetic operation.
162//
163// <group>
164template <class T>
166template <class T>
168// </group>
169
170//
171// Element by element arithmetic on MaskedArrays, returns a MaskedArray.
172//
173// <thrown>
174// <li> ArrayConformanceError
175// </thrown>
176//
177// <group>
178template <class T>
180template <class T>
182template <class T>
184template <class T>
186template <class T>
188template <class T>
190template <class T>
192template <class T>
194template <class T>
196template <class T>
198template <class T>
200template <class T>
202// </group>
203
204//
205// Element by element arithmetic between a MaskedArray and a scalar, returning
206// a MaskedArray.
207// <group>
208template <class T>
209MaskedArray<T> operator+(const MaskedArray<T> &left, const T &right);
210template <class T>
211MaskedArray<T> operator-(const MaskedArray<T> &left, const T &right);
212template <class T>
213MaskedArray<T> operator*(const MaskedArray<T> &left, const T &right);
214template <class T>
215MaskedArray<T> operator/(const MaskedArray<T> &left, const T &right);
216MaskedArray<std::complex<float>> operator*(const MaskedArray<std::complex<float>> &left,
217 const float &right);
218// </group>
219
220//
221// Element by element arithmetic between a scalar and a MaskedArray, returning
222// a MaskedArray.
223// <group>
224template <class T>
225MaskedArray<T> operator+(const T &left, const MaskedArray<T> &right);
226template <class T>
227MaskedArray<T> operator-(const T &left, const MaskedArray<T> &right);
228template <class T>
229MaskedArray<T> operator*(const T &left, const MaskedArray<T> &right);
230template <class T>
231MaskedArray<T> operator/(const T &left, const MaskedArray<T> &right);
233 const MaskedArray<std::complex<float>> &right);
234// </group>
235
236//
237// Transcendental function applied to the array on an element-by-element
238// basis. Although a template function, this may not make sense for all
239// numeric types.
240// <group>
241template <class T>
243template <class T>
245template <class T>
247template <class T>
249template <class T>
251template <class T>
253template <class T>
255template <class T>
257template <class T>
259template <class T>
261template <class T>
263template <class T>
265template <class T>
267template <class T>
269template <class T>
271template <class T>
273template <class T>
275// </group>
276
277// Transcendental functions requiring two arguments applied on an element-by-element
278// basis. Although a template function, this may not make sense for all
279// numeric types.
280// <thrown>
281// <li> ArrayConformanceError
282// </thrown>
283//
284// <group>
285template <class T>
286MaskedArray<T> atan2(const MaskedArray<T> &left, const Array<T> &right);
287template <class T>
288MaskedArray<T> fmod(const MaskedArray<T> &left, const Array<T> &right);
289template <class T>
290MaskedArray<T> atan2(const Array<T> &left, const MaskedArray<T> &right);
291template <class T>
292MaskedArray<T> fmod(const Array<T> &left, const MaskedArray<T> &right);
293template <class T>
295template <class T>
297template <class T>
298MaskedArray<T> atan2(const MaskedArray<T> &left, const T &right);
299template <class T>
300MaskedArray<T> fmod(const MaskedArray<T> &left, const T &right);
301template <class T>
302MaskedArray<T> atan2(const T &left, const MaskedArray<T> &right);
303template <class T>
304MaskedArray<T> fmod(const T &left, const MaskedArray<T> &right);
305template <class T, class U>
306MaskedArray<T> pow(const MaskedArray<T> &left, const Array<U> &right);
307template <class T, class U>
308MaskedArray<T> pow(const Array<T> &left, const MaskedArray<U> &right);
309template <class T, class U>
311template <class T>
312MaskedArray<T> pow(const MaskedArray<T> &left, const double &right);
313// </group>
314
315// Extracts the real part of a complex array into an array of floats.
316template <class T>
317MaskedArray<T> real(const MaskedArray<std::complex<T>> &carray) {
318 return MaskedArray<T>(real(carray.getArray()), carray.getMask());
319}
320
321//
322// Extracts the imaginary part of a complex array into an array of floats.
323template <class T>
324MaskedArray<T> imag(const MaskedArray<std::complex<T>> &carray) {
325 return MaskedArray<T>(imag(carray.getArray()), carray.getMask());
326}
327
328//
329// Find the minimum and maximum values of a MaskedArray.
330// Also find the IPositions of the minimum and maximum values.
331//
332// <thrown>
333// <li> ArrayError
334// </thrown>
335//
336// <group>
337template <class T>
338void minMax(T &minVal, T &maxVal, IPosition &minPos, IPosition &maxPos,
339 const MaskedArray<T> &marray);
340template <class T>
341void minMax(T &minVal, T &maxVal, const MaskedArray<T> &marray);
342// </group>
343
344//
345// The "min" and "max" functions require that the type "T" have comparison
346// operators.
347// The minimum element of the array.
348template <class T>
349T min(const MaskedArray<T> &left);
350
351// Return an array that contains the minimum of "left" and "right" at each
352// position.
353//
354// "left" and "right" must be conformant.
355//
356// <thrown>
357// <li> ArrayError
358// </thrown>
359// <group>
360template <class T>
361MaskedArray<T> min(const MaskedArray<T> &left, const Array<T> &right);
362template <class T>
363MaskedArray<T> min(const Array<T> &left, const MaskedArray<T> &right);
364template <class T>
366template <class T>
367MaskedArray<T> min(const T &left, const MaskedArray<T> &right);
368template <class T>
369MaskedArray<T> min(const MaskedArray<T> &left, const T &right);
370// </group>
371
372// "result" contains the minimum of "left" and "right" at each position.
373// "result", "left", and "right" must be conformant.
374//
375// <thrown>
376// <li> ArrayConformanceError
377// </thrown>
378//
379template <class T>
380void min(const MaskedArray<T> &result, const Array<T> &left, const Array<T> &right);
381
382// The maximum element of the array.
383template <class T>
384T max(const MaskedArray<T> &left);
385
386// Return an array that contains the maximum of "left" and "right" at each
387// position.
388//
389// "left" and "right" must be conformant.
390// <thrown>
391// <li> ArrayError
392// </thrown>
393//
394// <group>
395template <class T>
396MaskedArray<T> max(const MaskedArray<T> &left, const Array<T> &right);
397template <class T>
398MaskedArray<T> max(const Array<T> &left, const MaskedArray<T> &right);
399template <class T>
401template <class T>
402MaskedArray<T> max(const T &left, const MaskedArray<T> &right);
403template <class T>
404MaskedArray<T> max(const MaskedArray<T> &left, const T &right);
405// </group>
406
407// "result" contains the maximum of "left" and "right" at each position.
408// "result", "left", and "right" must be conformant.
409//
410// <thrown>
411// <li> ArrayConformanceError
412// </thrown>
413//
414template <class T>
415void max(const MaskedArray<T> &result, const Array<T> &left, const Array<T> &right);
416
417//
418// Fills all elements of "array" where the mask is true with a sequence
419// starting with "start" and incrementing by "inc" for each element
420// where the mask is true.
421// The first axis varies most rapidly.
422template <class T>
423void indgen(MaskedArray<T> &a, T start, T inc);
424
425//
426// Fills all elements of "array" where the mask is true with a sequence
427// starting with 0 and incremented by one for each element
428// where the mask is true.
429// The first axis varies most rapidly.
430template <class T>
432
433//
434// Fills all elements of "array" where the mask is true with a sequence
435// starting with "start" and incremented by one for each element
436// where the mask is true.
437// The first axis varies most rapidly.
438template <class T>
439void indgen(MaskedArray<T> &a, T start);
440
441// <thrown>
442// <li> ArrayError
443// </thrown>
444//
445// Sum of every element of the MaskedArray where the Mask is true.
446template <class T>
447T sum(const MaskedArray<T> &a);
448
449//
450// Sum of the squares of every element of the MaskedArray where the Mask is true.
451template <class T>
453
454//
455// Product of every element of the MaskedArray where the Mask is true.
456// This could of course easily overflow.
457template <class T>
459
460//
461// The mean of "a" is the sum of all elements of "a" divided by the number
462// of elements of "a".
463template <class T>
465
466//
467// The variance of "a" is the sum of (a(i) - mean(a))**2/(a.nelements() - ddof).
468// Similar to numpy the argument ddof tells if the population variance (ddof=0)
469// or the sample variance (ddof=1) is taken.
470// The variance functions proper use ddof=1.
471// <br>Note that for a complex valued T the absolute values are used; in that way
472// the variance is equal to the sum of the variances of the real and imaginary parts.
473// Hence the imaginary part in the return value is 0.
474template <class T>
476template <class T>
477T pvariance(const MaskedArray<T> &a, size_t ddof = 0);
478// Rather than using a computed mean, use the supplied value.
479template <class T>
481template <class T>
482T pvariance(const MaskedArray<T> &a, T mean, size_t ddof = 0);
483
484// The standard deviation of "a" is the square root of its variance.
485template <class T>
487template <class T>
488T pstddev(const MaskedArray<T> &a, size_t ddof = 0);
489template <class T>
491template <class T>
492T pstddev(const MaskedArray<T> &a, T mean, size_t ddof = 0);
493
494//
495// The average deviation of "a" is the sum of abs(a(i) - mean(a))/N. (N.B.
496// N, not N-1 in the denominator).
497template <class T>
499
500//
501// The average deviation of "a" is the sum of abs(a(i) - mean(a))/N. (N.B.
502// N, not N-1 in the denominator).
503// Rather than using a computed mean, use the supplied value.
504template <class T>
505T avdev(const MaskedArray<T> &a, T mean);
506
507//
508// The root-mean-square of "a" is the sqrt of sum(a*a)/N.
509template <class T>
510T rms(const MaskedArray<T> &a);
511
512//
513// The median of "a" is a(n/2).
514// When a has an even number of elements and the switch takeEvenMean is set,
515// the median is 0.5*(a(n/2) + a((n+1)/2)).
516// According to Numerical Recipes (2nd edition) it makes little sense to take
517// the mean when the array is large enough (> 100 elements). Therefore
518// the default for takeEvenMean is false when the array has > 100 elements,
519// otherwise it is true.
520// <br>If "sorted"==true we assume the data is already sorted and we
521// compute the median directly. Otherwise the function GenSort::kthLargest
522// is used to find the median (kthLargest is about 6 times faster
523// than a full quicksort).
524// <group>
525template <class T>
526inline T median(const MaskedArray<T> &a, bool sorted = false) {
527 return median(a, sorted, (a.nelements() <= 100));
528}
529template <class T>
530T median(const MaskedArray<T> &a, bool sorted, bool takeEvenMean);
531// </group>
532
533// The median absolute deviation from the median. Interface is as for
534// the median functions
535// <group>
536template <class T>
537inline T madfm(const MaskedArray<T> &a, bool sorted = false) {
538 return madfm(a, sorted, (a.nelements() <= 100));
539}
540template <class T>
541T madfm(const MaskedArray<T> &a, bool sorted, bool takeEvenMean);
542// </group>
543
544// Returns a MaskedArray where every element is squared.
545template <class T>
547
548// Returns a MaskedArray where every element is cubed.
549template <class T>
551
552// </group>
553
554template <typename T>
556 public:
557 T operator()(const MaskedArray<T> &arr) const { return sum(arr); }
558};
559template <typename T>
561 public:
562 T operator()(const MaskedArray<T> &arr) const { return product(arr); }
563};
564template <typename T>
566 public:
567 T operator()(const MaskedArray<T> &arr) const { return min(arr); }
568};
569template <typename T>
571 public:
572 T operator()(const MaskedArray<T> &arr) const { return max(arr); }
573};
574template <typename T>
576 public:
577 T operator()(const MaskedArray<T> &arr) const { return mean(arr); }
578};
579template <typename T>
581 public:
582 T operator()(const MaskedArray<T> &arr) const { return variance(arr); }
583};
584template <typename T>
586 public:
587 T operator()(const MaskedArray<T> &arr) const { return stddev(arr); }
588};
589template <typename T>
591 public:
592 T operator()(const MaskedArray<T> &arr) const { return avdev(arr); }
593};
594template <typename T>
596 public:
597 T operator()(const MaskedArray<T> &arr) const { return rms(arr); }
598};
599template <typename T>
601 public:
602 explicit MaskedMedianFunc(bool sorted = false, bool takeEvenMean = true)
603 : itsSorted(sorted), itsTakeEvenMean(takeEvenMean) {}
604 T operator()(const MaskedArray<T> &arr) const { return median(arr, itsSorted, itsTakeEvenMean); }
605
606 private:
610};
611template <typename T>
613 public:
614 explicit MaskedMadfmFunc(bool sorted = false, bool takeEvenMean = true)
615 : itsSorted(sorted), itsTakeEvenMean(takeEvenMean) {}
616 float operator()(const MaskedArray<float> &arr) const {
617 return madfm(arr, itsSorted, itsTakeEvenMean);
618 }
619
620 private:
624};
625
626// Apply the given ArrayMath reduction function objects
627// to each box in the array.
628// <example>
629// Downsample an array by taking the mean of every [25,25] elements.
630// <srcblock>
631// Array<float> downArr = boxedArrayMath(in, IPosition(2,25,25),
632// MaskedMeanFunc<float>());
633// </srcblock>
634// </example>
635// The dimensionality of the array can be larger than the box; in that
636// case the missing axes of the box are assumed to have length 1.
637// A box axis length <= 0 means the full array axis.
638template <typename T, typename FuncType>
640 const FuncType &funcObj);
641
642// Apply for each element in the array the given ArrayMath reduction function
643// object to the box around that element. The full box is 2*halfBoxSize + 1.
644// It can be used for arrays and boxes of any dimensionality; missing
645// halfBoxSize values are set to 1.
646// <example>
647// Determine for each element in the array the median of a box
648// with size [51,51] around that element:
649// <srcblock>
650// Array<float> medians = slidingArrayMath(in, IPosition(2,25,25),
651// MaskedMedianFunc<float>());
652// </srcblock>
653// This is a potentially expensive operation. On a high-end PC it took
654// appr. 27 seconds to get the medians for an array of [1000,1000] using
655// a halfBoxSize of [50,50].
656// </example>
657// <br>The fillEdge argument determines how the edge is filled where
658// no full boxes can be made. true means it is set to zero; false means
659// that the edge is removed, thus the output array is smaller than the
660// input array.
661// <note> This brute-force method of determining the medians outperforms
662// all kinds of smart implementations. For a vector it is about as fast
663// as the casacore class MedianSlider, for a 2D array
664// it is much, much faster.
665// </note>
666template <typename T, typename FuncType>
668 const FuncType &funcObj, bool fillEdge = true);
669
670} // namespace casacore
671
672#include "MaskArrMath.tcc"
673
674#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
For temporary backward namespace compatibility, use casa as alias for casacore.
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)
T * array
The actual storage.
Definition Block.h:689
LatticeExprNode stddev(const LatticeExprNode &expr)
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode variance(const LatticeExprNode &expr)
T product(const TableVector< T > &tv)
Definition TabVecMath.h:380
LatticeExprNode avdev(const LatticeExprNode &expr)
TableExprNode marray(const TableExprNode &array, const TableExprNode &mask)
Form a masked array.
Definition ExprNode.h:1567
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:1430
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.
MaskedArray< T > operator+(const MaskedArray< T > &left, const Array< T > &right)
Element by element arithmetic on MaskedArrays, returns a MaskedArray.
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 > operator-(const Array< T > &left, const MaskedArray< 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)
const MaskedArray< T > & operator-=(const MaskedArray< T > &left, const MaskedArray< T > &other)
MaskedArray< T > max(const T &left, const MaskedArray< T > &right)
MaskedArray< T > operator-(const T &left, const MaskedArray< T > &right)
Array< T > & operator*=(Array< T > &left, const MaskedArray< T > &other)
T madfm(const MaskedArray< T > &a, bool sorted=false)
The median absolute deviation from the median.
MaskedArray< T > operator+(const MaskedArray< T > &left, const T &right)
Element by element arithmetic between a MaskedArray and a scalar, returning a MaskedArray.
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.
const MaskedArray< T > & operator/=(const MaskedArray< T > &left, const MaskedArray< T > &other)
MaskedArray< T > max(const Array< T > &left, const MaskedArray< T > &right)
MaskedArray< T > operator/(const MaskedArray< T > &left, const MaskedArray< T > &right)
const MaskedArray< T > & operator+=(const MaskedArray< T > &left, const T &other)
Element by element arithmetic modifying left in-place.
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.
Array< T > & operator/=(Array< T > &left, const MaskedArray< T > &other)
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.
MaskedArray< T > operator+(const Array< T > &left, const MaskedArray< T > &right)
MaskedArray< T > operator/(const MaskedArray< T > &left, const T &right)
const MaskedArray< T > & operator+=(const MaskedArray< T > &left, const MaskedArray< T > &other)
MaskedArray< T > operator-(const MaskedArray< T > &left, const T &right)
MaskedArray< T > operator/(const Array< T > &left, const MaskedArray< T > &right)
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 > operator-(const MaskedArray< T > &left, const MaskedArray< T > &right)
MaskedArray< T > operator+(const MaskedArray< T > &left, const MaskedArray< T > &right)
const MaskedArray< T > & operator/=(const MaskedArray< T > &left, const MaskedArray< S > &other)
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 > operator*(const Array< T > &left, const MaskedArray< T > &right)
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)
MaskedArray< std::complex< float > > operator*(const MaskedArray< std::complex< float > > &left, const float &right)
MaskedArray< std::complex< float > > operator*(const float &left, const MaskedArray< std::complex< float > > &right)
Array< T > & operator-=(Array< T > &left, const MaskedArray< T > &other)
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.
MaskedArray< T > operator*(const MaskedArray< T > &left, const T &right)
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.
const MaskedArray< T > & operator-=(const MaskedArray< T > &left, const T &other)
MaskedArray< T > operator*(const MaskedArray< T > &left, const MaskedArray< T > &right)
MaskedArray< T > operator-(const MaskedArray< T > &left, const Array< T > &right)
MaskedArray< T > operator/(const T &left, const MaskedArray< T > &right)
Array< T > & operator+=(Array< T > &left, const MaskedArray< T > &other)
MaskedArray< T > min(const MaskedArray< T > &left, const MaskedArray< T > &right)
T madfm(const MaskedArray< T > &a, bool sorted, bool takeEvenMean)
const MaskedArray< T > & operator*=(const MaskedArray< T > &left, const MaskedArray< T > &other)
const MaskedArray< T > & operator*=(const MaskedArray< T > &left, const T &other)
MaskedArray< T > pow(const MaskedArray< T > &left, const Array< U > &right)
MaskedArray< T > min(const T &left, const MaskedArray< T > &right)
MaskedArray< T > operator*(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...
MaskedArray< T > operator+(const T &left, const MaskedArray< T > &right)
Element by element arithmetic between a scalar and a MaskedArray, returning a MaskedArray.
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.
const MaskedArray< T > & operator/=(const MaskedArray< T > &left, const T &other)
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)