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>
262 void apply(T (*
function)(T));
265 void apply(T (*
function)(
const T &));
376 void tovector(vector<T, U> &out)
const;
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.
Specify which elements to extract from an n-dimensional array.
const Array< T > * itsArray
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.
const_iterator begin() const
size_t capacity() const
Returns the number of elements allocated.
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)
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.
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()
Make this array a different shape.
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?
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.
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.
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.
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.
const typedef T * const_contiter
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
iterator begin()
Get the begin iterator object for any array.
const typedef value_type & reference
bool operator==(const BaseIteratorSTL &other) const
contiter cbegin()
Get the begin iterator object for a contiguous array.
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.
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...
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.
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.
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.
const typedef value_type * pointer
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
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.
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.
template <class T, class U> class vector;
virtual CountedPtr< ArrayPositionIterator > makeIterator(uInt byDim) const
Create an ArrayIterator object of the correct type.
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.
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++()