Go to the documentation of this file.
34 #include <casacore/casa/aips.h>
35 #include <casacore/casa/Arrays/ArrayBase.h>
36 #include <casacore/casa/Containers/Block.h>
37 #include <casacore/casa/Utilities/CountedPtr.h>
38 #include <casacore/casa/Arrays/MaskLogiArrFwd.h>
39 #include <casacore/casa/Arrays/IPosition.h>
40 #include <casacore/casa/ostream.h>
42 #include <casacore/casa/stdvector.h>
265 void apply(T (*
function)(
const T &));
423 uInt resizePercentage = 0,
438 uInt resizePercentage = 0,
439 bool resizeIfNeeded =
True);
690 class BaseIteratorSTL
722 {
return const_cast<T*
>(
itsPos); }
725 { os << iter.
itsPos;
return os; }
774 {
return *this->
getPos(); }
776 {
return this->
getPos(); }
931 extern template class Array<Bool>;
932 extern template class Array<Char>;
933 extern template class Array<uChar>;
934 extern template class Array<Short>;
935 extern template class Array<uShort>;
936 extern template class Array<Int>;
937 extern template class Array<uInt>;
938 extern template class Array<Int64>;
939 extern template class Array<Float>;
940 extern template class Array<Double>;
941 extern template class Array<Complex>;
942 extern template class Array<DComplex>;
943 extern template class Array<String>;
948 #ifndef CASACORE_NO_AUTO_TEMPLATES
949 #include <casacore/casa/Arrays/Array.tcc>
950 #endif //# CASACORE_NO_AUTO_TEMPLATES
Array< T > diagonals(uInt firstAxis=0, Int64 diag=0) const
Get the diagonal of each matrix part in the full array.
virtual const void * getVStorage(Bool &deleteIt) const
Specify which elements to extract from an n-dimensional array.
const Array< T > * itsArray
Bool conform(const MaskedArray< T > &other) const
A 2-D Specialization of the Array class.
void freeStorage(const T *&storage, Bool deleteIt) const
If deleteIt is set, delete "storage".
ConstIteratorSTL const_iterator
vector< T > tovector() const
Iterate an Array cursor through another Array.
IPosition length_p
Used to hold the shape, increment into the underlying storage and originalLength of the array.
const ConstIteratorSTL & operator++()
A Vector of integers, for indexing into Array<T> objects.
Array< T > nonDegenerate(const IPosition &ignoreAxes) const
const value_type & reference
const_iterator begin() const
size_t capacity() const
Returns the number of elements allocated.
Array(const IPosition &shape, const T &initialValue)
Create an array of the given shape and initialize it with the initial value.
Array(const IPosition &shape, T *storage, StorageInitPolicy policy, AbstractAllocator< T > const &allocator)
Create an Array of a given shape from a pointer.
virtual void * getVStorage(Bool &deleteIt)
The following functions behave the same as the corresponding getStorage functions in the derived temp...
static bool init_anyway()
friend ostream & operator<<(ostream &os, const BaseIteratorSTL &iter)
const Array< T > operator()(const IPosition &start, const IPosition &end, const IPosition &inc) const
virtual void putVStorage(void *&storage, Bool deleteAndCopy)
StorageInitPolicy
A global enum used by some Array constructors.
IteratorSTL(Array< T > &arr)
Create the begin iterator object for an Array.
virtual void assign(const Array< T > &other)
Assign the other array to this array.
Referenced counted pointer for constant data.
void copyMatchingPart(const Array< T > &from)
This function copies the matching part of from array to this array.
Map a domain object into a range object via operator().
virtual void assignBase(const ArrayBase &other, Bool checkType=True)
Assign the source array to this array.
ConstIteratorSTL(const Array< T > &arr)
Create the begin const_iterator object for an Array.
const Array< T > operator()(const IPosition &start, const IPosition &end) const
uInt ndim() const
The dimensionality of this array.
Non-templated base class for templated Array class.
static ArrayInitPolicy defaultArrayInitPolicy()
void putStorage(T *&storage, Bool deleteAndCopy)
putStorage() is normally called after a call to getStorage() (cf).
virtual Bool ok() const
Check to see if the Array is consistent.
IteratorSTL(const T *end=0)
Create the end iterator object for an Array.
IPosition steps_p
Used to hold the step to next element in each dimension.
static void copyToContiguousStorage(T *dst, Array< T > const &src, ArrayInitPolicy policy)
Array< T > operator[](size_t i) const
Get the subset given by the i-th value of the last axis.
virtual void preTakeStorage(const IPosition &)
pre/post processing hook of takeStorage() for subclasses.
virtual void resize(const IPosition &newShape, Bool copyValues=False)
Resize the array and optionally copy the values.
virtual void resize()
Make this array a different shape.
void apply(T(*function)(const T &))
This version takes a function which takes a const T reference and returns a T.
uInt nrefs() const
The number of references the underlying storage has assigned to it.
virtual ~Array()
Frees up storage only if this array was the last reference to it.
void makeSteps()
Fill the steps and the end for a derived class.
IteratorSTL operator++(int)
A global enum used by some Array/Block constructors.
virtual void reference(const Array< T > &other)
After invocation, this array and other reference the same storage.
const Array< T > addDegenerate(uInt numAxes) const
This member function returns an Array reference with the specified number of extra axes,...
Bool conform2(const ArrayBase &other) const
Are the shapes identical?
Array< T > & operator=(const T &value)
Set every element of this array to "value".
void tovector(vector< T, U > &out) const
Create an STL vector from an Array.
ConstIteratorSTL(const T *end=0)
Create the end const_iterator object for an Array.
Allocator_private::BulkAllocator< T > * nonNewDelAllocator() const
If the current allocator is NewDelAllocator<T>, BulkAllocator for DefaultAllocator<T> is returned,...
T * data()
Get a pointer to the beginning of the array.
virtual void takeStorage(const IPosition &shape, const T *storage)
Since the pointer is const, a copy is always taken.
T * getStorage(Bool &deleteIt)
Generally use of this should be shunned, except to use a FORTRAN routine or something similar.
size_t nels_p
Number of elements in the array.
BaseIteratorSTL(const Array< T > &)
Create the begin const_iterator object for an Array.
Array< T > operator()(const Slicer &)
Get a reference to an array section using a Slicer.
const_contiter cbegin() const
std::forward_iterator_tag iterator_category
bool adjustLastAxis(const IPosition &newShape, uInt resizePercentage=0, bool resizeIfNeeded=True)
Use this method to extend or reduce the last dimension of an array.
void removeDegenerate(const IPosition &ignoreAxes)
BaseIteratorSTL(const T *end=0)
Create the end const_iterator object for an Array.
const_iterator end() const
const IPosition & shape() const
The length of each axis.
See the function begin() and end() for a detailed description of the STL iterator capability.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
const Array< T > operator()(const Slicer &) const
iterator begin()
Get the begin iterator object for any array.
Array(const IPosition &shape, ArrayInitPolicy initPolicy)
Create an array of the given shape, i.e.
bool operator==(const BaseIteratorSTL &other) const
contiter cbegin()
Get the begin iterator object for a contiguous array.
void nonDegenerate(const Array< T > &other, uInt startingAxis=0, Bool throwIfError=True)
T * end_p
The end for an STL-style iteration.
ptrdiff_t difference_type
T & operator()(const IPosition &)
Access a single element of the array.
const T & operator()(const IPosition &) const
Array< T > reform(const IPosition &shape) const
It is occasionally useful to have an array which access the same storage appear to have a different s...
virtual void takeStorage(const IPosition &shape, const T *storage, AbstractAllocator< T > const &allocator)
Since the pointer is const, a copy is always taken.
T value_type
Define the STL-style iterator functions (only forward iterator).
virtual void doNonDegenerate(const Array< T > &other, const IPosition &ignoreAxes)
Remove the degenerate axes from the Array object.
virtual void takeStorage(const IPosition &shape, T *storage, StorageInitPolicy policy, AbstractAllocator< T > const &allocator)
If policy is COPY, storage of a new copy is allocated by allocator.
ConstIteratorSTL operator++(int)
@ COPY
COPY is used when an internal copy of the storage is to be made.
std::forward_iterator_tag iterator_category
void baseMakeSteps()
Make the indexing step sizes.
void apply(const Functional< T, T > &function)
This version applies a functional.
virtual Array< T > & operator=(const Array< T > &other)
Copy the values in other to this.
void nonDegenerate(const Array< T > &other, const IPosition &ignoreAxes)
Array()
Result has dimensionality of zero, and nelements is zero.
T * begin_p
This pointer is adjusted to point to the first element of the array.
ptrdiff_t difference_type
void freeVStorage(const void *&storage, Bool deleteIt) const
this file contains all the compiler specific defines
Array(const IPosition &shape)
Create an array of the given shape, i.e.
virtual void resize(const IPosition &newShape, Bool copyValues, ArrayInitPolicy policy)
Resize the array and optionally copy the values.
Array(const IPosition &shape, const T *storage)
Create an Array of a given shape from a pointer.
const T & operator*() const
Class for masking an Array for operations on that Array.
bool operator!=(const BaseIteratorSTL &other) const
virtual void takeStorage(const IPosition &shape, T *storage, StorageInitPolicy policy=COPY)
Replace the data values with those in the pointer storage.
void increment()
Increment iterator for a non-contiguous array.
virtual void postTakeStorage()
static constexpr ArrayInitPolicy INIT
Initialize all elements in the array with the default value.
void unique()
This ensures that this array does not reference any other storage.
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
LatticeExprNode mask(const LatticeExprNode &expr)
This function returns the mask of the given expression.
Array(const IPosition &shape, T *storage, StorageInitPolicy policy=COPY)
Create an Array of a given shape from a pointer.
void removeDegenerate(uInt startingAxis=0, Bool throwIfError=True)
Remove degenerate axes from this Array object.
TableExprNode marray(const TableExprNode &array, const TableExprNode &mask)
Form a masked array.
Array< T > operator()(const IPosition &start, const IPosition &end)
Get a reference to an array section extending from start to end (inclusive).
template <class T, class U> class vector;
const value_type * pointer
virtual CountedPtr< ArrayPositionIterator > makeIterator(uInt byDim) const
Create an ArrayIterator object of the correct type.
Array(const IPosition &shape, ArrayInitPolicy initPolicy, Allocator_private::BulkAllocator< T > *allocator)
void setEndIter()
Set the end iterator.
String: the storage and methods of handling collections of characters.
void apply(T(*function)(T))
Apply the function to every element of the array.
virtual CountedPtr< ArrayBase > makeArray() const
Make an empty array of the same template type.
bool Bool
Define the standard types used by Casacore.
Array< T > addDegenerate(uInt numAxes)
Bool conform(const Array< T > &other) const
Are the shapes identical?
CountedPtr< Block< T > > data_p
Reference counted block that contains the storage.
const_contiter cend() const
ConstIteratorSTL(const IteratorSTL &iter)
Create from a non-const iterator.
static constexpr ArrayInitPolicy NO_INIT
Don't initialize elements in the array.
bool reformOrResize(const IPosition &newShape, uInt resizePercentage=0, Bool resizeIfNeeded=True)
Having an array that can be reused without requiring reallocation can be useful for large arrays.
void set(const T &value)
Set every element of the array to "value." Also could use the assignment operator which assigns an ar...
virtual CountedPtr< ArrayBase > getSection(const Slicer &) const
Get a reference to a section of an array.
const T * getStorage(Bool &deleteIt) const
Array< T > copy(ArrayInitPolicy policy=ArrayInitPolicies::NO_INIT) const
This makes a copy of the array and returns it.
Bool contiguous_p
Are the data contiguous?
Array< T > nonDegenerate(uInt startingAxis=0, Bool throwIfError=True) const
These member functions remove degenerate (ie.
const IteratorSTL & operator++()
Array(const Array< T > &other)
After construction, this and other reference the same storage.
Array(Allocator_private::AllocSpec< T > allocator)
Array< T > operator()(const IPosition &start, const IPosition &end, const IPosition &inc)
Along the ith axis, every inc[i]'th element is chosen.
Array< T > copy(ArrayInitPolicy policy, Allocator_private::BulkAllocator< T > *allocator) const
Makes a copy using the allocator.