casacore
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members

Base class for an array with an optional mask. More...

#include <MArrayBase.h>

Public Member Functions

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...
 

Protected Member Functions

 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...
 

Private Member Functions

void init ()
 Initialize and check. More...
 
void fillNValid () const
 Fill the number of valid values. More...
 

Private Attributes

Array< BoolitsMask
 
IPosition itsShape
 
size_t itsSize
 
Int64 itsNValid
 
Bool itsNull
 

Detailed Description

Base class for an array with an optional mask.

Intended use:

Internal

Review Status

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

Prerequisite

Synopsis

This class is the base class of the templated class MArray. It contains the functions that are not template dependent.

MArray is developed to make it easier to handle arrays with an optional mask. The array is always present, but the mask is optional. MArrayMath contains functions to operate on such arrays.

Similar to numpy.masked_array and the MeasurementSet FLAG definition, a mask value True means that the corresponding value is masked off, thus is not taken into account in reduction functions like sum. on a masked array. In operations like addition, masked off values are processed because testing the mask value is more expensive than an addition (even if the value is a NaN). For an operation with multiple operands, the mask of the result is the OR of the operand masks.

MArray can be null meaning that the array is a null value. It can be used to indicate that a table cell does not contain an array. A null MArray has an empty array and mask. Operations where an operand is a null MArray, result in a null MArray.

Definition at line 84 of file MArrayBase.h.

Constructor & Destructor Documentation

◆ MArrayBase() [1/3]

casacore::MArrayBase::MArrayBase ( Bool  isNull)
inlineexplicitprotected

The default constructor creates an empty mask.

Definition at line 88 of file MArrayBase.h.

◆ MArrayBase() [2/3]

casacore::MArrayBase::MArrayBase ( const ArrayBase arr,
const Array< Bool > &  mask,
Bool  isNull 
)
protected

Construct from a given array shape and mask.

◆ MArrayBase() [3/3]

casacore::MArrayBase::MArrayBase ( const ArrayBase arr,
const MArrayBase marray 
)
protected

Construct from a given array shape and mask from another MArray.

Member Function Documentation

◆ combineMask()

Array<Bool> casacore::MArrayBase::combineMask ( const MArrayBase other) const

Combine this and the other mask.

One or both MArray-s can be unmasked.

◆ empty()

Bool casacore::MArrayBase::empty ( ) const
inline

Is the array empty?

Definition at line 139 of file MArrayBase.h.

References itsSize.

◆ fillNValid()

void casacore::MArrayBase::fillNValid ( ) const
private

Fill the number of valid values.

Referenced by nvalid().

◆ hasMask()

Bool casacore::MArrayBase::hasMask ( ) const
inline

Is there a mask?

Definition at line 119 of file MArrayBase.h.

References casacore::ArrayBase::empty(), and itsMask.

◆ init()

void casacore::MArrayBase::init ( )
private

Initialize and check.

◆ isNull()

Bool casacore::MArrayBase::isNull ( ) const
inline

Is the array null?

Definition at line 111 of file MArrayBase.h.

References itsNull.

◆ mask()

const Array<Bool>& casacore::MArrayBase::mask ( ) const
inline

Get the mask.

The returned array is empty if there is no mask.

Definition at line 126 of file MArrayBase.h.

References itsMask.

◆ ndim()

uInt casacore::MArrayBase::ndim ( ) const
inline

Get the dimensionality.

Definition at line 143 of file MArrayBase.h.

References itsShape, and casacore::IPosition::size().

◆ nelements()

size_t casacore::MArrayBase::nelements ( ) const
inline

Definition at line 154 of file MArrayBase.h.

References itsSize.

◆ nvalid()

Int64 casacore::MArrayBase::nvalid ( ) const
inline

Return the number of valid array values, thus unflagged elements.

Definition at line 132 of file MArrayBase.h.

References fillNValid(), and itsNValid.

◆ referenceBase()

void casacore::MArrayBase::referenceBase ( const MArrayBase other)
protected

Reference another MArray.

◆ removeMask()

void casacore::MArrayBase::removeMask ( )
inline

Remove the mask.

Definition at line 115 of file MArrayBase.h.

References itsMask, itsNValid, itsSize, and casacore::Array< T >::resize().

◆ resizeBase()

void casacore::MArrayBase::resizeBase ( const ArrayBase arr,
Bool  useMask 
)
protected

Set the array shape and resize the mask.

◆ setBase()

void casacore::MArrayBase::setBase ( const ArrayBase arr,
const Array< Bool > &  mask 
)
protected

Reference the mask and set the shape.

◆ setMask()

void casacore::MArrayBase::setMask ( const Array< Bool > &  mask)

Set the mask.

It checks if it matches the array shape.

◆ shape()

const IPosition& casacore::MArrayBase::shape ( ) const
inline

Get the shape.

Definition at line 147 of file MArrayBase.h.

References itsShape.

◆ size()

size_t casacore::MArrayBase::size ( ) const
inline

Get the size.

Definition at line 152 of file MArrayBase.h.

References itsSize.

◆ wmask()

Array<Bool>& casacore::MArrayBase::wmask ( )
inline

Definition at line 128 of file MArrayBase.h.

References itsMask.

Member Data Documentation

◆ itsMask

Array<Bool> casacore::MArrayBase::itsMask
private

Definition at line 170 of file MArrayBase.h.

Referenced by hasMask(), mask(), removeMask(), and wmask().

◆ itsNull

Bool casacore::MArrayBase::itsNull
private

Definition at line 174 of file MArrayBase.h.

Referenced by isNull().

◆ itsNValid

Int64 casacore::MArrayBase::itsNValid
mutableprivate

Definition at line 173 of file MArrayBase.h.

Referenced by nvalid(), and removeMask().

◆ itsShape

IPosition casacore::MArrayBase::itsShape
private

Definition at line 171 of file MArrayBase.h.

Referenced by ndim(), and shape().

◆ itsSize

size_t casacore::MArrayBase::itsSize
private

Definition at line 172 of file MArrayBase.h.

Referenced by empty(), nelements(), removeMask(), and size().


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