casacore
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_2_H
30 #define CASA_AXESMAPPING_2_H
31 
32 //# Includes
33 #include "IPosition.h"
34 
35 namespace casacore { //# NAMESPACE CASACORE - BEGIN
36 
37 //# Forward Declarations
38 class Slicer;
39 
40 
41 // <summary>
42 // Info about mapping array axes to another order.
43 // </summary>
44 
45 // <use visibility=local>
46 
47 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tAxesSpecifier.cc" demos="">
48 // </reviewed>
49 
50 // <prerequisite>
51 // <li> <linkto class="IPosition">IPosition</linkto>
52 // <li> <linkto class="AxesSpecifier">AxesSpecifier</linkto>
53 // </prerequisite>
54 
55 // <synopsis>
56 // AxesMapping holds the information about mapping axes to another order.
57 // It can be constructed by <linkto class=AxesSpecifier>AxesSpecifier</linkto>
58 // by applying a shape to the axes specification.
59 // <br>AxesMapping is thereafter used to map positions, shapes, and
60 // slices to the new axes or backwards.
61 // <note role=caution>
62 // Shapes and positions are both represented by class IPosition.
63 // However, they have to be treated differently in this class,
64 // because removed axes for a position have value 0, while for a
65 // shape they have value 1. Hence there are different functions for them
66 // and the user has to take care that the correct function is called.
67 // </note>
68 // </synopsis>
69 
70 // <example>
71 // <srcblock>
72 //
73 // </srcblock>
74 // </example>
75 
76 // <motivation>
77 // The class encapsulates the mapping functionality.
78 // It is meant as a helper class for casacore's SubLattice.
79 // </motivation>
80 
81 //# <todo asof="yyyy/mm/dd">
82 //# </todo>
83 
85 {
86 public:
87  // The default constructor creates empty maps.
89 
90  // Construct it with the mapping from old to new axes order.
91  // A value of -1 means that the old axes is ignored in the new one.
92  // Another value gives the new axis number.
93  // <br>It determines if axes are removed and/or reordered.
94  explicit AxesMapping (const IPosition& oldToNew);
95 
96  // Are axes removed?
97  bool isRemoved() const
98  { return itsRemoved; }
99 
100  // Is the axes order reordered?
101  bool isReordered() const
102  { return itsReordered; }
103 
104  // Get the mapping of old->new.
105  // The length of the resulting IPosition is the dimensionality of
106  // the original lattice. A value of -1 indicates that the corresponding
107  // axis in the original lattice is removed.
108  // Another value is the axis number in the new lattice,
109  const IPosition& getToNew() const
110  { return itsToNew; }
111 
112  // Get the mapping of new->old.
113  // The length of the resulting IPosition is the dimensionality of
114  // the new lattice. Its values give the axes in the original lattice.
115  const IPosition& getToOld() const
116  { return itsToOld; }
117 
118  // Map an old position to the new one.
119  // In debug-mode it checks if the removed axes have position 0
120  // in the input position.
121  IPosition posToNew (const IPosition& pos) const;
122 
123  // Map a new position or shape to the old one.
124  IPosition posToOld (const IPosition& pos) const;
125 
126  // Map an old shape to the new one.
127  // In debug-mode it checks if the removed axes have length 1
128  // in the input shape.
130 
131  // Map a new position or shape to the old one.
133 
134  // Map an old shape to the new one.
135  // In debug-mode it checks if the removed axes have length 1
136  // in the input slicer.
137  Slicer slicerToNew (const Slicer& slicer) const;
138 
139  // Map a new position or shape to the old one.
140  Slicer slicerToOld (const Slicer& slicer) const;
141 
142 private:
147 };
148 
149 
150 
151 } //# NAMESPACE CASACORE - END
152 
153 #endif
AxesMapping(const IPosition &oldToNew)
Construct it with the mapping from old to new axes order.
IPosition posToNew(const IPosition &pos) const
Map an old position to the new one.
IPosition shapeToOld(const IPosition &shape) const
Map a new position or shape to the old one.
const IPosition & getToOld() const
Get the mapping of new->old.
Definition: AxesMapping.h:115
bool isRemoved() const
Are axes removed?
Definition: AxesMapping.h:97
IPosition posToOld(const IPosition &pos) const
Map a new position or shape to the old one.
Slicer slicerToNew(const Slicer &slicer) const
Map an old shape to the new one.
IPosition shapeToNew(const IPosition &shape) const
Map an old shape to the new one.
AxesMapping()
The default constructor creates empty maps.
Slicer slicerToOld(const Slicer &slicer) const
Map a new position or shape to the old one.
const IPosition & getToNew() const
Get the mapping of old->new.
Definition: AxesMapping.h:109
bool isReordered() const
Is the axes order reordered?
Definition: AxesMapping.h:101
this file contains all the compiler specific defines
Definition: mainpage.dox:28
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape.
Definition: ExprNode.h:1987