casacore
Loading...
Searching...
No Matches
ExprFuncNodeArray.h
Go to the documentation of this file.
1//# ExprFuncNodeArray.h: Class representing an array function in table select expression
2//# Copyright (C) 2001,2003
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 TABLES_EXPRFUNCNODEARRAY_H
27#define TABLES_EXPRFUNCNODEARRAY_H
28
29//# Includes
30#include <casacore/casa/aips.h>
31#include <casacore/tables/TaQL/ExprNodeArray.h>
32#include <casacore/tables/TaQL/ExprFuncNode.h>
33
34namespace casacore { //# NAMESPACE CASACORE - BEGIN
35
36//# Forward Declarations
37
38
39// <summary>
40// Class representing an array function in table select expression
41// </summary>
42
43// <use visibility=local>
44
45// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
46// </reviewed>
47// <prerequisite>
48//# Classes you should understand before using this one.
49// <li> <linkto class=TableExprFuncNode>TableExprFuncNode</linkto>
50// <li> <linkto class=TableExprNodeArray>TableExprNodeArray</linkto>
51// </prerequisite>
52
53// <synopsis>
54// This class can be seen as a specialization of TableExprFuncNode
55// for functions returning arrays.
56// However, it is derived from TableExprNodeArray to make it possible
57// that the ExprNode classes use all array functionality offered by
58// that base class.
59// <br>Internally an TableExprFuncNode object is used.
60// <p>
61// When a TaQL function is used, TableExprFuncNode::checkOperands
62// determines whether the result is a scalar or an array.
63// Thereafter TableExprNode::newFunctionNode creates a TableExprFuncNode
64// for scalars or a TableExprFuncNodeArray for arrays.
65// </synopsis>
66
67
69{
70public:
71 // Constructor
74 const TableExprNodeSet& source,
75 const vector<TENShPtr>& nodes,
76 const Block<Int>& dtypeOper,
77 const TaQLStyle&);
78
79 // Destructor
81
82 // Flatten the node tree by adding the node and its children to the vector.
83 virtual void flattenTree (std::vector<TableExprNodeRep*>&);
84
85 // 'get' Functions to get the desired result of a function
86 // <group>
93 // </group>
94
95 // Get the function node.
97 { return &node_p; }
99 { return &node_p; }
100
101protected:
102 // Try if the function gives a constant result.
103 // If so, set the expression type to Constant.
104 // Get possible constant arguments like axes.
106
107 // Some functions to be used by TableExprNodeFuncArray.
108 // <group>
109 const std::vector<TENShPtr>& operands() const
110 { return node_p.operands(); }
111 std::vector<TENShPtr>& rwOperands()
112 { return node_p.rwOperands(); }
114 { return node_p.funcType(); }
116 { return node_p.argDataType(); }
117 // </group>
118
119private:
120 // Get the collapse axes for the partial functions.
121 // It compares the values with the #dim and removes them if too high.
122 // axarg gives the argument nr of the axes.
124 Int ndim, uInt axarg=1, Bool swapRemove=True);
125
126 // Remove axes exceeding ndim.
127 IPosition removeAxes (const IPosition& axes, Int ndim) const;
128
129 // Get the shape for the array, boxed and running functions.
130 // If an axis length < 0, the corresponding main shape axis (if present)
131 // is used.
132 // axarg gives the argument nr of the shape.
134 uInt axarg=1);
135
136 // Get the transpose order of the array axes.
138
139 // Get the axes for the reverse function.
141
142 // Get the arguments for the diagonals function.
143 // They are checked and if needed adapted if the shape is not empty.
145 const IPosition& shp);
146
147 // Set the alternate value expandAlt_p for array expand and return it.
149
150 // Adjust the resize shape by replacing negative axes with the
151 // original axis (if present) or 1.
153 const IPosition& origShape) const;
154
155 // Templated function to resize/expand an array.
156 template<typename T>
157 MArray<T> TEFResize (const MArray<T>& arr, const TableExprId& id);
158
159 // The angular distance between each pair of the arguments.
161 const MArray<Double>& a2) const;
162
163
164 //# Data members
166 Int origin_p; //# axes origin
167 Bool isCOrder_p; //# axes order
168 Bool constAxes_p; //# True = collapse axes are constant
169 Bool constAlt_p; //# True = expandAlt_p is constant
170 IPosition ipos_p; //# the (maybe constant) axes or shape
171 IPosition iposN_p; //# the non-reversed axes or shape
172 IPosition expandAlt_p; //# alternate for expand/resize
173};
174
175
176
177
178} //# NAMESPACE CASACORE - END
179
180#endif
simple 1-D array
Definition Block.h:198
virtual MArray< Bool > getArrayBool(const TableExprId &id)
'get' Functions to get the desired result of a function
const IPosition & getDiagonalArg(const TableExprId &id, const IPosition &shp)
Get the arguments for the diagonals function.
IPosition getOrder(const TableExprId &id, Int ndim)
Get the transpose order of the array axes.
IPosition removeAxes(const IPosition &axes, Int ndim) const
Remove axes exceeding ndim.
TableExprFuncNode::FunctionType funcType() const
virtual MArray< MVTime > getArrayDate(const TableExprId &id)
const IPosition & getArrayShape(const TableExprId &id, uInt axarg=1)
Get the shape for the array, boxed and running functions.
MArray< Double > angdistx(const MArray< Double > &a1, const MArray< Double > &a2) const
The angular distance between each pair of the arguments.
MArray< T > TEFResize(const MArray< T > &arr, const TableExprId &id)
Templated function to resize/expand an array.
IPosition getReverseAxes(const TableExprId &id, uInt ndim)
Get the axes for the reverse function.
IPosition getAxes(const TableExprId &id, Int ndim, uInt axarg=1, Bool swapRemove=True)
Get the collapse axes for the partial functions.
std::vector< TENShPtr > & rwOperands()
virtual MArray< Int64 > getArrayInt(const TableExprId &id)
TableExprFuncNodeArray(TableExprFuncNode::FunctionType, NodeDataType, ValueType, const TableExprNodeSet &source, const vector< TENShPtr > &nodes, const Block< Int > &dtypeOper, const TaQLStyle &)
Constructor.
virtual MArray< Double > getArrayDouble(const TableExprId &id)
const TableExprFuncNode * getChild() const
const IPosition & getAlternate(const TableExprId &id)
Set the alternate value expandAlt_p for array expand and return it.
IPosition adjustShape(const IPosition &shape, const IPosition &origShape) const
Adjust the resize shape by replacing negative axes with the original axis (if present) or 1.
const std::vector< TENShPtr > & operands() const
Some functions to be used by TableExprNodeFuncArray.
virtual MArray< String > getArrayString(const TableExprId &id)
TableExprFuncNode * getChild()
Get the function node.
virtual MArray< DComplex > getArrayDComplex(const TableExprId &id)
void tryToConst()
Try if the function gives a constant result.
virtual void flattenTree(std::vector< TableExprNodeRep * > &)
Flatten the node tree by adding the node and its children to the vector.
TableExprNodeArray(NodeDataType, OperType)
Create the object.
NodeDataType
Define the data types of a node.
ValueType
Define the value types.
this file contains all the compiler specific defines
Definition mainpage.dox:28
LatticeExprNode ndim(const LatticeExprNode &expr)
1-argument function to get the dimensionality of a lattice.
unsigned int uInt
Definition aipstype.h:49
IPosition shape(const RecordFieldId &) const
Get the actual shape of this field.
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41