casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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>
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  friend class IPositionComparator;
122 public:
123  enum {MIN_INT = -2147483647};
124  // A zero-length IPosition.
125  IPosition();
126 
127  // An IPosition of size "length." The values in the object are undefined.
128  explicit IPosition(uInt length);
129 
130  // An IPosition of size "length." The values in the object get
131  // initialized to val.
132  IPosition(uInt length, ssize_t val);
133 
134  // An IPosition of size "length" with defined values. You need to supply
135  // a value for each element of the IPosition (up to 10). [Unfortunately
136  // varargs might not be sufficiently portable.]
137  IPosition (uInt length, ssize_t val0, ssize_t val1, ssize_t val2=MIN_INT,
138  ssize_t val3=MIN_INT, ssize_t val4=MIN_INT, ssize_t val5=MIN_INT,
139  ssize_t val6=MIN_INT, ssize_t val7=MIN_INT, ssize_t val8=MIN_INT,
140  ssize_t val9=MIN_INT);
141 
142  // Makes a copy (copy, NOT reference, semantics) of other.
143  IPosition(const IPosition& other);
144 
145  ~IPosition();
146 
147  // Makes this a copy of other. "this" and "other" must either be conformant
148  // (same size) or this must be 0-length, in which case it will
149  // resize itself to be the same length as other.
150  IPosition& operator=(const IPosition& other);
151 
152  // Copy "value" into every position of this IPosition.
153  IPosition& operator=(ssize_t value);
154 
155  // Construct a default axis path consisting of the values 0 .. nrdim-1.
156  static IPosition makeAxisPath (uInt nrdim);
157 
158  // Construct a full axis path from a (partially) given axis path.
159  // It fills the path with the non-given axis.
160  // It is checked if the given axis path is valid (i.e. if the axis are
161  // < nrdim and if they are not doubly defined).
162  // E.g.: in the 4D case an axis path [0,2] is returned as [0,2,1,3].
163  static IPosition makeAxisPath (uInt nrdim, const IPosition& partialPath);
164 
165  // Make a list of axes which are the axes not given in <src>axes</src>
166  // up to the given dimension
167  static IPosition otherAxes (uInt nrdim, const IPosition& axes);
168 
169  // Convert an IPosition to and from an Array<Int>. In either case, the
170  // array must be one dimensional.
171  // <group>
172  IPosition(const Array<Int>& other);
173  Vector<Int> asVector() const;
174  // </group>
175 
176  // Convert an IPosition to and from an Array<Int>. In either case, the
177  // array must be one dimensional.
178  // <group>
179  IPosition(const std::vector<Int>& other);
180  std::vector<Int> asStdVector() const;
181  // </group>
182 
183  // Resize and fill this IPosition object.
184  template<typename InputIterator>
185  void fill (uInt size, InputIterator iter)
186  {
187  resize (size);
188  for (uInt i=0; i<size; ++i, ++iter) {
189  data_p[i] = *iter;
190  }
191  }
192 
193  // Copy the contents of this IPosition object to the output iterator.
194  // The size of the output must be sufficient.
195  template<typename OutputIterator>
196  void copy (OutputIterator iter) const
197  {
198  for (uInt i=0; i<size_p; ++i, ++iter) {
199  *iter = data_p[i];
200  }
201  }
202 
203 
204  // This member functions return an IPosition which has
205  // degenerate (length==1) axes removed and the dimensionality reduced
206  // appropriately.
207  // Only axes greater than startingAxis are considered (normally one
208  // wants to remove trailing axes.
209  // <br>
210  // The functions with argument <src>ignoreAxes</src> do
211  // not consider the axes given in that argument.
212  // <group>
213  IPosition nonDegenerate(uInt startingAxis=0) const;
214  IPosition nonDegenerate(const IPosition& ignoreAxes) const;
215  // </group>
216 
217  // Old values are copied on resize if copy==True.
218  // If the size increases, values beyond the former size are undefined.
219  void resize(uInt newSize, Bool copy=True);
220 
221  // Index into the IPosition. Indices are zero-based. If the preprocessor
222  // symbol AIPS_ARRAY_INDEX_CHECK is defined, operator() will check
223  // "index" to ensure it is not out of bounds. If this check fails, an
224  // AipsError will be thrown.
225  // <group>
226  ssize_t& operator[] (uInt index);
227  ssize_t operator[] (uInt index) const;
228  ssize_t& operator() (uInt index);
229  ssize_t operator() (uInt index) const;
230  // </group>
231 
232  // Make an IPosition by using only the specified elements of the current
233  // IPosition. All values of <src>axes</src> must be less than
234  // the number of elements of the current object.
235  // <example>
236  // IPosition ipos(4, 11, 12, 13, 14);
237  // // ex1 is IPosition(3, 11, 12, 13);
238  // IPosition ex1 = ipos(IPosition(3,0,1,2);
239  // // ex2 is IPosition(3, 12, 11)
240  // IPosition ex2 = ipos(IPosition(2,2,1);
241  // // ex3 is IPosition(4,14,14,14,14)
242  // IPosition ex3 = ipos(IPosition(4,3,3,3,3);
243  // </example>
244  IPosition operator() (const IPosition& axes) const;
245 
246  // Index into the IPosition from the end.
247  // By default the last value is returned.
248  // If the preprocessor symbol AIPS_ARRAY_INDEX_CHECK is defined, it will
249  // check if the index is not out of bounds.
250  // <group>
251  ssize_t& last (uInt index=0);
252  ssize_t last (uInt index=0) const;
253  // </group>
254 
255  // Get the storage.
256  const ssize_t *storage() const;
257 
258  // Append this IPosition with another one (causing a resize).
259  void append (const IPosition& other);
260 
261  // Prepend this IPosition with another one (causing a resize).
262  void prepend (const IPosition& other);
263 
264  // Return an IPosition as the concetanation of this and another IPosition.
265  IPosition concatenate (const IPosition& other) const;
266 
267  // Set the first values of this IPosition to another IPosition.
268  // An exception is thrown if the other IPosition is too long.
269  void setFirst (const IPosition& other);
270 
271  // Set the last values of this IPosition to another IPosition.
272  // An exception is thrown if the other IPosition is too long.
273  void setLast (const IPosition& other);
274 
275  // Construct an IPosition from the first <src>n</src> values of this
276  // IPosition.
277  // An exception is thrown if <src>n</src> is too high.
278  IPosition getFirst (uInt n) const;
279 
280  // Construct an IPosition from the last <src>n</src> values of this
281  // IPosition.
282  // An exception is thrown if <src>n</src> is too high.
283  IPosition getLast (uInt n) const;
284 
285  // Return an IPosition where the given axes are reoved.
286  IPosition removeAxes (const IPosition& axes) const;
287 
288  // Return an IPosition containing the given axes only.
289  IPosition keepAxes (const IPosition& axes) const;
290 
291  // The number of elements in this IPosition. Since IPosition
292  // objects use zero-based indexing, the maximum available index is
293  // nelements() - 1.
294  // <group>
295  uInt nelements() const;
296  uInt size() const;
297  // </group>
298 
299  // Is the IPosition empty (i.e. no elements)?
300  Bool empty() const;
301 
302  // conform returns true if nelements() == other.nelements().
303  Bool conform(const IPosition& other) const;
304 
305  // Element-by-element arithmetic.
306  // <group>
307  void operator += (const IPosition& other);
308  void operator -= (const IPosition& other);
309  void operator *= (const IPosition& other);
310  void operator /= (const IPosition& other);
311  void operator += (ssize_t val);
312  void operator -= (ssize_t val);
313  void operator *= (ssize_t val);
314  void operator /= (ssize_t val);
315  // </group>
316 
317  // Returns 0 if nelements() == 0, otherwise it returns the product of
318  // its elements.
319  Int64 product() const;
320 
321  // Are all elements equal to 1?
322  // Useful to check if a given stride is really a stride.
323  Bool allOne() const;
324 
325  // Element-by-element comparison for equality.
326  // It returns True if the lengths and all elements are equal.
327  // <br>
328  // Note that an important difference between this function and operator==()
329  // is that if the two IPositions have different lengths, this function
330  // returns False, instead of throwing an exception as operator==() does.
331  Bool isEqual (const IPosition& other) const;
332 
333  // Element-by-element comparison for equality.
334  // It returns True if all elements are equal.
335  // When <src>skipDegeneratedAxes</src> is True, axes with
336  // length 1 are skipped in both operands.
337  Bool isEqual (const IPosition& other, Bool skipDegeneratedAxes) const;
338 
339  // Element-by-element comparison for (partial) equality.
340  // It returns True if the lengths and the first <src>nrCompare</src>
341  // elements are equal.
342  Bool isEqual (const IPosition& other, uInt nrCompare) const;
343 
344  // Is the other IPosition a subset of (or equal to) this IPosition?
345  // It is a subset if zero or more axes of this IPosition do not occur
346  // or are degenerated in the other and if the remaining axes are
347  // in the same order.
348  Bool isSubSet (const IPosition& other) const;
349 
350  // Write the IPosition into a String.
351  String toString() const;
352 
353  // Write an IPosition to an ostream in a simple text form.
354  friend std::ostream& operator<<(std::ostream& os, const IPosition& ip);
355 
356  // Write an IPosition to an AipsIO stream in a binary format.
357  friend AipsIO& operator<<(AipsIO& aio, const IPosition& ip);
358 
359  // Write an IPosition to a LogIO stream.
360  friend LogIO& operator<<(LogIO& io, const IPosition& ip);
361 
362  // Read an IPosition from an AipsIO stream in a binary format.
363  // Will throw an AipsError if the current IPosition Version does not match
364  // that of the one on disk.
365  friend AipsIO& operator>>(AipsIO& aio, IPosition& ip);
366 
367  // Is this IPosition consistent?
368  Bool ok() const;
369 
370  // Define the STL-style iterators.
371  // It makes it possible to iterate through all data elements.
372  // <srcblock>
373  // IPosition shp(2,0);
374  // for (IPosition::iterator iter=shp.begin(); iter!=shp.end(); iter++) {
375  // *iter += 1;
376  // }
377  // </srcblock>
378  // <group name=STL-iterator>
379  // STL-style typedefs.
380  // <group>
381  typedef ssize_t value_type;
382  typedef ssize_t* iterator;
383  typedef const ssize_t* const_iterator;
384  typedef value_type* pointer;
385  typedef const value_type* const_pointer;
387  typedef const value_type& const_reference;
388  typedef size_t size_type;
389  typedef ptrdiff_t difference_type;
390  // </group>
391  // Get the begin and end iterator object for this object.
392  // <group>
394  { return data_p; }
396  { return data_p; }
398  { return data_p + size_p; }
400  { return data_p + size_p; }
401  // </group>
402  // </group>
403 
404 private:
405  // Allocate a buffer with length size_p.
406  void allocateBuffer();
407 
408  // Throw an index error exception.
409  void throwIndexError() const;
410 
411  enum { BufferLength = 4 };
414  // When the iposition is length BufferSize or less data is just buffer_p,
415  // avoiding calls to new and delete.
416  ssize_t *data_p;
417 };
418 
419 class IPositionComparator : public std::binary_function<IPosition, IPosition, bool> {
420  // allows a way for IPosition to be used as keys in a std::map
421 public:
422  // if sizes aren't equal, returns True if lhs.size() < rhs.size(), false
423  // otherwise. If sizes are equal, does an element by element comparison. The first
424  // corresponding elements that are not equal, returns True if the rhs element is
425  // less than the lhs element, False otherwise. Returns False if all elements are
426  // equal.
427  bool operator()(const IPosition& lhs, const IPosition& rhs) const;
428 };
429 
430 // <summary>Arithmetic Operations for IPosition's</summary>
431 // Element by element arithmetic on IPositions.
432 // <group name="IPosition Arithmetic">
433 // Each operation is done on corresponding elements of the IPositions. The
434 // two IPositions must have the same number of elements otherwise an
435 // exception (ArrayConformanceError) will be thrown.
436 // <group>
437 IPosition operator + (const IPosition& left, const IPosition& right);
438 IPosition operator - (const IPosition& left, const IPosition& right);
439 IPosition operator * (const IPosition& left, const IPosition& right);
440 IPosition operator / (const IPosition& left, const IPosition& right);
441 // </group>
442 // Each operation is done by appliying the integer argument to all elements
443 // of the IPosition argument.
444 // <group>
445 IPosition operator + (const IPosition& left, ssize_t val);
446 IPosition operator - (const IPosition& left, ssize_t val);
447 IPosition operator * (const IPosition& left, ssize_t val);
448 IPosition operator / (const IPosition& left, ssize_t val);
449 // </group>
450 // Same functions as above but with with the Int argument on the left side.
451 // <group>
452 IPosition operator + (ssize_t val, const IPosition& right);
453 IPosition operator - (ssize_t val, const IPosition& right);
454 IPosition operator * (ssize_t val, const IPosition& right);
455 IPosition operator / (ssize_t val, const IPosition& right);
456 // </group>
457 
458 // Returns the element by element minimum or maximum.
459 // <group>
460 IPosition max (const IPosition& left, const IPosition& right);
461 IPosition min (const IPosition& left, const IPosition& right);
462 // </group>
463 // </group>
464 
465 // <summary>Logical operations for IPosition's</summary>
466 // Element by element boolean operations on IPositions. The result is true
467 // only if the operation yields true for every element of the IPosition.
468 // <group name="IPosition Logical">
469 // Each operation is done on corresponding elements of the IPositions. The
470 // two IPositions must have the same number of elements otherwise an
471 // exception (ArrayConformanceError) will be thrown.
472 // <group>
473 Bool operator == (const IPosition& left, const IPosition& right);
474 Bool operator != (const IPosition& left, const IPosition& right);
475 Bool operator < (const IPosition& left, const IPosition& right);
476 Bool operator <= (const IPosition& left, const IPosition& right);
477 Bool operator > (const IPosition& left, const IPosition& right);
478 Bool operator >= (const IPosition& left, const IPosition& right);
479 // </group>
480 // Each operation is done by appliying the integer argument to all elements
481 // <group>
482 Bool operator == (const IPosition& left, ssize_t val);
483 Bool operator != (const IPosition& left, ssize_t val);
484 Bool operator < (const IPosition& left, ssize_t val);
485 Bool operator <= (const IPosition& left, ssize_t val);
486 Bool operator > (const IPosition& left, ssize_t val);
487 Bool operator >= (const IPosition& left, ssize_t val);
488 // </group>
489 // Same functions as above but with with the Int argument on the left side.
490 // <group>
491 Bool operator == (ssize_t val, const IPosition& right);
492 Bool operator != (ssize_t val, const IPosition& right);
493 Bool operator < (ssize_t val, const IPosition& right);
494 Bool operator <= (ssize_t val, const IPosition& right);
495 Bool operator > (ssize_t val, const IPosition& right);
496 Bool operator >= (ssize_t val, const IPosition& right);
497 // </group>
498 // </group>
499 
500 // <summary>Indexing functions for IPosition's</summary>
501 // Convert between IPosition and offset in an array.
502 //
503 // The offset of an element in an array is the number of elements from the
504 // origin that the element would be if the array were arranged linearly.
505 // The origin of the array has an offset equal to 0, while the
506 // "top right corner" of the array has an offset equal to one less than the
507 // total number of elements in the array.
508 //
509 // Two examples of offset would be the index in a carray and the seek position
510 // in a file.
511 
512 // <group name="IPosition Indexing">
513 // Convert from offset to IPosition in an array.
514 IPosition toIPositionInArray (Int64 offset, const IPosition& shape);
515 
516 // Convert from IPosition to offset in an array.
517 Int64 toOffsetInArray (const IPosition& iposition, const IPosition& shape);
518 
519 // Determine if the given offset or IPosition is inside the array. Returns
520 // True if it is inside the Array.
521 // <thrown>
522 // <li> ArrayConformanceError: If all the IPositions are not the same length
523 // </thrown>
524 // <group>
525 Bool isInsideArray (const Int64 offset, const IPosition& shape);
526 Bool isInsideArray (const IPosition& iposition, const IPosition& shape);
527 // </group>
528 // </group>
529 
530 
531 
532 //# Inlined member functions for IPosition
533 
535 : size_p (0),
536  data_p (buffer_p)
537 {}
538 
540 {
541  return makeAxisPath (nrdim, IPosition());
542 }
543 
545 {
546  return size_p;
547 }
548 inline uInt IPosition::size() const
549 {
550  return size_p;
551 }
552 inline Bool IPosition::empty() const
553 {
554  return size_p == 0;
555 }
556 
557 inline ssize_t& IPosition::operator[](uInt index)
558 {
559  return data_p[index];
560 }
561 
562 inline ssize_t IPosition::operator[](uInt index) const
563 {
564  return data_p[index];
565 }
566 
567 inline ssize_t& IPosition::operator()(uInt index)
568 {
569 #if defined(AIPS_ARRAY_INDEX_CHECK)
570  if (index >= nelements()) {
571  throwIndexError();
572  }
573 #endif
574  return data_p[index];
575 }
576 
577 inline ssize_t IPosition::operator()(uInt index) const
578 {
579 #if defined(AIPS_ARRAY_INDEX_CHECK)
580  if (index >= nelements()) {
581  throwIndexError();
582  }
583 #endif
584  return data_p[index];
585 }
586 
587 inline ssize_t& IPosition::last (uInt index)
588 {
589 #if defined(AIPS_ARRAY_INDEX_CHECK)
590  if (size_p - index <= 0) {
591  throwIndexError();
592  }
593 #endif
594  return data_p[size_p-index-1];
595 }
596 
597 inline ssize_t IPosition::last (uInt index) const
598 {
599 #if defined(AIPS_ARRAY_INDEX_CHECK)
600  if (size_p - index <= 0) {
601  throwIndexError();
602  }
603 #endif
604  return data_p[size_p-index-1];
605 }
606 
607 inline const ssize_t *IPosition::storage() const
608 {
609  return data_p;
610 }
611 
612 inline Bool IPosition::conform(const IPosition& other) const
613 {
614  return (size_p == other.size_p);
615 }
616 
617 } //# NAMESPACE CASACORE - END
618 
619 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
IPosition keepAxes(const IPosition &axes) const
Return an IPosition containing the given axes only.
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:393
std::vector< double > Vector
Definition: ds9context.h:24
IPosition & operator=(const IPosition &other)
Makes this a copy of other.
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:416
ssize_t buffer_p[BufferLength]
Definition: IPosition.h:413
Bool conform(const IPosition &other) const
conform returns true if nelements() == other.nelements().
Definition: IPosition.h:612
LatticeExprNode operator/(const LatticeExprNode &left, const LatticeExprNode &right)
AipsIO is the object persistency mechanism of Casacore.
Definition: AipsIO.h:168
IPosition concatenate(const IPosition &other) const
Return an IPosition as the concetanation of this and another IPosition.
LatticeExprNode max(const LatticeExprNode &left, const LatticeExprNode &right)
void throwIndexError() const
Throw an index error exception.
iterator end()
Definition: IPosition.h:397
void operator+=(const IPosition &other)
Element-by-element arithmetic.
LatticeExprNode operator!=(const LatticeExprNode &left, const LatticeExprNode &right)
ostream-like interface to creating log messages.
Definition: LogIO.h:167
const value_type * const_pointer
Definition: IPosition.h:385
Bool isEqual(const IPosition &other) const
Element-by-element comparison for equality.
const_iterator begin() const
Definition: IPosition.h:395
IPosition getFirst(uInt n) const
Construct an IPosition from the first n values 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 ...
MVEarthMagnetic operator*(const RotMatrix &left, const MVEarthMagnetic &right)
Rotate a EarthMagnetic vector with rotation matrix and other multiplications.
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:399
void setFirst(const IPosition &other)
Set the first values of this IPosition to another IPosition.
Bool ok() const
Is this IPosition consistent?
void fill(uInt size, InputIterator iter)
Resize and fill this IPosition object.
Definition: IPosition.h:185
IPosition removeAxes(const IPosition &axes) const
Return an IPosition where the given axes are reoved.
const ssize_t * storage() const
Get the storage.
Definition: IPosition.h:607
Bool allOne() const
Are all elements equal to 1? Useful to check if a given stride is really a stride.
IPosition()
A zero-length IPosition.
Definition: IPosition.h:534
LatticeExprNode min(const LatticeExprNode &left, const LatticeExprNode &right)
ssize_t value_type
Define the STL-style iterators.
Definition: IPosition.h:381
void allocateBuffer()
Allocate a buffer with length size_p.
void operator*=(const IPosition &other)
void operator/=(const IPosition &other)
Bool empty() const
Is the IPosition empty (i.e.
Definition: IPosition.h:552
ssize_t & last(uInt index=0)
Index into the IPosition from the end.
Definition: IPosition.h:587
void copy(OutputIterator iter) const
Copy the contents of this IPosition object to the output iterator.
Definition: IPosition.h:196
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.
std::vector< Int > asStdVector() const
ssize_t & operator[](uInt index)
Index into the IPosition.
Definition: IPosition.h:557
LatticeExprNode operator<=(const LatticeExprNode &left, const LatticeExprNode &right)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
static IPosition makeAxisPath(uInt nrdim)
Construct a default axis path consisting of the values 0.
Definition: IPosition.h:539
ssize_t & operator()(uInt index)
Definition: IPosition.h:567
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
LatticeExprNode operator>(const LatticeExprNode &left, const LatticeExprNode &right)
ptrdiff_t difference_type
Definition: IPosition.h:389
ssize_t * iterator
Definition: IPosition.h:382
value_type & reference
Definition: IPosition.h:386
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.
uInt size() const
Definition: IPosition.h:548
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
Bool operator==(const MVTime &lh, const MVTime &rh)
is equal operator, uses operator Double which returns days
Definition: MVTime.h:465
const value_type & const_reference
Definition: IPosition.h:387
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:383
IPosition nonDegenerate(uInt startingAxis=0) const
This member functions return an IPosition which has degenerate (length==1) axes removed and the dimen...
bool operator()(const IPosition &lhs, const IPosition &rhs) const
allows a way for IPosition to be used as keys in a std::map
value_type * pointer
Definition: IPosition.h:384
void setLast(const IPosition &other)
Set the last values of this IPosition to another IPosition.
uInt nelements() const
The number of elements in this IPosition.
Definition: IPosition.h:544
String toString() const
Write the IPosition into a String.
Vector< Int > asVector() const
const Bool True
Definition: aipstype.h:43
friend AipsIO & operator>>(AipsIO &aio, IPosition &ip)
Read an IPosition from an AipsIO stream in a binary format.
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
Int64 product() const
Returns 0 if nelements() == 0, otherwise it returns the product of its elements.
IPosition getLast(uInt n) const
Construct an IPosition from the last n values of this IPosition.
unsigned int uInt
Definition: aipstype.h:51
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42