casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AxesMapping.h
Go to the documentation of this file.
1 //# AxesMapping.h: Info about mapping array axes to another order
2 //# Copyright (C) 2000,2001
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 //#
27 //# $Id$
28 
29 #ifndef CASA_AXESMAPPING_H
30 #define CASA_AXESMAPPING_H
31 
32 
33 //# Includes
34 #include <casacore/casa/aips.h>
36 
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39 //# Forward Declarations
40 class Slicer;
41 
42 
43 // <summary>
44 // Info about mapping array axes to another order.
45 // </summary>
46 
47 // <use visibility=local>
48 
49 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tAxesSpecifier.cc" demos="">
50 // </reviewed>
51 
52 // <prerequisite>
53 // <li> <linkto class="IPosition">IPosition</linkto>
54 // <li> <linkto class="AxesSpecifier">AxesSpecifier</linkto>
55 // </prerequisite>
56 
57 // <synopsis>
58 // AxesMapping holds the information about mapping axes to another order.
59 // It can be constructed by <linkto class=AxesSpecifier>AxesSpecifier</linkto>
60 // by applying a shape to the axes specification.
61 // <br>AxesMapping is thereafter used to map positions, shapes, and
62 // slices to the new axes or backwards.
63 // <note role=caution>
64 // Shapes and positions are both represented by class IPosition.
65 // However, they have to be treated differently in this class,
66 // because removed axes for a position have value 0, while for a
67 // shape they have value 1. Hence there are different functions for them
68 // and the user has to take care that the correct function is called.
69 // </note>
70 // </synopsis>
71 
72 // <example>
73 // <srcblock>
74 //
75 // </srcblock>
76 // </example>
77 
78 // <motivation>
79 // The class encapsulates the mapping functionality.
80 // It is meant as a helper class for
81 // <linkto class=SubLattice>SubLattice</linkto>.
82 // </motivation>
83 
84 //# <todo asof="yyyy/mm/dd">
85 //# </todo>
86 
88 {
89 public:
90  // The default constructor creates empty maps.
91  AxesMapping();
92 
93  // Construct it with the mapping from old to new axes order.
94  // A value of -1 means that the old axes is ignored in the new one.
95  // Another value gives the new axis number.
96  // <br>It determines if axes are removed and/or reordered.
97  explicit AxesMapping (const IPosition& oldToNew);
98 
99  // Copy constructor (copy semantics).
100  AxesMapping(const AxesMapping& other);
101 
102  ~AxesMapping();
103 
104  // Assignment (copy semantics).
105  // This and that do not have to have the same length.
106  AxesMapping& operator= (const AxesMapping& other);
107 
108  // Are axes removed?
109  Bool isRemoved() const
110  { return itsRemoved; }
111 
112  // Is the axes order reordered?
114  { return itsReordered; }
115 
116  // Get the mapping of old->new.
117  // The length of the resulting IPosition is the dimensionality of
118  // the original lattice. A value of -1 indicates that the corresponding
119  // axis in the original lattice is removed.
120  // Another value is the axis number in the new lattice,
121  const IPosition& getToNew() const
122  { return itsToNew; }
123 
124  // Get the mapping of new->old.
125  // The length of the resulting IPosition is the dimensionality of
126  // the new lattice. Its values give the axes in the original lattice.
127  const IPosition& getToOld() const
128  { return itsToOld; }
129 
130  // Map an old position to the new one.
131  // In debug-mode it checks if the removed axes have position 0
132  // in the input position.
133  IPosition posToNew (const IPosition& pos) const;
134 
135  // Map a new position or shape to the old one.
136  IPosition posToOld (const IPosition& pos) const;
137 
138  // Map an old shape to the new one.
139  // In debug-mode it checks if the removed axes have length 1
140  // in the input shape.
141  IPosition shapeToNew (const IPosition& shape) const;
142 
143  // Map a new position or shape to the old one.
144  IPosition shapeToOld (const IPosition& shape) const;
145 
146  // Map an old shape to the new one.
147  // In debug-mode it checks if the removed axes have length 1
148  // in the input slicer.
149  Slicer slicerToNew (const Slicer& slicer) const;
150 
151  // Map a new position or shape to the old one.
152  Slicer slicerToOld (const Slicer& slicer) const;
153 
154 private:
159 };
160 
161 
162 
163 } //# NAMESPACE CASACORE - END
164 
165 #endif
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
Slicer slicerToNew(const Slicer &slicer) const
Map an old shape to the new one.
IPosition posToOld(const IPosition &pos) const
Map a new position or shape to the old one.
Info about mapping array axes to another order.
Definition: AxesMapping.h:87
AxesMapping & operator=(const AxesMapping &other)
Assignment (copy semantics).
AxesMapping()
The default constructor creates empty maps.
IPosition posToNew(const IPosition &pos) const
Map an old position to the new one.
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
Specify which elements to extract from an n-dimensional array.
Definition: Slicer.h:289
Bool isReordered() const
Is the axes order reordered?
Definition: AxesMapping.h:113
Bool isRemoved() const
Are axes removed?
Definition: AxesMapping.h:109
Slicer slicerToOld(const Slicer &slicer) const
Map a new position or shape to the old one.
IPosition shapeToNew(const IPosition &shape) const
Map an old shape to the new one.
const IPosition & getToNew() const
Get the mapping of old-&gt;new.
Definition: AxesMapping.h:121
const IPosition & getToOld() const
Get the mapping of new-&gt;old.
Definition: AxesMapping.h:127
IPosition shapeToOld(const IPosition &shape) const
Map a new position or shape to the old one.
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42