casacore
Loading...
Searching...
No Matches
IPosition.h
Go to the documentation of this file.
1//# IPosition.h: A vector of integers, used to index into arrays.
2//# Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001,2002
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: casa-feedback@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25
26#ifndef CASA_IPOSITION_2_H
27#define CASA_IPOSITION_2_H
28
29//# Includes
30#include "ArrayFwd.h"
31
32#include <vector>
33#include <cstddef> // for ptrdiff_t
34#include <initializer_list>
35
36#include <sys/types.h>
37
38namespace casacore { //# NAMESPACE CASACORE - BEGIN
39
40//# Forward Declarations
41class AipsIO;
42class LogIO;
43
44// <summary> A Vector of integers, for indexing into Array<T> objects. </summary>
45
46// <use visibility=export>
47
48// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
49// </reviewed>
50
51//# <prerequisite>
52//# Classes you should understand before using this one.
53//# </prerequisite>
54
55// <etymology>
56// IPosition is an Index Position in an n-dimensional array.
57// </etymology>
58
59// <synopsis>
60// IPosition is "logically" a Vector<int> constrained so that its origin
61// is zero-based, and in fact that used to be the way it was implemented.
62// It was split out into a separate class to make the inheritance from
63// Arrays simpler (since Arrays use IPositions). The
64// template instantiation mechanism is complicated enough that this
65// simplification was felt to be a good idea.
66// <p>
67// IPosition objects are normally used to index into, and define the shapes
68// of, multi-dimensional arrays. For example, if you have a 5 dimensional
69// array, you need an IPosition of length 5 to index into the array (or
70// to define its shape, etc.).
71// <p>
72// Unlike Vectors, IPositions always use copy semantics.
73// <srcblock>
74// IPosition ip1(5); // An IPosition of length 5
75// ip1(0) = 11; ip1(1) = 5; ... ip1(4) = 6; // Indices 0-based
76// IPosition ip2(ip1); // Copy constructor; a COPY
77// </srcblock>
78//
79// Binary operations must take place either with a conformnat (same size)
80// IPosition or with an integer, which behaves as if it was an IPosition
81// of the same size (i.e., length). All the usual binary arithmetic
82// operations are available, as well as logical operations, which return
83// Booleans. These all operate "element-by-element".
84// <p>
85// All non-inlined member functions of IPosition check invariants if the
86// preprocessor symbol AIPS_DEBUG is defined.
87// That is, the member functions check that ok() is true (constructors
88// check after construction, other functions on entry to the function).
89// If these tests fail, an AipsError exception is thrown; its message
90// contains the line number and source file of the failure (it is thrown
91// by the lAssert macro defined in aips/Assert.h).
92//
93// Constructors and functions exist to construct an IPosition directly from
94// a Vector or std::vector object or to convert to it. Furthermore the
95// <src>fill</src> and <src>copy</src> can be used to fill from or copy to
96// any STL-type iterator.
97//
98// <example>
99// <srcblock>
100// IPosition blc(5), trc(5,1,2,3,4,5);
101// blc = 0; // OR IPosition blc(5,0);
102// //...
103// if (blc > trc) {
104// IPosition tmp;
105// tmp = trc; // Swap
106// trc = blc;
107// blc = tmp;
108// }
109// //...
110// trc += 5; // make the box 5 larger in all dimensions
111// std::vector<int> vec(trc.toStdVector());
112// </srcblock>
113// </example>
114
115
117{
119
120public:
121 // A zero-length IPosition.
122 IPosition() noexcept;
123
124 // An IPosition of size "length." The values in the object are uninitialized.
125 explicit IPosition(size_t length);
126
127 // An IPosition initialized from the given list
128 IPosition(std::initializer_list<ssize_t> list);
129
130 // An IPosition of size "length." All values in the object are
131 // initialized to val.
132 IPosition(size_t length, ssize_t val);
133
134 // An IPosition initialized from a variable number of parameters.
135 // The first parameter should specify the size, but the actual
136 // size of the resulting IPosition is determined from the number
137 // of parameters (the first argument is ignored).
138 //
139 // This constructor should be disfavoured, because i) of the
140 // dummy parameter and ii) because it may narrow the
141 // specified parameter without a warning.
142 //
143 // Instead, use an initializer list constructor whenever possible.
144 // If an IPosition is created inside a macro, an initializer list
145 // is not possible. In those cases, use the Make(Vals...) factory
146 // method. Both of those methods do not have the above issues.
147 template<typename... Vals>
148 //[[ deprecated("Use the initializer list constructor or Make() method") ]]
149 IPosition (size_t /*dummy*/, ssize_t val1, ssize_t val2, Vals... vals) :
150 IPosition{val1, val2, static_cast<ssize_t>(vals)...} { }
151
152 // Makes a copy (copy, NOT reference, semantics) of source.
153 IPosition(const IPosition& source);
154
155 IPosition(IPosition&& source) noexcept;
156
158
159 // Construct an IPosition that is initialized from a variable number of parameter.
160 // The resulting size of the IPosition will equal the number of parameters specified.
161 //
162 // In general, using the initializer list constructor should be preferred. Defining
163 // an initializer list inside macros is however not possible. In those cases, this
164 // method can be used to construct the IPosition.
165 //
166 // Example: IPosition::Make(3, 5) creates an IPosition of size 2, with values 3 and 5.
167 // It is identical to IPosition{3, 5}. A program is ill-formed when narrowing of
168 // a parameter is required, causing a compiler warning or error.
169 template<typename... Vals>
170 static IPosition Make (Vals... vals) {
171 return IPosition{vals...};
172 }
173
174 // Makes this a copy of other. When the dest is not of the same
175 // size, it will resize itself to be the same length as the source.
177
179
180 // Copy "value" into every position of this IPosition.
182
183 // Construct a default axis path consisting of the values 0 .. nrdim-1.
184 static IPosition makeAxisPath (size_t nrdim);
185
186 // Construct a full axis path from a (partially) given axis path.
187 // It fills the path with the non-given axis.
188 // It is checked if the given axis path is valid (i.e. if the axis are
189 // < nrdim and if they are not doubly defined).
190 // E.g.: in the 4D case an axis path [0,2] is returned as [0,2,1,3].
191 static IPosition makeAxisPath (size_t nrdim, const IPosition& partialPath);
192
193 // Make a list of axes which are the axes not given in <src>axes</src>
194 // up to the given dimension
195 static IPosition otherAxes (size_t nrdim, const IPosition& axes);
196
197 // Convert an IPosition to and from an Array<int/int64>. In either case, the
198 // array must be one dimensional.
199 // <group>
200 IPosition(const Array<int>& other);
204 // </group>
205
206 // Convert an IPosition to and from an Array<int/int64>. In either case, the
207 // array must be one dimensional.
208 // <group>
209 IPosition(const std::vector<int>& other);
210 IPosition(const std::vector<long long>& other);
211 std::vector<int> asStdVector() const;
212 std::vector<long long> asStdVector64() const;
213 // </group>
214
215 // Resize and fill this IPosition object.
216 template<typename InputIterator>
217 void fill (size_t size, InputIterator iter)
218 {
219 resize (size);
220 for (size_t i=0; i<size; ++i, ++iter) {
221 data_p[i] = *iter;
222 }
223 }
224
225 // Copy the contents of this IPosition object to the output iterator.
226 // The size of the output must be sufficient.
227 template<typename OutputIterator>
228 void copy (OutputIterator iter) const
229 {
230 for (size_t i=0; i<size_p; ++i, ++iter) {
231 *iter = data_p[i];
232 }
233 }
234
235
236 // This member functions return an IPosition which has
237 // degenerate (length==1) axes removed and the dimensionality reduced
238 // appropriately.
239 // Only axes greater than startingAxis are considered (normally one
240 // wants to remove trailing axes.
241 // <br>
242 // The functions with argument <src>ignoreAxes</src> do
243 // not consider the axes given in that argument.
244 // <group>
245 IPosition nonDegenerate(size_t startingAxis=0) const;
246 IPosition nonDegenerate(const IPosition& ignoreAxes) const;
247 // </group>
248
249 // Old values are copied on resize if copy==true.
250 // If the size increases, values beyond the former size are undefined.
251 void resize(size_t newSize, bool copy=true);
252
253 // Index into the IPosition. Indices are zero-based. If the preprocessor
254 // symbol AIPS_ARRAY_INDEX_CHECK is defined, operator() will check
255 // "index" to ensure it is not out of bounds. If this check fails, an
256 // AipsError will be thrown.
257 // <group>
258 ssize_t& operator[] (size_t index);
259 ssize_t operator[] (size_t index) const;
260 ssize_t& operator() (size_t index);
261 ssize_t operator() (size_t index) const;
262 // </group>
263
264 // Make an IPosition by using only the specified elements of the current
265 // IPosition. All values of <src>axes</src> must be less than
266 // the number of elements of the current object.
267 // <example>
268 // IPosition ipos(4, 11, 12, 13, 14);
269 // // ex1 is IPosition(3, 11, 12, 13);
270 // IPosition ex1 = ipos(IPosition(3,0,1,2);
271 // // ex2 is IPosition(3, 12, 11)
272 // IPosition ex2 = ipos(IPosition(2,2,1);
273 // // ex3 is IPosition(4,14,14,14,14)
274 // IPosition ex3 = ipos(IPosition(4,3,3,3,3);
275 // </example>
276 IPosition operator() (const IPosition& axes) const;
277
278 // Index into the IPosition from the end.
279 // By default the last value is returned.
280 // If the preprocessor symbol AIPS_ARRAY_INDEX_CHECK is defined, it will
281 // check if the index is not out of bounds.
282 // <group>
283 ssize_t& last (size_t index=0);
284 ssize_t last (size_t index=0) const;
285 // </group>
286
287 // Get the storage.
288 const ssize_t *storage() const;
289
290 // Append this IPosition with another one (causing a resize).
291 void append (const IPosition& other);
292
293 // Prepend this IPosition with another one (causing a resize).
294 void prepend (const IPosition& other);
295
296 // Return an IPosition as the concetanation of this and another IPosition.
297 IPosition concatenate (const IPosition& other) const;
298
299 // Set the first values of this IPosition to another IPosition.
300 // An exception is thrown if the other IPosition is too long.
301 void setFirst (const IPosition& other);
302
303 // Set the last values of this IPosition to another IPosition.
304 // An exception is thrown if the other IPosition is too long.
305 void setLast (const IPosition& other);
306
307 // Construct an IPosition from the first <src>n</src> values of this
308 // IPosition.
309 // An exception is thrown if <src>n</src> is too high.
310 IPosition getFirst (size_t n) const;
311
312 // Construct an IPosition from the last <src>n</src> values of this
313 // IPosition.
314 // An exception is thrown if <src>n</src> is too high.
315 IPosition getLast (size_t n) const;
316
317 // Return an IPosition where the given axes are reoved.
318 IPosition removeAxes (const IPosition& axes) const;
319
320 // Return an IPosition containing the given axes only.
321 IPosition keepAxes (const IPosition& axes) const;
322
323 // The number of elements in this IPosition. Since IPosition
324 // objects use zero-based indexing, the maximum available index is
325 // nelements() - 1.
326 // <group>
327 size_t nelements() const;
328 size_t size() const;
329 // </group>
330
331 // Is the IPosition empty (i.e. no elements)?
332 bool empty() const;
333
334 // conform returns true if nelements() == other.nelements().
335 bool conform(const IPosition& other) const;
336
337 // Element-by-element arithmetic.
338 // <group>
339 void operator += (const IPosition& other);
340 void operator -= (const IPosition& other);
341 void operator *= (const IPosition& other);
342 void operator /= (const IPosition& other);
343 void operator += (ssize_t val);
344 void operator -= (ssize_t val);
345 void operator *= (ssize_t val);
346 void operator /= (ssize_t val);
347 // </group>
348
349 // Returns 0 if nelements() == 0, otherwise it returns the product of
350 // its elements.
351 long long product() const;
352
353 // Are all elements equal to 1?
354 // Useful to check if a given stride is really a stride.
355 bool allOne() const;
356
357 // Element-by-element comparison for equality.
358 // It returns true if the lengths and all elements are equal.
359 // <br>
360 // Note that an important difference between this function and operator==()
361 // is that if the two IPositions have different lengths, this function
362 // returns false, instead of throwing an exception as operator==() does.
363 bool isEqual (const IPosition& other) const;
364
365 // Element-by-element comparison for equality.
366 // It returns true if all elements are equal.
367 // When <src>skipDegeneratedAxes</src> is true, axes with
368 // length 1 are skipped in both operands.
369 bool isEqual (const IPosition& other, bool skipDegeneratedAxes) const;
370
371 // Element-by-element comparison for (partial) equality.
372 // It returns true if the lengths and the first <src>nrCompare</src>
373 // elements are equal.
374 bool isEqual (const IPosition& other, size_t nrCompare) const;
375
376 // Is the other IPosition a subset of (or equal to) this IPosition?
377 // It is a subset if zero or more axes of this IPosition do not occur
378 // or are degenerated in the other and if the remaining axes are
379 // in the same order.
380 bool isSubSet (const IPosition& other) const;
381
382 // Write the IPosition into a string.
383 // TODO deprecate in favour of to_string(const IPosition&)
384 std::string toString() const;
385
386 // Write an IPosition to an ostream in a simple text form.
387 friend std::ostream& operator<<(std::ostream& os, const IPosition& ip);
388
389 // Is this IPosition consistent?
390 bool ok() const;
391
392 // Define the STL-style iterators.
393 // It makes it possible to iterate through all data elements.
394 // <srcblock>
395 // IPosition shp(2,0);
396 // for (IPosition::iterator iter=shp.begin(); iter!=shp.end(); iter++) {
397 // *iter += 1;
398 // }
399 // </srcblock>
400 // <group name=STL-iterator>
401 // STL-style typedefs.
402 // <group>
403 typedef ssize_t value_type;
404 typedef ssize_t* iterator;
405 typedef const ssize_t* const_iterator;
407 typedef const value_type* const_pointer;
410 typedef size_t size_type;
411 typedef ptrdiff_t difference_type;
412 // </group>
413 // Get the begin and end iterator object for this object.
414 // <group>
416 { return data_p; }
418 { return data_p; }
420 { return data_p + size_p; }
422 { return data_p + size_p; }
423 // </group>
424 // </group>
425
426private:
427 // Allocate a buffer with length size_p.
429
430 // Throw an index error exception.
431 void throwIndexError() const;
432
433 enum { BufferLength = 4 };
434 size_t size_p;
436 // When the iposition is length BufferSize or less data is just buffer_p,
437 // avoiding calls to new and delete.
438 ssize_t *data_p;
439};
440
441// Allows a way for IPosition to be used as keys in a std::map
443public:
444 // if sizes aren't equal, returns true if lhs.size() < rhs.size(), false
445 // otherwise. If sizes are equal, does an element by element comparison. The first
446 // corresponding elements that are not equal, returns true if the rhs element is
447 // less than the lhs element, false otherwise. Returns false if all elements are
448 // equal.
449 bool operator()(const IPosition& lhs, const IPosition& rhs) const;
450};
451
452// <summary>Arithmetic Operations for IPosition's</summary>
453// Element by element arithmetic on IPositions.
454// <group name="IPosition Arithmetic">
455// Each operation is done on corresponding elements of the IPositions. The
456// two IPositions must have the same number of elements otherwise an
457// exception (ArrayConformanceError) will be thrown.
458// <group>
459IPosition operator + (const IPosition& left, const IPosition& right);
460IPosition operator - (const IPosition& left, const IPosition& right);
461IPosition operator * (const IPosition& left, const IPosition& right);
462IPosition operator / (const IPosition& left, const IPosition& right);
463// </group>
464// Each operation is done by appliying the integer argument to all elements
465// of the IPosition argument.
466// <group>
467IPosition operator + (const IPosition& left, ssize_t val);
468IPosition operator - (const IPosition& left, ssize_t val);
469IPosition operator * (const IPosition& left, ssize_t val);
470IPosition operator / (const IPosition& left, ssize_t val);
471// </group>
472// Same functions as above but with with the int argument on the left side.
473// <group>
474IPosition operator + (ssize_t val, const IPosition& right);
475IPosition operator - (ssize_t val, const IPosition& right);
476IPosition operator * (ssize_t val, const IPosition& right);
477IPosition operator / (ssize_t val, const IPosition& right);
478// </group>
479
480// Returns the element by element minimum or maximum.
481// <group>
482IPosition max (const IPosition& left, const IPosition& right);
483IPosition min (const IPosition& left, const IPosition& right);
484// </group>
485// </group>
486
487// <summary>Logical operations for IPosition's</summary>
488// Element by element boolean operations on IPositions. The result is true
489// only if the operation yields true for every element of the IPosition.
490// <group name="IPosition Logical">
491// Each operation is done on corresponding elements of the IPositions. The
492// two IPositions must have the same number of elements otherwise an
493// exception (ArrayConformanceError) will be thrown.
494// <group>
495bool operator == (const IPosition& left, const IPosition& right);
496bool operator != (const IPosition& left, const IPosition& right);
497bool operator < (const IPosition& left, const IPosition& right);
498bool operator <= (const IPosition& left, const IPosition& right);
499bool operator > (const IPosition& left, const IPosition& right);
500bool operator >= (const IPosition& left, const IPosition& right);
501// </group>
502// Each operation is done by appliying the integer argument to all elements
503// <group>
504bool operator == (const IPosition& left, ssize_t val);
505bool operator != (const IPosition& left, ssize_t val);
506bool operator < (const IPosition& left, ssize_t val);
507bool operator <= (const IPosition& left, ssize_t val);
508bool operator > (const IPosition& left, ssize_t val);
509bool operator >= (const IPosition& left, ssize_t val);
510// </group>
511// Same functions as above but with with the int argument on the left side.
512// <group>
513bool operator == (ssize_t val, const IPosition& right);
514bool operator != (ssize_t val, const IPosition& right);
515bool operator < (ssize_t val, const IPosition& right);
516bool operator <= (ssize_t val, const IPosition& right);
517bool operator > (ssize_t val, const IPosition& right);
518bool operator >= (ssize_t val, const IPosition& right);
519// </group>
520// </group>
521
522// <summary>Indexing functions for IPosition's</summary>
523// Convert between IPosition and offset in an array.
524//
525// The offset of an element in an array is the number of elements from the
526// origin that the element would be if the array were arranged linearly.
527// The origin of the array has an offset equal to 0, while the
528// "top right corner" of the array has an offset equal to one less than the
529// total number of elements in the array.
530//
531// Two examples of offset would be the index in a carray and the seek position
532// in a file.
533
534// <group name="IPosition Indexing">
535// Convert from offset to IPosition in an array.
536IPosition toIPositionInArray (long long offset, const IPosition& shape);
538// Convert from IPosition to offset in an array.
539long long toOffsetInArray (const IPosition& iposition, const IPosition& shape);
540
541// Determine if the given offset or IPosition is inside the array. Returns
542// true if it is inside the Array.
543// <thrown>
544// <li> ArrayConformanceError: If all the IPositions are not the same length
545// </thrown>
546// <group>
547bool isInsideArray (const long long offset, const IPosition& shape);
548bool isInsideArray (const IPosition& iposition, const IPosition& shape);
549// </group>
550// </group>
551
552std::string to_string(const IPosition& ip);
553
554//# Inlined member functions for IPosition
555
556inline IPosition::IPosition() noexcept
557: size_p (0),
558 data_p (buffer_p)
559{}
560
562{
563 return makeAxisPath (nrdim, IPosition());
564}
565
566inline size_t IPosition::nelements() const
567{
568 return size_p;
569}
570inline size_t IPosition::size() const
571{
572 return size_p;
573}
574inline bool IPosition::empty() const
575{
576 return size_p == 0;
577}
578
579inline ssize_t& IPosition::operator[](size_t index)
580{
581 return data_p[index];
582}
583
584inline ssize_t IPosition::operator[](size_t index) const
585{
586 return data_p[index];
587}
588
589inline ssize_t& IPosition::operator()(size_t index)
590{
591#if defined(AIPS_ARRAY_INDEX_CHECK)
592 if (index >= nelements()) {
594 }
595#endif
596 return data_p[index];
597}
598
599inline ssize_t IPosition::operator()(size_t index) const
600{
601#if defined(AIPS_ARRAY_INDEX_CHECK)
602 if (index >= nelements()) {
604 }
605#endif
606 return data_p[index];
607}
608
609inline ssize_t& IPosition::last (size_t index)
610{
611#if defined(AIPS_ARRAY_INDEX_CHECK)
612 if (size_p - index <= 0) {
614 }
615#endif
616 return data_p[size_p-index-1];
617}
618
619inline ssize_t IPosition::last (size_t index) const
620{
621#if defined(AIPS_ARRAY_INDEX_CHECK)
622 if (size_p - index <= 0) {
624 }
625#endif
626 return data_p[size_p-index-1];
627}
628
629inline const ssize_t *IPosition::storage() const
630{
631 return data_p;
632}
633
634inline bool IPosition::conform(const IPosition& other) const
635{
636 return (size_p == other.size_p);
637}
638
639} //# NAMESPACE CASACORE - END
640
641#endif
Allows a way for IPosition to be used as keys in a std::map.
Definition IPosition.h:442
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.
Definition IPosition.h:579
ptrdiff_t difference_type
Definition IPosition.h:411
void operator*=(const IPosition &other)
friend std::ostream & operator<<(std::ostream &os, const IPosition &ip)
Write an IPosition to an ostream in a simple text form.
const value_type * const_pointer
Definition IPosition.h:407
IPosition(const Array< long long > &other)
bool isEqual(const IPosition &other, size_t nrCompare) const
Element-by-element comparison for (partial) equality.
size_t size() const
Definition IPosition.h:570
IPosition & operator=(IPosition &&source)
IPosition(const Array< int > &other)
Convert an IPosition to and from an Array<int/int64>.
ssize_t & operator()(size_t index)
Definition IPosition.h:589
const_iterator end() const
Definition IPosition.h:421
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.
Definition IPosition.h:403
std::vector< long long > asStdVector64() const
void copy(OutputIterator iter) const
Copy the contents of this IPosition object to the output iterator.
Definition IPosition.h:228
void setLast(const IPosition &other)
Set the last values of this IPosition to another IPosition.
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.
IPosition & operator=(ssize_t value)
Copy "value" into every position of this IPosition.
void operator+=(const IPosition &other)
Element-by-element arithmetic.
IPosition() noexcept
A zero-length IPosition.
Definition IPosition.h:556
Vector< long long > asVector64() const
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.
Definition IPosition.h:561
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.
Definition IPosition.h:566
IPosition(const std::vector< long long > &other)
bool empty() const
Is the IPosition empty (i.e.
Definition IPosition.h:574
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.
std::vector< int > asStdVector() const
value_type * pointer
Definition IPosition.h:406
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.
Definition IPosition.h:415
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...
Definition IPosition.h:438
static IPosition Make(Vals... vals)
Construct an IPosition that is initialized from a variable number of parameter.
Definition IPosition.h:170
const ssize_t * storage() const
Get the storage.
Definition IPosition.h:629
bool conform(const IPosition &other) const
conform returns true if nelements() == other.nelements().
Definition IPosition.h:634
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).
IPosition & operator=(const IPosition &source)
Makes this a copy of other.
const_iterator begin() const
Definition IPosition.h:417
ssize_t & last(size_t index=0)
Index into the IPosition from the end.
Definition IPosition.h:609
ssize_t buffer_p[BufferLength]
Definition IPosition.h:435
const value_type & const_reference
Definition IPosition.h:409
void fill(size_t size, InputIterator iter)
Resize and fill this IPosition object.
Definition IPosition.h:217
void operator/=(const IPosition &other)
value_type & reference
Definition IPosition.h:408
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
Definition IPosition.h:405
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 ...
void setFirst(const IPosition &other)
Set the first values of this IPosition to another IPosition.
this file contains all the compiler specific defines
Definition mainpage.dox:28
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.
Definition ExprNode.h:1991
bool operator==(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
Definition Allocator.h:127
bool operator!=(const casacore_allocator< T, ALIGNMENT > &, const casacore_allocator< T, ALIGNMENT > &)
Definition Allocator.h:133
LatticeExprNode operator/(const LatticeExprNode &left, const LatticeExprNode &right)
std::string to_string(const IPosition &ip)
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
Define real & complex conjugation for non-complex types and put comparisons into std namespace.
Definition Complex.h:350
Arithmetic Operations for IPosition's Element by element arithmetic on IPositions.
Definition IPosition.h:456
IPosition operator/(const IPosition &left, const IPosition &right)
IPosition operator-(const IPosition &left, const IPosition &right)
IPosition operator*(const IPosition &left, const IPosition &right)
IPosition operator+(const IPosition &left, const IPosition &right)
Each operation is done on corresponding elements of the IPositions.
IPosition min(const IPosition &left, const IPosition &right)
IPosition max(const IPosition &left, const IPosition &right)
Returns the element by element minimum or maximum.
Indexing functions for IPosition's Convert between IPosition and offset in an array.
Definition IPosition.h:535
IPosition toIPositionInArray(long long offset, const IPosition &shape)
Convert from offset to IPosition in an array.
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)
Logical operations for IPosition's Element by element boolean operations on IPositions.
Definition IPosition.h:492
bool operator!=(const IPosition &left, const IPosition &right)
bool operator==(const IPosition &left, const IPosition &right)
Each operation is done on corresponding elements of the IPositions.