28 #ifndef CASA_IPOSITION_2_H
29 #define CASA_IPOSITION_2_H
36 #include <initializer_list>
38 #include <sys/types.h>
130 IPosition(std::initializer_list<ssize_t> list);
149 template<typename... Vals>
151 IPosition (
size_t , ssize_t val1, ssize_t val2, Vals... vals) :
152 IPosition{val1, val2,
static_cast<ssize_t
>(vals)...} { }
171 template<
typename... Vals>
172 static IPosition
Make (Vals... vals) {
173 return IPosition{vals...};
178 IPosition&
operator=(
const IPosition& source);
180 IPosition&
operator=(IPosition&& source);
193 static IPosition
makeAxisPath (
size_t nrdim,
const IPosition& partialPath);
197 static IPosition
otherAxes (
size_t nrdim,
const IPosition& axes);
211 IPosition(
const std::vector<int>& other);
212 IPosition(
const std::vector<long long>& other);
218 template<
typename InputIterator>
222 for (
size_t i=0; i<
size; ++i, ++iter) {
229 template<
typename OutputIterator>
230 void copy (OutputIterator iter)
const
232 for (
size_t i=0; i<
size_p; ++i, ++iter) {
278 IPosition
operator() (
const IPosition& axes)
const;
285 ssize_t&
last (
size_t index=0);
286 ssize_t
last (
size_t index=0)
const;
290 const ssize_t *
storage()
const;
293 void append (
const IPosition& other);
296 void prepend (
const IPosition& other);
299 IPosition
concatenate (
const IPosition& other)
const;
303 void setFirst (
const IPosition& other);
307 void setLast (
const IPosition& other);
312 IPosition
getFirst (
size_t n)
const;
317 IPosition
getLast (
size_t n)
const;
320 IPosition
removeAxes (
const IPosition& axes)
const;
323 IPosition
keepAxes (
const IPosition& axes)
const;
337 bool conform(
const IPosition& other)
const;
365 bool isEqual (
const IPosition& other)
const;
371 bool isEqual (
const IPosition& other,
bool skipDegeneratedAxes)
const;
376 bool isEqual (
const IPosition& other,
size_t nrCompare)
const;
382 bool isSubSet (
const IPosition& other)
const;
389 friend std::ostream&
operator<<(std::ostream& os,
const IPosition& ip);
423 const_iterator
end()
const
549 bool isInsideArray (
const long long offset,
const IPosition&
shape);
593 #if defined(AIPS_ARRAY_INDEX_CHECK)
603 #if defined(AIPS_ARRAY_INDEX_CHECK)
613 #if defined(AIPS_ARRAY_INDEX_CHECK)
614 if (
size_p - index <= 0) {
623 #if defined(AIPS_ARRAY_INDEX_CHECK)
624 if (
size_p - index <= 0) {
std::string toString() const
Write the IPosition into a string.
A Vector of integers, for indexing into Array<T> objects.
IPosition keepAxes(const IPosition &axes) const
Return an IPosition containing the given axes only.
A 1-D Specialization of the Array class.
void fill(size_t size, InputIterator iter)
Resize and fill this IPosition object.
iterator begin()
Get the begin and end iterator object for this object.
ssize_t * data_p
When the iposition is length BufferSize or less data is just buffer_p, avoiding calls to new and dele...
ssize_t buffer_p[BufferLength]
LatticeExprNode operator/(const LatticeExprNode &left, const LatticeExprNode &right)
bool conform(const IPosition &other) const
conform returns true if nelements() == other.nelements().
bool ok() const
Is this IPosition consistent?
IPosition concatenate(const IPosition &other) const
Return an IPosition as the concetanation of this and another IPosition.
IPosition getFirst(size_t n) const
Construct an IPosition from the first n values of this IPosition.
Vector< long long > asVector64() const
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
void throwIndexError() const
Throw an index error exception.
ssize_t & operator()(size_t index)
static IPosition Make(Vals...vals)
Construct an IPosition that is initialized from a variable number of parameter.
void operator+=(const IPosition &other)
Element-by-element arithmetic.
bool operator==(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
const value_type * const_pointer
const_iterator begin() const
void append(const IPosition &other)
Append this IPosition with another one (causing a resize).
IPosition nonDegenerate(size_t startingAxis=0) const
This member functions return an IPosition which has degenerate (length==1) axes removed and the dimen...
void operator-=(const IPosition &other)
LatticeExprNode operator>=(const LatticeExprNode &left, const LatticeExprNode &right)
bool isEqual(const IPosition &other) const
Element-by-element comparison for equality.
const_iterator end() const
void setFirst(const IPosition &other)
Set the first values of this IPosition to another IPosition.
long long product() const
Returns 0 if nelements() == 0, otherwise it returns the product of its elements.
ssize_t & last(size_t index=0)
Index into the IPosition from the end.
Vector< int > asVector() const
IPosition removeAxes(const IPosition &axes) const
Return an IPosition where the given axes are reoved.
const ssize_t * storage() const
Get the storage.
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
ssize_t value_type
Define the STL-style iterators.
void allocateBuffer()
Allocate a buffer with length size_p.
IPosition & operator=(const IPosition &source)
Makes this a copy of other.
void operator*=(const IPosition &other)
void operator/=(const IPosition &other)
static IPosition makeAxisPath(size_t nrdim)
Construct a default axis path consisting of the values 0.
void copy(OutputIterator iter) const
Copy the contents of this IPosition object to the output iterator.
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
friend std::ostream & operator<<(std::ostream &os, const IPosition &ip)
Write an IPosition to an ostream in a simple text form.
LatticeExprNode operator<=(const LatticeExprNode &left, const LatticeExprNode &right)
IPosition getLast(size_t n) const
Construct an IPosition from the last n values of this IPosition.
std::string to_string(const IPosition &ip)
size_t nelements() const
The number of elements in this IPosition.
std::vector< int > asStdVector() const
IPosition() noexcept
A zero-length IPosition.
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
A templated N-D Array class with zero origin. Array<T, Alloc> is a templated, N-dimensional, Array class. The origin is zero, but by default indices are zero-based. This Array class is the base class for the Vector, Matrix, and Cube subclasses.
LatticeExprNode operator>(const LatticeExprNode &left, const LatticeExprNode &right)
ptrdiff_t difference_type
ssize_t & operator[](size_t index)
Index into the IPosition.
std::vector< long long > asStdVector64() const
bool allOne() const
Are all elements equal to 1? Useful to check if a given stride is really a stride.
LatticeExprNode operator+(const LatticeExprNode &expr)
Global functions operating on a LatticeExprNode.
void resize(size_t newSize, bool copy=true)
Old values are copied on resize if copy==true.
bool empty() const
Is the IPosition empty (i.e.
void prepend(const IPosition &other)
Prepend this IPosition with another one (causing a resize).
LatticeExprNode operator-(const LatticeExprNode &expr)
const value_type & const_reference
LatticeExprNode operator<(const LatticeExprNode &left, const LatticeExprNode &right)
const ssize_t * const_iterator
Allows a way for IPosition to be used as keys in a std::map.
static IPosition otherAxes(size_t nrdim, const IPosition &axes)
Make a list of axes which are the axes not given in axes up to the given dimension.
bool isSubSet(const IPosition &other) const
Is the other IPosition a subset of (or equal to) this IPosition? It is a subset if zero or more axes ...
bool operator!=(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
void setLast(const IPosition &other)
Set the last values of this IPosition to another IPosition.
MVBaseline operator*(const RotMatrix &left, const MVBaseline &right)
Rotate a Baseline vector with rotation matrix and other multiplications.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.