28 #ifndef CASA_ARRAYMATH_H
29 #define CASA_ARRAYMATH_H
44 template<
class T>
class Matrix;
149 template<
typename _InputIterator1,
typename T,
150 typename _OutputIterator,
typename _BinaryOperation>
153 _OutputIterator __result, T left,
154 _BinaryOperation __binary_op)
156 for ( ; __first1 != __last1; ++__first1, ++__result)
157 *__result = __binary_op(left, *__first1);
160 template<
typename _InputIterator1,
typename T,
161 typename _OutputIterator,
typename _BinaryOperation>
164 _OutputIterator __result, T right,
165 _BinaryOperation __binary_op)
167 for ( ; __first1 != __last1; ++__first1, ++__result)
168 *__result = __binary_op(*__first1, right);
171 template<
typename _InputIterator1,
typename T,
172 typename _BinaryOperation>
176 _BinaryOperation __binary_op)
178 for ( ; __first1 != __last1; ++__first1)
179 *__first1 = __binary_op(*__first1, right);
191 template<
typename L,
typename R,
typename RES,
typename BinaryOperator>
207 template<
typename L,
typename R,
typename RES,
typename BinaryOperator>
214 result.
cbegin(), right, op);
218 myrtransform (left.
begin(), left.
end(),
219 result.
cbegin(), right, op);
227 template<
typename L,
typename R,
typename RES,
typename BinaryOperator>
234 result.
cbegin(), left, op);
238 myltransform (right.
begin(), right.
end(),
239 result.
cbegin(), left, op);
247 template<
typename T,
typename RES,
typename UnaryOperator>
261 template<
typename L,
typename R,
typename RES,
typename BinaryOperator>
267 template<
typename L,
typename R,
typename RES,
typename BinaryOperator>
268 void arrayTransform (
const Array<L>& left, R right,
273 template<
typename L,
typename R,
typename RES,
typename BinaryOperator>
274 void arrayTransform (L left,
const Array<R>& right,
279 template<
typename T,
typename RES,
typename UnaryOperator>
280 void arrayTransform (
const Array<T>& arr,
285 template<
typename T,
typename BinaryOperator>
291 template<
typename T,
typename BinaryOperator>
292 Array<T> arrayTransformResult (
const Array<T>& left, T right, BinaryOperator op);
296 template<
typename T,
typename BinaryOperator>
297 Array<T> arrayTransformResult (T left,
const Array<T>& right, BinaryOperator op);
301 template<
typename T,
typename UnaryOperator>
306 template<
typename L,
typename R,
typename BinaryOperator>
319 template<
typename L,
typename R,
typename BinaryOperator>
323 myiptransform (left.
cbegin(), left.
cend(), right, op);
326 myiptransform (left.
begin(), left.
end(), right, op);
334 template<
typename T,
typename UnaryOperator>
363 template<
class T>
void operator+= (
Array<T> &left,
const T &other);
364 template<
class T>
void operator-= (
Array<T> &left,
const T &other);
365 template<
class T>
void operator*= (
Array<T> &left,
const T &other);
366 template<
class T>
void operator/= (
Array<T> &left,
const T &other);
367 template<
class T>
void operator%= (
Array<T> &left,
const T &other);
368 template<
class T>
void operator&= (
Array<T> &left,
const T &other);
369 template<
class T>
void operator|= (
Array<T> &left,
const T &other);
370 template<
class T>
void operator^= (
Array<T> &left,
const T &other);
495 template<
class ScalarType>
501 template<
class ScalarType>
506 template<
class ScalarType>
507 void minMaxMasked(ScalarType &minVal, ScalarType &maxVal,
IPosition &minPos,
550 {
max (result, b, a); }
557 {
min (result, b, a); }
561 {
return max(b, a); }
565 {
return min(b, a); }
578 {
indgen(a, T(0), T(1)); }
584 {
indgen(a, start, T(1)); }
600 template<
class T> T sumsqr(
const Array<T> &a);
619 template<
class T> T pvariance(
const Array<T> &a,
uInt ddof=0);
626 template<
class T> T pstddev(
const Array<T> &a,
uInt ddof=0);
667 {
Block<T> tmp;
return median (a, tmp, sorted, takeEvenMean, inPlace); }
683 {
Block<T> tmp;
return madfm(a, tmp, sorted, takeEvenMean, inPlace); }
713 {
Block<T> tmp;
return interFractileRange(a, tmp, fraction, sorted, inPlace); }
725 {
return interFractileRange(a, tmp, 1./6., sorted, inPlace); }
728 {
return interFractileRange(a, 1./6., sorted, inPlace); }
737 {
return interFractileRange(a, tmp, 0.25, sorted, inPlace); }
740 {
return interFractileRange(a, 0.25, sorted, inPlace); }
748 void operator*= (
Array<std::complex<T> > &left,
const Array<T> &other);
750 void operator*= (
Array<std::complex<T> > &left,
const T &other);
752 void operator/= (
Array<std::complex<T> > &left,
const Array<T> &other);
754 void operator/= (
Array<std::complex<T> > &left,
const T &other);
801 template<
typename L,
typename R>
805 template<
typename R,
typename L>
879 template<
class T,
class U>
void convertArray(
Array<T> &to,
906 const T* in, T* out,
const IPosition& alternate);
927 #ifndef CASACORE_NO_AUTO_TEMPLATES
928 #include <casacore/casa/Arrays/ArrayMath.tcc>
929 #endif //# CASACORE_NO_AUTO_TEMPLATES
Array< T > max(const T &a, const Array< T > &b)
A Vector of integers, for indexing into Array<T> objects.
LatticeExprNode log10(const LatticeExprNode &expr)
A 1-D Specialization of the Array class.
T interHexileRange(const Array< T > &a, Bool sorted=False, Bool inPlace=False)
LatticeExprNode log(const LatticeExprNode &expr)
T interHexileRange(const Array< T > &a, Block< T > &tmp, Bool sorted=False, Bool inPlace=False)
Return the inter-hexile range of an array.
T median(const Array< T > &a, Bool sorted, Bool takeEvenMean, Bool inPlace=False)
LatticeExprNode median(const LatticeExprNode &expr)
size_t nelements() const
How many elements does this array have? Product of all axis lengths.
LatticeExprNode operator/(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
LatticeExprNode imag(const LatticeExprNode &expr)
void myiptransform(_InputIterator1 __first1, _InputIterator1 __last1, T right, _BinaryOperation __binary_op)
sequence OP= scalar
T medianInPlace(const Array< T > &a, Bool sorted=False)
void myrtransform(_InputIterator1 __first1, _InputIterator1 __last1, _OutputIterator __result, T right, _BinaryOperation __binary_op)
sequence = sequence OP scalar
TableExprNode array(const TableExprNode &values, const TableExprNodeSet &shape)
Create an array of the given shape and fill it with the values.
LatticeExprNode sum(const LatticeExprNode &expr)
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode operator%(const LatticeExprNode &left, const LatticeExprNode &right)
T fractile(const Array< T > &a, Float fraction, Bool sorted=False, Bool inPlace=False)
TableExprNode phase(const TableExprNode &node)
The phase (i.e.
Array< T > min(const T &a, const Array< T > &b)
void max(Array< T > &result, const T &a, const Array< T > &b)
void arrayTransformInPlace(Array< L > &left, const Array< R > &right, BinaryOperator op)
Transform left and right in place using the binary operator.
LatticeExprNode fractile(const LatticeExprNode &expr, const LatticeExprNode &fraction)
Determine the value of the element at the part fraction from the beginning of the given lattice...
T madfm(const Array< T > &a)
TableExprNode operator&(const TableExprNode &left, const TableExprNode &right)
LatticeExprNode exp(const LatticeExprNode &expr)
iterator begin()
Get the begin iterator object for any array.
Bool contiguousStorage() const
Are the array data contiguous? If they are not contiguous, getStorage (see below) needs to make a cop...
LatticeExprNode floor(const LatticeExprNode &expr)
MVEarthMagnetic operator*(const RotMatrix &left, const MVEarthMagnetic &right)
Rotate a EarthMagnetic vector with rotation matrix and other multiplications.
LatticeExprNode cos(const LatticeExprNode &expr)
contiter cbegin()
Get the begin iterator object for a contiguous array.
T interFractileRange(const Array< T > &a, Float fraction, Bool sorted=False, Bool inPlace=False)
void arrayTransformInPlace(Array< L > &left, R right, BinaryOperator op)
Transform left and right in place using the binary operator.
LatticeExprNode conj(const LatticeExprNode &expr)
void arrayContTransform(const Array< L > &left, R right, Array< RES > &result, BinaryOperator op)
Transform left and right to a result using the binary operator.
LatticeExprNode tanh(const LatticeExprNode &expr)
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
void transformInPlace(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, BinaryOperator op)
Define a function to do a binary transform in place.
LatticeExprNode avdev(const LatticeExprNode &expr)
T madfm(const Array< T > &a, Bool sorted)
void arrayContTransform(L left, const Array< R > &right, Array< RES > &result, BinaryOperator op)
Transform left and right to a result using the binary operator.
LatticeExprNode abs(const LatticeExprNode &expr)
Numerical 1-argument functions which result in a real number regardless of input expression type...
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
T interQuartileRange(const Array< T > &a, Bool sorted=False, Bool inPlace=False)
LatticeExprNode sign(const LatticeExprNode &expr)
LatticeExprNode sqrt(const LatticeExprNode &expr)
#define DebugAssert(expr, exception)
LatticeExprNode tan(const LatticeExprNode &expr)
void indgen(TableVector< T > &tv, Int start, Int inc)
LatticeExprNode atan(const LatticeExprNode &expr)
void arrayContTransform(const Array< T > &arr, Array< RES > &result, UnaryOperator op)
Transform array to a result using the unary operator.
T median(const Array< T > &a, Bool sorted)
TableExprNode product(const TableExprNode &array)
bool Bool
Define the standard types used by Casacore.
void minMax(T &min, T &max, const TableVector< T > &tv)
void min(Array< T > &result, const T &a, const Array< T > &b)
TableExprNode cube(const TableExprNode &node)
LatticeExprNode stddev(const LatticeExprNode &expr)
LatticeExprNode round(const LatticeExprNode &expr)
Vector< T > indgen(uInt length, T start, T inc)
Create a Vector of the given length and fill it with the start value incremented with inc for each el...
template <class T, class U> class vector;
TableExprNode operator|(const TableExprNode &left, const TableExprNode &right)
LatticeExprNode atan2(const LatticeExprNode &left, const LatticeExprNode &right)
Numerical 2-argument functions.
LatticeExprNode operator+(const LatticeExprNode &expr)
Global functions operating on a LatticeExprNode.
LatticeExprNode fmod(const LatticeExprNode &left, const LatticeExprNode &right)
T madfmInPlace(const Array< T > &a, Bool sorted=False)
Base class for all Casacore library errors.
LatticeExprNode asin(const LatticeExprNode &expr)
LatticeExprNode mean(const LatticeExprNode &expr)
void arrayTransformInPlace(Array< T > &arr, UnaryOperator op)
Transform the array in place using the unary operator.
void myltransform(_InputIterator1 __first1, _InputIterator1 __last1, _OutputIterator __result, T left, _BinaryOperation __binary_op)
The myxtransform functions are defined to avoid a bug in g++-4.3.
TableExprNode rms(const TableExprNode &array)
LatticeExprNode sinh(const LatticeExprNode &expr)
LatticeExprNode acos(const LatticeExprNode &expr)
TableExprNode square(const TableExprNode &node)
LatticeExprNode operator-(const LatticeExprNode &expr)
LatticeExprNode operator^(const LatticeExprNode &left, const LatticeExprNode &right)
T median(const Array< T > &a)
void arrayContTransform(const Array< L > &left, const Array< R > &right, Array< RES > &result, BinaryOperator op)
Functions to apply a binary or unary operator to arrays.
void indgen(Array< T > &a)
Fills all elements of "array" with a sequence starting with 0 and ending with nelements() - 1...
LatticeExprNode variance(const LatticeExprNode &expr)
T madfm(const Array< T > &a, Bool sorted, Bool takeEvenMean, Bool inPlace=False)
LatticeExprNode ceil(const LatticeExprNode &expr)
LatticeExprNode pow(const LatticeExprNode &left, const LatticeExprNode &right)
T interQuartileRange(const Array< T > &a, Block< T > &tmp, Bool sorted=False, Bool inPlace=False)
Return the inter-quartile range of an array.
void indgen(Array< T > &a, T start)
Fills all elements of "array" with a sequence starting with start incremented by one for each positio...
LatticeExprNode cosh(const LatticeExprNode &expr)
LatticeExprNode real(const LatticeExprNode &expr)
LatticeExprNode sin(const LatticeExprNode &expr)
Numerical 1-argument functions.
transform(a.begin(), a.end(), std::ostream_iterator< int >(cout,"\n"), compose(unary(h), compose(unary(f), unary(f))))
Global Functions.
#define casacore
<X11/Intrinsic.h> #defines true, false, casacore::Bool, and String.
TableExprNode amplitude(const TableExprNode &node)
The amplitude (i.e.