casa
5.7.0-16
|
Class to handle an Array with an optional mask. More...
#include <MArrayMathBase.h>
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 IPosition & | shape () const |
Get the shape. More... | |
size_t | size () const |
Get the size. More... | |
size_t | nelements () const |
Array< Bool > | combineMask (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... | |
Class to handle an Array with an optional mask.
Internal
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.
|
inline |
|
inlineexplicit |
|
inline |
|
inline |
|
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().
|
inline |
|
inline |
|
inline |
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().
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().
|
inline |
|
inline |
Reference another array.
Definition at line 114 of file MArray.h.
Referenced by casacore::TableExprNodeSet::getArray().
|
inline |
Resize the array and optionally the mask.
It always sets the MArray to non-null.
Definition at line 122 of file MArray.h.
Referenced by casacore::MArrayMath_global_functions_MArray_mathematical_operations::boxedArrayMath(), casacore::MArrayMath_global_functions_MArray_mathematical_operations::partialArrayMath(), and casacore::MArrayMath_global_functions_MArray_mathematical_operations::slidingArrayMath().
|
private |
Definition at line 178 of file MArray.h.
Referenced by casacore::MArray< casacore::String >::array(), casacore::MArray< casacore::String >::fill(), casacore::MArray< casacore::String >::MArray(), casacore::MArray< casacore::String >::operator()(), casacore::MArray< casacore::String >::reference(), and casacore::MArray< casacore::String >::resize().