28 #ifndef CASA_IPOSITION_2_H
29 #define CASA_IPOSITION_2_H
36 #include <initializer_list>
38 #include <sys/types.h>
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>
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) {
285 ssize_t&
last (
size_t index=0);
286 ssize_t
last (
size_t index=0)
const;
290 const ssize_t *
storage()
const;
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) {
Allows a way for IPosition to be used as keys in a std::map.
bool operator()(const IPosition &lhs, const IPosition &rhs) const
if sizes aren't equal, returns true if lhs.size() < rhs.size(), false otherwise.
ssize_t & operator[](size_t index)
Index into the IPosition.
ptrdiff_t difference_type
void operator*=(const IPosition &other)
const value_type * const_pointer
std::vector< int > asStdVector() const
IPosition & operator=(IPosition &&source)
IPosition(const Array< long long > &other)
bool isEqual(const IPosition &other, size_t nrCompare) const
Element-by-element comparison for (partial) equality.
IPosition(const Array< int > &other)
Convert an IPosition to and from an Array<int/int64>.
ssize_t & operator()(size_t index)
const_iterator end() const
IPosition nonDegenerate(const IPosition &ignoreAxes) const
IPosition keepAxes(const IPosition &axes) const
Return an IPosition containing the given axes only.
ssize_t value_type
Define the STL-style iterators.
void copy(OutputIterator iter) const
Copy the contents of this IPosition object to the output iterator.
void setLast(const IPosition &other)
Set the last values of this IPosition to another IPosition.
IPosition & operator=(const IPosition &source)
Makes this a copy of other.
std::vector< long long > asStdVector64() const
long long product() const
Returns 0 if nelements() == 0, otherwise it returns the product of its elements.
void operator-=(const IPosition &other)
IPosition getFirst(size_t n) const
Construct an IPosition from the first n values of this IPosition.
IPosition removeAxes(const IPosition &axes) const
Return an IPosition where the given axes are reoved.
void operator+=(const IPosition &other)
Element-by-element arithmetic.
IPosition() noexcept
A zero-length IPosition.
IPosition(IPosition &&source) noexcept
void resize(size_t newSize, bool copy=true)
Old values are copied on resize if copy==true.
std::string toString() const
Write the IPosition into a string.
bool isEqual(const IPosition &other) const
Element-by-element comparison for equality.
bool ok() const
Is this IPosition consistent?
IPosition(const IPosition &source)
Makes a copy (copy, NOT reference, semantics) of source.
void prepend(const IPosition &other)
Prepend this IPosition with another one (causing a resize).
bool isEqual(const IPosition &other, bool skipDegeneratedAxes) const
Element-by-element comparison for equality.
static IPosition makeAxisPath(size_t nrdim)
Construct a default axis path consisting of the values 0.
IPosition nonDegenerate(size_t startingAxis=0) const
This member functions return an IPosition which has degenerate (length==1) axes removed and the dimen...
size_t nelements() const
The number of elements in this IPosition.
IPosition(const std::vector< long long > &other)
friend std::ostream & operator<<(std::ostream &os, const IPosition &ip)
Write an IPosition to an ostream in a simple text form.
bool empty() const
Is the IPosition empty (i.e.
static IPosition makeAxisPath(size_t nrdim, const IPosition &partialPath)
Construct a full axis path from a (partially) given axis path.
bool allOne() const
Are all elements equal to 1? Useful to check if a given stride is really a stride.
IPosition concatenate(const IPosition &other) const
Return an IPosition as the concetanation of this and another IPosition.
iterator begin()
Get the begin and end iterator object for this object.
Vector< int > asVector() const
void allocateBuffer()
Allocate a buffer with length size_p.
ssize_t * data_p
When the iposition is length BufferSize or less data is just buffer_p, avoiding calls to new and dele...
static IPosition Make(Vals... vals)
Construct an IPosition that is initialized from a variable number of parameter.
const ssize_t * storage() const
Get the storage.
bool conform(const IPosition &other) const
conform returns true if nelements() == other.nelements().
IPosition getLast(size_t n) const
Construct an IPosition from the last n values of this IPosition.
void append(const IPosition &other)
Append this IPosition with another one (causing a resize).
const_iterator begin() const
ssize_t & last(size_t index=0)
Index into the IPosition from the end.
ssize_t buffer_p[BufferLength]
const value_type & const_reference
void fill(size_t size, InputIterator iter)
Resize and fill this IPosition object.
void operator/=(const IPosition &other)
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.
IPosition(const std::vector< int > &other)
Convert an IPosition to and from an Array<int/int64>.
void throwIndexError() const
Throw an index error exception.
const ssize_t * const_iterator
IPosition & operator=(ssize_t value)
Copy "value" into every position of this IPosition.
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 ...
Vector< long long > asVector64() const
void setFirst(const IPosition &other)
Set the first values of this IPosition to another IPosition.
this file contains all the compiler specific defines
LatticeExprNode operator>(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode operator+(const LatticeExprNode &expr)
Global functions operating on a LatticeExprNode.
MVBaseline operator*(const RotMatrix &left, const MVBaseline &right)
Rotate a Baseline vector with rotation matrix and other multiplications.
LatticeExprNode operator-(const LatticeExprNode &expr)
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
bool operator==(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
bool operator!=(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
LatticeExprNode operator/(const LatticeExprNode &left, const LatticeExprNode &right)
std::string to_string(const IPosition &ip)
LatticeExprNode operator<(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
LatticeExprNode operator>=(const LatticeExprNode &left, const LatticeExprNode &right)
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
LatticeExprNode operator<=(const LatticeExprNode &left, const LatticeExprNode &right)
Define real & complex conjugation for non-complex types and put comparisons into std namespace.
IPosition min(const IPosition &left, const IPosition &right)
IPosition max(const IPosition &left, const IPosition &right)
Returns the element by element minimum or maximum.
long long toOffsetInArray(const IPosition &iposition, const IPosition &shape)
Convert from IPosition to offset in an array.
bool isInsideArray(const long long offset, const IPosition &shape)
Determine if the given offset or IPosition is inside the array.
bool isInsideArray(const IPosition &iposition, const IPosition &shape)