casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
casacore::MArray< T > Class Template Reference

Class to handle an Array with an optional mask. More...

#include <MArrayMathBase.h>

Inheritance diagram for casacore::MArray< T >:
casacore::MArrayBase

Public Member Functions

 MArray ()
 Default constructor creates a null array. More...
 
 MArray (const Array< T > &array)
 Construct from an array without a mask. More...
 
 MArray (const Array< T > &array, const Array< Bool > &mask, Bool isNull=False)
 Construct from an array and a mask. More...
 
 MArray (const Array< T > &array, const MArrayBase &marray)
 Construct from an array with the mask and null from another MArray. More...
 
 MArray (const MArray< T > &array, const MArray< Bool > &mask)
 Construct from two MArrays, one the array, the other the mask. More...
 
void reference (const MArray< T > &other)
 Reference another array. More...
 
void resize (const IPosition &shape, Bool useMask)
 Resize the array and optionally the mask. More...
 
template<typename U >
void fill (const MArray< U > &from)
 Copy the array data and possible mask from another one. More...
 
template<typename U >
void fill (const Array< U > &from)
 Copy the array from a normal Array. More...
 
const Array< T > & array () const
 Get access to the array. More...
 
Array< T > & array ()
 
Vector< T > flatten () const
 Flatten the unmasked elements of the array to a vector. More...
 
size_t flatten (T *out, size_t size) const
 Copy the unmasked elements to the out. More...
 
MArray< T > operator() (const IPosition &start, const IPosition &end, const IPosition &stride)
 Get a subset of the array. More...
 
- Public Member Functions inherited from casacore::MArrayBase
Bool isNull () const
 Is the array null? More...
 
void removeMask ()
 Remove the mask. More...
 
Bool hasMask () const
 Is there a mask? More...
 
void setMask (const Array< Bool > &mask)
 Set the mask. More...
 
const Array< Bool > & mask () const
 Get the mask. More...
 
Array< Bool > & wmask ()
 
Int64 nvalid () const
 Return the number of valid array values, thus unflagged elements. More...
 
Bool empty () const
 Is the array empty? More...
 
uInt ndim () const
 Get the dimensionality. More...
 
const IPositionshape () const
 Get the shape. More...
 
size_t size () const
 Get the size. More...
 
size_t nelements () const
 
Array< BoolcombineMask (const MArrayBase &other) const
 Combine this and the other mask. More...
 

Private Attributes

Array< T > itsArray
 

Additional Inherited Members

- Protected Member Functions inherited from casacore::MArrayBase
 MArrayBase (Bool isNull)
 The default constructor creates an empty mask. More...
 
 MArrayBase (const ArrayBase &arr, const Array< Bool > &mask, Bool isNull)
 Construct from a given array shape and mask. More...
 
 MArrayBase (const ArrayBase &arr, const MArrayBase &marray)
 Construct from a given array shape and mask from another MArray. More...
 
void setBase (const ArrayBase &arr, const Array< Bool > &mask)
 Reference the mask and set the shape. More...
 
void referenceBase (const MArrayBase &other)
 Reference another MArray. More...
 
void resizeBase (const ArrayBase &arr, Bool useMask)
 Set the array shape and resize the mask. More...
 

Detailed Description

template<typename T>
class casacore::MArray< T >

Class to handle an Array with an optional mask.

Intended use:

Internal

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25

Prerequisite

Synopsis

This class makes it easier to handle arrays with ot without mask. The array is always present, but the mask is optional. The mask is contained in the non-templated base class MArrayBase and functions to operate on the mask are defined there.
The class is primarily developed for TaQL masked arrays, but could be used elsewhere as well.

A mask value True means that the corresponding value is masked off, thus not taken into account in reduction functions like sum. This is the same as the numpy masked array.

MArrayMath.h contains many functions to operate on MArray objects (addition, sin, etc.).

Definition at line 37 of file MArrayMathBase.h.

Constructor & Destructor Documentation

template<typename T>
casacore::MArray< T >::MArray ( )
inline

Default constructor creates a null array.

Definition at line 73 of file MArray.h.

template<typename T>
casacore::MArray< T >::MArray ( const Array< T > &  array)
inlineexplicit

Construct from an array without a mask.

It references the given array.

Definition at line 79 of file MArray.h.

template<typename T>
casacore::MArray< T >::MArray ( const Array< T > &  array,
const Array< Bool > &  mask,
Bool  isNull = False 
)
inline

Construct from an array and a mask.

It references the given arrays. isNull=True requires the arrays to be empty.

Definition at line 89 of file MArray.h.

template<typename T>
casacore::MArray< T >::MArray ( const Array< T > &  array,
const MArrayBase marray 
)
inline

Construct from an array with the mask and null from another MArray.

It references the given arrays. The shapes of both arrays must match.

Definition at line 97 of file MArray.h.

template<typename T>
casacore::MArray< T >::MArray ( const MArray< T > &  array,
const MArray< Bool > &  mask 
)
inline

Construct from two MArrays, one the array, the other the mask.

If one of them is null, the constructed MArray is null.

Definition at line 104 of file MArray.h.

Member Function Documentation

template<typename T>
const Array<T>& casacore::MArray< T >::array ( ) const
inline

Get access to the array.

Definition at line 153 of file MArray.h.

Referenced by casacore::MArrayMath_global_functions_MArray_mathematical_operations::abs(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::acos(), casacore::MArrayLogical_global_functions_MArray_logical_operations::allEQ(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::amplitude(), casacore::MArrayLogical_global_functions_MArray_logical_operations::anyEQ(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::asin(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::atan(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::atan2(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::avdev(), casacore::MArrayLogical_global_functions_MArray_logical_operations::boxedAlls(), casacore::MArrayLogical_global_functions_MArray_logical_operations::boxedAnys(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::boxedArrayMath(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::boxedAvdevs(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::boxedFractiles(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::boxedMaxs(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::boxedMeans(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::boxedMedians(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::boxedMins(), casacore::MArrayLogical_global_functions_MArray_logical_operations::boxedNFalse(), casacore::MArrayLogical_global_functions_MArray_logical_operations::boxedNTrue(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::boxedProducts(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::boxedRmss(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::boxedStddevs(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::boxedSums(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::boxedSumSqrs(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::boxedVariances(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::ceil(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::conj(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::cos(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::cosh(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::cube(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::exp(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::fabs(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::floor(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::floormod(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::fmod(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::fractile(), casacore::TableExprGroupAggr::getArray(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::imag(), casacore::MArrayLogical_global_functions_MArray_logical_operations::isFinite(), casacore::MArrayLogical_global_functions_MArray_logical_operations::isInf(), casacore::MArrayLogical_global_functions_MArray_logical_operations::isNaN(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::log(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::log10(), casacore::MArray< casacore::String >::MArray(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::max(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::mean(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::median(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::min(), casacore::MArrayLogical_global_functions_MArray_logical_operations::near(), casacore::MArrayLogical_global_functions_MArray_logical_operations::nearAbs(), casacore::MArrayLogical_global_functions_MArray_logical_operations::nfalse(), casacore::MArrayLogical_global_functions_MArray_logical_operations::ntrue(), casacore::MArrayLogical_global_functions_MArray_logical_operations::operator!(), casacore::MArrayLogical_global_functions_MArray_logical_operations::operator!=(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::operator%(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::operator&(), casacore::MArrayLogical_global_functions_MArray_logical_operations::operator&&(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::operator*(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::operator+(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::operator-(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::operator/(), casacore::MArrayLogical_global_functions_MArray_logical_operations::operator==(), casacore::MArrayLogical_global_functions_MArray_logical_operations::operator>(), casacore::MArrayLogical_global_functions_MArray_logical_operations::operator>=(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::operator^(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::operator|(), casacore::MArrayLogical_global_functions_MArray_logical_operations::operator||(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::operator~(), casacore::MArrayLogical_global_functions_MArray_logical_operations::partialAlls(), casacore::MArrayLogical_global_functions_MArray_logical_operations::partialAnys(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialArrayMath(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialAvdevs(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialFractiles(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialMaxs(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialMeans(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialMedians(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialMins(), casacore::MArrayLogical_global_functions_MArray_logical_operations::partialNFalse(), casacore::MArrayLogical_global_functions_MArray_logical_operations::partialNTrue(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialProducts(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialRmss(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialStddevs(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialSums(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialSumSqrs(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialVariances(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::phase(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::pow(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::product(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::real(), casacore::MArrayUtil_global_functions_reorderMArray::reorderArray(), casacore::MArrayUtil_global_functions_reverseMArray::reverseArray(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::rms(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::round(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::sign(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::sin(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::sinh(), casacore::MArrayLogical_global_functions_MArray_logical_operations::slidingAlls(), casacore::MArrayLogical_global_functions_MArray_logical_operations::slidingAnys(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::slidingArrayMath(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::slidingAvdevs(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::slidingFractiles(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::slidingMaxs(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::slidingMeans(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::slidingMedians(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::slidingMins(), casacore::MArrayLogical_global_functions_MArray_logical_operations::slidingNFalse(), casacore::MArrayLogical_global_functions_MArray_logical_operations::slidingNTrue(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::slidingProducts(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::slidingRmss(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::slidingStddevs(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::slidingSums(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::slidingSumSqrs(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::slidingVariances(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::sqrt(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::square(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::sum(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::sumsqr(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::tan(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::tanh(), casacore::TableExprNodeSet::toArray(), and casacore::MArrayMath_global_functions_MArray_mathematical_operations::variance().

template<typename T>
Array<T>& casacore::MArray< T >::array ( )
inline

Definition at line 155 of file MArray.h.

template<typename T>
template<typename U >
void casacore::MArray< T >::fill ( const MArray< U > &  from)
inline

Copy the array data and possible mask from another one.

The shapes do not need to match. The array data is copied, but the new mask references the possible mask in from.

Definition at line 133 of file MArray.h.

template<typename T>
template<typename U >
void casacore::MArray< T >::fill ( const Array< U > &  from)
inline

Copy the array from a normal Array.

The possible mask is removed. The shapes do not need to match. The array data is always copied.

Definition at line 144 of file MArray.h.

template<typename T >
Vector< T > casacore::MArray< T >::flatten ( ) const

Flatten the unmasked elements of the array to a vector.

We lie about the size, because we know the buffer has the right size.

Definition at line 184 of file MArray.h.

References casacore::Array< T >::data().

Referenced by casacore::MArrayMath_global_functions_MArray_mathematical_operations::fractile(), and casacore::MArrayMath_global_functions_MArray_mathematical_operations::median().

template<typename T>
size_t casacore::MArray< T >::flatten ( T *  out,
size_t  size 
) const

Copy the unmasked elements to the out.

The argument size gives the size of the output buffer which should be at least the size of the array. It returns the nr of unmasked elements.

No mask, so copy all elements.

Copy only the valid elements.

Definition at line 193 of file MArray.h.

References casacore::mask(), casacore::SHARE, casacore::ArrayBase::size(), and casacore::String::toString().

template<typename T>
MArray<T> casacore::MArray< T >::operator() ( const IPosition start,
const IPosition end,
const IPosition stride 
)
inline

Get a subset of the array.

Definition at line 167 of file MArray.h.

template<typename T>
void casacore::MArray< T >::reference ( const MArray< T > &  other)
inline

Reference another array.

Definition at line 114 of file MArray.h.

Referenced by casacore::TableExprNodeSet::getArray().

template<typename T>
void casacore::MArray< T >::resize ( const IPosition shape,
Bool  useMask 
)
inline

Member Data Documentation

template<typename T>
Array<T> casacore::MArray< T >::itsArray
private

The documentation for this class was generated from the following files: