StokesUtil.h

Classes

Global Functions -- for use with StokesVectors and related classes (full description)

for use with StokesVectors and related classes (source)

Interface

void unpackStokes(Array<U>& output, const Array<T>& input)
void repackStokes(Array<U>& output, const Array<T>& input)
Array<StokesVector> operator* (const Array<Float> & farray, const StokesVector & sv)
inline Array<StokesVector> operator* (const StokesVector & sv, const Array<Float> & farray)
inline Float abs(const StokesVector& sv)
Bool operator>(const StokesVector& left,const StokesVector& right)
inline Bool operator<(const StokesVector& left, const StokesVector& right)
Bool nearAbs(const StokesVector& val1, const StokesVector& val2, Double tol = 1.0e-5)
Bool near(const StokesVector& val1, const StokesVector& val2, Double tol = 1.0e-5)

Description

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Synopsis

Global Functions to operate on StokesVectors. Currently this includes functions to convert arrays from/to arrays of StokesVectors and some miscellaneous mathematical operations.

The {un,re}packStokes functions convert between an Array of StokesVector or CStokesvector into an Array of Float/Double or Complex/DComplex. The Float/Double array has one more dimension than the corresponding StokesVector array, and this extra dimension (always the slowest moving or last one) has a length of 4. The output array is always resized to the appropriate size.

The StokesVector comparison functions use the the "length" of the StokesVector (ie. sqrt(I^2+Q^2+U^2+V^2)) to make a comparison. In particular the abs() function returns the "length" of the StokesVector. It is called abs rather than say length() to allow StokesVectors to utilise other globals functions (like allNearAbs()) which expect the absolute value function to be defined.

Motivation

g++ does not like templated and non-templated code in the same file. So the templated stuff was split off and put into this file. Later this became a convient place to put all the global functions, and the non-templated global functions are also defined here (and the implementation is put in a separate .cc file)

Thrown Exceptions

To Do

Member Description

void unpackStokes(Array<U>& output, const Array<T>& input)

Convert an Array of StokesVectors to an array of Floats or Doubles (depending on the templates). The same function can be used to convert an array of CStokesVectors to a Complex or DComplex Array. I have not tested if this works for other template types.

void repackStokes(Array<U>& output, const Array<T>& input)

Convert an Array of Floats or Doubles to an Array of StokesVectors. The same function can be used to convert a Complex/DComplex array to an array of CStokesVector. The last non-degenerate axis on the input array MUST be of length 4

Array<StokesVector> operator* (const Array<Float> & farray, const StokesVector & sv)
inline Array<StokesVector> operator* (const StokesVector & sv, const Array<Float> & farray)

These Functions to multiply a StokesVector by an Array of Floats. The result is an Array of StokesVectors that is the same size as the Array of Floats with each polarization being the Array of floats multiplied by the corresponding component in the supplied StokesVector.

inline Float abs(const StokesVector& sv)
Bool operator>(const StokesVector& left,const StokesVector& right)
inline Bool operator<(const StokesVector& left, const StokesVector& right)

Functions to compare stokesVectors with each other. They are all based on the norm derived using the "length" of the vector in 4-space.

Bool nearAbs(const StokesVector& val1, const StokesVector& val2, Double tol = 1.0e-5)
Bool near(const StokesVector& val1, const StokesVector& val2, Double tol = 1.0e-5)

Functions to determine if one StokesVector is near another