LSST Applications g070148d5b3+33e5256705,g0d53e28543+25c8b88941,g0da5cf3356+2dd1178308,g1081da9e2a+62d12e78cb,g17e5ecfddb+7e422d6136,g1c76d35bf8+ede3a706f7,g295839609d+225697d880,g2e2c1a68ba+cc1f6f037e,g2ffcdf413f+853cd4dcde,g38293774b4+62d12e78cb,g3b44f30a73+d953f1ac34,g48ccf36440+885b902d19,g4b2f1765b6+7dedbde6d2,g5320a0a9f6+0c5d6105b6,g56b687f8c9+ede3a706f7,g5c4744a4d9+ef6ac23297,g5ffd174ac0+0c5d6105b6,g6075d09f38+66af417445,g667d525e37+2ced63db88,g670421136f+2ced63db88,g71f27ac40c+2ced63db88,g774830318a+463cbe8d1f,g7876bc68e5+1d137996f1,g7985c39107+62d12e78cb,g7fdac2220c+0fd8241c05,g96f01af41f+368e6903a7,g9ca82378b8+2ced63db88,g9d27549199+ef6ac23297,gabe93b2c52+e3573e3735,gb065e2a02a+3dfbe639da,gbc3249ced9+0c5d6105b6,gbec6a3398f+0c5d6105b6,gc9534b9d65+35b9f25267,gd01420fc67+0c5d6105b6,geee7ff78d7+a14128c129,gf63283c776+ede3a706f7,gfed783d017+0c5d6105b6,w.2022.47
LSST Data Management Base Package
|
A ChebyMap is a form of Mapping which performs a Chebyshev polynomial transformation. More...
#include <ChebyMap.h>
Public Types | |
using | ObjectPtr = std::unique_ptr< AstObject, Deleter > |
unique pointer holding an AST raw pointer More... | |
Public Member Functions | |
ChebyMap (ConstArray2D const &coeff_f, ConstArray2D const &coeff_i, std::vector< double > const &lbnd_f, std::vector< double > const &ubnd_f, std::vector< double > const &lbnd_i, std::vector< double > const &ubnd_i, std::string const &options="") | |
Construct a ChebyMap with a specified forward and/or inverse transforms. More... | |
ChebyMap (ConstArray2D const &coeff_f, int nout, std::vector< double > const &lbnd_f, std::vector< double > const &ubnd_f, std::string const &options="IterInverse=0") | |
Construct a ChebyMap with only the forward transform specified. More... | |
virtual | ~ChebyMap () |
ChebyMap (ChebyMap const &)=default | |
Copy constructor: make a deep copy. More... | |
ChebyMap (ChebyMap &&)=default | |
ChebyMap & | operator= (ChebyMap const &)=delete |
ChebyMap & | operator= (ChebyMap &&)=default |
std::shared_ptr< ChebyMap > | copy () const |
Return a deep copy of this object. More... | |
ChebyDomain | getDomain (bool forward) const |
Return the bounding box of the domain of a ChebyMap. More... | |
ChebyMap | polyTran (bool forward, double acc, double maxacc, int maxorder, std::vector< double > const &lbnd, std::vector< double > const &ubnd) const |
This function creates a new ChebyMap which is a copy of this one, in which a specified transformation (forward or inverse) has been replaced by a new Chebyshev polynomial transformation. More... | |
ChebyMap | polyTran (bool forward, double acc, double maxacc, int maxorder) const |
This method is the same as polyTran except that the bounds are those originally provided when the polynomial whose inverse is being fit was specified. 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... | |
ChebyMap (AstChebyMap *map) | |
Construct a ChebyMap from an 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 ChebyMap is a form of Mapping which performs a Chebyshev polynomial transformation.
Each output coordinate is a linear combination of Chebyshev polynomials of the first kind, of order zero up to a specified maximum order, evaluated at the input coordinates. The coefficients to be used in the linear combination are specified separately for each output coordinate.
For a 1-dimensional ChebyMap, the forward transformation is defined as follows:
f(x) = c0 T0(x') + c1 T1(x') + c2 T2(x') + ...
where:
For an N-dimensional ChebyMap, the forward transformation is a generalisation of the above form. Each output axis value is the sum of ncoeff
terms, where each term is the product of a single coefficient value and N factors of the form ‘Tn(x’_i), where
x'_i` is the normalised value of the i'th input axis value.
The forward and inverse transformations are defined independantly by separate sets of coefficients, supplied when the ChebyMap is created. If no coefficients are supplied to define the inverse transformation, the polyTran method can instead be used to create an inverse transformation. The inverse transformation so generated will be a Chebyshev polynomial with coefficients chosen to minimise the residuals left by a round trip (forward transformation followed by inverse transformation).
All those of Mapping. In addition, the forward and inverse bounds can be retrieved using getDomain
Strictly speaking, ChebyMap it has all the attributes of PolyMap, but the only attributes PolyMap adds to Mapping are iterative inverse parameters and those are ignored by ChebyMap because it does not (yet) support an iterative inverse.
Definition at line 97 of file ChebyMap.h.
|
inherited |
|
inlineexplicit |
Construct a ChebyMap with a specified forward and/or inverse transforms.
The two sets of coefficients are independent of each other: the inverse transform need not undo the forward transform.
[in] | coeff_f | A matrix of coefficients describing the forward transformation. If coeff_f is empty then no forward transformation is provided. |
[in] | coeff_i | A matrix of coefficients describing the inverse transformation. If coeff_i is empty then no inverse transformation is provided, unless you specify suitable options to request an iterative inverse; see the other constructor for details. |
[in] | lbnd_f | Lower bounds for input data; one element per input axis |
[in] | ubnd_f | Upper bounds for input data; one element per input axis |
[in] | lbnd_i | Lower bounds for output data; one element per output axis |
[in] | ubnd_i | Upper bounds for output data; one element per output axis |
[in] | options | Comma-separated list of attribute assignments. |
If a transform is not specified then the corresponding bounds are ignored (not even length-checked) and can be empty. For example if coeff_f
is empty then lbnd_f
and ubnd_f
are ignored.
std::invalid_argument | if neither transform is specified (coeff_f and coeff_i are both empty). |
std::invalid_argument | if the forward transform is specified (coeff_f is not empty) and lbnd_f or ubnd_f do not have nin elements. |
std::invalid_argument | if the inverse transform is specified (coeff_i is not empty) and lbnd_i or ubnd_i do not have nout elements. |
The coefficients describing a forward transformation are specified as 2-dimensional ndarray, with one row per coefficient. Each row contains the following consecutive (2 + nin)
values:
For example, suppose you want to make a ChebyMap with 3 inputs and 2 outputs. Then each row of coeff_f
must have 5 = 2 + nin elements. A row with values (1.2, 2, 6, 3, 0)
describes a coefficient that increments output 2 as follows:
`out2 += 1.2 * T6(in1') * T3(in2') * T0(in3')`
and a row with values (-1.5, 1, 0, 0, 0)
describes a coefficient that increments output 1 with a constant value of -1.5 (since all powers are 0):
`out1 += -1.5 * T0(in1') * T0(in2') * T0(in3')`
where inI' is the normalized value of input axis I.
The final value of each output coordinate is the sum of all values specified by coefficients which increment that output coordinate, or 0 if there are no such coefficients.
The coefficients describing the inverse transformation work the same way, of course, but each coefficient is described by (2 + nout)
values.
Definition at line 161 of file ChebyMap.h.
|
inlineexplicit |
Construct a ChebyMap with only the forward transform specified.
If the polynomial is invertible and you want an inverse can you call polyTran to fit one (at this time the iterative inverse offered by PolyMap is not available for ChebyMap).
[in] | coeff_f | A (2 + nin) x ncoeff_f matrix of coefficients describing the forward transformation. |
[in] | nout | Number of output coordinates. |
[in] | lbnd_f | Lower bounds for input data; one element per input axis |
[in] | ubnd_f | Upper bounds for input data; one element per input axis |
[in] | options | Comma-separated list of attribute assignments. |
std::invalid_argument | if the forward transform is not defined (coeff_f is empty) |
std::invalid_argument | if lbnd_f or ubnd_f do not have nin elements |
Definition at line 184 of file ChebyMap.h.
|
inlinevirtual |
Definition at line 189 of file ChebyMap.h.
|
default |
Copy constructor: make a deep copy.
|
default |
|
protected |
Construct a ChebyMap from an raw AST pointer.
Definition at line 49 of file ChebyMap.cc.
|
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 |
Perform an inverse 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 314 of file Mapping.h.
|
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.
Definition at line 119 of file Object.h.
|
inline |
Return a deep copy of this object.
Definition at line 198 of file ChebyMap.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.
Definition at line 307 of file ChebyMap.h.
|
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 |
|
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 |
ChebyDomain ast::ChebyMap::getDomain | ( | bool | forward | ) | const |
Return the bounding box of the domain of a ChebyMap.
Return the upper and lower limits of the box defining the domain of either the forward or inverse transformation of a ChebyMap. These are the values that were supplied when the ChebyMap was created.
If the requested direction was fit using polyTran, and so does not have a user-specified domain bounding box, this method returns a box determined by calling MapBox on opposite direction's transformation.
[in] | forward | If true return the domain of the forward transform, else the inverse |
std::runtime_error | if the domain cannot be computed |
Definition at line 57 of file ChebyMap.cc.
|
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 |
|
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.
ChebyMap ast::ChebyMap::polyTran | ( | bool | forward, |
double | acc, | ||
double | maxacc, | ||
int | maxorder | ||
) | const |
This method is the same as polyTran except that the bounds are those originally provided when the polynomial whose inverse is being fit was specified.
Definition at line 35 of file ChebyMap.cc.
ChebyMap ast::ChebyMap::polyTran | ( | bool | forward, |
double | acc, | ||
double | maxacc, | ||
int | maxorder, | ||
std::vector< double > const & | lbnd, | ||
std::vector< double > const & | ubnd | ||
) | const |
This function creates a new ChebyMap which is a copy of this one, in which a specified transformation (forward or inverse) has been replaced by a new Chebyshev polynomial transformation.
The coefficients of the new transformation are estimated by sampling the other transformation and performing a least squares polynomial fit in the opposite direction to the sampled positions and values.
This method can only be used on (1-input,1-output) or (2-input, 2-output) ChebyMaps.
[in] | forward | If true the forward transformation is replaced. Otherwise the inverse transformation is replaced. |
[in] | acc | The target accuracy, expressed as a geodesic distance within the ChebyMap's input space (if forward is false) or output space (if forward is true). |
[in] | maxacc | The maximum allowed accuracy for an acceptable polynomial, expressed as a geodesic distance within the ChebyMap's input space (if forward is false) or output space (if forward is true). |
[in] | maxorder | The maximum allowed polynomial order. This is one more than the maximum power of either input axis. So for instance, a value of 3 refers to a quadratic polynomial. Note, cross terms with total powers greater than or equal to maxorder are not inlcuded in the fit. So the maximum number of terms in each of the fitted polynomials is maxorder*(maxorder + 1)/2. |
[in] | lbnd | A vector holding the lower bounds of a rectangular region within the ChebyMap's input space (if forward is false) or output space (if forward is true). If both lbnd and ubnd are empty (the default) then they will be estimated. The new polynomial will be evaluated over this rectangle. The length should equal getNIn() or getNOut(), depending on forward . |
[in] | ubnd | A vector holding the upper bounds of a rectangular region within the ChebyMap's input space (if forward is false) or output space (if forward is true). If both lbnd and ubnd are empty (the default) then they will be estimated. The new polynomial will be evaluated over this rectangle. The length should equal getNIn() or getNOut(), depending on forward . |
std::invalid_argument | if the size of lbnd or ubnd does not match getNIn() (if forward false) or getNOut() (if forward true). |
The variant that takes omits the lbnd
and ubnd
arguments uses the full domain of the polynomial whose inverse is being fit.
The transformation to create is specified by the forward
parameter. In what follows "X" refers to the inputs of the ChebyMap, and "Y" to the outputs of the ChebyMap. The forward transformation transforms input values (X) into output values (Y), and the inverse transformation transforms output values (Y) into input values (X). Within a ChebyMap, each transformation is represented by an independent set of polynomials, P_f or P_i: Y=P_f(X) for the forward transformation and X=P_i(Y) for the inverse transformation.
The forward
parameter specifies the transformation to be replaced. If it is true, a new forward transformation is created by first finding the input values (X) using the inverse transformation (which must be available) at a regular grid of points (Y) covering a rectangular region of the ChebyMap's output space. The coefficients of the required forward polynomial, Y=P_f(X), are chosen in order to minimise the sum of the squared residuals between the sampled values of Y and P_f(X).
If forward
is false (probably the most likely case), a new inverse transformation is created by first finding the output values (Y) using the forward transformation (which must be available) at a regular grid of points (X) covering a rectangular region of the ChebyMap's input space. The coefficients of the required inverse polynomial, X=P_i(Y), are chosen in order to minimise the sum of the squared residuals between the sampled values of X and P_i(Y).
This fitting process is performed repeatedly with increasing polynomial orders (starting with linear) until the target accuracy is achieved, or a specified maximum order is reached. If the target accuracy cannot be achieved even with this maximum-order polynomial, the best fitting maximum-order polynomial is returned so long as its accuracy is better than "maxacc". If it is not, an error is reported.
Definition at line 30 of file ChebyMap.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.
|
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? |
Definition at line 158 of file Object.cc.
|
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. |
|
friend |
Definition at line 98 of file ChebyMap.h.