casacore
Public Types | Public Member Functions | Protected Attributes | List of all members
casacore::MaskedArray< T, ArrayAlloc, MaskAlloc > Class Template Reference

More...

#include <MaskedArray.h>

Public Types

typedef Array< T, ArrayAlloc > array_type
 
typedef Array< LogicalArrayElem, MaskAlloc > mask_type
 
typedef MaskedArray< T, ArrayAlloc, MaskAlloc > masked_array_type
 

Public Member Functions

 MaskedArray ()
 Default constructor for a MaskedArray does not allocate any memory for the Data array or Mask. More...
 
void setData (const array_type &data, const mask_type &mask, bool isReadOnly=false)
 Reset the data and mask of the the MaskedArray. More...
 
void setData (const masked_array_type &array, bool isReadOnly=false)
 
 MaskedArray (const array_type &inarray, const LogicalArray &inmask, bool isreadonly)
 Create a MaskedArray from an Array and a LogicalArray. More...
 
 MaskedArray (const array_type &inarray, const LogicalArray &inmask)
 
 MaskedArray (const masked_array_type &inarray, const LogicalArray &inmask, bool isreadonly)
 Create a MaskedArray from a MaskedArray and a LogicalArray. More...
 
 MaskedArray (const masked_array_type &inarray, const LogicalArray &inmask)
 
 MaskedArray (const array_type &inarray, const MaskedLogicalArray &inmask, bool isreadonly)
 Create a MaskedArray from an Array and a MaskedLogicalArray. More...
 
 MaskedArray (const array_type &inarray, const MaskedLogicalArray &inmask)
 
 MaskedArray (const masked_array_type &inarray, const MaskedLogicalArray &inmask, bool isreadonly)
 Create a MaskedArray from a MaskedArray and a MaskedLogicalArray. More...
 
 MaskedArray (const masked_array_type &inarray, const MaskedLogicalArray &inmask)
 
 MaskedArray (const masked_array_type &other, bool isreadonly)
 Copy constructor. More...
 
 MaskedArray (const masked_array_type &other)
 
 MaskedArray (masked_array_type &&source)
 The source is left empty after moving. More...
 
masked_array_type operator() (const LogicalArray &mask) const
 Return a MaskedArray. More...
 
masked_array_type operator() (const MaskedLogicalArray &mask) const
 Return a MaskedArray. More...
 
masked_array_type operator() (const IPosition &start, const IPosition &end)
 Get a reference to an array part which extends from "start" to end. More...
 
masked_array_type operator() (const IPosition &start, const IPosition &end, const IPosition &inc)
 Along the ith axis, every inc[i]'th element is chosen. More...
 
masked_array_type operator() (const Slicer &)
 Get a reference to an array using a Slicer. More...
 
masked_array_type copy (bool isreadonly) const
 Make a copy of the masked array. More...
 
masked_array_type copy () const
 
const array_typegetArray () const
 Return the internal Array. More...
 
array_typegetRWArray () const
 Return the internal Array, writeable. More...
 
const mask_typegetMask () const
 Return the (const) internal Mask. More...
 
size_t ndim () const
 The dimensionality of this masked array. More...
 
size_t nelements () const
 The number of elements of this masked array. More...
 
size_t size () const
 
size_t nelementsValid () const
 The number of valid elements of this masked array. More...
 
bool ok () const
 Check to see if the masked array is consistent. More...
 
bool conform (const array_type &other) const
 Are the shapes identical? More...
 
bool conform (const masked_array_type &other) const
 
const IPositionshape () const
 The length of each axis. More...
 
bool isReadOnly () const
 Is the array read only? More...
 
void setReadOnly () const
 Set the array to be read only. More...
 
masked_array_typeoperator= (const array_type &inarray)
 Copy the values in inarray to this, only copying those elements for which the corresponding mask element is true. More...
 
masked_array_typeoperator= (array_type &&inarray)
 
masked_array_typeoperator= (const masked_array_type &other)
 Copies/moves the values in other to this, only copying those elements for which the logical AND of the corresponding mask elements of both MaskedArrays is true. More...
 
masked_array_typeoperator= (masked_array_type &&other)
 
masked_array_typeoperator= (const T &value)
 Set every element of this array to "value", only setting those elements for which the corresponding mask element is true. More...
 
Array< T, ArrayAlloc > getCompressedArray () const
 Return a "compressed" Array containing only the valid elements of the MaskedArray. More...
 
Array< T, ArrayAlloc > getCompressedArray (const IPosition &shape) const
 The returned Array will have the input shape. More...
 
void getCompressedArray (array_type &inarr) const
 Fill the argument "compressed" Array with only the valid elements of the MaskedArray. More...
 
void setCompressedArray (const array_type &inarr)
 Set only the valid elements of the MaskedArray from the argument "compressed" Array. More...
 
const T * getArrayStorage (bool &deleteIt) const
 Manipulate the storage for the underlying Array. More...
 
T * getRWArrayStorage (bool &deleteIt) const
 
void freeArrayStorage (const T *&storage, bool deleteIt) const
 
void putArrayStorage (T *&storage, bool deleteAndCopy) const
 
const LogicalArrayElemgetMaskStorage (bool &deleteIt) const
 Manipulate the storage for the underlying Mask. More...
 
void freeMaskStorage (const LogicalArrayElem *&storage, bool deleteIt) const
 

Protected Attributes

std::unique_ptr< array_typepArray
 The array. More...
 
std::unique_ptr< mask_typepMask
 The mask. More...
 
size_t nelemValid
 Cache the number of valid elements. More...
 
bool nelemValidIsOK
 Is the number of valid elements cache OK? i.e. More...
 
bool isRO
 Is the array read only? More...
 

Detailed Description

template<typename T, typename ArrayAlloc, typename MaskAlloc>
class casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >

Class for masking an Array for operations on that Array.

Review Status

Reviewed By:
UNKNOWN
Date Reviewed:
before2004/08/25
Test programs:
tMaskedArray tMaskArrExcp

Prerequisite

Etymology

MaskedArray is a class for masking elements of an Array while performing operations on that Array.

Synopsis

A MaskedArray is an association between an Array and a mask. The mask selects elements of the Array. Only elements of the Array where the corresponding element of the mask is true are defined. Thus, operations on a MaskedArray only operate on those elements of the Array where the corresponding element of the mask is true.

A MaskedArray should be thought of as a manipulator for an Array, analogous to an iterator. It allows one to perform whole Array operations on selected elements of the Array.

The mask used in the constructor for the MaskedArray must conform to the Array, thus have the same shape. The internal mask is (will be) copy constructed with reference semantics from the input mask. Therefore, it is (will be) possible to change the internal mask by changing values in the input mask after the MaskedArray has been constructed. To ensure that the internal mask is independent of the input mask after construction, use mask.copy() as the input argument.

One can explicitly construct a MaskedArray from an Array and a mask or a MaskedArray and a mask. One can also use operator() on an Array or a MaskedArray to implicitly create a MaskedArray.

One can create a MaskedArray from a MaskedArray and a mask. The resulting MaskedArray has as its Array the Array from the original MaskedArray. The mask for the resulting MaskedArray is the AND of the mask from the original MaskedArray and the input mask.

Any operation involving a MaskedArray or a set of MaskedArrays is only performed for those elements where the AND of the masks is true.

Any operation involving a MaskedArray or a set of MaskedArrays results in a MaskedArray whose mask is the AND of the masks of the original MaskedArrays. The only exception to this is assignment, where the mask determines which elements of the underlying Array are assigned.

Masks, which are LogicalArrays, can be constructed by logical operations involving Arrays. They can also, of course, be constructed by individually setting individual elements of an LogicalArray.

MaskedArrays constructed directly from Arrays are by default writeable. MaskedArrays constructed indirectly from Arrays by operator() are writeable if the Array is non-const and are readonly if the Array is const. MaskedArrays constructed from other MaskedArrays, either directly by constructors or indirectly by operator(), are by default writeable if the input MaskedArray is writeable, and readonly if the input MaskedArray is readonly.

A given MaskedArray can be set to be readonly. One specifies this in the constructor with the bool argument isreadonly, or calls the setReadOnly() member function. A MaskedArray which would default to be readonly cannot be forced to be writeable. It will remain readonly even if the bool argument isreadonly is set to be false.

The isReadOnly(), member function is used to test whether the MaskedArray is readonly.

Member functions which change the MaskedArray test to see whether the MaskedArray is readonly, and throw an ArrayError exception if it is. These member functions are:

The copy() member function makes a deep copy of a MaskedArray. By default it returns a writeable MaskedArray, but the MaskedArray returned can be made readonly by using the bool argument "isreadonly" to copy() (or by calling setReadOnly() on the new MaskedArray).

The valid elements of the MaskedArray can be manipulated as a "compressed" Array which contains only the valid elements. The number of elements in this "compressed" Array is the number of valid elements in the MaskedArray, nelementsValid(). The "compressed" Array can have any shape which meets this requirement. The MaskedArray can have any shape.

The getCompressedArray() member functions get a compressed Array from the valid members of the MaskedArray, while the setCompressedArray() member function sets the valid members of the MaskedArray from the input compressed Array.

Many mathematical and logical global operators and functions which operate on MaskedArrays are defined. Typically, they are defined for all sensible combinations of MaskedArrays, Arrays, and scalars.

Mathematical global operators and functions are defined in Arrays/MaskArrMath.h. The list is:

Logical global operators and functions are defined in Arrays/MaskArrLogi.h. The list is:

Example

Use an explicit MaskedArray to limit the maximum value of an Array.

Vector<int> arr (20);
...
MaskedArray<int> marr (arr, (arr > 5));
marr = 5;

This sets all elements of arr which are greater than 5 to 5.

Example

Use an implicit MaskedArray to limit the minimum value of an Array.

Vector<int> arr (20);
...
arr (arr < 0) = 0;

This sets all elements of arr which are less than 0 to 0.

Example

It does not matter where in an expression the MaskedArrays are located. The operation is only performed on those elements where the AND of the masks is true.

The following expressions are all equivalent. The first (and second) expressions are the most efficient, since the sum is only performed for those elements where ((a > 0) && (b > 0)). The third example is less efficient, since the sum is performed for all elements of a and b, and then the assignment is only performed for those elements where ((a > 0) && (b > 0)).

Vector<int> arr (20);
Vector<int> a (20);
Vector<int> b (20);
...
arr = a(a > 0) + b(b > 0);
arr = a(b > 0) + b(a > 0);
arr ((a > 0) && (b > 0)) = a + b;
arr = (a + b) ((a > 0) && (b > 0));
arr (a > 0) = a + b(b > 0);

All of these expressions set those elements of arr where ((a > 0) && (b > 0)) to a + b. Those elements of arr where the condition is false are unchanged.

Example

This example extracts the valid elements of the MaskedArray as a "compressed" Vector, manipulates this Vector, and then puts the result back into the MaskedArray.

Matrix<int> arr (20,5);
...
MaskedArray<int> marr (arr, (arr>0) && (arr<10));
Vector<int> vec (marr.getCompressedArray());
...
marr.setCompressedArray (vec);

Motivation

A MaskedArray is an association between an Array and a LogicalArray which masks the Array. It allows one to perform whole Array manipulations with a single expression, selecting those elements of the Array to modify based either on a logical expression, typically involving some of the Arrays involved in the expression, or based on a specifically set mask.

To Do

Definition at line 324 of file MaskedArray.h.

Member Typedef Documentation

◆ array_type

template<typename T , typename ArrayAlloc , typename MaskAlloc >
typedef Array<T, ArrayAlloc> casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::array_type

Definition at line 328 of file MaskedArray.h.

◆ mask_type

template<typename T , typename ArrayAlloc , typename MaskAlloc >
typedef Array<LogicalArrayElem, MaskAlloc> casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::mask_type

Definition at line 329 of file MaskedArray.h.

◆ masked_array_type

template<typename T , typename ArrayAlloc , typename MaskAlloc >
typedef MaskedArray<T, ArrayAlloc, MaskAlloc> casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::masked_array_type

Definition at line 330 of file MaskedArray.h.

Constructor & Destructor Documentation

◆ MaskedArray() [1/12]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::MaskedArray ( )

Default constructor for a MaskedArray does not allocate any memory for the Data array or Mask.

Hence the masked array should not be used until some data is allocated to the object using one of the set functions.

◆ MaskedArray() [2/12]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::MaskedArray ( const array_type inarray,
const LogicalArray inmask,
bool  isreadonly 
)

Create a MaskedArray from an Array and a LogicalArray.

The internal mask is a total copy of the input mask, and is completely independent of the input mask.

The Array is copy constructed, which means that it is a really smart pointer to the underlying Block, and shares this Block with the input Array.

By default, the MaskedArray constructed is writeable. If isreadonly is true, then the MaskedArray returned is readonly.

Thrown Exceptions

◆ MaskedArray() [3/12]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::MaskedArray ( const array_type inarray,
const LogicalArray inmask 
)

◆ MaskedArray() [4/12]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::MaskedArray ( const masked_array_type inarray,
const LogicalArray inmask,
bool  isreadonly 
)

Create a MaskedArray from a MaskedArray and a LogicalArray.

The internal mask is the AND of the input mask and the mask of the input MaskedArray.

The Array from the input MaskedArray is copy constructed, which means that it is a really smart pointer to the underlying Block, and shares this Block with the Array from the input MaskedArray.

By default, the MaskedArray constructed is writeable if the input MaskedArray is writeable, and readonly if the input MaskedArray is readonly. If isreadonly is true, then the MaskedArray returned is readonly. If isreadonly is false and the input MaskedArray is readonly, then the constructed MaskedArray is readonly.

Thrown Exceptions

◆ MaskedArray() [5/12]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::MaskedArray ( const masked_array_type inarray,
const LogicalArray inmask 
)

◆ MaskedArray() [6/12]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::MaskedArray ( const array_type inarray,
const MaskedLogicalArray inmask,
bool  isreadonly 
)

Create a MaskedArray from an Array and a MaskedLogicalArray.

The internal mask is the AND of the internal LogicalArray and the internal mask of the MaskedLogicalArray.

The Array is copy constructed, which means that it is a really smart pointer to the underlying Block, and shares this Block with the input Array.

By default, the MaskedArray constructed is writeable. If isreadonly is true, then the MaskedArray returned is readonly.

Thrown Exceptions

◆ MaskedArray() [7/12]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::MaskedArray ( const array_type inarray,
const MaskedLogicalArray inmask 
)

◆ MaskedArray() [8/12]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::MaskedArray ( const masked_array_type inarray,
const MaskedLogicalArray inmask,
bool  isreadonly 
)

Create a MaskedArray from a MaskedArray and a MaskedLogicalArray.

The internal mask is the AND of the internal LogicalArray and the internal mask of the MaskedLogicalArray, ANDed with the mask of the input MaskedArray.

The Array from the input MaskedArray is copy constructed, which means that it is a really smart pointer to the underlying Block, and shares this Block with the Array from the input MaskedArray.

By default, the MaskedArray constructed is writeable if the input MaskedArray is writeable, and readonly if the input MaskedArray is readonly. If isreadonly is true, then the MaskedArray returned is readonly. If isreadonly is false and the input MaskedArray is readonly, then the constructed MaskedArray is readonly.

Thrown Exceptions

◆ MaskedArray() [9/12]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::MaskedArray ( const masked_array_type inarray,
const MaskedLogicalArray inmask 
)

◆ MaskedArray() [10/12]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::MaskedArray ( const masked_array_type other,
bool  isreadonly 
)

Copy constructor.

The internal mask is a total copy of the mask from the input MaskedArray, and is completely independent of this input mask.

The Array from the input MaskedArray is copy constructed, which means that it is a really smart pointer to the underlying Block, and shares this Block with the Array from the input MaskedArray.

By default, the MaskedArray constructed is writeable if the input MaskedArray is writeable, and readonly if the input MaskedArray is readonly. If isreadonly is true, then the MaskedArray returned is readonly. If isreadonly is false and the input MaskedArray is readonly, then the constructed MaskedArray is readonly.

◆ MaskedArray() [11/12]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::MaskedArray ( const masked_array_type other)

◆ MaskedArray() [12/12]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::MaskedArray ( masked_array_type &&  source)

The source is left empty after moving.

Member Function Documentation

◆ conform() [1/2]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
bool casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::conform ( const array_type other) const

Are the shapes identical?

◆ conform() [2/2]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
bool casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::conform ( const masked_array_type other) const

◆ copy() [1/2]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
masked_array_type casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::copy ( ) const

◆ copy() [2/2]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
masked_array_type casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::copy ( bool  isreadonly) const

Make a copy of the masked array.

This is a deep copy. The Array and mask components of the returned MaskedArray are deep copies of the Array and mask in the input MaskedArray pointed to by this. In other words, the Array and mask in the output MaskedArray are completely independent of those in the input MaskedArray.

By default, the MaskedArray returned is writeable. If isreadonly is true, then the MaskedArray returned is readonly.

◆ freeArrayStorage()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
void casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::freeArrayStorage ( const T *&  storage,
bool  deleteIt 
) const

◆ freeMaskStorage()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
void casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::freeMaskStorage ( const LogicalArrayElem *&  storage,
bool  deleteIt 
) const

◆ getArray()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
const array_type& casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::getArray ( ) const

Return the internal Array.

◆ getArrayStorage()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
const T* casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::getArrayStorage ( bool &  deleteIt) const

Manipulate the storage for the underlying Array.

See the description of the corresponding Array functions for more information.

◆ getCompressedArray() [1/3]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
Array<T, ArrayAlloc> casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::getCompressedArray ( ) const

Return a "compressed" Array containing only the valid elements of the MaskedArray.

The number of elements in the Array will be nelementsValid() for the MaskedArray. The MaskedArray can have any shape.

The returned Array will have dimension one.

◆ getCompressedArray() [2/3]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
void casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::getCompressedArray ( array_type inarr) const

Fill the argument "compressed" Array with only the valid elements of the MaskedArray.

The size of the Array must be nelementsValid() for the MaskedArray. The Array can have any shape which meets this requirement. The MaskedArray can have any shape.

Thrown Exceptions

◆ getCompressedArray() [3/3]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
Array<T, ArrayAlloc> casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::getCompressedArray ( const IPosition shape) const

The returned Array will have the input shape.

This shape must give the returned Array the required number of elements.

Thrown Exceptions

◆ getMask()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
const mask_type& casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::getMask ( ) const

Return the (const) internal Mask.

◆ getMaskStorage()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
const LogicalArrayElem* casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::getMaskStorage ( bool &  deleteIt) const

Manipulate the storage for the underlying Mask.

See the description of the corresponding Array functions for more information.

◆ getRWArray()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
array_type& casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::getRWArray ( ) const

Return the internal Array, writeable.

Thrown Exceptions

◆ getRWArrayStorage()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
T* casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::getRWArrayStorage ( bool &  deleteIt) const

Thrown Exceptions

◆ isReadOnly()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
bool casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::isReadOnly ( ) const
inline

Is the array read only?

Definition at line 563 of file MaskedArray.h.

References casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::isRO.

◆ ndim()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
size_t casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::ndim ( ) const

The dimensionality of this masked array.

◆ nelements()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
size_t casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::nelements ( ) const

◆ nelementsValid()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
size_t casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::nelementsValid ( ) const

The number of valid elements of this masked array.

This is the number of elements of the mask which are TRUE.

◆ ok()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
bool casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::ok ( ) const

Check to see if the masked array is consistent.

This is about the same thing as checking for invariants. If AIPS_DEBUG is defined, this is invoked after construction and on entry to most member functions.

◆ operator()() [1/5]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
masked_array_type casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::operator() ( const IPosition start,
const IPosition end 
)

Get a reference to an array part which extends from "start" to end.

"

◆ operator()() [2/5]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
masked_array_type casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::operator() ( const IPosition start,
const IPosition end,
const IPosition inc 
)

Along the ith axis, every inc[i]'th element is chosen.

◆ operator()() [3/5]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
masked_array_type casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::operator() ( const LogicalArray mask) const

Return a MaskedArray.

The new MaskedArray is masked by the input LogicalArray "anded" with the mask of the original MaskedArray. This mask must conform to the array.

The MaskedArray constructed is writeable if the input MaskedArray is writeable, and readonly if the input MaskedArray is readonly.

◆ operator()() [4/5]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
masked_array_type casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::operator() ( const MaskedLogicalArray mask) const

Return a MaskedArray.

The new MaskedArray is masked by the input MaskedLogicalArray "anded" with the mask of the original MaskedArray. This mask must conform to the array.

The MaskedArray constructed is writeable if the input MaskedArray is writeable, and readonly if the input MaskedArray is readonly.

◆ operator()() [5/5]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
masked_array_type casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::operator() ( const Slicer )

Get a reference to an array using a Slicer.

◆ operator=() [1/5]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
masked_array_type& casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::operator= ( array_type &&  inarray)

◆ operator=() [2/5]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
masked_array_type& casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::operator= ( const array_type inarray)

Copy the values in inarray to this, only copying those elements for which the corresponding mask element is true.

Thrown Exceptions

TODO rename, see copy assignment operator.

◆ operator=() [3/5]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
masked_array_type& casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::operator= ( const masked_array_type other)

Copies/moves the values in other to this, only copying those elements for which the logical AND of the corresponding mask elements of both MaskedArrays is true.

Thrown Exceptions

TODO this should be renamed: assignment operator should make obervable state equal, which should thus include getArray().

◆ operator=() [4/5]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
masked_array_type& casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::operator= ( const T &  value)

Set every element of this array to "value", only setting those elements for which the corresponding mask element is true.

In other words, a scalar behaves as if it were a constant conformant array.

Thrown Exceptions

◆ operator=() [5/5]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
masked_array_type& casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::operator= ( masked_array_type &&  other)

◆ putArrayStorage()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
void casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::putArrayStorage ( T *&  storage,
bool  deleteAndCopy 
) const

Thrown Exceptions

◆ setCompressedArray()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
void casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::setCompressedArray ( const array_type inarr)

Set only the valid elements of the MaskedArray from the argument "compressed" Array.

The size of the Array must be nelementsValid() for the MaskedArray. The Array can have any shape which meets this requirement. The MaskedArray can have any shape.

Thrown Exceptions

◆ setData() [1/2]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
void casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::setData ( const array_type data,
const mask_type mask,
bool  isReadOnly = false 
)

Reset the data and mask of the the MaskedArray.

There should perhaps be a whole family of setData functions with different arguements, analogous to the constructors. However these are sufficient for the moment.

◆ setData() [2/2]

template<typename T , typename ArrayAlloc , typename MaskAlloc >
void casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::setData ( const masked_array_type array,
bool  isReadOnly = false 
)

◆ setReadOnly()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
void casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::setReadOnly ( ) const

Set the array to be read only.

◆ shape()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
const IPosition& casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::shape ( ) const
inline

The length of each axis.

Definition at line 559 of file MaskedArray.h.

References casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::pArray.

◆ size()

template<typename T , typename ArrayAlloc , typename MaskAlloc >
size_t casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::size ( ) const
inline

Member Data Documentation

◆ isRO

template<typename T , typename ArrayAlloc , typename MaskAlloc >
bool casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::isRO
protected

Is the array read only?

Definition at line 698 of file MaskedArray.h.

Referenced by casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::isReadOnly().

◆ nelemValid

template<typename T , typename ArrayAlloc , typename MaskAlloc >
size_t casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::nelemValid
protected

Cache the number of valid elements.

Definition at line 691 of file MaskedArray.h.

◆ nelemValidIsOK

template<typename T , typename ArrayAlloc , typename MaskAlloc >
bool casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::nelemValidIsOK
protected

Is the number of valid elements cache OK? i.e.

has it been calculated?

Definition at line 695 of file MaskedArray.h.

◆ pArray

template<typename T , typename ArrayAlloc , typename MaskAlloc >
std::unique_ptr<array_type> casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::pArray
protected

The array.

Definition at line 685 of file MaskedArray.h.

Referenced by casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::shape().

◆ pMask

template<typename T , typename ArrayAlloc , typename MaskAlloc >
std::unique_ptr<mask_type> casacore::MaskedArray< T, ArrayAlloc, MaskAlloc >::pMask
protected

The mask.

Definition at line 688 of file MaskedArray.h.


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