casacore
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
casacore::ArrayBase Class Reference

Non-templated base class for templated Array class. More...

#include <ArrayBase.h>

Public Member Functions

 ArrayBase () noexcept
 
 ArrayBase (const IPosition &shape)
 Create an array of the given shape, i.e. More...
 
 ArrayBase (const ArrayBase &other)
 Copy constructor. More...
 
 ArrayBase (ArrayBase &&source) noexcept
 
ArrayBaseassign (const ArrayBase &)
 Assignment. More...
 
ArrayBaseoperator= (const ArrayBase &)=delete
 
ArrayBaseoperator= (ArrayBase &&) noexcept
 
virtual ~ArrayBase () noexcept
 Destructor. More...
 
size_t ndim () const
 The dimensionality of this array. More...
 
size_t nelements () const
 How many elements does this array have? Product of all axis lengths. More...
 
size_t size () const
 
bool empty () const
 Is the array empty (i.e. More...
 
bool contiguousStorage () const
 Are the array data contiguous? If they are not contiguous, getStorage (see below) needs to make a copy. More...
 
virtual bool ok () const
 Check to see if the Array is consistent. More...
 
const IPositionshape () const
 The length of each axis. More...
 
IPosition endPosition () const
 A convenience function: endPosition(i) = shape(i) - 1; i.e. More...
 
const IPositionsteps () const
 Return steps to be made if stepping one element in a dimension. More...
 
virtual std::unique_ptr< ArrayBasemakeArray () const
 Make an empty array of the same type. More...
 
virtual void resize (const IPosition &newShape, bool copyValues=false)
 Resize the array and optionally copy the values. More...
 
virtual std::unique_ptr< ArrayPositionIteratormakeIterator (size_t byDim) const
 Resize the array and optionally copy the values. More...
 
virtual std::unique_ptr< ArrayBasegetSection (const Slicer &) const
 Get a reference to a section of an array. More...
 
virtual void assignBase (const ArrayBase &source, bool checkType=true)
 Assign the source array to this array. More...
 
virtual void * getVStorage (bool &deleteIt)
 The following functions behave the same as the corresponding getStorage functions in the derived templated Array class. More...
 
virtual const void * getVStorage (bool &deleteIt) const
 
virtual void putVStorage (void *&storage, bool deleteAndCopy)
 
virtual void freeVStorage (const void *&storage, bool deleteIt) const
 
void validateConformance (const ArrayBase &) const
 Various helper functions. More...
 
void validateIndex (const IPosition &) const
 
void validateIndex (size_t index) const
 
void validateIndex (size_t index1, size_t index2) const
 
void validateIndex (size_t index1, size_t index2, size_t index3) const
 

Static Public Member Functions

static unsigned arrayVersion ()
 Array version for major change (used by ArrayIO). More...
 

Protected Member Functions

 ArrayBase (ArrayBase &&source, const IPosition &shapeForSource) noexcept
 For subclasses, this move constructor allows the moved-from object to obtain a given shape after resizing. More...
 
void swap (ArrayBase &source) noexcept
 
bool reformOrResize (const IPosition &newShape, bool resizeIfNeeded, size_t nReferences, long long nElementsAllocated, bool copyDataIfNeeded, size_t resizePercentage)
 Either reforms the array if size permits or resizes it to the new shape. More...
 
bool isStorageContiguous () const
 Determine if the storage of a subset is contiguous. More...
 
void checkVectorShape ()
 Check if the shape of a vector is correct. More...
 
void checkMatrixShape ()
 Check if the shape of a matrix is correct. More...
 
void checkCubeShape ()
 Check if the shape of a cube is correct. More...
 
void baseReform (ArrayBase &tmp, const IPosition &shape, bool strict=true) const
 Reform the array to a shape with the same nr of elements. More...
 
void baseNonDegenerate (const ArrayBase &other, const IPosition &ignoreAxes)
 Remove the degenerate axes from the Array object. More...
 
void baseAddDegenerate (ArrayBase &, size_t numAxes)
 These member functions return an Array reference with the specified number of extra axes, all of length one, appended to the end of the Array. More...
 
size_t makeSubset (ArrayBase &out, const IPosition &b, const IPosition &e, const IPosition &i)
 Make a subset of an array. More...
 
size_t makeDiagonal (size_t firstAxis, long long diag)
 Set the length and stride such that the diagonal of the matrices defined by two consecutive axes is formed. More...
 
bool conform2 (const ArrayBase &other) const
 Are the shapes identical? More...
 
void baseMakeSteps ()
 Make the indexing step sizes. More...
 
bool copyVectorHelper (const ArrayBase &other)
 Helper function for templated Vector class. More...
 

Protected Attributes

size_t nels_p
 Number of elements in the array. More...
 
size_t ndimen_p
 Dimensionality of the array. More...
 
bool contiguous_p
 Are the data contiguous? More...
 
IPosition length_p
 Used to hold the shape, increment into the underlying storage and originalLength of the array. More...
 
IPosition inc_p
 
IPosition originalLength_p
 
IPosition steps_p
 Used to hold the step to next element in each dimension. More...
 

Detailed Description

Non-templated base class for templated Array class.

ArrayBase is only used to factor out common code from the templated Array class.

Definition at line 72 of file ArrayBase.h.

Constructor & Destructor Documentation

◆ ArrayBase() [1/5]

casacore::ArrayBase::ArrayBase ( )
noexcept

◆ ArrayBase() [2/5]

casacore::ArrayBase::ArrayBase ( const IPosition shape)
explicit

Create an array of the given shape, i.e.

after construction array.ndim() == shape.nelements() and array.shape() == shape. The origin of the Array is zero.

◆ ArrayBase() [3/5]

casacore::ArrayBase::ArrayBase ( const ArrayBase other)

Copy constructor.

◆ ArrayBase() [4/5]

casacore::ArrayBase::ArrayBase ( ArrayBase &&  source)
noexcept

◆ ~ArrayBase()

virtual casacore::ArrayBase::~ArrayBase ( )
virtualnoexcept

Destructor.

◆ ArrayBase() [5/5]

casacore::ArrayBase::ArrayBase ( ArrayBase &&  source,
const IPosition shapeForSource 
)
protectednoexcept

For subclasses, this move constructor allows the moved-from object to obtain a given shape after resizing.

This way, e.g. a source Matrix can still kee a dimensionality of 2.

Member Function Documentation

◆ arrayVersion()

static unsigned casacore::ArrayBase::arrayVersion ( )
inlinestatic

Array version for major change (used by ArrayIO).

enum did not work properly with cfront 3.0.1), so replaced by a static inline function. Users won't normally use this.

Definition at line 142 of file ArrayBase.h.

◆ assign()

ArrayBase& casacore::ArrayBase::assign ( const ArrayBase )

Assignment.

◆ assignBase()

virtual void casacore::ArrayBase::assignBase ( const ArrayBase source,
bool  checkType = true 
)
virtual

◆ baseAddDegenerate()

void casacore::ArrayBase::baseAddDegenerate ( ArrayBase ,
size_t  numAxes 
)
protected

These member functions return an Array reference with the specified number of extra axes, all of length one, appended to the end of the Array.

Note that the reform function can also be used to add extra axes.

◆ baseMakeSteps()

void casacore::ArrayBase::baseMakeSteps ( )
protected

Make the indexing step sizes.

Referenced by casacore::Array< T, Alloc >::makeSteps().

◆ baseNonDegenerate()

void casacore::ArrayBase::baseNonDegenerate ( const ArrayBase other,
const IPosition ignoreAxes 
)
protected

Remove the degenerate axes from the Array object.

This is the implementation of the nonDegenerate functions. It has a different name to be able to make it virtual without having the "hide virtual function" message when compiling derived classes.

◆ baseReform()

void casacore::ArrayBase::baseReform ( ArrayBase tmp,
const IPosition shape,
bool  strict = true 
) const
protected

Reform the array to a shape with the same nr of elements.

If nonStrict then caller assumes responsibility for not overrunning storage (avoid or use with extreme care).

◆ checkCubeShape()

void casacore::ArrayBase::checkCubeShape ( )
protected

Check if the shape of a cube is correct.

Adjust it if smaller.

◆ checkMatrixShape()

void casacore::ArrayBase::checkMatrixShape ( )
protected

Check if the shape of a matrix is correct.

Adjust it if smaller.

◆ checkVectorShape()

void casacore::ArrayBase::checkVectorShape ( )
protected

Check if the shape of a vector is correct.

If possible, adjust if not. It is possible if at most one axis has length > 1.

◆ conform2()

bool casacore::ArrayBase::conform2 ( const ArrayBase other) const
inlineprotected

Are the shapes identical?

Definition at line 247 of file ArrayBase.h.

References casacore::IPosition::isEqual(), and length_p.

Referenced by casacore::Array< T, Alloc >::conform().

◆ contiguousStorage()

bool casacore::ArrayBase::contiguousStorage ( ) const
inline

◆ copyVectorHelper()

bool casacore::ArrayBase::copyVectorHelper ( const ArrayBase other)
protected

Helper function for templated Vector class.

It returns if this and other are conformant.

◆ empty()

bool casacore::ArrayBase::empty ( ) const
inline

Is the array empty (i.e.

no elements)?

Definition at line 110 of file ArrayBase.h.

References nels_p.

Referenced by casacore::MArrayBase::hasMask().

◆ endPosition()

IPosition casacore::ArrayBase::endPosition ( ) const

A convenience function: endPosition(i) = shape(i) - 1; i.e.

this is the IPosition of the last element of the Array.

◆ freeVStorage()

virtual void casacore::ArrayBase::freeVStorage ( const void *&  storage,
bool  deleteIt 
) const
virtual

◆ getSection()

virtual std::unique_ptr<ArrayBase> casacore::ArrayBase::getSection ( const Slicer ) const
virtual

◆ getVStorage() [1/2]

virtual void* casacore::ArrayBase::getVStorage ( bool &  deleteIt)
virtual

◆ getVStorage() [2/2]

virtual const void* casacore::ArrayBase::getVStorage ( bool &  deleteIt) const
virtual

◆ isStorageContiguous()

bool casacore::ArrayBase::isStorageContiguous ( ) const
protected

Determine if the storage of a subset is contiguous.

◆ makeArray()

virtual std::unique_ptr<ArrayBase> casacore::ArrayBase::makeArray ( ) const
virtual

◆ makeDiagonal()

size_t casacore::ArrayBase::makeDiagonal ( size_t  firstAxis,
long long  diag 
)
protected

Set the length and stride such that the diagonal of the matrices defined by two consecutive axes is formed.

diag == 0 indicates the main diagonal, >0 above, <0 below. It returns the offset of the diagonal in the (original) array.

◆ makeIterator()

virtual std::unique_ptr<ArrayPositionIterator> casacore::ArrayBase::makeIterator ( size_t  byDim) const
virtual

Resize the array and optionally copy the values.


The default implementation in ArrayBase throws an exception. virtual void resize(const IPosition &newShape, bool copyValues, ArrayInitPolicy policy);

Create an ArrayIterator object of the correct type. This is implemented in the derived Array classes.
The default implementation in ArrayBase throws an exception.

Reimplemented in casacore::Array< T, Alloc >, casacore::Array< Float >, casacore::Array< Double >, casacore::Array< casacore::MVFrequency >, casacore::Array< Short >, casacore::Array< T >, casacore::Array< Int >, casacore::Array< Int64 >, casacore::Array< DComplex >, casacore::Array< Bool >, casacore::Array< FType >, casacore::Array< typename casacore::NumericTraits< FType >::ConjugateType >, casacore::Array< M >, and casacore::Array< casacore::String >.

◆ makeSubset()

size_t casacore::ArrayBase::makeSubset ( ArrayBase out,
const IPosition b,
const IPosition e,
const IPosition i 
)
protected

Make a subset of an array.

It checks if start,end,incr are within the array limits. It returns the offset of the subset in the (original) array.

◆ ndim()

size_t casacore::ArrayBase::ndim ( ) const
inline

◆ nelements()

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

◆ ok()

virtual bool casacore::ArrayBase::ok ( ) const
virtual

Check to see if the 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.

Reimplemented in casacore::Matrix< T, Alloc >, casacore::Matrix< casacore::SquareMatrix< Complex, 2 > >, casacore::Matrix< Float >, casacore::Matrix< casacore::GaussianBeam >, casacore::Matrix< Double >, casacore::Matrix< T >, casacore::Matrix< Int >, casacore::Matrix< Int64 >, casacore::Matrix< FType >, casacore::Matrix< Bool >, casacore::Matrix< Complex >, casacore::Cube< T, Alloc >, casacore::Cube< Double >, casacore::Cube< casacore::RigidVector< Double, 2 > >, casacore::Array< T, Alloc >, casacore::Array< Float >, casacore::Array< Double >, casacore::Array< casacore::MVFrequency >, casacore::Array< Short >, casacore::Array< T >, casacore::Array< Int >, casacore::Array< Int64 >, casacore::Array< DComplex >, casacore::Array< Bool >, casacore::Array< FType >, casacore::Array< typename casacore::NumericTraits< FType >::ConjugateType >, casacore::Array< M >, casacore::Array< casacore::String >, casacore::Vector< T, Alloc >, casacore::Vector< Quantum< Double > >, casacore::Vector< casacore::SquareMatrix< Complex, 2 > >, casacore::Vector< casacore::MPosition >, casacore::Vector< Float >, casacore::Vector< double >, casacore::Vector< Double >, casacore::Vector< casacore::Vector< Range > >, casacore::Vector< T >, casacore::Vector< Int >, casacore::Vector< casacore::Unit >, casacore::Vector< rownr_t >, casacore::Vector< Int64 >, casacore::Vector< casacore::MDirection >, casacore::Vector< casacore::MFrequency >, casacore::Vector< casacore::RORecordFieldPtr< Double > >, casacore::Vector< size_t >, casacore::Vector< FType >, casacore::Vector< Bool >, casacore::Vector< typename casacore::FunctionTraits< T >::BaseType >, casacore::Vector< typename casacore::FunctionTraits< T >::ArgType >, casacore::Vector< casacore::Slicer * >, casacore::Vector< casacore::Quantum< Double > >, casacore::Vector< casacore::MeasComet * >, casacore::Vector< Domain >, casacore::Vector< casacore::Vector< typename casacore::LSQTraits< typename casacore::FunctionTraits< T >::BaseType >::base > >, casacore::Vector< uInt >, casacore::Vector< ArgType >, and casacore::Vector< casacore::String >.

◆ operator=() [1/2]

ArrayBase& casacore::ArrayBase::operator= ( ArrayBase &&  )
noexcept

◆ operator=() [2/2]

ArrayBase& casacore::ArrayBase::operator= ( const ArrayBase )
delete

◆ putVStorage()

virtual void casacore::ArrayBase::putVStorage ( void *&  storage,
bool  deleteAndCopy 
)
virtual

◆ reformOrResize()

bool casacore::ArrayBase::reformOrResize ( const IPosition newShape,
bool  resizeIfNeeded,
size_t  nReferences,
long long  nElementsAllocated,
bool  copyDataIfNeeded,
size_t  resizePercentage 
)
protected

Either reforms the array if size permits or resizes it to the new shape.

Implementation of Array<T>::reformOrResize (slightly different signature).

◆ resize()

virtual void casacore::ArrayBase::resize ( const IPosition newShape,
bool  copyValues = false 
)
virtual

Resize the array and optionally copy the values.


The default implementation in ArrayBase throws an exception.

Reimplemented in casacore::Array< T, Alloc >, casacore::Array< Float >, casacore::Array< Double >, casacore::Array< casacore::MVFrequency >, casacore::Array< Short >, casacore::Array< T >, casacore::Array< Int >, casacore::Array< Int64 >, casacore::Array< DComplex >, casacore::Array< Bool >, casacore::Array< FType >, casacore::Array< typename casacore::NumericTraits< FType >::ConjugateType >, casacore::Array< M >, casacore::Array< casacore::String >, casacore::Vector< T, Alloc >, casacore::Vector< Quantum< Double > >, casacore::Vector< casacore::SquareMatrix< Complex, 2 > >, casacore::Vector< casacore::MPosition >, casacore::Vector< Float >, casacore::Vector< double >, casacore::Vector< Double >, casacore::Vector< casacore::Vector< Range > >, casacore::Vector< T >, casacore::Vector< Int >, casacore::Vector< casacore::Unit >, casacore::Vector< rownr_t >, casacore::Vector< Int64 >, casacore::Vector< casacore::MDirection >, casacore::Vector< casacore::MFrequency >, casacore::Vector< casacore::RORecordFieldPtr< Double > >, casacore::Vector< size_t >, casacore::Vector< FType >, casacore::Vector< Bool >, casacore::Vector< typename casacore::FunctionTraits< T >::BaseType >, casacore::Vector< typename casacore::FunctionTraits< T >::ArgType >, casacore::Vector< casacore::Slicer * >, casacore::Vector< casacore::Quantum< Double > >, casacore::Vector< casacore::MeasComet * >, casacore::Vector< Domain >, casacore::Vector< casacore::Vector< typename casacore::LSQTraits< typename casacore::FunctionTraits< T >::BaseType >::base > >, casacore::Vector< uInt >, casacore::Vector< ArgType >, and casacore::Vector< casacore::String >.

◆ shape()

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

◆ size()

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

◆ steps()

const IPosition& casacore::ArrayBase::steps ( ) const
inline

Return steps to be made if stepping one element in a dimension.

This is the 'physical' step, thus it also works correctly for non-contiguous arrays. E.g. data() + steps(0) gives the second element of the first axis.

Definition at line 136 of file ArrayBase.h.

References steps_p.

Referenced by casacore::ArrayMath_global_functions_Array_mathematical_operations::expandArray().

◆ swap()

void casacore::ArrayBase::swap ( ArrayBase source)
protectednoexcept

◆ validateConformance()

void casacore::ArrayBase::validateConformance ( const ArrayBase ) const

Various helper functions.

◆ validateIndex() [1/4]

void casacore::ArrayBase::validateIndex ( const IPosition ) const

◆ validateIndex() [2/4]

void casacore::ArrayBase::validateIndex ( size_t  index) const

◆ validateIndex() [3/4]

void casacore::ArrayBase::validateIndex ( size_t  index1,
size_t  index2 
) const

◆ validateIndex() [4/4]

void casacore::ArrayBase::validateIndex ( size_t  index1,
size_t  index2,
size_t  index3 
) const

Member Data Documentation

◆ contiguous_p

bool casacore::ArrayBase::contiguous_p
protected

◆ inc_p

IPosition casacore::ArrayBase::inc_p
protected

◆ length_p

IPosition casacore::ArrayBase::length_p
protected

◆ ndimen_p

size_t casacore::ArrayBase::ndimen_p
protected

Dimensionality of the array.

Definition at line 271 of file ArrayBase.h.

Referenced by ndim().

◆ nels_p

size_t casacore::ArrayBase::nels_p
protected

Number of elements in the array.

Cached rather than computed.

Definition at line 269 of file ArrayBase.h.

Referenced by empty(), nelements(), casacore::Array< T, Alloc >::setEndIter(), and size().

◆ originalLength_p

IPosition casacore::ArrayBase::originalLength_p
protected

◆ steps_p

IPosition casacore::ArrayBase::steps_p
protected

Used to hold the step to next element in each dimension.

Definition at line 278 of file ArrayBase.h.

Referenced by casacore::Array< T, Alloc >::setEndIter(), and steps().


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