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