26#ifndef CASA_ARRAYBASE_2_H
27#define CASA_ARRAYBASE_2_H
37class ArrayPositionIterator;
120 virtual bool ok()
const;
158 virtual std::unique_ptr<ArrayPositionIterator>
makeIterator (
size_t byDim)
const;
197 long long nElementsAllocated,
198 bool copyDataIfNeeded,
199 size_t resizePercentage);
312 const ssize_t* Origin,
const ssize_t* Inc,
315 const ssize_t* Inc,
const IPosition& Index);
Non-templated base class for templated Array class.
virtual bool ok() const
Check to see if the Array is consistent.
void validateIndex(size_t index1, size_t index2, size_t index3) const
static unsigned arrayVersion()
Array version for major change (used by ArrayIO).
void validateConformance(const ArrayBase &) const
Various helper functions.
ArrayBase & assign(const ArrayBase &)
Assignment.
void baseNonDegenerate(const ArrayBase &other, const IPosition &ignoreAxes)
Remove the degenerate axes from the Array object.
void baseReform(ArrayBase &tmp, const IPosition &shape, bool strict=true) const
Reform the array to a shape with the same nr of elements.
bool copyVectorHelper(const ArrayBase &other)
Helper function for templated Vector class.
virtual const void * getVStorage(bool &deleteIt) const
const IPosition & steps() const
Return steps to be made if stepping one element in a dimension.
void checkMatrixShape()
Check if the shape of a matrix is correct.
ArrayBase(ArrayBase &&source, const IPosition &shapeForSource) noexcept
For subclasses, this move constructor allows the moved-from object to obtain a given shape after resi...
size_t ndim() const
The dimensionality of this array.
size_t nels_p
Number of elements in the array.
void swap(ArrayBase &source) noexcept
void validateIndex(const IPosition &) const
virtual void assignBase(const ArrayBase &source, bool checkType=true)
Assign the source array to this array.
size_t nelements() const
How many elements does this array have? Product of all axis lengths.
virtual std::unique_ptr< ArrayBase > getSection(const Slicer &) const
Get a reference to a section of an array.
virtual std::unique_ptr< ArrayBase > makeArray() const
Make an empty array of the same type.
size_t makeSubset(ArrayBase &out, const IPosition &b, const IPosition &e, const IPosition &i)
Make a subset of an array.
size_t ndimen_p
Dimensionality of the array.
bool contiguous_p
Are the data contiguous?
void baseAddDegenerate(ArrayBase &, size_t numAxes)
These member functions return an Array reference with the specified number of extra axes,...
virtual void freeVStorage(const void *&storage, bool deleteIt) const
IPosition originalLength_p
void baseMakeSteps()
Make the indexing step sizes.
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.
bool contiguousStorage() const
Are the array data contiguous? If they are not contiguous, getStorage (see below) needs to make a cop...
bool empty() const
Is the array empty (i.e.
void validateIndex(size_t index1, size_t index2) const
const IPosition & shape() const
The length of each axis.
void validateIndex(size_t index) const
IPosition length_p
Used to hold the shape, increment into the underlying storage and originalLength of the array.
virtual void * getVStorage(bool &deleteIt)
The following functions behave the same as the corresponding getStorage functions in the derived temp...
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 f...
virtual void resize(const IPosition &newShape, bool copyValues=false)
Resize the array and optionally copy the values.
void checkVectorShape()
Check if the shape of a vector is correct.
virtual std::unique_ptr< ArrayPositionIterator > makeIterator(size_t byDim) const
Resize the array and optionally copy the values.
virtual void putVStorage(void *&storage, bool deleteAndCopy)
IPosition steps_p
Used to hold the step to next element in each dimension.
bool conform2(const ArrayBase &other) const
Are the shapes identical?
IPosition endPosition() const
A convenience function: endPosition(i) = shape(i) - 1; i.e.
void checkCubeShape()
Check if the shape of a cube is correct.
bool isStorageContiguous() const
Determine if the storage of a subset is contiguous.
bool isEqual(const IPosition &other) const
Element-by-element comparison for equality.
size_t ArrayVolume(size_t Ndim, const int *Shape)
General global functions for Arrays.
@ COPY
COPY is used when an internal copy of the storage is to be made.
@ SHARE
Share means that the Array will just use the pointer (no copy), however the Array will NOT delete it ...
@ TAKE_OVER
TAKE_OVER is used to indicate that the Array should just use the external storage (i....
this file contains all the compiler specific defines
void checkArrayShapes(const ArrayBase &left, const ArrayBase &right, const char *name)
size_t ArrayIndexOffset(size_t Ndim, const ssize_t *Shape, const ssize_t *Origin, const ssize_t *Inc, const IPosition &Index)
What is the linear index into an "Ndim" dimensional array of the given "Shape", "Origin",...
void throwArrayShapes(const IPosition &shape1, const IPosition &shape2, const char *name)
Function to check the shapes.