LSST Applications
21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
|
A MathMap is a Mapping which allows you to specify a set of forward and/or inverse transformation functions using arithmetic operations and mathematical functions similar to those available in C. More...
#include <MathMap.h>
Public Types | |
using | ObjectPtr = std::unique_ptr< AstObject, Deleter > |
unique pointer holding an AST raw pointer More... | |
Public Member Functions | |
MathMap (int nin, int nout, std::vector< std::string > const &fwd, std::vector< std::string > const &rev, std::string const &options="") | |
Construct a Mathmap. More... | |
virtual | ~MathMap () |
MathMap (MathMap const &)=default | |
Copy constructor: make a deep copy. More... | |
MathMap (MathMap &&)=default | |
MathMap & | operator= (MathMap const &)=delete |
MathMap & | operator= (MathMap &&)=default |
std::shared_ptr< MathMap > | copy () const |
Return a deep copy of this object. More... | |
int | getSeed () const |
Get Seed: random number seed. More... | |
bool | getSimpFI () const |
Get SimpFI: can forward-inverse MathMap pairs safely simplify? More... | |
bool | getSimpIF () const |
Get SimpIF: can inverse-forward MathMap pairs safely simplify? More... | |
int | getNIn () const |
Get NIn: the number of input axes. More... | |
int | getNOut () const |
Get NOut: the number of output axes. More... | |
bool | getIsSimple () const |
Get IsSimple: has the mapping been simplified? More... | |
bool | isInverted () const |
Is this an inverted mapping? More... | |
bool | getIsLinear () const |
Get IsLinear: is the Mapping linear? More... | |
bool | getReport () const |
Get Report: report transformed coordinates to stdout? More... | |
bool | hasForward () const |
Is the forward transform available? More... | |
bool | hasInverse () const |
Is the inverse transform available? More... | |
std::shared_ptr< Mapping > | inverted () const |
Get an inverse mapping. More... | |
Array2D | linearApprox (PointD const &lbnd, PointD const &ubnd, double tol) const |
Compute a linear approximation to the forward transformation. More... | |
SeriesMap | then (Mapping const &next) const |
Return a series compound mapping this(first(input)) containing shallow copies of the original. More... | |
ParallelMap | under (Mapping const &next) const |
Return a parallel compound mapping containing shallow copies of the original. More... | |
double | rate (PointD const &at, int ax1, int ax2) const |
Evaluate the rate of change of the Mapping with respect to a specified input, at a specified position. More... | |
void | setReport (bool report) |
Set Report: report transformed coordinates to stdout? More... | |
std::shared_ptr< Mapping > | simplified () const |
Return a simplied version of the mapping (which may be a compound Mapping such as a CmpMap). More... | |
void | applyForward (ConstArray2D const &from, Array2D const &to) const |
Perform a forward transformation on 2-D array, putting the results into a pre-allocated 2-D array. More... | |
Array2D | applyForward (ConstArray2D const &from) const |
Perform a forward transformation on a 2-D array, returning the results as a new array. More... | |
std::vector< double > | applyForward (std::vector< double > const &from) const |
Perform a forward transformation on a vector, returning the results as a new vector. More... | |
void | applyInverse (ConstArray2D const &from, Array2D const &to) const |
Perform an inverse transformation on a 2-D array, putting the results into a pre-allocated 2-D array. More... | |
Array2D | applyInverse (ConstArray2D const &from) const |
Perform an inverse transformation on a 2-D array, returning the results as a new 2-D array. More... | |
std::vector< double > | applyInverse (std::vector< double > const &from) const |
Perform an inverse transformation on a vector, returning the results as a new vector. More... | |
void | tranGridForward (PointI const &lbnd, PointI const &ubnd, double tol, int maxpix, Array2D const &to) const |
Transform a grid of points in the forward direction. More... | |
Array2D | tranGridForward (PointI const &lbnd, PointI const &ubnd, double tol, int maxpix, int nPts) const |
Transform a grid of points in the inverse direction, returning the results as a new Array2D. More... | |
void | tranGridInverse (PointI const &lbnd, PointI const &ubnd, double tol, int maxpix, Array2D const &to) const |
Transform a grid of points in the inverse direction. More... | |
Array2D | tranGridInverse (PointI const &lbnd, PointI const &ubnd, double tol, int maxpix, int nPts) const |
Transform a grid of points in the inverse direction. More... | |
bool | operator== (Object const &rhs) const |
Return True if this and rhs are the equal. More... | |
bool | operator!= (Object const &rhs) const |
Return True if this and rhs are not equal. More... | |
void | clear (std::string const &attrib) |
Clear the values of a specified set of attributes for an Object. More... | |
bool | hasAttribute (std::string const &attrib) const |
Does this object have an attribute with the specified name? More... | |
std::string | getClassName () const |
Get Class: the name of the class (e.g. More... | |
std::string | getID () const |
Get ID: object identification string that is not copied. More... | |
std::string | getIdent () const |
Get Ident: object identification string that is copied. More... | |
int | getNObject () const |
Get NObject: number of AST objects in existence of the same type as the underlying AST class. More... | |
int | getObjSize () const |
Get ObjSize: the in-memory size of the AST object in bytes. More... | |
int | getRefCount () const |
Get RefCount: number of active pointers to the underlying AST object. More... | |
bool | getUseDefs () const |
Get UseDefs: allow use of default values for Object attributes? More... | |
void | lock (bool wait) |
Lock this object for exclusive use by the calling thread. More... | |
bool | same (Object const &other) const |
Does this contain the same AST object as another? More... | |
void | setID (std::string const &id) |
Set ID: object identification string that is not copied. More... | |
void | setIdent (std::string const &ident) |
Set Ident: object identification string that is copied. More... | |
void | setUseDefs (bool usedefs) |
Set UseDefs: allow use of default values for Object attributes? More... | |
void | show (std::ostream &os, bool showComments=true) const |
Print a textual description the object to an ostream. More... | |
std::string | show (bool showComments=true) const |
Return a textual description the object as a string. More... | |
bool | test (std::string const &attrib) const |
Has this attribute been explicitly set (and not subsequently cleared)? More... | |
void | unlock (bool report=false) |
Unlock this object previously locked using lock, so that other threads can use this object. More... | |
AstObject const * | getRawPtr () const |
Get the raw AST pointer. More... | |
AstObject * | getRawPtr () |
Get the raw AST pointer. More... | |
Static Public Member Functions | |
static std::shared_ptr< Object > | fromString (std::string const &str) |
Construct an Object from a string, using astFromString. More... | |
template<typename Class > | |
static std::shared_ptr< Class > | fromAstObject (AstObject *rawObj, bool copy) |
Given a bare AST object pointer return a shared pointer to an ast::Object of the correct type. More... | |
Protected Member Functions | |
virtual std::shared_ptr< Object > | copyPolymorphic () const override |
Return a deep copy of this object. More... | |
MathMap (AstMathMap *rawptr) | |
Construct a MathMap from a raw AST pointer. More... | |
template<typename Class > | |
std::shared_ptr< Class > | decompose (int i, bool copy) const |
Return a deep copy of one of the two component mappings. More... | |
template<typename T , typename AstT > | |
std::shared_ptr< T > | copyImpl () const |
Implementation of deep copy. More... | |
bool | getB (std::string const &attrib) const |
Get the value of an attribute as a bool. More... | |
std::string const | getC (std::string const &attrib) const |
Get the value of an attribute as a string. More... | |
double | getD (std::string const &attrib) const |
Get the value of an attribute as a double. More... | |
float | getF (std::string const &attrib) const |
Get the value of an attribute as a float. More... | |
int | getI (std::string const &attrib) const |
Get the value of an attribute as an int. More... | |
long int | getL (std::string const &attrib) const |
Get the value of an attribute as a long int. More... | |
void | set (std::string const &setting) |
Assign a set of attribute values, over-riding any previous values. More... | |
void | setB (std::string const &attrib, bool value) |
Set the value of an attribute as a bool. More... | |
void | setC (std::string const &attrib, std::string const &value) |
Set the value of an attribute as a string. More... | |
void | setD (std::string const &attrib, double value) |
Set the value of an attribute as a double. More... | |
void | setF (std::string const &attrib, float value) |
Set the value of an attribute as a float. More... | |
void | setI (std::string const &attrib, int value) |
Set the value of an attribute as an int. More... | |
void | setL (std::string const &attrib, long int value) |
Set the value of an attribute as a long int. More... | |
Static Protected Member Functions | |
template<typename ShimT , typename AstT > | |
static std::shared_ptr< ShimT > | makeShim (AstObject *p) |
Functor to make an astshim instance from a raw AST pointer of the corresponding type. More... | |
Friends | |
class | Object |
A MathMap is a Mapping which allows you to specify a set of forward and/or inverse transformation functions using arithmetic operations and mathematical functions similar to those available in C.
The MathMap interprets these functions at run-time, whenever its forward or inverse transformation is required. Because the functions are not compiled in the normal sense (unlike an IntraMap), they may be used to describe coordinate transformations in a transportable manner. A MathMap therefore provides a flexible way of defining new types of Mapping whose descriptions may be stored as part of a dataset and interpreted by other programs.
In addition to those attributes provided by Mapping and Object, MathMap has the following attributes:
|
inherited |
|
inline |
Construct a Mathmap.
[in] | nin | Number of input variables for the MathMap. |
[in] | nout | Number of output variables for the MathMap. |
[in] | fwd | An array contain the expressions defining the forward transformation. The syntax of these expressions is described below. |
[in] | rev | An array contain the expressions defining the reverse transformation. The syntax of these expressions is described below. |
[in] | options | Comma-separated list of attribute assignments. |
A MathMap
's transformation functions are supplied as a set of expressions in an array of character strings. Normally you would supply the same number of expressions for the forward transformation, via the fwd
parameter, as there are output variables (given by the MathMap
's NOut attribute). For instance, if NOut is 2 you might use:
r
and theta
) provide names for the output variables and those that appear on the right (x
and y
) are references to input variables.To complement this, you must also supply expressions for the inverse transformation via the "inv" parameter. In this case, the number of expressions given would normally match the number of MathMap input coordinates (given by the NIn attribute). If NIn is 2, you might use:
x
and y
) are named on the left of each expression, and the output variables (r
and theta
are referenced on the right.Normally, you cannot refer to a variable on the right of an expression unless it is named on the left of an expression in the complementary set of functions. Therefore both sets of functions (forward and inverse) must be formulated using the same consistent set of variable names. This means that if you wish to leave one of the transformations undefined, you must supply dummy expressions which simply name each of the output (or input) variables. For example, you might use:
x
It is sometimes useful to calculate intermediate values and then to use these in the final expressions for the output (or input) variables. This may be done by supplying additional expressions for the forward (or inverse) transformation functions. For instance, the following array of five expressions describes 2-dimensional pin-cushion distortion:
Here, we first calculate three intermediate results ("r" , " rout" and "theta" ) and then use these to calculate the final results ("xout" and "yout" ). The MathMap knows that only the final two results constitute values for the output variables because its NOut attribute is set to 2. You may define as many intermediate variables in this way as you choose. Having defined a variable, you may then refer to it on the right of any subsequent expressions.
Note that when defining the inverse transformation you may only refer to the output variables "xout" and " yout" . The intermediate variables "r", "rout" and "theta" (above) are private to the forward transformation and may not be referenced by the inverse transformation. The inverse transformation may, however, define its own private intermediate variables.
The expressions given for the forward and inverse transformations closely follow the syntax of the C programming language (with some extensions for compatibility with Fortran). They may contain references to variables and literal constants, together with arithmetic, boolean, relational and bitwise operators, and function invocations. A set of symbolic constants is also available. Each of these is described in detail below. Parentheses may be used to over-ride the normal order of evaluation. There is no built-in limit to the length of expressions and they are insensitive to case or the presence of additional white space.
Variable names must begin with an alphabetic character and may contain only alphabetic characters, digits, and the underscore character " _" . There is no built-in limit to the length of variable names.
Literal constants, such as 0
, 1
, 0.007
or 2.505e-16
may appear in expressions, with the decimal point and exponent being optional (a D
may also be used as an exponent character for compatibility with Fortran). A unary minus -
may be used as a prefix.
Arithmetic Precision:
All arithmetic is floating point, performed in double precision.
Unless indicated otherwise, if any argument of a function or operator has the value AST__BAD (indicating missing data), then the result of that function or operation is also AST__BAD, so that such values are propagated automatically through all operations performed by MathMap transformations. The special value AST__BAD can be represented in expressions by the symbolic constant <bad>
. A <bad>
result (i.e. equal to AST__BAD) is also produced in response to any numerical error (such as division by zero or numerical overflow), or if an invalid argument value is provided to a function or operator.
The following arithmetic operators are available:
x1 + x2
: x1
plus x2
.x1 - x2
: x1
minus x2
.x1 * x2
: x1
times x2
.x1 / x2
: x1
divided by x2
.x1 ** x2
: x1
raised to the power of x2
.+x
: Unary plus, has no effect on its argument.-x
: Unary minus, negates its argument.Boolean values are represented using zero to indicate false and non-zero to indicate true. In addition, the value AST__BAD is taken to mean unknown
. The values returned by boolean operators may therefore be 0, 1 or AST__BAD. Where appropriate, "tri-state" logic is implemented. For example, a||b
may evaluate to 1 if a
is non-zero, even if b
has the value AST__BAD. This is because the result of the operation would not be affected by the value of b
, so long as a
is non-zero.
The following boolean operators are available:
x1 && x2
: Boolean AND between x1
and x2
, returning 1 if both x1
and x2
are non-zero, and 0 otherwise. This operator implements tri-state logic. (The synonym " .and." is also provided for compatibility with Fortran.)x1 || x2
: Boolean OR between x1
and x2
, returning 1 if either x1
or x2
are non-zero, and 0 otherwise. This operator implements tri-state logic. (The synonym " .or." is also provided for compatibility with Fortran.)x1 ^^ x2
: Boolean exclusive OR (XOR) between x1
and x2
, returning 1 if exactly one of x1
and x2
is non-zero, and 0 otherwise. Tri-state logic is not used with this operator. (The synonyms " .neqv." and " .xor." are also provided for compatibility with Fortran, although the second of these is not standard.)x1 .eqv. x2
: This is provided only for compatibility with Fortran and tests whether the boolean states of x1
and x2
(i.e. true/false) are equal. It is the negative of the exclusive OR (XOR) function. Tri-state logic is not used with this operator.!x
: Boolean unary NOT operation, returning 1 if x
is zero, and 0 otherwise. (The synonym " .not." is also provided for compatibility with Fortran.)Relational operators return the boolean result (0 or 1) of comparing the values of two floating point values for equality or inequality. The value AST__BAD may also be returned if either argument is <bad>
.
The following relational operators are available:
x1 == x2
: Tests whether x1
equals x1
. (The synonym " .eq." is also provided for compatibility with Fortran.)x1 != x2
: Tests whether x1
is unequal to x2
. (The synonym " .ne." is also provided for compatibility with Fortran.)x1 > x2
: Tests whether x1
is greater than x2
. (The synonym " .gt." is also provided for compatibility with Fortran.)x1 >= x2
: Tests whether x1
is greater than or equal to x2
. (The synonym " .ge." is also provided for compatibility with Fortran.)x1 < x2
: Tests whether x1
is less than x2
. (The synonym " .lt." is also provided for compatibility with Fortran.)x1 <= x2
: Tests whether x1
is less than or equal to x2
. (The synonym " .le." is also provided for compatibility with Fortran.)Note that relational operators cannot usefully be used to compare values with the <bad>
value (representing missing data), because the result is always <bad>
. The isbad() function should be used instead.
The bitwise operators provided by C are often useful when operating on raw data (e.g. from instruments), so they are also provided for use in MathMap expressions. In this case, however, the values on which they operate are floating point values rather than pure integers. In order to produce results which match the pure integer case, the operands are regarded as fixed point binary numbers (i.e. with the binary equivalent of a decimal point) with negative numbers represented using twos-complement notation. For integer values, the resulting bit pattern corresponds to that of the equivalent signed integer (digits to the right of the point being zero). Operations on the bits representing the fractional part are also possible, however.
The following bitwise operators are available:
x1 >> x2
: Rightward bit shift. The integer value of x2
is taken (rounding towards zero) and the bits representing x1
are then shifted this number of places to the right (or to the left if the number of places is negative). This is equivalent to dividing x1
by the corresponding power of 2.x1 << x2
: Leftward bit shift. The integer value of x2
is taken (rounding towards zero), and the bits representing x1
are then shifted this number of places to the left (or to the right if the number of places is negative). This is equivalent to multiplying x1
by the corresponding power of 2.x1 & x2
: Bitwise AND between the bits of x1
and those of x2
(equivalent to a boolean AND applied at each bit position in turn).x1 | x2
: Bitwise OR between the bits of x1
and those of x2
(equivalent to a boolean OR applied at each bit position in turn).x1 ^ x2
: Bitwise exclusive OR (XOR) between the bits of x1
and those of x2
(equivalent to a boolean XOR applied at each bit position in turn).Note that no bit inversion operator (~
in C) is provided. This is because inverting the bits of a twos-complement fixed point binary number is equivalent to simply negating it. This differs from the pure integer case because bits to the right of the binary point are also inverted. To invert only those bits to the left of the binary point, use a bitwise exclusive OR with the value -1 (i.e. x^-1
).
The following functions are available:
abs(x)
: Absolute value of x
(sign removal), same as fabs(x).acos(x)
: Inverse cosine of x
, in radians.acosd(x)
: Inverse cosine of x
, in degrees.acosh(x)
: Inverse hyperbolic cosine of x
.acoth(x)
: Inverse hyperbolic cotangent of x
.acsch(x)
: Inverse hyperbolic cosecant of x
.aint(x)
: Integer part of x
(round towards zero), same as int(x)
.asech(x)
: Inverse hyperbolic secant of x
.asin(x)
: Inverse sine of x
, in radians.asind(x)
: Inverse sine of x
, in degrees.asinh(x)
: Inverse hyperbolic sine of x
.atan(x)
: Inverse tangent of x
, in radians.atand(x)
: Inverse tangent of x
, in degrees.atanh(x)
: Inverse hyperbolic tangent of x
.atan2(x1, x2)
: Inverse tangent of x1/x2
, in radians.atan2d(x1, x2)
: Inverse tangent of x1/x2
, in degrees.ceil(x)
: Smallest integer value not less then x
(round towards plus infinity).cos(x)
: Cosine of x
in radians.cosd(x)
: Cosine of x
in degrees.cosh(x)
: Hyperbolic cosine of x
.coth(x)
: Hyperbolic cotangent of x
.csch(x)
: Hyperbolic cosecant of x
.dim(x1, x2)
: Returns x1-x2
if x1
is greater than x2
, otherwise 0.exp(x)
: Exponential function of x
.fabs(x)
: Absolute value of x
(sign removal), same as abs(x).floor(x)
: Largest integer not greater than x
(round towards minus infinity).fmod(x1, x2)
: Remainder when x1
is divided by x2
, same as mod(x1, x2).gauss(x1, x2)
: Random sample from a Gaussian distribution with mean x1
and standard deviation x2
.int(x)
: Integer part of x
(round towards 0), same as aint(x)
.isbad(x)
: Returns 1 if x
has thelog(x)
: Natural logarithm of x
.log10(x)
: Logarithm of x
to basemax(x1, x2, ...)
: Maximum of two ormin(x1, x2, ...)
: Minimum of two ormod(x1, x2)
: Remainder when x1
is divided by x2
, same as fmod(x1, x2).nint(x)
: Nearest integer to x
(round to nearest).poisson(x)
: Random integer-valued sample from a Poisson distribution with mean x
.pow(x1, x2)
: x1
raised to the power of x2
.qif(x1, x2, x3)
: Returns x2
if x1
is true, and " x3" otherwise.rand(x1, x2)
: Random sample from a uniform distribution in the range x1
to x2
inclusive.sech(x)
: Hyperbolic secant of x
.sign(x1, x2)
: Absolute value of x1
with the sign of x2
(transfer of sign).sin(x)
: Sine of x
in radians.sinc(x)
: Sinc function of x
[= " sin(x)/x" ].sind(x)
: Sine of x
in degrees.sinh(x)
: Hyperbolic sine of x
.sqr(x)
: Square of x
(= " x*x" ).sqrt(x)
: Square root of x
.tan(x)
: Tangent of x
in radians.tand(x)
: Tangent of x
in degrees.tanh(x)
: Hyperbolic tangent of x
.The following symbolic constants are available (the enclosing <>
brackets must be included):
<bad>
: The "bad" value (AST__BAD) used to flag missing data. Note that you cannot usefully compare values with this constant because the result is always <bad>
. The isbad() function should be used instead.<dig>
: Number of decimal digits of precision available in a floating point (double) value.<e>
: Base of natural logarithms.<epsilon>
: Smallest positive number such that 1.0+<epsilon>
is distinguishable from unity.<mant_dig>
: The number of base <radix>
digits stored in the mantissa of a floating point (double) value.<max>
: Maximum representable floating point (double) value.<max_10_exp>
: Maximum integer such that 10 raised to that power can be represented as a floating point (double) value.<max_exp>
: Maximum integer such that <radix>
raised to that power minus 1 can be represented as a floating point (double) value.<min>
: Smallest positive number which can be represented as a normalised floating point (double) value.<min_10_exp>
: Minimum negative integer such that 10 raised to that power can be represented as a normalised floating point (double) value.<min_exp>
: Minimum negative integer such that <radix>
raised to that power minus 1 can be represented as a normalised floating point (double) value.<pi>
: Ratio of the circumference of a circle to its diameter.<radix>
: The radix (number base) used to represent the mantissa of floating point (double) values.<rounds>
: The mode used for rounding floating point results after addition. Possible values include: -1 (indeterminate), 0 (toward zero), 1 (to nearest), 2 (toward plus infinity) and 3 (toward minus infinity). Other values indicate machine-dependent behaviour.Items appearing in expressions are evaluated in the following order (highest precedence first):
+ - ! .not.
**
*\/
+-
<< >>
< .lt. <=.le. > .gt. >=.ge.
== .eq. != .ne.
&
^
|
&& .and.
^^
|| .or.
.eqv. .neqv. .xor.
All operators associate from left-to-right, except for unary +
, unary -
, !
, .not.
and **
which associate from right-to-left.
Definition at line 375 of file MathMap.h.
|
default |
Copy constructor: make a deep copy.
|
default |
|
inlineexplicitprotected |
Construct a MathMap from a raw AST pointer.
Definition at line 415 of file MathMap.h.
|
inlineinherited |
Perform a forward transformation on a 2-D array, returning the results as a new array.
[in] | from | input coordinates, with dimensions (nPts, nIn) |
Definition at line 268 of file Mapping.h.
|
inlineinherited |
|
inlineinherited |
Perform a forward transformation on a vector, returning the results as a new vector.
[in] | from | input coordinates as a vector, with axes adjacent, e.g. x0, y0, x1, y1...xn, yn |
Definition at line 280 of file Mapping.h.
|
inlineinherited |
Perform an inverse transformation on a 2-D array, returning the results as a new 2-D array.
[in] | from | output coordinates, with dimensions (nPts, nOut) |
|
inlineinherited |
Perform an inverse transformation on a 2-D array, putting the results into a pre-allocated 2-D array.
[in] | from | input coordinates, with dimensions (nPts, nOut) |
[out] | to | transformed coordinates, with dimensions (nPts, nIn) |
|
inlineinherited |
|
inlineinherited |
Clear the values of a specified set of attributes for an Object.
Clearing an attribute cancels any value that has previously been explicitly set for it, so that the standard default attribute value will subsequently be used instead. This also causes the astTest function to return the value zero for the attribute, indicating that no value has been set.
|
inline |
Return a deep copy of this object.
Definition at line 392 of file MathMap.h.
|
inlineprotectedinherited |
|
inlineoverrideprotectedvirtual |
Return a deep copy of this object.
This is called by copy.
Each subclass must override this method. The standard implementation is:
for example Frame implements this as:
Reimplemented from ast::Mapping.
|
protectedinherited |
Return a deep copy of one of the two component mappings.
This is intended to be exposed by classes that need it (e.g. CmpMap, CmpFrame and TranMap) as operator[]
.
[in] | i | Index: 0 for the first mapping, 1 for the second |
[in] | copy | If true make a deep copy, else a shallow copy |
std::invalid_argument | if i is not 0 or 1. |
std::runtime_error | if this mapping is not a compound mapping. |
Definition at line 64 of file Mapping.cc.
|
staticinherited |
Given a bare AST object pointer return a shared pointer to an ast::Object of the correct type.
The returned object takes ownership of the pointer. This is almost always what you want, for instance astDecompose returns shallow copies of the internal pointers.
Class | The class of the returned shared pointer. (The actual class will be the correct class of rawPtr.) |
[in] | rawObj | A bare AST object pointer |
[in] | copy | If True then make a deep copy of the pointer (and free the original) |
Definition at line 138 of file Object.cc.
|
inlinestaticinherited |
|
inlineprotectedinherited |
Get the value of an attribute as a bool.
If possible, the attribute value is converted to the type you request.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
|
inlineprotectedinherited |
Get the value of an attribute as a string.
If possible, the attribute value is converted to the type you request.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
Definition at line 361 of file Object.h.
|
inlineinherited |
Get Class: the name of the class (e.g.
Note: if AST returns "CmpMap" then the name will be changed to "SeriesMap" or "ParallelMap", as appropriate.
Definition at line 139 of file Object.h.
|
inlineprotectedinherited |
Get the value of an attribute as a double.
If possible, the attribute value is converted to the type you request.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
|
inlineprotectedinherited |
Get the value of an attribute as a float.
If possible, the attribute value is converted to the type you request.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
|
inlineprotectedinherited |
Get the value of an attribute as an int.
If possible, the attribute value is converted to the type you request.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
|
inlineinherited |
Get ID: object identification string that is not copied.
Definition at line 142 of file Object.h.
|
inlineinherited |
|
inlineinherited |
Get IsLinear: is the Mapping linear?
Definition at line 100 of file Mapping.h.
|
inlineinherited |
Get IsSimple: has the mapping been simplified?
Definition at line 87 of file Mapping.h.
|
inlineprotectedinherited |
Get the value of an attribute as a long int.
If possible, the attribute value is converted to the type you request.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
|
inline |
|
inline |
|
inline |
|
inlineinherited |
|
inlineinherited |
|
inlineinherited |
Is the forward transform available?
hasForward
instead of getTranForward
for clarity, since it does not return a transform. Definition at line 114 of file Mapping.h.
|
inlineinherited |
Is the inverse transform available?
hasInverse
instead of getTranInverse
for clarity, since it does not return a transform. Definition at line 123 of file Mapping.h.
|
inherited |
Get an inverse mapping.
An inverse mapping is a deep copy of a mapping whose Invert attribute has been toggled, as indicated by isInverted. This swaps the meaning of "input" and "output", and of "forward" and "inverse". Thus it swaps the behavior of applyForward and applyInverse, getNIn and getNOut, hasForward and hasInverse and so on.
Note that the inverse mapping contains exactly the same model coefficients as the original, but they are used by applyInverse instead of applyForward. Thus for example if a ZoomMap has a zoom factor of 4.0 then its inverse also reports a zoom factor of 4.0 (despite behaving like an uninverted ZoomMap with zoom factor of 0.25).
Definition at line 41 of file Mapping.cc.
|
inlineinherited |
|
inherited |
Compute a linear approximation to the forward transformation.
[in] | lbnd | Input point defining the lower bounds of the box over which the linear approximation is computed. |
[in] | ubnd | Input point defining the upper bounds of the box over which the linear approximation is computed. |
[in] | tol | The maximum permitted deviation from linearity, expressed as apositive Cartesian displacement in the output coordinate space. If a linear fit to the forward transformation of the Mapping deviates from the true transformation by more than this amount at any point which is tested, then raise an exception. |
X_out = fit[0, 0] + fit[1, 0] X_in + fit[2, 0] Y_in Y_out = fit[0, 1] + fit[1, 1] X_in + fit[2, 1] Y_in Z_out = fit[0, 2] + fit[1, 2] X_in + fit[2, 2] Y_in
std::runtime_error | if the forward transformation cannot be modeled to within the specified tol . |
Definition at line 49 of file Mapping.cc.
|
inlineinherited |
Lock this object for exclusive use by the calling thread.
The thread-safe public interface to AST is designed so that an error is reported if any thread attempts to use an Object that it has not previously locked for its own exclusive use using this function. When an Object is created, it is initially locked by the thread that creates it, so newly created objects do not need to be explicitly locked. However, if an Object pointer is passed to another thread, the original thread must first unlock it (using astUnlock) and the new thread must then lock it (using astLock) before the new thread can use the Object.
[in] | wait | If the Object is curently locked by another thread then this function will either report an error or block. If a non-zero value is supplied for "wait", the calling thread waits until the object is available for it to use. Otherwise, an error is reported and the function returns immediately without locking the Object. |
|
inlinestaticprotectedinherited |
Functor to make an astshim instance from a raw AST pointer of the corresponding type.
ShimT | Output astshim class |
AstT | Output AST class |
|
inlineinherited |
|
inherited |
Return True if this and rhs
are the equal.
For two objects be equal, they both must have the same attributes and all contained objects must be equal.
Definition at line 85 of file Object.cc.
|
inlineinherited |
Evaluate the rate of change of the Mapping with respect to a specified input, at a specified position.
The result is estimated by interpolating the function using a fourth order polynomial in the neighbourhood of the specified position. The size of the neighbourhood used is chosen to minimise the RMS residual per unit length between the interpolating polynomial and the supplied Mapping function. This method produces good accuracy but can involve evaluating the Mapping 100 or more times.
[in] | at | The input position at which the rate of change is to be evaluated. |
[in] | ax1 | The index of the output for which the rate of change is to be found (1 for first output). |
[in] | ax2 | The index of the input which is to be varied in order to find the rate of change (1 for the first input). |
ax1
with respect to input ax2
, evaluated at at
, or nan
if the value cannot be calculated. Definition at line 215 of file Mapping.h.
|
inlineinherited |
|
inlineprotectedinherited |
Assign a set of attribute values, over-riding any previous values.
The attributes and their new values are specified via a character string, which should contain a comma-separated list of the form: "attribute_1 = value_1, attribute_2 = value_2, ... " where "attribute_n" specifies an attribute name, and the value to the right of each " =" sign should be a suitable textual representation of the value to be assigned. This value will be interpreted according to the attribute's data type.
std::runtime_error | if the attribute is read-only |
|
inlineprotectedinherited |
Set the value of an attribute as a bool.
If possible, the type you provide is converted to the actual type of the attribute.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
|
inlineprotectedinherited |
Set the value of an attribute as a string.
If possible, the type you provide is converted to the actual type of the attribute.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
|
inlineprotectedinherited |
Set the value of an attribute as a double.
If possible, the type you provide is converted to the actual type of the attribute.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
|
inlineprotectedinherited |
Set the value of an attribute as a float.
If possible, the type you provide is converted to the actual type of the attribute.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
|
inlineprotectedinherited |
Set the value of an attribute as an int.
If possible, the type you provide is converted to the actual type of the attribute.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
|
inlineinherited |
Set ID: object identification string that is not copied.
Definition at line 215 of file Object.h.
|
inlineinherited |
|
inlineprotectedinherited |
Set the value of an attribute as a long int.
If possible, the type you provide is converted to the actual type of the attribute.
std::runtime_error | if the attribute does not exist or the value cannot be converted |
|
inlineinherited |
Set Report: report transformed coordinates to stdout?
Definition at line 225 of file Mapping.h.
|
inlineinherited |
|
inherited |
|
inherited |
Print a textual description the object to an ostream.
[in,out] | os | The stream to which to write the string representation. |
[in] | showComments | Show comments? |
|
inlineinherited |
Return a simplied version of the mapping (which may be a compound Mapping such as a CmpMap).
Simplification eliminates redundant computational steps and merges separate steps which can be performed more efficiently in a single operation. As a simple example, a Mapping which multiplied coordinates by 5, and then multiplied the result by 10, could be simplified to a single step which multiplied by 50. Similarly, a Mapping which multiplied by 5, and then divided by 5, could be reduced to a simple copying operation.
This function should typically be applied to Mappings which have undergone substantial processing or have been formed by merging other Mappings. It is of potential benefit, for example, in reducing execution time if applied before using a Mapping to transform a large number of coordinates.
|
inlineinherited |
Has this attribute been explicitly set (and not subsequently cleared)?
false
.std::runtime_error | if an error results. |
Return a series compound mapping this(first(input)) containing shallow copies of the original.
[in] | next | the mapping whose input is the output of this mapping |
std::invalid_argument | if the number of input axes of next does not match the number of output axes of this mapping. |
Definition at line 37 of file Mapping.cc.
|
inlineinherited |
Transform a grid of points in the forward direction.
[in] | lbnd | The coordinates of the centre of the first pixel in the input grid along each dimension, size = nIn |
[in] | ubnd | The coordinates of the centre of the last pixel in the input grid along each dimension, size = nIn |
[in] | tol | The maximum tolerable geometrical distortion which may be introduced as a result of approximating non-linear Mappings by a set of piece-wise linear transformations. This should be expressed as a displacement within the output coordinate system of the Mapping. |
If piece-wise linear approximation is not required, a value of zero may be given. This will ensure that the Mapping is used without any approximation, but may increase execution time.
If the value is too high, discontinuities between the linear approximations used in adjacent panel will be higher. If this is a problem, reduce the tolerance value used.
[in] | maxpix | A value which specifies an initial scale size (in input grid points) for the adaptive algorithm which approximates non-linear Mappings with piece-wise linear transformations. Normally, this should be a large value (larger than any dimension of the region of the input grid being used). In this case, a first attempt to approximate the Mapping by a linear transformation will be made over the entire input region. If a smaller value is used, the input region will first be divided into sub-regions whose size does not exceed " maxpix" grid points in any dimension. Only at this point will attempts at approximation commence. This value may occasionally be useful in preventing false convergence of the adaptive algorithm in cases where the Mapping appears approximately linear on large scales, but has irregularities (e.g. holes) on smaller scales. A value of, say, 50 to 100 grid points can also be employed as a safeguard in general-purpose software, since the effect on performance is minimal. If too small a value is given, it will have the effect of inhibiting linear approximation altogether (equivalent to setting " tol" to zero). Although this may degrade performance, accurate results will still be obtained. |
[in] | to | Computed points, with dimensions (nPts, nOut), where nPts the desired number of points |
|
inlineinherited |
Transform a grid of points in the inverse direction, returning the results as a new Array2D.
See the overload of tranGridForward that outputs the data as the last argument for more information
|
inherited |
Return a parallel compound mapping containing shallow copies of the original.
The resulting mapping has getNIn() + next.getNIn()
inputs and getNOut() + next.getNOut()
outputs. The first getNIn()
axes of input are transformed by this mapping, producing the first getNOut()
axes of output. The remaining axes of input are processed by next
, resulting in the remaining axes of output.
The name comes the way vectors are sometimes shown for matrix multiplication: vertically, with the first axis at the bottom and the last axis at the top.
[in] | next | the mapping that processes the final next.getNin() axes of input to produce the final next.getNout() axes of output. |
Definition at line 39 of file Mapping.cc.
|
inlineinherited |
Unlock this object previously locked using lock, so that other threads can use this object.
See lock for further details.
[in] | report | If true, an error will be reported if the supplied Object, or any Object contained within the supplied Object, is not currently locked by the running thread. If false, such Objects will be left unchanged, and no error will be reported. |