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// <summary>
39// Class representing an array function in table select expression
40// </summary>
41
42// <use visibility=local>
43
44// <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="">
45// </reviewed>
46// <prerequisite>
47// # Classes you should understand before using this one.
48// <li> <linkto class=TableExprFuncNode>TableExprFuncNode</linkto>
49// <li> <linkto class=TableExprNodeArray>TableExprNodeArray</linkto>
50// </prerequisite>
51
52// <synopsis>
53// This class can be seen as a specialization of TableExprFuncNode
54// for functions returning arrays.
55// However, it is derived from TableExprNodeArray to make it possible
56// that the ExprNode classes use all array functionality offered by
57// that base class.
58// <br>Internally an TableExprFuncNode object is used.
59// <p>
60// When a TaQL function is used, TableExprFuncNode::checkOperands
61// determines whether the result is a scalar or an array.
62// Thereafter TableExprNode::newFunctionNode creates a TableExprFuncNode
63// for scalars or a TableExprFuncNodeArray for arrays.
64// </synopsis>
65
67 public:
68 // Constructor
70 const TableExprNodeSet& source, const vector<TENShPtr>& nodes,
71 const Block<Int>& dtypeOper, const TaQLStyle&);
72
73 // Destructor
75
76 // Flatten the node tree by adding the node and its children to the vector.
77 virtual void flattenTree(std::vector<TableExprNodeRep*>&);
78
79 // 'get' Functions to get the desired result of a function
80 // <group>
87 // </group>
88
89 // Get the function node.
91 const TableExprFuncNode* getChild() const { return &node_p; }
92
93 protected:
94 // Try if the function gives a constant result.
95 // If so, set the expression type to Constant.
96 // Get possible constant arguments like axes.
97 void tryToConst();
98
99 // Some functions to be used by TableExprNodeFuncArray.
100 // <group>
101 const std::vector<TENShPtr>& operands() const { return node_p.operands(); }
102 std::vector<TENShPtr>& rwOperands() { return node_p.rwOperands(); }
103 TableExprFuncNode::FunctionType funcType() const { return node_p.funcType(); }
104 NodeDataType argDataType() const { return node_p.argDataType(); }
105 // </group>
106
107 private:
108 // Get the collapse axes for the partial functions.
109 // It compares the values with the #dim and removes them if too high.
110 // axarg gives the argument nr of the axes.
111 IPosition getAxes(const TableExprId& id, Int ndim, uInt axarg = 1, Bool swapRemove = True);
112
113 // Remove axes exceeding ndim.
114 IPosition removeAxes(const IPosition& axes, Int ndim) const;
115
116 // Get the shape for the array, boxed and running functions.
117 // If an axis length < 0, the corresponding main shape axis (if present)
118 // is used.
119 // axarg gives the argument nr of the shape.
120 const IPosition& getArrayShape(const TableExprId& id, uInt axarg = 1);
121
122 // Get the transpose order of the array axes.
124
125 // Get the axes for the reverse function.
127
128 // Get the arguments for the diagonals function.
129 // They are checked and if needed adapted if the shape is not empty.
130 const IPosition& getDiagonalArg(const TableExprId& id, const IPosition& shp);
131
132 // Set the alternate value expandAlt_p for array expand and return it.
134
135 // Adjust the resize shape by replacing negative axes with the
136 // original axis (if present) or 1.
137 IPosition adjustShape(const IPosition& shape, const IPosition& origShape) const;
138
139 // Templated function to resize/expand an array.
140 template <typename T>
141 MArray<T> TEFResize(const MArray<T>& arr, const TableExprId& id);
142
143 // The angular distance between each pair of the arguments.
145
146 // # Data members
148 Int origin_p; // # axes origin
149 Bool isCOrder_p; // # axes order
150 Bool constAxes_p; // # True = collapse axes are constant
151 Bool constAlt_p; // # True = expandAlt_p is constant
152 IPosition ipos_p; // # the (maybe constant) axes or shape
153 IPosition iposN_p; // # the non-reversed axes or shape
154 IPosition expandAlt_p; // # alternate for expand/resize
155};
156
157} // namespace casacore
158
159#endif
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.
For temporary backward namespace compatibility, use casa as alias for casacore.
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