28 #ifndef CASA_ARRAYMATH_H 29 #define CASA_ARRAYMATH_H 31 #include <casacore/casa/aips.h> 32 #include <casacore/casa/BasicMath/Math.h> 33 #include <casacore/casa/BasicMath/Functors.h> 34 #include <casacore/casa/Arrays/Array.h> 36 #include <casacore/casa/BasicSL/Complex.h> 37 #include <casacore/casa/Utilities/Assert.h> 38 #include <casacore/casa/Exceptions/Error.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);
186 void throwArrayShapes (
const char* name);
191 throwArrayShapes (name);
204 template<
typename L,
typename R,
typename RES,
typename BinaryOperator>
220 template<
typename L,
typename R,
typename RES,
typename BinaryOperator>
227 result.
cbegin(), right, op);
231 myrtransform (left.
begin(), left.
end(),
232 result.
cbegin(), right, op);
240 template<
typename L,
typename R,
typename RES,
typename BinaryOperator>
247 result.
cbegin(), left, op);
251 myltransform (right.
begin(), right.
end(),
252 result.
cbegin(), left, op);
260 template<
typename T,
typename RES,
typename UnaryOperator>
274 template<
typename L,
typename R,
typename RES,
typename BinaryOperator>
280 template<
typename L,
typename R,
typename RES,
typename BinaryOperator>
281 void arrayTransform (
const Array<L>& left, R right,
286 template<
typename L,
typename R,
typename RES,
typename BinaryOperator>
287 void arrayTransform (L left,
const Array<R>& right,
292 template<
typename T,
typename RES,
typename UnaryOperator>
293 void arrayTransform (
const Array<T>& arr,
298 template<
typename T,
typename BinaryOperator>
304 template<
typename T,
typename BinaryOperator>
305 Array<T> arrayTransformResult (
const Array<T>& left, T right, BinaryOperator op);
309 template<
typename T,
typename BinaryOperator>
310 Array<T> arrayTransformResult (T left,
const Array<T>& right, BinaryOperator op);
314 template<
typename T,
typename UnaryOperator>
319 template<
typename L,
typename R,
typename BinaryOperator>
332 template<
typename L,
typename R,
typename BinaryOperator>
336 myiptransform (left.
cbegin(), left.
cend(), right, op);
339 myiptransform (left.
begin(), left.
end(), right, op);
347 template<
typename T,
typename UnaryOperator>
376 template<
class T>
void operator+= (
Array<T> &left,
const T &other);
377 template<
class T>
void operator-= (
Array<T> &left,
const T &other);
378 template<
class T>
void operator*= (
Array<T> &left,
const T &other);
379 template<
class T>
void operator/= (
Array<T> &left,
const T &other);
380 template<
class T>
void operator%= (
Array<T> &left,
const T &other);
381 template<
class T>
void operator&= (
Array<T> &left,
const T &other);
382 template<
class T>
void operator|= (
Array<T> &left,
const T &other);
383 template<
class T>
void operator^= (
Array<T> &left,
const T &other);
505 template<
class ScalarType>
511 template<
class ScalarType>
516 template<
class ScalarType>
517 void minMaxMasked(ScalarType &minVal, ScalarType &maxVal,
IPosition &minPos,
560 {
max (result, b, a); }
567 {
min (result, b, a); }
571 {
return max(b, a); }
575 {
return min(b, a); }
588 {
indgen(a, T(0), T(1)); }
594 {
indgen(a, start, T(1)); }
673 {
Block<T> tmp;
return median (a, tmp, sorted, takeEvenMean, inPlace); }
689 {
Block<T> tmp;
return madfm(a, tmp, sorted, takeEvenMean, inPlace); }
719 {
Block<T> tmp;
return interFractileRange(a, tmp, fraction, sorted, inPlace); }
731 {
return interFractileRange(a, tmp, 1./6., sorted, inPlace); }
734 {
return interFractileRange(a, 1./6., sorted, inPlace); }
743 {
return interFractileRange(a, tmp, 0.25, sorted, inPlace); }
746 {
return interFractileRange(a, 0.25, sorted, inPlace); }
754 void operator*= (
Array<std::complex<T> > &left,
const Array<T> &other);
756 void operator*= (
Array<std::complex<T> > &left,
const T &other);
758 void operator/= (
Array<std::complex<T> > &left,
const Array<T> &other);
760 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,
905 const T* in, T* out,
const IPosition& alternate);
919 #ifndef CASACORE_NO_AUTO_TEMPLATES 920 #include <casacore/casa/Arrays/ArrayMath.tcc> 921 #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)
Non-templated base class for templated Array class.
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)
LatticeExprNode operator/(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
T product(const TableVector< T > &tv)
const IPosition & shape() const
The length of each axis.
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)
LatticeExprNode exp(const LatticeExprNode &expr)
iterator begin()
Get the begin iterator object for any array.
LatticeExprNode floor(const LatticeExprNode &expr)
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.
Float pow(Float f1, Float f2)
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)
size_t nelements() const
How many elements does this array have? Product of all axis lengths.
Bool contiguousStorage() const
Are the array data contiguous? If they are not contiguous, getStorage (see below) needs to make a cop...
Bool isEqual(const IPosition &other) const
Element-by-element comparison for equality.
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)
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)
TableExprNode operator &(const TableExprNode &left, const TableExprNode &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...
void checkArrayShapes(const ArrayBase &left, const ArrayBase &right, const char *name)
LatticeExprNode variance(const LatticeExprNode &expr)
T madfm(const Array< T > &a, Bool sorted, Bool takeEvenMean, Bool inPlace=False)
LatticeExprNode ceil(const LatticeExprNode &expr)
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...
this file contains all the compiler specific defines
MVBaseline operator*(const RotMatrix &left, const MVBaseline &right)
Rotate a Baseline vector with rotation matrix and other multiplications.
LatticeExprNode cosh(const LatticeExprNode &expr)
LatticeExprNode real(const LatticeExprNode &expr)
LatticeExprNode sin(const LatticeExprNode &expr)
Numerical 1-argument functions.
TableExprNode amplitude(const TableExprNode &node)
The amplitude (i.e.