casa::ArrayMath_global_functions_Array_mathematical_operations Struct Reference
[Arrays]

#include <ArrayMath.h>

List of all members.


Detailed Description

Mathematical operations for Arrays.

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Test programs:
tArray

Prerequisite

Etymology

This file contains global functions which perform element by element mathematical operations on arrays.

Synopsis

These functions perform element by element mathematical operations on arrays. The two arrays must conform.

Example

      Vector<Int> a(10);
      Vector<Int> b(10);
      Vector<Int> c(10);
         . . .
      c = a + b;
This example sets the elements of c to (a+b). The result of this operation is an Array.

Example

      Vector<Double> a(10);
      Vector<Double> b(10);
      Vector<Double> c(10);
         . . .
      c = atan2 (a, b);
This example sets the elements of c to atan2 (a,b). The result of this operation is an Array.

Example

      Vector<Int> a(10);
      Int result;
         . . .
      result = sum (a);
This example sums a.

Motivation

One wants to be able to perform mathematical operations on arrays.

<linkfrom anchor="Array mathematical operations" classes="Array Vector Matrix Cube"> <here>Array mathematical operations</here> -- Mathematical operations for Arrays. </linkfrom>

Definition at line 104 of file ArrayMath.h.

Public Member Functions

void ArrayMinMaxPrintOnceDeprecated ()
 Function to print "deprecated" message once per program.
template<class T>
void indgen (Array< T > &a, T start, T inc)
 Fills all elements of "array" with a sequence starting with "start" and incrementing by "inc" for each element.
template<class T>
void indgen (Array< T > &a)
 Fills all elements of "array" with a sequence starting with 0 and ending with nelements() - 1.
template<class T>
void indgen (Array< T > &a, T start)
 Fills all elements of "array" with a sequence starting with start incremented by one for each position in the array.
template<class T>
sum (const Array< T > &a)
 Sum of every element of the array.
template<class T>
product (const Array< T > &a)
 Product of every element of the array.
template<class T>
mean (const Array< T > &a)
 The mean of "a" is the sum of all elements of "a" divided by the number of elements of "a".
template<class T>
variance (const Array< T > &a)
 The variance of "a" is the sum of (a(i) - mean(a))**2/(a.nelements() - 1).
template<class T>
variance (const Array< T > &a, T mean)
 The variance of "a" is the sum of (a(i) - mean(a))**2/(a.nelements() - 1).
template<class T>
stddev (const Array< T > &a)
 The standard deviation of "a" is the square root of its variance.
template<class T>
stddev (const Array< T > &a, T mean)
 The standard deviation of "a" is the square root of its variance.
template<class T>
avdev (const Array< T > &a)
 The average deviation of "a" is the sum of abs(a(i) - mean(a))/N.
template<class T>
avdev (const Array< T > &a, T mean)
 The average deviation of "a" is the sum of abs(a(i) - mean(a))/N.
template<class T>
rms (const Array< T > &a)
 The root-mean-square of "a" is the sqrt of sum(a*a)/N.
template<class T>
fractile (const Array< T > &a, Float fraction, Bool sorted=False, Bool inPlace=False)
 Return the fractile of an array.
Array< FloatComplexToReal (const Array< Complex > &carray)
 Copy an array of complex into an array of real,imaginary pairs.
Array< DoubleComplexToReal (const Array< DComplex > &carray)
Array< Complex > RealToComplex (const Array< Float > &rarray)
 Copy an array of real,imaginary pairs into a complex array.
Array< DComplex > RealToComplex (const Array< Double > &rarray)
template<typename T>
Array< T > slidingArrayMath (const Array< T > &array, const IPosition &halfBoxSize, T(*reductionFunc)(const Array< T > &), Bool fillEdge=True)
 Apply for each element in the array the given ArrayMath reduction function to the box around that element.
template<class T, class U>
void convertArray (Array< T > &to, const Array< U > &from)
 Make a copy of an array of a different type; for example make an array of doubles from an array of floats.
template<class T>
Array< T > square (const Array< T > &val)
 Returns an array where every element is squared.
template<class T>
Array< T > cube (const Array< T > &val)
 Returns an array where every element is cubed.
template<class T>
void operator+= (Array< T > &left, const Array< T > &other)
 Element by element arithmetic modifying left in-place.
template<class T>
void operator-= (Array< T > &left, const Array< T > &other)
template<class T>
void operator *= (Array< T > &left, const Array< T > &other)
template<class T>
void operator/= (Array< T > &left, const Array< T > &other)
template<class T>
void operator+= (Array< T > &left, const T &other)
 Element by element arithmetic modifying left in-place.
template<class T>
void operator-= (Array< T > &left, const T &other)
template<class T>
void operator *= (Array< T > &left, const T &other)
template<class T>
void operator/= (Array< T > &left, const T &other)
template<class T>
Array< T > operator+ (const Array< T > &a)
 Unary arithmetic operation.
template<class T>
Array< T > operator- (const Array< T > &a)
template<class T>
Array< T > operator+ (const Array< T > &left, const Array< T > &right)
 Element by element arithmetic on two arrays, returning an array.
template<class T>
Array< T > operator- (const Array< T > &left, const Array< T > &right)
template<class T>
Array< T > operator * (const Array< T > &left, const Array< T > &right)
template<class T>
Array< T > operator/ (const Array< T > &left, const Array< T > &right)
template<class T>
Array< T > operator+ (const Array< T > &left, const T &right)
 Element by element arithmetic between an array and a scalar, returning an array.
template<class T>
Array< T > operator- (const Array< T > &left, const T &right)
template<class T>
Array< T > operator * (const Array< T > &left, const T &right)
template<class T>
Array< T > operator/ (const Array< T > &left, const T &right)
template<class T>
Array< T > operator+ (const T &left, const Array< T > &right)
 Element by element arithmetic between a scalar and an array, returning an array.
template<class T>
Array< T > operator- (const T &left, const Array< T > &right)
template<class T>
Array< T > operator * (const T &left, const Array< T > &right)
template<class T>
Array< T > operator/ (const T &left, const Array< T > &right)
template<class T>
Array< T > cos (const Array< T > &a)
 Transcendental function that can be applied to essentially all numeric types.
template<class T>
Array< T > cosh (const Array< T > &a)
template<class T>
Array< T > exp (const Array< T > &a)
template<class T>
Array< T > log (const Array< T > &a)
template<class T>
Array< T > log10 (const Array< T > &a)
template<class T>
Array< T > pow (const Array< T > &a, const Array< T > &b)
template<class T>
Array< T > pow (const T &a, const Array< T > &b)
template<class T>
Array< T > sin (const Array< T > &a)
template<class T>
Array< T > sinh (const Array< T > &a)
template<class T>
Array< T > sqrt (const Array< T > &a)
template<class T>
Array< T > acos (const Array< T > &a)
 Transcendental function applied to the array on an element-by-element basis.
template<class T>
Array< T > asin (const Array< T > &a)
template<class T>
Array< T > atan (const Array< T > &a)
template<class T>
Array< T > atan2 (const Array< T > &y, const Array< T > &x)
template<class T>
Array< T > ceil (const Array< T > &a)
template<class T>
Array< T > fabs (const Array< T > &a)
template<class T>
Array< T > abs (const Array< T > &a)
template<class T>
Array< T > floor (const Array< T > &a)
template<class T>
Array< T > fmod (const Array< T > &a, const Array< T > &b)
template<class T>
Array< T > fmod (const T &a, const Array< T > &b)
template<class T>
Array< T > fmod (const Array< T > &a, const T &b)
template<class T>
Array< T > pow (const Array< T > &a, const Double &b)
template<class T>
Array< T > tan (const Array< T > &a)
template<class T>
Array< T > tanh (const Array< T > &a)
template<class T>
Array< T > fabs (const Array< T > &a)
 N.B.
template<class ScalarType>
void minMax (ScalarType &minVal, ScalarType &maxVal, IPosition &minPos, IPosition &maxPos, const Array< ScalarType > &array)
 Find the minimum and maximum values of an array, including their locations.
template<class ScalarType>
void minMax (ScalarType &minVal, ScalarType &maxVal, IPosition &minPos, IPosition &maxPos, const Array< ScalarType > &array, const Array< Bool > &mask)
 The array is only searched at locations where the mask is True.
template<class ScalarType>
void minMaxMasked (ScalarType &minVal, ScalarType &maxVal, IPosition &minPos, IPosition &maxPos, const Array< ScalarType > &array, const Array< ScalarType > &mask)
 The array * mask is searched.
template<class T>
void minMax (T &min, T &max, const Array< T > &a)
 This sets min and max to the minimum and maximum of the array to avoid having to do two passes with max() and min() separately.
template<class T>
void minMax (const Array< T > &a, T &min, T &max)
 This version is deprecated, due to its nonstandard argument order.
template<class T>
min (const Array< T > &a)
 The minimum element of the array.
template<class T>
max (const Array< T > &a)
 The maximum element of the array.
template<class T>
void max (Array< T > &result, const Array< T > &a, const Array< T > &b)
 "result" contains the maximum of "a" and "b" at each position.
template<class T>
void min (Array< T > &result, const Array< T > &a, const Array< T > &b)
 "result" contains the minimum of "a" and "b" at each position.
template<class T>
Array< T > max (const Array< T > &a, const Array< T > &b)
 Return an array that contains the maximum of "a" and "b" at each position.
template<class T>
Array< T > min (const Array< T > &a, const Array< T > &b)
 Return an array that contains the minimum of "a" and "b" at each position.
template<class T>
void max (Array< T > &result, const Array< T > &a, const T &b)
 "result" contains the maximum of "a" and "b" at each position.
template<class T>
void min (Array< T > &result, const Array< T > &a, const T &b)
 "result" contains the minimum of "a" and "b" at each position.
template<class T>
Array< T > max (const Array< T > &a, const T &b)
 Return an array that contains the maximum of "a" and "b" at each position.
template<class T>
Array< T > min (const Array< T > &a, const T &b)
 Return an array that contains the minimum of "a" and "b" at each position.
template<class T>
median (const Array< T > &a)
 The median of "a" is a(n/2).
template<class T>
median (const Array< T > &a, Bool sorted)
template<class T>
medianInPlace (const Array< T > &a, Bool sorted=False)
template<class T>
median (const Array< T > &a, Bool sorted, Bool takeEvenMean, Bool inPlace=False)
template<class T>
Array< T > partialSums (const Array< T > &array, const IPosition &collapseAxes)
 The same functions as above, but determine the sum, etc.
template<class T>
Array< T > partialProducts (const Array< T > &array, const IPosition &collapseAxes)
template<class T>
Array< T > partialMins (const Array< T > &array, const IPosition &collapseAxes)
template<class T>
Array< T > partialMaxs (const Array< T > &array, const IPosition &collapseAxes)
template<class T>
Array< T > partialMeans (const Array< T > &array, const IPosition &collapseAxes)
template<class T>
Array< T > partialVariances (const Array< T > &array, const IPosition &collapseAxes)
template<class T>
Array< T > partialVariances (const Array< T > &array, const IPosition &collapseAxes, const Array< T > &means)
template<class T>
Array< T > partialStddevs (const Array< T > &array, const IPosition &collapseAxes)
template<class T>
Array< T > partialStddevs (const Array< T > &array, const IPosition &collapseAxes, const Array< T > &means)
template<class T>
Array< T > partialAvdevs (const Array< T > &array, const IPosition &collapseAxes)
template<class T>
Array< T > partialAvdevs (const Array< T > &array, const IPosition &collapseAxes, const Array< T > &means)
template<class T>
Array< T > partialRmss (const Array< T > &array, const IPosition &collapseAxes)
template<class T>
Array< T > partialMedians (const Array< T > &array, const IPosition &collapseAxes, Bool takeEvenMean=False, Bool inPlace=False)
template<class T>
Array< T > partialFractiles (const Array< T > &array, const IPosition &collapseAxes, Float fraction, Bool inPlace=False)
void operator *= (Array< Complex > &left, const Array< Float > &other)
 Methods for element-by-element scaling of Complex by Float.
void operator *= (Array< Complex > &left, const Float &other)
void operator/= (Array< Complex > &left, const Array< Float > &other)
void operator/= (Array< Complex > &left, const Float &other)
Array< Complex > operator * (const Array< Complex > &left, const Array< Float > &right)
Array< Complex > operator * (const Array< Complex > &left, const Float &right)
Array< Complex > operator/ (const Array< Complex > &left, const Array< Float > &right)
Array< Complex > operator/ (const Array< Complex > &left, const Float &right)
Array< Complex > conj (const Array< Complex > &carray)
 Returns the complex conjugate of a complex array.
Array< DComplex > conj (const Array< DComplex > &carray)
Matrix< Complex > conj (const Matrix< Complex > &carray)
Matrix< DComplex > conj (const Matrix< DComplex > &carray)
Array< Floatreal (const Array< Complex > &carray)
 Extracts the real part of a complex array into an array of floats.
Array< Doublereal (const Array< DComplex > &carray)
void real (Array< Float > &rarray, const Array< Complex > &carray)
 Modifies rarray in place.
void real (Array< Double > &rarray, const Array< DComplex > &carray)
Array< Floatimag (const Array< Complex > &carray)
 Extracts the imaginary part of a complex array into an array of floats.
Array< Doubleimag (const Array< DComplex > &carray)
void imag (Array< Float > &rarray, const Array< Complex > &carray)
 Modifies rarray in place.
void imag (Array< Double > &rarray, const Array< DComplex > &carray)
Array< Floatamplitude (const Array< Complex > &carray)
 Extracts the amplitude (i.e.
Array< Doubleamplitude (const Array< DComplex > &carray)
void amplitude (Array< Float > &rarray, const Array< Complex > &carray)
 Modifies rarray in place.
void amplitude (Array< Double > &rarray, const Array< DComplex > &carray)
Array< Floatphase (const Array< Complex > &carray)
 Extracts the phase (i.e.
Array< Doublephase (const Array< DComplex > &carray)
void phase (Array< Float > &rarray, const Array< Complex > &carray)
 Modifies rarray in place.
void phase (Array< Double > &rarray, const Array< DComplex > &carray)
void ComplexToReal (Array< Float > &rarray, const Array< Complex > &carray)
 Modify the array "rarray" in place.
void ComplexToReal (Array< Double > &rarray, const Array< DComplex > &carray)
void RealToComplex (Array< Complex > &carray, const Array< Float > &rarray)
 Modify the array "carray" in place.
void RealToComplex (Array< DComplex > &carray, const Array< Double > &rarray)


Member Function Documentation

void casa::ArrayMath_global_functions_Array_mathematical_operations::ArrayMinMaxPrintOnceDeprecated (  ) 

Function to print "deprecated" message once per program.

template<class T>
void casa::ArrayMath_global_functions_Array_mathematical_operations::operator+= ( Array< T > &  left,
const Array< T > &  other 
)

Element by element arithmetic modifying left in-place.

left and other must be conformant.

template<class T>
void casa::ArrayMath_global_functions_Array_mathematical_operations::operator-= ( Array< T > &  left,
const Array< T > &  other 
)

template<class T>
void casa::ArrayMath_global_functions_Array_mathematical_operations::operator *= ( Array< T > &  left,
const Array< T > &  other 
)

template<class T>
void casa::ArrayMath_global_functions_Array_mathematical_operations::operator/= ( Array< T > &  left,
const Array< T > &  other 
)

template<class T>
void casa::ArrayMath_global_functions_Array_mathematical_operations::operator+= ( Array< T > &  left,
const T &  other 
)

Element by element arithmetic modifying left in-place.

The scalar "other" behaves as if it were a conformant Array to left filled with constant values.

template<class T>
void casa::ArrayMath_global_functions_Array_mathematical_operations::operator-= ( Array< T > &  left,
const T &  other 
)

template<class T>
void casa::ArrayMath_global_functions_Array_mathematical_operations::operator *= ( Array< T > &  left,
const T &  other 
)

template<class T>
void casa::ArrayMath_global_functions_Array_mathematical_operations::operator/= ( Array< T > &  left,
const T &  other 
)

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::operator+ ( const Array< T > &  a  ) 

Unary arithmetic operation.

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::operator- ( const Array< T > &  a  ) 

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::operator+ ( const Array< T > &  left,
const Array< T > &  right 
)

Element by element arithmetic on two arrays, returning an array.

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::operator- ( const Array< T > &  left,
const Array< T > &  right 
)

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::operator * ( const Array< T > &  left,
const Array< T > &  right 
)

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::operator/ ( const Array< T > &  left,
const Array< T > &  right 
)

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::operator+ ( const Array< T > &  left,
const T &  right 
)

Element by element arithmetic between an array and a scalar, returning an array.

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::operator- ( const Array< T > &  left,
const T &  right 
)

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::operator * ( const Array< T > &  left,
const T &  right 
)

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::operator/ ( const Array< T > &  left,
const T &  right 
)

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::operator+ ( const T &  left,
const Array< T > &  right 
)

Element by element arithmetic between a scalar and an array, returning an array.

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::operator- ( const T &  left,
const Array< T > &  right 
)

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::operator * ( const T &  left,
const Array< T > &  right 
)

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::operator/ ( const T &  left,
const Array< T > &  right 
)

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::cos ( const Array< T > &  a  ) 

Transcendental function that can be applied to essentially all numeric types.

Works on an element-by-element basis.

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::cosh ( const Array< T > &  a  ) 

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::exp ( const Array< T > &  a  ) 

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::log ( const Array< T > &  a  ) 

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::log10 ( const Array< T > &  a  ) 

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::pow ( const Array< T > &  a,
const Array< T > &  b 
)

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::pow ( const T &  a,
const Array< T > &  b 
)

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::sin ( const Array< T > &  a  ) 

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::sinh ( const Array< T > &  a  ) 

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::sqrt ( const Array< T > &  a  ) 

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::acos ( const Array< T > &  a  ) 

Transcendental function applied to the array on an element-by-element basis.

Although a template function, this does not make sense for all numeric types.

template<class T>
Array<T> casa::ArrayMath_global_functions_Array_mathematical_operations::asin ( const Array< T > &  a  ) 

template<class T>