casacore
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: aips2-request@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 //# $Id$
27 
28 #ifndef CASA_IPOSITION_H
29 #define CASA_IPOSITION_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/iosfwd.h>
34 #include <casacore/casa/BasicSL/String.h>
35 #include <vector>
36 #include <cstddef> // for ptrdiff_t
37 #include <sys/types.h>
38 
39 namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 
41 //# Forward Declarations
42 class AipsIO;
43 class LogIO;
44 template<class T> class Array;
45 template<class T> class Vector;
46 
47 // <summary> A Vector of integers, for indexing into Array<T> objects. </summary>
48 
49 // <use visibility=export>
50 
51 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
52 // </reviewed>
53 
54 //# <prerequisite>
55 //# Classes you should understand before using this one.
56 //# </prerequisite>
57 
58 // <etymology>
59 // IPosition is an Index Position in an n-dimensional array.
60 // </etymology>
61 
62 // <synopsis>
63 // IPosition is "logically" a Vector<Int> constrained so that its origin
64 // is zero-based, and in fact that used to be the way it was implemented.
65 // It was split out into a separate class to make the inheritance from
66 // Arrays simpler (since Arrays use IPositions). The
67 // template instantiation mechanism is complicated enough that this
68 // simplification was felt to be a good idea.
69 // <p>
70 // IPosition objects are normally used to index into, and define the shapes
71 // of, multi-dimensional arrays. For example, if you have a 5 dimensional
72 // array, you need an IPosition of length 5 to index into the array (or
73 // to define its shape, etc.).
74 // <p>
75 // Unlike Vectors, IPositions always use copy semantics.
76 // <srcblock>
77 // IPosition ip1(5); // An IPosition of length 5
78 // ip1(0) = 11; ip1(1) = 5; ... ip1(4) = 6; // Indices 0-based
79 // IPosition ip2(ip1); // Copy constructor; a COPY
80 // </srcblock>
81 //
82 // Binary operations must take place either with a conformnat (same size)
83 // IPosition or with an integer, which behaves as if it was an IPosition
84 // of the same size (i.e., length). All the usual binary arithmetic
85 // operations are available, as well as logical operations, which return
86 // Booleans. These all operate "element-by-element".
87 // <p>
88 // All non-inlined member functions of IPosition check invariants if the
89 // preprocessor symbol AIPS_DEBUG is defined.
90 // That is, the member functions check that ok() is true (constructors
91 // check after construction, other functions on entry to the function).
92 // If these tests fail, an AipsError exception is thrown; its message
93 // contains the line number and source file of the failure (it is thrown
94 // by the lAssert macro defined in aips/Assert.h).
95 //
96 // Constructors and functions exist to construct an IPosition directly from
97 // a Vector or std::vector object or to convert to it. Furthermore the
98 // <src>fill</src> and <src>copy</src> can be used to fill from or copy to
99 // any STL-type iterator.
100 //
101 // <example>
102 // <srcblock>
103 // IPosition blc(5), trc(5,1,2,3,4,5);
104 // blc = 0; // OR IPosition blc(5,0);
105 // //...
106 // if (blc > trc) {
107 // IPosition tmp;
108 // tmp = trc; // Swap
109 // trc = blc;
110 // blc = tmp;
111 // }
112 // //...
113 // trc += 5; // make the box 5 larger in all dimensions
114 // std::vector<Int> vec(trc.toStdVector());
115 // </srcblock>
116 // </example>
117 
118 
120 {
121 public:
122  enum {MIN_INT = -2147483647};
123  // A zero-length IPosition.
124  IPosition();
125 
126  // An IPosition of size "length." The values in the object are undefined.
127  explicit IPosition(uInt length);
128 
129  // An IPosition of size "length." The values in the object get
130  // initialized to val.
131  IPosition(uInt length, ssize_t val);
132 
133  // An IPosition of size "length" with defined values. You need to supply
134  // a value for each element of the IPosition (up to 10). [Unfortunately
135  // varargs might not be sufficiently portable.]
136  IPosition (uInt length, ssize_t val0, ssize_t val1, ssize_t val2=MIN_INT,
137  ssize_t val3=MIN_INT, ssize_t val4=MIN_INT, ssize_t val5=MIN_INT,
138  ssize_t val6=MIN_INT, ssize_t val7=MIN_INT, ssize_t val8=MIN_INT,
139  ssize_t val9=MIN_INT);
140 
141  // Makes a copy (copy, NOT reference, semantics) of other.
142  IPosition(const IPosition& other);
143 
144  ~IPosition();
145 
146  // Makes this a copy of other. "this" and "other" must either be conformant
147  // (same size) or this must be 0-length, in which case it will
148  // resize itself to be the same length as other.
149  IPosition& operator=(const IPosition& other);
150 
151  // Copy "value" into every position of this IPosition.
152  IPosition& operator=(ssize_t value);
153 
154  // Construct a default axis path consisting of the values 0 .. nrdim-1.
155  static IPosition makeAxisPath (uInt nrdim);
156 
157  // Construct a full axis path from a (partially) given axis path.
158  // It fills the path with the non-given axis.
159  // It is checked if the given axis path is valid (i.e. if the axis are
160  // < nrdim and if they are not doubly defined).
161  // E.g.: in the 4D case an axis path [0,2] is returned as [0,2,1,3].
162  static IPosition makeAxisPath (uInt nrdim, const IPosition& partialPath);
163 
164  // Make a list of axes which are the axes not given in <src>axes</src>
165  // up to the given dimension
166  static IPosition otherAxes (uInt nrdim, const IPosition& axes);
167 
168  // Convert an IPosition to and from an Array<Int>. In either case, the
169  // array must be one dimensional.
170  // <group>
171  IPosition(const Array<Int>& other);
172  Vector<Int> asVector() const;
173  // </group>
174 
175  // Convert an IPosition to and from an Array<Int>. In either case, the
176  // array must be one dimensional.
177  // <group>
178  IPosition(const std::vector<Int>& other);
179  std::vector<Int> asStdVector() const;
180  // </group>
181 
182  // Resize and fill this IPosition object.
183  template<typename InputIterator>
184  void fill (uInt size, InputIterator iter)
185  {
186  resize (size);
187  for (uInt i=0; i<size; ++i, ++iter) {
188  data_p[i] = *iter;
189  }
190  }
191 
192  // Copy the contents of this IPosition object to the output iterator.
193  // The size of the output must be sufficient.
194  template<typename OutputIterator>
195  void copy (OutputIterator iter) const
196  {
197  for (uInt i=0; i<size_p; ++i, ++iter) {
198  *iter = data_p[i];
199  }
200  }
201 
202 
203  // This member functions return an IPosition which has
204  // degenerate (length==1) axes removed and the dimensionality reduced
205  // appropriately.
206  // Only axes greater than startingAxis are considered (normally one
207  // wants to remove trailing axes.
208  // <br>
209  // The functions with argument <src>ignoreAxes</src> do
210  // not consider the axes given in that argument.
211  // <group>
212  IPosition nonDegenerate(uInt startingAxis=0) const;
213  IPosition nonDegenerate(const IPosition& ignoreAxes) const;
214  // </group>
215 
216  // Old values are copied on resize if copy==True.
217  // If the size increases, values beyond the former size are undefined.
218  void resize(uInt newSize, Bool copy=True);
219 
220  // Index into the IPosition. Indices are zero-based. If the preprocessor
221  // symbol AIPS_ARRAY_INDEX_CHECK is defined, operator() will check
222  // "index" to ensure it is not out of bounds. If this check fails, an
223  // AipsError will be thrown.
224  // <group>
225  ssize_t& operator[] (uInt index);
226  ssize_t operator[] (uInt index) const;
227  ssize_t& operator() (uInt index);
228  ssize_t operator() (uInt index) const;
229  // </group>
230 
231  // Make an IPosition by using only the specified elements of the current
232  // IPosition. All values of <src>axes</src> must be less than
233  // the number of elements of the current object.
234  // <example>
235  // IPosition ipos(4, 11, 12, 13, 14);
236  // // ex1 is IPosition(3, 11, 12, 13);
237  // IPosition ex1 = ipos(IPosition(3,0,1,2);
238  // // ex2 is IPosition(3, 12, 11)
239  // IPosition ex2 = ipos(IPosition(2,2,1);
240  // // ex3 is IPosition(4,14,14,14,14)
241  // IPosition ex3 = ipos(IPosition(4,3,3,3,3);
242  // </example>
243  IPosition operator() (const IPosition& axes) const;
244 
245  // Index into the IPosition from the end.
246  // By default the last value is returned.
247  // If the preprocessor symbol AIPS_ARRAY_INDEX_CHECK is defined, it will
248  // check if the index is not out of bounds.
249  // <group>
250  ssize_t& last (uInt index=0);
251  ssize_t last (uInt index=0) const;
252  // </group>
253 
254  // Get the storage.
255  const ssize_t *storage() const;
256 
257  // Append this IPosition with another one (causing a resize).
258  void append (const IPosition& other);
259 
260  // Prepend this IPosition with another one (causing a resize).
261  void prepend (const IPosition& other);
262 
263  // Return an IPosition as the concetanation of this and another IPosition.
264  IPosition concatenate (const IPosition& other) const;
265 
266  // Set the first values of this IPosition to another IPosition.
267  // An exception is thrown if the other IPosition is too long.
268  void setFirst (const IPosition& other);
269 
270  // Set the last values of this IPosition to another IPosition.
271  // An exception is thrown if the other IPosition is too long.
272  void setLast (const IPosition& other);
273 
274  // Construct an IPosition from the first <src>n</src> values of this
275  // IPosition.
276  // An exception is thrown if <src>n</src> is too high.
277  IPosition getFirst (uInt n) const;
278 
279  // Construct an IPosition from the last <src>n</src> values of this
280  // IPosition.
281  // An exception is thrown if <src>n</src> is too high.
282  IPosition getLast (uInt n) const;
283 
284  // Return an IPosition where the given axes are reoved.
285  IPosition removeAxes (const IPosition& axes) const;
286 
287  // Return an IPosition containing the given axes only.
288  IPosition keepAxes (const IPosition& axes) const;
289 
290  // The number of elements in this IPosition. Since IPosition
291  // objects use zero-based indexing, the maximum available index is
292  // nelements() - 1.
293  // <group>
294  uInt nelements() const;
295  uInt size() const;
296  // </group>
297 
298  // Is the IPosition empty (i.e. no elements)?
299  Bool empty() const;
300 
301  // conform returns true if nelements() == other.nelements().
302  Bool conform(const IPosition& other) const;
303 
304  // Element-by-element arithmetic.
305  // <group>
306  void operator += (const IPosition& other);
307  void operator -= (const IPosition& other);
308  void operator *= (const IPosition& other);
309  void operator /= (const IPosition& other);
310  void operator += (ssize_t val);
311  void operator -= (ssize_t val);
312  void operator *= (ssize_t val);
313  void operator /= (ssize_t val);
314  // </group>
315 
316  // Returns 0 if nelements() == 0, otherwise it returns the product of
317  // its elements.
318  Int64 product() const;
319 
320  // Are all elements equal to 1?
321  // Useful to check if a given stride is really a stride.
322  Bool allOne() const;
323 
324  // Element-by-element comparison for equality.
325  // It returns True if the lengths and all elements are equal.
326  // <br>
327  // Note that an important difference between this function and operator==()
328  // is that if the two IPositions have different lengths, this function
329  // returns False, instead of throwing an exception as operator==() does.
330  Bool isEqual (const IPosition& other) const;
331 
332  // Element-by-element comparison for equality.
333  // It returns True if all elements are equal.
334  // When <src>skipDegeneratedAxes</src> is True, axes with
335  // length 1 are skipped in both operands.
336  Bool isEqual (const IPosition& other, Bool skipDegeneratedAxes) const;
337 
338  // Element-by-element comparison for (partial) equality.
339  // It returns True if the lengths and the first <src>nrCompare</src>
340  // elements are equal.
341  Bool isEqual (const IPosition& other, uInt nrCompare) const;
342 
343  // Is the other IPosition a subset of (or equal to) this IPosition?
344  // It is a subset if zero or more axes of this IPosition do not occur
345  // or are degenerated in the other and if the remaining axes are
346  // in the same order.
347  Bool isSubSet (const IPosition& other) const;
348 
349  // Write the IPosition into a String.
350  String toString() const;
351 
352  // Write an IPosition to an ostream in a simple text form.
353  friend std::ostream& operator<<(std::ostream& os, const IPosition& ip);
354 
355  // Write an IPosition to an AipsIO stream in a binary format.
356  friend AipsIO& operator<<(AipsIO& aio, const IPosition& ip);
357 
358  // Write an IPosition to a LogIO stream.
359  friend LogIO& operator<<(LogIO& io, const IPosition& ip);
360 
361  // Read an IPosition from an AipsIO stream in a binary format.
362  // Will throw an AipsError if the current IPosition Version does not match
363  // that of the one on disk.
364  friend AipsIO& operator>>(AipsIO& aio, IPosition& ip);
365 
366  // Is this IPosition consistent?
367  Bool ok() const;
368 
369  // Define the STL-style iterators.
370  // It makes it possible to iterate through all data elements.
371  // <srcblock>
372  // IPosition shp(2,0);
373  // for (IPosition::iterator iter=shp.begin(); iter!=shp.end(); iter++) {
374  // *iter += 1;
375  // }
376  // </srcblock>
377  // <group name=STL-iterator>
378  // STL-style typedefs.
379  // <group>
380  typedef ssize_t value_type;
381  typedef ssize_t* iterator;
382  typedef const ssize_t* const_iterator;
383  typedef value_type* pointer;
384  typedef const value_type* const_pointer;
385  typedef value_type& reference;
386  typedef const value_type& const_reference;
387  typedef size_t size_type;
388  typedef ptrdiff_t difference_type;
389  // </group>
390  // Get the begin and end iterator object for this object.
391  // <group>
392  iterator begin()
393  { return data_p; }
394  const_iterator begin() const
395  { return data_p; }
396  iterator end()
397  { return data_p + size_p; }
398  const_iterator end() const
399  { return data_p + size_p; }
400  // </group>
401  // </group>
402 
403 private:
404  // Allocate a buffer with length size_p.
405  void allocateBuffer();
406 
407  // Throw an index error exception.
408  void throwIndexError() const;
409 
410  enum { BufferLength = 4 };
413  // When the iposition is length BufferSize or less data is just buffer_p,
414  // avoiding calls to new and delete.
415  ssize_t *data_p;
416 };
417 
418 // <summary>Arithmetic Operations for IPosition's</summary>
419 // Element by element arithmetic on IPositions.
420 // <group name="IPosition Arithmetic">
421 // Each operation is done on corresponding elements of the IPositions. The
422 // two IPositions must have the same number of elements otherwise an
423 // exception (ArrayConformanceError) will be thrown.
424 // <group>
425 IPosition operator + (const IPosition& left, const IPosition& right);
426 IPosition operator - (const IPosition& left, const IPosition& right);
427 IPosition operator * (const IPosition& left, const IPosition& right);
428 IPosition operator / (const IPosition& left, const IPosition& right);
429 // </group>
430 // Each operation is done by appliying the integer argument to all elements
431 // of the IPosition argument.
432 // <group>
433 IPosition operator + (const IPosition& left, ssize_t val);
434 IPosition operator - (const IPosition& left, ssize_t val);
435 IPosition operator * (const IPosition& left, ssize_t val);
436 IPosition operator / (const IPosition& left, ssize_t val);
437 // </group>
438 // Same functions as above but with with the Int argument on the left side.
439 // <group>
440 IPosition operator + (ssize_t val, const IPosition& right);
441 IPosition operator - (ssize_t val, const IPosition& right);
442 IPosition operator * (ssize_t val, const IPosition& right);
443 IPosition operator / (ssize_t val, const IPosition& right);
444 // </group>
445 
446 // Returns the element by element minimum or maximum.
447 // <group>
448 IPosition max (const IPosition& left, const IPosition& right);
449 IPosition min (const IPosition& left, const IPosition& right);
450 // </group>
451 // </group>
452 
453 // <summary>Logical operations for IPosition's</summary>
454 // Element by element boolean operations on IPositions. The result is true
455 // only if the operation yields true for every element of the IPosition.
456 // <group name="IPosition Logical">
457 // Each operation is done on corresponding elements of the IPositions. The
458 // two IPositions must have the same number of elements otherwise an
459 // exception (ArrayConformanceError) will be thrown.
460 // <group>
461 Bool operator == (const IPosition& left, const IPosition& right);
462 Bool operator != (const IPosition& left, const IPosition& right);
463 Bool operator < (const IPosition& left, const IPosition& right);
464 Bool operator <= (const IPosition& left, const IPosition& right);
465 Bool operator > (const IPosition& left, const IPosition& right);
466 Bool operator >= (const IPosition& left, const IPosition& right);
467 // </group>
468 // Each operation is done by appliying the integer argument to all elements
469 // <group>
470 Bool operator == (const IPosition& left, ssize_t val);
471 Bool operator != (const IPosition& left, ssize_t val);
472 Bool operator < (const IPosition& left, ssize_t val);
473 Bool operator <= (const IPosition& left, ssize_t val);
474 Bool operator > (const IPosition& left, ssize_t val);
475 Bool operator >= (const IPosition& left, ssize_t val);
476 // </group>
477 // Same functions as above but with with the Int argument on the left side.
478 // <group>
479 Bool operator == (ssize_t val, const IPosition& right);
480 Bool operator != (ssize_t val, const IPosition& right);
481 Bool operator < (ssize_t val, const IPosition& right);
482 Bool operator <= (ssize_t val, const IPosition& right);
483 Bool operator > (ssize_t val, const IPosition& right);
484 Bool operator >= (ssize_t val, const IPosition& right);
485 // </group>
486 // </group>
487 
488 // <summary>Indexing functions for IPosition's</summary>
489 // Convert between IPosition and offset in an array.
490 //
491 // The offset of an element in an array is the number of elements from the
492 // origin that the element would be if the array were arranged linearly.
493 // The origin of the array has an offset equal to 0, while the
494 // "top right corner" of the array has an offset equal to one less than the
495 // total number of elements in the array.
496 //
497 // Two examples of offset would be the index in a carray and the seek position
498 // in a file.
499 
500 // <group name="IPosition Indexing">
501 // Convert from offset to IPosition in an array.
502 IPosition toIPositionInArray (Int64 offset, const IPosition& shape);
503 
504 // Convert from IPosition to offset in an array.
505 Int64 toOffsetInArray (const IPosition& iposition, const IPosition& shape);
506 
507 // Determine if the given offset or IPosition is inside the array. Returns
508 // True if it is inside the Array.
509 // <thrown>
510 // <li> ArrayConformanceError: If all the IPositions are not the same length
511 // </thrown>
512 // <group>
513 Bool isInsideArray (const Int64 offset, const IPosition& shape);
514 Bool isInsideArray (const IPosition& iposition, const IPosition& shape);
515 // </group>
516 // </group>
517 
518 
519 
520 //# Inlined member functions for IPosition
521 
523 : size_p (0),
524  data_p (buffer_p)
525 {}
526 
528 {
529  return makeAxisPath (nrdim, IPosition());
530 }
531 
533 {
534  return size_p;
535 }
536 inline uInt IPosition::size() const
537 {
538  return size_p;
539 }
540 inline Bool IPosition::empty() const
541 {
542  return size_p == 0;
543 }
544 
545 inline ssize_t& IPosition::operator[](uInt index)
546 {
547  return data_p[index];
548 }
549 
550 inline ssize_t IPosition::operator[](uInt index) const
551 {
552  return data_p[index];
553 }
554 
555 inline ssize_t& IPosition::operator()(uInt index)
556 {
557 #if defined(AIPS_ARRAY_INDEX_CHECK)
558  if (index >= nelements()) {
559  throwIndexError();
560  }
561 #endif
562  return data_p[index];
563 }
564 
565 inline ssize_t IPosition::operator()(uInt index) const
566 {
567 #if defined(AIPS_ARRAY_INDEX_CHECK)
568  if (index >= nelements()) {
569  throwIndexError();
570  }
571 #endif
572  return data_p[index];
573 }
574 
575 inline ssize_t& IPosition::last (uInt index)
576 {
577 #if defined(AIPS_ARRAY_INDEX_CHECK)
578  if (size_p - index <= 0) {
579  throwIndexError();
580  }
581 #endif
582  return data_p[size_p-index-1];
583 }
584 
585 inline ssize_t IPosition::last (uInt index) const
586 {
587 #if defined(AIPS_ARRAY_INDEX_CHECK)
588  if (size_p - index <= 0) {
589  throwIndexError();
590  }
591 #endif
592  return data_p[size_p-index-1];
593 }
594 
595 inline const ssize_t *IPosition::storage() const
596 {
597  return data_p;
598 }
599 
600 inline Bool IPosition::conform(const IPosition& other) const
601 {
602  return (size_p == other.size_p);
603 }
604 
605 } //# NAMESPACE CASACORE - END
606 
607 #endif
A Vector of integers, for indexing into Array<T> objects.
Definition: IPosition.h:119
IPosition getFirst(uInt n) const
Construct an IPosition from the first n values of this IPosition.
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
iterator begin()
Get the begin and end iterator object for this object.
Definition: IPosition.h:392
IPosition & operator=(const IPosition &other)
Makes this a copy of other.
Bool allOne() const
Are all elements equal to 1? Useful to check if a given stride is really a stride.
IPosition removeAxes(const IPosition &axes) const
Return an IPosition where the given axes are reoved.
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:415
ssize_t buffer_p[BufferLength]
Definition: IPosition.h:412
bool operator==(const std11_allocator< T > &, const std11_allocator< T > &)
Definition: Allocator.h:99
LatticeExprNode operator/(const LatticeExprNode &left, const LatticeExprNode &right)
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
void copy(OutputIterator iter) const
Copy the contents of this IPosition object to the output iterator.
Definition: IPosition.h:195
bool operator!=(const std11_allocator< T > &, const std11_allocator< T > &)
Definition: Allocator.h:105
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
IPosition nonDegenerate(uInt startingAxis=0) const
This member functions return an IPosition which has degenerate (length==1) axes removed and the dimen...
iterator end()
Definition: IPosition.h:396
void operator+=(const IPosition &other)
Element-by-element arithmetic.
Bool conform(const IPosition &other) const
conform returns true if nelements() == other.nelements().
Definition: IPosition.h:600
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 ...
ostream-like interface to creating log messages.
Definition: LogIO.h:167
const value_type * const_pointer
Definition: IPosition.h:384
const ssize_t * storage() const
Get the storage.
Definition: IPosition.h:595
uInt size() const
Definition: IPosition.h:536
IPosition concatenate(const IPosition &other) const
Return an IPosition as the concetanation of this and another IPosition.
uInt nelements() const
The number of elements in this IPosition.
Definition: IPosition.h:532
void append(const IPosition &other)
Append this IPosition with another one (causing a resize).
void operator-=(const IPosition &other)
LatticeExprNode operator>=(const LatticeExprNode &left, const LatticeExprNode &right)
const_iterator end() const
Definition: IPosition.h:398
std::vector< Int > asStdVector() const
void setFirst(const IPosition &other)
Set the first values of this IPosition to another IPosition.
IPosition keepAxes(const IPosition &axes) const
Return an IPosition containing the given axes only.
void throwIndexError() const
Throw an index error exception.
void fill(uInt size, InputIterator iter)
Resize and fill this IPosition object.
Definition: IPosition.h:184
IPosition()
A zero-length IPosition.
Definition: IPosition.h:522
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
ssize_t value_type
Define the STL-style iterators.
Definition: IPosition.h:380
void allocateBuffer()
Allocate a buffer with length size_p.
void operator*=(const IPosition &other)
Bool isEqual(const IPosition &other) const
Element-by-element comparison for equality.
void operator/=(const IPosition &other)
ssize_t & last(uInt index=0)
Index into the IPosition from the end.
Definition: IPosition.h:575
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.
ssize_t & operator[](uInt index)
Index into the IPosition.
Definition: IPosition.h:545
LatticeExprNode operator<=(const LatticeExprNode &left, const LatticeExprNode &right)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
IPosition getLast(uInt n) const
Construct an IPosition from the last n values of this IPosition.
Vector< Int > asVector() const
static IPosition makeAxisPath(uInt nrdim)
Construct a default axis path consisting of the values 0 .
Definition: IPosition.h:527
Bool empty() const
Is the IPosition empty (i.e.
Definition: IPosition.h:540
ssize_t & operator()(uInt index)
Definition: IPosition.h:555
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:2015
LatticeExprNode operator>(const LatticeExprNode &left, const LatticeExprNode &right)
ptrdiff_t difference_type
Definition: IPosition.h:388
ssize_t * iterator
Definition: IPosition.h:381
value_type & reference
Definition: IPosition.h:385
String toString() const
Write the IPosition into a String.
LatticeExprNode operator+(const LatticeExprNode &expr)
Global functions operating on a LatticeExprNode.
static IPosition otherAxes(uInt nrdim, const IPosition &axes)
Make a list of axes which are the axes not given in axes up to the given dimension.
const_iterator begin() const
Definition: IPosition.h:394
void prepend(const IPosition &other)
Prepend this IPosition with another one (causing a resize).
LatticeExprNode operator-(const LatticeExprNode &expr)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
const value_type & const_reference
Definition: IPosition.h:386
void resize(uInt newSize, Bool copy=True)
Old values are copied on resize if copy==True.
LatticeExprNode operator<(const LatticeExprNode &left, const LatticeExprNode &right)
const ssize_t * const_iterator
Definition: IPosition.h:382
value_type * pointer
Definition: IPosition.h:383
Bool ok() const
Is this IPosition consistent?
void setLast(const IPosition &other)
Set the last values of this IPosition to another IPosition.
Int64 product() const
Returns 0 if nelements() == 0, otherwise it returns the product of its elements.
const Bool True
Definition: aipstype.h:40
this file contains all the compiler specific defines
Definition: mainpage.dox:28
friend AipsIO & operator>>(AipsIO &aio, IPosition &ip)
Read an IPosition from an AipsIO stream in a binary format.
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.
unsigned int uInt
Definition: aipstype.h:48