diff --git a/docs/c-library-bugs.md b/docs/c-library-bugs.md index bea9ff8..25bfc33 100644 --- a/docs/c-library-bugs.md +++ b/docs/c-library-bugs.md @@ -20,6 +20,13 @@ An entry is removed when an upstream commit fixes the bug; the commit that remov - [Two equal 1-D SelectorMaps in series simplify to a UnitMap](#two-equal-1-d-selectormaps-in-series-simplify-to-a-unitmap) - [Reading a `-TAB` header whose table is missing annuls a UnitMap twice](#reading-a--tab-header-whose-table-is-missing-annuls-a-unitmap-twice) - [SwitchMap converts selector values outside the `int` range to `int`](#switchmap-converts-selector-values-outside-the-int-range-to-int) +- [A UnitNormMap with a bad centre writes outside its output](#a-unitnormmap-with-a-bad-centre-writes-outside-its-output) +- [An XphMap accepts positions up to a facet left of or below its grid](#an-xphmap-accepts-positions-up-to-a-facet-left-of-or-below-its-grid) +- [A ChebyMap cancels with a PolyMap of the same coefficients](#a-chebymap-cancels-with-a-polymap-of-the-same-coefficients) +- [`astChebyDomain` of an inverted ChebyMap with different numbers of inputs and outputs](#astchebydomain-of-an-inverted-chebymap-with-different-numbers-of-inputs-and-outputs) +- [A ChebyMap is written as SIP coefficients of powers](#a-chebymap-is-written-as-sip-coefficients-of-powers) +- [Simplifying a CmpMap changes the Invert attribute of a component it holds](#simplifying-a-cmpmap-changes-the-invert-attribute-of-a-component-it-holds) +- [Comparing two CmpMaps that share a component gives a wrong answer and changes the component](#comparing-two-cmpmaps-that-share-a-component-gives-a-wrong-answer-and-changes-the-component) - [C quirks recorded with the differences from Rust](#c-quirks-recorded-with-the-differences-from-rust) ## Open @@ -121,6 +128,80 @@ An entry is removed when an upstream commit fixes the bug; the commit that remov - Rust: its quirks file has the same bug ("SwitchMap converts its selector to `int` without a range check"); the Rust port compares the rounded value with the route range before converting. - Reproducer: `switchmap_selector`: `switchmap.c:1737:22: runtime error: -1e+30 is outside the range of representable values of type 'int'` and `switchmap.c:1737:45: runtime error: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'`, and the same pairs at 1796, 1815 and 499. +### A UnitNormMap with a bad centre writes outside its output + +- C location: `unitnormmap.c` `Transform`, whose branch for a centre with a bad coordinate sets `ptr_out[ point ][ coord_out ] = AST__BAD` at 1017 (1025 at `1d0714fb`). +- What happens: the indices are exchanged, the first of `ptr_out` being the coordinate and the second the point, so the loop over every point and output coordinate reads row pointers beyond the last output coordinate when there are more points than output coordinates, and writes beyond the end of a coordinate's array when there are more output coordinates than points. +- Consequence: a UnitNormMap whose centre holds `AST__BAD` (which the public constructor accepts, and which a null centre gives) corrupts memory or crashes when it transforms a number of points other than its number of outputs; when the numbers are equal it does make every output bad, as the code means to. +- Java: every output of every point is bad (`UnitNormMap.transformInto`); `docs/rust-c-differences.md`, "A UnitNormMap with a bad centre". +- Rust: its `docs/audits/mapping-c-parity.md` notes "C's bad-center branch indexes `ptr_out[point][coord]`, a C defect", not its quirks file; the Rust port makes every output bad. +- Reproducer: `unitnormmap_bad_centre` (a 1-D UnitNormMap with a bad centre transforming three points): `AddressSanitizer: heap-buffer-overflow ... READ of size 8 ... in Transform unitnormmap.c:1017`. + +### An XphMap accepts positions up to a facet left of or below its grid + +- C location: `xphmap.c` `Transform`, whose facet indices `fx = ix/nppf` and `fy = iy/nppf` are at 759, 808, 1032, 1081, 1134 and 1191 (`fx = trunc( ix/nppf )` at 783, 832, 1056, 1105, 1158 and 1215 at `1d0714fb`), in the HPX12 and HPX0 forward transformations and every inverse transformation. +- What happens: the zero-based cell indices `ix = ceil( x - 1.5 )` and `iy = ceil( y - 1.5 )` are divided by the facet size `nppf` rounding towards zero, so a cell index from `-(nppf - 1)` to -1, which is outside the grid, gives facet index 0 and passes the test that the facet indices are those of the HPX layout; the position is then accepted wherever the sum of its cell indices is in the used part of the layout. + At `1d0714fb` the indices are doubles but are still rounded towards zero with `trunc`, and a comment there says this is relied on: the Moc class can place a sky position on the lower edge of an HPX12 grid marginally outside it by rounding errors. +- Consequence: a position up to `nppf - 1` cells left of or below the grid is transformed as if it were on the grid rather than made bad: at order 1, (0, 4) is copied by an HPX12 XphMap and moved to (4, 8) by an HPX0 one, and at order 2 (-2, 8.5), three cells left of the grid, is copied (oracle `src/test/resources/oracle/xphmap.json`, from the Rust repository's `xphmap_probe.c`, holds the order 1 values). + A position on the other sides of the grid, or a full facet or more outside it, is bad, so the accepted margin depends on the order and on which side of the grid the position lies. +- Java: as C (`XphMap.hpxCellSum`, `XphMapTest.positionsUpToAFacetOffTheGridAreAccepted`). +- Rust: as C (`xphmap.rs`, `hpx_cell`, integer division of `i64`); not in its quirks file. +- Reproducer: `xphmap_off_grid` (order 1 HPX12 and HPX0 forward at (0, 4); order 2 HPX12 forward at (-2, 8.5) and at (-3, 8.5), one cell further out, which is bad): `order 1 HPX12 forward 0 4 -> 0 4`, `order 1 HPX0 forward 0 4 -> 4 8`, `order 2 HPX12 forward -2 8.5 -> -2 8.5`. + +### A ChebyMap cancels with a PolyMap of the same coefficients + +- C location: `chebymap.c` `Equal` (413; 413), which calls PolyMap's `Equal` at 468 (468) and compares the bounding boxes only `if( astIsAChebyMap( that ) )` at 478 (478); `polymap.c` `Equal` (638; 658), which accepts any `that` for which `astIsAPolyMap` holds at 699 (719); and `polymap.c` `MapMerge` (3449; 3476), which takes every neighbour that is a PolyMap at 3953 (3980) and cancels it with the nominated one when `astEqual` holds at 3973 (4000). +- What happens: a ChebyMap is a PolyMap, so `MapMerge` offers a ChebyMap and a PolyMap applied in opposite directions to `astEqual`, and both classes' `Equal` compare only the coefficients when the two classes differ: a ChebyMap's Chebyshev coefficients are compared with the PolyMap's coefficients of powers, and the ChebyMap's bounding box is not compared at all. +- Consequence: simplifying changes the transformation: the ChebyMap 1 + T1(x') + 0.5 T2(x') over [0, 10] followed by the inverse of the PolyMap 1 + x + 0.5 x^2 maps 0 to -0.96875, and the UnitMap it simplifies to maps 0 to 0; with the PolyMap first it simplifies to a UnitMap too. +- Java: as C (`ChebyMap.equalTo`, `PolyMap.equalTo`, `ChebyMapProbeTest.cancelsWithAPolyMapOfTheSameCoefficients`); `docs/rust-c-differences.md`, "A ChebyMap compared with a PolyMap". +- Rust: `ChebyMap::equal` compares only with another ChebyMap, so the pair does not merge; not in its quirks file. +- Reproducer: `chebymap_polymap_cancel`: `equal 1 1`, `simplified class UnitMap`, `x 0: pair -0.96875 simplified 0`, and `reversed simplified class UnitMap`. + +### `astChebyDomain` of an inverted ChebyMap with different numbers of inputs and outputs + +- C location: `chebymap.c` `ChebyDomain` (245; 245), which takes the number of axes from the ChebyMap as it stands, `astGetNin( this )` at 342 and `astGetNout( this )` at 350 (the same at `1d0714fb`), and the box from the ChebyMap as created, chosen by `forward != astGetInvert( this )`; the box is read at 358 to 367 and mapped by `astMapBox` at 394. +- What happens: for an inverted ChebyMap the box chosen belongs to the other space, so the number of axes is that of the wrong space: the box is read for as many axes as the inverted ChebyMap has inputs (forward) or outputs (inverse), which is the number of axes of the other box. +- Consequence: for ChebyMap(1, 2) with both boxes, inverted, the forward domain fills one of the caller's two bounds and leaves the other unwritten, and the inverse domain reads two values of the one-axis forward box, beyond its end; without the requested box, `astMapBox` is asked for outputs that do not exist (AST__BADCI) or fewer than there are. + A ChebyMap with as many inputs as outputs, or not inverted, is not affected. +- Java: `chebyDomain` returns, for each direction and Invert value, the box C chooses with that box's own number of axes, which is the number of inputs (forward) or outputs (inverse) of the ChebyMap as it stands (`ChebyMapProbeTest.givesTheDomainsWithUnequalAxes`); `docs/rust-c-differences.md`, "`astChebyDomain` of an inverted ChebyMap with different numbers of inputs and outputs". +- Rust: returns a stored box with its own number of axes; without the requested box it takes the number of axes from the ChebyMap as it stands, as C does, and gives bad bounds where `map_box` fails; not in its quirks file. +- Reproducer: `chebymap_inverted_domain`: `forward 1 axes 2: -1 -77 : 1 -77` (one bound of two written), then `AddressSanitizer: heap-buffer-overflow ... READ of size 8 ... in ChebyDomain chebymap.c:360`; built without the sanitisers it goes on to `astMapBox(ChebyMap): Output coordinate index (2) invalid - it should be in the range 1 to 1.` for the forward-only ChebyMap(2, 1), inverted. + +### A ChebyMap is written as SIP coefficients of powers + +- C location: `fitschan.c` `SIPIntWorld` (28888; 29547), which takes the first Mapping for which `astIsAPolyMap` holds at 29112 (29771), a ChebyMap among them; `ScalePolyInputs` (27289; 27864), called at 29215 (29874), which rebuilds it with `astPolyMap` from the coefficients `astPolyCoeffs` gives; and `AnalysePoly` (4402; 4523), called at 29226 (29885), which gives up for a Mapping without an iterative inverse at 4509 (4630) while `SIPIntWorld` goes on. +- What happens: a ChebyMap's coefficients, which multiply Chebyshev polynomials of its inputs normalised to its bounding box, are taken as coefficients of powers of the pixel offsets and written as SIP's A, B, AP and BP coefficients. +- Consequence: the header does not describe the FrameSet: a ChebyMap u = 50 T1(x/50) + 5 T2(x/50), v = 50 T1(y/50) + 3 T2(y/50) over [-50, 50] in a TAN FrameSet is written with `A_1_0 = 49` and `A_2_0 = 5`, and reading the header back maps pixel (1, 1) to (2.005, 1.507) where the FrameSet gives (-0.765, 1.570). + The same FrameSet with a MathMap of the same transformation in place of the ChebyMap is not written at all (the reproducer's last line). +- Java: a ChebyMap is passed over when looking for the SIP polynomial (`FitsSipIntWorld.sipIntWorld`), so it is never written as SIP coefficients; with no other PolyMap the FrameSet is not written, as C does for the MathMap (`FitsSipIntWorldTest.aChebyMapIsNotWrittenAsSip`), and a plain PolyMap later in the Mapping, which C would not reach, is taken instead; `docs/rust-c-differences.md`, "A ChebyMap in a FrameSet written as SIP". +- Rust: `sip_int_world.rs` takes only a PolyMap, so a ChebyMap is passed over, as in Java; not in its quirks file. +- Reproducer: `chebymap_sip`: `written 1`, `A_1_0 = 49.0`, `A_2_0 = 5.0`, and `pixel 1 1: FrameSet -0.7650817839 1.570485557 header 2.005209305 1.507388147`; with the MathMap, `MathMap written 0 ncard 2 status 0`. + +### Simplifying a CmpMap changes the Invert attribute of a component it holds + +- C location: `splinemap.c` `MapMerge` (1620; 1786), which sets the nominated SplineMap's Invert attribute to the value the merge list applies it with at 1783 (1949), annuls its pointer when the SplineMap cancels with its neighbour at 1829 (1995), and sets the attribute back only when it did not, at 1851 (2017); `dssmap.c` `MapMerge` (845; 863), which does the same to the WinMap it absorbs: it sets the WinMap's attribute at 1021 (1039), annuls its pointer when the two merge at 1110 (1130), and sets the attribute back only when they did not, at 1138 (1158). + The list is built by `cmpmap.c` `MapList` (1208; 1239) from the clones of the components that `mapping.c` `MapList` (7541; 7662) gives, so the Mapping in it is the CmpMap's own. + `polymap.c` `MapMerge` (3449) did the same to a PolyMap cancelled with its inverse, annulling it at 3984 before setting it back at 4006; `1d0714fb` sets it back first (4013), so that case is fixed there. +- What happens: the merge list of an inverted CmpMap applies each component with the opposite of its own Invert value; when such a SplineMap cancels with its inverse, or such a WinMap is absorbed into a DssMap, the component is left with the list's value. + Each Invert attribute that is set back is set back with `astSetInvert`, so one that was unset is left set to the value it had. +- Consequence: simplifying the inverse of a series CmpMap of a SplineMap and the inverse of an equal SplineMap b gives a UnitMap, as it should, but leaves b, which the caller may hold and use elsewhere, with Invert 0 where it was 1, so that it then transforms in the other direction; simplifying the inverse of a series CmpMap of an inverted DssMap and an inverted WinMap w does the same to w. + The CmpMap itself is unaffected, since it applies each component with the Invert value it recorded. +- Java: sets each Invert attribute back as it was, set or unset, whether or not the Mappings merge, so a Mapping the caller holds is unchanged (`Mapping.cancelWithOppositeNeighbour`, used by `SplineMap.mapMerge` and `PolyMap.mapMerge`, and `DssMap.mapMerge`; `SplineMapProbeTest.simplifyingAnInvertedCmpMapLeavesTheSplineMapsAsTheyWere`, `DssMapTest.aMergeLeavesTheWinmapAsItWas`, `PolyMapTest.simplifyingLeavesThePolymapsAsTheyWere`); the simplified Mapping is C's; `docs/rust-c-differences.md`, "SplineMap merges change Invert attributes", "A DssMap merge leaves the WinMap's Invert attribute changed" and "Cancelling a PolyMap with its inverse". +- Rust: compares or reads the Mappings in the list's orientations without changing them; not in its quirks file. +- Reproducer: `merge_invert`: `before: b Invert 1, b forward (0.5, 0.6) -> (0.25, 0.2)`, `simplified class UnitMap`, `after: b Invert 0, b forward (0.5, 0.6) -> (1, 1.8)`, then `before: w Invert 1, w forward (1, 1) -> (0.75, 0.75)`, `simplified class DssMap`, `after: w Invert 0, w forward (1, 1) -> (1.5, 1.5)`. + +### Comparing two CmpMaps that share a component gives a wrong answer and changes the component + +- C location: `cmpmap.c` `Equal` (458; 489), whose comparison without its expanded lists sets each component's Invert attribute to the value its list gives at 590 to 593 (621 to 624), calls `astEqual`, and sets the attributes back at 599 and 600 (630 and 631); `object.c` `astEqual_` (6045; 6146), which returns 1 when the two pointers are equal before calling any class's `Equal` (6047; 6148). +- What happens: when the two CmpMaps hold the same object at the same place, `astEqual` is given that object twice and returns 1, whatever Invert values the two lists apply it with. + The attribute is then set back first to the value saved for the first list and then to the value saved for the second, which is the one just set for the first, so the object is left with the first list's value, and set where it may have been unset. +- Consequence: two CmpMaps that transform differently compare equal: a series CmpMap of a ZoomMap and a UnitMap equals the one made from the same ZoomMap while it was inverted, though one doubles and the other halves. + The shared component, which the caller may hold, is left with its Invert attribute set; when the lists apply it with different values, it is left with the first list's, so it then transforms in the other direction. + `Simplify` (`cmpmap.c`) compares CmpMaps this way, so simplifying `simplify/brad.map` changes the Invert attribute of its WcsMap from 1 to 0; the simplified Mapping transforms correctly, since a CmpMap applies each component with the Invert value it recorded. +- Java: as C, in both effects (`CmpMap.equalTo`, `AstObject.equals`); `brad.simp` records C's changed attribute; `docs/rust-c-differences.md`, "A CmpMap comparison changes a shared component's Invert attribute". +- Rust: compares owned copies in their list orientations, so nothing changes; not in its quirks file. +- Reproducer: `cmpmap_equal_shared`: `before: c1(1) = 2, c2(1) = 0.5, a Invert 0, set 0`, `astEqual(c1, c2) = 1`, `after: a Invert 0, set 1`. + ## C quirks recorded with the differences from Rust [`rust-c-differences.md`](rust-c-differences.md) is the other half of this record: its entries marked **C quirk** or **C bug** describe C behaviour that is at fault and that the Java port follows, or departs from, with what C, Rust and Java each do. diff --git a/docs/c-library-bugs/README.md b/docs/c-library-bugs/README.md index f9289f0..68ab000 100644 --- a/docs/c-library-bugs/README.md +++ b/docs/c-library-bugs/README.md @@ -13,6 +13,13 @@ Each program here reproduces one or more entries of [`../c-library-bugs.md`](../ | `selectormap_merge` | none | Two equal 1-D SelectorMaps in series simplify to a UnitMap | | `tab_missing_table` | none, or `first` | Reading a `-TAB` header whose table is missing annuls a UnitMap twice | | `switchmap_selector` | none | SwitchMap converts selector values outside the `int` range to `int` | +| `unitnormmap_bad_centre` | none | A UnitNormMap with a bad centre writes outside its output | +| `xphmap_off_grid` | none | An XphMap accepts positions up to a facet left of or below its grid | +| `chebymap_polymap_cancel` | none | A ChebyMap cancels with a PolyMap of the same coefficients | +| `chebymap_inverted_domain` | none | `astChebyDomain` of an inverted ChebyMap with different numbers of inputs and outputs | +| `chebymap_sip` | none | A ChebyMap is written as SIP coefficients of powers | +| `merge_invert` | none | Simplifying a CmpMap changes the Invert attribute of a component it holds | +| `cmpmap_equal_shared` | none | Comparing two CmpMaps that share a component gives a wrong answer and changes the component | `resample_rebin` reads the cases of a file, one per line; its header comment describes the fields. diff --git a/docs/c-library-bugs/chebymap_inverted_domain.c b/docs/c-library-bugs/chebymap_inverted_domain.c new file mode 100644 index 0000000..957966b --- /dev/null +++ b/docs/c-library-bugs/chebymap_inverted_domain.c @@ -0,0 +1,51 @@ +/* chebymap_inverted_domain: astChebyDomain of an inverted ChebyMap with + different numbers of inputs and outputs. ChebyDomain chooses the box + of the ChebyMap as created that the requested direction of the inverted + ChebyMap uses, but takes its number of axes from the inverted ChebyMap + (astGetNin for one branch and astGetNout for the other) where it should + take that of the box. For ChebyMap(1, 2) with both boxes, inverted, + forward gives one bound where the box and the caller's arrays have two, + and inverse reads two values of the one-axis forward box, beyond its + end. For a forward-only ChebyMap(2, 1), inverted, forward asks + astMapBox for output 2 of a Mapping with one, and fails with + AST__BADCI. The arrays are filled with -77 first, so an unwritten + bound shows as -77. */ +#include +#include "ast.h" + +static void domain( AstChebyMap *c, int forward ) { + double lb[ 2 ] = { -77, -77 }, ub[ 2 ] = { -77, -77 }; + int n = astGetI( c, forward ? "Nin" : "Nout" ); + astChebyDomain( c, forward, lb, ub ); + printf( "forward %d axes %d: %g %g : %g %g status %d\n", forward, n, lb[ 0 ], lb[ 1 ], + ub[ 0 ], ub[ 1 ], astStatus ); + astClearStatus; +} + +int main( void ) { + int status = 0; + double fc[] = { 1.0, 1, 1, 2.0, 2, 1 }; + double ic[] = { 1.0, 1, 1, 0 }; + double flb[] = { 0 }, fub[] = { 10 }, ilb[] = { -1, -2 }, iub[] = { 1, 2 }; + double fc2[] = { 1.0, 1, 1, 0, 1.0, 1, 0, 1 }; + double lb2[] = { 0, 0 }, ub2[] = { 1, 1 }; + astWatch( &status ); + setvbuf( stdout, NULL, _IONBF, 0 ); + AstChebyMap *c = astChebyMap( 1, 2, 2, fc, 1, ic, flb, fub, ilb, iub, " " ); + printf( "ChebyMap(1, 2), both boxes\n" ); + domain( c, 1 ); + domain( c, 0 ); + astInvert( c ); + printf( "inverted\n" ); + domain( c, 1 ); + domain( c, 0 ); + AstChebyMap *d = astChebyMap( 2, 1, 2, fc2, 0, NULL, lb2, ub2, NULL, NULL, " " ); + printf( "ChebyMap(2, 1), forward box only\n" ); + domain( d, 1 ); + domain( d, 0 ); + astInvert( d ); + printf( "inverted\n" ); + domain( d, 1 ); + domain( d, 0 ); + return 0; +} diff --git a/docs/c-library-bugs/chebymap_polymap_cancel.c b/docs/c-library-bugs/chebymap_polymap_cancel.c new file mode 100644 index 0000000..2d9bc1b --- /dev/null +++ b/docs/c-library-bugs/chebymap_polymap_cancel.c @@ -0,0 +1,38 @@ +/* chebymap_polymap_cancel: a ChebyMap followed by an inverted PolyMap with + the same coefficients simplifies to a UnitMap. PolyMap's MapMerge + cancels a PolyMap with a neighbouring PolyMap applied the other way when + astEqual finds them equal, and a ChebyMap is a PolyMap. ChebyMap's Equal + calls PolyMap's, which compares only the coefficients, and compares the + bounding boxes only when the second Object is a ChebyMap too, so the + ChebyMap 1 + T1(x') + 0.5 T2(x') over [0, 10] and the PolyMap + 1 + x + 0.5 x^2 are equal, and the pair, which maps 0 to -0.96875, is + replaced by a UnitMap, which maps 0 to 0. The other order, the PolyMap + nominated first, is replaced too. */ +#include +#include "ast.h" + +int main( void ) { + int status = 0; + double c[] = { 1.0, 1, 0, 1.0, 1, 1, 0.5, 1, 2 }; + double lb = 0.0, ub = 10.0; + double x[ 3 ] = { 0.0, 5.0, 10.0 }, y[ 3 ], z[ 3 ]; + astWatch( &status ); + AstChebyMap *cm = astChebyMap( 1, 1, 3, c, 0, NULL, &lb, &ub, NULL, NULL, " " ); + AstPolyMap *pm = astPolyMap( 1, 1, 3, c, 0, NULL, " " ); + printf( "equal %d %d\n", astEqual( cm, pm ), astEqual( pm, cm ) ); + astInvert( pm ); + AstMapping *pair = (AstMapping *) astCmpMap( cm, pm, 1, " " ); + AstMapping *simp = astSimplify( pair ); + printf( "simplified class %s\n", astGetC( simp, "Class" ) ); + astTran1( pair, 3, x, 1, y ); + astTran1( simp, 3, x, 1, z ); + for( int i = 0; i < 3; i++ ) { + printf( "x %.17g: pair %.17g simplified %.17g\n", x[ i ], y[ i ], z[ i ] ); + } + astInvert( pm ); + astInvert( cm ); + simp = astSimplify( astCmpMap( pm, cm, 1, " " ) ); + printf( "reversed simplified class %s\n", astGetC( simp, "Class" ) ); + printf( "status %d\n", status ); + return 0; +} diff --git a/docs/c-library-bugs/chebymap_sip.c b/docs/c-library-bugs/chebymap_sip.c new file mode 100644 index 0000000..35b7918 --- /dev/null +++ b/docs/c-library-bugs/chebymap_sip.c @@ -0,0 +1,68 @@ +/* chebymap_sip: a FrameSet whose pixel to sky Mapping holds a ChebyMap is + written as a FITS-WCS SIP header that does not describe it. SIPIntWorld + takes the first Mapping for which astIsAPolyMap holds, and a ChebyMap is + a PolyMap; AnalysePoly, which needs an iterative inverse, gives up, but + SIPIntWorld goes on and stores the coefficients astPolyCoeffs gives, so + the Chebyshev coefficients of the ChebyMap, which apply to the inputs + normalised to its bounding box, are written as SIP's coefficients of + powers of the pixel offsets. The ChebyMap here is + u = 50 T1(x/50) + 5 T2(x/50), v = 50 T1(y/50) + 3 T2(y/50) over + [-50, 50], that is u = x + 5 (2 (x/50)^2 - 1); the header has + A_1_0 = 49 and A_2_0 = 5 where u - x = 0.004 x^2 - 5. Reading the + header back gives sky positions far from the FrameSet's. The same + FrameSet with a MathMap of the same transformation in place of the + ChebyMap is not written at all (the last line, "MathMap written 0"). */ +#include +#include "ast.h" + +int main( void ) { + int status = 0; + double fc[] = { 50.0, 1, 1, 0, 5.0, 1, 2, 0, 50.0, 2, 0, 1, 3.0, 2, 0, 2 }; + double ic[] = { 50.0, 1, 1, 0, -5.0, 1, 2, 0, 50.0, 2, 0, 1, -3.0, 2, 0, 2 }; + double flb[] = { -50, -50 }, fub[] = { 50, 50 }, ilb[] = { -60, -60 }, iub[] = { 60, 60 }; + double sh[] = { -50, -50 }; + double x[ 2 ] = { 1.0, 90.0 }, y[ 2 ] = { 1.0, 30.0 }, a[ 2 ], b[ 2 ], c[ 2 ], d[ 2 ]; + char card[ 81 ]; + astWatch( &status ); + AstChebyMap *cm = astChebyMap( 2, 2, 4, fc, 4, ic, flb, fub, ilb, iub, " " ); + AstMapping *shift = (AstMapping *) astShiftMap( 2, sh, " " ); + AstMapping *zoom = (AstMapping *) astZoomMap( 2, 1.0/3600*AST__DD2R, " " ); + AstWcsMap *tan = astWcsMap( 2, AST__TAN, 1, 2, " " ); + astInvert( tan ); + AstMapping *m = (AstMapping *) astCmpMap( astCmpMap( astCmpMap( shift, cm, 1, " " ), zoom, 1, " " ), + tan, 1, " " ); + AstFrameSet *fs = astFrameSet( astFrame( 2, " " ), " " ); + astAddFrame( fs, AST__BASE, m, astSkyFrame( " " ) ); + AstFitsChan *fch = astFitsChan( NULL, NULL, " " ); + astPutFits( fch, "NAXIS1 = 100", 0 ); + astPutFits( fch, "NAXIS2 = 100", 0 ); + astSet( fch, "Encoding=FITS-WCS" ); + printf( "written %d\n", astWrite( fch, fs ) ); + astClear( fch, "Card" ); + while( astFindFits( fch, "%f", card, 1 ) ) { + if( card[ 0 ] == 'A' || card[ 0 ] == 'B' || card[ 0 ] == 'C' ) printf( "%.30s\n", card ); + } + astClear( fch, "Card" ); + AstFrameSet *back = astRead( fch ); + astTran2( fs, 2, x, y, 1, a, b ); + astTran2( back, 2, x, y, 1, c, d ); + for( int i = 0; i < 2; i++ ) { + printf( "pixel %g %g: FrameSet %.10g %.10g header %.10g %.10g\n", x[ i ], y[ i ], a[ i ], b[ i ], + c[ i ], d[ i ] ); + } + printf( "status %d\n", status ); + + const char *fwd[] = { "u = x + 5*(2*(x/50)*(x/50) - 1)", "v = y + 3*(2*(y/50)*(y/50) - 1)" }; + const char *inv[] = { "x = u", "y = v" }; + AstMapping *mm = (AstMapping *) astMathMap( 2, 2, 2, fwd, 2, inv, " " ); + m = (AstMapping *) astCmpMap( astCmpMap( astCmpMap( shift, mm, 1, " " ), zoom, 1, " " ), tan, 1, " " ); + fs = astFrameSet( astFrame( 2, " " ), " " ); + astAddFrame( fs, AST__BASE, m, astSkyFrame( " " ) ); + fch = astFitsChan( NULL, NULL, " " ); + astPutFits( fch, "NAXIS1 = 100", 0 ); + astPutFits( fch, "NAXIS2 = 100", 0 ); + astSet( fch, "Encoding=FITS-WCS" ); + int written = astWrite( fch, fs ); + printf( "MathMap written %d ncard %d status %d\n", written, astGetI( fch, "Ncard" ), status ); + return 0; +} diff --git a/docs/c-library-bugs/cmpmap_equal_shared.c b/docs/c-library-bugs/cmpmap_equal_shared.c new file mode 100644 index 0000000..6bf6f64 --- /dev/null +++ b/docs/c-library-bugs/cmpmap_equal_shared.c @@ -0,0 +1,45 @@ +/* cmpmap_equal_shared: comparing two CmpMaps that hold the same component + object gives a wrong answer and changes that object. CmpMap's Equal + (cmpmap.c), without its expanded lists, sets each component's Invert + attribute to the value its list gives, calls astEqual, and sets the + attributes back in the same order. When the two components are one + object, astEqual (object.c) returns 1 at once, whatever Invert values + the two lists apply it with, and the object is left with the first + list's value, set where it may have been unset. + + c1 is the series CmpMap of a ZoomMap a (factor 2) and a UnitMap; c2 is + the same with a inverted when c2 was made, so c1 doubles and c2 halves. + a is inverted back before the comparison. */ +#include +#include "ast.h" + +int main( void ) { + AstZoomMap *a; + AstUnitMap *u; + AstCmpMap *c1, *c2; + double in = 1.0, out1, out2; + int equal; + + astBegin; + a = astZoomMap( 1, 2.0, " " ); + u = astUnitMap( 1, " " ); + c1 = astCmpMap( a, u, 1, " " ); + astInvert( a ); + c2 = astCmpMap( a, u, 1, " " ); + astInvert( a ); + astClear( a, "Invert" ); + + astTran1( c1, 1, &in, 1, &out1 ); + astTran1( c2, 1, &in, 1, &out2 ); + printf( "before: c1(1) = %g, c2(1) = %g, a Invert %d, set %d\n", out1, out2, + astGetI( a, "Invert" ), astTest( a, "Invert" ) ); + + equal = astEqual( c1, c2 ); + printf( "astEqual(c1, c2) = %d\n", equal ); + printf( "after: a Invert %d, set %d\n", astGetI( a, "Invert" ), + astTest( a, "Invert" ) ); + + astEnd; + printf( "status %d\n", astOK ? 0 : astStatus ); + return 0; +} diff --git a/docs/c-library-bugs/merge_invert.c b/docs/c-library-bugs/merge_invert.c new file mode 100644 index 0000000..ad00f0f --- /dev/null +++ b/docs/c-library-bugs/merge_invert.c @@ -0,0 +1,116 @@ +/* merge_invert: simplifying a CmpMap changes the Invert attribute of a + component Mapping the caller holds. The merge list of an inverted + CmpMap applies each component with the opposite of its own Invert + value. SplineMap's MapMerge (splinemap.c) sets the nominated + SplineMap's Invert attribute to the list's value and annuls its pointer + without setting it back when the SplineMap cancels with its inverse; + DssMap's MapMerge (dssmap.c) does the same to a WinMap it absorbs. The + list holds clones, so the caller's Mapping itself is changed. + + SplineMap: the inverse of the series CmpMap of a SplineMap and the + inverse of an equal SplineMap b, simplified, leaves b with Invert 0. + The SplineMap is u = 2x, v = 3y over the unit square + (testsplinemap_c.c). + + DssMap: the inverse of the series CmpMap of an inverted DssMap and an + inverted WinMap w, simplified, leaves w with Invert 0. The DssMap is + the plate solution of ast_tester's serialisation/c_dssmap.ast, with + whole pixel offsets so that the WinMap can be absorbed. */ +#include +#include "ast.h" + +static void show( const char *when, const char *name, AstMapping *m, double x, double y ) { + double u, v; + astTran2( m, 1, &x, &y, 1, &u, &v ); + printf( "%s: %s Invert %d, %s forward (%g, %g) -> (%g, %g)\n", when, name, + astGetI( m, "Invert" ), name, x, y, u, v ); +} + +static const char *dssmap = + " Begin DssMap\n" + " Nin = 2\n" + " IsA Mapping\n" + " PltRA = 2.8272374655684112\n" + " PltDec = -1.0518122540502668\n" + " PltScl = 67.200000000000003\n" + " CNPix1 = 4200\n" + " CNPix2 = 4200\n" + " XPixSz = 25.263000000000002\n" + " YPixSz = 25.263000000000002\n" + " PPO1 = 0\n" + " PPO2 = 0\n" + " PPO3 = 105990.5119\n" + " PPO4 = 0\n" + " PPO5 = 0\n" + " PPO6 = 105990.5119\n" + " AMDX1 = 67.152600000000007\n" + " AMDX2 = 0.0051200000000000004\n" + " AMDX3 = -288.40899999999999\n" + " AMDX4 = -8.8400000000000001e-06\n" + " AMDX5 = -2.9300000000000001e-05\n" + " AMDX6 = 3.9099999999999998e-06\n" + " AMDX7 = -4.16e-06\n" + " AMDX8 = -9.7500000000000005e-10\n" + " AMDX9 = 3.2600000000000001e-10\n" + " AMDX10 = 7.78e-10\n" + " AMDX11 = 2.0700000000000001e-10\n" + " AMDX12 = 5.5500000000000001e-09\n" + " AMDX13 = 1.4899999999999999e-12\n" + " AMDX14 = 0\n" + " AMDX15 = 0\n" + " AMDX16 = 0\n" + " AMDX17 = 0\n" + " AMDX18 = 0\n" + " AMDX19 = 0\n" + " AMDY1 = 67.154200000000003\n" + " AMDY2 = -0.0038300000000000001\n" + " AMDY3 = 191.56200000000001\n" + " AMDY4 = -2.12e-05\n" + " AMDY5 = -2.9200000000000002e-05\n" + " AMDY6 = -9.4399999999999994e-06\n" + " AMDY7 = -4.1400000000000002e-06\n" + " AMDY8 = 6.6699999999999997e-10\n" + " AMDY9 = 6.9399999999999998e-10\n" + " AMDY10 = -2.0800000000000001e-10\n" + " AMDY11 = -1.2e-09\n" + " AMDY12 = 5.5599999999999998e-09\n" + " AMDY13 = 1.5000000000000001e-12\n" + " AMDY14 = 0\n" + " AMDY15 = 0\n" + " AMDY16 = 0\n" + " AMDY17 = 0\n" + " AMDY18 = 0\n" + " AMDY19 = 0\n" + " End DssMap\n"; + +int main( void ) { + int status = 0; + double tk[ 4 ] = { 0.0, 0.0, 1.0, 1.0 }; + double cu[ 4 ] = { 0.0, 0.0, 2.0, 2.0 }; + double cv[ 4 ] = { 0.0, 3.0, 0.0, 3.0 }; + double ina[ 2 ] = { 0.0, 0.0 }, inb[ 2 ] = { 1.0, 1.0 }; + double outa[ 2 ] = { -0.5, -0.5 }, outb[ 2 ] = { 1.5, 1.5 }; + astWatch( &status ); + setvbuf( stdout, NULL, _IONBF, 0 ); + + AstSplineMap *a = astSplineMap( 2, 2, 2, 2, tk, tk, cu, cv, " " ); + AstSplineMap *b = astSplineMap( 2, 2, 2, 2, tk, tk, cu, cv, " " ); + astInvert( b ); + AstCmpMap *cmp = astCmpMap( a, b, 1, " " ); + astInvert( cmp ); + show( "before", "b", (AstMapping *) b, 0.5, 0.6 ); + printf( "simplified class %s\n", astGetC( astSimplify( cmp ), "Class" ) ); + show( "after", "b", (AstMapping *) b, 0.5, 0.6 ); + + AstMapping *d = (AstMapping *) astFromString( dssmap ); + AstWinMap *w = astWinMap( 2, ina, inb, outa, outb, " " ); + astInvert( d ); + astInvert( w ); + cmp = astCmpMap( d, w, 1, " " ); + astInvert( cmp ); + show( "before", "w", (AstMapping *) w, 1.0, 1.0 ); + printf( "simplified class %s\n", astGetC( astSimplify( cmp ), "Class" ) ); + show( "after", "w", (AstMapping *) w, 1.0, 1.0 ); + printf( "status %d\n", status ); + return 0; +} diff --git a/docs/c-library-bugs/unitnormmap_bad_centre.c b/docs/c-library-bugs/unitnormmap_bad_centre.c new file mode 100644 index 0000000..6e20dba --- /dev/null +++ b/docs/c-library-bugs/unitnormmap_bad_centre.c @@ -0,0 +1,24 @@ +/* unitnormmap_bad_centre: a 1-D UnitNormMap whose centre is AST__BAD, + transforming three points forward. Transform's bad-centre branch + sets ptr_out[ point ][ coord_out ], the indices exchanged, so for the + third point it reads ptr_out[ 2 ], past the end of the array of two + output coordinate pointers (AddressSanitizer: a READ of size 8), and + it would write past the end of a coordinate's values were there more + output coordinates than points. */ +#include +#include "ast.h" + +int main( void ) { + int status = 0; + astWatch( &status ); + double centre[ 1 ] = { AST__BAD }; + AstUnitNormMap *m = astUnitNormMap( 1, centre, " " ); + double in[ 3 ] = { 1.0, 2.0, 3.0 }; + double out[ 2 ][ 3 ] = { { 7.0, 7.0, 7.0 }, { 7.0, 7.0, 7.0 } }; + astTranN( m, 3, 1, 3, in, 1, 2, 3, &out[ 0 ][ 0 ] ); + for( int k = 0; k < 3; k++ ) { + printf( "%.17g -> %.17g %.17g\n", in[ k ], out[ 0 ][ k ], out[ 1 ][ k ] ); + } + printf( "status %d\n", status ); + return 0; +} diff --git a/docs/c-library-bugs/xphmap_off_grid.c b/docs/c-library-bugs/xphmap_off_grid.c new file mode 100644 index 0000000..0191d1f --- /dev/null +++ b/docs/c-library-bugs/xphmap_off_grid.c @@ -0,0 +1,34 @@ +/* xphmap_off_grid: positions left of or below the HEALPix grid that an + XphMap accepts as positions in its bottom-left facets. Transform finds + a position's facet indices by dividing its zero-based cell indices by + the facet size, nppf, in integer arithmetic, which rounds towards zero, + so cell indices from -(nppf - 1) to -1 give facet index 0 and the + position passes the test on the facet indices. At order 1 (nppf 2), + (0, 4) is in cell (-1, 3), which is outside the grid, yet HPX12 forward + copies it and HPX0 forward moves it to (4, 8); at order 2 (nppf 4), + (-2, 8.5), three cells left of the grid, is copied too. A position one + more cell to the left, (-3, 8.5), is bad. */ +#include +#include "ast.h" + +static void show( int order, const char *type, double x, double y ) { + char dump[ 256 ]; + double u, v; + snprintf( dump, sizeof dump, " Begin XphMap\n Nin = 2\n IsA Mapping\n" + " Order = %d\n Type = \"%s\"\n End XphMap\n", order, type ); + AstMapping *m = astFromString( dump ); + astTran2( m, 1, &x, &y, 1, &u, &v ); + printf( "order %d %s forward %.17g %.17g -> %.17g %.17g\n", order, type, x, y, u, v ); + m = astAnnul( m ); +} + +int main( void ) { + int status = 0; + astWatch( &status ); + show( 1, "HPX12", 0.0, 4.0 ); + show( 1, "HPX0", 0.0, 4.0 ); + show( 2, "HPX12", -2.0, 8.5 ); + show( 2, "HPX12", -3.0, 8.5 ); + printf( "status %d\n", status ); + return 0; +} diff --git a/docs/reports/2026-11-20-phase9-report.md b/docs/reports/2026-11-20-phase9-report.md new file mode 100644 index 0000000..6c621c2 --- /dev/null +++ b/docs/reports/2026-11-20-phase9-report.md @@ -0,0 +1,160 @@ +# Pure-Java AST: phase 9 report + +## Summary + +Phase 9 ported the Mappings that C has and jniast lacks on 20 November 2026, following the plan [`2026-11-20-pure-java-ast-phase9-mappings.md`](../superpowers/plans/2026-11-20-pure-java-ast-phase9-mappings.md); it is the first part of the spec's "Later phases" item 9, AST classes that are not in jniast. +`NormMap`, `UnitNormMap`, `ChebyMap` and `SplineMap` (public) and `XphMap` (package-private, as C's constructor is protected) now construct, transform, compare, simplify, dump and load as C's do; `ChebyMap extends PolyMap`, as C's structure does and as the user confirmed at plan review. +Their public members are those the API rule gives, which jniast's generator would make from the C prologues; the rule is now in the spec as a settled decision, since the user approved it at plan review, and `src/test/resources/astjava-api.txt` with its check in `JniastApiTest` holds every public class of the package to it. +Every fixture of C's corpora that holds one of these classes now reads, writes and simplifies as C's does, `lsst2.ast` included, and no deferred list names one of them; of the Rust port's tests naming these classes, all are translated except three meta-tests of the Rust port's own files. +Four new C probes (one also built against the hardening PR's library) and three converted oracle files give the expected values. +The work found 7 defects in the C library that are still present at the tip of the upstream pull request that hardens it, all now in `docs/c-library-bugs.md` with a reproducer. +Against the plan commit `1ff5584` the work adds 3,252 lines of main code and 8,685 lines of tests, and removes 70 and 470; `mvn verify` passes with 4,913 tests on JDK 21 (4,649 at the end of phase 8), and the tests pass on the JDK 27 runtime. + +## What was ported + +| Task | What | Main lines | Test lines | +| --- | --- | ---: | ---: | +| 1 | The API rule (spec, `astjava-api.txt`, `JniastApiTest`); `NormMap` (normmap.c: Transform, Equal, MapMerge, MapSplit, Rate, RemoveRegions, Copy, Dump and load) and `UnitNormMap` (unitnormmap.c: Transform, Equal, MapMerge, Copy, Dump and load) | 786 | 2,616 | +| 2 | `XphMap` (xphmap.c: every HPX variant of Transform, Equal, IsLinear, MapMerge, Dump and load) | 514 | 806 | +| 3 | `ChebyMap` (chebymap.c: the constructor, `chebyDomain`, PolyPowers, PolyTran's fit, Equal, Copy, Dump and load) and the ChebyMap branch of polymap.c's MapMerge | 704 | 2,616 | +| 4 | `SplineMap` (splinemap.c: the constructor, the attributes, `Db2val`, `Dbvalu` and `Dintrv`, the iterative inverse, Rate, Equal, MapMerge, Copy, Dump and load) and the shared `Mapping.cancelWithOppositeNeighbour` | 1,327 | 2,616 | +| 5 | Three fixes carried over from the reviews, the sweep and this report | 14 | 125 | + +Lines are those each task's commits add, the fix commits included; Task 5's fixes are fixup commits of `Add SplineMap` and `Add ChebyMap`. +The test lines include the probe sources and outputs and the converted oracle files. +Each task was done by one implementer subagent, reviewed by a second, and verified in the controlling session before it was recorded. +The reviews found no Critical problem and six Important ones, each fixed in one round: the NormMap and UnitNormMap loader refusals unrecorded and overstating what C does (Task 1); an XphMap Javadoc that said off-grid positions are refused where C's truncation accepts them (Task 2); `chebyDomain` of an inverted ChebyMap with different numbers of inputs and outputs, where C reads beyond its arrays, and the SIP writer taking a ChebyMap as a polynomial of powers (Task 3); a claim that the pinned C gives bad outside the range a SplineMap covers, where it combines bad values arithmetically, and a SplineMap merge that broke the project's Invert-restore convention (Task 4). +The second reviews raised three minor points, fixed in Task 5: a SplineMap whose covered range along X has zero width gave infinite and NaN rates, two entries labelled the same C defect differently, and a C result the SIP entry stated was not in committed code. +The review of the whole branch found one Important problem, that simplifying a CmpMap left a cancelled PolyMap, ChebyMap or SplineMap the caller holds with the merge list's Invert value, so that it transformed the other way, and six minor ones; that problem, five of the minor ones and the two minor findings of Task 5's review are fixed in a final pass of fixup commits, and the sixth, which predates phase 9, is listed under Future work. +The tasks were committed between 15:18 (Add NormMap and UnitNormMap) and 17:54 on 20 November, after the plan at 12:55. + +New main classes: `NormMap`, `UnitNormMap`, `XphMap`, `ChebyMap`, `SplineMap`. +New test classes, with their tests: `NormMapTest` (14), `UnitNormMapTest` (33), `NormMapProbeTest` (20), `MappingBadTest` (1), `XphMapTest` (24), `ChebyMapTest` (41), `ChebyMapProbeTest` (29), `SplineMapTest` (23), `SplineMapCApiTest` (7), `SplineMapProbeTest` (31). +Existing test classes gained the cases held back for these classes: `JniastApiTest`, `TransformOracleTest`, `MapSplitTest`, `MapSplitOracleTest`, `ObjectIdOracleTest`, `RemoveRegionsOracleTest`, `BulkKernelsTest`, `NanProtocolTest`, `NanOutputsTest`, `ConstructorChecksTest`, `NativeRoundTripTest`, `FrameEqualityTest`, `PolyBadTest`, `NumericRateTest`, `EqualTest`, `TranDefinednessTest`, `AttrTestClearOracleTest`, `ClearOnSetTest`, `FitsChanWcsWriteTest`, `FitsSipIntWorldTest` and `NativeClassesTest`. +New probes: `normmap_probe.c` (53 cases), `xphmap_probe.c` (18), `chebymap_probe.c` (49) and `splinemap_probe.c` (35, and 37 against the hardening PR's library); converted oracles: `mapping_bad.json`, `xphmap.json` and `spline_inverse.json`. +`docs/rust-c-differences.md` has 23 new entries (six NormMap and UnitNormMap, three XphMap, seven ChebyMap, seven SplineMap), and its PolyMap and DssMap entries on cancelled Invert attributes now point to the shared C bug entry. + +## Departures from the plan + +The [rulings](2026-11-20-phase9-rulings.md) give each with its reason and cost; these change what later work builds on. + +- **The API rule is settled in the spec**, not marked for the user to confirm as the plan's Shared Design said, since the user approved it at plan review after being asked about it. +- **NormMap shares the Frame it is given.** + The plan's "Taken from C" item 2 said it copies it; `astInitNormMap_` calls `astClone`, and the `object_id` oracle shows the Frame's ID in C's dump. +- **The C probes are built against Release libraries**, with and without `-ffp-contract=off`, not only against the phase 8 build, which is unoptimised and never contracts a multiply-add; see Tolerances. +- **`oracle-rows.txt` has two new forms**: `probes// `, for the rows of a C probe's output that differ only by contraction, with `other` counting lines that are not transformed points (fitted coefficients, dumps, domains, rates); `TransformOracleTest.PROBE_ROW_TESTS` names the test that reads each probe's rows. +- **Where the pinned C misbehaves and the hardening PR (Starlink/ast #104, at `1d0714fb`) does not, Java follows the PR**: XphMap's indices far from the grid, the loaders' checks, and SplineMap's `Db2val` and `Dbvalu`, ported as the PR has them; see "Departures from C and from Rust". +- **Simplifying leaves the Mappings the caller holds unchanged**: the plan and phases 2 and 5 followed C in leaving a cancelled PolyMap, or the WinMap a DssMap absorbs, with the Invert value the merge list applied it with; the final review found that this flips a Mapping the caller holds, so PolyMap, ChebyMap, SplineMap and DssMap now set it back, as PR #104 does for PolyMap. +- **No sweep commit**: Tasks 1 to 4 removed every deferred entry and deferral note for their classes, and rewriting the lists changed nothing. + +## Gates + +| Gate | Before | After | +| --- | --- | --- | +| `rust-tests.txt` entries | 283 | 222: 61 removed as translated (NormMap 6, UnitNormMap 39, XphMap 1, ChebyMap 6, SplineMap 9), none added | +| `simplify.txt` entries | 60 | 0 (NormMap 15, UnitNormMap 27, XphMap 7, ChebyMap 6, SplineMap 5) | +| `simplify-cases.txt` entries | 48 | 0 (12, 19, 6, 6, 5) | +| `full-dumps.txt`, `read-warnings.txt`, `serialisation.txt` entries | 62, 64, 63 | 0, 2, 2 (NormMap and UnitNormMap 42, XphMap 7, ChebyMap 7, SplineMap 6, 6 and 5); the two left need MocChan | +| `framesets.txt`, `wcsconv.txt` entries | 1, 1 | 0, 0 (`lsst2.ast`, `lsst2_fits-wcs`) | +| `headers.txt` entries | 0 | 0 | +| `oracle-rows.txt` entries | 0 | 29, all C probe rows that contraction changes: `normmap_probe` 5 (7 rows), `chebymap_probe` 17 (66 lines), `splinemap_probe` 7 (84 lines) | +| `map_split` oracle cases run | 60 | 66 (6 NormMap) | +| `remove_regions` oracle cases run | 9 of 11 | 11 of 11 | +| `object_id.json` cases run | 26 | 27 (`normmap`), every case of the file | +| `poly_bad` oracle cases run | 4 | 6 (ChebyMap) | +| `attr_test_clear` probe cases run | 18 | 20 (SplineMap) | +| `mapping_bad`, `xphmap`, `spline_inverse` oracles | not converted | 7 cases, 8 cases, 40 values (bit for bit) | +| Tests | 4,649 | 4,913 | + +Every oracle and probe test asserts the number of cases it ran, and each probe test checks that it reads every case of its output. +The sweep listed every test of the Rust port that names one of these classes (160 in 22 files, `src/` included) and matched each against the Java test methods and `rust-tests.txt`: every test of `test_normmap.rs`, `test_unitnormmap.rs`, `test_xphmap.rs`, `test_chebymap.rs`, `test_splinemap.rs` and `test_splinemap_c_api.rs` (the five files the survey found listed nowhere among them) is translated, those that assert a Rust-only refusal as C's behaviour (the rulings name them); the tests naming these classes in 13 other files, `src/mappings/splinemap.rs`'s unit test among them, are translated into the existing Java classes for those files. +Three tests are neither translated nor listed (see Gaps and risks). +Rewriting the lists with `-Dast.writeDeferred=true` changes nothing. +`mvn verify` passes on JDK 21 (4,913 tests, Error Prone, Checkstyle and PMD clean), and the tests pass on the JDK 27 runtime; no Java 8 runtime is installed on this machine. + +## Tolerances + +Every value Java computes against a C probe is compared exactly, as text printed with `%.17g`, and the `xphmap` and `spline_inverse` oracles bit for bit; the Rust tests' tolerances are kept only where they compare with exact analytic values, and `testsplinemap_c.c`'s where they come from C. + +### Fused multiply-adds + +Apple clang contracts `a*b + c` into a fused multiply-add when it optimises, and Java never does. +The phase 8 C build is unoptimised and so never contracts, which hides the effect; Task 1 built two Release libraries at the pin, one with the compiler's default flags and one with `-ffp-contract=off`, and Task 4 a third, the hardening PR's library at `1d0714fb`, Release with `-ffp-contract=off`. +Each probe is built against the first two: its default-flags output is committed as `.json` and its unfused output as `_nocontract.json`, and the unoptimised build gives the unfused output exactly. +A line on which the two differ is listed in `oracle-rows.txt` with its cause, shown by emulating the fusion or by the fused instructions in the object file (`otool -tV`), and compared with the unfused line; each probe test's `contractionRowsAreThoseListed` checks that the two outputs differ in exactly the listed lines. + +| Probe | Entries | Lines | Contracted arithmetic | +| --- | ---: | ---: | --- | +| `normmap_probe` | 5 | 7 | unitnormmap.c's inverse `in*norm + centre` (once defeating the next UnitNormMap's zero-norm guard), and winmap.c's `x*b + a` | +| `xphmap_probe` | 0 | 0 | none: xphmap.c's Transform has no floating-point multiplication | +| `chebymap_probe` | 17 | 66 | chebymap.c's `PolyPowers` (`x*scale + offset`, `2.0*x*Tn - Tn-1`), `FitPoly1DInit` and `FitPoly2DInit`, cminpack's `lmder`, and winmap.c's inverse | +| `splinemap_probe` | 7 | 84 | splinemap.c's `Dbvalu` (`work[jj+1]*dm + work[jj]*dp`) and the iterative inverse's `2*u - a` and `x*x + y*y` | + +The Rust port's `spline_inverse_oracle` equals the unfused build's values (the default build differs in 8 of its 40), and the `xphmap_oracle` cannot depend on contraction; both are compared bit for bit. + +## Departures from C and from Rust + +Each is an entry of [`docs/rust-c-differences.md`](../rust-c-differences.md), under "Mappings". + +The rule the phase settled on: **Java follows the pinned C, except where the pinned C reads or writes out of bounds, gives arithmetic garbage, or changes a Mapping the caller holds; there Java follows PR #104 where the PR fixes it, and otherwise gives the corrected result and records the C bug** in `docs/c-library-bugs.md`. + +- **C's quirks are kept** where C's result is defined: UnitNormMap merges compare with unitnormmap.c's own `EQUAL` macro, not `astEQUAL`; a ChebyMap keeps its input box only with forward coefficients, and accepts no inputs or outputs; `chebyDomain` throws the error `astMapBox` reports, despite C's prologue; a ChebyMap with IterInverse set dumps `IterInv = 1`; a linear ChebyMap reduces to a Mapping that transforms points outside its box; SplineMaps compare without InvNiter, InvTol or OutUnit; a SplineMap's constructor takes SciPy's coefficient order, and `splineKnots` and `splineCoeffs` take any axis other than 1 as the second. +- **C bugs whose result is defined are followed**: a ChebyMap cancels with an inverted PolyMap of the same coefficients; an XphMap accepts positions up to a facet off its grid. +- **Where C reads or writes beyond its arrays, or changes a Mapping the caller holds, and PR #104 does not fix it, Java gives the corrected result**: a UnitNormMap with a bad centre gives bad outputs; `chebyDomain` of an inverted ChebyMap with different numbers of inputs and outputs gives the box C chooses with that box's own axes; simplifying a CmpMap sets a cancelled SplineMap, and the WinMap a DssMap absorbs, back to its own Invert value, where C leaves the list's value (the simplified Mapping is C's). +- **Java follows the hardening PR (Starlink/ast #104, at `1d0714fb`) where the pinned C misbehaves**: XphMap holds its grid indices in doubles, as the PR does, so positions beyond the `int` range are bad; the NormMap, UnitNormMap, XphMap and SplineMap loaders refuse counts, orders and knots the pinned C stores and later overruns with, with the PR's messages; a SplineMap gives the default value outside the range its knots cover, where the pinned C combines bad values arithmetically or reads beyond its arrays, finds a position on the upper Y limit among the knots up to it (so a spline with a single knot interval along Y has a value there, where the pinned C gives bad), makes the result bad for a bad column, and gives bad on a covered range of zero width along X, where the pinned C divides 0 by 0 (or, for order 1, gives its first coefficient); a cancelled PolyMap or ChebyMap is set back to its own Invert value, as the PR's polymap.c does. + Each of these leaves Java unchanged when the pin moves past PR #104. +- **Java departs from C where C writes a misleading result**: the SIP writer passes over a ChebyMap, as Rust does, so it is never written as SIP coefficients, where C writes its Chebyshev coefficients as SIP's coefficients of powers; with no other PolyMap the FrameSet is not written, as C does not write it with a MathMap of the same transformation, and a plain PolyMap later in the Mapping, which C would not reach, is taken instead. +- **Non-finite coordinates are bad**, by the library's rule, where C tests `AST__BAD` only (UnitNormMap, NormMap's Frame, XphMap, SplineMap). +- **Merges set Invert attributes back as they were**, set or unset, where C's `astSetInvert` leaves them set, so where C sets them back the two differ only in what `test("Invert")` gives afterwards. + +## Defects found in the C library + +The tasks and the final review found 7 defects in the pinned C library (`3d3f255f`) that are still present at `1d0714fb`, the tip of the upstream pull request (PR #104) the C library is being hardened in; each is in `docs/c-library-bugs.md` with a reproducer in `docs/c-library-bugs/`: + +| Entry | Reproducer | Java | +| --- | --- | --- | +| A UnitNormMap with a bad centre writes outside its output | `unitnormmap_bad_centre` | every output bad | +| An XphMap accepts positions up to a facet left of or below its grid (a comment at `1d0714fb` says Moc relies on it) | `xphmap_off_grid` | as C | +| A ChebyMap cancels with a PolyMap of the same coefficients | `chebymap_polymap_cancel` | as C | +| `astChebyDomain` of an inverted ChebyMap with different numbers of inputs and outputs | `chebymap_inverted_domain` | the box with its own axes | +| A ChebyMap is written as SIP coefficients of powers | `chebymap_sip` | not written | +| Simplifying a CmpMap changes the Invert attribute of a component it holds (SplineMap and DssMap; PolyMap's case is fixed at `1d0714fb`) | `merge_invert` | the component the caller holds is unchanged | +| Comparing two CmpMaps that share a component gives a wrong answer and changes the component | `cmpmap_equal_shared` | as C | + +The pinned C's other defects found here, the XphMap `int` conversion far from the grid, the unchecked NormMap, UnitNormMap, XphMap and SplineMap loaders, and SplineMap's reads beyond its arrays outside the range its knots cover, are fixed by PR #104, so they are recorded only in `docs/rust-c-differences.md`, where Java follows the PR. + +## Gaps and risks + +- **For the user to decide: following C's wrong ChebyMap cancellation.** + A ChebyMap and an inverted PolyMap of the same coefficients simplify to a UnitMap in Java as in C, although they are different transformations, by the rule that Java follows C where C's result is defined (precedent `WinDiagMat`, phase 2). + Java departs from C for `chebyDomain`, where C reads beyond its arrays, and for the SIP writer, where C writes a header that other software would read as true; the cancellation is a simplification result, as `WinDiagMat`'s is, so it was left as C's. +- **For the user to decide: following PR #104 rather than the pinned C.** + Java gives PR #104's results for XphMap positions far from the grid, the four loaders, SplineMap's `Db2val` and `Dbvalu` (positions outside the range its knots cover, the upper Y limit of a single knot interval, and a covered range of zero width, which for an order-1 spline replaces a value the pinned C defines), and a cancelled PolyMap's Invert attribute; these change nothing when the pin moves past PR #104. +- **The pin will change some results.** + When the pin moves past PR #104, the rows `SplineMapProbeTest.PR104_ROWS` names take the pinned C's values unchanged, the loader messages already are the PR's, and the PolyMap part of the Invert bug entry is fixed. +- **Runtimes.** + The tests ran on JDK 21 and the JDK 27 runtime on AArch64 macOS only; the paths phase 9 adds, SkyFrame's normalisation for NormMap included, use only `abs`, `min`, `max`, `floor`, `ceil`, `ulp` and `sqrt` of `java.lang.Math`, which give the same bits on every platform, so the exact comparisons are not expected to differ on CI's x86-64 Linux runtimes. +- **Another C bug changes a Mapping the caller holds.** + cmpmap.c's `Equal`, comparing a CmpMap whose two components are one object, compares it equal to itself whatever Invert values the two lists apply it with, and leaves it with the first list's value (`docs/c-library-bugs.md`, "Comparing two CmpMaps that share a component gives a wrong answer and changes the component"; `docs/rust-c-differences.md`, "A CmpMap comparison changes a shared component's Invert attribute"; `simplify/brad.map` changes its WcsMap's Invert from 1 to 0, recorded in `brad.simp`); Java follows C there, which the rule above would now correct; it is left for a later phase, since it changes a fixture's recorded result. +- **`rust-tests.txt` has no automated checker.** + The sweep matched each Rust test naming these classes against the Java test methods by name and checked each mismatch by hand. + Three tests are neither translated nor listed: `src/serial/object_text.rs::every_class_name_matches_the_class_its_dump_names`, `tests/test_mapmerge_audit.rs::no_checklist_is_orphaned` and `tests/test_simplify_regression.rs::drift_licence_lapses_outside_the_bound` (which names ChebyMap only in a comment beside it); they test the Rust port's own files and licences, as phases 7 and 8 found for such meta-tests. + `tests/test_verification_ledger.rs` repeats the claim, corrected in `TransformOracleTest`, that the `tnx-cheb` fixture's inverse is bad because it builds a ChebyMap; it has no Java translation. +- **A UnitNormMap whose input differs from its centre by more than `DBL_MAX`** gives NaN outputs, as C's arithmetic and Rust do; the library's convention of no NaN output is not enforced on that overflow path. + +## Future work + +- **A checker for `rust-tests.txt`**, so that a Rust test file neither translated nor listed fails a test. +- **Moving the C pin past PR #104**, after which the PolyMap part of the Invert bug entry is removed, and `SplineMapProbeTest`'s pinned and PR outputs become one. +- **Floating-point attributes formatted with 15 digits**: `PolyMap` (TolInverse, `PolyMap.java:1179`), `SphMap` (PolarLong, `SphMap.java:226`), `Region` (FillFactor, `Region.java:629`) and `WcsMap` (`WcsMap.java:913-923`) format their values with `%.15g` in `getAttrib`, where C uses `AST__DBL_DIG`, 17 digits; a ChebyMap's `getC("TolInverse")` gives `1e-06` where C gives `9.9999999999999995e-07`. + This predates phase 9 and is not fixed here. + +## What the next phase takes + +The next part of item 9, phase 9b, is **Table, FitsTable and FitsChan's `-TAB` support**: `Table` (table.c, a KeyMap whose entries are cells keyed `COLUMN(row)`, with its column and parameter functions), `FitsTable` (fitstable.c, a Table with a FITS binary-table header and column data), and FitsChan's table store (`astPutTable`, `astPutTables`, `astRemoveTables`, `astTableSource`, a public `getTables`) and its reading and writing of `-TAB` headers, which now throw `UnsupportedOperationException` naming FitsTable. +It raises a **KeyMap public-API question** for the user: Table is a KeyMap in C and in Java, and its columns may hold the types jniast's KeyMap does not make public (C's byte, short, 64-bit integer and float types, `astMapPutU`, and the type constants `AST__BYTETYPE`, `AST__SINTTYPE`, `AST__KINTTYPE`, `AST__FLOATTYPE` and `AST__UNDEFTYPE`); this phase's rule adds no public member to a jniast class, so either KeyMap gains those members publicly (listed in `jniast-api-additions.txt` with the reason), or Table's cells of those types are reachable only through the package. +Moc and MocChan (9c, which build on XphMap) and the newer functions on jniast's classes (9d) follow. + +## Rulings + +Every decision made while executing the plan where it was wrong, unclear or silent, every departure from Rust, C or jniast and every C quirk kept is in [`2026-11-20-phase9-rulings.md`](2026-11-20-phase9-rulings.md), with its reason and its cost if wrong: 95 rulings, 9 from the plan's Shared Design, 3 by the controller before Task 1, 53 by the implementers of Tasks 1 to 4, 11 by the controller during them, 9 in Task 5, and 10 in the final fix pass. diff --git a/docs/reports/2026-11-20-phase9-rulings.md b/docs/reports/2026-11-20-phase9-rulings.md new file mode 100644 index 0000000..067dafe --- /dev/null +++ b/docs/reports/2026-11-20-phase9-rulings.md @@ -0,0 +1,182 @@ +# Phase 9: rulings + +These are the decisions made while executing the phase 9 plan ([`2026-11-20-pure-java-ast-phase9-mappings.md`](../superpowers/plans/2026-11-20-pure-java-ast-phase9-mappings.md)) where the plan was wrong, unclear or silent, or where the port departs from Rust, C or jniast or keeps a C quirk. +They are copied from the plan's Shared Design (the rulings made when the plan was written), from the execution ledger (the controller's rulings) and from each task's report (the implementer's rulings), grouped by task; within a task the implementer's come first, in the order of the report, fix rounds included, then the controller's, in the order they were made. +Each ruling gives what was decided, why, and what it costs if wrong; the plan's rulings state what and why, and the cost here is added from what the tasks found. +A later ruling can reverse or amend an earlier one; a ruling that a later one replaced carries a bracketed note saying so. +There are 95 rulings: 9 from the plan, 3 by the controller before Task 1, 53 by the implementers of Tasks 1 to 4, 11 by the controller during Tasks 1 to 4, 8 by the implementer of Task 5 and 1 by the controller, and 10 in the final fix pass after the review of the whole branch, 5 by the controller and 5 by the implementer. +Commits are cited by subject. +The phase report is [`2026-11-20-phase9-report.md`](2026-11-20-phase9-report.md). + +## Plan: Shared Design + +### The API rule + +- Ruling: the public API of a class that is in AST but not in jniast is what jniast's generator (`JMaker.pm`) would make from the C prologue, and nothing else (constructor arguments in C order without `options`, `astFoo` as `foo`, out-parameter arrays the caller sizes from the object returned, attributes as typed `get`/`set` pairs, constants on the class whose header defines them), checked by `src/test/resources/astjava-api.txt` and `JniastApiTest` — the spec asks for such classes to follow jniast's conventions, and jniast's classes are the generator's output — cost if wrong: a later phase's class may need a member the rule does not give, which would then need its own ruling. [amended before Task 1: written into the spec as a settled decision, not marked for the user to confirm] +- Ruling: `XphMap` is package-private, as C's constructor is protected, and no public member is added to a jniast class in this phase — the API rule — cost if wrong: Moc (phase 9c) reaches XphMap from inside the package, so none. + +### Where the code goes + +- Ruling: `ChebyMap extends PolyMap`, as C's structure and vtab do, with the ChebyMap branch of `polymap.c`'s `MapMerge` in `PolyMap.java`; the per-input scaling comes from `chebymap.c`, not from Rust's composition — C's layout, and the user's answer at plan review — cost if wrong: none (user decision). +- Ruling: Java's `isA` for ChebyMap follows what C prints (`astIsAPolyMap` and the dump's `IsA` lines), since `astMAKE_ISA(ChebyMap,Mapping)` names Mapping — C's behaviour is the reference, not its macro — cost if wrong: none; Task 3's probe shows `astIsAPolyMap` of a ChebyMap is 1. + +### Taken from C rather than Rust + +- Ruling: constructors check their arguments as C's do, with C's status and message, and a null array or Frame is a `NullPointerException` naming the argument, as phase 6 ruled for jniast arguments — C is the reference for jniast's users — cost if wrong: an exception type or order where both a size and an array are wrong. +- Ruling: copy and share follow C; NormMap copies its Frame at construction — the plan's reading of `astInitNormMap_` — cost if wrong: a caller's change to the Frame does or does not reach the NormMap. [amended in Task 1: `astInitNormMap_` clones the Frame, so NormMap shares it] +- Ruling: loaders follow C where C's result is usable and raise `AST__LDERR` where C would store a null and fail later (H9) — an error is better than a plausible wrong value — cost if wrong: a dump C reads (and mis-transforms) does not load. +- Ruling: attribute setters clear `IsSimple` where C's do (SplineMap's InvNiter, InvTol and OutUnit, and PolyMap's attributes on a ChebyMap) — C's `astMAKE_SET1` and clearers — cost if wrong: a simplified record survives a change, or is discarded needlessly. + +### Gates and deferred lists + +- Ruling: each Rust test file of these classes becomes a Java test class, the `xphmap_oracle` and `spline_inverse_oracle` cases are converted with `CasesToJson`, the tests of other Rust files that name these classes go into the existing Java classes for those files, and each task removes from the deferred lists only the entries whose missing classes it adds — the convention of phases 1 to 8 — cost if wrong: none. + +## Before Task 1 + +### Controller + +- Ruling: ChebyMap extends PolyMap — the user confirmed "ChebyMap is a PolyMap" at plan review; the probe still records C's `astIsAPolyMap` and dump lines — cost if wrong: none (user decision). +- Ruling: C bugs found go in `docs/c-library-bugs.md` with a reproducer (CLAUDE.md rule), not in a private report — the user's instruction — cost if wrong: none. +- Ruling: the API rule goes into the spec as a settled decision, not marked "to confirm" — the user approved the plan ("looks good") after being asked about the API rule specifically — cost if wrong: one sentence in the spec. + +## Task 1: The API rule, NormMap and UnitNormMap + +### Implementer + +- Ruling: NormMap holds (shares, `markShared`) the Frame it is given, as `astInitNormMap_` calls `astClone`; the plan's "Taken from C" item 2 says NormMap copies its Frame, but normmap.c clones it (only `Copy` copies) — C wins, and `ObjectIdOracleTest` case `normmap` (the Frame's ID kept in C's dump) confirms it — cost if wrong: a caller's later change to the Frame changes the NormMap. +- Ruling: UnitNormMap's `MakeMergedMap` compares centres and WinMap scales with unitnormmap.c's own `EQUAL` macro (1.0E9 epsilons, floor `DBL_MIN`), not `astEQUAL` as Rust does, while `Equal` uses `astEQUAL`; probe cases `unm_simplify_near_centres` and `unm_simplify_win_near_unit` show C merging where Rust would not; recorded in `docs/rust-c-differences.md` — cost if wrong: none, C shown. +- Ruling: a bad centre makes every UnitNormMap output bad (Rust; what C's code means), where C's bad-centre branch indexes `ptr_out[point][coord_out]` and overruns (C bug, new entry and reproducer) — cost if wrong: none for valid memory behaviour. +- Ruling: non-finite inputs, norms and centre values count as bad in UnitNormMap (Java's `isBad`, as Rust and the existing "Infinite input coordinates" entry), where C tests only `AST__BAD` — cost if wrong: infinite inputs give bad where C gives NaN. +- Ruling: NormMap gives a NaN input to the Frame as `AST__BAD` (what C receives for bad) and returns a NaN the Frame gives as `AST__BAD`; infinities pass to the Frame as in C — cost if wrong: none seen. +- Ruling: constructor checks follow the phase 1 rule: a null `centre` or `frame` is a `NullPointerException` naming it (C treats a NULL centre as all bad), a short centre `AST__DIMIN`, then `ncoord <= 0` is `AST__BADSM` with C's exact message "The centre must have at least one axis" (probe case `unm_error_no_axes`) — cost if wrong: the exception type for a null centre. +- Ruling: loaders raise `AST__LDERR` for a missing or non-Frame `Frame` item, for a NormMap whose Nin or Nout differ from its Frame's axes, and for a UnitNormMap whose Nout is not Nin+1 (H9: the pinned C stores them and fails or overruns later; PR #104 at `1d0714fb` adds similar checks with its own messages); a UnitNormMap with no inputs uses C's pinned message — cost if wrong: message text differs from PR #104's when the pin moves. +- Ruling: NormMap's `mapMerge` does not set the NormMap's Invert for the duration as C does (its two directions are the same, so it has no effect); UnitNormMap swaps and restores each neighbour's Invert exactly, where C leaves it set — cost if wrong: only `test("Invert")` afterwards. +- Ruling: an empty `mapSplit` selection gives no split (C's `astStore` of no indices gives NULL; oracle case `normmap_empty` is `None`) — cost if wrong: none. +- Ruling: `GetMappingType` compares class names, as C does, so a subclass of ShiftMap or WinMap would not merge — cost if wrong: none (no subclasses). +- Ruling: the committed probe output is from a Release build with default flags (which contracts multiply-adds), not the phase 8 build (unoptimised, so never contracting, identical to the unfused output); the second, unfused, output is committed so the cause of each listed row is shown, and `oracle-rows.txt` gains a `probes//` form that `TransformOracleTest`'s gates skip — cost if wrong: one more output file and a format extension to maintain. +- Ruling: Rust's `try_merge` tests (Rust-only API) are translated as simplifications of the pair in a CmpMap, which reach the same C merge — cost if wrong: none; the probe covers the same merges against C. +- Ruling: `test_mapping_bad.rs`, neither translated nor listed and naming NormMap, is translated as `MappingBadTest` with `oracle/mapping_bad.json` — cost if wrong: none. +- Ruling: the package-private centre accessor is `getCentre()` (PMD forbids a method named like the field); no NormMap Frame accessor is kept, as nothing needs it — cost if wrong: none. +- Ruling: the API rule is written into the spec as a settled decision, as the dispatch says the user approved it, not "for the user to confirm" as the plan's text has it — cost if wrong: one spec sentence. + +#### Fix round 1 + +- Ruling: the probe-row registry is checked by reflection on the package-private `ROWS_PREFIX` (PMD forbids `setAccessible`) — cost if wrong: a later probe test must declare that field. [superseded in Task 3: `PROBE_ROW_TESTS` maps each probe name to its prefix directly, without reflection] + +### Controller + +- Ruling: keep both loader refusals (do not narrow NormMap's) and record them in `docs/rust-c-differences.md` with exactly what C does in each case — Java's `mapMerge` and `mapSplit` assume Nin = Nout = the Frame's axes, so accepting Nin greater than the axes would need its own unported handling; C stores the counts, Rust rederives them — cost if wrong: a hand-edited description that C transforms loads in C but not in Java. +- Ruling: Task 3 simplifies `PROBE_ROW_TESTS` to hold the prefixes directly when it registers `chebymap_probe`, since it touches the registry anyway — cost if wrong: one small test refactor. + +## Task 2: XphMap + +### Implementer + +- Ruling: grid and facet indices are held in doubles, facet indices rounded towards zero (`trunc`), as the hardening PR (Starlink/ast #104 at `1d0714fb`) does, not in `int` as the pinned C nor `i64` as Rust — the pinned C's `int` conversion is undefined beyond `int` range (on AArch64 it saturates, transforming (3e9, 5e9) through XPHN order 1 to (4999999998, -2999999989)), and the PR's change keeps every in-range result — cost if wrong: positions beyond ±2^31 pixels differ from the pinned C build on this machine; recorded in `docs/rust-c-differences.md`, "XphMap positions far from the grid". +- Ruling: a NaN or infinite input makes both outputs bad (Java's `isBad`, as Rust and every Java Mapping), where C tests only `AST__BAD` and converts a NaN to `int` (undefined) — cost if wrong: none for finite inputs. +- Ruling: the loader refuses an order outside 0 to 27 and numbers of inputs or outputs other than 2 with `AST__LDERR`, using the hardening PR's messages, after the pinned C's Type check (`AST__OPT` first, where the PR checks the order before reading the Type) — the pinned C stores them and then shifts by an undefined amount, overflows `9*nppf`, or reads and writes beyond the coordinate arrays (H9), as Task 1 ruled for NormMap and UnitNormMap — cost if wrong: dumps the pinned C would load (and mis-transform) are refused. +- Ruling: `mapMerge` restores each Invert attribute as it was, set or unset, where C's `astSetInvert` leaves both set — the phase 2 convention used by every Java merge — cost if wrong: only `test("Invert")` differs afterwards. +- Ruling: `mapMerge` uses `astEqual` on the list's shared objects as C does, not Rust's clones; one XphMap appearing twice does not falsely cancel, since C's `astInitCmpMap` copies a repeated component and `SeparateMappings` (Java `MergeList.separate`) gives each later place a copy (probe cases `same_object_twice` and `same_object_then_inverse`) — cost if wrong: none observed. +- Ruling: `NativeClassesTest` uses Moc where it used XphMap as the example of a class the library cannot load — the test's point is an absent class — cost if wrong: none. + +### Controller + +- Ruling: the truncation that accepts positions up to a facet off the grid goes in `docs/c-library-bugs.md` as a probable C bug with a reproducer, and Java keeps C's behaviour (the oracle agrees) — the user's rule is to track every C bug found, and PR #104 keeps `trunc`, so it is not a hardening item — cost if wrong: one entry the user may reclassify as intended (a comment at `1d0714fb` says Moc relies on it). +- Ruling: the loader keeps the pinned C's check order (Type first, `AST__OPT`), with the docs and report corrected to say so — the pinned C is the reference, and the PR differs only when both are bad — cost if wrong: a different status for a doubly corrupt dump. + +## Task 3: ChebyMap + +### Implementer + +- Ruling: Java `isA` is `instanceof`, so a ChebyMap is a PolyMap — the probe shows C's `astIsAPolyMap` of a ChebyMap is 1 (its vtab parent is PolyMap's) and its dump has `IsA PolyMap`, although `astMAKE_ISA(ChebyMap,Mapping)` names Mapping — cost if wrong: none (user ruling, C agrees). +- Ruling: `ChebyMap.equalTo` finds a ChebyMap equal to a PolyMap of the same coefficients, and `MapMerge` therefore cancels them, as C does; recorded as a C bug with reproducer `chebymap_polymap_cancel` (present at `3d3f255f` and `1d0714fb`) and in `docs/rust-c-differences.md` — C wins over correctness by the project rule — cost if wrong: a ChebyMap and PolyMap pair simplifies to a UnitMap in Java too. +- Ruling: `chebyDomain` throws the error MapBox reports (`AST__MTRMT` for a bad coefficient), as C does, although C's prologue says bad bounds and no error; Rust returns bad — cost if wrong: an exception where a caller reading the prologue expects bad values. +- Ruling: the input box is kept only with forward coefficients (C), not always (Rust); a ChebyMap of no inputs or outputs, and longer bounds arrays, are accepted (C); a used null bounds array is a `NullPointerException` naming it and a short one `AST__DIMIN` (jniast convention), checked after PolyMap's coefficient checks — cost if wrong: the error order when both a coefficient and a bounds array are wrong. +- Ruling: Rust tests that assert Rust-only refusals are translated to C's behaviour (`chebymap_nin_zero_rejected` and `nout_zero_rejected` become `...Accepted`, `chebymap_bad_bounds_len_rejected` checks `AST__DIMIN` for a short array and acceptance of a longer one, `chebymap_inverse_without_bounds_rejected` checks `NullPointerException`), and `try_merge` tests become simplifications of the pair in a CmpMap — cost if wrong: none; the probe gives C's behaviour. +- Ruling: the loader follows C exactly (no scales means an ordinary polynomial, an incomplete set is `AST__OBJIN` with C's message, items of a transformation without coefficients are unread); no H9 refusal is needed, since C's result is usable — cost if wrong: none seen. +- Ruling: PolyMap's dump writes the held IterInverse value when set (C's `GetIterInverse` there is the non-virtual one), so a ChebyMap with IterInverse set dumps `IterInv = 1` — cost if wrong: none for PolyMap, whose virtual and held values agree when set. +- Ruling: `isMonomial()` is false for every ChebyMap, so its transformations are evaluated point by point; PolyMap's block path gives the same values — cost if wrong: speed only. +- Ruling: `oracle-rows.txt` probe entries gain the `other` kind, since contraction changes fitted coefficients, dumps, domains and rates, which are not transformed points — cost if wrong: one more form to maintain; the parser refuses it outside `probes/`. +- Ruling: the probe's error lines naming the C routine below the first message (`! AST: Error in routine ...`) are dropped by the test with the `!! ` lines — cost if wrong: none; they name C source lines. +- Ruling: `TransformOracleTest`'s `tnx-cheb` comment (from Rust) said its inverse is bad because it builds a ChebyMap; the fixture holds no ChebyMap (C makes a TPN WcsMap) and C's recorded inverse values are finite but recover no pixel; the comment now says that, and the round-trip exclusion is unchanged — cost if wrong: a comment. +- Ruling: `EqualTest`'s two ChebyMap tests take C's answers from `chebymap_probe` (case `equal_rust`) rather than regenerating `equal_probe` — cost if wrong: none. +- Ruling: the Rust tests' tolerances are kept where they compare with exact values (`NumericRateTest`, `ChebyMapTest`); every value Java computes against C is compared exactly in `ChebyMapProbeTest` — cost if wrong: none. + +#### Fix round 1 + +- Ruling: `chebyDomain` on an inverted ChebyMap with different numbers of inputs and outputs gives the box C chooses with that box's own number of axes, not C's out-of-bounds result — cost if wrong: none for equal counts or an uninverted ChebyMap, where C agrees. +- Ruling: Java's SIP writer passes over a ChebyMap, as Rust does, so such a FrameSet is not written as FITS-WCS, where C writes a header that does not describe it — cost if wrong: a FrameSet C writes, wrongly, is not written. + +### Controller + +- Ruling: `chebyDomain` returns the box C selects with that box's own axis count (the count at creation, as Rust), with a `docs/c-library-bugs.md` entry and reproducer, a `docs/rust-c-differences.md` entry and a test with Nin ≠ Nout in both directions — C reads and writes beyond its arrays, which cannot be copied — cost if wrong: Java returns full boxes where C returns garbage. +- Ruling: Java's SIP writer does not take a ChebyMap (follows Rust), recorded as a C bug and a `docs/rust-c-differences.md` entry, while the ChebyMap and inverted-PolyMap cancellation stays "Java follows C", since it is a simplification result (precedent `WinDiagMat`, phase 2) and is flagged to the user — C writes a FITS header describing a different distortion, which other software would read as true, so writing none is the honest failure — cost if wrong: Java gives no SIP header where C gives a wrong one. + +## Task 4: SplineMap + +### Implementer + +- Ruling: the constructor takes SciPy's coefficient order (C's public and internal `astSplineMap`), so every Rust test built with `SplineMap::new` (CMLIB order) is translated with transposed coefficients, and Rust's `scipy_and_cmlib_constructors_agree` becomes "the coefficients `splineCoeffs` gives back build an equal SplineMap, and the transposed values a different one" — no CMLIB-order constructor exists in C's C API or jniast — cost if wrong: one translated test. +- Ruling: `splineKnots` and `splineCoeffs` take any axis other than 1 as the second, as C does (probe case `knots_coeffs`); Rust's `coeffs_ignore_invert_and_check_the_axis` (`AST__AXIIN` for 0 and 3) is translated to C's behaviour — cost if wrong: a caller passing 0 or 3 gets data, not an error. +- Ruling: the constructor checks C's sizes, then PR #104's overflow check, then null (`NullPointerException`) and length (`AST__DIMIN`, jniast convention), then C's knot checks — the array lengths depend on valid sizes — cost if wrong: the error chosen when both sizes and arrays are wrong. +- Ruling: the loader refuses Nin or Nout other than 2 (`AST__LDERR`) and bad orders, counts and knots (`AST__ATTIN`, `astLoadSplineMap: ...`) with PR #104's statuses and messages, where the pinned C stores them and later transforms out of bounds (the XphMap precedent of following the PR) — cost if wrong: a corrupt dump the pinned C would load (then misbehave on) is refused. +- Ruling: Java gives `AST__BAD` exactly where the pinned C would index outside its arrays (Y outside the range a non-clamped knot vector covers, a NaN Y, and a NaN X in `Dbvalu` for k > 1), matching what the pinned C gives along X for the same position — cost if wrong: with OutUnit set and a non-clamped Y knot vector, Java gives bad where the hardened C gives the input. [superseded in fix round 1: the pinned C does not give bad along X there, and Java follows PR #104's range test on both axes] +- Ruling: the pinned C's quirk that a spline with a single knot interval along Y is bad on its upper Y limit is kept (Rust and Rust's test agree; PR #104 changes it) — cost if wrong: one edge line per such spline, to change when the pin moves. [superseded in the final fix pass: `Db2val` is PR #104's as written, which gives the value there] +- Ruling: `MapMerge` follows C exactly, including setting attributes back with `setInvert` (unset becomes set) and leaving the nominated SplineMap with the list's Invert value when it cancels, as the probe records C's `astTest` — cost if wrong: Java mutates a caller's SplineMap as C does. [superseded in fix round 1: the merge uses `swapInvert` and `restoreInvert`, as PolyMap does, and only a cancelled nominee keeps C's change; superseded again in the final fix pass: the cancelled nominee is set back too] +- Ruling: a NaN or infinite user input is bad and a NaN output is bad (the Mapping contract), while the iterative inverse's internal values use C's `!= AST__BAD` tests, so its bookkeeping (and the clamp of converged points on later iterations) is C's — cost if wrong: none seen; Java differs from C only for non-finite inputs, where C reads out of bounds or returns NaN. +- Ruling: `Dbvalu` is C's generic version, not Rust's per-order specialisation — the quirks entry says the bits are the same — cost if wrong: speed. +- Ruling: `Dbvalu`'s `AST__INTER` check for `k < 1 || n < k || ideriv < 0` is kept, though the constructor and loader make it unreachable — cost if wrong: none. +- Ruling: Rust tests' tolerances are kept where they compare with exact analytic values (`SplineMapTest`), and `testsplinemap_c.c`'s tolerances (1e-11, 1e-6, 1e-12) where they come from C; every value Java computes against C is compared exactly in `SplineMapProbeTest` and `forwardAndInverseMatchTheCLibraryBitForBit` — cost if wrong: none. +- Ruling: the four `FitsChanWcsWriteTest` lsst2 tests keep Rust's assertions (count and keyword membership), and their C values are checked exactly (full keyword lists) by the probe cases `fits_lsst2_*` — cost if wrong: none. +- Ruling: `NativeClassesTest` uses `Table`, absent after phase 9, in place of SplineMap — cost if wrong: none. + +#### Fix round 1 + +- Ruling: where the pinned C is well defined but PR #104 changes the result (the single-interval upper Y limit), Java keeps the pinned C; where the pinned C overruns or combines bad values, Java gives PR #104's result; each such row is named in the test — the controller's ruling applied row by row — cost if wrong: the named rows. [amended in Task 5: the step-back of PR #104's `Dbvalu` also replaces one well-defined pinned result, for an order-1 spline whose covered range along X has zero width] [superseded in the final fix pass: `Db2val` and `Dbvalu` are PR #104's as written, so no row keeps the pinned C's value] +- Ruling: PR #104's values come from a library built here with `-ffp-contract=off` (Release, at `1d0714fb`), not from the existing sanitiser build, which contracts multiply-adds — cost if wrong: none; the PR-only rows are exact values. +- Ruling: a NaN input stays bad (the Mapping contract), where PR #104 gives the default (the NaN itself with OutUnit set) — cost if wrong: NaN inputs with OutUnit set. + +### Controller + +- Ruling: SplineMap's out-of-range handling follows PR #104 on both axes (its bad-column check and its basic-interval test in `Db2val` and `Dbvalu`), with expected values from the PR #104 build for rows where the pinned C reads out of bounds or gives garbage, recorded in `docs/rust-c-differences.md` — the XphMap precedent of following the PR where the pinned C misbehaves — cost if wrong: out-of-range rows change when the pin moves past PR #104 only if the PR changes again. +- Ruling: SplineMap's `MapMerge` uses `swapInvert` and `restoreInvert` as PolyMap does (a cancelled nominee keeps C's change), with the tests adjusted as `XphMapTest` does and the standard sentence in the entry — the project's convention since phase 2 — cost if wrong: `test("Invert")` differs from C after a merge. [amended in the final fix pass: the cancelled nominee is set back too] +- Ruling: one `docs/c-library-bugs.md` entry covers the cancelled-nominee Invert bug in PolyMap, DssMap and SplineMap, and their `docs/rust-c-differences.md` entries point to it — the user's rule is to track every C bug, and it is one pattern — cost if wrong: none. +- Ruling: the zero-width covered X range (`Dbvalu` divides 0 by 0, so `rate` gives infinity or NaN) is fixed in Task 5 by porting PR #104's `Dbvalu` step-back and testing the rate — a NaN or infinity from `rate` breaks the bad-value contract, and the ruling above already follows PR #104 there — cost if wrong: one small fixup. +- Ruling: Task 5 also makes the C quirk and C bug labels of the cancelled-nominee Invert entries consistent, and shows the MathMap comparison of the SIP entry in committed code — cost if wrong: none. + +## Task 5: Sweep and report + +### Implementer + +- Ruling: `SplineMap.dbvalu` steps back from the upper limit as PR #104's `Dbvalu` does (`do { if (i == k - 1) return BAD; i--; } while (x == t[i])`), so a range covered along X of zero width gives bad values and rates, where the pinned C evaluates the interval of zero width (NaN and infinity for order 2, knots 0, 1, 1, 2) — the controller's ruling — cost if wrong: none for order 2, where the pinned C gives no usable value. +- Ruling: the same step-back makes an order-1 spline with knots 1, 1 bad at x = 1, where the pinned C gives its first coefficient, a defined value; the PR's behaviour is kept there too rather than keeping the pinned C's loop for order 1 alone, which neither C version has — cost if wrong: such a spline (every X knot equal) gives bad where the pinned C gives a value, until the pin moves past PR #104. +- Ruling: the zero-width case (`tran_zero_width_x`) runs against the pinned C as well as PR #104, not only against the PR, so the pinned C's NaN, infinite and coefficient values are committed and `pr104DiffersOnlyInTheNamedRows` checks that the two libraries differ in exactly the rows that take the PR's values — the pinned C reads within its arrays there — cost if wrong: none. +- Ruling: the PolyMap and DssMap entries of `docs/rust-c-differences.md` for the cancelled-nominee Invert defect are labelled **C bug**, as the SplineMap entry is and as `docs/c-library-bugs.md` lists them — cost if wrong: none. +- Ruling: `FitsSipIntWorldTest.aChebyMapIsNotWrittenAsSip` also writes the FrameSet with a MathMap of the same transformation, and the reproducer `chebymap_sip.c` prints C's result for it (`MathMap written 0 ncard 2 status 0`), so the claim of the entry and the Javadoc is in committed code — cost if wrong: none. +- Ruling: the three carried-over fixes are fixup commits of `Add SplineMap` (the step-back and the labels) and `Add ChebyMap` (the SIP comparison), the commits that added the code and entries they change — cost if wrong: none. +- Ruling: no `Sweep the deferred lists after phase 9` commit — Tasks 1 to 4 removed every deferred entry and deferral note naming this phase's classes, every Rust test naming them is translated or listed, and `mvn test -Dast.writeDeferred=true` changed nothing (phase 8's precedent) — cost if wrong: none. +- Ruling: three Rust tests that name this phase's classes are neither translated nor listed: `src/serial/object_text.rs::every_class_name_matches_the_class_its_dump_names`, `tests/test_mapmerge_audit.rs::no_checklist_is_orphaned` and `tests/test_simplify_regression.rs::drift_licence_lapses_outside_the_bound` (which names ChebyMap only in a neighbouring comment); they test the Rust port's own files and licences, and phases 7 and 8 left such meta-tests unlisted — cost if wrong: `rust-tests.txt` stays incomplete for Rust-only meta-tests until a checker exists. + +### Controller + +- Ruling: accept PR #104's bad for the order-1 all-equal-knots case — a spline covering zero width is degenerate, and a Java-only condition keeping the pinned value for order 1 alone exists in neither C version — cost if wrong: one degenerate input gives bad instead of a coefficient. + +## Final fix pass + +These follow the review of the whole branch. + +### Controller + +- Ruling: the cancelled nominee's Invert attribute is restored in `Mapping.cancelWithOppositeNeighbour` (PolyMap, ChebyMap, SplineMap) and in DssMap's merge — PR #104 does so for PolyMap, and the only effect of C's behaviour is to change a Mapping the caller holds (Rust's copies never show it); the `docs/c-library-bugs.md` entry keeps SplineMap and DssMap as open C bugs with Java's line updated; this supersedes the phase 2 and 5 rule that a cancelled nominee keeps C's change — cost if wrong: `test("Invert")` and `getInvert()` of a held Mapping after `simplify` differ from the pinned C. +- Ruling: `SplineMap.db2val` ports PR #104's `Db2val` as written along Y, with no mix of the pinned and the PR's searches — the reason of the order-1 ruling — cost if wrong: the rows of a single knot interval's upper Y limit take the PR's values now rather than when the pin moves. +- Ruling: one stated rule goes in the report and this file: Java follows the pinned C, except where it reads or writes out of bounds, gives arithmetic garbage, or changes a Mapping the caller holds; there Java follows PR #104 where the PR fixes it, and otherwise gives the corrected result and records the C bug — cost if wrong: none; it states what the rulings above do. +- Ruling: the review's minor findings that are false or misleading statements in committed text (the ChebyMap Javadoc's `polyTran`, the SIP writer's "not written", the report's runtime caveat, the spec's "C's names", the rulings file's missing ruling, the probe header's build list) enter the fix pass — cost if wrong: text-only fixups. +- Ruling: the 15-digit formatting of floating-point attributes (PolyMap TolInverse, SphMap PolarLong, Region FillFactor, WcsMap), where C uses 17 digits, predates phase 9 and is named as a follow-up in the report, not fixed — cost if wrong: `getC` of those attributes differs from C in the last digits until it is fixed. + +### Implementer + +- Ruling: the PolyMap, SplineMap and DssMap tests assert that each Mapping the caller holds is as it was, value and set-ness (the probe's C after-line replaced by its before-line), where PR #104 sets a cancelled PolyMap back but leaves its attribute set (its probe output is `after p 0 set 1 q 1 set 1`) — the phase 2 convention restores set-ness exactly — cost if wrong: `test("Invert")` differs from PR #104's. +- Ruling: `SplineMapProbeTest.PR104_ROWS` names exactly the rows where the PR's library differs from the pinned C's, and `pr104DiffersOnlyInTheNamedRows` asserts the two sets are equal; the `tran_open_knots_x` rows with OutUnit unset, where both give bad at y = 0.5 (the pinned C by chance), are dropped from it, since both libraries agree there — cost if wrong: none; the expected lines are the same. +- Ruling: the DssMap change is a fixup of `Leave the WinMap a DssMap merges with at the list's Invert value, as C`, the commit that made the merge leave the WinMap changed, which is in this branch's base and not on `main` — the coordinator's rule — cost if wrong: autosquash rewrites a commit shared with the earlier phase branches. +- Ruling: the search of the other Mapping classes for a merge that leaves a held Mapping changed found only cmpmap.c's `Equal` on a CmpMap whose two components are one object (recorded since phase 2, "A CmpMap comparison changes a shared component's Invert attribute", visible in `simplify/brad.simp`); it uses different code and changes a fixture's recorded result, so it is listed in the report, not changed — cost if wrong: Java still changes a held WcsMap's Invert there, as C does. +- Ruling: the ChebyMap Javadoc says that without inverse coefficients a ChebyMap has no inverse, and that C's `astPolyTran` is not part of its public interface, rather than pointing to the package-private `polyTran` — cost if wrong: none. diff --git a/docs/rust-c-differences.md b/docs/rust-c-differences.md index cf36b1e..7c9fd5f 100644 --- a/docs/rust-c-differences.md +++ b/docs/rust-c-differences.md @@ -112,10 +112,10 @@ The entries are grouped by area, in the order the Java classes were ported. ### Cancelling a PolyMap with its inverse -- **C quirk**: when `MapMerge` cancels a nominated PolyMap with its inverse it annuls the PolyMap before restoring its Invert attribute (`polymap.c` `MapMerge`), so the PolyMap is left with the value the list applied it with, set: simplifying the inverse of a series CmpMap of a PolyMap and an inverted copy of it gives a UnitMap and leaves the copy, which the CmpMap shares, with Invert set to 0 (probe `src/test/resources/probes/polymap_cancel_probe.c`, case `inverted_series`). +- **C bug**: when `MapMerge` cancels a nominated PolyMap with its inverse it annuls the PolyMap before restoring its Invert attribute (`polymap.c` `MapMerge`), so the PolyMap is left with the value the list applied it with, set: simplifying the inverse of a series CmpMap of a PolyMap and an inverted copy of it gives a UnitMap and leaves the copy, which the CmpMap shares, with Invert set to 0 (probe `src/test/resources/probes/polymap_cancel_probe.c`, case `inverted_series`). - Rust: not compared. -- Java: as C. - Java sets back the neighbour's Invert attribute after the comparison as it was, set or unset, where C's `astSetInvert` leaves it set, so the two differ only in what `test("Invert")` gives afterwards. +- Java: the simplified Mapping is C's, but Java sets back both PolyMaps' Invert attributes as they were, set or unset, so the copy keeps Invert 1 and neither attribute is left set where it was unset (`PolyMapTest.simplifyingLeavesThePolymapsAsTheyWere`). + The hardening PR (Starlink/ast #104, at `1d0714fb`) sets the cancelled PolyMap's attribute back (the probe built against it gives `after p 0 set 1 q 1 set 1` for `inverted_series`), leaving it set; the SplineMap and DssMap merges still do not (`docs/c-library-bugs.md`, "Simplifying a CmpMap changes the Invert attribute of a component it holds"). ### Cancelling WcsMaps whose projection parameters differ @@ -344,7 +344,7 @@ The entries are grouped by area, in the order the Java classes were ported. ### A CmpMap comparison changes a shared component's Invert attribute -- **C quirk**: `Equal` (`cmpmap.c`), without its expanded lists, saves the Invert attribute of the two components it compares, sets each to the value its list gives, compares, and restores them in the same order. +- **C bug** (`docs/c-library-bugs.md`, "Comparing two CmpMaps that share a component gives a wrong answer and changes the component"): `Equal` (`cmpmap.c`), without its expanded lists, saves the Invert attribute of the two components it compares, sets each to the value its list gives, compares, and restores them in the same order. When the two components are the same object, the value it saves for the second is the one it has just set for the first, so the object is left with the first (`this`) list's value instead of its own. `Simplify` (`cmpmap.c`) compares CmpMaps this way, so simplifying `simplify/brad.map` changes the Invert attribute of its WcsMap, which the simplified CmpMap shares, from 1 to 0 (traced in the pinned library), and `brad.simp` records 0. A CmpMap applies each component with the Invert value it recorded when made (`cmpmap.c` `Transform`), so neither the original Mapping nor the simplified one transforms differently: brad.map and brad.simp give the same values in C and in Java. @@ -352,7 +352,7 @@ The entries are grouped by area, in the order the Java classes were ported. - Rust: compares owned copies, so nothing changes. - Java: as C, and the recursion guard of the simplification compares Mappings with `astEqual` as C's does: simplifying `brad.map` gives `brad.simp` and leaves the Mapping read with the WcsMap not inverted (probe `src/test/resources/probes/simplify_input_probe.c`). The `brad` row of `simplify/cases.txt` matches C; its gate compares the input's dump after simplification with the one the probe records. - Java restores each component's Invert attribute as it was, set or unset, where C's `astSetInvert` leaves it set, so the two differ only in what `test("Invert")` gives afterwards. + Java restores each component's Invert attribute as it was, set or unset, where C's `astSetInvert` leaves it set, so for two different objects the two differ only in what `test("Invert")` gives afterwards; for one object shared by both lists Java, like C, leaves it set to the first list's value, and, like C, compares it equal to itself whatever the two lists' values (`astEqual` of one object). ### The status of a MathMap with no outputs @@ -636,11 +636,175 @@ The entries are grouped by area, in the order the Java classes were ported. ### A DssMap merge leaves the WinMap's Invert attribute changed -- **C quirk**: `MapMerge` (`dssmap.c`) sets the WinMap's Invert attribute to the value the list applies it with, and restores it only when the two do not merge, since it annuls the WinMap's pointer before the restore when they do. - Simplifying the inverse of a series CmpMap of an inverted DssMap and an inverted WinMap merges the two and leaves the WinMap, which the CmpMap shares, with Invert 0 (probe case `invert_attr_both_inverted`). +- **C bug**: `MapMerge` (`dssmap.c`) sets the WinMap's Invert attribute to the value the list applies it with, and restores it only when the two do not merge, since it annuls the WinMap's pointer before the restore when they do. + Simplifying the inverse of a series CmpMap of an inverted DssMap and an inverted WinMap merges the two and leaves the WinMap, which the CmpMap shares, with Invert 0 (probe case `invert_attr_both_inverted`; `docs/c-library-bugs.md`, "Simplifying a CmpMap changes the Invert attribute of a component it holds"). - Rust: reads the terms of an owned WinMap, so nothing changes. - Java: the merged DssMap is C's, but Java sets back the WinMap's Invert attribute as it was, set or unset, whether or not the two merge, so the WinMap keeps Invert 1 (`DssMapTest.aMergeLeavesTheWinmapAsItWas`); after a failed merge the two differ only in what `test("Invert")` gives afterwards. +### A NormMap holds the Frame it is given + +- C: `astInitNormMap` (`normmap.c`) takes a clone of the Frame (`astClone`), so a change made later through the caller's pointer changes the NormMap, and the Frame keeps its ID in the NormMap's dump. +- Rust: `NormMap::new` takes ownership of the Frame, so the caller cannot change it afterwards. +- Java: as C; the NormMap holds the Frame and marks it shared (`ObjectIdOracleTest`, case `normmap`, where the Frame's ID is in C's dump). + +### Loading a NormMap or UnitNormMap whose numbers of inputs and outputs do not fit + +- C: `astLoadNormMap` stores the Frame item and the Nin and Nout the Mapping loader read, with no check (`normmap.c`); without a Frame, or with an Object that is not a Frame, the transformation fails; with Nin equal to Nout but more than the Frame's axes it transforms, `astNorm` normalising only the Frame's axes, but `MapMerge` replaces a NormMap of a plain Frame, or of a Frame that simplifies, with a Mapping of the Frame's axes, and `MapSplit` picks the Frame's axes by input number; with fewer, `astNorm` reads and writes beyond the values of a point; and with Nin and Nout different, `Transform` copies as many values as a point has (Nin forward, Nout in the inverse) into the outputs, writing beyond them or leaving some unwritten. + `astLoadUnitNormMap` refuses only a UnitNormMap of no inputs (AST__LDERR) and stores the Nout it read (`unitnormmap.c`): with Nout less than Nin the forward transformation writes beyond the last output and the inverse reads beyond the last input; with Nout equal to Nin the forward transformation's norm overwrites the last component of the unit vector and the inverse takes that component as the norm; with Nout more than Nin + 1 the forward transformation leaves the outputs between the unit vector and the norm unwritten and the inverse ignores those inputs. + The hardening PR (Starlink/ast #104, at `1d0714fb`) refuses all of these when loading. +- Rust: `NormMap::from_node` refuses a missing Frame and takes its numbers of inputs and outputs from the Frame, ignoring Nin and Nout; `UnitNormMap::from_node` makes the UnitNormMap of Nin centre values, so Nout is ignored, and no inputs is AST__BADSM from its constructor. +- Java: refuses each with AST__LDERR (no inputs with C's message), so that no NormMap or UnitNormMap whose counts do not fit is made, rather than ignoring the numbers the description gives, as Rust does. + +### The tolerance of UnitNormMap's merges + +- C: `MakeMergedMap` (`unitnormmap.c`) compares centres, and a WinMap's scales with 1, with the file's own `EQUAL` macro, `|a - b| <= 1.0E9 * max((|a| + |b|) * DBL_EPSILON, DBL_MIN)`, not `astEQUAL` (1.0E5 epsilons, at least 1.0E-12), which only `Equal` uses. + A UnitNormMap followed by the inverse of one whose centre is 2.0E-7 away cancels to a UnitMap, and a WinMap of scale 1.00000001 before a UnitNormMap is absorbed into its centre (probe `src/test/resources/probes/normmap_probe.c`, cases `unm_simplify_near_centres` and `unm_simplify_win_near_unit`). +- Rust: `make_merged_map` and `try_merge_into_unitnormmap` compare with `ast_equal`, C's `astEQUAL`, so neither pair merges into what C gives. +- Java: as C. + +### A UnitNormMap with a bad centre + +- **C bug**: the bad-centre branch of `Transform` (`unitnormmap.c:1017`) indexes its output `ptr_out[ point ][ coord_out ]`, the indices exchanged, so when the numbers of points and outputs differ it reads or writes outside the arrays and leaves outputs unwritten (`docs/c-library-bugs.md`, "A UnitNormMap with a bad centre writes outside its output"). +- Rust: every output of every point is bad, which is what the code means. +- Java: as Rust. + +### Multiply-adds contracted in a UnitNormMap's arithmetic + +- **C quirk**, the Rust repository's "`UnitNormMap`'s zero-norm guard is defeated by compiler multiply-add contraction": a compiler allowed to contract a multiply and an add into a fused multiply-add, as Apple clang is by default when it optimises, does so in `unitnormmap.c`'s inverse, `in*norm + centre`, and in `winmap.c`'s `x*b + a`. + The pinned library built for release on macOS AArch64 then gives values a few units in the last place away from the unfused ones, and, where an inverse reconstructs exactly the centre of the next UnitNormMap (fixture `neg_unitnormmap_inv_fwd_diffcentre` at its zero sample), a unit vector made of the rounding residue where the unfused arithmetic gives a bad unit vector and a zero norm (probe `src/test/resources/probes/normmap_probe.c`, built against both a default and a `-ffp-contract=off` library; the rows that differ are listed in `src/test/resources/deferred/oracle-rows.txt`). + The library built unoptimised (as the phase 8 C build is) does not contract them and gives the unfused values. +- Rust: never contracts, so it gives the unfused values. +- Java: never contracts, so it gives the unfused values; the listed probe rows are compared with the library built with `-ffp-contract=off`. + +### NormMap and UnitNormMap merges leave Invert attributes set + +- C: `MapMerge` (`normmap.c`) sets the nominated NormMap's Invert attribute to the value the list applies it with and puts it back with `astSetInvert( map, map_inv )`; `MapMerge` (`unitnormmap.c`) does the same to both Mappings of each pair it offers to `MakeMergedMap`, before either is annulled. + Each attribute ends with the value it had, but set, where it may have been unset. +- Rust: holds the Mappings with the attribute unset and passes the list's values alongside. +- Java: NormMap's merge neither reads nor changes the attribute, since nothing in it depends on the direction; UnitNormMap's restores each attribute as it was, set or unset, so the two differ from C only in what `test("Invert")` gives afterwards. + +### Loading an XphMap whose order or numbers of inputs and outputs do not fit + +- C: `astLoadXphMap` (`xphmap.c`) stores the Order item and the Nin and Nout the Mapping loader read, with no check, where `astInitXphMap` refuses an order outside 0 to `AST__MXORDHPX` (27); `Transform` shifts 1 by the order, which is undefined for a negative order or one of 31 or more, and multiplies the result by up to 9 in an `int`, which overflows from order 28; it reads two inputs and writes two outputs, reading beyond the inputs of an XphMap of one input and leaving the third output of one of three unwritten. + The hardening PR (Starlink/ast #104, at `1d0714fb`) refuses all of these when loading, with AST__LDERR. +- Rust: `XphMap::from_node` takes the order as a `u32`, so a negative order becomes a large one and the shift overflows, and ignores Nin and Nout, making an XphMap of two inputs and two outputs. +- Java: refuses each with AST__LDERR, with the hardening PR's messages, after the pinned C's check of the Type item (AST__OPT for an unknown name), where the hardening PR checks the order before reading the Type (`XphMapTest`). + +### XphMap positions far from the grid + +- C: `Transform` (`xphmap.c`) converts each position's grid indices, `ceil( x - 1.5 )` and the like, to `int`, which is undefined beyond the range of an `int`, and forms their sums and differences in `int`; a NaN input, which is not `AST__BAD`, is converted in the same way. + On AArch64 the conversion saturates, so (3e9, 5e9), in the north-polar gore 3 of an XPHN XphMap, has two equal indices and transforms to (4999999998, -2999999989), with the library built with or without optimisation. + The hardening PR (Starlink/ast #104, at `1d0714fb`) holds the indices in doubles, rounding the facet indices towards zero with `trunc`, which gives the same result for every position within range of an `int`. +- Rust: holds the indices in `i64`, converted with Rust's saturating `as`, and treats a NaN or infinite input as bad. +- Java: holds the indices in doubles as the hardening PR does, so (3e9, 5e9) is bad, and treats a NaN or infinite input as bad, as for every Mapping (`XphMapTest`). + +### XphMap merges leave Invert attributes set + +- C: `MapMerge` (`xphmap.c`) sets the Invert attributes of the two XphMaps it compares to the values the list applies them with, inverts the first and inverts it back around `astEqual`, and puts both back with `astSetInvert`, before either is annulled. + Each attribute ends with the value it had, but set, where it may have been unset (probe `src/test/resources/probes/xphmap_probe.c`). +- Rust: compares clones in the list's orientations, leaving the Mappings unchanged. +- Java: restores each attribute as it was, set or unset, so Java differs from C only in what `test("Invert")` gives afterwards. + +### The bounding boxes a ChebyMap keeps + +- C: `astInitChebyMap` (`chebymap.c`) stores the scale and offset onto [-1, 1] of the input box only when there are forward coefficients, and of the output box only when there are inverse coefficients; it reads no bounds array otherwise, so either may be null. + `astLoadChebyMap` reads a transformation's scales and offsets only when it has coefficients, takes a transformation with none of them as an ordinary polynomial, of the plain powers of its inputs, and refuses one with some but not all (AST__OBJIN). + It accepts no inputs or no outputs, as `astInitPolyMap` does, and reads only as many bounds as there are axes (probe `src/test/resources/probes/chebymap_probe.c`, cases `ctor_no_axes`, `domain_no_forward`, `load_standard_polynomial`, `load_insufficient` and `load_unused_scales`). +- Rust: `ChebyMap::new` always keeps the input box, refuses no inputs or no outputs and a bounds slice of the wrong length, refuses inverse coefficients without an output box, and its loader refuses a ChebyMap with no forward box. +- Java: as C; a bounds array that is used and null is a `NullPointerException` naming it, and one shorter than the axes AST__DIMIN, as jniast checks its arrays. + +### A ChebyMap's domain when the other box cannot be mapped + +- C: `ChebyDomain` (`chebymap.c`) finds the box of a transformation without one by `astMapBox` of the other transformation's box, and its prologue says that when this fails the bounds are bad and no error is reported; but it does not check or clear the status, so the error `astMapBox` reports reaches the caller (probe case `domain_bad_coefficient`, a forward transformation whose coefficient is bad, where `astMapBox` reports AST__MTRMT from `astInitMatrixMap`). +- Rust: `ChebyMap::domain` ignores the error and gives bad bounds, as the prologue says. +- Java: as C; `chebyDomain` throws the error. + +### `astChebyDomain` of an inverted ChebyMap with different numbers of inputs and outputs + +- **C bug**: `ChebyDomain` (`chebymap.c`) chooses the box of the ChebyMap as created but takes its number of axes from the ChebyMap as it stands, so for an inverted ChebyMap with different numbers of inputs and outputs it reads beyond the box, leaves bounds unwritten, or asks `astMapBox` for outputs that do not exist (`docs/c-library-bugs.md`). +- Rust: sizes a stored box by its own length; without the requested box it takes the count of the ChebyMap as it stands, as C does, and gives bad bounds where `map_box` fails. +- Java: the box C chooses, with that box's own number of axes in both cases, which is the number of inputs (forward) or outputs (inverse) of the ChebyMap as it stands: inverted, each direction gives the other direction's domain of the ChebyMap as created. + +### A ChebyMap in a FrameSet written as SIP + +- **C bug**: `SIPIntWorld` (`fitschan.c`) takes a ChebyMap as the SIP polynomial, since `astIsAPolyMap` holds for it, and writes its Chebyshev coefficients as SIP's coefficients of powers, without its normalisation, so the header does not describe the FrameSet (`docs/c-library-bugs.md`, "A ChebyMap is written as SIP coefficients of powers"). +- Rust: takes only a PolyMap (`sip_int_world.rs`), so a ChebyMap is passed over. +- Java: as Rust; a ChebyMap is never written as SIP coefficients, and with no other PolyMap the FrameSet is not written as FITS-WCS, as C does not write it with a MathMap of the same transformation in place of the ChebyMap. + With a plain PolyMap later in the Mapping, Java and Rust take that one as the SIP polynomial, where C stops at the ChebyMap. + +### IterInverse of a ChebyMap in its dump + +- C: a ChebyMap's `GetIterInverse` gives 0 whatever the attribute holds, but the attribute can be set; `Dump` (`polymap.c`) writes the value held when it is set and the class's default otherwise, so a ChebyMap with IterInverse set to 1 is dumped with `IterInv = 1` (probe case `no_inverse`). +- Rust: never writes IterInv, NiterInv or TolInv as set for a ChebyMap. +- Java: as C. + +### A ChebyMap compared with a PolyMap + +- **C bug**: ChebyMap's `Equal` (`chebymap.c`) calls PolyMap's, which compares the coefficients and not the class, and compares the bounding boxes only when the second Object is also a ChebyMap; PolyMap's `Equal` likewise accepts a ChebyMap. + A ChebyMap and a PolyMap with the same coefficients are therefore equal, and `MapMerge` (`polymap.c`) cancels them when they are applied in opposite directions in series, although they are different transformations (`docs/c-library-bugs.md`, "A ChebyMap cancels with a PolyMap of the same coefficients"; probe case `simp_cheby_poly_same_coeffs`). +- Rust: `ChebyMap::equal` compares only with another ChebyMap, and `try_merge` cancels only two ChebyMaps. +- Java: as C (`ChebyMap.equalTo`, `PolyMap.equalTo`). + +### A ChebyMap reduced to a linear Mapping + +- C: `MapMerge` (`polymap.c`) replaces a ChebyMap whose terms are all of degree one or less by a MatrixMap and ShiftMap with its normalisation folded in, which transform points outside the ChebyMap's bounding box, where the ChebyMap gives bad values (probe case `simp_linear_win`: the WinMap and ChebyMap pair gives a bad value at 2, outside the box, and the WinMap it simplifies to, 8x - 3, gives 13 there). +- Rust: as C. +- Java: as C. + +### The SplineMap constructor + +- C: `astSplineMap` (`splinemap.c`, the public `astSplineMapId_` and the internal `astSplineMap_` alike) takes the coefficients with the Y index varying fastest, SciPy's order, and transposes them to CMLIB's, the X index varying fastest, in which they are held and dumped; only the Fortran interface takes CMLIB's order. + `astInitSplineMap` reports AST__ATTIN with its own messages for an order outside 1 to 6, fewer coefficients than the order and knots that decrease, and reads the arrays for as many elements as its arguments say. + `astSplineKnots` and `astSplineCoeffs` take any axis other than 1 as the second. +- Rust: `SplineMap::new` takes CMLIB's order and `from_scipy` SciPy's; the errors are AST__ATTIN with its own messages, and an array of the wrong length is refused; `coeffs` refuses an axis other than 1 or 2 with AST__AXIIN. +- Java: the constructor takes SciPy's order, as C's `astSplineMap` does, with C's statuses and messages; a null array is a `NullPointerException` and one shorter than the arguments say AST__DIMIN, as jniast checks its arrays, after C's checks of the orders and numbers of coefficients and before its checks of the knots; numbers of coefficients whose products overflow an `int` are AST__ATTIN with the message of the PR that hardens C (Starlink/ast #104, at `1d0714fb`); `splineKnots` and `splineCoeffs` take any axis other than 1 as the second, as C does (probe `src/test/resources/probes/splinemap_probe.c`, cases `ctor_errors` and `knots_coeffs`). + +### Loading a SplineMap whose orders, coefficients or knots do not fit + +- C: `astLoadSplineMap` (`splinemap.c`) stores the orders, numbers of coefficients and knots it reads, and the numbers of inputs and outputs the Mapping loader read, without checking them; with an order or number of coefficients the constructor refuses, knots that decrease, or other than two inputs and two outputs, `Transform` reads and writes beyond its arrays or reports AST__INTER from `Dbvalu`. + The hardening PR (Starlink/ast #104, at `1d0714fb`) refuses each when loading, with AST__LDERR for the numbers of inputs and outputs and AST__ATTIN, with the constructor's messages naming `astLoadSplineMap`, for the rest. +- Rust: `SplineMap::from_node` stores what it reads without checking it. +- Java: refuses each as the hardening PR does, with its statuses and messages. + +### A SplineMap position the spline does not cover + +- C: a spline of order k with n coefficients covers knots k to n + 1 (counting from one), which is the whole range of the knots only when the first k and the last k knots are equal; `Db2val` (`splinemap.c`) tests only the range of the knots. + Within it but outside the range covered along X, each column's `Dbvalu` is AST__BAD, and `Db2val` combines those values arithmetically, `(BAD*dm + BAD*dp)/(dm + dp)`, which gives AST__BAD only where the rounding happens to: for knots 0, 1, 2, 3, 4 along X and 0, 0, 1, 1 along Y, -1.7976931348623155e+308 at (0.5, 0.3) and (0.5, 0.7), but AST__BAD at (0.5, 0.1) and (0.5, 0.5), whatever OutUnit is. + Outside the range covered along Y, on its upper limit when the last knots along Y are not all equal, and for a NaN Y, `Db2val` reads coefficients and knots beyond its arrays (a heap-buffer-overflow under AddressSanitizer); for a NaN X, `Dbvalu` reads before the start of its arrays, into the header `astMalloc` places there, which the sanitiser does not report, and gives NaN. + The hardening PR (Starlink/ast #104, at `1d0714fb`) tests the range covered, so that each such position, and a NaN, gives the default value (bad, or with OutUnit set the input), and finds a position on the upper limit along Y among the knots up to that limit, giving the spline's value there; it also makes the result bad when a column's value along X is bad. +- C: when the range covered along X has zero width (knots k to n + 1 equal), `Dbvalu` (`splinemap.c`) steps back from that single position to the first knot interval, of zero width, and evaluates it: for order 2 with knots 0, 1, 1, 2 it divides 0 by 0, so at x = 1 the transformation gives NaN and the rates infinity or NaN; for order 1 with knots 1, 1 it gives the first coefficient (probe case `tran_zero_width_x`). + The hardening PR's `Dbvalu` stops when it reaches the first interval and gives AST__BAD, as CMLIB's `DBVALU` does, so both splines are bad at x = 1, and so are their rates other than those of the order-1 spline with respect to x, which are zero without evaluating it. +- Rust: `db2val` indexes the same elements as the pinned C, so it panics or reads other coefficients; its `dbvalu` steps back as the pinned C does. +- Java: as the hardening PR (`SplineMap.db2val` and `SplineMap.dbvalu`; probe cases `tran_open_knots_x`, whose rows with OutUnit set outside the range covered are the PR's, and `tran_zero_width_x`, whose rows on the range of zero width are the PR's, and cases `pr_open_knots_x` and `pr_open_knots_y`, recorded only from the PR's library); a NaN or infinite input to `transform` or `rate` is bad, as for every Mapping. + +### A SplineMap on the upper limit of a single knot interval along Y + +- **C quirk**: `Db2val` (`splinemap.c`) steps back from the upper limit along Y to the last knot interval of non-zero width, but gives a bad value when that is the first interval, so a spline with a single interval along Y, such as the linear one over [0, 1] with knots 0, 0, 1, 1, is bad along y = 1, where `Dbvalu` gives the value along x = 1 (probe case `tran_linear_edges`). + The same holds along y = 1 of an order-1 SplineMap with knots 0, 1 (probe case `order1`, at (1, 1)). + The hardening PR (Starlink/ast #104, at `1d0714fb`) searches only the knots up to the upper limit of the range covered and gives bad only when no knot interval of non-zero width remains, so it gives the value in both cases. +- Rust: as C. +- Java: as the hardening PR, whose `Db2val` it ports as written (`SplineMap.db2val`; the rows of `tran_linear_edges` and `order1` that `SplineMapProbeTest.PR104_ROWS` names). + +### SplineMaps compared without their attributes + +- C: `Equal` (`splinemap.c`) compares the Invert attributes, orders, knots and coefficients, but not InvNiter, InvTol or OutUnit, so `MapMerge` cancels a SplineMap with the inverse of one that differs only in those, though OutUnit changes the transformation outside the knots and InvNiter and InvTol the inverse (probe cases `equal` and `simp_outunit_differs`). +- Rust: as C. +- Java: as C. + +### SplineMap merges change Invert attributes + +- **C bug**: `MapMerge` (`splinemap.c`) sets the nominated SplineMap's Invert attribute to the value the merge list applies it with, and the neighbour's to the same value while it compares them, setting each back with `astSetInvert`, so an attribute that was unset is left set; when the two cancel it annuls its pointer to the nominated SplineMap without setting it back. + The list holds the Mapping being simplified's own components, so simplifying an inverted CmpMap of a SplineMap and the inverse of an equal one leaves the second SplineMap, which the caller may hold, with its Invert attribute changed, and it then transforms in the other direction (`docs/c-library-bugs.md`, "Simplifying a CmpMap changes the Invert attribute of a component it holds"; probe cases `simp_inverted_cmpmap` and `simp_cmpmap_attrs`). +- Rust: compares the SplineMaps in the list's orientations without changing them. +- Java: the simplified Mapping is C's, but Java sets back both SplineMaps' Invert attributes as they were, set or unset, whether or not they cancel, so a SplineMap the caller holds is unchanged (`SplineMapProbeTest.simplifyingAnInvertedCmpMapLeavesTheSplineMapsAsTheyWere` and `simplifyingLeavesNoInvertAttributeSet`). + +### Multiply-adds contracted in a SplineMap's arithmetic + +- C: built with a compiler that contracts a multiply and an add into a fused multiply-add, as Apple clang does by default when it optimises, `splinemap.c` gives values a few units in the last place away from the unfused ones: `Dbvalu`'s step `work[jj+1]*dm + work[jj]*dp`, and `IterInverse`'s first guess `2*u - a` and convergence test `x*x + y*y` are fused (probe `src/test/resources/probes/splinemap_probe.c`, built against both a default and a `-ffp-contract=off` library; the rows that differ are listed in `src/test/resources/deferred/oracle-rows.txt`). + The Rust repository's `spline_inverse_oracle`, `src/test/resources/oracle/spline_inverse.json` here, holds the unfused values. +- Rust: never contracts. +- Java: never contracts, so it gives the unfused values. + ## Units Rust's `src/units/` departs from C's `unit.c` in the following ways; Java follows C in each. diff --git a/docs/superpowers/plans/2026-11-20-pure-java-ast-phase9-mappings.md b/docs/superpowers/plans/2026-11-20-pure-java-ast-phase9-mappings.md new file mode 100644 index 0000000..f5787c1 --- /dev/null +++ b/docs/superpowers/plans/2026-11-20-pure-java-ast-phase9-mappings.md @@ -0,0 +1,161 @@ +# Pure-Java AST Phase 9 (the Mappings jniast lacks) Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. +> Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** C's public `NormMap`, `UnitNormMap`, `ChebyMap` and `SplineMap`, and the protected `XphMap`, construct, transform, compare, simplify, dump and load as C's do, with a public API made by the rule jniast's generator applies to C, so that every C fixture and Rust test still deferred for these classes runs, `lsst2.ast` included. + +**Architecture:** Port the Rust port's `src/mappings/normmap.rs`, `unitnormmap.rs`, `xphmap.rs`, `chebymap.rs` and `splinemap.rs` onto the phase 1 to 8 Mapping machinery, with C (`reference/starlink-ast/src/normmap.c`, `unitnormmap.c`, `xphmap.c`, `chebymap.c`, `splinemap.c`, and the ChebyMap branch of `polymap.c`) as the authority wherever the two differ. +`ChebyMap` extends `PolyMap`, as C's structure and vtab do; the others extend `Mapping`. + +**Tech Stack:** as phases 1 to 8: Java 8 (`--release 8`), Maven, JUnit 5, Jackson (test scope), Error Prone, Checkstyle, PMD, Spotless; JDK 21 to build. + +**Spec:** `docs/superpowers/specs/2026-11-02-pure-java-ast-design.md` ("Later phases", item 9, first part; Goals: "Classes that are in AST but not jniast ... added later following jniast's conventions"). +This branch, `u/timj/phase9-nonjniast`, is stacked on phase 8 (`u/timj/phase8-stc`, `f0af84f`). +The earlier plans' Shared Design sections and the rulings in `docs/reports/2026-11-*-phase*-rulings.md` still apply where this plan does not change them. +The scope survey this plan was written from covers all of item 9; later parts are Table, FitsTable and FitsChan `-TAB` (9b), Moc and MocChan (9c), and the newer functions on jniast's classes (9d). + +## Global Constraints + +- Every Global Constraint of the phase 1 plan applies unchanged (Java 8, no runtime dependencies, jniast signatures for jniast's classes, C at `3d3f255f`, `default` and final `else` throw `AST__INTER`, `MODERN-JAVA` tags, no heuristics the original lacks, expected values from C only, share where C calls `astClone` and copy where C calls `astCopy`, British spelling, one sentence per line in Markdown). +- Public API of a class jniast lacks: what jniast's generator (`reference/starjava/jniast/src/perl/JMaker.pm`) makes from the C prologue (Shared Design, "The API rule"), and nothing else; exactly: + - `NormMap(Frame frame)`. + - `UnitNormMap(int ncoord, double[] centre)`. + - `ChebyMap(int nin, int nout, int ncoeff_f, double[] coeff_f, int ncoeff_i, double[] coeff_i, double[] lbnd_f, double[] ubnd_f, double[] lbnd_i, double[] ubnd_i)`, `double[][] chebyDomain(boolean forward)` (lower bounds then upper bounds, as jniast's `Region.getRegionBounds`). + - `SplineMap(int kx, int ky, int nx, int ny, double[] tx, double[] ty, double[] cu, double[] cv)`; `getInvNiter()`/`setInvNiter(int)`, `getInvTol()`/`setInvTol(double)`, `getOutUnit()`/`setOutUnit(boolean)`, `getSplineKx()`, `getSplineKy()`, `getSplineNx()`, `getSplineNy()` (read-only, `int`); `double[] splineKnots(int axis)`, `double[] splineCoeffs(int axis)` (the whole array C would fill). + - `XphMap` is package-private, as C's constructor is protected. +- No public member is added to a jniast class in this phase. +- Before porting a class, read Rust `docs/porting-hazards.md` (H4, H7, H9 above all) and every entry naming the class in `docs/issues/c-library-quirks.md`, and this repository's `docs/rust-c-differences.md` and `docs/c-library-bugs.md`. +- Rust comments cite older C line numbers; find each C function by name in the pinned source. +- Values must match C to the oracle tolerances; when one does not, find the C function that computes it before touching the arithmetic (H7). +- Tolerances for values that pass through `java.lang.Math` come from an error bound worked out from the computation, never from the drift seen on this machine: CI runs on x86-64 Linux with Java 8, 21 and 25. +- A row whose C value differs because the C build contracted a multiply-add goes on `src/test/resources/deferred/oracle-rows.txt` with that reason, as the spec's Java version section says; the cause is shown, not assumed. +- C probes go in `src/test/resources/probes/` with the build recipe in the header, built against the pinned C in `scratchpad/build-ast`, values printed with `%.17g`; source and output are committed. +- A C library bug found goes in `docs/c-library-bugs.md` with a reproducer in `docs/c-library-bugs/`; a C quirk that changes behaviour also gets its `docs/rust-c-differences.md` entry. +- Classes still absent after this phase: Table, FitsTable, Moc, MocChan, Plot and its Grf classes, Plot3D, XmlChan, YamlChan, StcsChan. + +## Review Focus + +1. A NormMap of a SkyFrame, of a CmpFrame holding a SkyFrame, and of a plain Frame, given longitudes outside 0 to 2π, latitudes past a pole and points bad on one axis: the normalised values C gives, the same in both directions, and C's simplification of the NormMap of a plain Frame to a UnitMap (test in Task 1, from `normmap_probe.c`). +2. A UnitNormMap given its own centre, a point one ulp from it, a bad coordinate, and 1-D and 3-D centres: the unit vector and norm C gives, the zero-norm case included, with any row that depends on C's multiply-add contraction shown to and listed as Global Constraints say (test in Task 1, from the probe). +3. A ChebyMap given points outside its bounding box, a ChebyMap with no inverse coefficients (iterative inverse, `IterInverse` set and unset), and a ChebyMap next to a PolyMap and a WinMap in a CmpMap: bad outside the domain, C's iterative inverse, and C's `MapMerge` result (test in Task 3, from `chebymap_probe.c`). +4. A SplineMap given points outside the knot range and points whose inverse does not converge within `InvNiter`, with `OutUnit` set and unset and `InvTol` changed: C's values, and `IsSimple` cleared when any of the three changes as C's setters clear it (test in Task 4, from `spline_inverse_oracle` and `splinemap_probe.c`). +5. Each new class dumped, read back, copied, compared with `equals`, inverted and put in a FrameSet read from a file (`lsst2.ast`): C's dump text, `equals` as C's `Equal` (ChebyMap compares bounds and both coefficient sets), and the transform oracle's values (tests in Tasks 1 to 4, from the fixtures and the oracles). + +--- + +## Shared Design + +### The API rule + +The spec asks for classes jniast lacks to follow jniast's conventions; jniast's classes were generated from the C prologues by `JMaker.pm`, so its rules are the convention: + +- A constructor takes the C constructor's arguments without `options`, in C order, with C's names and explicit counts beside arrays (`PolyMap(int nin, int nout, int ncoeff_f, double[] coeff_f, int ncoeff_i, double[] coeff_i)`). +- A function `astFoo(this, ..., status)` becomes `foo(...)`; C out-parameter arrays that the caller sizes from the object's own attributes become a returned array (`Region.getRegionBounds()` returns `double[][]`); a C boolean argument is a Java `boolean`. +- A public attribute gets `get()` and, unless read-only, `set(value)`, typed as C's synopsis says (Integer `int`, Floating point `double`, Boolean `boolean`, String `String`); test and clear go through `AstObject.test(String)` and `clear(String)`, as in jniast. +- Constants are `public static final` fields on the class whose C header defines them. +- Javadoc is drawn from the C prologue, with `@throws AstException` as jniast's. + +Task 1 records this rule in the spec (a new paragraph under "Decisions already made", marked as the user's to confirm in the phase report), and adds the check: `src/test/resources/astjava-api.txt`, in the format of `jniast-api.txt`, lists every public and protected member of each public class jniast lacks, and `JniastApiTest` fails on a public class that is in neither file, on a member of such a class that is not listed, and on a listed member that does not exist. + +### Where the code goes + +- `NormMap`, `UnitNormMap`, `XphMap`, `ChebyMap`, `SplineMap`: one file each, registered in `ObjectRegistry` (class name, loader, `isA` chain); `NativeStream.parentOf` already names their parents. +- Simplification goes where each class's `MapMerge` is: the class's own `mapMerge` override, and the ChebyMap branch of `polymap.c`'s `MapMerge` in `PolyMap.java` (the branch `PolyMap.java:1015-1016` says is absent). +- `ChebyMap extends PolyMap`: its state (the bounds of each direction) and its `PolyTran`, `Equal`, `Copy` and `Dump` overrides; the per-input scaling PolyMap applies to a ChebyMap comes from `chebymap.c`, not from Rust's composition. +- C's `astMAKE_ISA(ChebyMap,Mapping)` names Mapping, not PolyMap, as the parent: Task 3's probe prints `astIsAPolyMap` of a ChebyMap and the `Class` and `IsA` lines of its dump, and Java's `isA` follows what C prints. + +### Taken from C rather than Rust + +1. **Constructors check their arguments as C's do**, with C's status and message (`AST__BADNI`, `AST__BDPAR` and the rest from each `astInit_`), not Rust's errors; a null array or Frame is a `NullPointerException` naming the argument, as phase 6 ruled for jniast arguments. +2. **Copy and share follow C**: NormMap copies its Frame at construction (`normmap.c` `astInitNormMap_`); each class's Copy and Dump follow its C file. +3. **Loaders follow C where C's result is usable** and raise `AST__LDERR` where C would store a null and fail later (H9). +4. **Attribute setters clear `IsSimple` where C's do** (SplineMap's `InvNiter`, `InvTol`, `OutUnit`, and PolyMap's inherited attributes on a ChebyMap). + +### Gates and deferred lists + +- Each Rust test file becomes a Java test class as before (`test_normmap.rs` → `NormMapTest`, `test_unitnormmap.rs` → `UnitNormMapTest`, `test_xphmap.rs` → `XphMapTest`, `test_chebymap.rs` → `ChebyMapTest`, `test_splinemap.rs` → `SplineMapTest`, `test_splinemap_c_api.rs` → `SplineMapCApiTest`); the `xphmap_oracle` and `spline_inverse_oracle` `cases.rs` files are converted to `src/test/resources/oracle/*.json` with `CasesToJson`. +- The tests of other Rust files that name these classes (survey: `test_equal.rs`, `test_numeric_rate.rs`, `test_poly_bad.rs`, `test_map_split_oracle.rs`, `test_object_id_oracle.rs`, `test_nan_protocol.rs`, `test_bulk_kernels.rs`, `test_constructor_checks.rs`, `test_attr_test_clear_oracle.rs`, `test_clear_on_set.rs`, `test_transform_oracle.rs`, `test_fitschan_wcs_write.rs` and others) are translated into the existing Java classes for those files, and the in-test skips that name these classes are removed (`AttrTestClearOracleTest`, `ClearOnSetTest`, `FitsChanWcsWriteTest` (`lsst2`), `PolyBadTest`, `NumericRateTest`, `EqualTest`, `TransformOracleTest` (`tnx-cheb`), `MapSplitOracleTest`, `ObjectIdOracleTest`, `RemoveRegionsOracleTest` (its two NormMap cases), `BulkKernelsTest`, `NanOutputsTest`). +- Each task removes from the deferred lists the entries whose only missing class is now present (`mvn test -Dast.writeDeferred=true`, then check that the diff removes only entries naming the task's classes); counts from the survey are given per task as the expected order of size, and a difference is explained in the task report. +- `rust-tests.txt` does not list every Rust test of these classes (survey section 5); each task's sweep finds the unlisted ones in its files. + +--- + +### Task 1: The API rule, NormMap and UnitNormMap + +**Files:** +- Create: `NormMap.java`, `UnitNormMap.java`, `src/test/resources/astjava-api.txt`, `src/test/resources/probes/normmap_probe.c` and its output +- Modify: `docs/superpowers/specs/2026-11-02-pure-java-ast-design.md` (the API rule), `JniastApiTest.java`, `ObjectRegistry.java`, and the Java tests named in Gates whose skips name NormMap or UnitNormMap +- Test: `NormMapTest` (`test_normmap.rs`, 13), `UnitNormMapTest` (`test_unitnormmap.rs`, 32), `NormMapProbeTest` (Review Focus 1 and 2), `JniastApiTest` (a public class in neither API file fails; a missing or extra member fails) + +**Interfaces:** +- Produces: `public class NormMap extends Mapping`, `public class UnitNormMap extends Mapping`; `astjava-api.txt` and its check, which Tasks 3 and 4 extend. + +- [ ] **Step 1: Write the probe** `normmap_probe.c` (Review Focus 1 and 2: each input printed with `%.17g`, forward and inverse; `astSimplify` of a NormMap of a plain Frame, of a NormMap between two other Mappings, and of a UnitNormMap next to a ShiftMap and a WinMap, as dumps; `testnormmap.c` and `testunitnormmap.c` cases), build it and commit source and output; for each UnitNormMap row, also build the probe with `-ffp-contract=off` and record which rows change. +- [ ] **Step 2: Write the failing tests** named under Files, and the API-file check. +- [ ] **Step 3: Run** `mvn test -Dtest='NormMap*Test,UnitNormMapTest,JniastApiTest'` — Expected: FAIL (classes missing). +- [ ] **Step 4: Implement** from `normmap.c` (`Transform`, `Equal`, `MapMerge`, `MapSplit`, `Rate`, `RemoveRegions`, `Dump`, loader) and `unitnormmap.c` (`Transform`, `Equal`, `MapMerge`, `Dump`, loader), with Rust's files as the guide; add the API rule to the spec and both classes to `astjava-api.txt`. +- [ ] **Step 5: Run** the Step 3 command, `mvn test -Dast.writeDeferred=true` and then `mvn -q test` — Expected: PASS; the list diff removes only NormMap and UnitNormMap entries (about 15 and 27 in each fixture list, 6 and 39 in `rust-tests.txt`). +- [ ] **Step 6: Commit** `Add NormMap and UnitNormMap`, and the list changes as `Run the NormMap and UnitNormMap fixtures`. + +### Task 2: XphMap + +**Files:** +- Create: `XphMap.java`, `src/test/resources/oracle/xphmap.json` +- Modify: `ObjectRegistry.java` +- Test: `XphMapTest` (`test_xphmap.rs`, 6, and the 8 `xphmap_oracle` cases), `NanProtocolTest` (its XphMap cases) + +**Interfaces:** +- Produces: package-private `final class XphMap extends Mapping` with a package-private constructor taking `astInitXphMap_`'s `order` and `type` arguments, for Moc in phase 9c. + +- [ ] **Step 1: Convert** `xphmap_oracle/cases.rs` with `CasesToJson`, and write the failing tests. +- [ ] **Step 2: Run** `mvn test -Dtest='XphMapTest,NanProtocolTest'` — Expected: FAIL. +- [ ] **Step 3: Implement** from `xphmap.c` (`Transform`, `Equal`, `MapMerge`, `Dump`, loader), with Rust `xphmap.rs` as the guide. +- [ ] **Step 4: Run** the Step 2 command, `mvn test -Dast.writeDeferred=true` and then `mvn -q test` — Expected: PASS; the list diff removes only XphMap entries (about 7 in each fixture list, 1 in `rust-tests.txt`). +- [ ] **Step 5: Commit** `Add XphMap`. + +### Task 3: ChebyMap + +**Files:** +- Create: `ChebyMap.java`, `src/test/resources/probes/chebymap_probe.c` and its output +- Modify: `PolyMap.java` (the ChebyMap branch of `MapMerge`, and whatever hooks `ChebyMap` needs, package-private), `ObjectRegistry.java`, `astjava-api.txt`, and the Java tests named in Gates whose skips name ChebyMap +- Test: `ChebyMapTest` (`test_chebymap.rs`, 39), `ChebyMapProbeTest` (Review Focus 3, `testchebymap.c`'s cases, and the `isA` question of Shared Design), `TransformOracleTest` (`tnx-cheb` inverse), `PolyBadTest`, `NumericRateTest`, `EqualTest` (2 ChebyMap cases) + +**Interfaces:** +- Consumes: phase 5's `PolyMap` (`polyTran`, the iterative inverse, `IterInverse`, `NiterInverse`, `TolInverse`). +- Produces: `public class ChebyMap extends PolyMap`. + +- [ ] **Step 1: Write the probe** `chebymap_probe.c` (Review Focus 3; `astChebyDomain` of each direction, of an inverted ChebyMap, and of one with no inverse coefficients; `astIsAPolyMap` and the dump of a ChebyMap; `astSimplify` of a ChebyMap with a PolyMap, a WinMap and its own inverse in series), build it and commit source and output. +- [ ] **Step 2: Write the failing tests** named under Files. +- [ ] **Step 3: Run** `mvn test -Dtest='ChebyMap*Test,TransformOracleTest,PolyBadTest,NumericRateTest,EqualTest'` — Expected: FAIL. +- [ ] **Step 4: Implement** from `chebymap.c` and the ChebyMap branch of `polymap.c` `MapMerge`, with Rust `chebymap.rs` as the guide; add the class to `astjava-api.txt`. +- [ ] **Step 5: Run** the Step 3 command, `mvn test -Dast.writeDeferred=true` and then `mvn -q test` — Expected: PASS; the list diff removes only ChebyMap entries (about 6 or 7 in each fixture list, 6 in `rust-tests.txt`). +- [ ] **Step 6: Commit** `Add ChebyMap`. + +### Task 4: SplineMap + +**Files:** +- Create: `SplineMap.java`, `src/test/resources/oracle/spline_inverse.json`, `src/test/resources/probes/splinemap_probe.c` and its output, `src/test/resources/splinemap/` (the `ast_tester/fixtures/programs/testsplinemap` data the C-API test reads, if it is not read in place) +- Modify: `ObjectRegistry.java`, `astjava-api.txt`, and the Java tests named in Gates whose skips name SplineMap +- Test: `SplineMapTest` (`test_splinemap.rs`, 21, and the unit test in `splinemap.rs`), `SplineMapCApiTest` (`test_splinemap_c_api.rs`, 7), `SplineMapProbeTest` (Review Focus 4, from the oracle and the probe), `AttrTestClearOracleTest`, `ClearOnSetTest`, `ConstructorChecksTest`, `FitsChanWcsWriteTest` (`lsst2`), the `lsst2.ast` rows of `framesets.txt` and `wcsconv.txt` + +**Interfaces:** +- Produces: `public class SplineMap extends Mapping`. + +- [ ] **Step 1: Write the probe** `splinemap_probe.c` (Review Focus 4: points outside the knots, a non-converging inverse with `OutUnit` set and unset, `InvTol` changed, `IsSimple` after each setter; `astSplineKnots` and `astSplineCoeffs` of each axis; `astSimplify` of a SplineMap with its inverse and with a WinMap; an inverted SplineMap's `Rate`), build it and commit source and output; convert `spline_inverse_oracle/cases.rs`. +- [ ] **Step 2: Write the failing tests** named under Files. +- [ ] **Step 3: Run** `mvn test -Dtest='SplineMap*Test,AttrTestClearOracleTest,ClearOnSetTest,ConstructorChecksTest,FitsChanWcsWriteTest'` — Expected: FAIL. +- [ ] **Step 4: Implement** from `splinemap.c` (`Transform` with C's `Dbvalu` and the Newton-Raphson inverse, `Rate`, `MapMerge`, `Equal`, the attributes, `astSplineKnots`, `astSplineCoeffs`, `Dump`, loader), with Rust `splinemap.rs` as the guide; Rust specialises `Dbvalu` per spline order, a speed-up that must give C's values exactly (c-library-quirks "SplineMap's `Dbvalu` loops to the spline order at run time"); add the class to `astjava-api.txt`. +- [ ] **Step 5: Run** the Step 3 command, `mvn test -Dast.writeDeferred=true` and then `mvn -q test` — Expected: PASS; the list diff removes only SplineMap entries (about 5 or 6 in each fixture list, `lsst2.ast` in `framesets.txt` and `wcsconv.txt`, 9 in `rust-tests.txt`). +- [ ] **Step 6: Commit** `Add SplineMap`, and the list changes as `Run the SplineMap fixtures`. + +### Task 5: Sweep and report + +**Files:** +- Modify: the deferred lists, the Javadoc deferral notes that remain (`PolyMap`, `NativeStream`, `ObjectRegistry`, the tests named in Gates), `docs/rust-c-differences.md`, `docs/c-library-bugs.md` +- Create: `docs/reports/2026-11-20-phase9-report.md`, `docs/reports/2026-11-20-phase9-rulings.md` + +- [ ] **Step 1: Sweep:** `rg` the Rust `tests/` directory and the Java test sources for NormMap, UnitNormMap, XphMap, ChebyMap and SplineMap; each Rust test is translated or listed in `rust-tests.txt` with a reason, including the files the survey found listed nowhere (`test_chebymap.rs`, `test_splinemap.rs`, `test_splinemap_c_api.rs`, `test_normmap.rs`, `test_xphmap.rs`); `mvn test -Dast.writeDeferred=true` changes nothing. +- [ ] **Step 2: Write the report** in the layout of `docs/reports/2026-11-19-phase8-report.md`: what was ported, the API rule and the spec change for the user to confirm, the gates and their counts, the deferred-list changes, the C bugs found (in `docs/c-library-bugs.md`), the gaps, and what the next phase takes (9b: Table, FitsTable and FitsChan `-TAB`, with the KeyMap public-API question it raises); and the rulings file, citing commits by subject. +- [ ] **Step 3: Run** `mvn -q verify` and `mvn -q test -Djvm=/opt/homebrew/opt/openjdk@27/libexec/openjdk.jdk/Contents/Home/bin/java` — Expected: PASS. +- [ ] **Step 4: Commit** `Sweep the deferred lists after phase 9` and `Report phase 9`. diff --git a/docs/superpowers/specs/2026-11-02-pure-java-ast-design.md b/docs/superpowers/specs/2026-11-02-pure-java-ast-design.md index 9247ff3..9708f70 100644 --- a/docs/superpowers/specs/2026-11-02-pure-java-ast-design.md +++ b/docs/superpowers/specs/2026-11-02-pure-java-ast-design.md @@ -103,6 +103,12 @@ First phase (the prototype): - The ERFA and PAL subset is ported from Rust, as the Rust port did, rather than using a third-party jar. - Rust's structural speed-ups (whole-array loops, the NaN protocol, bulk kernels) are ported; its hardware-SIMD paths, which Java 8 cannot express, are ported as their scalar fallbacks and tagged `MODERN-JAVA`. - `Frame extends Mapping` is kept because jniast's hierarchy needs it (FrameSet and later Region are Mappings); a plain Frame transforms as the identity, as in C, and nothing more of C's Frame-as-Mapping handling is ported. +- The public API of a class that is in AST but not in jniast is what jniast's generator (`reference/starjava/jniast/src/perl/JMaker.pm`) would make from the C prologue, and nothing else; everything else the class needs is package-private, and a class whose C constructor is protected is package-private itself. + A constructor takes the C constructor's arguments without `options`, in C order, with C's names in camelCase and explicit counts beside arrays, as astjava's `PolyMap(int nin, int nout, int ncoeffF, double[] coeffF, int ncoeffI, double[] coeffI)` has jniast's `ncoeff_f` and `coeff_f` as `ncoeffF` and `coeffF`. + A function `astFoo(this, ..., status)` becomes `foo(...)`; a C out-parameter array that the caller sizes from the object's own attributes becomes a returned array, as `Region.getRegionBounds()` returns `double[][]`; a C boolean argument is a Java `boolean`. + A public attribute gets `get()` and, unless read-only, `set(value)`, typed as C's synopsis says (Integer `int`, Floating point `double`, Boolean `boolean`, String `String`); test and clear go through `AstObject.test(String)` and `clear(String)`, as in jniast. + Constants are `public static final` fields on the class whose C header defines them, and Javadoc is drawn from the C prologue, with `@throws AstException` as jniast's. + `src/test/resources/astjava-api.txt` lists the public and protected members of each such class, in the format of `jniast-api.txt`, and `JniastApiTest` fails on a public class in neither file, on an unlisted member of a listed class, and on a listed member that does not exist. ## Constraints diff --git a/src/main/java/uk/ac/starlink/ast/ChebyMap.java b/src/main/java/uk/ac/starlink/ast/ChebyMap.java new file mode 100644 index 0000000..0b98639 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/ChebyMap.java @@ -0,0 +1,627 @@ +package uk.ac.starlink.ast; + +import java.util.Arrays; +import java.util.Objects; + +/** + * A 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: + * + *
    + *
  • Tn(x') is the nth Chebyshev polynomial of the first kind: T0(x') = 1, T1(x') = x', + * Tn+1(x') = 2.x'.Tn(x') - Tn-1(x') + *
  • x' is the input axis value, x, offset and scaled to the range [-1, 1] as x ranges over a + * specified bounding box, given when the ChebyMap is created. The input positions, x, + * supplied to the forward transformation must fall within the bounding box - bad axis values + * ({@link #AST__BAD}) are generated for points outside the bounding box. + *
+ * + *

For an N-dimensional ChebyMap, the forward transformation is a generalisation of the above + * form. Each output axis value is the sum of {@code 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 independently by separate sets of + * coefficients, supplied when the ChebyMap is created. If no coefficients are supplied to define + * the inverse transformation, an iterative inverse is not available, so the ChebyMap has no + * inverse transformation; C's {@code astPolyTran}, which fits one, is not part of this class's + * public interface. + * + *

The ChebyMap class does not define any new attributes beyond those which are applicable to + * all PolyMaps. A ChebyMap never uses an iterative inverse: its IterInverse attribute is always + * zero, and setting or clearing it has no effect on the transformation. + * + *

A transformation whose coefficients were read from a description without a bounding box is + * an ordinary polynomial of its inputs, as in a PolyMap. + * + *

Ported from C {@code chebymap.c}, with Rust {@code mappings/chebymap.rs} as a guide. As in + * C, the class extends PolyMap, which holds the coefficients and transforms with the values of the + * Chebyshev polynomials in place of the powers of the inputs; the bounding box of each + * transformation is kept as the scale and offset that map it onto [-1, 1]. + */ +public class ChebyMap extends PolyMap { + + /** + * The scale of each input of the ChebyMap as created onto [-1, 1] (C's {@code scale_f}); null + * when the forward transformation has no bounding box. + */ + private double[] scaleF; + + /** The offsets that go with {@link #scaleF} (C's {@code offset_f}). */ + private double[] offsetF; + + /** + * The scale of each output of the ChebyMap as created onto [-1, 1] (C's {@code scale_i}); null + * when the inverse transformation has no bounding box. + */ + private double[] scaleI; + + /** The offsets that go with {@link #scaleI} (C's {@code offset_i}). */ + private double[] offsetI; + + /** + * Creates a ChebyMap. + * + *

Each coefficient is described by a group of {@code 2 + nin} elements of {@code coeffF}: + * the coefficient value; the integer index of the ChebyMap output which uses the coefficient + * within its defining expression (the first output has index 1); and the integer powers to use + * with each input coordinate value (powers must not be negative, and floating point values are + * rounded to the nearest integer). For instance, if the ChebyMap has 3 inputs and 2 outputs, + * the group {@code (1.2, 2.0, 1.0, 3.0, 0.0)} describes a coefficient with value 1.2 which is + * used within the definition of output 2. The output value is incremented by the product of the + * coefficient value, the value of the Chebyshev polynomial of power 1 evaluated at input + * coordinate 1, and the value of the Chebyshev polynomial of power 3 evaluated at input + * coordinate 2. Input coordinate 3 is not used since its power is specified as zero. As another + * example, the group {@code (-1.0, 1.0, 0.0, 0.0, 0.0)} adds a constant value -1.0 onto output + * 1 (it is a constant value since the power for every input axis is given as zero). Each final + * output coordinate value is the sum of the {@code ncoeffF} terms described by the groups + * within the supplied array. The inverse coefficients in {@code coeffI} are described the same + * way with groups of {@code 2 + nout} elements, inputs and outputs transposed. + * + * @param nin the number of input coordinates + * @param nout the number of output coordinates + * @param ncoeffF the number of non-zero coefficients necessary to define the forward + * transformation of the ChebyMap. If zero is supplied, the forward transformation will be + * undefined + * @param coeffF an array containing {@code ncoeffF*(2 + nin)} elements describing the forward + * coefficients; may be null if {@code ncoeffF} is zero + * @param ncoeffI the number of non-zero coefficients necessary to define the inverse + * transformation of the ChebyMap. If zero is supplied, the inverse transformation will be + * undefined + * @param coeffI an array containing {@code ncoeffI*(2 + nout)} elements describing the inverse + * coefficients; may be null if {@code ncoeffI} is zero + * @param lbndF an array containing the lower bounds of the input bounding box within which the + * ChebyMap is defined, {@code nin} elements. It is not used if {@code ncoeffF} is zero, and + * so may be null + * @param ubndF an array containing the upper bounds of the input bounding box, {@code nin} + * elements; not used if {@code ncoeffF} is zero + * @param lbndI an array containing the lower bounds of the output bounding box within which the + * ChebyMap is defined, {@code nout} elements. It is not used if {@code ncoeffI} is zero, + * and so may be null + * @param ubndI an array containing the upper bounds of the output bounding box, {@code nout} + * elements; not used if {@code ncoeffI} is zero + * @throws NullPointerException if a bounds array that is used is null + * @throws AstException with status {@code AST__BADCI} if a coefficient names an output that + * does not exist, {@code AST__BADPW} if it has a negative power, {@code AST__DIMIN} if an + * array is too short, or {@code AST__BADBX} if a bounding box that is used has zero width on + * an axis + */ + public ChebyMap( + int nin, + int nout, + int ncoeffF, + double[] coeffF, + int ncoeffI, + double[] coeffI, + double[] lbndF, + double[] ubndF, + double[] lbndI, + double[] ubndI) { + super("ChebyMap", nin, nout, ncoeffF, coeffF, ncoeffI, coeffI); + if (ncoeffF > 0) { + double[][] so = normalisation(nin, lbndF, ubndF, "lbnd_f", "ubnd_f", "Input", "input"); + scaleF = so[0]; + offsetF = so[1]; + } + if (ncoeffI > 0) { + double[][] so = normalisation(nout, lbndI, ubndI, "lbnd_i", "ubnd_i", "Output", "output"); + scaleI = so[0]; + offsetI = so[1]; + } + } + + /** + * The scales and offsets C's {@code astInitChebyMap} computes to map the box {@code lbnd} to + * {@code ubnd} of {@code naxes} axes onto [-1, 1], after the checks jniast makes of its arrays. + */ + private static double[][] normalisation( + int naxes, double[] lbnd, double[] ubnd, String lname, String uname, String space, String axis) { + Objects.requireNonNull(lbnd, lname); + Objects.requireNonNull(ubnd, uname); + checkLength(lname, lbnd, naxes); + checkLength(uname, ubnd, naxes); + double[] scale = new double[naxes]; + double[] offset = new double[naxes]; + for (int i = 0; i < naxes; i++) { + if (ubnd[i] != lbnd[i]) { + scale[i] = 2.0 / (ubnd[i] - lbnd[i]); + offset[i] = -(ubnd[i] + lbnd[i]) / (ubnd[i] - lbnd[i]); + } else { + throw Ast.err( + AstException.AST__BADBX, + "astInitChebyMap(ChebyMap): " + space + " bounding box has zero width on " + axis + " axis " + + (i + 1) + "."); + } + } + return new double[][] {scale, offset}; + } + + /** An {@code AST__DIMIN} error if {@code values} has fewer than {@code naxes} elements. */ + private static void checkLength(String what, double[] values, int naxes) { + if (values.length < naxes) { + throw Ast.err( + AstException.AST__DIMIN, + "astChebyMap(ChebyMap): The " + what + " array holds " + values.length + + " values.\nThis should not be less than " + naxes + "."); + } + } + + /** + * Loads a ChebyMap from its description, as C's {@code astLoadChebyMap} does: for each + * transformation that has coefficients, the scales {@code FSCL} and offsets {@code + * FOFF} of the inputs (forward) or {@code ISCL} and {@code IOFF} of the outputs + * (inverse). A transformation with none of them is an ordinary polynomial; items of a + * transformation without coefficients are not read. + * + * @throws AstException with status {@code AST__OBJIN} if a transformation has some of its + * scales and offsets but not all + */ + ChebyMap(NativeNode node) { + super(node); + NativeNode part = node.section("ChebyMap"); + if (hasCoeffs(true)) { + double[][] so = readNormalisation(part, createdNin(), "fscl", "foff", "forward"); + if (so != null) { + scaleF = so[0]; + offsetF = so[1]; + } + } + if (hasCoeffs(false)) { + double[][] so = readNormalisation(part, createdNout(), "iscl", "ioff", "inverse"); + if (so != null) { + scaleI = so[0]; + offsetI = so[1]; + } + } + } + + /** One transformation's scales and offsets in {@link #ChebyMap(NativeNode)}, or null if none. */ + private static double[][] readNormalisation(NativeNode part, int naxes, String skey, String okey, String dir) { + double[] scale = new double[naxes]; + double[] offset = new double[naxes]; + int ngood = 0; + for (int i = 0; i < naxes; i++) { + scale[i] = part.readDouble(skey + (i + 1), AST__BAD); + if (scale[i] != AST__BAD) { + ngood++; + } + } + for (int i = 0; i < naxes; i++) { + offset[i] = part.readDouble(okey + (i + 1), AST__BAD); + if (offset[i] != AST__BAD) { + ngood++; + } + } + if (ngood == 0) { + return null; + } + if (ngood != 2 * naxes) { + throw Ast.err( + AstException.AST__OBJIN, + "astLoadChebyMap: insufficient scale and offset values for the " + dir + + " transformation in loaded ChebyMap."); + } + return new double[][] {scale, offset}; + } + + @Override + String dumpComment() { + return "Chebyshev polynomial transformation"; + } + + /** + * Writes the ChebyMap's part of its description, as C's {@code Dump} (chebymap.c) does: the + * scale and then the offset of each input of a forward transformation with a bounding box, and + * of each output of an inverse one. + */ + @Override + void dump(NativeNode node) { + super.dump(node); + node.writeIsA("PolyMap", "Polynomial transformation"); + writeArray(node, scaleF, "FSCL", "Scale factor on input "); + writeArray(node, offsetF, "FOFF", "Offset on input "); + writeArray(node, scaleI, "ISCL", "Scale factor on output "); + writeArray(node, offsetI, "IOFF", "Offset on output "); + } + + private static void writeArray(NativeNode node, double[] values, String key, String comment) { + if (values != null) { + for (int i = 0; i < values.length; i++) { + node.writeDouble(key + (i + 1), true, true, values[i], comment + (i + 1)); + } + } + } + + /** Completes a copy as C's {@code Copy} (chebymap.c) does: the scales and offsets are copied. */ + @Override + void deepCopy() { + super.deepCopy(); + scaleF = scaleF == null ? null : scaleF.clone(); + offsetF = offsetF == null ? null : offsetF.clone(); + scaleI = scaleI == null ? null : scaleI.clone(); + offsetI = offsetI == null ? null : offsetI.clone(); + } + + /** The scales of the inputs of the ChebyMap as created onto [-1, 1], or null; not a copy. */ + double[] forwardScale() { + return scaleF; + } + + /** The offsets that go with {@link #forwardScale}, or null; not a copy. */ + double[] forwardOffset() { + return offsetF; + } + + // ------------------------------------------------------------------ + // The domain + // ------------------------------------------------------------------ + + /** + * Returns 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 transformation is undefined (i.e. no transformation coefficients were + * specified when the ChebyMap was created), this method returns a box determined using the + * {@link Mapping#mapBox} method on the opposite transformation, if the opposite transformation + * is defined. If neither transformation has a box, the bounds are {@link #AST__BAD}, as is any + * bound of an axis whose scale onto [-1, 1] is zero. + * + *

The transformations are those of the ChebyMap as it stands: for an inverted ChebyMap the + * domain of the forward transformation is the box given for the inverse transformation when it + * was created, with one value for each of its outputs as created, which are the inverted + * ChebyMap's inputs, and the domain of the inverse transformation is the box given for the + * forward one. C takes the number of axes from the ChebyMap as it stands but paired with the + * box as created, so for an inverted ChebyMap with different numbers of inputs and outputs it + * reads beyond the box or fills too few axes (docs/c-library-bugs.md); here each box has its + * own number of axes. + * + * @param forward true if the domain of the ChebyMap's forward transformation is to be + * returned, false if the domain of the inverse transformation should be returned + * @return two arrays, the lower bounds and the upper bounds of the domain, with one element + * for each input of the ChebyMap as it stands (if {@code forward} is true) or each output + * (if {@code forward} is false) + * @throws AstException with the status of the error {@code mapBox} reports if the box of the + * opposite transformation cannot be mapped, as C reports it, although the C prologue says + * no error is reported + */ + public double[][] chebyDomain(boolean forward) { + double[] scale; + double[] offset; + int naxes; + double[] scaleO; + double[] offsetO; + // The box C chooses for each direction and Invert value, with the number of axes of that + // box, the inputs or outputs of the ChebyMap as created, where C takes the number of + // inputs or outputs of the ChebyMap as it stands. + if (forward != getInvert()) { + scale = scaleF; + offset = offsetF; + naxes = createdNin(); + scaleO = scaleI; + offsetO = offsetI; + } else { + scale = scaleI; + offset = offsetI; + naxes = createdNout(); + scaleO = scaleF; + offsetO = offsetF; + } + double[] lbnd = new double[naxes]; + double[] ubnd = new double[naxes]; + if (scale != null && offset != null) { + box(scale, offset, naxes, lbnd, ubnd); + } else if (scaleO != null && offsetO != null) { + // The other transformation's box, mapped by the direction opposite to the requested + // one, relative to the ChebyMap as it stands. + int naxesO = scaleO.length; + double[] lbndO = new double[naxesO]; + double[] ubndO = new double[naxesO]; + box(scaleO, offsetO, naxesO, lbndO, ubndO); + for (int iax = 0; iax < naxes; iax++) { + double[] b = MapBox.mapBox(this, lbndO, ubndO, !forward, iax, null, null); + lbnd[iax] = b[0]; + ubnd[iax] = b[1]; + } + } else { + Arrays.fill(lbnd, AST__BAD); + Arrays.fill(ubnd, AST__BAD); + } + return new double[][] {lbnd, ubnd}; + } + + /** The box that the scales and offsets of {@code naxes} axes map onto [-1, 1]. */ + private static void box(double[] scale, double[] offset, int naxes, double[] lbnd, double[] ubnd) { + for (int iax = 0; iax < naxes; iax++) { + if (scale[iax] != 0.0) { + lbnd[iax] = (-1.0 - offset[iax]) / scale[iax]; + ubnd[iax] = (1.0 - offset[iax]) / scale[iax]; + } else { + lbnd[iax] = AST__BAD; + ubnd[iax] = AST__BAD; + } + } + } + + // ------------------------------------------------------------------ + // PolyMap overrides + // ------------------------------------------------------------------ + + /** C's {@code GetIterInverse} (chebymap.c): always false, whatever the attribute holds. */ + @Override + boolean getIterInverse() { + return false; + } + + /** + * C's {@code PolyPowers} (chebymap.c): for a transformation with a bounding box, the Chebyshev + * polynomials of the first kind of each input normalised into [-1, 1] by the box, {@code x' = + * x * scale + offset}, in place of its powers, by the recurrence {@code Tn+1(x') = 2.x'.Tn(x') - + * Tn-1(x')}. An input that is bad, or whose normalised value is outside [-1, 1] (a NaN among + * them), has bad values above degree zero. A transformation without a box is an ordinary + * polynomial, PolyMap's. + */ + @Override + boolean polyPowers(double[][] work, int[] maxPows, double[] input, boolean forward) { + double[] scales = forward ? scaleF : scaleI; + double[] offsets = forward ? offsetF : offsetI; + if (scales == null) { + return super.polyPowers(work, maxPows, input, forward); + } + boolean allGood = true; + for (int coord = 0; coord < work.length; coord++) { + double[] pwork = work[coord]; + pwork[0] = 1.0; + int mp = maxPows[coord]; + double x = input[coord]; + boolean inside = false; + if (x != AST__BAD) { + x = x * scales[coord] + offsets[coord]; + inside = Math.abs(x) <= 1.0; + } + if (inside) { + pwork[1] = x; + for (int ip = 2; ip <= mp; ip++) { + pwork[ip] = 2.0 * x * pwork[ip - 1] - pwork[ip - 2]; + } + } else { + Arrays.fill(pwork, 1, mp + 1, AST__BAD); + allGood &= mp == 0; + } + } + return allGood; + } + + /** The values {@link #polyPowers} gives are not plain powers. */ + @Override + boolean isMonomial() { + return false; + } + + /** + * C's {@code PolyTran} (chebymap.c): as PolyMap's, with the box sampled defaulting to the + * bounding box of the transformation sampled when {@code lbnd} or {@code ubnd} is null. The + * result is a ChebyMap whose new transformation is a Chebyshev polynomial over the box the + * sampled values span, which becomes its bounding box. + * + * @throws AstException with status {@code AST__NOBOX} if a bound is null and the transformation + * sampled has no bounding box, or the errors of PolyMap's + */ + @Override + PolyMap polyTran(boolean forward, double acc, double maxacc, int maxorder, double[] lbnd, double[] ubnd) { + String word; + double[] scale; + double[] offset; + int naxes; + if (forward != getInvert()) { + word = "inverse"; + scale = scaleI; + offset = offsetI; + naxes = createdNout(); + } else { + word = "forward"; + scale = scaleF; + offset = offsetF; + naxes = createdNin(); + } + double[] thisLbnd = lbnd; + if (thisLbnd == null) { + thisLbnd = boxEdge(scale, offset, naxes, -1.0, word, "lower"); + } + double[] thisUbnd = ubnd; + if (thisUbnd == null) { + thisUbnd = boxEdge(scale, offset, naxes, 1.0, word, "upper"); + } + return super.polyTran(forward, acc, maxacc, maxorder, thisLbnd, thisUbnd); + } + + /** + * The lower ({@code edge} -1) or upper ({@code edge} +1) bounds C's {@code PolyTran} takes from + * the box of the transformation sampled, for at most its first two axes. + */ + private double[] boxEdge(double[] scale, double[] offset, int naxes, double edge, String word, String which) { + if (scale == null || offset == null) { + throw Ast.err( + AstException.AST__NOBOX, + "astPolyTran(" + astClass() + "): The " + word + " transformation is not a Chebyshev polynomial " + + "and therefore requires a user-supplied bounding box. But no " + which + + " bounds were supplied. "); + } + double[] b = new double[Math.min(naxes, 2)]; + for (int i = 0; i < b.length; i++) { + b[i] = (edge - offset[i]) / scale[i]; + } + return b; + } + + /** + * C's {@code FitPoly1DInit} (chebymap.c): the bounding box of the transformation being + * replaced becomes the range of the sampled values, as scale and offset onto [-1, 1], and the + * values each coefficient multiplies are the Chebyshev polynomials of the normalised samples. + * {@code scales[0]} is set to 1, since the ChebyMap applies the scaling itself. + * + * @throws AstException with status {@code AST__BADBX} if the sampled values have no range + */ + @Override + double[] fitPoly1DInit(boolean forward, double[][] table, int order, int nsamp, double[] scales) { + double[] range = range(table[0], nsamp); + double pmax = range[1] * scales[0]; + double pmin = range[0] * scales[0]; + if (pmax == pmin) { + throw Ast.err( + AstException.AST__BADBX, + "astPolyTran(" + astClass() + "): New bounding box has zero width on axis 1."); + } + double scl = 2.0 / (pmax - pmin); + double off = -(pmax + pmin) / (pmax - pmin); + storeNormalisation(forward, new double[] {scl}, new double[] {off}); + double[] xp = chebyshevBasis(table[0], nsamp, order, scl, scales[0], off); + scales[0] = 1.0; + return xp; + } + + /** + * C's {@code FitPoly2DInit} (chebymap.c): as {@link #fitPoly1DInit} for each of the two inputs. + * + * @throws AstException with status {@code AST__BADBX} if the sampled values of either input + * have no range + */ + @Override + double[][] fitPoly2DInit(boolean forward, double[][] table, int order, int nsamp, double[] scales) { + double[] rx = range(table[0], nsamp); + double[] ry = range(table[1], nsamp); + double pxmax = rx[1] * scales[0]; + double pxmin = rx[0] * scales[0]; + double pymax = ry[1] * scales[1]; + double pymin = ry[0] * scales[1]; + if (pxmax == pxmin || pymax == pymin) { + throw Ast.err( + AstException.AST__BADBX, + "astPolyTran(" + astClass() + "): New bounding box has zero width on or both axes."); + } + double[] scl = {2.0 / (pxmax - pxmin), 2.0 / (pymax - pymin)}; + double[] off = {-(pxmax + pxmin) / (pxmax - pxmin), -(pymax + pymin) / (pymax - pymin)}; + storeNormalisation(forward, scl.clone(), off.clone()); + double[] xp1 = chebyshevBasis(table[0], nsamp, order, scl[0], scales[0], off[0]); + double[] xp2 = chebyshevBasis(table[1], nsamp, order, scl[1], scales[1], off[1]); + scales[0] = 1.0; + scales[1] = 1.0; + return new double[][] {xp1, xp2}; + } + + /** + * The smallest and largest of the first {@code nsamp} values, found as C's {@code + * FitPoly1DInit} finds them: a value above the largest so far is not compared with the + * smallest. + */ + private static double[] range(double[] v, int nsamp) { + double min = v[0]; + double max = v[0]; + for (int k = 1; k < nsamp; k++) { + if (v[k] > max) { + max = v[k]; + } else if (v[k] < min) { + min = v[k]; + } + } + return new double[] {min, max}; + } + + /** + * The Chebyshev polynomials of degree 0 to {@code order - 1} of each of the {@code nsamp} + * values normalised as {@code x * scl * scale + off}, sample by sample. + */ + private static double[] chebyshevBasis(double[] v, int nsamp, int order, double scl, double scale, double off) { + double[] xp = new double[nsamp * order]; + int k = 0; + for (int i = 0; i < nsamp; i++) { + double x = v[i] * scl * scale + off; + xp[k] = 1.0; + xp[k + 1] = x; + for (int w = 2; w < order; w++) { + xp[k + w] = 2.0 * x * xp[k + w - 1] - xp[k + w - 2]; + } + k += order; + } + return xp; + } + + /** + * Stores the scales and offsets of the transformation {@code forward} replaces, of the + * ChebyMap as it stands, as C's {@code FitPoly1DInit} and {@code FitPoly2DInit} store them. + */ + private void storeNormalisation(boolean forward, double[] scale, double[] offset) { + if (forward != getInvert()) { + scaleF = scale; + offsetF = offset; + } else { + scaleI = scale; + offsetI = offset; + } + } + + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + /** + * chebymap.c {@code Equal}: PolyMap's comparison and then, if {@code that} is a ChebyMap, the + * scales and offsets of both transformations, each absent in both or equal to within {@code + * astEQUAL}. A PolyMap that is not a ChebyMap is compared by PolyMap's comparison alone, as C + * compares it. + */ + @Override + boolean equalTo(AstObject that) { + if (!super.equalTo(that)) { + return false; + } + if (!(that instanceof ChebyMap)) { + return true; + } + ChebyMap other = (ChebyMap) that; + return sameNormalisation(scaleF, other.scaleF, offsetF, other.offsetF, createdNin()) + && sameNormalisation(scaleI, other.scaleI, offsetI, other.offsetI, createdNout()); + } + + private static boolean sameNormalisation(double[] s1, double[] s2, double[] o1, double[] o2, int naxes) { + if (s1 != null && s2 != null && o1 != null && o2 != null) { + for (int i = 0; i < naxes; i++) { + if (!MappingHelpers.astEqual(s1[i], s2[i]) || !MappingHelpers.astEqual(o1[i], o2[i])) { + return false; + } + } + return true; + } + return s1 == null && s2 == null && o1 == null && o2 == null; + } +} diff --git a/src/main/java/uk/ac/starlink/ast/FitsSipIntWorld.java b/src/main/java/uk/ac/starlink/ast/FitsSipIntWorld.java index 58c13de..3b4b145 100644 --- a/src/main/java/uk/ac/starlink/ast/FitsSipIntWorld.java +++ b/src/main/java/uk/ac/starlink/ast/FitsSipIntWorld.java @@ -88,7 +88,12 @@ static Mapping sipIntWorld( inaxes[0] = inax1[0]; inaxes[1] = inax1[1]; - // The first PolyMap of the simplified Mapping as a list in series. + // The first PolyMap of the simplified Mapping as a list in series that is not a ChebyMap. + // C takes the first Mapping for which astIsAPolyMap holds, a ChebyMap among them, and then + // writes its Chebyshev coefficients as SIP's coefficients of powers, without its + // normalisation (docs/c-library-bugs.md); a ChebyMap is passed over here, as in the Rust + // port, so it is never described with SIP coefficients, and a plain PolyMap later in the + // list, which C would not reach, is taken instead. Mapping smap = tmap1.simplify(); List mapList = new ArrayList<>(); List invertList = new ArrayList<>(); @@ -97,7 +102,7 @@ static Mapping sipIntWorld( int imapPm = -1; PolyMap polymap = null; for (int imap = 0; imap < nmap; imap++) { - if (mapList.get(imap) instanceof PolyMap) { + if (mapList.get(imap) instanceof PolyMap && !(mapList.get(imap) instanceof ChebyMap)) { imapPm = imap; polymap = (PolyMap) mapList.get(imap).copy(); polymap.setInvert(invertList.get(imap)); diff --git a/src/main/java/uk/ac/starlink/ast/Mapping.java b/src/main/java/uk/ac/starlink/ast/Mapping.java index 7c91f26..9f48235 100644 --- a/src/main/java/uk/ac/starlink/ast/Mapping.java +++ b/src/main/java/uk/ac/starlink/ast/Mapping.java @@ -623,6 +623,56 @@ static int cancelWithNeighbour(Mapping map, MergeList list, int where, Class kind, int result) { + boolean inv0 = list.invert(where); + int saved0 = pmap0.swapInvert(inv0); + try { + int nin = pmap0.getNin(); + int nout = pmap0.getNout(); + for (int i = where - 1; i <= where + 1; i += 2) { + if (i < 0 || i >= list.size() || !kind.isInstance(list.map(i)) || list.invert(i) == inv0) { + continue; + } + Mapping pmap1 = list.map(i); + int saved1 = pmap1.swapInvert(inv0); + boolean ok; + try { + ok = pmap0.astEqual(pmap1); + } finally { + pmap1.restoreInvert(saved1); + } + if (ok) { + int n = i < where ? nout : nin; + list.set(where, new UnitMap(n), false); + list.set(i, new UnitMap(n), false); + return Math.min(i, where); + } + } + } finally { + pmap0.restoreInvert(saved0); + } + return result; + } + /** * Simplifies a Mapping, eliminating redundant computational steps or merging separate steps * that can be performed more efficiently in a single operation, as C's {@code astSimplify} diff --git a/src/main/java/uk/ac/starlink/ast/NormMap.java b/src/main/java/uk/ac/starlink/ast/NormMap.java new file mode 100644 index 0000000..171225d --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/NormMap.java @@ -0,0 +1,280 @@ +package uk.ac.starlink.ast; + +import java.util.Objects; + +/** + * A Mapping which normalises coordinate values using the {@link Frame#norm} method of a supplied + * Frame. The number of inputs and outputs of a NormMap are both equal to the number of axes in + * the supplied Frame. + * + *

The forward and inverse transformation of a NormMap are both defined but are identical (that + * is, they do not form a real inverse pair in that the inverse transformation does not undo the + * normalisation, instead it reapplies it). However, the {@link #simplify} method will replace + * neighbouring pairs of forward and inverse NormMaps by a single UnitMap (so long as the Frames + * encapsulated by the two NormMaps are equal - i.e. have the same class and the same attribute + * values). This means, for instance, that if a CmpMap contains a NormMap, the CmpMap will still + * cancel with its own inverse. Simplification also replaces a run of equal NormMaps applied in + * the same direction by one of them, a NormMap whose Frame simplifies by a NormMap of the + * simplified Frame, and a NormMap of a plain Frame, whose normalisation does nothing, by a + * UnitMap. + * + *

The NormMap class does not define any new attributes or methods beyond those which are + * applicable to all Mappings. + * + *

A NormMap holds the Frame it is given, not a copy, as C's {@code astNormMap} does: later + * changes to the Frame change the NormMap. Each point is normalised as it stands, a bad + * coordinate included, so the Frame decides what a bad value means (a SkyFrame still normalises + * the longitude of a point whose latitude is bad); a NaN is given to the Frame as {@link + * #AST__BAD}, and the Mapping never gives a NaN. + * + *

Ported from Rust {@code mappings/normmap.rs} and C {@code normmap.c}. + */ +public class NormMap extends Mapping { + + /** The Frame whose normalisation the NormMap applies (C's {@code frame}). */ + private Frame frame; + + /** + * Creates a NormMap. + * + * @param frame the Frame which is to be used to normalise the supplied axis values. The NormMap + * holds it, not a copy + * @throws NullPointerException if {@code frame} is null + */ + public NormMap(Frame frame) { + this(Objects.requireNonNull(frame, "frame"), true); + } + + /** + * C's {@code astInitNormMap} (normmap.c): as many inputs and outputs as {@code frame} has axes, + * both directions defined, holding {@code frame}, which is marked shared if {@code share}, as + * C's {@code astClone} of a Frame its caller keeps makes it. A Frame only the new NormMap refers + * to, as one made within a computation, is not marked. + */ + NormMap(Frame frame, boolean share) { + super(frame.getNaxes(), frame.getNaxes(), true, true); + this.frame = frame; + if (share) { + frame.markShared(); + } + } + + /** + * Loads a NormMap from its description, as C's {@code astLoadNormMap} does: the Frame is item + * {@code Frame}. + * + *

The pinned C stores what it reads (the PR that hardens it refuses these too). With no + * Frame, or an Object that is not a Frame, its transformation fails. With Nin equal to Nout but + * more than the Frame's axes it transforms, normalising only the Frame's axes, but its {@code + * MapMerge} replaces it with a Mapping of the Frame's axes and its {@code MapSplit} picks the + * Frame's axes by input number, an input beyond them being none of the Frame's axes (a plain + * Frame gives an axis of default attributes); with fewer, the Frame's {@code astNorm} reads and writes + * beyond the values of a point; and with Nin and Nout different, its transformation copies as + * many values as a point has to the outputs, so it writes beyond the outputs or leaves some + * unwritten, depending on the direction. + * + * @throws AstException with status {@code AST__LDERR} if the Frame is missing or is not a + * Frame, or the NormMap does not have one input and one output for each of the Frame's axes + */ + NormMap(NativeNode node) { + super(node); + NativeNode desc = node.section("NormMap").readObject("Frame"); + if (desc == null) { + throw Ast.err(AstException.AST__LDERR, "astLoadNormMap(NormMap): The NormMap has no Frame."); + } + AstObject obj = ObjectRegistry.loadNested(desc, "Frame"); + if (!(obj instanceof Frame)) { + throw Ast.err( + AstException.AST__LDERR, + "astLoadNormMap(NormMap): The Frame item is a " + obj.astClass() + ", not a Frame."); + } + frame = (Frame) obj; + int naxes = frame.getNaxes(); + if (createdNin() != naxes || createdNout() != naxes) { + throw Ast.err( + AstException.AST__LDERR, + "astLoadNormMap(NormMap): The NormMap read has " + createdNin() + " inputs and " + createdNout() + + " outputs, but its Frame has " + naxes + " axes."); + } + } + + @Override + String dumpComment() { + return "Normalise axis values"; + } + + /** Writes the Frame, as C's {@code Dump} (normmap.c) does. */ + @Override + void dump(NativeNode node) { + super.dump(node); + node.writeIsA("Mapping", "Mapping between coordinate systems"); + node.writeObject("Frame", true, true, NativeNode.of(frame), "Frame defining the normalisation"); + } + + /** Gives the copy a copy of the Frame, as C's {@code Copy} (normmap.c) does. */ + @Override + void deepCopy() { + super.deepCopy(); + frame = (Frame) frame.copy(); + } + + // ------------------------------------------------------------------ + // Transformation + // ------------------------------------------------------------------ + + /** + * C's {@code Transform} (normmap.c): each point, in either direction, normalised by the Frame + * ({@link Frame#norm}). A NaN input is given to the Frame as {@link #AST__BAD}, which is what C + * receives for a bad value, and a NaN the Frame gives is returned as {@link #AST__BAD}. + */ + @Override + void transformInto(double[][] in, int npoint, boolean forward, double[][] out) { + validateTransformInto(in, npoint, forward, out); + int ncoord = in.length; + double[] work = new double[ncoord]; + for (int p = 0; p < npoint; p++) { + for (int c = 0; c < ncoord; c++) { + double v = in[c][p]; + work[c] = Double.isNaN(v) ? AST__BAD : v; + } + frame.norm(work); + for (int c = 0; c < ncoord; c++) { + double v = work[c]; + out[c][p] = Double.isNaN(v) ? AST__BAD : v; + } + } + } + + /** The rate of change: one where the output is the input, zero elsewhere ({@code Rate}, normmap.c). */ + @Override + double rateAt(double[] at, int ax1, int ax2) { + return ax1 == ax2 ? 1.0 : 0.0; + } + + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + /** + * normmap.c {@code Equal}: {@code that} is a NormMap with the same Invert attribute whose Frame + * is equal to this one's ({@link #astEqual}). + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof NormMap)) { + return false; + } + NormMap other = (NormMap) that; + return getInvert() == other.getInvert() && frame.astEqual(other.frame); + } + + // ------------------------------------------------------------------ + // Simplification, splitting and Regions + // ------------------------------------------------------------------ + + /** + * normmap.c {@code MapMerge}, in C's order. If simplifying the Frame gives a different Object, + * the NormMap is replaced by a NormMap of the simplified Frame; otherwise, if the Frame is a + * plain Frame (its class exactly {@code Frame}), whose normalisation does nothing, by a UnitMap. + * Otherwise, in series, the NormMap and a neighbour that is a NormMap applied in the other + * direction with an equal Frame, the lower neighbour first, are both replaced by UnitMaps, + * applied forward; failing that, each NormMap in the run that follows it, applied in the same + * direction with an equal Frame, is replaced by a UnitMap. The NormMap's own Invert attribute + * is neither read nor changed, as a NormMap's two directions are the same. + */ + // C compares the pointers: whether astSimplify returned the Frame it was given. + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) + @Override + int mapMerge(MergeList list, int where, boolean series) { + Mapping smap = frame.simplify(); + if (smap != frame) { + if (!(smap instanceof Frame)) { + throw Ast.err( + AstException.AST__INTER, + "astMapMerge(NormMap): Simplifying a " + frame.astClass() + " gave a " + smap.astClass() + + ", not a Frame (internal AST programming error)."); + } + list.set(where, new NormMap((Frame) smap, false), list.invert(where)); + return where; + } + if ("Frame".equals(smap.astClass())) { + list.set(where, new UnitMap(smap.getNin()), list.invert(where)); + return where; + } + if (!series) { + return -1; + } + boolean inv = list.invert(where); + int cancel = -1; + int naxes = 0; + if (where > 0 && list.map(where - 1) instanceof NormMap && inv != list.invert(where - 1)) { + if (frame.astEqual(((NormMap) list.map(where - 1)).frame)) { + cancel = where - 1; + } + naxes = getNout(); + } + if (cancel == -1 + && where + 1 < list.size() + && list.map(where + 1) instanceof NormMap + && inv != list.invert(where + 1)) { + if (frame.astEqual(((NormMap) list.map(where + 1)).frame)) { + cancel = where + 1; + } + naxes = getNin(); + } + if (cancel != -1) { + list.set(where, new UnitMap(naxes), false); + list.set(cancel, new UnitMap(naxes), false); + return Math.min(cancel, where); + } + int result = -1; + naxes = getNin(); + cancel = where; + while (++cancel < list.size() && list.map(cancel) instanceof NormMap) { + if (inv == list.invert(cancel) && frame.astEqual(((NormMap) list.map(cancel)).frame)) { + list.set(cancel, new UnitMap(naxes), list.invert(cancel)); + if (result == -1) { + result = cancel; + } + } + } + return result; + } + + /** + * normmap.c {@code MapSplit}: the parent's split if it gives one ({@link MapSplit#baseSplit}, + * which refuses an input that does not exist), and otherwise a NormMap of the chosen axes of + * the Frame ({@link Frame#pickAxes}, which refuses an axis chosen twice), whose outputs are the + * inputs chosen. No inputs give no split, as C's {@code astStore} of no indices gives none. + */ + @Override + MapSplit splitOff(int[] in) { + MapSplit result = MapSplit.baseSplit(this, in); + if (result != null || in.length == 0) { + return result; + } + int[] axes = new int[in.length]; + for (int i = 0; i < in.length; i++) { + axes[i] = in[i] + 1; + } + Frame frm2 = frame.pickAxes(in.length, axes, null); + return new MapSplit(in.clone(), new NormMap(frm2, false)); + } + + /** + * normmap.c {@code RemoveRegions}: the NormMap itself if removing the Regions from its Frame + * leaves the Frame unchanged, and otherwise a copy holding the Frame that gives. + */ + // C compares the pointers: whether astRemoveRegions returned the Frame it was given. + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) + @Override + Mapping removeRegions() { + Frame newfrm = frame.removeRegions(); + if (newfrm == frame) { + return this; + } + NormMap result = (NormMap) copy(); + result.frame = newfrm; + return result; + } +} diff --git a/src/main/java/uk/ac/starlink/ast/ObjectRegistry.java b/src/main/java/uk/ac/starlink/ast/ObjectRegistry.java index d088045..ef3c1db 100644 --- a/src/main/java/uk/ac/starlink/ast/ObjectRegistry.java +++ b/src/main/java/uk/ac/starlink/ast/ObjectRegistry.java @@ -32,6 +32,8 @@ static Loader loader(String className) { return Box::new; case "Channel": return Channel::new; + case "ChebyMap": + return ChebyMap::new; case "Circle": return Circle::new; case "CmpFrame": @@ -68,6 +70,8 @@ static Loader loader(String className) { return MathMap::new; case "MatrixMap": return MatrixMap::new; + case "NormMap": + return NormMap::new; case "NullRegion": return NullRegion::new; case "PcdMap": @@ -104,6 +108,8 @@ static Loader loader(String className) { return SpecMap::new; case "SphMap": return SphMap::new; + case "SplineMap": + return SplineMap::new; case "StcCatalogEntryLocation": return StcCatalogEntryLocation::new; case "StcObsDataLocation": @@ -122,10 +128,14 @@ static Loader loader(String className) { return TranMap::new; case "UnitMap": return UnitMap::new; + case "UnitNormMap": + return UnitNormMap::new; case "WcsMap": return WcsMap::new; case "WinMap": return WinMap::new; + case "XphMap": + return XphMap::new; case "ZoomMap": return ZoomMap::new; default: diff --git a/src/main/java/uk/ac/starlink/ast/PolyMap.java b/src/main/java/uk/ac/starlink/ast/PolyMap.java index e878a18..81784e3 100644 --- a/src/main/java/uk/ac/starlink/ast/PolyMap.java +++ b/src/main/java/uk/ac/starlink/ast/PolyMap.java @@ -128,9 +128,17 @@ public class PolyMap extends Mapping { * array is too short, or {@code AST__BADNI} or {@code AST__BADNO} if a count is negative */ public PolyMap(int nin, int nout, int ncoeffF, double[] coeffF, int ncoeffI, double[] coeffI) { + this("PolyMap", nin, nout, ncoeffF, coeffF, ncoeffI, coeffI); + } + + /** + * C's {@code astInitPolyMap} for a PolyMap of class {@code cls}, which names the class in the + * error messages. + */ + PolyMap(String cls, int nin, int nout, int ncoeffF, double[] coeffF, int ncoeffI, double[] coeffI) { super(nin, nout, true, true); - Coeffs f = Coeffs.of(true, nin, nout, ncoeffF, coeffF); - Coeffs i = Coeffs.of(false, nin, nout, ncoeffI, coeffI); + Coeffs f = Coeffs.of(cls, true, nin, nout, ncoeffF, coeffF); + Coeffs i = Coeffs.of(cls, false, nin, nout, ncoeffI, coeffI); if (f != null) { this.ncoeffF = f.nco; this.coeffF = f.cof; @@ -260,7 +268,8 @@ void dump(NativeNode node) { if (ncoeffI != null) { dumpArrays(node, createdNout(), mxpowI, ncoeffI, coeffI, powerI, false); } - boolean iter = getIterInverse(); + // As C, the value held when set, and otherwise the default the class gives. + boolean iter = testIterInverse() ? iterInverse != 0 : getIterInverse(); node.writeInt( "IterInv", testIterInverse(), @@ -387,7 +396,7 @@ private static int[][][] deepClone(int[][][] a) { */ final void storeArrays(boolean forward, int ncoeff, double[] coeff) { boolean origForward = forward != getInvert(); - Coeffs c = Coeffs.of(origForward, createdNin(), createdNout(), ncoeff, coeff); + Coeffs c = Coeffs.of(astClass(), origForward, createdNin(), createdNout(), ncoeff, coeff); if (origForward) { setForward(c); } else { @@ -425,10 +434,11 @@ private Coeffs(int npoly, int nvar) { /** * The arrays C's {@code StoreArrays} makes from {@code ncoeff} coefficients of the original - * forward ({@code origForward}) or inverse transformation of a PolyMap with {@code nin} - * inputs and {@code nout} outputs, or null if {@code ncoeff} is not positive. + * forward ({@code origForward}) or inverse transformation of a PolyMap of class {@code cls} + * with {@code nin} inputs and {@code nout} outputs, or null if {@code ncoeff} is not + * positive. */ - static Coeffs of(boolean origForward, int nin, int nout, int ncoeff, double[] coeff) { + static Coeffs of(String cls, boolean origForward, int nin, int nout, int ncoeff, double[] coeff) { if (ncoeff <= 0) { return null; } @@ -440,7 +450,7 @@ static Coeffs of(boolean origForward, int nin, int nout, int ncoeff, double[] co if (length < need) { throw Ast.err( AstException.AST__DIMIN, - "astPolyMap(PolyMap): The " + array + " array holds " + length + "ast" + cls + "(" + cls + "): The " + array + " array holds " + length + " values.\nThis should not be less than " + need + "."); } Coeffs c = new Coeffs(npoly, nvar); @@ -453,7 +463,8 @@ static Coeffs of(boolean origForward, int nin, int nout, int ncoeff, double[] co if (iout < 1 || iout > npoly) { throw Ast.err( AstException.AST__BADCI, - "astInitPolyMap(PolyMap): " + what + " coefficient " + (i + 1) + " referred to an illegal " + "astInitPolyMap(" + cls + "): " + what + " coefficient " + (i + 1) + + " referred to an illegal " + (origForward ? "output" : "input") + " coordinate " + iout + ".\nThis number should be in the range 1 to " + npoly + "."); } @@ -462,7 +473,7 @@ static Coeffs of(boolean origForward, int nin, int nout, int ncoeff, double[] co if (pows[j] < 0) { throw Ast.err( AstException.AST__BADPW, - "astInitPolyMap(PolyMap): " + what + " coefficient " + (i + 1) + "astInitPolyMap(" + cls + "): " + what + " coefficient " + (i + 1) + " has a negative power (" + pows[j] + ") for " + (origForward ? "input" : "output") + " coordinate " + (j + 1) + ".\nAll powers should be zero or positive."); @@ -987,7 +998,11 @@ private static boolean sameCoeffs( * original forward transformation has coefficients, as many inputs as outputs, and no term of * degree above one, the PolyMap is replaced by the simplified series CmpMap of the MatrixMap of * its linear terms and the ShiftMap of its constant terms, applied with the PolyMap's Invert - * value from the list. Finally, in series, a neighbouring PolyMap applied in the other + * value from the list. The coefficients of a ChebyMap apply to its inputs normalised to its + * bounding box, {@code z = scale * x + offset}, and the only Chebyshev polynomials of degree one + * or less are 1 and {@code z}, so a ChebyMap that passes the test is linear in its inputs too, + * with the normalisation folded into the matrix and offsets; the replacement transforms points + * outside the box, which the ChebyMap makes bad. Finally, in series, a neighbouring PolyMap applied in the other * direction that is equal to the nominated Mapping once both are applied in the nominated * Mapping's direction turns the pair into two UnitMaps. */ @@ -1012,13 +1027,19 @@ int mapMerge(MergeList list, int where, boolean series) { pmap0 = consolidated; } - // The ChebyMap branch of polymap.c MapMerge, which folds a ChebyMap's input normalisation - // into the matrix and offsets, is absent. PolyMap poly0 = (PolyMap) pmap0; if (poly0.ncoeffF != null && nout == nin) { + // The normalisation applied to each input before the coefficients are used: C takes it + // from a ChebyMap, by its class, and a PolyMap has none. + double[] normScale = null; + double[] normOffset = null; + if (poly0 instanceof ChebyMap) { + normScale = ((ChebyMap) poly0).forwardScale(); + normOffset = ((ChebyMap) poly0).forwardOffset(); + } double[] offsets = new double[nout]; double[] matrix = new double[nout * nout]; - if (linearTerms(poly0, nin, nout, offsets, matrix)) { + if (linearTerms(poly0, nin, nout, normScale, normOffset, offsets, matrix)) { ShiftMap sm = new ShiftMap(offsets); MatrixMap mm = new MatrixMap(nin, nout, MatrixMap.FULL, matrix); Mapping simplified = new CmpMap(mm, sm, true).simplify(); @@ -1029,7 +1050,7 @@ int mapMerge(MergeList list, int where, boolean series) { } if (series) { - result = cancelWithNeighbour(list, where, pmap0, result); + result = cancelWithOppositeNeighbour(list, where, pmap0, PolyMap.class, result); } return result; } @@ -1087,11 +1108,21 @@ private static boolean consolidate(int[] ncoeff, double[][] coeff, int[][][] pow * The linearity test of polymap.c {@code MapMerge}: adds each non-zero constant term of the * original forward transformation of {@code poly} into {@code offsets}, and each non-zero term * of degree one into {@code matrix} (row-major, {@code nout} rows of {@code nin}), stopping at - * the first term of higher degree. + * the first term of higher degree. When the inputs are normalised ({@code normScale} and + * {@code normOffset} not null), a term {@code c * z} of input {@code j}, with {@code z = scale * + * x + offset}, adds {@code c * scale[j]} to the matrix and {@code c * offset[j]} to the + * output's offset. * * @return whether every term is of degree one or less */ - private static boolean linearTerms(PolyMap poly, int nin, int nout, double[] offsets, double[] matrix) { + private static boolean linearTerms( + PolyMap poly, + int nin, + int nout, + double[] normScale, + double[] normOffset, + double[] offsets, + double[] matrix) { for (int iout = 0; iout < nout; iout++) { int nc = poly.ncoeffF[iout]; double[] outcof = poly.coeffF[iout]; @@ -1119,7 +1150,12 @@ private static boolean linearTerms(PolyMap poly, int nin, int nout, double[] off if (constTerm) { offsets[iout] += outcof[ic]; } else if (linearTerm) { - matrix[jin + iout * nin] += outcof[ic]; + if (normScale != null && normOffset != null) { + matrix[jin + iout * nin] += outcof[ic] * normScale[jin]; + offsets[iout] += outcof[ic] * normOffset[jin]; + } else { + matrix[jin + iout * nin] += outcof[ic]; + } } else { return false; } @@ -1129,56 +1165,6 @@ private static boolean linearTerms(PolyMap poly, int nin, int nout, double[] off return true; } - /** - * The neighbour half of polymap.c {@code MapMerge}: with {@code pmap0}, the Mapping now at - * {@code where}, applied as the list applies it, each neighbour in turn (the one before, then - * the one after) that is a PolyMap applied in the other direction is applied in {@code - * pmap0}'s direction and compared with it; the first equal one and {@code pmap0} are replaced - * by UnitMaps applied forward, of {@code pmap0}'s output count if the neighbour comes first and - * its input count otherwise. As in C, the neighbour's Invert attribute is restored after the - * comparison, and {@code pmap0}'s only when the pair does not cancel: a cancelled {@code pmap0}, - * which may be shared with the Mapping being simplified, is left with the list's value - * (docs/rust-c-differences.md, "Cancelling a PolyMap with its inverse"). - * - * @return the index of the first entry changed: the lower of the pair if they cancel, and - * {@code result} otherwise - */ - private static int cancelWithNeighbour(MergeList list, int where, Mapping pmap0, int result) { - boolean inv0 = list.invert(where); - int saved0 = pmap0.swapInvert(inv0); - boolean cancelled = false; - try { - int nin = pmap0.getNin(); - int nout = pmap0.getNout(); - for (int i = where - 1; i <= where + 1; i += 2) { - if (i < 0 || i >= list.size() || !(list.map(i) instanceof PolyMap) || list.invert(i) == inv0) { - continue; - } - PolyMap pmap1 = (PolyMap) list.map(i); - int saved1 = pmap1.swapInvert(inv0); - boolean ok; - try { - ok = pmap0.astEqual(pmap1); - } finally { - pmap1.restoreInvert(saved1); - } - if (ok) { - int n = i < where ? nout : nin; - list.set(where, new UnitMap(n), false); - list.set(i, new UnitMap(n), false); - cancelled = true; - return Math.min(i, where); - } - } - } finally { - // C annuls its pointer to a cancelled pmap0, which skips the restore. - if (!cancelled) { - pmap0.restoreInvert(saved0); - } - } - return result; - } - // ------------------------------------------------------------------ // Attribute strings (polymap.c GetAttrib, SetAttrib, TestAttrib, ClearAttrib) // ------------------------------------------------------------------ diff --git a/src/main/java/uk/ac/starlink/ast/ShiftMap.java b/src/main/java/uk/ac/starlink/ast/ShiftMap.java index 397e542..1c0a25b 100644 --- a/src/main/java/uk/ac/starlink/ast/ShiftMap.java +++ b/src/main/java/uk/ac/starlink/ast/ShiftMap.java @@ -68,6 +68,11 @@ boolean isLinear() { return true; } + /** A copy of the shifts as stored, for the ShiftMap as created (C's {@code this->shift}). */ + double[] storedShifts() { + return shift.clone(); + } + /** * A copy of the shifts the ShiftMap applies forward in its current orientation, as C's {@code * astGetShifts} (shiftmap.c {@code GetShifts}) gives them: negated if it is inverted, a bad diff --git a/src/main/java/uk/ac/starlink/ast/SplineMap.java b/src/main/java/uk/ac/starlink/ast/SplineMap.java new file mode 100644 index 0000000..0b89245 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/SplineMap.java @@ -0,0 +1,1207 @@ +package uk.ac.starlink.ast; + +import java.util.Arrays; +import java.util.Objects; +import uk.ac.starlink.ast.internal.pal.Pal; + +/** + * Map coordinates using spline functions. + * + *

A SplineMap is a class of Mapping that has two input axes and two output axes and contains a + * pair of two-dimensional splines (stored in B-spline form). Each output coordinate of a SplineMap + * is the value of one of these two-dimensional splines defined over the two input coordinates. The + * two splines (one generating the first output coordinate and the other generating the second + * output coordinate) share the same order and the same knot positions, but have coefficients that + * are specified separately. No extrapolation is performed - input positions that are outside the + * area covered by the supplied knots cannot be transformed (but see attribute OutUnit). + * + *

An iterative method is used to evaluate the inverse transformation based on the forward + * transformation (see attributes InvTol and InvNiter). This puts some restrictions on how the + * SplineMap class is used. Specifically, the output axis values must represent perturbed input + * axis values, rather than representing the perturbations themselves. It also requires that the + * perturbations be small. In other words, if the input axis values are (x,y), the output axis + * values are (u,v) and the perturbations in u and v are Pu(x,y) and Pv(x,y), then: + * + *

    + *
  • u = x + Pu(x,y) + *
  • v = y + Pv(x,y) + *
+ * + *

The perturbations should be sufficiently small to ensure that u always increases with x and + * that v always increases with y. The knots and coefficients of the B-splines supplied when the + * SplineMap is constructed should ensure that each B-spline value represents the sum of the input + * axis value and the perturbation. For instance, the first supplied B-spline should have value x + + * Pu(x,y) and not just Pu(x,y). + * + *

In addition to those attributes common to all Mappings, every SplineMap also has the + * attributes InvNiter (the maximum number of iterations for the iterative inverse), InvTol (its + * target relative error), OutUnit (how out-of-bounds input positions are handled), and the + * read-only SplineKx, SplineKy (the orders of the splines along the input X and Y axes), + * SplineNx and SplineNy (the numbers of spline coefficients along them). InvNiter, InvTol and + * OutUnit cannot be changed once the SplineMap is held by another Object, such as a CmpMap. + * + *

On each axis, a spline of order k with n coefficients covers the range from knot k to knot + * n + 1 (counting from one), the whole range of the knots when the first k knots coincide and the + * last k knots coincide, as is usual. A position outside the range covered is treated as one + * outside the knots, even when it lies within the range of the knots (OutUnit applies to it). A + * range covered along X of zero width, a single position, gives bad values there. + * + *

Ported from C {@code splinemap.c}, with Rust {@code mappings/splinemap.rs} as a guide. The + * B-spline evaluation is C's, from the CMLIB routines {@code DB2VAL}, {@code DBVALU} and {@code + * DINTRV}; the coefficients are held as C holds them, the X index varying fastest, the transpose + * of the order the constructor takes. + */ +public class SplineMap extends Mapping { + + /** The largest spline order, C's {@code MAX_K} (order 4 is a cubic). */ + private static final int MAX_K = 6; + + /** The value C stores while InvNiter or OutUnit is unset, {@code -INT_MAX}. */ + private static final int UNSET = -Integer.MAX_VALUE; + + /** InvNiter's default. */ + private static final int DEFAULT_INV_NITER = 6; + + /** InvTol's default. */ + private static final double DEFAULT_INV_TOL = 1.0e-6; + + /** The spline order along the first input axis (C's {@code kx}). */ + private final int kx; + + /** The spline order along the second input axis (C's {@code ky}). */ + private final int ky; + + /** The number of coefficients along the first input axis (C's {@code nx}). */ + private final int nx; + + /** The number of coefficients along the second input axis (C's {@code ny}). */ + private final int ny; + + /** The {@code nx + kx} knots along the first input axis (C's {@code tx}). */ + private double[] tx; + + /** The {@code ny + ky} knots along the second input axis (C's {@code ty}). */ + private double[] ty; + + /** + * The {@code nx * ny} coefficients of the spline giving the first output, element {@code i + + * j*nx} for X index {@code i} and Y index {@code j} (C's {@code cu}). + */ + private double[] cu; + + /** The coefficients of the spline giving the second output, as {@link #cu} (C's {@code cv}). */ + private double[] cv; + + /** The InvNiter attribute, {@link #UNSET} while unset. */ + private int invNiter = UNSET; + + /** The InvTol attribute, {@link #AST__BAD} while unset. */ + private double invTol = AST__BAD; + + /** The OutUnit attribute, 0 or 1, or {@link #UNSET} while unset. */ + private int outUnit = UNSET; + + /** + * Creates a SplineMap. + * + * @param kx the order of the spline along the first ("x") input axis (e.g. 4 for a bi-cubic + * spline). This must be in the range [1,6] + * @param ky the order of the spline along the second ("y") input axis (e.g. 4 for a bi-cubic + * spline). This must be in the range [1,6] + * @param nx the number of B-spline coefficients along the first input axis ("x"). Must be + * larger than or equal to {@code kx} + * @param ny the number of B-spline coefficients along the second input axis ("y"). Must be + * larger than or equal to {@code ky} + * @param tx an array of {@code nx + kx} elements holding the knots along the first input axis + * ("x"). These must be supplied in non-decreasing order + * @param ty an array of {@code ny + ky} elements holding the knots along the second input axis + * ("y"). These must be supplied in non-decreasing order + * @param cu an array of {@code nx * ny} elements holding the coefficients of the spline that + * generates the first (u) output coordinate value. Element {@code j + i*ny} is the + * coefficient for x index {@code i} and y index {@code j}, the order of SciPy's {@code + * BivariateSpline.get_coeffs()} + * @param cv an array of {@code nx * ny} elements holding the coefficients of the spline that + * generates the second (v) output coordinate value, in the same order as {@code cu} + * @throws NullPointerException if an array is null + * @throws AstException with status {@code AST__ATTIN} if an order is outside [1,6], a number of + * coefficients is smaller than the order or too large, or the knots along an axis decrease, + * or {@code AST__DIMIN} if an array is too short + */ + public SplineMap(int kx, int ky, int nx, int ny, double[] tx, double[] ty, double[] cu, double[] cv) { + super(2, 2, true, true); + checkSizes("astSplineMap", kx, ky, nx, ny); + Objects.requireNonNull(tx, "tx"); + Objects.requireNonNull(ty, "ty"); + Objects.requireNonNull(cu, "cu"); + Objects.requireNonNull(cv, "cv"); + checkLength("tx", tx, nx + kx); + checkLength("ty", ty, ny + ky); + checkLength("cu", cu, nx * ny); + checkLength("cv", cv, nx * ny); + checkKnots("astSplineMap", "X", tx, nx + kx); + checkKnots("astSplineMap", "Y", ty, ny + ky); + this.kx = kx; + this.ky = ky; + this.nx = nx; + this.ny = ny; + this.tx = Arrays.copyOf(tx, nx + kx); + this.ty = Arrays.copyOf(ty, ny + ky); + // C's astSplineMap transposes the coefficients from SciPy's order to CMLIB's. + this.cu = transposed(cu, nx, ny); + this.cv = transposed(cv, nx, ny); + } + + /** + * Loads a SplineMap from its description, as C's {@code astLoadSplineMap} does: the orders + * {@code KX} and {@code KY} and the numbers of coefficients {@code NX} and {@code NY} (each + * default 0), the knots {@code TX} and {@code TY} and the coefficients {@code CU} and + * {@code CV} (each {@link #AST__BAD} if absent), then InvNiter, OutUnit and InvTol, each + * re-applied through its setter when set. + * + *

The pinned C stores what it reads without checking it, and then transforms beyond its + * arrays for orders or numbers of coefficients its constructor refuses, for knots that + * decrease, and for numbers of inputs or outputs other than 2. The loader refuses each, with + * the checks and messages of the PR that hardens C (Starlink/ast #104). + * + * @throws AstException with status {@code AST__LDERR} if the SplineMap does not have two inputs + * and two outputs, or {@code AST__ATTIN} if its orders, numbers of coefficients or knots are + * ones the constructor refuses + */ + // C's astGetNin and astGetNout of the Mapping as loaded, which SplineMap does not override. + @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") + SplineMap(NativeNode node) { + super(node); + if (getNin() != 2 || getNout() != 2) { + throw Ast.err( + AstException.AST__LDERR, + "astLoadSplineMap(SplineMap): Invalid number of inputs (" + getNin() + ") or outputs (" + getNout() + + ") read for a SplineMap - both must be 2."); + } + NativeNode part = node.section("SplineMap"); + kx = part.readInt("KX", 0); + ky = part.readInt("KY", 0); + nx = part.readInt("NX", 0); + ny = part.readInt("NY", 0); + checkSizes("astLoadSplineMap", kx, ky, nx, ny); + tx = readValues(part, "TX", nx + kx); + ty = readValues(part, "TY", ny + ky); + cu = readValues(part, "CU", nx * ny); + cv = readValues(part, "CV", nx * ny); + invNiter = part.readInt("NiterInv", UNSET); + if (testInvNiter()) { + storeInvNiter(invNiter); + } + outUnit = part.readInt("OutUnit", UNSET); + if (testOutUnit()) { + storeOutUnit(outUnit); + } + invTol = part.readDouble("TolInv", AST__BAD); + if (testInvTol()) { + storeInvTol(invTol); + } + checkKnots("astLoadSplineMap", "X", tx, nx + kx); + checkKnots("astLoadSplineMap", "Y", ty, ny + ky); + } + + /** Items {@code 1} to {@code } of {@code part}, each {@link #AST__BAD} if absent. */ + private static double[] readValues(NativeNode part, String key, int n) { + double[] values = new double[n]; + for (int i = 0; i < n; i++) { + values[i] = part.readDouble(key + (i + 1), AST__BAD); + } + return values; + } + + /** + * C's checks of the orders and numbers of coefficients, those of {@code astInitSplineMap}, with + * the check that the numbers of knots and coefficients can be represented by an {@code int} + * that the PR hardening C (Starlink/ast #104) adds; {@code method} begins each message. + */ + private static void checkSizes(String method, int kx, int ky, int nx, int ny) { + if (kx < 1 || kx > MAX_K) { + throw Ast.err( + AstException.AST__ATTIN, + method + ": The supplied spline order in the X direction (" + kx + + ") is invalid - it must be in the range [1," + MAX_K + "]."); + } else if (ky < 1 || ky > MAX_K) { + throw Ast.err( + AstException.AST__ATTIN, + method + ": The supplied spline order in the Y direction (" + ky + + ") is invalid - it must be in the range [1," + MAX_K + "]."); + } else if (nx < kx) { + throw Ast.err( + AstException.AST__ATTIN, + method + ": The supplied number of coefficients in the X direction (" + nx + + ") is too small - it must be larger than or equal to " + kx + "."); + } else if (ny < ky) { + throw Ast.err( + AstException.AST__ATTIN, + method + ": The supplied number of coefficients in the Y direction (" + ny + + ") is too small - it must be larger than or equal to " + ky + "."); + } else if (nx > Integer.MAX_VALUE - kx || ny > Integer.MAX_VALUE - ky || nx > Integer.MAX_VALUE / ny) { + throw Ast.err( + AstException.AST__ATTIN, + method + ": The supplied numbers of coefficients in the X and Y directions (" + nx + " and " + ny + + ") are too large."); + } + } + + /** C's check that the first {@code nknot} knots of {@code t} do not decrease. */ + private static void checkKnots(String method, String dir, double[] t, int nknot) { + for (int i = 1; i < nknot; i++) { + if (t[i - 1] > t[i]) { + throw Ast.err( + AstException.AST__ATTIN, + method + ": The supplied knots in the " + dir + " direction are not monotonic increasing."); + } + } + } + + /** An {@code AST__DIMIN} error if {@code values} has fewer than {@code n} elements, as jniast checks its arrays. */ + private static void checkLength(String what, double[] values, int n) { + if (values.length < n) { + throw Ast.err( + AstException.AST__DIMIN, + "astSplineMap(SplineMap): The " + what + " array holds " + values.length + + " values.\nThis should not be less than " + n + "."); + } + } + + /** + * The {@code nx * ny} coefficients of {@code c}, given with the Y index varying fastest + * (element {@code j + i*ny}), with the X index varying fastest (element {@code i + j*nx}), as + * C's {@code astSplineMap} reorders them. + */ + private static double[] transposed(double[] c, int nx, int ny) { + double[] out = new double[nx * ny]; + for (int j = 0; j < ny; j++) { + for (int i = 0; i < nx; i++) { + out[i + j * nx] = c[j + i * ny]; + } + } + return out; + } + + @Override + String dumpComment() { + return "Map using a bi-cubic spline"; + } + + /** + * Writes the orders, the numbers of coefficients, the knots and the coefficients, then + * InvNiter, OutUnit and InvTol, each only when set, as C's {@code Dump} (splinemap.c) does. + */ + @Override + void dump(NativeNode node) { + super.dump(node); + node.writeIsA("Mapping", "Mapping between coordinate systems"); + node.writeInt("KX", true, true, kx, "Polynomial order in X direction"); + node.writeInt("KY", true, true, ky, "Polynomial order in Y direction"); + node.writeInt("NX", true, true, nx, "No. of coeffs in X direction"); + node.writeInt("NY", true, true, ny, "No. of coeffs in Y direction"); + for (int i = 0; i < nx + kx; i++) { + node.writeDouble("TX" + (i + 1), true, true, tx[i], "Knot " + (i + 1) + " x position"); + } + for (int i = 0; i < ny + ky; i++) { + node.writeDouble("TY" + (i + 1), true, true, ty[i], "Knot " + (i + 1) + " y position"); + } + int nc = nx * ny; + for (int i = 0; i < nc; i++) { + node.writeDouble("CU" + (i + 1), true, true, cu[i], "X coeff " + (i + 1)); + } + for (int i = 0; i < nc; i++) { + node.writeDouble("CV" + (i + 1), true, true, cv[i], "Y coeff " + (i + 1)); + } + node.writeInt( + "NiterInv", testInvNiter(), false, getInvNiter(), "Max number of iterations for iterative inverse"); + node.writeInt("OutUnit", testOutUnit(), false, getOutUnit() ? 1 : 0, "How to handle out-of-bounds points"); + node.writeDouble("TolInv", testInvTol(), false, getInvTol(), "Target relative error for iterative inverse"); + } + + /** Gives the copy its own knots and coefficients, as C's {@code Copy} (splinemap.c) does. */ + @Override + void deepCopy() { + super.deepCopy(); + tx = tx.clone(); + ty = ty.clone(); + cu = cu.clone(); + cv = cv.clone(); + } + + // ------------------------------------------------------------------ + // Knots and coefficients + // ------------------------------------------------------------------ + + /** + * Retrieves the knots used by the SplineMap along either the "x" (first) or "y" (second) input + * axis. + * + *

The Invert attribute of the SplineMap is ignored. The returned values always refer to the + * forward transformation of the SplineMap as it was originally constructed. + * + * @param axis the index of the input axis for which the knots are required (1 for the "x" axis + * and 2 for the "y" axis); any value other than 1 gives the "y" axis knots, as C does + * @return the knot positions: {@code SplineNx + SplineKx} values for the "x" axis or {@code + * SplineNy + SplineKy} for the "y" axis + */ + public double[] splineKnots(int axis) { + return axis == 1 ? tx.clone() : ty.clone(); + } + + /** + * Retrieves the coefficient values used by the spline that generates the values of either the + * first ("u") or second ("v") output axis of the SplineMap, in the same form that they are + * supplied to the SplineMap constructor. + * + *

The Invert attribute of the SplineMap is ignored. The returned values always refer to the + * forward transformation of the SplineMap as it was originally constructed. + * + * @param axis the index of the output axis for which the coefficients are required (1 for the + * "u" axis and 2 for the "v" axis); any value other than 1 gives the "v" axis coefficients, + * as C does + * @return the {@code SplineNx * SplineNy} coefficients, element {@code j + i*SplineNy} being + * the coefficient for x index {@code i} and y index {@code j} + */ + public double[] splineCoeffs(int axis) { + double[] pin = axis == 1 ? cu : cv; + double[] out = new double[nx * ny]; + for (int j = 0; j < ny; j++) { + for (int i = 0; i < nx; i++) { + out[j + i * ny] = pin[i + j * nx]; + } + } + return out; + } + + // ------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------ + + /** + * Gets the order of the splines along the input X axis: one more than the degree of the + * piecewise polynomial used by the spline (e.g. SplineKx is 4 for a cubic spline in the X + * direction). The value is specified when a SplineMap is first created and cannot subsequently + * be changed. + * + * @return the SplineKx attribute + */ + public int getSplineKx() { + return kx; + } + + /** + * Gets the order of the splines along the input Y axis: one more than the degree of the + * piecewise polynomial used by the spline (e.g. SplineKy is 4 for a cubic spline in the Y + * direction). The value is specified when a SplineMap is first created and cannot subsequently + * be changed. + * + * @return the SplineKy attribute + */ + public int getSplineKy() { + return ky; + } + + /** + * Gets the number of spline coefficients along the input X axis. The value is specified when a + * SplineMap is first created and cannot subsequently be changed. + * + * @return the SplineNx attribute + */ + public int getSplineNx() { + return nx; + } + + /** + * Gets the number of spline coefficients along the input Y axis. The value is specified when a + * SplineMap is first created and cannot subsequently be changed. + * + * @return the SplineNy attribute + */ + public int getSplineNy() { + return ny; + } + + /** + * Gets the maximum number of iterations for the iterative inverse transformation: the maximum + * number of iterations of the Newton-Raphson algorithm to be used for each transformed + * position. If the iterative inverse fails to converge to the target relative error specified + * by attribute InvTol within the number of iterations specified by InvNiter, then the value + * {@link #AST__BAD} is returned for both output axis values. The default value for InvNiter is + * 6. + * + * @return the InvNiter attribute + */ + public int getInvNiter() { + return invNiter == UNSET ? DEFAULT_INV_NITER : invNiter; + } + + /** + * Sets the maximum number of iterations for the iterative inverse transformation (see {@link + * #getInvNiter}). A value different from the one held discards the record that the SplineMap + * has been simplified. + * + * @param invNiter the InvNiter attribute + * @throws AstException with status {@code AST__IMMUT} if the SplineMap is shared with a holder + * such as a CmpMap, which a copy is not + */ + public void setInvNiter(int invNiter) { + storeInvNiter(invNiter); + } + + /** C's private {@code SetInvNiter}, an {@code astMAKE_SET1} attribute. */ + private void storeInvNiter(int value) { + checkSet1("InvNiter"); + if (value != invNiter) { + clearIsSimple(); + } + invNiter = value; + } + + private boolean testInvNiter() { + return invNiter != UNSET; + } + + /** Clears InvNiter, discarding the record of simplification ({@code astMAKE_CLEAR1}). */ + private void clearInvNiter() { + checkClear1("InvNiter"); + clearIsSimple(); + invNiter = UNSET; + } + + /** + * Gets the target relative error for the iterative inverse transformation: the target relative + * error in the axis values of each transformed position (the change in axis value divided by + * the absolute axis value). Further iterations will be performed until the target relative + * error is reached, or the maximum number of iterations given by attribute InvNiter is reached. + * If the target relative error is not reached within the maximum number of iterations the + * value {@link #AST__BAD} is returned for both output axis values. The default value for + * InvTol is 1.0E-6. + * + * @return the InvTol attribute + */ + public double getInvTol() { + return invTol == AST__BAD ? DEFAULT_INV_TOL : invTol; + } + + /** + * Sets the target relative error for the iterative inverse transformation (see {@link + * #getInvTol}). {@link #AST__BAD} leaves the attribute unset. A value different from the one + * held discards the record that the SplineMap has been simplified. + * + * @param invTol the InvTol attribute + * @throws AstException with status {@code AST__IMMUT} if the SplineMap is shared with a holder + * such as a CmpMap, which a copy is not + */ + public void setInvTol(double invTol) { + storeInvTol(invTol); + } + + /** C's private {@code SetInvTol}, an {@code astMAKE_SET1} attribute. */ + private void storeInvTol(double value) { + checkSet1("InvTol"); + if (value != invTol) { + clearIsSimple(); + } + invTol = value; + } + + private boolean testInvTol() { + return invTol != AST__BAD; + } + + /** Clears InvTol, discarding the record of simplification ({@code astMAKE_CLEAR1}). */ + private void clearInvTol() { + checkClear1("InvTol"); + clearIsSimple(); + invTol = AST__BAD; + } + + /** + * Gets the OutUnit attribute, which controls the output values returned by the original + * forward transformation (i.e. assuming the SplineMap has not been inverted) when transforming + * input positions that fall outside the bounds of the knot positions stored within the + * SplineMap. If false (the default), {@link #AST__BAD} is returned for both output axes at such + * points. If true, the forward transformation behaves like a unit mapping at such points (i.e. + * the input axis values are copied to the output axis values). The setting of this attribute + * also affects the value returned by the {@link #rate} method. + * + * @return the OutUnit attribute + */ + public boolean getOutUnit() { + return outUnit != UNSET && outUnit != 0; + } + + /** + * Sets the OutUnit attribute (see {@link #getOutUnit}). A value different from the one held + * discards the record that the SplineMap has been simplified. + * + * @param outUnit the OutUnit attribute + * @throws AstException with status {@code AST__IMMUT} if the SplineMap is shared with a holder + * such as a CmpMap, which a copy is not + */ + public void setOutUnit(boolean outUnit) { + storeOutUnit(outUnit ? 1 : 0); + } + + /** + * C's private {@code SetOutUnit}, an {@code astMAKE_SET1} attribute: any value but 0 is stored + * as 1, and a value different from the one held discards the record of simplification. + */ + private void storeOutUnit(int value) { + checkSet1("OutUnit"); + int v = value != 0 ? 1 : 0; + if (v != outUnit) { + clearIsSimple(); + } + outUnit = v; + } + + private boolean testOutUnit() { + return outUnit != UNSET; + } + + /** Clears OutUnit, discarding the record of simplification ({@code astMAKE_CLEAR1}). */ + private void clearOutUnit() { + checkClear1("OutUnit"); + clearIsSimple(); + outUnit = UNSET; + } + + /** Whether {@code attrib} is one of the class's read-only attributes. */ + private static boolean isReadOnly(String attrib) { + switch (attrib) { + case "splinekx": + case "splineky": + case "splinenx": + case "splineny": + return true; + default: + return false; + } + } + + @Override + String getAttrib(String attrib) { + switch (attrib) { + case "invniter": + return Integer.toString(getInvNiter()); + case "invtol": + return CFormat.format("%.17g", getInvTol()); + case "outunit": + return getOutUnit() ? "1" : "0"; + case "splinekx": + return Integer.toString(kx); + case "splineky": + return Integer.toString(ky); + case "splinenx": + return Integer.toString(nx); + case "splineny": + return Integer.toString(ny); + default: + return super.getAttrib(attrib); + } + } + + @Override + void setAttrib(String attrib, String value) { + Integer ival = CScan.scanInt(value); + Double dval = CScan.scanDouble(value); + if ("invniter".equals(attrib) && ival != null) { + storeInvNiter(ival); + } else if ("invtol".equals(attrib) && dval != null) { + storeInvTol(dval); + } else if ("outunit".equals(attrib) && ival != null) { + storeOutUnit(ival); + } else if (isReadOnly(attrib)) { + throw Ast.err( + AstException.AST__NOWRT, + "astSet: The setting \"" + attrib + "=" + value + "\" is invalid for a " + astClass() + + ".\nThis is a read-only attribute."); + } else { + super.setAttrib(attrib, value); + } + } + + @Override + boolean testAttrib(String attrib) { + switch (attrib) { + case "invniter": + return testInvNiter(); + case "invtol": + return testInvTol(); + case "outunit": + return testOutUnit(); + default: + return !isReadOnly(attrib) && super.testAttrib(attrib); + } + } + + @Override + void clearAttrib(String attrib) { + switch (attrib) { + case "invniter": + clearInvNiter(); + break; + case "invtol": + clearInvTol(); + break; + case "outunit": + clearOutUnit(); + break; + default: + if (isReadOnly(attrib)) { + throw Ast.err( + AstException.AST__NOWRT, + "astClear: Invalid attempt to clear the \"" + attrib + "\" value for a " + astClass() + + ".\nThis is a read-only attribute."); + } + super.clearAttrib(attrib); + break; + } + } + + // ------------------------------------------------------------------ + // Equality and simplification + // ------------------------------------------------------------------ + + /** + * splinemap.c {@code Equal}: {@code that} is a SplineMap with the same Invert attribute, the + * same orders and numbers of coefficients, and knots and coefficients equal to within {@code + * astEQUAL}. InvNiter, InvTol and OutUnit are not compared. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof SplineMap)) { + return false; + } + SplineMap other = (SplineMap) that; + // An inverted SplineMap has no forward transformation of its own. + if (getInvert() != other.getInvert()) { + return false; + } + if (kx != other.kx || ky != other.ky || nx != other.nx || ny != other.ny) { + return false; + } + for (int i = 0; i < nx + kx; i++) { + if (!MappingHelpers.astEqual(tx[i], other.tx[i])) { + return false; + } + } + for (int i = 0; i < ny + ky; i++) { + if (!MappingHelpers.astEqual(ty[i], other.ty[i])) { + return false; + } + } + int nc = nx * ny; + for (int i = 0; i < nc; i++) { + if (!MappingHelpers.astEqual(cu[i], other.cu[i]) || !MappingHelpers.astEqual(cv[i], other.cv[i])) { + return false; + } + } + return true; + } + + /** + * splinemap.c {@code MapMerge}: in series, the nominated SplineMap cancels with a neighbouring + * SplineMap applied in the opposite direction that is equal to it applied in its direction, + * the pair becoming two UnitMaps ({@link #cancelWithOppositeNeighbour}). + */ + @Override + int mapMerge(MergeList list, int where, boolean series) { + if (!series) { + return -1; + } + return cancelWithOppositeNeighbour(list, where, list.map(where), SplineMap.class, -1); + } + + // ------------------------------------------------------------------ + // Transformation + // ------------------------------------------------------------------ + + /** + * C's {@code Transform} (splinemap.c): forward, each output is the value of its spline at the + * input position, or, outside the knots, bad or (with OutUnit set) the input value; inverse, + * the iterative inverse ({@link #iterInverse}). A point bad on either input is bad on both + * outputs; a NaN or infinite input counts as bad, and a NaN output is bad. + */ + @Override + void transformInto(double[][] in, int npoint, boolean forward, double[][] out) { + validateTransformInto(in, npoint, forward, out); + if (effectiveForward(forward)) { + double[] xin = in[0]; + double[] yin = in[1]; + double[] x = new double[npoint]; + double[] y = new double[npoint]; + for (int point = 0; point < npoint; point++) { + x[point] = isBad(xin[point]) ? AST__BAD : xin[point]; + y[point] = isBad(yin[point]) ? AST__BAD : yin[point]; + } + forwardInto(x, y, npoint, out[0], out[1]); + } else { + iterInverse(in[0], in[1], npoint, out[0], out[1]); + } + for (int c = 0; c < 2; c++) { + double[] axis = out[c]; + for (int point = 0; point < npoint; point++) { + if (Double.isNaN(axis[point])) { + axis[point] = AST__BAD; + } + } + } + } + + /** + * The forward transformation of C's {@code Transform}, of the original forward transformation + * whatever the Invert attribute: a point whose x or y is {@link #AST__BAD} is bad on both + * outputs; otherwise each output is its spline's value, as {@link #db2val} gives it, with the + * input value as the default outside the knots when OutUnit is set. + */ + private void forwardInto(double[] xin, double[] yin, int npoint, double[] xout, double[] yout) { + boolean outunit = getOutUnit(); + double[] work = new double[4 * MAX_K]; + int[] iw = new int[2]; + for (int point = 0; point < npoint; point++) { + double x = xin[point]; + double y = yin[point]; + if (x != AST__BAD && y != AST__BAD) { + xout[point] = db2val(outunit ? x : AST__BAD, x, y, 0, 0, cu, work, iw); + yout[point] = db2val(outunit ? y : AST__BAD, x, y, 0, 0, cv, work, iw); + } else { + xout[point] = AST__BAD; + yout[point] = AST__BAD; + } + } + } + + /** + * C's {@code IterInverse} (splinemap.c): the original inverse transformation of the outputs + * {@code (pu, pv)}, found by Newton-Raphson iteration of the original forward transformation. + * The first guess at each input is {@code 2u - u'}, where {@code u'} is the spline's value at + * the output position, or the output itself where that is bad. Each iteration holds every + * guess that is not bad to the knots, shrunk by a tiny amount, transforms the guesses forward, + * and solves the Jacobian, from the splines' derivatives, for the step to the required output + * ({@code palDmat}); a bad value or a singular Jacobian makes the point bad, and a point + * converges when the squared length of its step is no more than InvTol squared times the + * squared length of its position. Iterations stop when every point has converged or after + * InvNiter of them, and a point that has not converged is bad. + */ + private void iterInverse(double[] pu, double[] pv, int npoint, double[] px, double[] py) { + boolean outunit = getOutUnit(); + double[] dwork = new double[4 * MAX_K]; + int[] iw = new int[2]; + boolean[] flags = new boolean[npoint]; + int nconv = 0; + for (int ipoint = 0; ipoint < npoint; ipoint++) { + double u = pu[ipoint]; + double v = pv[ipoint]; + // A NaN or infinite output counts as bad, where C tests for AST__BAD. + if (!isBad(u) && !isBad(v)) { + double a = db2val(outunit ? u : AST__BAD, u, v, 0, 0, cu, dwork, iw); + px[ipoint] = a != AST__BAD ? 2 * u - a : u; + a = db2val(outunit ? v : AST__BAD, u, v, 0, 0, cv, dwork, iw); + py[ipoint] = a != AST__BAD ? 2 * v - a : v; + if (px[ipoint] == AST__BAD || py[ipoint] == AST__BAD) { + px[ipoint] = AST__BAD; + py[ipoint] = AST__BAD; + flags[ipoint] = true; + nconv++; + } + } else { + px[ipoint] = AST__BAD; + py[ipoint] = AST__BAD; + flags[ipoint] = true; + nconv++; + } + } + + int maxiter = getInvNiter(); + double maxerr = getInvTol(); + maxerr *= maxerr; + + // The region covered by the knots, reduced by a tiny amount to avoid edge cases. + double xlo = tx[0]; + double xhi = tx[nx + kx - 1]; + double a = 1.0E-16 * (xhi - xlo); + xlo += a; + xhi -= a; + double ylo = ty[0]; + double yhi = ty[ny + ky - 1]; + a = 1.0E-16 * (yhi - ylo); + ylo += a; + yhi -= a; + + double[] wu = new double[npoint]; + double[] wv = new double[npoint]; + double[] mat = new double[4]; + double[] vec = new double[2]; + for (int iter = 0; iter < maxiter && nconv < npoint; iter++) { + for (int ipoint = 0; ipoint < npoint; ipoint++) { + if (px[ipoint] != AST__BAD) { + if (px[ipoint] < xlo) { + px[ipoint] = xlo; + } else if (px[ipoint] > xhi) { + px[ipoint] = xhi; + } + } + if (py[ipoint] != AST__BAD) { + if (py[ipoint] < ylo) { + py[ipoint] = ylo; + } else if (py[ipoint] > yhi) { + py[ipoint] = yhi; + } + } + } + + // The outputs of the current guesses, then their offsets from the required outputs. + forwardInto(px, py, npoint, wu, wv); + offsets(pu, wu, npoint); + offsets(pv, wv, npoint); + + for (int ipoint = 0; ipoint < npoint; ipoint++) { + if (flags[ipoint]) { + continue; + } + double x = px[ipoint]; + double y = py[ipoint]; + mat[0] = db2val(outunit ? 1.0 : AST__BAD, x, y, 1, 0, cu, dwork, iw); + mat[1] = db2val(outunit ? 0.0 : AST__BAD, x, y, 0, 1, cu, dwork, iw); + mat[2] = db2val(outunit ? 0.0 : AST__BAD, x, y, 1, 0, cv, dwork, iw); + mat[3] = db2val(outunit ? 1.0 : AST__BAD, x, y, 0, 1, cv, dwork, iw); + vec[0] = wu[ipoint]; + vec[1] = wv[ipoint]; + boolean sing; + if (vec[0] != AST__BAD + && vec[1] != AST__BAD + && mat[0] != AST__BAD + && mat[1] != AST__BAD + && mat[2] != AST__BAD + && mat[3] != AST__BAD) { + sing = !Pal.dmat(2, mat, vec); + } else { + sing = true; + } + if (sing) { + px[ipoint] = AST__BAD; + py[ipoint] = AST__BAD; + flags[ipoint] = true; + nconv++; + } else { + px[ipoint] += vec[0]; + py[ipoint] += vec[1]; + double xlensq = px[ipoint] * px[ipoint] + py[ipoint] * py[ipoint]; + double vlensq = vec[0] * vec[0] + vec[1] * vec[1]; + if (vlensq <= maxerr * xlensq) { + flags[ipoint] = true; + nconv++; + } + } + } + } + + if (nconv < npoint) { + for (int ipoint = 0; ipoint < npoint; ipoint++) { + if (!flags[ipoint]) { + px[ipoint] = AST__BAD; + py[ipoint] = AST__BAD; + } + } + } + } + + /** Replaces each {@code w[i]} by {@code target[i] - w[i]}, bad where either is {@link #AST__BAD}. */ + private static void offsets(double[] target, double[] w, int npoint) { + for (int ipoint = 0; ipoint < npoint; ipoint++) { + if (target[ipoint] != AST__BAD && w[ipoint] != AST__BAD) { + w[ipoint] = target[ipoint] - w[ipoint]; + } else { + w[ipoint] = AST__BAD; + } + } + } + + /** + * splinemap.c {@code Rate}: the derivative of the spline giving output {@code ax1} with respect + * to input {@code ax2}, or, outside the knots, bad or (with OutUnit set) that of a unit + * Mapping. The splines give the derivatives of the forward transformation only, so the rate of + * an inverted SplineMap, that of its inverse transformation, is found numerically, by the + * Mapping class's method. + */ + @Override + double rateAt(double[] at, int ax1, int ax2) { + if (getInvert()) { + return super.rateAt(at, ax1, ax2); + } + if (isBad(at[0]) || isBad(at[1])) { + return AST__BAD; + } + double[] coef = ax1 == 0 ? cu : cv; + int xder = ax2 == 0 ? 1 : 0; + int yder = ax2 == 0 ? 0 : 1; + double def; + if (getOutUnit()) { + def = ax1 == ax2 ? 1.0 : 0.0; + } else { + def = AST__BAD; + } + return db2val(def, at[0], at[1], xder, yder, coef, new double[4 * MAX_K], new int[2]); + } + + // ------------------------------------------------------------------ + // B-spline evaluation: CMLIB's DB2VAL, DBVALU and DINTRV, as C has them + // ------------------------------------------------------------------ + + /** + * C's {@code Db2val} (splinemap.c, from CMLIB's {@code DB2VAL}), as the PR that hardens C + * (Starlink/ast #104) has it: the value at {@code (xval, yval)} of the spline of the + * SplineMap's knots and orders with coefficients {@code bcoef}, or its {@code idx}-th partial + * derivative with respect to x and {@code idy}-th with respect to y. + * + *

The spline is defined only over the range its knots cover, from {@code tx[kx - 1]} to + * {@code tx[nx]} and from {@code ty[ky - 1]} to {@code ty[ny]}, the whole box of the knots + * when the first and last {@code kx} and {@code ky} knots are equal; elsewhere, and for a NaN, + * the result is {@code def}. On the upper limit in y, found among the knots up to {@code + * ty[ny]}, the knot interval is the last one of non-zero width, and the result is bad if there + * is none; a column of coefficients whose value along x is bad (a bad coefficient, or a range + * covered along x of zero width) makes the result bad. The pinned C tests only the box of the + * knots: beyond the range covered along x it combines the bad values {@code Dbvalu} gives + * arithmetically, which may or may not give {@link #AST__BAD}; along y, and for a NaN, it reads + * beyond its arrays; and it searches all the knots along y, giving bad on the upper limit of a + * spline with a single knot interval along y. + * + * @param work at least {@code 4 * MAX_K} elements of work space (C's {@code work}, of which C + * uses {@code 3*max(kx,ky) + ky}) + * @param iw two elements of work space for {@link #dintrv} + */ + private double db2val( + double def, double xval, double yval, int idx, int idy, double[] bcoef, double[] work, int[] iw) { + if (!(xval >= tx[kx - 1] && xval <= tx[nx] && yval >= ty[ky - 1] && yval <= ty[ny])) { + return def; + } + // Only the knots up to the upper limit of the range covered are searched, so that a + // position on that limit is flagged by mflag whatever the multiplicity of the last knots. + iw[0] = 0; + int lefty = dintrv(ty, 0, ny + 1, yval, iw); + int mflag = iw[1]; + if (mflag != 0) { + if (yval > ty[lefty]) { + return AST__BAD; + } + // Step back to the last knot interval of non-zero width. + do { + if (lefty == ky - 1) { + return AST__BAD; + } + lefty--; + } while (yval == ty[lefty]); + } + int iwork = ky; + int kcol = lefty - ky; + for (int k = 0; k < ky; k++) { + kcol++; + work[k] = dbvalu(tx, 0, bcoef, nx * kcol, nx, kx, idx, xval, 0, work, iwork, iw); + if (work[k] == AST__BAD) { + return AST__BAD; + } + } + kcol = lefty - ky + 1; + return dbvalu(ty, kcol, work, 0, ky, ky, idy, yval, 0, work, iwork, iw); + } + + /** + * C's {@code Dbvalu} (splinemap.c, from CMLIB's {@code DBVALU}): the value at {@code x} of the + * B-spline of order {@code k} with knots {@code t[toff]} to {@code t[toff + n + k - 1]} and + * coefficients {@code a[aoff]} to {@code a[aoff + n - 1]}, or its {@code ideriv}-th + * derivative. The spline is defined from {@code t[toff + k - 1]} to {@code t[toff + n]}, and + * the result is bad elsewhere; on the upper limit the knot interval is the last one of + * non-zero width (C's change to CMLIB), and the result is bad if there is none, when the range + * covered has zero width, as the PR that hardens C (Starlink/ast #104) has it; the pinned C + * then evaluates the first knot interval, of zero width. A derivative of order {@code k} or + * more is zero. + * + *

{@code x} must not be NaN: C then reads before the start of the arrays, and {@link + * #db2val} gives the default value for a NaN before calling this. + * + * @param inbv the knot interval at which to start the search (C's {@code inbv}), 0 the first + * time + * @param work {@code 3*k} elements of work space from {@code woff} + * @param iw two elements of work space for {@link #dintrv} + * @throws AstException with status {@code AST__INTER} if {@code k} is less than 1, {@code n} + * is less than {@code k} or {@code ideriv} is negative + */ + static double dbvalu( + double[] t, + int toff, + double[] a, + int aoff, + int n, + int k, + int ideriv, + double x, + int inbv, + double[] work, + int woff, + int[] iw) { + if (k < 1 || n < k || ideriv < 0) { + throw Ast.err( + AstException.AST__INTER, + "SplineMap: Dbvalu called with inappropriate arguments (internal AST programming error)."); + } + // A spline of order k is a piecewise polynomial of degree k-1, so any derivative of order k + // or higher is zero within each piece. + if (ideriv >= k) { + return 0.0; + } + if (x < t[toff + k - 1]) { + return AST__BAD; + } + int kmider = k - ideriv; + int km1 = k - 1; + iw[0] = inbv; + int i = dintrv(t, toff, n + 1, x, iw); + int mflag = iw[1]; + if (mflag != 0) { + if (x > t[toff + i]) { + return AST__BAD; + } + // Step back to the last knot interval of non-zero width; if the first interval is + // reached and it too has zero width, the range covered has zero width and there is no + // left limiting value (the hardening PR's step-back). + do { + if (i == k - 1) { + return AST__BAD; + } + i--; + } while (x == t[toff + i]); + } + + // Difference the coefficients ideriv times: work[j] holds aj[j], work[k + j] dp[j] and + // work[2k + j] dm[j]. + int imk = i - k + 1; + for (int j = 0; j < k; j++) { + work[woff + j] = a[aoff + imk + j]; + } + if (ideriv != 0) { + for (int j = 1; j <= ideriv; j++) { + int kmj = k - j; + double fkmj = kmj; + for (int jj = 0; jj < kmj; jj++) { + int ihi = i + jj + 1; + int ihmkmj = ihi - kmj; + work[woff + jj] = + (work[woff + jj + 1] - work[woff + jj]) / (t[toff + ihi] - t[toff + ihmkmj]) * fkmj; + } + } + } + + // The value at x in (t[i], t[i+1]) of the ideriv-th derivative, from its B-spline + // coefficients in work[0] to work[k - ideriv - 1]. + if (ideriv != km1) { + int ip1 = i + 1; + int kpk = k + k; + int j1 = k; + int j2 = kpk; + for (int j = 1; j <= kmider; j++) { + int ipj = i + j; + work[woff + j1] = t[toff + ipj] - x; + int ip1mj = ip1 - j; + work[woff + j2] = x - t[toff + ip1mj]; + j1++; + j2++; + } + int iderp1 = ideriv + 1; + for (int j = iderp1; j <= km1; j++) { + int kmj = k - j; + int ilo = kmj - 1; + for (int jj = 0; jj < kmj; jj++) { + work[woff + jj] = + (work[woff + jj + 1] * work[woff + kpk + ilo] + work[woff + jj] * work[woff + k + jj]) + / (work[woff + kpk + ilo] + work[woff + k + jj]); + ilo--; + } + } + } + return work[woff]; + } + + /** + * C's {@code Dintrv} (splinemap.c, from CMLIB's {@code DINTRV}): the largest index {@code + * ileft} in 0 to {@code lxt - 1} such that {@code xt[xoff + ileft] <= x}, among the {@code lxt} + * non-decreasing knots from {@code xt[xoff]}. On entry {@code iw[0]} is the index at which to + * start the search (C's {@code ilo}, 0 the first time), and on exit it holds the search's + * state; {@code iw[1]} is set to -1 (and the result is 0) if {@code x < xt[xoff]}, 1 (and the + * result is {@code lxt - 1}) if {@code x >= xt[xoff + lxt - 1]}, and 0 otherwise (C's {@code + * mflag}). + */ + static int dintrv(double[] xt, int xoff, int lxt, double x, int[] iw) { + int ilo = iw[0]; + int ihi = ilo + 1; + if (ihi >= lxt - 1) { + if (x >= xt[xoff + lxt - 1]) { + return dintrvResult(iw, ilo, 1, lxt - 1); + } + if (lxt <= 1) { + return dintrvResult(iw, ilo, -1, 0); + } + ilo = lxt - 2; + ihi = lxt - 1; + } + if (x >= xt[xoff + ihi]) { + // Now x >= xt[ilo]: find an upper bound. + int istep = 1; + while (true) { + ilo = ihi; + ihi = ilo + istep; + if (ihi >= lxt - 1) { + if (x >= xt[xoff + lxt - 1]) { + return dintrvResult(iw, ilo, 1, lxt - 1); + } + ihi = lxt - 1; + break; + } + if (x < xt[xoff + ihi]) { + break; + } + istep *= 2; + } + } else if (x >= xt[xoff + ilo]) { + return dintrvResult(iw, ilo, 0, ilo); + } else { + // Now x < xt[ihi]: find a lower bound. + int istep = 1; + while (true) { + ihi = ilo; + ilo = ihi - istep; + if (ilo <= 0) { + ilo = 0; + if (x < xt[xoff]) { + return dintrvResult(iw, ilo, -1, 0); + } + break; + } + if (x >= xt[xoff + ilo]) { + break; + } + istep *= 2; + } + } + // Now xt[ilo] <= x < xt[ihi]: narrow the interval. + while (true) { + int middle = (ilo + ihi) / 2; + if (middle == ilo) { + return dintrvResult(iw, ilo, 0, ilo); + } + if (x < xt[xoff + middle]) { + ihi = middle; + } else { + ilo = middle; + } + } + } + + /** Stores {@link #dintrv}'s search state and flag in {@code iw}, and returns {@code ileft}. */ + private static int dintrvResult(int[] iw, int ilo, int mflag, int ileft) { + iw[0] = ilo; + iw[1] = mflag; + return ileft; + } +} diff --git a/src/main/java/uk/ac/starlink/ast/UnitNormMap.java b/src/main/java/uk/ac/starlink/ast/UnitNormMap.java new file mode 100644 index 0000000..68f11b3 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/UnitNormMap.java @@ -0,0 +1,487 @@ +package uk.ac.starlink.ast; + +import java.util.Arrays; +import java.util.Objects; + +/** + * A Mapping which converts a vector to a unit vector and its norm, relative to a specified centre. + * + *

The forward transformation of a UnitNormMap subtracts the specified centre and then + * transforms the resulting vector to a unit vector and the vector norm. The output contains one + * more coordinate than the input: the initial Nin outputs are in the same order as the input; the + * final output is the norm. If the norm is 0, then the output of the forward transformation is + * {@link #AST__BAD} for each component of the unit vector and 0 for the norm (the final value). + * + *

The inverse transformation of a UnitNormMap multiplies each component of the provided vector + * by the provided norm and adds the specified centre. The output contains one fewer coordinate + * than the input: the initial Nin inputs are in the same order as the output; the final input is + * the norm. If the provided norm is 0 then the other input values are ignored, and the output + * vector is the centre. + * + *

Example: if centre = [1, -1] then [5, 2] transforms to [4, 3] after subtracting the centre; + * the norm is 5, so the output is [0.8, 0.6, 5]. + * + *

UnitNormMap enables radially symmetric transformations, as follows: + * + *

    + *
  • apply a UnitNormMap to produce a unit vector and norm (radius) + *
  • apply a one-dimensional mapping to the norm (radius), while passing the unit vector + * unchanged + *
  • apply the same UnitNormMap in the inverse direction to produce the result + *
+ * + *

The UnitNormMap class does not define any new attributes or methods beyond those which are + * applicable to all Mappings. + * + *

Both transformations are discontinuous at the centre. The forward transformation tests + * whether the supplied position coincides with the centre, and the inverse tests whether the + * supplied norm is zero; each test is exact, because a position that differs from the centre by + * any representable amount does have a direction, and reporting it is more useful than discarding + * it. A consequence is that a Mapping which computes a position close to a UnitNormMap's centre, + * rather than supplying one directly, may not give the same result on every platform. Composing + * the inverse of one UnitNormMap with the forward transformation of another whose centre is the + * position the first one reconstructs is the case to watch: the reconstruction is a multiply-add, + * which a C compiler may contract into a fused multiply-add, rounding once instead of twice, so + * that the C library, depending on how it was built, can report a direction derived from a + * rounding residue where this class, which never fuses them, reports none. + * + *

A bad (or non-finite) centre coordinate makes every output bad, and so does any input value + * that is bad or not finite, except that in the inverse transformation a zero norm gives the + * centre whatever the other inputs are, and a bad component of the unit vector makes only its own + * output bad. + * + *

Ported from Rust {@code mappings/unitnormmap.rs} and C {@code unitnormmap.c}. + */ +public class UnitNormMap extends Mapping { + + /** The centre, one value per input of the UnitNormMap as created (C's {@code centre}). */ + private double[] centre; + + /** + * Creates a UnitNormMap. + * + * @param ncoord the number of input coordinate values for each point to be transformed (i.e. + * the number of dimensions of the space in which the input points will reside); the + * output has one more. It must be at least 1 + * @param centre an array containing the coordinates of the centre, one for each input + * coordinate + * @throws NullPointerException if {@code centre} is null + * @throws AstException with status {@code AST__DIMIN} if {@code centre} holds fewer than + * {@code ncoord} values, or {@code AST__BADSM} if {@code ncoord} is less than 1 + */ + public UnitNormMap(int ncoord, double[] centre) { + super(checkedNcoord(ncoord, centre), ncoord + 1, true, true); + this.centre = Arrays.copyOf(centre, ncoord); + } + + /** + * {@code ncoord}, after the checks of jniast's arguments (a null or short array) and then that + * of C's {@code astInitUnitNormMap}, which refuses a centre of no axes with a message giving no + * function name. + */ + private static int checkedNcoord(int ncoord, double[] centre) { + Objects.requireNonNull(centre, "centre"); + if (centre.length < ncoord) { + throw Ast.err( + AstException.AST__DIMIN, + "astUnitNormMap(UnitNormMap): The centre array holds " + centre.length + + " values.\nThis should not be less than " + ncoord + "."); + } + if (ncoord <= 0) { + throw Ast.err(AstException.AST__BADSM, "The centre must have at least one axis"); + } + return ncoord; + } + + /** + * Loads a UnitNormMap from its description, as C's {@code astLoadUnitNormMap} does: the centre + * has one value for each input of the UnitNormMap as created, the value for axis {@code i} + * being item {@code Ctr}, zero if absent. + * + *

The pinned C checks only that there is an input, and stores the numbers of inputs and + * outputs it reads (the PR that hardens it refuses other numbers too). With Nout less than Nin + * its forward transformation writes beyond the last output and its inverse reads beyond the + * last input; with Nout equal to Nin the forward transformation's norm overwrites the last + * component of the unit vector, and the inverse takes that component as the norm; with Nout + * more than Nin + 1 the forward transformation leaves the outputs between the unit vector and + * the norm unwritten, and the inverse ignores those inputs. + * + * @throws AstException with status {@code AST__LDERR} if the UnitNormMap as created has no + * inputs, with C's message, which gives no function name, or does not have one more output + * than inputs + */ + UnitNormMap(NativeNode node) { + super(node); + // C takes Nout if the UnitNormMap is inverted and Nin if not, which is the Nin it was made with. + int ncoord = createdNin(); + if (ncoord <= 0) { + throw Ast.err( + AstException.AST__LDERR, "The UnitNormMap has " + ncoord + " axes - it must have at least one."); + } + NativeNode part = node.section("UnitNormMap"); + centre = new double[ncoord]; + for (int axis = 0; axis < ncoord; axis++) { + centre[axis] = part.readDouble("Ctr" + (axis + 1), 0.0); + } + if (createdNout() != ncoord + 1) { + throw Ast.err( + AstException.AST__LDERR, + "astLoadUnitNormMap(UnitNormMap): The UnitNormMap read has " + ncoord + " inputs and " + + createdNout() + " outputs; it must have one more output than inputs."); + } + } + + /** A copy of the centre, one value per input of the UnitNormMap as created. */ + double[] getCentre() { + return centre.clone(); + } + + @Override + String dumpComment() { + return "Compute unit vector and norm relative to a centre"; + } + + /** Writes each centre value, set when it is not zero, as C's {@code Dump} (unitnormmap.c) does. */ + @Override + void dump(NativeNode node) { + super.dump(node); + node.writeIsA("Mapping", "Mapping between coordinate systems"); + for (int axis = 0; axis < centre.length; axis++) { + node.writeDouble( + "Ctr" + (axis + 1), centre[axis] != 0.0, false, centre[axis], "Centre for axis " + (axis + 1)); + } + } + + /** Gives the copy its own centre, as C's {@code Copy} (unitnormmap.c) does. */ + @Override + void deepCopy() { + super.deepCopy(); + centre = centre.clone(); + } + + // ------------------------------------------------------------------ + // Transformation + // ------------------------------------------------------------------ + + /** + * C's {@code Transform} (unitnormmap.c). A bad centre coordinate makes every output of every + * point bad (C writes these through indices in the wrong order, see {@code + * docs/c-library-bugs.md}). Forward, a point bad on any input is bad on every output; one at + * the centre (the largest absolute difference from it zero) has a bad unit vector and a zero + * norm; otherwise the norm is the largest absolute difference times the square root of the sum + * of the squares of the differences scaled by it, which cannot overflow, and the unit vector is + * the differences divided by the norm. Inverse, a bad norm makes the point bad, a zero norm + * gives the centre, and otherwise each output is its component times the norm plus the centre, + * bad where the component is bad. Any value that is not finite counts as bad. + */ + @Override + void transformInto(double[][] in, int npoint, boolean forward, double[][] out) { + validateTransformInto(in, npoint, forward, out); + boolean fwd = effectiveForward(forward); + int ncoord = centre.length; + int ncoordOut = fwd ? ncoord + 1 : ncoord; + for (double c : centre) { + if (isBad(c)) { + for (int k = 0; k < ncoordOut; k++) { + Arrays.fill(out[k], 0, npoint, AST__BAD); + } + return; + } + } + if (fwd) { + forward(in, npoint, out); + } else { + inverse(in, npoint, out); + } + } + + /** The forward transformation: vector to unit vector and norm. */ + private void forward(double[][] in, int npoint, double[][] out) { + int ncoord = centre.length; + for (int p = 0; p < npoint; p++) { + double maxRelin = 0.0; + boolean bad = false; + for (int c = 0; c < ncoord; c++) { + double v = in[c][p]; + if (isBad(v)) { + bad = true; + break; + } + double absRelin = Math.abs(v - centre[c]); + if (absRelin > maxRelin) { + maxRelin = absRelin; + } + } + if (bad) { + for (int k = 0; k <= ncoord; k++) { + out[k][p] = AST__BAD; + } + continue; + } + if (maxRelin == 0.0) { + for (int k = 0; k < ncoord; k++) { + out[k][p] = AST__BAD; + } + out[ncoord][p] = 0.0; + continue; + } + double scaledSum = 0.0; + for (int c = 0; c < ncoord; c++) { + double scaledIn = (in[c][p] - centre[c]) / maxRelin; + scaledSum += scaledIn * scaledIn; + } + double norm = maxRelin * Math.sqrt(scaledSum); + for (int c = 0; c < ncoord; c++) { + out[c][p] = (in[c][p] - centre[c]) / norm; + } + out[ncoord][p] = norm; + } + } + + /** The inverse transformation: unit vector and norm to vector. */ + private void inverse(double[][] in, int npoint, double[][] out) { + int ncoord = centre.length; + double[] norms = in[ncoord]; + for (int p = 0; p < npoint; p++) { + double norm = norms[p]; + if (isBad(norm)) { + for (int c = 0; c < ncoord; c++) { + out[c][p] = AST__BAD; + } + } else if (norm == 0.0) { + for (int c = 0; c < ncoord; c++) { + out[c][p] = centre[c]; + } + } else { + for (int c = 0; c < ncoord; c++) { + double v = in[c][p]; + out[c][p] = isBad(v) ? AST__BAD : v * norm + centre[c]; + } + } + } + } + + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + /** + * unitnormmap.c {@code Equal}: {@code that} is a UnitNormMap with the same Invert attribute and + * number of inputs whose centre is equal to this one's, each value to within {@code astEQUAL}. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof UnitNormMap)) { + return false; + } + UnitNormMap other = (UnitNormMap) that; + if (getInvert() != other.getInvert()) { + return false; + } + int nin = getNin(); + if (nin != other.getNin()) { + return false; + } + // The centre has one value per axis of the UnitNormMap as created: the smaller of Nin and Nout. + int nc = Math.min(getNout(), nin); + for (int i = 0; i < nc; i++) { + if (!MappingHelpers.astEqual(centre[i], other.centre[i])) { + return false; + } + } + return true; + } + + // ------------------------------------------------------------------ + // Simplification + // ------------------------------------------------------------------ + + /** C's {@code DBL_EPSILON}. */ + private static final double DBL_EPSILON = Math.ulp(1.0); + + /** C's {@code DBL_MIN}. */ + private static final double DBL_MIN = Double.MIN_NORMAL; + + /** + * unitnormmap.c's {@code EQUAL} macro, which its {@code MakeMergedMap} uses in place of {@code + * astEQUAL}: two bad values are equal, a bad and a good one are not, and otherwise {@code |a - + * b| <= 1.0E9 * max((|a| + |b|) * DBL_EPSILON, DBL_MIN)}. + */ + private static boolean equal(double a, double b) { + if (a == AST__BAD) { + return b == AST__BAD; + } + return b != AST__BAD && Math.abs(a - b) <= 1.0e9 * Math.max((Math.abs(a) + Math.abs(b)) * DBL_EPSILON, DBL_MIN); + } + + /** + * unitnormmap.c {@code MapMerge}: in series, each adjacent pair of the list from the one + * before this UnitNormMap (or from the first) to the end is offered, each Mapping applied with + * the Invert value the list gives it, to {@link #makeMergedMap}, and the first pair that merges + * is replaced by the merged Mapping, applied with its own Invert value. A UnitNormMap does not + * merge in parallel. + */ + @Override + int mapMerge(MergeList list, int where, boolean series) { + if (!series) { + return -1; + } + for (int i1 = Math.max(where - 1, 0); i1 + 1 < list.size(); i1++) { + int i2 = i1 + 1; + Mapping map1 = list.map(i1); + Mapping map2 = list.map(i2); + int saved1 = map1.swapInvert(list.invert(i1)); + int saved2 = map2.swapInvert(list.invert(i2)); + Mapping newmap; + try { + newmap = makeMergedMap(map1, map2); + } finally { + map1.restoreInvert(saved1); + map2.restoreInvert(saved2); + } + if (newmap != null) { + list.replacePairWith(i1, newmap, newmap.getInvert()); + return i1; + } + } + return -1; + } + + /** unitnormmap.c {@code GetMappingType}: 1 for a UnitNormMap, 2 for a ShiftMap, 3 for a WinMap, 0 otherwise. */ + private static int mappingType(Mapping map) { + // C compares the class names, so a subclass is none of these. + switch (map.astClass()) { + case "UnitNormMap": + return 1; + case "ShiftMap": + return 2; + case "WinMap": + return 3; + default: + return 0; + } + } + + /** + * unitnormmap.c {@code MakeMergedMap}: the Mapping equivalent to {@code map1} followed by + * {@code map2}, each in its current orientation, or null. One must be a UnitNormMap and the + * other a UnitNormMap, a ShiftMap or a WinMap. A ShiftMap, or a WinMap whose scales are all 1 + * ({@link #equal}), before a forward UnitNormMap moves its centre back by the shift; one after + * an inverted UnitNormMap moves its centre on by the shift, giving an inverted UnitNormMap. + * Two UnitNormMaps applied in opposite directions with equal centres give a UnitMap; with + * different centres, the forward one followed by the inverted one gives the ShiftMap from the + * first centre to the second, and the other order does not merge. + */ + static Mapping makeMergedMap(Mapping map1, Mapping map2) { + int type1 = mappingType(map1); + int type2 = mappingType(map2); + if (type1 == 0 || type2 == 0 || !(type1 == 1 || type2 == 1)) { + return null; + } + if (type1 == 2) { + if (map2.getInvert()) { + return null; + } + ShiftMap shiftmap = (ShiftMap) map1; + UnitNormMap unm = (UnitNormMap) map2; + int nin = shiftmap.getNin(); + double shiftmult = shiftmap.getInvert() ? -1 : 1; + double[] shift = shiftmap.storedShifts(); + double[] newcentre = new double[nin]; + for (int coord = 0; coord < nin; coord++) { + newcentre[coord] = unm.centre[coord] - shiftmult * shift[coord]; + } + return new UnitNormMap(nin, newcentre); + } else if (type1 == 3) { + if (map2.getInvert()) { + return null; + } + WinMap winmap = (WinMap) map1; + UnitNormMap unm = (UnitNormMap) map2; + int nin = winmap.getNin(); + double shiftmult = winmap.getInvert() ? -1 : 1; + double[] a = winmap.storedShifts(); + double[] b = winmap.storedScales(); + double[] newcentre = new double[nin]; + boolean ok = true; + for (int coord = 0; coord < nin; coord++) { + if (!equal(b[coord], 1.0)) { + ok = false; + } + newcentre[coord] = unm.centre[coord] - shiftmult * a[coord]; + } + return ok ? new UnitNormMap(nin, newcentre) : null; + } else if (type2 == 2) { + if (!map1.getInvert()) { + return null; + } + ShiftMap shiftmap = (ShiftMap) map2; + UnitNormMap unm = (UnitNormMap) map1; + int nin = shiftmap.getNin(); + double shiftmult = shiftmap.getInvert() ? -1 : 1; + double[] shift = shiftmap.storedShifts(); + double[] newcentre = new double[nin]; + for (int coord = 0; coord < nin; coord++) { + newcentre[coord] = unm.centre[coord] + shiftmult * shift[coord]; + } + return invertedUnitNormMap(nin, newcentre); + } else if (type2 == 3) { + if (!map1.getInvert()) { + return null; + } + WinMap winmap = (WinMap) map2; + UnitNormMap unm = (UnitNormMap) map1; + int nin = winmap.getNin(); + double shiftmult = winmap.getInvert() ? -1 : 1; + double[] a = winmap.storedShifts(); + double[] b = winmap.storedScales(); + double[] newcentre = new double[nin]; + boolean ok = true; + for (int coord = 0; coord < nin; coord++) { + if (!equal(b[coord], 1.0)) { + ok = false; + } + newcentre[coord] = unm.centre[coord] + shiftmult * a[coord]; + } + return ok ? invertedUnitNormMap(nin, newcentre) : null; + } else if (type1 == 1 && type2 == 1) { + if (map1.getInvert() == map2.getInvert()) { + return null; + } + UnitNormMap unm1 = (UnitNormMap) map1; + UnitNormMap unm2 = (UnitNormMap) map2; + int ctrlen = Math.min(map1.getNin(), map2.getNin()); + boolean centresEqual = true; + for (int i = 0; i < ctrlen; i++) { + if (!equal(unm1.centre[i], unm2.centre[i])) { + centresEqual = false; + break; + } + } + if (centresEqual) { + return new UnitMap(map1.getNin()); + } + if (!map2.getInvert()) { + return null; + } + int nin = map1.getNin(); + double[] shift = new double[nin]; + for (int coord = 0; coord < nin; coord++) { + shift[coord] = unm2.centre[coord] - unm1.centre[coord]; + } + return new ShiftMap(shift); + } else { + throw Ast.err( + AstException.AST__INTER, + "astMapMerge(UnitNormMap): Unexpected Mapping types " + type1 + " and " + type2 + + " (internal AST programming error)."); + } + } + + /** A UnitNormMap with the Invert attribute set, as C's {@code astUnitNormMap( ..., "Invert=1" )} makes. */ + private static UnitNormMap invertedUnitNormMap(int nin, double[] centre) { + UnitNormMap m = new UnitNormMap(nin, centre); + m.setInvert(true); + return m; + } +} diff --git a/src/main/java/uk/ac/starlink/ast/XphMap.java b/src/main/java/uk/ac/starlink/ast/XphMap.java new file mode 100644 index 0000000..3524ef3 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/XphMap.java @@ -0,0 +1,509 @@ +package uk.ac.starlink.ast; + +/** + * A Mapping between grid coordinates within different types of HEALPix projection. The available + * types are: + * + *

    + *
  • "HPX0": an HPX projection centred on RA=0h ({@link #AST__HPX0}). + *
  • "HPX12": an HPX projection centred on RA=12h ({@link #AST__HPX12}). + *
  • "XPHN": an XPH ("butterfly") projection centred on the north pole ({@link #AST__XPHN}). + *
  • "XPHS": an XPH ("butterfly") projection centred on the south pole ({@link #AST__XPHS}). + *
+ * + *

The HPX projection is described in "Mapping on the HEALPix grid" by Calabretta and Roukema, + * A&A, 2005. The XPH projection is described in "Representing the 'butterfly' projection in + * FITS - projection code XPH" by Calabretta and Lowe, PASA, 2018. + * + *

The forward transformation of an XphMap transforms from grid coordinates within the projection + * type given when it was created into grid coordinates within an HPX12 projection; a position + * outside the part of the grid the projection uses is bad. The HEALPix order gives the size of the + * grid: each facet has {@code 2^order} pixels along each edge. + * + *

The XphMap class does not define any new attributes or methods beyond those which are + * applicable to all Mappings. As C's {@code astXphMap} is protected, the class and its constructor + * are package-private: XphMaps are made by the classes that need them, and otherwise read from a + * dump. + * + *

The grid indices of a position are whole numbers held in doubles, as in the C library's + * hardened transformation, so that a position any distance from the grid is placed in its cell + * (docs/rust-c-differences.md, "XphMap positions far from the grid"). Any input value that is bad + * or not finite makes both outputs bad. + * + *

Ported from Rust {@code mappings/xphmap.rs} and C {@code xphmap.c}. + */ +final class XphMap extends Mapping { + + /** An HPX projection centred on RA=0h (C's {@code AST__HPX0}, xphmap.h). */ + static final int AST__HPX0 = 0; + + /** An HPX projection centred on RA=12h (C's {@code AST__HPX12}). */ + static final int AST__HPX12 = 1; + + /** An XPH projection centred on the north pole (C's {@code AST__XPHN}). */ + static final int AST__XPHN = 2; + + /** An XPH projection centred on the south pole (C's {@code AST__XPHS}). */ + static final int AST__XPHS = 3; + + /** The highest projection type (C's {@code AST__MXPRJHPX}). */ + static final int AST__MXPRJHPX = 3; + + /** The highest HEALPix order (C's {@code AST__MXORDHPX}). */ + static final int AST__MXORDHPX = 27; + + /** The name a dump gives each projection type, indexed by type (C's {@code proj_name}). */ + private static final String[] PROJ_NAME = {"HPX0", "HPX12", "XPHN", "XPHS"}; + + /** The comment a dump writes with each name (C's {@code proj_comm}). */ + private static final String[] PROJ_COMM = { + "HPX projection centred on RA=0h", + "HPX projection centred on RA=12h", + "XPH projection centred on north pole", + "XPH projection centred on south pole" + }; + + /** The HEALPix order (C's {@code order}). */ + private final int order; + + /** The projection type the forward transformation maps from (C's {@code type}). */ + private final int type; + + /** + * Creates an XphMap, as C's {@code astInitXphMap} does: two inputs and two outputs, both + * transformations defined. + * + * @param order the HEALPix order of the HPX transformation, 0 to {@link #AST__MXORDHPX} + * @param type the type of projection corresponding to the inputs of the XphMap: {@link + * #AST__HPX0}, {@link #AST__HPX12}, {@link #AST__XPHN} or {@link #AST__XPHS} + * @throws AstException with status {@code AST__INTER} if {@code order} or {@code type} is out + * of range + */ + XphMap(int order, int type) { + super(2, 2, true, true); + if (order < 0 || order > AST__MXORDHPX) { + throw Ast.err( + AstException.AST__INTER, + "astInitXphMap(XphMap): Invalid order supplied (" + order + ") (internal programming error)."); + } else if (type < 0 || type > AST__MXPRJHPX) { + throw Ast.err( + AstException.AST__INTER, + "astInitXphMap(XphMap): Invalid projection type supplied (" + type + + ") (internal programming error)."); + } + this.order = order; + this.type = type; + } + + /** + * Loads an XphMap from its description, as C's {@code astLoadXphMap} does: the order is item + * {@code Order}, 19 if absent, and the projection type is item {@code Type}, matched to the + * type names ignoring case and trailing white space, HPX12 if absent. + * + *

The pinned C stores whatever order and numbers of inputs and outputs it reads; its + * transformation shifts by the order, reads two inputs and writes two outputs. The hardened C + * library refuses the others when loading, with the messages used here. + * + * @throws AstException with status {@code AST__OPT} if the type is no projection name, or + * {@code AST__LDERR} if the order is outside the range the constructor accepts or the + * XphMap as created does not have two inputs and two outputs + */ + XphMap(NativeNode node) { + super(node); + NativeNode part = node.section("XphMap"); + int ord = part.readInt("Order", 19); + String text = part.readString("Type", PROJ_NAME[AST__HPX12]); + int t = 0; + while (t <= AST__MXPRJHPX && !chrMatch(text, PROJ_NAME[t])) { + t++; + } + if (t > AST__MXPRJHPX) { + throw Ast.err( + AstException.AST__OPT, + "astRead(XphMap): Illegal value '" + text + "' supplied for the XphMap component 'Type'."); + } + if (ord < 0 || ord > AST__MXORDHPX) { + throw Ast.err( + AstException.AST__LDERR, + "astLoad(XphMap): The HEALPix order read for a XphMap (" + ord + ") is not in the range 0 to " + + AST__MXORDHPX + "."); + } + if (createdNin() != 2 || createdNout() != 2) { + throw Ast.err( + AstException.AST__LDERR, + "astLoad(XphMap): Invalid numbers of inputs (" + createdNin() + ") and outputs (" + createdNout() + + ") read for a XphMap - there should be 2 and 2."); + } + this.order = ord; + this.type = t; + } + + /** The HEALPix order. */ + int getOrder() { + return order; + } + + /** The projection type the forward transformation maps from, {@link #AST__HPX0} to {@link #AST__XPHS}. */ + int getType() { + return type; + } + + @Override + String dumpComment() { + return "HPX variant mapping"; + } + + /** Writes the order and the projection type's name, as C's {@code Dump} (xphmap.c) does. */ + @Override + void dump(NativeNode node) { + super.dump(node); + node.writeIsA("Mapping", "Mapping between coordinate systems"); + node.writeInt("Order", true, true, order, "HEALPix order"); + node.writeString("Type", true, true, PROJ_NAME[type], PROJ_COMM[type]); + } + + /** + * xphmap.c {@code GetIsLinear}: only an HPX12 XphMap is linear, though even that one makes + * positions outside the used part of the grid bad. + */ + @Override + boolean isLinear() { + return type == AST__HPX12; + } + + // ------------------------------------------------------------------ + // Transformation + // ------------------------------------------------------------------ + + /** + * C's {@code Transform} (xphmap.c). The forward transformation maps from the XphMap's + * projection type to HPX12, the inverse from HPX12 to the type. A cell of the grid holds its + * boundaries on the low RA edges, and those on the high RA edges belong to the neighbouring + * cell. + */ + @Override + void transformInto(double[][] in, int npoint, boolean forward, double[][] out) { + validateTransformInto(in, npoint, forward, out); + boolean fwd = effectiveForward(forward); + int nppf = 1 << order; + double[] xin = in[0]; + double[] yin = in[1]; + double[] xout = out[0]; + double[] yout = out[1]; + double[] xy = new double[2]; + for (int p = 0; p < npoint; p++) { + double x = xin[p]; + double y = yin[p]; + if (isBad(x) || isBad(y)) { + xy[0] = AST__BAD; + xy[1] = AST__BAD; + } else if (fwd) { + forwardPoint(x, y, nppf, xy); + } else { + inversePoint(x, y, nppf, xy); + } + xout[p] = xy[0]; + yout[p] = xy[1]; + } + } + + /** + * The cell of the HPX layout holding (x, y), as C's {@code Transform} finds it: the + * zero-based grid indices {@code ceil(x - 1.5)} and {@code ceil(y - 1.5)}, and their facet + * indices, each divided by {@code nppf} and rounded towards zero. The result is the sum of the + * grid indices plus one, or NaN when the facet indices are not those of a facet of the layout + * (both 0 to 4 and differing by at most 1). + * + *

Rounding towards zero gives facet index 0 to a cell index from {@code -(nppf - 1)} to -1, + * which is outside the grid, so a position less than one facet left of or below the grid is + * placed in a bottom-left facet, and the callers accept it wherever its sum is in the used part + * of the layout, as C does (docs/c-library-bugs.md, "An XphMap accepts positions up to a facet + * left of or below its grid"). + */ + private static double hpxCellSum(double x, double y, int nppf) { + double ix = Math.ceil(x - 1.5); + double iy = Math.ceil(y - 1.5); + double fx = trunc(ix / nppf); + double fy = trunc(iy / nppf); + if (fx >= 0 && fx < 5 && fy >= 0 && fy < 5 && Math.abs(fx - fy) <= 1) { + return ix + iy + 1; + } + return Double.NaN; + } + + /** C's {@code trunc}: {@code v} rounded towards zero. */ + private static double trunc(double v) { + return v < 0 ? Math.ceil(v) : Math.floor(v); + } + + private static void bad(double[] xy) { + xy[0] = AST__BAD; + xy[1] = AST__BAD; + } + + /** The forward transformation of one good position, from the projection type to HPX12, into {@code xy}. */ + private void forwardPoint(double x, double y, int nppf, double[] xy) { + int n2 = 2 * nppf; + int n3 = 3 * nppf; + int n4 = 4 * nppf; + int n5 = 5 * nppf; + int n6 = 6 * nppf; + int n9 = 9 * nppf; + switch (type) { + case AST__HPX12: { + // A unit transformation, except that positions outside the used part of the grid + // (the bottom left half of the bottom left facet and the top right half of the top + // right facet, and outside the facets) are bad. + double s = hpxCellSum(x, y, nppf); + if (Double.isNaN(s) || s <= nppf || s > n9) { + bad(xy); + } else { + xy[0] = x; + xy[1] = y; + } + break; + } + case AST__HPX0: { + // The bottom left and top right halves of the whole-sky map swap places. + double s = hpxCellSum(x, y, nppf); + if (Double.isNaN(s) || s <= nppf || s > n9) { + bad(xy); + } else if (s <= n5) { + xy[0] = x + n2; + xy[1] = y + n2; + } else { + xy[0] = x - n2; + xy[1] = y - n2; + } + break; + } + case AST__XPHN: + // By the gore holding the position; a gore holds its low RA boundaries but not its + // high RA ones. + if (x < n2 + 0.5 && y >= n2 + 0.5) { + // Gore 0. + double s = Math.floor(x - 0.5) + Math.floor(y - 0.5) + 1; + if (s < n5 && s >= n3) { + xy[0] = n4 + 1.0 - x; + xy[1] = n6 + 1.0 - y; + } else { + bad(xy); + } + } else if (x >= n2 + 0.5 && y > n2 + 0.5) { + // Gore 3. + double d = Math.floor(x - 0.5) - Math.ceil(y - 1.5); + if (d >= -nppf && d < nppf) { + xy[0] = y - nppf; + xy[1] = n5 + 1.0 - x; + } else { + bad(xy); + } + } else if (x > n2 + 0.5 && y <= n2 + 0.5) { + // Gore 2. + double s = Math.ceil(x - 1.5) + Math.ceil(y - 1.5) + 1; + if (s > n3 && s <= n5) { + xy[0] = x - n2; + xy[1] = y; + } else { + bad(xy); + } + } else { + // Gore 1. + double d = Math.ceil(x - 1.5) - Math.floor(y - 0.5); + if (d > -nppf && d <= nppf) { + xy[0] = n5 + 1.0 - y; + xy[1] = n3 + x; + } else { + bad(xy); + } + } + break; + case AST__XPHS: + if (x < n2 + 0.5 && y <= n2 + 0.5) { + // Gore 0. + double d = Math.floor(x - 0.5) - Math.ceil(y - 1.5); + if (d >= -nppf && d < nppf) { + xy[0] = n2 + y; + xy[1] = n4 + 1.0 - x; + } else { + bad(xy); + } + } else if (x >= n2 + 0.5 && y < n2 + 0.5) { + // Gore 3. + double s = Math.floor(x - 0.5) + Math.floor(y - 0.5) + 1; + if (s >= n3 && s < n5) { + xy[0] = n5 + 1.0 - x; + xy[1] = n3 + 1.0 - y; + } else { + bad(xy); + } + } else if (x > n2 + 0.5 && y >= n2 + 0.5) { + // Gore 2. + double d = Math.ceil(x - 1.5) - Math.floor(y - 0.5); + if (d <= nppf && d > -nppf) { + xy[0] = n4 + 1 - y; + xy[1] = x - n2; + } else { + bad(xy); + } + } else { + // Gore 1. + double s = Math.ceil(x - 1.5) + Math.ceil(y - 1.5) + 1; + if (s <= n5 && s > n3) { + xy[0] = n3 + x; + xy[1] = nppf + y; + } else { + bad(xy); + } + } + break; + default: + throw invalidType(); + } + } + + /** + * The inverse transformation of one good position, from HPX12 to the projection type, into + * {@code xy}: positions outside the used part of the HPX12 grid are bad, and the others are + * placed by the half (HPX0) or quarter (XPH) of the sky they lie in. + */ + private void inversePoint(double x, double y, int nppf, double[] xy) { + int n2 = 2 * nppf; + int n3 = 3 * nppf; + int n4 = 4 * nppf; + int n5 = 5 * nppf; + int n6 = 6 * nppf; + int n7 = 7 * nppf; + int n9 = 9 * nppf; + double s = hpxCellSum(x, y, nppf); + if (Double.isNaN(s) || s <= nppf || s > n9) { + bad(xy); + return; + } + switch (type) { + case AST__HPX12: + xy[0] = x; + xy[1] = y; + break; + case AST__HPX0: + if (s <= n5) { + xy[0] = x + n2; + xy[1] = y + n2; + } else { + xy[0] = x - n2; + xy[1] = y - n2; + } + break; + case AST__XPHN: + if (s <= n3) { + // Gore 2. + xy[0] = n2 + x; + xy[1] = y; + } else if (s <= n5) { + // Gore 3. + xy[0] = n5 + 1.0 - y; + xy[1] = nppf + x; + } else if (s <= n7) { + // Gore 0. + xy[0] = n4 + 1.0 - x; + xy[1] = n6 + 1.0 - y; + } else { + // Gore 1. + xy[0] = y - n3; + xy[1] = n5 + 1.0 - x; + } + break; + case AST__XPHS: + if (s <= n3) { + // Gore 2. + xy[0] = n2 + y; + xy[1] = n4 + 1.0 - x; + } else if (s <= n5) { + // Gore 3. + xy[0] = n5 + 1.0 - x; + xy[1] = n3 + 1.0 - y; + } else if (s <= n7) { + // Gore 0. + xy[0] = n4 + 1.0 - y; + xy[1] = x - n2; + } else { + // Gore 1. + xy[0] = x - n3; + xy[1] = y - nppf; + } + break; + default: + throw invalidType(); + } + } + + private AstException invalidType() { + return Ast.err( + AstException.AST__INTER, + "astTransform(XphMap): Invalid projection type encountered (" + type + + ") (internal programming error)."); + } + + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + /** xphmap.c {@code Equal}: {@code that} is an XphMap with the same Invert attribute, projection type and order. */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof XphMap)) { + return false; + } + XphMap other = (XphMap) that; + return getInvert() == other.getInvert() && type == other.type && order == other.order; + } + + // ------------------------------------------------------------------ + // Simplification + // ------------------------------------------------------------------ + + /** + * xphmap.c {@code MapMerge}: in series, this XphMap and an adjacent XphMap (the one before it + * if that is an XphMap, otherwise the one after), each applied with the Invert value the list + * gives it, become a UnitMap if they are equal and opposite: if inverting the first makes it + * equal to the second. Nothing else merges; an HPX12 XphMap is not a UnitMap, since it makes + * positions outside the used part of the grid bad. Each Invert attribute is put back as it + * was, set or unset. + */ + @Override + int mapMerge(MergeList list, int where, boolean series) { + if (!series) { + return -1; + } + int imap1 = -1; + // C compares the class names, as here. + if (where > 0 && "XphMap".equals(list.map(where - 1).astClass())) { + imap1 = where - 1; + } else if (where < list.size() - 1 + && "XphMap".equals(list.map(where + 1).astClass())) { + imap1 = where; + } + if (imap1 == -1) { + return -1; + } + int imap2 = imap1 + 1; + Mapping map1 = list.map(imap1); + Mapping map2 = list.map(imap2); + int saved1 = map1.swapInvert(list.invert(imap1)); + int saved2 = map2.swapInvert(list.invert(imap2)); + boolean cancel; + try { + map1.invert(); + cancel = map1.astEqual(map2); + map1.invert(); + } finally { + map2.restoreInvert(saved2); + map1.restoreInvert(saved1); + } + if (!cancel) { + return -1; + } + list.replacePairWith(imap1, new UnitMap(2), false); + return imap1; + } +} diff --git a/src/test/java/uk/ac/starlink/ast/AttrTestClearOracleTest.java b/src/test/java/uk/ac/starlink/ast/AttrTestClearOracleTest.java index 042529e..f197076 100644 --- a/src/test/java/uk/ac/starlink/ast/AttrTestClearOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/AttrTestClearOracleTest.java @@ -6,7 +6,6 @@ import com.fasterxml.jackson.databind.JsonNode; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; import uk.ac.starlink.ast.testsupport.ProbeData; @@ -18,14 +17,10 @@ * attribute is written whenever it is set, its default included; a cleared one is written * commented, as its default, only when the class marks it "helpful" (such as Zoom and PlrLg). * - *

{@link #build} makes each object as the probe does. The cases of SplineMap are skipped (class - * not yet ported). + *

{@link #build} makes each object as the probe does. */ class AttrTestClearOracleTest { - /** The cases whose classes are out of scope. */ - private static final List OUT_OF_SCOPE = Arrays.asList("splinemap_default", "splinemap_cleared"); - private static PermMap perm() { return new PermMap(2, new int[] {2, 1}, 2, new int[] {2, 1}, null); } @@ -44,6 +39,19 @@ private static LutMap lut() { return m; } + /** + * An order-1 SplineMap with OutUnit, InvNiter and InvTol set to their defaults, as the probe + * makes it. + */ + private static SplineMap spline() { + SplineMap m = new SplineMap( + 1, 1, 1, 1, new double[] {0.0, 1.0}, new double[] {0.0, 1.0}, new double[] {1.5}, new double[] {2.5}); + m.setOutUnit(false); + m.setInvNiter(6); + m.setInvTol(1.0e-6); + return m; + } + private static SphMap sph() { SphMap m = new SphMap(); m.set("UnitRadius=0,PolarLong=1.0"); @@ -106,6 +114,15 @@ private static Mapping build(String name) { m.clear("PV2_1"); return m; } + case "splinemap_default": + return spline(); + case "splinemap_cleared": { + SplineMap m = spline(); + m.clear("OutUnit"); + m.clear("InvNiter"); + m.clear("InvTol"); + return m; + } case "sphmap_default": return sph(); case "sphmap_cleared": { @@ -176,9 +193,6 @@ void testAndDumpMatchTheCLibrary() { int run = 0; for (JsonNode c : ProbeData.load("attr_test_clear").get("CASES")) { String name = c.get(0).asText(); - if (OUT_OF_SCOPE.contains(name)) { - continue; - } run++; Mapping obj = build(name); for (JsonNode t : c.get(1)) { @@ -193,7 +207,7 @@ void testAndDumpMatchTheCLibrary() { failures.add(name + ": dump\n" + written + "C:\n" + c.get(2).asText()); } } - assertEquals(18, run, "the in-scope cases the C probe recorded"); + assertEquals(20, run, "the cases the C probe recorded"); assertTrue(failures.isEmpty(), String.join("\n", failures)); } @@ -202,9 +216,6 @@ void testAndDumpMatchTheCLibrary() { void cDumpsReadBackAsInC() { for (JsonNode c : ProbeData.load("attr_test_clear").get("CASES")) { String name = c.get(0).asText(); - if (OUT_OF_SCOPE.contains(name)) { - continue; - } AstObject obj = ChannelText.read(c.get(2).asText()); assertEquals(c.get(3).asText(), ChannelText.dump(obj), name); } diff --git a/src/test/java/uk/ac/starlink/ast/BulkKernelsTest.java b/src/test/java/uk/ac/starlink/ast/BulkKernelsTest.java index 8990e90..f01d04f 100644 --- a/src/test/java/uk/ac/starlink/ast/BulkKernelsTest.java +++ b/src/test/java/uk/ac/starlink/ast/BulkKernelsTest.java @@ -14,8 +14,7 @@ * non-finite input as bad, and write only the points they are given into outputs longer than the * input. * - *

The UnitNormMap tests need a class that is out of scope and are deferred. - * Rust's NaN-path entry point is {@link Mapping#transformIntoNan}. + *

Rust's NaN-path entry point is {@link Mapping#transformIntoNan}. */ class BulkKernelsTest { @@ -254,4 +253,200 @@ void aSeriesCmpmapOfNoPointsChecksEachComponentOnTheNanPath() { AstException.class, () -> m.transformIntoNan(new double[][] {{}, {}}, 0, false, new double[][] {{}})); assertTrue(m.getTranForward()); } + + // ------------------------------------------------------------------ + // UnitNormMap + // ------------------------------------------------------------------ + + private static final double[] CENTRE = {1.0, -2.0}; + + private static boolean badInput(double v) { + return !Double.isFinite(v) || v == BAD; + } + + /** One point of UnitNormMap's forward transformation about {@code centre} (unitnormmap.c). */ + private static double[] unitNormAbout(double[] centre, double[] p) { + int n = centre.length; + double[] out = new double[n + 1]; + Arrays.fill(out, BAD); + for (double v : p) { + if (badInput(v)) { + return out; + } + } + double[] rel = new double[n]; + double max = 0.0; + for (int k = 0; k < n; k++) { + rel[k] = p[k] - centre[k]; + if (Math.abs(rel[k]) > max) { + max = Math.abs(rel[k]); + } + } + if (max == 0.0) { + out[n] = 0.0; + return out; + } + double sum = 0.0; + for (double r : rel) { + sum += (r / max) * (r / max); + } + double norm = max * Math.sqrt(sum); + for (int k = 0; k < n; k++) { + out[k] = rel[k] / norm; + } + out[n] = norm; + return out; + } + + @Test + void unitnormmapKernelKeepsEachPointsStateAcrossBlocks() { + UnitNormMap m = new UnitNormMap(2, CENTRE); + // Cycle through a good point, a bad first coordinate followed by a larger good one, a bad + // second coordinate, the centre itself and an infinity, over enough points to cross a + // block boundary. + int n = 1030; + double[][] inp = new double[2][n]; + for (int i = 0; i < n; i++) { + double t = i; + double[] p; + switch (i % 5) { + case 0: + p = new double[] {t, -t * 0.5}; + break; + case 1: + p = new double[] {BAD, 1.0e6 + t}; + break; + case 2: + p = new double[] {3.0 * t, Double.NaN}; + break; + case 3: + p = CENTRE.clone(); + break; + default: + p = new double[] {Double.POSITIVE_INFINITY, t}; + break; + } + inp[0][i] = p[0]; + inp[1][i] = p[1]; + } + assertPoints(m, true, inp, 3, p -> unitNormAbout(CENTRE, p)); + } + + @Test + void unitnormmapInverseKernelKeepsEachPointsState() { + UnitNormMap m = new UnitNormMap(2, CENTRE); + // A good point, a bad norm, a zero norm, a bad component, and a bad component with a zero + // norm, which gives the centre. + int n = 1030; + double[][] inp = new double[3][n]; + for (int i = 0; i < n; i++) { + double t = i; + double[] p; + switch (i % 5) { + case 0: + p = new double[] {0.6, 0.8, t}; + break; + case 1: + p = new double[] {0.6, 0.8, BAD}; + break; + case 2: + p = new double[] {0.6, 0.8, 0.0}; + break; + case 3: + p = new double[] {Double.NaN, 0.8, t}; + break; + default: + p = new double[] {BAD, 0.8, 0.0}; + break; + } + for (int k = 0; k < 3; k++) { + inp[k][i] = p[k]; + } + } + assertPoints(m, false, inp, 2, p -> { + double norm = p[2]; + if (norm == BAD) { + return new double[] {BAD, BAD}; + } else if (norm == 0.0) { + return CENTRE.clone(); + } + double[] out = new double[2]; + for (int k = 0; k < 2; k++) { + out[k] = Double.isFinite(p[k]) ? p[k] * norm + CENTRE[k] : BAD; + } + return out; + }); + } + + @Test + void unitnormmapForwardKernelMatchesCForEachAxisCount() { + // 1030 points cross a block boundary; every seventh point is the centre, giving a zero norm. + double[] odd = {BAD, Double.NaN, Double.POSITIVE_INFINITY, -0.0}; + for (int ncoord = 1; ncoord <= 5; ncoord++) { + double[] centre = new double[ncoord]; + for (int j = 0; j < ncoord; j++) { + centre[j] = j * 1.5 - 2.0; + } + UnitNormMap m = new UnitNormMap(ncoord, centre); + double[][] inp = new double[ncoord][1030]; + for (int j = 0; j < ncoord; j++) { + for (int i = 0; i < 1030; i++) { + if (i % 7 == 3) { + inp[j][i] = centre[j]; + } else if (i % (5 + j) == 2) { + inp[j][i] = odd[(i + j) % odd.length]; + } else { + inp[j][i] = i * 0.37 - 20.0 + j; + } + } + } + assertPoints(m, true, inp, ncoord + 1, p -> unitNormAbout(centre, p)); + } + } + + /** + * Transforms two points with {@code map} into one more output coordinate than it gives, each + * holding one point more than given, directly and through the NaN protocol, and checks that + * the surplus is untouched; gives the number of the two calls that ran. + */ + private static int surplusKept(Mapping map, boolean forward) { + int nin = forward ? map.getNin() : map.getNout(); + int nout = forward ? map.getNout() : map.getNin(); + double[][] inp = new double[nin][]; + for (int j = 0; j < nin; j++) { + inp[j] = new double[] {0.5 + j, 2.0}; + } + int ok = 0; + for (boolean nan : new boolean[] {false, true}) { + double[][] out = new double[nout + 1][3]; + for (double[] axis : out) { + Arrays.fill(axis, 7.0); + } + try { + if (nan) { + map.transformIntoNan(inp, 2, forward, out); + } else { + map.transformInto(inp, 2, forward, out); + } + } catch (AstException e) { + continue; + } + ok++; + for (int k = 0; k < nout; k++) { + assertEquals(7.0, out[k][2], "nan=" + nan + ": surplus point written"); + } + for (double v : out[nout]) { + assertEquals(7.0, v, "nan=" + nan + ": surplus axis written"); + } + } + return ok; + } + + @Test + void transformsThatFillEveryOutputLeaveSurplusAxesAlone() { + // A bad centre makes every UnitNormMap output bad. + assertEquals(2, surplusKept(new UnitNormMap(2, new double[] {BAD, 0.0}), true)); + // A NullRegion's transformation is all bad. + assertEquals(2, surplusKept(new NullRegion(new Frame(2), null), true)); + } } diff --git a/src/test/java/uk/ac/starlink/ast/ChebyMapProbeTest.java b/src/test/java/uk/ac/starlink/ast/ChebyMapProbeTest.java new file mode 100644 index 0000000..2623931 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/ChebyMapProbeTest.java @@ -0,0 +1,891 @@ +package uk.ac.starlink.ast; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.ProbeOutput; + +/** + * ChebyMap behaviour against C, from {@code probes/chebymap_probe.c}: whether a ChebyMap is a + * PolyMap and its dump; its values inside, on the edge of and outside its bounding box and for bad + * and NaN inputs, in both directions; a ChebyMap with no inverse coefficients, with IterInverse + * unset, set and cleared; {@code chebyDomain} of each direction, of an inverted ChebyMap, of one + * with no inverse coefficients (found by MapBox), of one with neither and of one whose box has no + * width C can represent; its simplification next to a PolyMap, a WinMap and its own inverse, in + * series and in parallel; its comparisons; the constructor's and loader's errors; {@code polyTran} + * with the ChebyMap's own box; and testchebymap.c's checks, every value printed. + * + *

Each case writes the lines the probe writes and compares them with C's exactly. C's output + * comes from two builds of the library: {@code chebymap_probe.json} from one with the compiler's + * default flags, which contracts a multiply and an add into a fused multiply-add, and {@code + * chebymap_probe_nocontract.json} from one built with {@code -ffp-contract=off}. Java never fuses + * them, so a line whose value the contraction changes is listed in {@code deferred/oracle-rows.txt} + * and compared with the second build's: a transformed point as {@code probes/chebymap_probe/ + * }, counting the case's {@code fwd} or {@code inv} lines from 0, and any + * other line as {@code probes/chebymap_probe/ other }, counting the case's other lines + * from 0. {@link #contractionRowsAreThoseListed} checks that the two builds differ in exactly those + * lines. + */ +class ChebyMapProbeTest { + + private static final double BAD = AstObject.AST__BAD; + + private static final String PROBE = "chebymap_probe"; + + /** The prefix of this probe's entries in {@code deferred/oracle-rows.txt}. */ + static final String ROWS_PREFIX = "probes/" + PROBE + "/"; + + private static final Map FUSED = ProbeOutput.load(PROBE); + + private static final Map UNFUSED = ProbeOutput.load(PROBE + "_nocontract"); + + // ------------------------------------------------------------------ + // Comparison with the probe + // ------------------------------------------------------------------ + + private static String probeCase(Map cases, String name) { + String text = cases.get(name); + if (text == null) { + throw new IllegalStateException("no probe case " + name); + } + return withoutSource(text); + } + + /** + * The case without the lines naming the C source of an error, which Java cannot give: the + * first line of a report ({@code !! }), and the line naming the routine when C writes it below + * the first message. + */ + private static String withoutSource(String text) { + StringBuilder sb = new StringBuilder(); + for (String line : text.split("\n", -1)) { + if (!line.startsWith("!! ") && !line.startsWith("! AST: Error in routine ") && !line.isEmpty()) { + sb.append(line).append('\n'); + } + } + return sb.toString(); + } + + /** The rows of {@code name} of {@code kind} (forward, inverse or other) that are listed. */ + private static Set listedRows(String name, String kind) { + TransformOracleTest.ExcusedRows rows = + TransformOracleTest.committedOracleRows().get(ROWS_PREFIX + name + " " + kind); + return rows == null ? Collections.emptySet() : rows.rows; + } + + /** + * The row each line of {@code text} is: {@code forward } for its n-th {@code fwd} line, + * {@code inverse } for its n-th {@code inv} line, and {@code other } for its n-th other + * line. + */ + private static List rowKinds(String text) { + List out = new ArrayList<>(); + int nfwd = 0; + int ninv = 0; + int nother = 0; + for (String line : text.split("\n", -1)) { + if (line.startsWith("fwd ")) { + out.add("forward " + nfwd++); + } else if (line.startsWith("inv ")) { + out.add("inverse " + ninv++); + } else { + out.add("other " + nother++); + } + } + return out; + } + + /** + * What C gives for case {@code name}: the default build's lines, with the unfused build's in + * the rows {@code oracle-rows.txt} lists. + */ + private static String expected(String name) { + String[] fused = probeCase(FUSED, name).split("\n", -1); + String[] unfused = probeCase(UNFUSED, name).split("\n", -1); + assertEquals(fused.length, unfused.length, name); + List kinds = rowKinds(probeCase(FUSED, name)); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < fused.length; i++) { + String kind = kinds.get(i); + int space = kind.indexOf(' '); + boolean listed = + listedRows(name, kind.substring(0, space)).contains(Integer.parseInt(kind.substring(space + 1))); + sb.append(listed ? unfused[i] : fused[i]); + if (i < fused.length - 1) { + sb.append('\n'); + } + } + return sb.toString(); + } + + private static void assertCase(String name, String got) { + assertEquals(expected(name), got, name); + } + + private static String g(double v) { + return CFormat.format("%.17g", v); + } + + private static int flag(boolean b) { + return b ? 1 : 0; + } + + /** The dump of {@code obj}, as the probe's {@code astShow} writes it. */ + private static String show(AstObject obj) { + StringBuilder sb = new StringBuilder(); + for (String l : ChannelText.dump(obj).split("\n", -1)) { + if (!l.isEmpty()) { + sb.append(ProbeOutput.trimLines(l)).append('\n'); + } + } + return sb.toString(); + } + + /** The probe's lines for an error: its message and status. */ + private static String error(AstException e) { + StringBuilder sb = new StringBuilder(); + for (String line : ProbeOutput.trimLines(e.getMsgText()).split("\n", -1)) { + sb.append("! ").append(line).append('\n'); + } + return sb.append("status ").append(e.getStatus()).append('\n').toString(); + } + + /** + * The probe's {@code tran}: the transformation of {@code npt} points given coordinate by + * coordinate in {@code in}, one line each, or the error. + */ + private static String tran(Mapping m, int npt, double[] in, boolean forward) { + int nin = in.length / npt; + int nout = forward ? m.getNout() : m.getNin(); + double[] out; + try { + out = m.tranN(npt, nin, in, forward, nout); + } catch (AstException e) { + return error(e); + } + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < npt; i++) { + sb.append(forward ? "fwd" : "inv"); + for (int j = 0; j < nin; j++) { + sb.append(' ').append(g(in[j * npt + i])); + } + sb.append(" ->"); + for (int j = 0; j < nout; j++) { + sb.append(' ').append(g(out[j * npt + i])); + } + sb.append('\n'); + } + return sb.toString(); + } + + /** The class of the simplified Mapping, whether it is the Mapping itself, and its dump. */ + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) // astSame compares the Objects. + private static String simp(Mapping m) { + Mapping s = m.simplify(); + return "-- simplified " + s.astClass() + " same " + flag(s == m) + "\n" + show(s); + } + + /** The probe's {@code domain}: chebyDomain in one direction, or the error. */ + private static String domain(ChebyMap cm, boolean forward) { + double[][] box; + try { + box = cm.chebyDomain(forward); + } catch (AstException e) { + return error(e); + } + StringBuilder sb = new StringBuilder("domain ").append(flag(forward)); + for (double v : box[0]) { + sb.append(' ').append(g(v)); + } + sb.append(" :"); + for (double v : box[1]) { + sb.append(' ').append(g(v)); + } + return sb.append('\n').toString(); + } + + /** The probe's {@code coeffs}: polyCoeffs in one direction, one line per coefficient. */ + private static String coeffs(PolyMap pm, boolean forward) { + int naxes = forward ? pm.getNin() : pm.getNout(); + double[] cofs = pm.polyCoeffs(forward); + int nco = cofs.length / (2 + naxes); + StringBuilder sb = new StringBuilder("coeffs ") + .append(flag(forward)) + .append(" n ") + .append(nco) + .append('\n'); + for (int i = 0; i < nco; i++) { + sb.append("cof"); + for (int j = 0; j < 2 + naxes; j++) { + sb.append(' ').append(g(cofs[i * (2 + naxes) + j])); + } + sb.append('\n'); + } + return sb.toString(); + } + + /** The probe's {@code iter}: the iterative inverse attributes and each direction's definedness. */ + private static String iter(Mapping m) { + return "IterInverse " + m.getI("IterInverse") + " set " + flag(m.test("IterInverse")) + " TranForward " + + flag(m.getTranForward()) + " TranInverse " + flag(m.getTranInverse()) + "\n"; + } + + private static String equal(String label, AstObject a, AstObject b) { + return "equal " + label + " " + flag(a.astEqual(b)) + "\n"; + } + + private static String rate(Mapping m, double at) { + return "rate " + g(at) + " -> " + g(m.rate(new double[] {at}, 1, 1)) + "\n"; + } + + private static double[] d(double... v) { + return v; + } + + private static T inverted(T m) { + m.invert(); + return m; + } + + private static ChebyMap cheby( + int nin, int nout, double[] fc, double[] ic, double[] lb, double[] ub, double[] ilb, double[] iub) { + int ncf = fc == null ? 0 : fc.length / (2 + nin); + int nci = ic == null ? 0 : ic.length / (2 + nout); + return new ChebyMap(nin, nout, ncf, fc, nci, ic, lb, ub, ilb, iub); + } + + /** The text of a case, built a piece at a time. */ + private static final class Lines { + private final List parts = new ArrayList<>(); + + Lines add(String text) { + parts.add(text); + return this; + } + + @Override + public String toString() { + return String.join("", parts); + } + } + + // ------------------------------------------------------------------ + // The two builds of C + // ------------------------------------------------------------------ + + /** + * The lines in which the default and unfused builds of C differ are exactly those {@code + * oracle-rows.txt} lists for this probe, so that each listed line is shown to depend on the + * contraction and no other does. + */ + @Test + void contractionRowsAreThoseListed() { + assertEquals(FUSED.keySet(), UNFUSED.keySet()); + Set differing = new TreeSet<>(); + for (String name : FUSED.keySet()) { + String[] fused = probeCase(FUSED, name).split("\n", -1); + String[] unfused = probeCase(UNFUSED, name).split("\n", -1); + assertEquals(fused.length, unfused.length, name); + List kinds = rowKinds(probeCase(FUSED, name)); + for (int i = 0; i < fused.length; i++) { + if (!fused[i].equals(unfused[i])) { + differing.add(name + " " + kinds.get(i)); + } + } + } + Set listed = new TreeSet<>(); + for (TransformOracleTest.ExcusedRows x : + TransformOracleTest.committedOracleRows().values()) { + if (x.relpath.startsWith(ROWS_PREFIX)) { + for (int row : x.rows) { + listed.add(x.relpath.substring(ROWS_PREFIX.length()) + " " + x.kind + " " + row); + } + } + } + assertEquals(differing, listed); + assertFalse(listed.isEmpty()); + } + + // ------------------------------------------------------------------ + // testchebymap.c + // ------------------------------------------------------------------ + + private static final double[] COEFFS_1 = {1.5, 1, 0, -1.0, 1, 2, 2.0, 1, 3, 1.3, 1, 4}; + private static final double[] COEFFS_2 = {1.0, 1, 0, -2.0, 1, 1}; + private static final double[] COEFFS_3 = {1.0, 1, 0, 0, -2.0, 1, 1, 2, 1.0, 1, 0, 1, 1.5, 2, 0, 0, -2.5, 2, 1, 2}; + private static final double[] COEFFS_4 = {1.0, 1, 1, 0, 1.0, 1, 0, 1, 1.0, 2, 1, 0, -1.0, 2, 0, 1}; + + private static final double[] XIN = {-1.0, -0.5, 0.0, 0.5, 1.0}; + + @Test + void evaluatesTestchebymapCoefficients() { + double[] lbnd = {-1.0, -1.0}; + double[] ubnd = {1.0, 1.0}; + for (int n = 1; n <= 4; n++) { + ChebyMap cm = new ChebyMap(1, 1, n, COEFFS_1, 0, null, lbnd, ubnd, lbnd, ubnd); + String got = tran(cm, 5, XIN, true); + assertCase("t_eval_" + n, n == 4 ? got + iter(cm) : got); + } + } + + @Test + void fitsA1dInverse() { + double[] lbnd = {-1.0}; + double[] ubnd = {1.0}; + ChebyMap cm = new ChebyMap(1, 1, 2, COEFFS_2, 0, null, lbnd, ubnd, lbnd, ubnd); + ChebyMap cm2 = (ChebyMap) cm.polyTran(false, 0.01, 0.01, 5, lbnd, ubnd); + Lines sb = new Lines().add("-- class " + cm2.astClass() + "\n"); + sb.add(tran(cm2, 5, XIN, true)); + sb.add(tran(cm2, 5, cm2.tran1(5, XIN, true), false)); + sb.add(domain(cm2, false)).add(domain(cm2, true)); + sb.add(coeffs(cm2, false)).add(iter(cm2)).add(show(cm2)); + assertCase("t_polytran_1d", sb.toString()); + } + + @Test + void fitsA1dInverseOverPartOfAWideBox() { + ChebyMap cm = new ChebyMap(1, 1, 4, COEFFS_1, 0, null, d(-100.0), d(100.0), d(-100.0), d(100.0)); + ChebyMap cm2 = (ChebyMap) cm.polyTran(false, 0.01, 0.01, 10, d(-5.0), d(50.0)); + double[] x = {0.0, 10.0, 20.0, 30.0, 40.0}; + Lines sb = new Lines(); + sb.add(tran(cm2, 5, x, true)); + sb.add(tran(cm2, 5, cm2.tran1(5, x, true), false)); + sb.add(domain(cm2, false)).add(coeffs(cm2, false)); + sb.add(equal("copy", cm2, cm2.copy())); + sb.add(equal("read", ChannelText.read(ChannelText.dump(cm2)), cm2)); + sb.add(show(cm2)); + assertCase("t_polytran_wide", sb.toString()); + } + + @Test + void fitsA2dInverseOverTheUnitBox() { + double[] lbnd = {-1.0, -1.0}; + double[] ubnd = {1.0, 1.0}; + ChebyMap cm = new ChebyMap(2, 2, 4, COEFFS_4, 0, null, lbnd, ubnd, lbnd, ubnd); + Lines sb = new Lines().add(simp(new CmpMap(cm, inverted((ChebyMap) cm.copy()), true))); + double[] in = {0.5, 0.0, -0.5, 0.0, 0.0, 0.5, 0.0, -0.5}; + sb.add(tran(cm, 4, in, true)); + double[] out = cm.tranN(4, 2, in, true, 2); + ChebyMap cm2 = (ChebyMap) cm.polyTran(false, 0.01, 0.01, 10, lbnd, ubnd); + sb.add(tran(cm2, 4, out, false)).add(coeffs(cm2, false)).add(domain(cm2, false)); + assertCase("t_2d_unit", sb.toString()); + } + + @Test + void fitsA2dInverseOverPartOfTheBox() { + double[] lbnd = {0.0, 0.0}; + double[] ubnd = {10.0, 10.0}; + ChebyMap cm = new ChebyMap(2, 2, 5, COEFFS_3, 0, null, lbnd, ubnd, lbnd, ubnd); + double[] in = {0.0, 2.0, 6.0, 10.0, 2.0, 5.0, 8.0, 0.0}; + double[] fit = {4.0, 4.5, 5.0, 5.5, 6.0, 5.5, 5.0, 4.5}; + Lines sb = new Lines().add(tran(cm, 4, in, true)); + ChebyMap cm2 = (ChebyMap) cm.polyTran(false, 0.01, 0.01, 10, d(4.0, 4.0), d(6.0, 6.0)); + sb.add(tran(cm2, 4, fit, true)); + sb.add(tran(cm2, 4, cm2.tranN(4, 2, fit, true, 2), false)); + sb.add(coeffs(cm2, true)).add(coeffs(cm2, false)); + sb.add(domain(cm, true)).add(domain(cm, false)).add(domain(cm2, true)).add(domain(cm2, false)); + assertCase("t_2d_nonunit", sb.toString()); + } + + @Test + void invertingSwapsTheDomains() { + double[] fc = {1.0, 1, 1, 0, 1.0, 2, 0, 1, 0.25, 2, 1, 1}; + ChebyMap fcm = new ChebyMap(2, 2, 3, fc, 0, null, d(0.0, -1.0), d(1.0, 2.0), null, null); + String before = domain(fcm, true) + domain(fcm, false); + fcm.invert(); + assertCase("t_inverted_domain", before + domain(fcm, true) + domain(fcm, false)); + } + + @Test + void ratesInsideTheBox() { + ChebyMap rcm = new ChebyMap(1, 1, 1, d(3.0, 1, 1), 0, null, d(-1.0), d(1.0), d(-1.0), d(1.0)); + assertCase("t_rate", rate(rcm, 0.5) + rate(rcm, 0.0) + rate(rcm, 1.0)); + } + + @Test + void reducesALinear1dChebyMap() { + ChebyMap lcm = new ChebyMap(1, 1, 1, d(2.0, 1, 1), 0, null, d(0.0), d(10.0), null, null); + Mapping lsm = lcm.simplify(); + double[] lx = {0.0, 1.0, 10.0}; + String got = simp(lcm) + + tran(lcm, 3, lx, true) + + tran(lsm, 3, lx, true) + + tran(lsm, 3, lcm.tran1(3, lx, true), false); + assertCase("t_linear_1d", got); + } + + @Test + void reducesALinear2dChebyMap() { + double[] c = {3.0, 1, 1, 0, 0.5, 1, 0, 0, -1.0, 2, 0, 1, 2.0, 2, 0, 0}; + ChebyMap lcm2 = new ChebyMap(2, 2, 4, c, 0, null, d(0.0, -5.0), d(10.0, 5.0), null, null); + Mapping lsm2 = lcm2.simplify(); + double[] l2 = {0.0, 10.0, 3.0, 7.5, -5.0, 5.0, 1.0, -2.0}; + String got = simp(lcm2) + + tran(lcm2, 4, l2, true) + + tran(lsm2, 4, l2, true) + + tran(lsm2, 4, lcm2.tranN(4, 2, l2, true, 2), false); + assertCase("t_linear_2d", got); + } + + // ------------------------------------------------------------------ + // Review Focus 3 and the rest + // ------------------------------------------------------------------ + + /** Forward over [0,10]x[-2,2], inverse over [-1,3]x[0,8]. */ + private static ChebyMap bothWays() { + double[] fc = {1.0, 1, 1, 0, 0.5, 1, 2, 1, -0.25, 2, 0, 3, 2.0, 2, 0, 0}; + double[] ic = {3.0, 1, 1, 0, 1.5, 1, 0, 0, 0.75, 2, 2, 1}; + return cheby(2, 2, fc, ic, d(0.0, -2.0), d(10.0, 2.0), d(-1.0, 0.0), d(3.0, 8.0)); + } + + private static final double[] QUADRATIC_COEFFS = {1.0, 1, 0, 1.0, 1, 1, 0.5, 1, 2}; + + /** 1 + T1 + 0.5 T2 over [0, 10], no inverse coefficients. */ + private static ChebyMap quadratic() { + return cheby(1, 1, QUADRATIC_COEFFS, null, d(0.0), d(10.0), null, null); + } + + @Test + void isAPolyMap() { + // Declared as Objects, so that each test is of the class. + AstObject cm = quadratic(); + AstObject pm = new PolyMap(1, 1, 1, d(1.0, 1, 1), 0, null); + String got = "IsAPolyMap " + flag(cm instanceof PolyMap) + " IsAChebyMap " + flag(cm instanceof ChebyMap) + + " IsAMapping " + flag(cm instanceof Mapping) + " Class " + cm.getC("Class") + "\n" + + "PolyMap IsAChebyMap " + flag(pm instanceof ChebyMap) + "\n" + show(cm); + assertCase("isa", got); + } + + @Test + void givesBadOutsideTheBox() { + ChebyMap cm = bothWays(); + double nan = Double.NaN; + double[] in = { + 5.0, + 0.0, + 10.0, + Math.nextDown(0.0), + Math.nextUp(10.0), + -1.0, + 11.0, + 5.0, + 5.0, + BAD, + nan, + 1.0e300, + 0.5, + -2.0, + 2.0, + 0.0, + 0.0, + 0.0, + 0.0, + 2.5, + BAD, + 1.0, + 1.0, + 0.0 + }; + double[] inv = { + 1.0, + -1.0, + 3.0, + -1.5, + 3.5, + 1.0, + 1.0, + BAD, + nan, + Math.nextUp(3.0), + 4.0, + 0.0, + 8.0, + 4.0, + 4.0, + -0.5, + BAD, + 4.0, + 4.0, + 4.0 + }; + String before = tran(cm, 12, in, true) + tran(cm, 10, inv, false); + cm.invert(); + assertCase("outside_box", before + tran(cm, 10, inv, true) + tran(cm, 12, in, false)); + } + + @Test + void neverUsesAnIterativeInverse() { + ChebyMap cm = quadratic(); + double[] y = {1.0, 2.0}; + Lines sb = new Lines().add(iter(cm)).add(tran(cm, 2, y, false)); + cm.setI("IterInverse", 1); + sb.add(iter(cm)).add("-- attribute ").add(cm.getC("IterInverse")).add("\n"); + sb.add(tran(cm, 2, y, false)).add(show(cm)); + cm.setI("IterInverse", 0); + sb.add(iter(cm)).add(show(cm)); + cm.clear("IterInverse"); + sb.add(iter(cm)); + cm.setI("NiterInverse", 7); + cm.setD("TolInverse", 1.0e-9); + sb.add(show(cm)); + assertCase("no_inverse", sb.toString()); + + PolyMap pm = new PolyMap(1, 1, 3, QUADRATIC_COEFFS, 0, null); + assertCase("no_inverse_polymap", iter(pm) + tran(pm, 2, y, false)); + } + + @Test + void refusesAnIterativeInverseWithUnequalAxes() { + ChebyMap c21 = cheby(2, 1, d(1.0, 1, 1, 0, 1.0, 1, 0, 1), null, d(0.0, 0.0), d(1.0, 1.0), null, null); + Lines sb = new Lines().add(iter(c21)); + try { + c21.setI("IterInverse", 1); + } catch (AstException e) { + sb.add(error(e)); + } + sb.add(iter(c21)); + assertCase("iterinverse_unequal", sb.toString()); + } + + @Test + void givesTheDomains() { + ChebyMap cm = bothWays(); + String before = domain(cm, true) + domain(cm, false); + cm.invert(); + assertCase("domain_both", before + domain(cm, true) + domain(cm, false)); + + cm = quadratic(); + before = domain(cm, true) + domain(cm, false); + cm.invert(); + assertCase("domain_no_inverse", before + domain(cm, true) + domain(cm, false)); + + cm = cheby(1, 1, null, d(2.0, 1, 1, 1.0, 1, 0), null, null, d(-4.0), d(4.0)); + assertCase("domain_no_forward", iter(cm) + domain(cm, true) + domain(cm, false) + show(cm)); + + cm = cheby(2, 2, null, null, d(0.0, 0.0), d(1.0, 1.0), d(0.0, 0.0), d(1.0, 1.0)); + assertCase("domain_neither", iter(cm) + domain(cm, true) + domain(cm, false) + show(cm)); + + cm = cheby(1, 1, d(BAD, 1, 1), null, d(0.0), d(1.0), null, null); + assertCase("domain_bad_coefficient", tran(cm, 2, d(0.0, 0.5), true) + domain(cm, true) + domain(cm, false)); + + cm = cheby(1, 1, d(1.0, 1, 0, 2.0, 1, 1), null, d(-1.0e308), d(1.0e308), null, null); + assertCase("domain_infinite_width", tran(cm, 3, d(-1.0e308, 0.0, 5.0), true) + domain(cm, true) + show(cm)); + } + + /** + * The domains of ChebyMaps with different numbers of inputs and outputs, with and without + * inverse coefficients, are C's when not inverted. Inverted, C takes the number of axes from the + * inverted ChebyMap and reads beyond the box (docs/c-library-bugs.md, "astChebyDomain of an + * inverted ChebyMap with different numbers of inputs and outputs"), so there each direction is + * checked to give the other direction's domain of the ChebyMap not inverted, as C's + * {@code ChebyDomain} means. + */ + @Test + void givesTheDomainsWithUnequalAxes() { + double[] fc = {1.0, 1, 1, 2.0, 2, 1}; + ChebyMap[] maps = { + cheby(1, 2, fc, d(1.0, 1, 1, 0), d(0.0), d(10.0), d(-1.0, -2.0), d(1.0, 2.0)), + cheby(1, 2, fc, null, d(0.0), d(10.0), null, null), + cheby(2, 1, d(1.0, 1, 1, 0, 1.0, 1, 0, 1), null, d(0.0, 0.0), d(1.0, 1.0), null, null) + }; + Lines sb = new Lines(); + for (ChebyMap m : maps) { + sb.add(domain(m, true)).add(domain(m, false)); + } + assertCase("domain_unequal", sb.toString()); + for (ChebyMap m : maps) { + double[][] fwd = m.chebyDomain(true); + double[][] inv = m.chebyDomain(false); + assertEquals(m.getNin(), fwd[0].length); + assertEquals(m.getNout(), inv[0].length); + m.invert(); + assertArrayEquals(inv, m.chebyDomain(true)); + assertArrayEquals(fwd, m.chebyDomain(false)); + assertEquals(m.getNin(), inv[0].length); + } + } + + @Test + void simplifiesAlone() { + assertCase("simp_alone", simp(quadratic())); + } + + @Test + void simplifiesBesideAPolyMapAndAWinMap() { + PolyMap pm = new PolyMap(1, 1, 2, d(1.0, 1, 1, 0.1, 1, 3), 0, null); + WinMap wm = new WinMap(1, d(0.0), d(1.0), d(2.0), d(4.0)); + Mapping m = new CmpMap(new CmpMap(wm, quadratic(), true), pm, true); + assertCase("simp_poly_win", simp(m) + tran(m, 3, d(0.0, 0.5, 1.0), true)); + + ChebyMap lin = cheby(1, 1, d(4.0, 1, 1, 1.0, 1, 0), null, d(2.0), d(6.0), null, null); + m = new CmpMap(new WinMap(1, d(0.0), d(1.0), d(2.0), d(6.0)), lin, true); + assertCase("simp_linear_win", simp(m) + tran(m, 4, d(0.0, 0.25, 1.0, 2.0), true)); + } + + @Test + void cancelsWithItsInverse() { + ChebyMap a = bothWays(); + ChebyMap b = inverted(bothWays()); + assertCase( + "simp_cancel", + simp(new CmpMap(a, b, true)) + simp(new CmpMap(b, a, true)) + simp(new CmpMap(a, b, false))); + + ChebyMap c = inverted(cheby(1, 1, QUADRATIC_COEFFS, null, d(0.0), d(20.0), null, null)); + assertCase( + "simp_no_cancel_bounds", + simp(new CmpMap(quadratic(), c, true)) + simp(new CmpMap(quadratic(), inverted(quadratic()), true))); + } + + /** + * A ChebyMap and an inverted PolyMap with the same coefficients are equal by C's {@code Equal}, + * so they cancel although together they do not make a unit transformation + * (docs/c-library-bugs.md, "A ChebyMap cancels with a PolyMap of the same coefficients"). + */ + @Test + void cancelsWithAPolyMapOfTheSameCoefficients() { + PolyMap pm = inverted(new PolyMap(1, 1, 3, QUADRATIC_COEFFS, 0, null)); + Mapping m = new CmpMap(quadratic(), pm, true); + Lines sb = new Lines(); + sb.add(equal("cheby_poly", quadratic(), new PolyMap(1, 1, 3, QUADRATIC_COEFFS, 0, null))); + sb.add(equal("poly_cheby", new PolyMap(1, 1, 3, QUADRATIC_COEFFS, 0, null), quadratic())); + sb.add(tran(m, 3, d(0.0, 5.0, 10.0), true)).add(simp(m)); + sb.add(simp(new CmpMap(new PolyMap(1, 1, 3, QUADRATIC_COEFFS, 0, null), inverted(quadratic()), true))); + assertCase("simp_cheby_poly_same_coeffs", sb.toString()); + } + + @Test + void consolidatesItsCoefficients() { + double[] fc = {1.0, 1, 0, 2.0, 1, 2, 0.5, 1, 0, 0.0, 1, 1, -1.0, 1, 2, 3.0, 1, 3}; + double[] ic = {1.0, 1, 1, 2.0, 1, 1}; + ChebyMap c = cheby(1, 1, fc, ic, d(-3.0), d(5.0), d(0.0), d(4.0)); + String before = tran(c, 3, d(-3.0, 1.0, 5.0), true) + simp(c); + c.invert(); + assertCase("simp_consolidate", before + simp(c)); + } + + @Test + void doesNotMergeInParallel() { + WinMap wm = new WinMap(1, d(0.0), d(1.0), d(2.0), d(4.0)); + assertCase("simp_parallel_win", simp(new CmpMap(quadratic(), wm, false))); + } + + @Test + void comparesAsC() { + double[] fcb = {1.0, 1, 1, 0, 0.5, 1, 2, 1, -0.25, 2, 0, 3, 2.0, 2, 0, 0}; + double[] ic = {3.0, 1, 1, 0, 1.5, 1, 0, 0, 0.75, 2, 2, 1}; + ChebyMap a = bothWays(); + ChebyMap b = bothWays(); + Lines sb = new Lines().add(equal("same", a, b)); + sb.add(equal("inverse_bounds", a, cheby(2, 2, fcb, ic, d(0.0, -2.0), d(10.0, 2.0), d(-1.0, 0.0), d(3.0, 9.0)))); + sb.add(equal("forward_bounds", a, cheby(2, 2, fcb, ic, d(0.0, -2.0), d(11.0, 2.0), d(-1.0, 0.0), d(3.0, 8.0)))); + b.invert(); + sb.add(equal("inverted", a, b)); + a.invert(); + sb.add(equal("both_inverted", a, b)); + sb.add(equal("bounds_1d", quadratic(), cheby(1, 1, QUADRATIC_COEFFS, null, d(0.0), d(20.0), null, null))); + sb.add(equal( + "no_inverse_vs_inverse", + quadratic(), + new ChebyMap(1, 1, 3, QUADRATIC_COEFFS, 1, QUADRATIC_COEFFS, d(0.0), d(20.0), d(0.0), d(20.0)))); + assertCase("equal", sb.toString()); + } + + @Test + void ratesACubic() { + ChebyMap cm = cheby(1, 1, d(0.75, 1, 1, 0.25, 1, 3), null, d(-1.0), d(1.0), null, null); + assertCase("rate_cubic", rate(cm, 0.5) + rate(cm, 0.0)); + } + + private static String construct(Runnable r) { + try { + r.run(); + return ""; + } catch (AstException e) { + return error(e); + } + } + + @Test + void checksItsArgumentsAsC() { + assertCase( + "ctor_zero_width_forward", + construct(() -> cheby(2, 1, d(1.0, 1, 1, 0), null, d(0.0, 3.0), d(1.0, 3.0), null, null))); + assertCase( + "ctor_zero_width_inverse", + construct(() -> cheby(1, 2, d(1.0, 1, 1), d(1.0, 1, 1, 0), d(0.0), d(1.0), d(0.0, 2.0), d(1.0, 2.0)))); + assertCase("ctor_zero_width_unused", show(cheby(1, 1, d(1.0, 1, 1), null, d(0.0), d(1.0), d(2.0), d(2.0)))); + ChebyMap cm = cheby(1, 1, d(1.0, 1, 1), null, d(10.0), d(0.0), null, null); + assertCase("ctor_reversed", tran(cm, 4, d(0.0, 2.5, 10.0, -1.0), true) + domain(cm, true) + show(cm)); + assertCase("ctor_bad_output", construct(() -> cheby(1, 1, d(1.0, 2, 1), null, d(0.0), d(1.0), null, null))); + assertCase( + "ctor_bad_power", + construct(() -> cheby(1, 1, d(1.0, 1, 1), d(1.0, 1, -1), d(0.0), d(1.0), d(0.0), d(1.0)))); + assertCase("ctor_no_axes", show(new ChebyMap(0, 1, 0, null, 0, null, null, null, null, null))); + } + + private static String load(String... lines) { + try { + AstObject o = ChannelText.read(String.join("\n", lines) + "\n"); + return show(o); + } catch (AstException e) { + return error(e); + } + } + + @Test + void loadsAsC() { + AstObject o = ChannelText.read(" Begin ChebyMap\n Nin = 1\n IsA Mapping\n" + + " MPF1 = 2\n NCF1 = 2\n CF1 = 1\n CF2 = 3\n" + + " PF2 = 2\n IsA PolyMap\n End ChebyMap\n"); + ChebyMap cm = (ChebyMap) o; + assertCase("load_standard_polynomial", tran(cm, 3, d(-2.0, 0.5, 4.0), true) + domain(cm, true) + show(cm)); + assertCase( + "load_insufficient", + load( + " Begin ChebyMap", + " Nin = 1", + " IsA Mapping", + " MPF1 = 1", + " NCF1 = 1", + " CF1 = 1", + " PF1 = 1", + " IsA PolyMap", + " FSCL1 = 2", + " End ChebyMap")); + assertCase( + "load_insufficient_inverse", + load( + " Begin ChebyMap", + " Nin = 2", + " IsA Mapping", + " MPI1 = 1", + " MPI2 = 0", + " NCI1 = 1", + " NCI2 = 0", + " CI1 = 1", + " PI1 = 1", + " IsA PolyMap", + " ISCL1 = 2", + " ISCL2 = 2", + " IOFF1 = 0", + " End ChebyMap")); + assertCase( + "load_unused_scales", + load( + " Begin ChebyMap", + " Nin = 1", + " IsA Mapping", + " MPF1 = 1", + " NCF1 = 1", + " CF1 = 1", + " PF1 = 1", + " IsA PolyMap", + " FSCL1 = 0.5", + " FOFF1 = -1", + " ISCL1 = 2", + " IOFF1 = 0", + " End ChebyMap")); + } + + @Test + void fitsWithItsOwnBox() { + ChebyMap cm = cheby(1, 1, d(1.0, 1, 0, 2.0, 1, 1, 0.1, 1, 2), null, d(0.0), d(10.0), null, null); + ChebyMap fit = (ChebyMap) cm.polyTran(false, 1.0e-3, 1.0e-2, 8, null, null); + double[] x = {0.0, 4.0, 10.0}; + assertCase( + "polytran_own_box", + "-- class " + fit.astClass() + "\n" + tran(fit, 3, x, true) + tran(fit, 3, fit.tran1(3, x, true), false) + + domain(fit, false) + coeffs(fit, false)); + + cm = cheby(1, 1, d(2.0, 1, 1, 0.5, 1, 0), d(0.5, 1, 1, 0.1, 1, 2), d(0.0), d(4.0), d(-1.0), d(3.0)); + fit = (ChebyMap) cm.polyTran(true, 1.0e-3, 1.0e-2, 8, null, null); + assertCase( + "polytran_forward_own_box", + tran(fit, 3, d(-1.0, 1.0, 3.0), false) + domain(fit, true) + domain(fit, false)); + + Lines sb = new Lines(); + ChebyMap q = quadratic(); + sb.add(construct(() -> q.polyTran(true, 1.0e-6, 1.0e-4, 6, null, null))); + q.invert(); + sb.add(construct(() -> q.polyTran(false, 1.0e-6, 1.0e-4, 6, null, null))); + assertCase("polytran_no_box", sb.toString()); + } + + /** test_equal.rs's two comparisons, whose results EqualTest checks against these lines. */ + static String equalRust() { + ChebyMap a = cheby(1, 1, d(1.0, 1, 1), null, d(-1.0), d(1.0), null, null); + ChebyMap b = cheby(1, 1, d(1.0, 1, 1), null, d(-1.0), d(1.0), null, null); + ChebyMap c = cheby(1, 1, d(1.0, 1, 1), null, d(-2.0), d(2.0), null, null); + return equal("chebymap_same", a, b) + equal("chebymap_different_bounds", a, c); + } + + @Test + void comparesAsTestEqualDoes() { + assertCase("equal_rust", equalRust()); + } + + /** The cases this test reads are all the probe's cases. */ + @Test + void everyCaseIsRead() { + List read = new ArrayList<>(); + for (int n = 1; n <= 4; n++) { + read.add("t_eval_" + n); + } + Collections.addAll( + read, + "t_polytran_1d", + "t_polytran_wide", + "t_2d_unit", + "t_2d_nonunit", + "t_inverted_domain", + "t_rate", + "t_linear_1d", + "t_linear_2d", + "isa", + "outside_box", + "no_inverse", + "no_inverse_polymap", + "iterinverse_unequal", + "domain_both", + "domain_no_inverse", + "domain_no_forward", + "domain_neither", + "domain_bad_coefficient", + "domain_infinite_width", + "simp_alone", + "simp_poly_win", + "simp_linear_win", + "simp_cancel", + "simp_no_cancel_bounds", + "simp_cheby_poly_same_coeffs", + "simp_consolidate", + "simp_parallel_win", + "equal", + "equal_rust", + "rate_cubic", + "ctor_zero_width_forward", + "ctor_zero_width_inverse", + "ctor_zero_width_unused", + "ctor_reversed", + "ctor_bad_output", + "ctor_bad_power", + "ctor_no_axes", + "load_standard_polynomial", + "load_insufficient", + "load_insufficient_inverse", + "load_unused_scales", + "polytran_own_box", + "polytran_forward_own_box", + "polytran_no_box", + "domain_unequal"); + assertEquals(new ArrayList<>(FUSED.keySet()), read); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/ChebyMapTest.java b/src/test/java/uk/ac/starlink/ast/ChebyMapTest.java new file mode 100644 index 0000000..db0102b --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/ChebyMapTest.java @@ -0,0 +1,725 @@ +package uk.ac.starlink.ast; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static uk.ac.starlink.ast.PolyTerms.flat; +import static uk.ac.starlink.ast.PolyTerms.term; + +import org.junit.jupiter.api.Test; + +/** + * Translation of Rust {@code tests/test_chebymap.rs}, which follows C's {@code testchebymap.c}. + * + *

Rust's terms are C's coefficient groups ({@link PolyTerms}); its {@code domain}, {@code + * coeffs}, {@code forward_terms}/{@code inverse_terms} and {@code poly_tran} are {@link + * ChebyMap#chebyDomain}, {@link PolyMap#polyCoeffs} and {@link ChebyMap#polyTran}. Its {@code + * try_merge} tests become the simplification of the pair in a CmpMap, which reaches the same merge + * (polymap.c {@code MapMerge}). Where the Rust constructor refuses arguments C accepts (no inputs + * or no outputs, a longer bounds array) the test checks C's behaviour ({@code probes/chebymap_probe} + * case {@code ctor_no_axes}); inverse coefficients without inverse bounds, which C would read + * through a null pointer, are a {@link NullPointerException}, and a bounds array shorter than the + * axes is {@code AST__DIMIN}, as jniast checks its arrays. + */ +class ChebyMapTest { + + private static final double BAD = AstObject.AST__BAD; + + private static final double[] L1 = {-1.0}; + private static final double[] U1 = {1.0}; + + /** A ChebyMap with the given forward terms and bounds and no inverse. */ + static ChebyMap cheby(int nin, int nout, double[] lbnd, double[] ubnd, double[]... fwd) { + return new ChebyMap(nin, nout, fwd.length, flat(fwd), 0, null, lbnd, ubnd, null, null); + } + + /** A ChebyMap with forward and inverse terms and bounds. */ + static ChebyMap cheby( + int nin, + int nout, + double[][] fwd, + double[][] inv, + double[] lbndF, + double[] ubndF, + double[] lbndI, + double[] ubndI) { + return new ChebyMap(nin, nout, fwd.length, flat(fwd), inv.length, flat(inv), lbndF, ubndF, lbndI, ubndI); + } + + private static double[] d(double... v) { + return v; + } + + private static double[][] terms(double[]... t) { + return t; + } + + private static double tran1(Mapping m, double x, boolean forward) { + return m.tran1(1, d(x), forward)[0]; + } + + private static double[] tran1(Mapping m, double[] x, boolean forward) { + return m.tran1(x.length, x, forward); + } + + private static Mapping simplifiedPair(Mapping a, Mapping b) { + return new CmpMap(a, b, true).simplify(); + } + + // ------------------------------------------------------------------ + // Construction and basic properties + // ------------------------------------------------------------------ + + @Test + void chebymapDimensions() { + ChebyMap m = cheby(1, 1, d(0.0), d(10.0), term(1.5, 1, 0)); + assertEquals(1, m.getNin()); + assertEquals(1, m.getNout()); + assertFalse(m.getInvert()); + } + + /** C accepts a ChebyMap with no inputs (Rust refuses it): probe case {@code ctor_no_axes}. */ + @Test + void chebymapNinZeroAccepted() { + ChebyMap m = new ChebyMap(0, 1, 0, null, 0, null, null, null, null, null); + assertEquals(0, m.getNin()); + assertEquals(1, m.getNout()); + } + + /** C accepts a ChebyMap with no outputs, as it accepts a PolyMap with none (Rust refuses it). */ + @Test + void chebymapNoutZeroAccepted() { + ChebyMap m = new ChebyMap(1, 0, 0, null, 0, null, d(0.0), d(1.0), null, null); + assertEquals(0, m.getNout()); + } + + /** A bounds array shorter than the axes is AST__DIMIN; a longer one is used as C uses it. */ + @Test + void chebymapBadBoundsLenRejected() { + double[] t = term(1.0, 1, 0); + AstException e = assertThrows( + AstException.class, + () -> new ChebyMap(2, 1, 1, flat(term(1.0, 1, 0, 0)), 0, null, d(0.0), d(10.0, 1.0), null, null)); + assertEquals(AstException.AST__DIMIN, e.getStatus()); + assertEquals( + "astChebyMap(ChebyMap): The lbnd_f array holds 1 values.\nThis should not be less than 2.", + e.getMsgText()); + ChebyMap m = new ChebyMap(1, 1, 1, t, 0, null, d(0.0, 1.0), d(10.0), null, null); + assertEquals(1.5, tran1(m, 0.0, true) + 0.5); + } + + @Test + void chebymapZeroWidthBoundsRejected() { + AstException e = assertThrows(AstException.class, () -> cheby(1, 1, d(5.0), d(5.0), term(1.0, 1, 0))); + assertEquals(AstException.AST__BADBX, e.getStatus()); + assertEquals("astInitChebyMap(ChebyMap): Input bounding box has zero width on input axis 1.", e.getMsgText()); + // Reversed bounds give a negative scale. + assertNotNull(cheby(1, 1, d(10.0), d(0.0), term(1.0, 1, 0))); + } + + @Test + void chebymapInverseWithoutBoundsRejected() { + double[] t = term(1.0, 1, 1); + double[][] pairs = {null, null, {0.0}, null, null, {1.0}}; + for (int i = 0; i < pairs.length; i += 2) { + double[] li = pairs[i]; + double[] ui = pairs[i + 1]; + NullPointerException e = assertThrows( + NullPointerException.class, () -> new ChebyMap(1, 1, 1, t, 1, t, d(0.0), d(1.0), li, ui)); + assertTrue(e.getMessage().startsWith(li == null ? "lbnd_i" : "ubnd_i"), e.getMessage()); + } + // An empty inverse defines nothing, so it needs no box. + assertNotNull(new ChebyMap(1, 1, 1, t, 0, new double[0], d(0.0), d(1.0), null, null)); + assertNotNull(new ChebyMap(1, 1, 1, t, 1, t, d(0.0), d(1.0), d(0.0), d(1.0))); + } + + // ------------------------------------------------------------------ + // Evaluation + // ------------------------------------------------------------------ + + @Test + void chebymap1dConstant() { + ChebyMap m = cheby(1, 1, d(0.0), d(10.0), term(1.5, 1, 0)); + for (double v : tran1(m, d(0.0, 5.0, 10.0), true)) { + assertEquals(1.5, v, 1e-12); + } + } + + /** 2.5 T0 - 2 T2 over [0, 1]: x' = 2x - 1. */ + @Test + void chebymap1dQuadratic() { + ChebyMap m = cheby(1, 1, d(0.0), d(1.0), term(2.5, 1, 0), term(-2.0, 1, 2)); + assertEquals(0.5, tran1(m, 0.0, true), 1e-12); + assertEquals(4.5, tran1(m, 0.5, true), 1e-12); + assertEquals(0.5, tran1(m, 1.0, true), 1e-12); + assertEquals(3.5, tran1(m, 0.25, true), 1e-12); + } + + @Test + void chebymapOutOfBounds() { + ChebyMap m = cheby(1, 1, d(0.0), d(10.0), term(1.0, 1, 1)); + assertEquals(BAD, tran1(m, -0.1, true), "below lower bound should be BAD"); + assertEquals(BAD, tran1(m, 10.1, true), "above upper bound should be BAD"); + double[] edge = tran1(m, d(0.0, 10.0), true); + assertNotEquals(BAD, edge[0], "at lower bound should not be BAD"); + assertNotEquals(BAD, edge[1], "at upper bound should not be BAD"); + } + + /** A bad or NaN input spoils only the output whose terms use it (chebymap.c PolyPowers). */ + @Test + void chebymapBadValuePropagation() { + ChebyMap m = cheby(2, 2, d(-10.0, -10.0), d(10.0, 10.0), term(1.0, 1, 1, 0), term(1.0, 2, 0, 1)); + double[][] out = m.tran2(1, d(BAD), d(3.0), true); + assertEquals(BAD, out[0][0]); + assertEquals(0.3, out[1][0], 1e-15); + out = m.tran2(1, d(Double.NaN), d(3.0), true); + assertEquals(BAD, out[0][0]); + assertEquals(0.3, out[1][0], 1e-15); + } + + /** 3 T1(x') T2(y') over [-1, 1] x [-1, 1]. */ + @Test + void chebymap2dMixedPowers() { + ChebyMap m = cheby(2, 1, d(-1.0, -1.0), d(1.0, 1.0), term(3.0, 1, 1, 2)); + assertEquals(-0.75, m.tranP(1, 2, new double[][] {{0.5}, {0.5}}, true, 1)[0][0], 1e-12); + assertEquals(-3.0, m.tranP(1, 2, new double[][] {{1.0}, {0.0}}, true, 1)[0][0], 1e-12); + assertEquals(0.0, m.tranP(1, 2, new double[][] {{0.0}, {0.0}}, true, 1)[0][0], 1e-12); + } + + /** T1(x') over [0, 10] x [0, 20]: x' = 0.2x - 1. */ + @Test + void chebymap2dNontrivialDomain() { + ChebyMap m = cheby(2, 1, d(0.0, 0.0), d(10.0, 20.0), term(1.0, 1, 1, 0)); + assertEquals(0.0, m.tranP(1, 2, new double[][] {{5.0}, {10.0}}, true, 1)[0][0], 1e-12); + assertEquals(1.0, m.tranP(1, 2, new double[][] {{10.0}, {10.0}}, true, 1)[0][0], 1e-12); + assertEquals(-1.0, m.tranP(1, 2, new double[][] {{0.0}, {10.0}}, true, 1)[0][0], 1e-12); + } + + /** Forward T1(x') over [0, 10]; inverse 5 T0 + 5 T1 over [-1, 1]. */ + private static ChebyMap roundTripMap() { + return cheby(1, 1, terms(term(1.0, 1, 1)), terms(term(5.0, 1, 0), term(5.0, 1, 1)), d(0.0), d(10.0), L1, U1); + } + + @Test + void chebymapForwardInverseRoundtrip() { + ChebyMap m = roundTripMap(); + double y = tran1(m, 5.0, true); + assertEquals(0.0, y, 1e-12); + assertEquals(5.0, tran1(m, y, false), 1e-12); + y = tran1(m, 0.0, true); + assertEquals(-1.0, y, 1e-12); + assertEquals(0.0, tran1(m, y, false), 1e-12); + } + + @Test + void chebymapInvert() { + ChebyMap m = roundTripMap(); + assertEquals(0.0, tran1(m, 5.0, true), 1e-12); + m.invert(); + assertTrue(m.getInvert()); + assertEquals(5.0, tran1(m, 0.0, true), 1e-12); + } + + @Test + void chebymapNoInverseIsAnError() { + ChebyMap m = cheby(1, 1, d(0.0), d(10.0), term(1.0, 1, 1)); + assertFalse(m.getTranInverse()); + AstException e = assertThrows(AstException.class, () -> m.tran1(1, d(5.0), false)); + assertEquals(AstException.AST__TRNND, e.getStatus()); + } + + // ------------------------------------------------------------------ + // Domain + // ------------------------------------------------------------------ + + @Test + void chebymapDomainAccessor() { + ChebyMap m = cheby(1, 1, terms(term(1.0, 1, 1)), terms(term(1.0, 1, 1)), d(0.0), d(10.0), L1, U1); + double[][] f = m.chebyDomain(true); + assertArrayEquals(d(0.0), f[0]); + assertArrayEquals(d(10.0), f[1]); + double[][] i = m.chebyDomain(false); + assertArrayEquals(d(-1.0), i[0]); + assertArrayEquals(d(1.0), i[1]); + } + + /** + * A forward-only 2-D ChebyMap has no inverse box, so the inverse domain is found by MapBox from + * the forward box; inverting it swaps the two domains (testchebymap.c errors 800-803). The + * values are C's astChebyDomain (probe case {@code t_inverted_domain}). + */ + @Test + void chebymapDomainInvertedForwardOnly() { + ChebyMap m = + cheby(2, 2, d(0.0, -1.0), d(1.0, 2.0), term(1.0, 1, 1, 0), term(1.0, 2, 0, 1), term(0.25, 2, 1, 1)); + double[][] forwardBox = {{0.0, -1.0000000000000002}, {1.0, 2.0}}; + double[][] inverseBox = {{-1.0, -1.25}, {1.0, 1.25}}; + assertArrayEquals(forwardBox, m.chebyDomain(true)); + assertArrayEquals(inverseBox, m.chebyDomain(false)); + m.invert(); + assertArrayEquals(inverseBox, m.chebyDomain(true)); + assertArrayEquals(forwardBox, m.chebyDomain(false)); + } + + /** T3(x) = 4x^3 - 3x over [-1, 1]. */ + @Test + void chebymapHigherOrderChebyshev() { + ChebyMap m = cheby(1, 1, L1, U1, term(1.0, 1, 3)); + assertEquals(-1.0, tran1(m, 0.5, true), 1e-12); + assertEquals(1.0, tran1(m, 1.0, true), 1e-12); + assertEquals(0.0, tran1(m, 0.0, true), 1e-12); + } + + // ------------------------------------------------------------------ + // Serialisation + // ------------------------------------------------------------------ + + private static ChebyMap readBack(ChebyMap m) { + AstObject obj = ChannelText.read(ChannelText.dump(m)); + return assertInstanceOf(ChebyMap.class, obj); + } + + @Test + void chebymapSerialisationRoundtrip() { + ChebyMap m = cheby( + 1, + 1, + terms(term(2.5, 1, 0), term(-2.0, 1, 2)), + terms(term(5.0, 1, 0), term(5.0, 1, 1)), + d(0.0), + d(1.0), + L1, + U1); + ChebyMap m2 = readBack(m); + double[] x = {0.0, 0.25, 0.5, 0.75, 1.0}; + double[] out1 = tran1(m, x, true); + double[] out2 = tran1(m2, x, true); + for (int i = 0; i < x.length; i++) { + assertEquals(out1[i], out2[i], 1e-12, "fwd point " + i); + } + double[] y = {0.0, 0.5, -0.5}; + out1 = tran1(m, y, false); + out2 = tran1(m2, y, false); + for (int i = 0; i < y.length; i++) { + assertEquals(out1[i], out2[i], 1e-12, "inv point " + i); + } + } + + @Test + void chebymapSerialisationForwardOnly() { + ChebyMap m = cheby(1, 1, d(-5.0), d(5.0), term(1.0, 1, 0), term(3.0, 1, 1)); + ChebyMap m2 = readBack(m); + double[] x = {-5.0, 0.0, 5.0}; + double[] out1 = tran1(m, x, true); + double[] out2 = tran1(m2, x, true); + for (int i = 0; i < x.length; i++) { + assertEquals(out1[i], out2[i], 1e-12, "point " + i); + } + double[][] box = m2.chebyDomain(true); + assertArrayEquals(d(-5.0), box[0]); + assertArrayEquals(d(5.0), box[1]); + } + + @Test + void chebymap2dSerialisationRoundtrip() { + ChebyMap m = + cheby(2, 2, d(0.0, 0.0), d(10.0, 20.0), term(1.0, 1, 1, 0), term(2.0, 2, 0, 1), term(0.5, 2, 1, 1)); + ChebyMap m2 = readBack(m); + double[][] pts = {{5.0, 2.5}, {10.0, 15.0}}; + double[][] out1 = m.tranP(2, 2, pts, true, 2); + double[][] out2 = m2.tranP(2, 2, pts, true, 2); + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 2; j++) { + assertEquals(out1[j][i], out2[j][i], 1e-12, "point " + i + " axis " + j); + } + } + } + + @Test + void chebymapSerialisationPreservesClass() { + ChebyMap m = cheby(1, 1, d(0.0), d(10.0), term(1.0, 1, 1)); + assertTrue(ChannelText.dump(m).contains("ChebyMap"), "native string should contain ChebyMap class name"); + } + + // ------------------------------------------------------------------ + // Rate + // ------------------------------------------------------------------ + + /** T1(x) over [-1, 1] is x: the rate is 1 at 0 and at 0.5. */ + @Test + void chebymapRate() { + ChebyMap m = cheby(1, 1, L1, U1, term(1.0, 1, 1)); + assertEquals(1.0, m.rate(d(0.0), 1, 1), 1e-6); + assertEquals(1.0, m.rate(d(0.5), 1, 1), 1e-6); + } + + // ------------------------------------------------------------------ + // Merging with neighbours (Rust try_merge, here the simplification of the pair) + // ------------------------------------------------------------------ + + private static ChebyMap quadraticWithInverse() { + return cheby( + 1, + 1, + terms(term(2.5, 1, 0), term(-2.0, 1, 2)), + terms(term(5.0, 1, 0), term(5.0, 1, 1)), + d(0.0), + d(1.0), + L1, + U1); + } + + private static T inverted(T m) { + m.invert(); + return m; + } + + @Test + void chebymapCancelsWithInverse() { + ChebyMap m = quadraticWithInverse(); + Mapping s = simplifiedPair(m, inverted((ChebyMap) m.copy())); + assertInstanceOf(UnitMap.class, s, "should cancel with its own inverse"); + assertEquals(1, s.getNin()); + assertEquals(1, s.getNout()); + } + + @Test + void chebymapSameDirectionDoesNotCancel() { + ChebyMap m = cheby(1, 1, d(0.0), d(10.0), term(1.0, 1, 1), term(0.5, 1, 2)); + Mapping s = simplifiedPair(m, (Mapping) m.copy()); + assertFalse(s instanceof UnitMap, "same direction should not cancel"); + } + + @Test + void chebymapDifferentMapsDoNotCancel() { + ChebyMap m1 = cheby(1, 1, d(0.0), d(10.0), term(1.0, 1, 1), term(0.5, 1, 2)); + ChebyMap m2 = cheby(1, 1, d(0.0), d(10.0), term(2.0, 1, 1), term(0.5, 1, 2)); + assertFalse(simplifiedPair(m1, inverted(m2)) instanceof UnitMap, "different maps should not cancel"); + } + + @Test + void chebymapDifferentBoundsDoNotCancel() { + ChebyMap m1 = cheby(1, 1, d(0.0), d(10.0), term(1.0, 1, 1), term(0.5, 1, 2)); + ChebyMap m2 = cheby(1, 1, d(0.0), d(20.0), term(1.0, 1, 1), term(0.5, 1, 2)); + assertFalse(simplifiedPair(m1, inverted(m2)) instanceof UnitMap, "different bounds should not cancel"); + } + + @Test + void chebymapParallelDoesNotMerge() { + ChebyMap m = cheby(1, 1, d(0.0), d(10.0), term(1.0, 1, 1), term(0.5, 1, 2)); + Mapping s = new CmpMap(m, inverted((ChebyMap) m.copy()), false).simplify(); + assertInstanceOf(CmpMap.class, s, "parallel should not merge"); + } + + @Test + void chebymap2dCancelsWithInverse() { + ChebyMap m = cheby( + 2, + 2, + terms(term(1.0, 1, 1, 0), term(2.0, 2, 0, 1)), + terms(term(1.0, 1, 1, 0), term(0.5, 2, 0, 1)), + d(-1.0, -1.0), + d(1.0, 1.0), + d(-1.0, -2.0), + d(1.0, 2.0)); + Mapping s = simplifiedPair(m, inverted((ChebyMap) m.copy())); + assertInstanceOf(UnitMap.class, s); + assertEquals(2, s.getNin()); + assertEquals(2, s.getNout()); + s = simplifiedPair(inverted((ChebyMap) m.copy()), m); + assertInstanceOf(UnitMap.class, s); + assertEquals(2, s.getNin()); + } + + /** + * Identical forward transformations and boxes, inverse transformations with different + * coefficient counts and maximum powers: the comparison ChebyMap inherits from PolyMap compares + * them, so the pair stands. + */ + @Test + void chebymapDoesNotCancelWhenTheInverseShapesDiffer() { + double[][] fwd = terms(term(2.0, 1, 2)); + ChebyMap a = cheby(1, 1, fwd, terms(term(0.5, 1, 1)), d(0.0), d(10.0), d(-5.0), d(5.0)); + ChebyMap b = cheby(1, 1, fwd, terms(term(0.5, 1, 1), term(0.3, 1, 2)), d(0.0), d(10.0), d(-5.0), d(5.0)); + assertFalse(simplifiedPair(a, inverted(b)) instanceof UnitMap); + } + + /** As above, with the same inverse shapes and different inverse coefficient values. */ + @Test + void chebymapDoesNotCancelWhenOnlyInverseCoefficientValuesDiffer() { + double[][] fwd = terms(term(2.0, 1, 2)); + ChebyMap a = cheby(1, 1, fwd, terms(term(0.5, 1, 1)), d(0.0), d(10.0), d(-5.0), d(5.0)); + ChebyMap b = cheby(1, 1, fwd, terms(term(0.7, 1, 1)), d(0.0), d(10.0), d(-5.0), d(5.0)); + assertFalse(simplifiedPair(a, inverted(b)) instanceof UnitMap); + } + + /** + * A ChebyMap whose every term is linear reduces with its normalisation folded in: over [0, 10] + * 2 T1(z) is 0.4x - 2 (testchebymap.c, the block after error 601). + */ + @Test + void aLinearChebymapReducesWithItsNormalisationFoldedIn() { + ChebyMap m = cheby(1, 1, d(0.0), d(10.0), term(2.0, 1, 1)); + Mapping s = m.simplify(); + assertFalse(s instanceof ChebyMap, "a linear ChebyMap must be replaced"); + double[] x = {0.0, 1.0, 10.0}; + double[] ref = tran1(m, x, true); + double[] simp = tran1(s, x, true); + for (int i = 0; i < 3; i++) { + assertEquals(ref[i], simp[i], 1.0e-10, "point " + i); + } + assertEquals(-2.0, ref[0], 1.0e-12); + assertEquals(2.0, ref[2], 1.0e-12); + double[] back = tran1(s, ref, false); + for (int i = 0; i < 3; i++) { + assertEquals(x[i], back[i], 1.0e-10, "point " + i); + } + } + + /** fx = 3 T1(x') + 0.5, fy = -T1(y') + 2 over [0, 10] x [-5, 5]: offsets accumulate. */ + @Test + void aLinearChebymapAccumulatesEachOutputsConstantContributions() { + ChebyMap m = cheby( + 2, + 2, + d(0.0, -5.0), + d(10.0, 5.0), + term(3.0, 1, 1, 0), + term(0.5, 1, 0, 0), + term(-1.0, 2, 0, 1), + term(2.0, 2, 0, 0)); + Mapping s = m.simplify(); + assertFalse(s instanceof ChebyMap, "a linear ChebyMap must be replaced"); + double[][] x = {{0.0, 10.0, 3.0, 7.5}, {-5.0, 5.0, 1.0, -2.0}}; + double[][] ref = m.tranP(4, 2, x, true, 2); + double[][] simp = s.tranP(4, 2, x, true, 2); + double[][] back = s.tranP(4, 2, ref, false, 2); + for (int i = 0; i < 4; i++) { + for (int a = 0; a < 2; a++) { + assertEquals(ref[a][i], simp[a][i], 1.0e-10, "point " + i + " axis " + (a + 1)); + assertEquals(x[a][i], back[a][i], 1.0e-9, "point " + i + " axis " + (a + 1)); + } + } + } + + // ------------------------------------------------------------------ + // testchebymap.c, in its order; assertion messages carry C's error numbers + // ------------------------------------------------------------------ + + private static final double[] C_COEFFS_1 = {1.5, 1.0, 0.0, -1.0, 1.0, 2.0, 2.0, 1.0, 3.0, 1.3, 1.0, 4.0}; + private static final double[] C_COEFFS_2 = {1.0, 1.0, 0.0, -2.0, 1.0, 1.0}; + private static final double[] C_COEFFS_3 = { + 1.0, 1.0, 0.0, 0.0, -2.0, 1.0, 1.0, 2.0, 1.0, 1.0, 0.0, 1.0, 1.5, 2.0, 0.0, 0.0, -2.5, 2.0, 1.0, 2.0 + }; + private static final double[] C_COEFFS_4 = { + 1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0, 1.0, 2.0, 1.0, 0.0, -1.0, 2.0, 0.0, 1.0 + }; + + /** A forward-only ChebyMap whose inverse box is given too, as testchebymap.c builds them. */ + private static ChebyMap cChebymap(int nin, double[] cofs, int ncoeff, double[] lbnd, double[] ubnd) { + return new ChebyMap(nin, nin, ncoeff, cofs, 0, null, lbnd, ubnd, lbnd, ubnd); + } + + private static ChebyMap cChebymap(int nin, double[] cofs, double[] lbnd, double[] ubnd) { + return cChebymap(nin, cofs, cofs.length / (2 + nin), lbnd, ubnd); + } + + @Test + void c1dEvaluation() { + double[] xin = {-1.0, -0.5, 0.0, 0.5, 1.0}; + for (double v : tran1(cChebymap(1, C_COEFFS_1, 1, L1, U1), xin, true)) { + assertEquals(1.5, v, "Error 0"); + } + double[] out = tran1(cChebymap(1, C_COEFFS_1, 2, L1, U1), xin, true); + for (int i = 0; i < 5; i++) { + double x = xin[i]; + assertEquals(2.5 - 2.0 * x * x, out[i], "Error 1"); + } + out = tran1(cChebymap(1, C_COEFFS_1, 3, L1, U1), xin, true); + for (int i = 0; i < 5; i++) { + double x = xin[i]; + assertEquals(2.5 - 6.0 * x - 2.0 * x * x + 8.0 * x * x * x, out[i], "Error 2"); + } + ChebyMap cm = cChebymap(1, C_COEFFS_1, 4, L1, U1); + out = tran1(cm, xin, true); + for (int i = 0; i < 5; i++) { + double x = xin[i]; + double[] w = {1.0, x, 0.0, 0.0, 0.0}; + for (int j = 2; j < 5; j++) { + w[j] = 2.0 * x * w[j - 1] - w[j - 2]; + } + assertEquals(1.5 * w[0] - 1.0 * w[2] + 2.0 * w[3] + 1.3 * w[4], out[i], "Error 3"); + } + assertEquals(0, cm.getI("IterInverse"), "Error 4"); + } + + /** The inverse of 1 - 2x over [-1, 1]: its box is [-1, 3], over which it is -T1. */ + @Test + void c1dPolyTran() { + ChebyMap cm = cChebymap(1, C_COEFFS_2, L1, U1); + ChebyMap cm2 = assertInstanceOf(ChebyMap.class, cm.polyTran(false, 0.01, 0.01, 5, L1, U1), "Error 5"); + double[] xin = {-1.0, -0.5, 0.0, 0.5, 1.0}; + double[] xrec = tran1(cm2, tran1(cm2, xin, true), false); + for (int i = 0; i < 5; i++) { + assertTrue(Math.abs(xrec[i] - xin[i]) <= 1.0e-3 * Math.abs(xin[i]), "Error 6"); + } + double[][] dom = cm2.chebyDomain(false); + assertEquals(-1.0, dom[0][0], "Error 501"); + assertEquals(3.0, dom[1][0], "Error 502"); + double[] cofs = cm2.polyCoeffs(false); + assertEquals(1, cofs.length / 3, "Error 503"); + assertEquals(-1.0, cofs[0], 1.0e-10, "Error 504"); + assertEquals(1.0, cofs[1], 1.0e-10, "Error 505"); + assertEquals(1.0, cofs[2], 1.0e-10, "Error 506"); + } + + /** The inverse of a quartic fitted over part of a wider domain; it copies and dumps equal. */ + @Test + void c1dPolyTranWide() { + ChebyMap cm = cChebymap(1, C_COEFFS_1, d(-100.0), d(100.0)); + ChebyMap cm2 = + assertInstanceOf(ChebyMap.class, cm.polyTran(false, 0.01, 0.01, 10, d(-5.0), d(50.0)), "Error 7"); + double[] xin = {0.0, 10.0, 20.0, 30.0, 40.0}; + double[] xrec = tran1(cm2, tran1(cm2, xin, true), false); + for (int i = 0; i < 5; i++) { + assertEquals(xin[i], xrec[i], 0.01, "Error 8"); + } + ChebyMap cm3 = (ChebyMap) cm2.copy(); + assertTrue(cm2.astEqual(cm3), "Error 9"); + assertTrue(readBack(cm2).astEqual(cm2), "Error -3"); + } + + /** fx = T1(x') + T1(y'), fy = T1(x') - T1(y') over [-1, 1]. */ + @Test + void c2dPolyTranUnitDomain() { + double[] l = {-1.0, -1.0}; + double[] u = {1.0, 1.0}; + ChebyMap cm = cChebymap(2, C_COEFFS_4, l, u); + assertInstanceOf(UnitMap.class, simplifiedPair(cm, inverted((ChebyMap) cm.copy())), "Error 1000"); + double[] xin = {0.5, 0.0, -0.5, 0.0}; + double[] yin = {0.0, 0.5, 0.0, -0.5}; + double[][] out = cm.tran2(4, xin, yin, true); + for (int i = 0; i < 4; i++) { + double xv = xin[i] + yin[i]; + double yv = xin[i] - yin[i]; + assertTrue( + Math.abs(out[0][i] - xv) <= 1.0e-6 * Math.abs(xv) + && Math.abs(out[1][i] - yv) <= 1.0e-6 * Math.abs(yv), + "Error 101"); + } + ChebyMap cm2 = assertInstanceOf(ChebyMap.class, cm.polyTran(false, 0.01, 0.01, 10, l, u), "Error 102"); + double[][] rec = cm2.tran2(4, out[0], out[1], false); + for (int i = 0; i < 4; i++) { + assertTrue(Math.abs(rec[0][i] - xin[i]) <= 0.01 && Math.abs(rec[1][i] - yin[i]) <= 0.01, "Error 103"); + } + double[] cofs = cm2.polyCoeffs(false); + assertEquals(4, cofs.length / 4, "Error 104"); + for (int i = 0; i < 16; i++) { + assertEquals(C_COEFFS_4[i], cofs[i], 0.01, "Error 105"); + } + double[][] dom = cm2.chebyDomain(false); + assertArrayEquals(d(-2.0, -2.0), dom[0], "Error 106-107"); + assertArrayEquals(d(2.0, 2.0), dom[1], "Error 108-109"); + } + + /** A 2-D ChebyMap over [0, 10], a fit of its inverse over [4, 6], and the domains of both. */ + @Test + // Errors 18 and 19 compare with C's literals, written to more digits than a double holds. + @SuppressWarnings("FloatingPointLiteralPrecision") + void c2dPolyTranNonunitDomain() { + double[] l = {0.0, 0.0}; + double[] u = {10.0, 10.0}; + ChebyMap cm = cChebymap(2, C_COEFFS_3, l, u); + double[] xin = {0.0, 2.0, 6.0, 10.0}; + double[] yin = {2.0, 5.0, 8.0, 0.0}; + double[][] out = cm.tran2(4, xin, yin, true); + for (int i = 0; i < 4; i++) { + double xi = 2.0 * (xin[i] - l[0]) / (u[0] - l[0]) - 1.0; + double yi = 2.0 * (yin[i] - l[1]) / (u[1] - l[1]) - 1.0; + double xv = 1.0 - 2.0 * xi * (2.0 * yi * yi - 1.0) + yi; + double yv = 1.5 - 2.5 * xi * (2.0 * yi * yi - 1.0); + assertTrue( + Math.abs(out[0][i] - xv) <= 1.0e-6 * Math.abs(xv) + && Math.abs(out[1][i] - yv) <= 1.0e-6 * Math.abs(yv), + "Error 10"); + } + ChebyMap cm2 = assertInstanceOf( + ChebyMap.class, cm.polyTran(false, 0.01, 0.01, 10, d(4.0, 4.0), d(6.0, 6.0)), "Error 11"); + double[] x2 = {4.0, 4.5, 5.0, 5.5}; + double[] y2 = {6.0, 5.5, 5.0, 4.5}; + double[][] fwd = cm2.tran2(4, x2, y2, true); + double[][] rec = cm2.tran2(4, fwd[0], fwd[1], false); + for (int i = 0; i < 4; i++) { + assertTrue(Math.abs(rec[0][i] - x2[i]) <= 0.01 && Math.abs(rec[1][i] - y2[i]) <= 0.01, "Error 12"); + } + double[] f = cm2.polyCoeffs(true); + assertEquals(5, f.length / 4, "Error 13-14"); + assertArrayEquals(C_COEFFS_3, f, "Error 15"); + double[] inv = cm2.polyCoeffs(false); + assertEquals(9, inv.length / 4, "Error 16-17"); + assertEquals(5.0000000000000018, inv[0], 1.0e-6, "Error 18"); + assertEquals(0.35096188953505458, inv[12], 1.0e-6, "Error 19"); + assertEquals(2.0, inv[14], "Error 20"); + double[][] dom = cm.chebyDomain(true); + assertArrayEquals(l, dom[0], "Error 21-22"); + assertArrayEquals(u, dom[1], "Error 23-24"); + dom = cm.chebyDomain(false); + assertArrayEquals(d(-2.0, -1.0), dom[0], "Error 25-26"); + assertArrayEquals(d(4.0, 4.0), dom[1], "Error 27-28"); + dom = cm2.chebyDomain(true); + assertArrayEquals(l, dom[0], "Error 29-30"); + assertArrayEquals(u, dom[1], "Error 31-32"); + dom = cm2.chebyDomain(false); + assertEquals(0.432, dom[0][0], 1.0e-6, "Error 33"); + assertEquals(1.000816, dom[0][1], 1.0e-6, "Error 34"); + assertEquals(1.568, dom[1][0], 1.0e-6, "Error 35"); + assertEquals(1.9991836, dom[1][1], 1.0e-6, "Error 36"); + } + + /** + * polyCoeffs gives the coefficients of the ChebyMap as it stands, so an inverted ChebyMap's + * forward coefficients are those it was created with for the inverse, as C's astPolyCoeffs gives + * them. + */ + @Test + void coeffsFollowInversionLikeC() { + double[][] fwd = terms(term(1.5, 1, 1, 0), term(2.5, 1, 0, 2)); + double[][] inv = terms(term(3.0, 1, 1), term(4.0, 2, 0)); + ChebyMap map = cheby(2, 1, fwd, inv, d(-1.0, -2.0), d(1.0, 2.0), d(0.0), d(5.0)); + assertArrayEquals(flat(fwd), map.polyCoeffs(true)); + assertArrayEquals(flat(inv), map.polyCoeffs(false)); + map.invert(); + assertArrayEquals(flat(inv), map.polyCoeffs(true)); + assertArrayEquals(flat(fwd), map.polyCoeffs(false)); + } + + // ------------------------------------------------------------------ + // Java: the loader and the API + // ------------------------------------------------------------------ + + /** A ChebyMap is a PolyMap, as C's astIsAPolyMap says (probe case {@code isa}). */ + @Test + void aChebyMapIsAPolyMap() { + Mapping m = cheby(1, 1, L1, U1, term(1.0, 1, 1)); + assertInstanceOf(PolyMap.class, m); + assertEquals("ChebyMap", m.getC("Class")); + } + + /** A fit is made in a copy, which gets its own inverse box; the ChebyMap fitted keeps none. */ + @Test + void aFitLeavesTheChebyMapFittedAlone() { + ChebyMap cm = cChebymap(1, C_COEFFS_2, L1, U1); + ChebyMap copy = (ChebyMap) cm.copy(); + ChebyMap fit = (ChebyMap) cm.polyTran(false, 0.01, 0.01, 5, L1, U1); + assertNotNull(fit); + assertEquals(0, cm.polyCoeffs(false).length); + assertTrue(cm.astEqual(copy)); + assertFalse(cm.astEqual(fit)); + assertEquals(3.0, fit.chebyDomain(false)[1][0]); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/ClearOnSetTest.java b/src/test/java/uk/ac/starlink/ast/ClearOnSetTest.java index 42935fa..9fdf951 100644 --- a/src/test/java/uk/ac/starlink/ast/ClearOnSetTest.java +++ b/src/test/java/uk/ac/starlink/ast/ClearOnSetTest.java @@ -19,12 +19,9 @@ * flag must survive it. The loader re-applies attributes through the same setters, which discard a * record only when the value changes, so a dumped {@code IsSimp} card survives a read. * - *

The cases of SplineMap are listed in {@code deferred/rust-tests.txt} (class not yet - * ported), and the same class is left out of {@link - * #loadPreservesTheRecordForEveryClearOnSetClass}. Rust's {@code GrismMap::new}, which sets every - * attribute, is {@link #grismMap}, through the jniast setters. LutInterp and LutEpsilon, which have no jniast - * methods, are set through the generic attribute methods, as are the clearing of a MathMap's Seed - * and its test. + *

Rust's {@code GrismMap::new}, which sets every attribute, is {@link #grismMap}, through the + * jniast setters. LutInterp and LutEpsilon, which have no jniast methods, are set through the + * generic attribute methods, as are the clearing of a MathMap's Seed and its test. */ class ClearOnSetTest { @@ -66,6 +63,11 @@ private static GrismMap grismMap(double nr, double nrp, double waveR, double alp return map; } + private static SplineMap splineMap() { + return new SplineMap( + 1, 1, 1, 1, new double[] {0.0, 1.0}, new double[] {0.0, 1.0}, new double[] {1.0}, new double[] {2.0}); + } + private static WcsMap wcsMap() { return new WcsMap(2, WcsMap.AST__TAN, 1, 2); } @@ -90,6 +92,21 @@ void polyTolInverseDiscardsTheRecord() { assertDiscards(polyMap(), "PolyMap.setTolInverse", m -> m.setTolInverse(1.0e-8)); } + @Test + void splineInvNiterDiscardsTheRecord() { + assertDiscards(splineMap(), "SplineMap.setInvNiter", m -> m.setInvNiter(20)); + } + + @Test + void splineInvTolDiscardsTheRecord() { + assertDiscards(splineMap(), "SplineMap.setInvTol", m -> m.setInvTol(1.0e-8)); + } + + @Test + void splineOutUnitDiscardsTheRecord() { + assertDiscards(splineMap(), "SplineMap.setOutUnit", m -> m.setOutUnit(true)); + } + @Test void sphUnitRadiusDiscardsTheRecord() { assertDiscards(new SphMap(), "SphMap.setUnitRadius", m -> m.setUnitRadius(true)); @@ -350,6 +367,12 @@ void loadPreservesTheRecordForEveryClearOnSetClass() { poly.setTolInverse(1e-8); assertLoadPreserves(poly, "PolyMap IterInverse"); + SplineMap spline = splineMap(); + spline.setInvNiter(9); + spline.setInvTol(1e-7); + spline.setOutUnit(true); + assertLoadPreserves(spline, "SplineMap InvNiter"); + SphMap sph = new SphMap(); sph.setUnitRadius(true); sph.setPolarLong(0.5); diff --git a/src/test/java/uk/ac/starlink/ast/ConstructorChecksTest.java b/src/test/java/uk/ac/starlink/ast/ConstructorChecksTest.java index c09a070..d36615b 100644 --- a/src/test/java/uk/ac/starlink/ast/ConstructorChecksTest.java +++ b/src/test/java/uk/ac/starlink/ast/ConstructorChecksTest.java @@ -9,8 +9,6 @@ /** * Translation of Rust {@code tests/test_constructor_checks.rs}: constructors and setters refuse * arguments C refuses, with C's status. - * - *

The other tests need classes not yet ported. */ class ConstructorChecksTest { @@ -71,6 +69,35 @@ void aSelectormapNeedsRegionsInOneFrame() { assertEquals(AstException.AST__BADNI, e.getStatus()); } + /** + * splinemap.c astInitSplineMap: an order outside 1 to 6, fewer coefficients than the order, or + * knots that decrease, are AST__ATTIN. + */ + @Test + void aSplinemapChecksItsArguments() { + double[] knots = {0.0, 0.0, 1.0, 1.0}; + double[] coeffs = new double[4]; + new SplineMap(2, 2, 2, 2, knots, knots, coeffs, coeffs); + AstException e = + assertThrows(AstException.class, () -> new SplineMap(0, 2, 2, 2, knots, knots, coeffs, coeffs)); + assertEquals(AstException.AST__ATTIN, e.getStatus()); + e = assertThrows( + AstException.class, + () -> new SplineMap(2, 2, 1, 2, new double[] {0.0, 0.0, 1.0}, knots, new double[2], new double[2])); + assertEquals(AstException.AST__ATTIN, e.getStatus()); + e = assertThrows( + AstException.class, + () -> new SplineMap(2, 2, 2, 2, new double[] {0.0, 1.0, 0.5, 1.0}, knots, coeffs, coeffs)); + assertEquals(AstException.AST__ATTIN, e.getStatus()); + } + + /** unitnormmap.c astInitUnitNormMap: a centre of no axes is AST__BADSM. */ + @Test + void aUnitnormmapNeedsACentre() { + AstException e = assertThrows(AstException.class, () -> new UnitNormMap(0, new double[0])); + assertEquals(AstException.AST__BADSM, e.getStatus()); + } + /** wcsmap.c SetPV: an axis out of range, or one that is not celestial, is AST__AXIIN. */ @Test void aWcsmapPvNeedsACelestialAxis() { diff --git a/src/test/java/uk/ac/starlink/ast/EqualTest.java b/src/test/java/uk/ac/starlink/ast/EqualTest.java index 700fbb6..2bfd1f3 100644 --- a/src/test/java/uk/ac/starlink/ast/EqualTest.java +++ b/src/test/java/uk/ac/starlink/ast/EqualTest.java @@ -23,8 +23,8 @@ * that changes the Invert attribute of a shared component, CmpMaps with Ident set, FrameSets, and * Objects of classes without their own {@code Equal}. * - *

Rust's {@code chebymap_same} and {@code chebymap_different_bounds} need ChebyMap and are listed - * in {@code deferred/rust-tests.txt}. + *

Rust's {@code chebymap_same} and {@code chebymap_different_bounds} take C's answers from the + * case {@code equal_rust} of {@code probes/chebymap_probe.c}. */ class EqualTest { @@ -351,6 +351,38 @@ void polymapDifferentCoeff() { assertAsC("polymap_different_coeff", a.astEqual(b)); } + // ------------------------------------------------------------------ + // ChebyMap + // ------------------------------------------------------------------ + + /** C's answer for the comparison {@code label} of the ChebyMap probe's case {@code equal_rust}. */ + private static void assertAsChebyMapProbe(String label, boolean result) { + String text = ProbeOutput.load("chebymap_probe").get("equal_rust"); + String prefix = "equal " + label + " "; + for (String line : text.split("\n", -1)) { + if (line.startsWith(prefix)) { + assertEquals(line, prefix + (result ? 1 : 0), label); + return; + } + } + throw new IllegalStateException("no probe line " + label); + } + + private static ChebyMap cheby1(double lbnd, double ubnd) { + return new ChebyMap( + 1, 1, 1, new double[] {1.0, 1.0, 1.0}, 0, null, new double[] {lbnd}, new double[] {ubnd}, null, null); + } + + @Test + void chebymapSame() { + assertAsChebyMapProbe("chebymap_same", cheby1(-1.0, 1.0).astEqual(cheby1(-1.0, 1.0))); + } + + @Test + void chebymapDifferentBounds() { + assertAsChebyMapProbe("chebymap_different_bounds", cheby1(-1.0, 1.0).astEqual(cheby1(-2.0, 2.0))); + } + // ------------------------------------------------------------------ // LutMap // ------------------------------------------------------------------ diff --git a/src/test/java/uk/ac/starlink/ast/FitsChanWcsWriteTest.java b/src/test/java/uk/ac/starlink/ast/FitsChanWcsWriteTest.java index ed94968..2e452fc 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsChanWcsWriteTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsChanWcsWriteTest.java @@ -5,9 +5,12 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; import uk.ac.starlink.ast.testsupport.CValues; +import uk.ac.starlink.ast.testsupport.Fixtures; /** * Translation of Rust {@code tests/test_fitschan_wcs_write.rs}: a FrameSet read from a FITS-WCS @@ -18,8 +21,9 @@ * with {@code -GRI} and {@code -GRA} axes read with each encoding and written back, and FrameSets * whose Mapping ends in a GrismMap written FITS-WCS. * - *

Listed in {@code deferred/rust-tests.txt}: the four tests of the {@code lsst2.ast} FrameSet - * (SplineMap). + *

The four tests of the {@code lsst2.ast} FrameSet, whose Mapping holds a SplineMap, are checked + * against C by {@code probes/splinemap_probe.c} too ({@code SplineMapProbeTest}, cases {@code + * fits_lsst2_*}). */ class FitsChanWcsWriteTest { @@ -174,6 +178,112 @@ void aFrameSetWhoseMappingHasNoInverseWritesNothing() { FitsHeaders.foundCards(fc)); } + // ------------------------------------------------------------------ + // SIP descriptions validated over the image: the lsst2.ast FrameSet + // ------------------------------------------------------------------ + + /** + * The FrameSet of {@code wcsconv/inputs/lsst2.ast}, whose pixel to sky Mapping holds a + * SplineMap, so has no exact FITS-WCS description. Its SIP reference point lies some 20000 + * pixels outside the image, and its SplineMap sets OutUnit. + */ + private static FrameSet readLsst2() { + return (FrameSet) ChannelText.read(Fixtures.read("wcsconv/inputs/lsst2.ast")); + } + + /** A FITS-WCS FitsChan holding a 1000 by 1000 image size, with FitsTol {@code tol} if not null. */ + private static FitsChan chanWithDims(Double tol) { + FitsChan fc = new FitsChan(); + fc.setEncoding("FITS-WCS"); + if (tol != null) { + fc.setD("FitsTol", tol); + } + fc.putFits("NAXIS1 = 1000", false); + fc.putFits("NAXIS2 = 1000", false); + return fc; + } + + /** The keywords of the cards {@code fc} holds, in order, without END. */ + private static List keywordsWithoutEnd(FitsChan fc) { + List out = new ArrayList<>(FitsHeaders.keywords(fc)); + out.remove("END"); + return out; + } + + /** + * At a FitsTol tight enough that no linear approximation spans the image, the FrameSet has no + * FITS-WCS description, so the write gives 0 and leaves only the cards it was given (Rust's + * ancestor: testfitschan.c {@code stopit( 906, ... )}). + */ + @Test + void aSplinemapFramesetWritesNothingAtATightFitsTol() { + FitsChan fc = chanWithDims(1.0e-4); + assertEquals(0, fc.write(readLsst2())); + assertEquals(Arrays.asList("NAXIS1", "NAXIS2"), keywordsWithoutEnd(fc)); + } + + /** + * The same FrameSet wrapped as {@code lsst.images}' {@code Transform.as_fits_wcs} writes it, in + * an outer FrameSet whose base Frame carries the FITS one-based origin shift, writes nothing + * either (Rust's ancestor: testfitschan.c {@code stopit( 907, ... )}). + */ + @Test + void theAsFitsWcsWrappingOfASplinemapFramesetAlsoWritesNothing() { + Frame detector = new Frame(2); + detector.set("Ident=detector"); + FrameSet outer = new FrameSet(detector); + outer.addFrame(FrameSet.AST__BASE, readLsst2(), new SkyFrame()); + int sky = outer.getNframe(); + Frame grid = new Frame(2); + grid.setDomain("GRID"); + outer.addFrame(FrameSet.AST__BASE, new ShiftMap(new double[] {1.0, 1.0}), grid); + outer.setBase(outer.getNframe()); + outer.setCurrent(sky); + FitsChan fc = chanWithDims(1.0e-4); + fc.setCDMatrix(true); + assertEquals(0, fc.write(outer)); + } + + /** + * An alternate axis description qualifies a primary one, so a FrameSet whose primary description + * cannot be written writes nothing, though its alternates could be: at the default FitsTol every + * description is written, the new alternate included, and at a tolerance the primary cannot + * meet, none is (C's {@code if( !primok ) break;} in fitschan.c). + */ + @Test + void alternateDescriptionsAreWithheldWhenThePrimaryCannotBeWritten() { + FrameSet fs = readLsst2(); + int sky = fs.getNframe(); + Frame alt = new Frame(2); + alt.setDomain("MYALT"); + alt.set("Ident=A"); + fs.addFrame(FrameSet.AST__BASE, new UnitMap(2), alt); + fs.setCurrent(sky); + + FitsChan fc = chanWithDims(null); + assertEquals(1, fc.write(fs), "the default FitsTol should describe this FrameSet"); + List kw = keywordsWithoutEnd(fc); + assertTrue(kw.contains("CTYPE1A"), kw.toString()); + + fc = chanWithDims(1.0e-4); + assertEquals(0, fc.write(fs), "a failed primary description should write nothing"); + assertEquals(Arrays.asList("NAXIS1", "NAXIS2"), keywordsWithoutEnd(fc)); + } + + /** + * At the default FitsTol the FrameSet has an adequate linear approximation, so the write succeeds + * with a primary axis description and no SIP description (Rust's ancestor: testfitschan.c {@code + * stopit( 908, ... )} and {@code stopit( 909, ... )}). + */ + @Test + void aSplinemapFramesetWritesACompleteHeaderAtTheDefaultFitsTol() { + FitsChan fc = chanWithDims(null); + assertEquals(1, fc.write(readLsst2())); + List kw = keywordsWithoutEnd(fc); + assertTrue(kw.contains("CTYPE1") && kw.contains("CTYPE2"), kw.toString()); + assertFalse(kw.contains("A_ORDER"), kw.toString()); + } + /** Rust's {@code SPECTRAL_HEADER}: a frequency axis in Hz. */ private static final String[] SPECTRAL_HEADER = { "NAXIS = 1 / Number of axes", @@ -351,7 +461,7 @@ private static void cards(List out, FitsChan fc) { /** The probe's {@code fitsrw}: the header read with the encoding, written with it and read back. */ private static String fitsrw(String encoding, String... header) { - List out = new java.util.ArrayList<>(); + List out = new ArrayList<>(); FitsChan fc = FitsHeaders.chan(header); fc.setEncoding(encoding); fc.clear("Card"); @@ -396,7 +506,7 @@ private static String fitsrw(String encoding, String... header) { /** The probe's {@code fitswrite}: a FrameSet from a GRID Frame to the SpecFrame written FITS-WCS. */ private static String fitswrite(Mapping map, String specattrs) { - List out = new java.util.ArrayList<>(); + List out = new ArrayList<>(); Frame grid = new Frame(1); grid.setDomain("GRID"); FrameSet fs = new FrameSet(grid); @@ -447,7 +557,7 @@ private static boolean rateDerived(String line) { */ static boolean grismMatchesC(String got, String want) { List g = CValues.lines(got); - List w = new java.util.ArrayList<>(); + List w = new ArrayList<>(); for (String line : CValues.lines(want)) { if (!line.contains("AST: Error in routine")) { w.add(line); diff --git a/src/test/java/uk/ac/starlink/ast/FitsSipIntWorldTest.java b/src/test/java/uk/ac/starlink/ast/FitsSipIntWorldTest.java index c185eb4..fe98b5f 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsSipIntWorldTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsSipIntWorldTest.java @@ -279,4 +279,55 @@ void sipSuffixFollowsCsBuffer() { assertEquals("RA", store.ctype[0]); assertEquals("DEC--TAN-SIP", store.ctype[1]); } + + /** + * A FrameSet whose pixel to sky Mapping holds a ChebyMap (u = 50 T1(x/50) + 5 T2(x/50), v = 50 + * T1(y/50) + 3 T2(y/50) over [-50, 50]) is not described with SIP coefficients, as in the Rust + * port, so, holding no other PolyMap, it is not written, as C writes no FITS-WCS for the same FrameSet with a MathMap of + * the same transformation in place of the ChebyMap, which this test also writes. C takes the + * ChebyMap as a PolyMap and writes its Chebyshev coefficients as SIP's (A_1_0 = 49, A_2_0 = 5), + * which do not describe it (docs/c-library-bugs.md, "A ChebyMap is written as SIP coefficients + * of powers", whose reproducer chebymap_sip.c writes both FrameSets). + */ + @Test + void aChebyMapIsNotWrittenAsSip() { + double[] fc = {50.0, 1, 1, 0, 5.0, 1, 2, 0, 50.0, 2, 0, 1, 3.0, 2, 0, 2}; + double[] ic = {50.0, 1, 1, 0, -5.0, 1, 2, 0, 50.0, 2, 0, 1, -3.0, 2, 0, 2}; + ChebyMap cm = new ChebyMap( + 2, + 2, + 4, + fc, + 4, + ic, + new double[] {-50.0, -50.0}, + new double[] {50.0, 50.0}, + new double[] {-60.0, -60.0}, + new double[] {60.0, 60.0}); + MathMap mm = new MathMap( + 2, + 2, + new String[] {"u = x + 5*(2*(x/50)*(x/50) - 1)", "v = y + 3*(2*(y/50)*(y/50) - 1)"}, + new String[] {"x = u", "y = v"}); + for (Mapping distortion : new Mapping[] {cm, mm}) { + WcsMap tan = new WcsMap(2, WcsMap.AST__TAN, 1, 2); + tan.invert(); + Mapping m = new CmpMap( + new CmpMap( + new CmpMap(new ShiftMap(new double[] {-50.0, -50.0}), distortion, true), + new ZoomMap(2, 1.0 / 3600 * Math.PI / 180), + true), + tan, + true); + FrameSet fs = new FrameSet(new Frame(2)); + fs.addFrame(FrameSet.AST__BASE, m, new SkyFrame()); + FitsChan fch = new FitsChan(); + fch.putFits("NAXIS1 = 100", false); + fch.putFits("NAXIS2 = 100", false); + fch.setEncoding("FITS-WCS"); + String name = distortion.getClass().getSimpleName(); + assertEquals(0, fch.write(fs), name); + assertEquals(2, fch.getNcard(), name); + } + } } diff --git a/src/test/java/uk/ac/starlink/ast/FrameEqualityTest.java b/src/test/java/uk/ac/starlink/ast/FrameEqualityTest.java index 0a70cdd..1da2c9a 100644 --- a/src/test/java/uk/ac/starlink/ast/FrameEqualityTest.java +++ b/src/test/java/uk/ac/starlink/ast/FrameEqualityTest.java @@ -1,6 +1,7 @@ package uk.ac.starlink.ast; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -56,4 +57,17 @@ void skyframesDifferingInSystemAreNotEqual() { sf2.setSystem("Galactic"); assertFalse(icrs().astEqual(sf2)); } + + /** + * A NormMap followed by the inverse of one whose Frame differs only in Title simplifies to a + * UnitMap, as the Frames are equal (normmap.c {@code MapMerge}). + */ + @Test + void normmapPairOverCosmeticallyDifferentFramesCancels() { + SkyFrame sf2 = icrs(); + sf2.setTitle("A different description"); + NormMap nm2 = new NormMap(sf2); + nm2.invert(); + assertInstanceOf(UnitMap.class, new CmpMap(new NormMap(icrs()), nm2, true).simplify()); + } } diff --git a/src/test/java/uk/ac/starlink/ast/JniastApiTest.java b/src/test/java/uk/ac/starlink/ast/JniastApiTest.java index 492245f..9e01f97 100644 --- a/src/test/java/uk/ac/starlink/ast/JniastApiTest.java +++ b/src/test/java/uk/ac/starlink/ast/JniastApiTest.java @@ -9,7 +9,13 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; +import java.net.JarURLConnection; +import java.net.URISyntaxException; +import java.net.URL; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -18,7 +24,11 @@ import java.util.Map; import java.util.Set; import java.util.TreeSet; +import java.util.function.Predicate; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.junit.jupiter.api.Test; import uk.ac.starlink.ast.testsupport.CValues; import uk.ac.starlink.ast.testsupport.Deferred; @@ -101,8 +111,8 @@ class JniastApiTest { "WinMap", "ZoomMap"); - /** One line of {@code jniast-api.txt}. */ - private static final class Member { + /** One line of {@code jniast-api.txt} or {@code astjava-api.txt}. */ + static final class Member { final String owner; final String kind; final String access; @@ -129,13 +139,15 @@ private static final class Member { } private static List api() throws IOException { + return members(readResource("jniast-api.txt")); + } + + /** The members {@code text} lists, one per line, in the format of {@code jniast-api.txt}; lines starting {@code #} are comments. */ + static List members(String text) { List out = new ArrayList<>(); - try (InputStream in = JniastApiTest.class.getResourceAsStream("/jniast-api.txt")) { - byte[] all = readAll(in); - for (String l : CValues.lines(new String(all, StandardCharsets.UTF_8))) { - if (!CValues.isBlank(l)) { - out.add(new Member(l)); - } + for (String l : CValues.lines(text)) { + if (!CValues.isBlank(l) && !l.startsWith("#")) { + out.add(new Member(l)); } } return out; @@ -467,4 +479,217 @@ void everyPublicMemberIsAJniastMemberOrAListedAddition() throws IOException { stale.isEmpty(), "jniast-api-additions.txt entries naming no such member:\n" + String.join("\n", stale)); } + + // ------------------------------------------------------------------ + // Public classes jniast lacks: astjava-api.txt + // ------------------------------------------------------------------ + + /** + * The public top-level classes and interfaces of the package, read from the directory or JAR + * file holding {@link AstObject}. + */ + static Set publicTypes() throws IOException { + URL url = AstObject.class.getResource("AstObject.class"); + List files = new ArrayList<>(); + if ("file".equals(url.getProtocol())) { + try (Stream list = Files.list(Paths.get(url.toURI()).getParent())) { + list.forEach(f -> files.add(f.getFileName().toString())); + } catch (URISyntaxException e) { + throw new IOException(e); + } + } else if ("jar".equals(url.getProtocol())) { + String dir = PACKAGE.replace('.', '/') + "/"; + try (JarFile jar = ((JarURLConnection) url.openConnection()).getJarFile()) { + for (JarEntry e : Collections.list(jar.entries())) { + String name = e.getName(); + if (name.startsWith(dir) && name.indexOf('/', dir.length()) < 0) { + files.add(name.substring(dir.length())); + } + } + } + } else { + throw new IOException("cannot list the classes at " + url); + } + Set out = new TreeSet<>(); + for (String f : files) { + if (f.endsWith(".class") && f.indexOf('$') < 0 && !"package-info.class".equals(f)) { + String name = f.substring(0, f.length() - ".class".length()); + Class c = lookup(name); + if (c != null && Modifier.isPublic(c.getModifiers())) { + out.add(name); + } + } + } + return out; + } + + /** The types {@code members} lists. */ + private static Set types(List members) { + Set out = new TreeSet<>(); + for (Member m : members) { + if ("type".equals(m.kind)) { + out.add(m.owner); + } + } + return out; + } + + /** The keys of the members, other than types, {@code members} lists, as {@link #additions} keys them. */ + private static Set memberKeys(List members) { + Set out = new TreeSet<>(); + for (Member m : members) { + if (!"type".equals(m.kind)) { + out.add(exclusionKey(m)); + } + } + return out; + } + + /** + * The keys of the public and protected members and nested types {@code c} declares, other than + * those overriding a member of a JDK type or a member one of its superclasses or interfaces in + * the package has in {@code inherited} (keyed by {@link #memberKeys}). + */ + private static Set declaredApi(Class c, Set inherited) { + String owner = jniastName(c); + List supers = new ArrayList<>(); + for (Class k : hierarchy(c)) { + if (k != c && !isJdk(k)) { + supers.add(jniastName(k)); + } + } + Set out = new TreeSet<>(); + for (Class n : c.getDeclaredClasses()) { + if (isApi(n.getModifiers())) { + out.add(jniastName(n)); + } + } + for (Field f : c.getDeclaredFields()) { + if (isApi(f.getModifiers()) && !f.isSynthetic() && !inherited(inherited, supers, f.getName())) { + out.add(owner + "." + f.getName()); + } + } + for (Constructor k : c.getDeclaredConstructors()) { + if (isApi(k.getModifiers()) && !k.isSynthetic()) { + out.add(owner + ".(" + String.join(",", paramNames(k.getParameterTypes())) + ")"); + } + } + for (Method m : c.getDeclaredMethods()) { + if (!isApi(m.getModifiers()) || m.isSynthetic() || m.isBridge() || overridesJdk(c, m)) { + continue; + } + String sig = m.getName() + "(" + String.join(",", paramNames(m.getParameterTypes())) + ")"; + if (!inherited(inherited, supers, sig)) { + out.add(owner + "." + sig); + } + } + return out; + } + + /** + * What is wrong with {@code astjava}, the API of the public classes jniast lacks, given the + * public types of the package and {@code jniast}, jniast's API: a public type in neither list; + * a type in both; a listed type that is not a public class; a public or protected member of a + * listed type that is not listed; and a listed member that does not exist with the type and + * access given. + */ + static List astjavaApiProblems(Set publicTypes, List jniast, List astjava) { + Set jniastTypes = types(jniast); + Set astjavaTypes = types(astjava); + List problems = new ArrayList<>(); + for (String t : publicTypes) { + if (!jniastTypes.contains(t) && !astjavaTypes.contains(t)) { + problems.add("public class " + t + " is in neither jniast-api.txt nor astjava-api.txt"); + } + } + Set listed = memberKeys(astjava); + Set inherited = new TreeSet<>(memberKeys(jniast)); + inherited.addAll(listed); + for (String t : astjavaTypes) { + if (jniastTypes.contains(t)) { + problems.add("astjava-api.txt lists " + t + ", which is a jniast class"); + continue; + } + Class c = lookup(t); + if (c == null || !isApi(c.getModifiers())) { + problems.add("astjava-api.txt lists " + t + ", which is not a public class"); + continue; + } + for (String key : declaredApi(c, inherited)) { + if (!listed.contains(key) && !astjavaTypes.contains(key)) { + problems.add("public member " + key + " is not in astjava-api.txt"); + } + } + } + for (Member m : astjava) { + if ("type".equals(m.kind)) { + continue; + } + Class c = lookup(m.owner); + if (!astjavaTypes.contains(m.owner) || c == null) { + problems.add("astjava-api.txt lists " + m.line + ", a member of a type it does not list"); + } else if (!exists(m, c)) { + problems.add("astjava-api.txt lists " + m.line + ", which does not exist"); + } + } + return problems; + } + + private static List astjavaApi() throws IOException { + return members(readResource("astjava-api.txt")); + } + + @Test + void everyPublicClassIsInAnApiFileWithItsMembers() throws IOException { + List problems = astjavaApiProblems(publicTypes(), api(), astjavaApi()); + assertTrue(problems.isEmpty(), String.join("\n", problems)); + } + + /** {@code astjavaApi()} without the lines {@code drop} matches, with {@code add} appended. */ + private static List edited(Predicate drop, String... add) throws IOException { + List out = new ArrayList<>(); + for (Member m : astjavaApi()) { + if (!drop.test(m.line)) { + out.add(m); + } + } + for (String line : add) { + out.add(new Member(line)); + } + return out; + } + + @Test + void aPublicClassInNeitherFileFails() throws IOException { + List problems = astjavaApiProblems(publicTypes(), api(), edited(l -> l.startsWith("NormMap|"))); + assertEquals( + Collections.singletonList("public class NormMap is in neither jniast-api.txt nor astjava-api.txt"), + problems); + Set types = new TreeSet<>(publicTypes()); + types.add("NoSuchMap"); + assertEquals( + Collections.singletonList("public class NoSuchMap is in neither jniast-api.txt nor astjava-api.txt"), + astjavaApiProblems(types, api(), astjavaApi())); + } + + @Test + void anUnlistedMemberFails() throws IOException { + List problems = astjavaApiProblems( + publicTypes(), api(), edited(l -> "NormMap|constructor|public||(Frame)".equals(l))); + assertEquals( + Collections.singletonList("public member NormMap.(Frame) is not in astjava-api.txt"), problems); + } + + @Test + void aListedMemberThatDoesNotExistFails() throws IOException { + String getter = "NormMap|method|public|Frame|getFrame()"; + String wrongAccess = "UnitNormMap|constructor|protected||(int,double[])"; + List problems = astjavaApiProblems( + publicTypes(), api(), edited(l -> l.startsWith("UnitNormMap|constructor"), getter, wrongAccess)); + assertEquals( + Arrays.asList( + "astjava-api.txt lists " + getter + ", which does not exist", + "astjava-api.txt lists " + wrongAccess + ", which does not exist"), + problems); + } } diff --git a/src/test/java/uk/ac/starlink/ast/MapSplitOracleTest.java b/src/test/java/uk/ac/starlink/ast/MapSplitOracleTest.java index 5e577e0..5b876c3 100644 --- a/src/test/java/uk/ac/starlink/ast/MapSplitOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/MapSplitOracleTest.java @@ -20,7 +20,7 @@ * range with {@code AST__AXIIN}; the others give no split. A split is compared by its outputs and * its dump, byte for byte. * - *

The NormMap cases need a class not yet ported. Rust compares {@code tranmap_full_permuted} + *

Rust compares {@code tranmap_full_permuted} * and {@code ratemap_full_permuted} without their {@code IsSimp} cards, for one card C writes on a * component and the port does not. Here a case whose dump differs from C's only in those cards is * listed in {@link #ISSIMP_COMPONENT_EXCLUDED}, and {@code @@ -57,7 +57,7 @@ private static Mapping inverted(Mapping m) { return m; } - /** The probe's Mapping for a case, by the case name's prefix, or null for one not yet here. */ + /** The probe's Mapping for a case, by the case name's prefix. */ private static Mapping mapping(String name) { if (name.startsWith("unitmap_")) { return new UnitMap(3); @@ -83,7 +83,7 @@ private static Mapping mapping(String name) { } else if (name.startsWith("ratemap_")) { return new RateMap(new ZoomMap(2, 2.0), 1, 1); } else if (name.startsWith("normmap_")) { - return null; + return new NormMap(new Frame(3)); } throw new IllegalArgumentException("no Java construction for case " + name); } @@ -134,9 +134,6 @@ void mapSplitMatchesTheCLibrary() { for (JsonNode c : ProbeData.load("map_split").get("CASES")) { String name = c.get(0).asText(); Mapping map = mapping(name); - if (map == null) { - continue; - } int[] inputs = ints(c.get(1)); String got = outcome(map, inputs); String want = want(c.get(2)); @@ -147,7 +144,7 @@ void mapSplitMatchesTheCLibrary() { ran++; } assertTrue(failures.isEmpty(), String.join("\n", failures)); - assertEquals(60, ran, "cases run"); + assertEquals(66, ran, "cases run"); } /** diff --git a/src/test/java/uk/ac/starlink/ast/MapSplitTest.java b/src/test/java/uk/ac/starlink/ast/MapSplitTest.java index 7ea714e..6f6dabc 100644 --- a/src/test/java/uk/ac/starlink/ast/MapSplitTest.java +++ b/src/test/java/uk/ac/starlink/ast/MapSplitTest.java @@ -17,8 +17,6 @@ * Translation of Rust {@code tests/test_map_split.rs}. Rust's {@code map_split_zero_based} is the * package-private {@code mapSplit(int[])}, C's protected {@code astMapSplit} with zero-based * indices, and Rust's public {@code map_split} is jniast's {@code mapSplit(int[], int[])}. - * - *

The {@code normmap_*} tests need a class not yet ported. */ class MapSplitTest { @@ -764,4 +762,40 @@ void ratemapSplitRejectsWhenInverted() { assertEquals(1, s.map.getNout()); assertNull(split(rm, 1)); } + + // ------------------------------------------------------------------ + // NormMap + // ------------------------------------------------------------------ + + @Test + void normmapSplitPicksAxes() { + MapSplit s = split(new NormMap(new Frame(3)), 0, 2); + assertNotNull(s); + assertArrayEquals(new int[] {0, 2}, s.outputs); + assertEquals(2, s.map.getNin()); + assertEquals(2, s.map.getNout()); + } + + @Test + void normmapSplitFullInputsViaDefault() { + MapSplit s = split(new NormMap(new Frame(3)), 0, 1, 2); + assertNotNull(s); + assertArrayEquals(new int[] {0, 1, 2}, s.outputs); + assertEquals(3, s.map.getNin()); + } + + /** + * normmap.c {@code MapSplit} calls the parent's first (AST__AXIIN for an index out of range) + * and then picks the Frame's axes, which refuses a repeated axis (AST__SELIN). + */ + @Test + void normmapSplitRefusesOutOfRangeAndRepeatedAxes() { + NormMap nm = new NormMap(new Frame(3)); + assertEquals( + AstException.AST__AXIIN, + assertThrows(AstException.class, () -> split(nm, 3)).getStatus()); + assertEquals( + AstException.AST__SELIN, + assertThrows(AstException.class, () -> split(nm, 0, 0)).getStatus()); + } } diff --git a/src/test/java/uk/ac/starlink/ast/MappingBadTest.java b/src/test/java/uk/ac/starlink/ast/MappingBadTest.java new file mode 100644 index 0000000..8a95397 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/MappingBadTest.java @@ -0,0 +1,107 @@ +package uk.ac.starlink.ast; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.fasterxml.jackson.databind.JsonNode; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.ProbeData; + +/** + * Translation of Rust {@code tests/test_mapping_bad.rs}: NormMaps, ShiftMaps and MatrixMaps treat + * bad values as C does. A NormMap normalises every point, so a SkyFrame wraps the longitude of a + * point whose latitude is bad (normmap.c {@code Transform}); a bad shift makes its axis bad + * (shiftmap.c {@code Transform}); and a MatrixMap ignores a bad input where a full matrix's element + * is zero, but not a diagonal one's, and a bad element makes its output bad (matrixmap.c {@code + * Transform}). Each case's forward and inverse transformations equal C's bit for bit, from {@code + * oracle/mapping_bad.json}, through both the bad-value path and the NaN protocol. + */ +class MappingBadTest { + + private static double[] doubles(JsonNode n) { + double[] v = new double[n.size()]; + for (int i = 0; i < v.length; i++) { + v[i] = ProbeData.toDouble(n.get(i)); + } + return v; + } + + /** Points given point by point, {@code n} values each, as {@code [n][npoint]}. */ + private static double[][] points(double[] values, int n) { + int np = values.length / n; + double[][] out = new double[n][np]; + for (int p = 0; p < np; p++) { + for (int c = 0; c < n; c++) { + out[c][p] = values[p * n + c]; + } + } + return out; + } + + /** Points as {@code [ncoord][npoint]}, flattened point by point. */ + private static double[] flat(double[][] pts) { + int np = pts[0].length; + double[] out = new double[np * pts.length]; + for (int p = 0; p < np; p++) { + for (int c = 0; c < pts.length; c++) { + out[p * pts.length + c] = pts[c][p]; + } + } + return out; + } + + private static boolean same(double[] got, double[] want) { + if (got.length != want.length) { + return false; + } + for (int i = 0; i < got.length; i++) { + if (Double.doubleToRawLongBits(got[i]) != Double.doubleToRawLongBits(want[i])) { + return false; + } + } + return true; + } + + @Test + void badValuesMatchTheCLibrary() { + List failures = new ArrayList<>(); + int ran = 0; + for (JsonNode c : ProbeData.load("mapping_bad").get("CASES")) { + String name = c.get(0).asText(); + List lines = new ArrayList<>(); + for (JsonNode l : c.get(1)) { + lines.add(l.asText()); + } + Mapping map = (Mapping) ChannelText.read(ChannelText.text(lines.toArray(new String[0]))); + double[] input = doubles(c.get(2)); + List dirs = new ArrayList<>(); + dirs.add(new Object[] {true, map.getNin(), doubles(c.get(3))}); + if (!c.get(4).isNull()) { + dirs.add(new Object[] {false, map.getNout(), doubles(c.get(4))}); + } + for (Object[] d : dirs) { + boolean forward = (Boolean) d[0]; + int n = (Integer) d[1]; + double[] want = (double[]) d[2]; + double[][] pts = points(input, n); + int np = pts[0].length; + double[] got = flat(map.transform(pts, np, forward)); + if (!same(got, want)) { + failures.add(name + " forward=" + forward + ": " + Arrays.toString(got) + "\n C gives " + + Arrays.toString(want)); + } + got = flat(map.transformNanProtocol(pts, np, forward)); + if (!same(got, want)) { + failures.add(name + " NaN protocol forward=" + forward + ": " + Arrays.toString(got) + + "\n C gives " + Arrays.toString(want)); + } + } + ran++; + } + assertTrue(failures.isEmpty(), String.join("\n", failures)); + assertEquals(7, ran, "cases run"); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/NanOutputsTest.java b/src/test/java/uk/ac/starlink/ast/NanOutputsTest.java index 0757acd..0e81576 100644 --- a/src/test/java/uk/ac/starlink/ast/NanOutputsTest.java +++ b/src/test/java/uk/ac/starlink/ast/NanOutputsTest.java @@ -14,7 +14,7 @@ * NaN input is taken to be bad. Each Mapping is given points with a NaN on one input axis at a * time, and transformed in each direction it defines. * - *

The Rust test's UnitNormMap is a class not yet ported. A DssMap, which the Rust test lacks (its + *

A DssMap, which the Rust test lacks (its * constructor is crate-private, as C's is protected), is read from the C fixture. */ class NanOutputsTest { @@ -50,6 +50,7 @@ private static Map mappings() { m.put("MathMap", new MathMap(2, 2, new String[] {"y1=x1", "y2=x2*2"}, new String[] {"x1=y1", "x2=y2/2"})); m.put("TranMap", new TranMap(new ZoomMap(2, 2.0), new UnitMap(2))); m.put("PolyMap", new PolyMap(2, 2, 2, new double[] {1.0, 1.0, 1.0, 0.0, 2.0, 2.0, 0.0, 1.0}, 0, null)); + m.put("UnitNormMap", new UnitNormMap(2, new double[] {0.5, 0.5})); return m; } diff --git a/src/test/java/uk/ac/starlink/ast/NanProtocolTest.java b/src/test/java/uk/ac/starlink/ast/NanProtocolTest.java index e4d25d2..8723fbb 100644 --- a/src/test/java/uk/ac/starlink/ast/NanProtocolTest.java +++ b/src/test/java/uk/ac/starlink/ast/NanProtocolTest.java @@ -185,6 +185,32 @@ void nanProtocolSpecmap() { assertNanProtocolMatchesTransform(map, fromRows(rows), 32, true, 1e-14); } + @Test + void nanProtocolNormmap() { + // A plain Frame's normalisation does nothing, so this tests the per-point copy and the + // (empty) normalisation. + NormMap map = new NormMap(new Frame(2)); + double[][] rows = new double[32][]; + for (int i = 0; i < 32; i++) { + rows[i] = new double[] {i, -i}; + } + rows[3][0] = BAD; + rows[9][1] = Double.NaN; + assertNanProtocolMatchesTransform(map, fromRows(rows), 32, true, 0.0); + } + + @Test + void nanProtocolUnitnormmap() { + UnitNormMap map = new UnitNormMap(2, new double[] {0.0, 0.0}); + double[][] rows = new double[32][]; + for (int i = 0; i < 32; i++) { + rows[i] = new double[] {i + 1, (i + 1) * 0.5}; + } + rows[5][0] = BAD; + rows[7][1] = Double.NaN; + assertNanProtocolMatchesTransform(map, fromRows(rows), 32, true, 1e-14); + } + @Test void nanProtocolLutmap() { // A 5-entry table covering x in [0, 4]. @@ -216,6 +242,29 @@ void nanProtocolGrismmap() { assertNanProtocolMatchesTransform(map, fromRows(rows), 32, true, 1e-14); } + /** + * A Mapping with no NaN path of its own writes {@link AstObject#AST__BAD} for a bad output; + * inside the NaN protocol that must reach the next stage as bad, not as a number for it to + * scale. + */ + @Test + void nanProtocolCarriesABadOutputOfAMappingWithoutItsOwnNanPath() { + Mapping xph = (Mapping) ChannelText.read( + " Begin XphMap\n Nin = 2\n IsA Mapping\n Order = 3\n Type = \"HPX12\"\n End XphMap\n"); + CmpMap map = new CmpMap(xph, new ZoomMap(2, 0.5), true); + // The first point is outside the projection, so the XphMap makes it bad. + double[][] pts = fromRows(new double[] {1000.0, 1000.0}, new double[] {20.0, 20.0}); + double[][] regular = map.transform(pts, 2, true); + double[][] viaNan = map.transformNanProtocol(pts, 2, true); + assertEquals(BAD, regular[0][0]); + assertEquals(BAD, regular[1][0]); + for (int i = 0; i < 2; i++) { + for (int axis = 0; axis < 2; axis++) { + assertEquals(regular[axis][i], viaNan[axis][i], "point " + i + " axis " + axis); + } + } + } + /** The simplified FrameSet read from {@code lsst.ast}. */ private static Mapping loadLsst() { return LsstOracleTest.loadLsst().simplify(); diff --git a/src/test/java/uk/ac/starlink/ast/NativeRoundTripTest.java b/src/test/java/uk/ac/starlink/ast/NativeRoundTripTest.java index 4fffab8..376784d 100644 --- a/src/test/java/uk/ac/starlink/ast/NativeRoundTripTest.java +++ b/src/test/java/uk/ac/starlink/ast/NativeRoundTripTest.java @@ -55,6 +55,39 @@ void roundTripInvertedWinmapWithIdent() { assertEquals("w1", r.getID()); } + /** A ChebyMap with no inverse and bounds away from [-1, 1]. */ + @Test + void roundTripChebymap() { + double[] c = {1.0, 1, 1, 0, 1.0, 2, 0, 1, 0.05, 1, 0, 1, 0.05, 2, 1, 0, 0.02, 1, 2, 0, 0.02, 2, 0, 2}; + ChebyMap m = new ChebyMap(2, 2, 6, c, 0, null, new double[] {-2.0, -2.0}, new double[] {2.0, 2.0}, null, null); + Mapping r = (Mapping) assertDoubleRoundTrip(m, "ChebyMap (no inv, non-default bounds)"); + assertArrayEquals( + m.tranN(1, 2, new double[] {0.5, -1.5}, true, 2), r.tranN(1, 2, new double[] {0.5, -1.5}, true, 2)); + } + + /** + * A bicubic SplineMap over the unit square (Rust's coefficients, transposed into the order the + * Java constructor takes). + */ + @Test + void roundTripSplinemap() { + int nx = 5; + int ny = 5; + double[] t = {0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 1.0, 1.0, 1.0}; + double[] cu = new double[nx * ny]; + double[] cv = new double[nx * ny]; + for (int i = 0; i < nx; i++) { + for (int j = 0; j < ny; j++) { + cu[j + i * ny] = i / (double) (nx - 1) + 0.05 * j; + cv[j + i * ny] = j / (double) (ny - 1) + 0.05 * i; + } + } + SplineMap m = new SplineMap(4, 4, nx, ny, t, t, cu, cv); + Mapping r = (Mapping) assertDoubleRoundTrip(m, "SplineMap"); + assertArrayEquals( + m.tranN(1, 2, new double[] {0.3, 0.6}, true, 2), r.tranN(1, 2, new double[] {0.3, 0.6}, true, 2)); + } + @Test void roundTripUnitmap() { UnitMap m = new UnitMap(3); @@ -158,6 +191,20 @@ void roundTripRatemap() { assertDoubleRoundTrip(new RateMap(inner, 1, 1), "RateMap"); } + @Test + void roundTripUnitnormmap() { + UnitNormMap m = new UnitNormMap(2, new double[] {0.5, -0.5}); + assertDoubleRoundTrip(m, "UnitNormMap"); + // The text holds the centre, which is not zero. + String text = ChannelText.dump(m); + assertTrue(text.contains("0.5") && text.contains("-0.5"), text); + } + + @Test + void roundTripNormmap() { + assertDoubleRoundTrip(new NormMap(new Frame(2)), "NormMap"); + } + @Test void roundTripPermmap() { PermMap m = new PermMap(3, new int[] {2, -1, 1}, 2, new int[] {3, 1}, new double[] {7.5}); diff --git a/src/test/java/uk/ac/starlink/ast/NormMapProbeTest.java b/src/test/java/uk/ac/starlink/ast/NormMapProbeTest.java new file mode 100644 index 0000000..6b57be4 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/NormMapProbeTest.java @@ -0,0 +1,656 @@ +package uk.ac.starlink.ast; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.ProbeOutput; + +/** + * NormMap and UnitNormMap behaviour against C, from {@code probes/normmap_probe.c}. + * + *

NormMap: the values a NormMap of a SkyFrame, of a CmpFrame holding a SkyFrame and of a plain + * Frame gives for longitudes outside 0 to 2π, latitudes past a pole and points bad on one axis, + * the same in both directions; its dump; its simplification alone (to a UnitMap for a plain Frame + * only), between two other Mappings, next to its inverse, in a run of four and in parallel; its + * split, rate and comparisons; and testnormmap.c's checks. + * + *

UnitNormMap: the unit vector and norm for its own centre, a point one ulp from it, a bad + * coordinate and other points, with one, two and three axes, and the inverse for zero, bad and + * other norms; its dump; its simplification next to ShiftMaps, WinMaps and other UnitNormMaps; + * its comparisons; the constructor's error; and testunitnormmap.c's checks, every value printed. + * + *

Each case writes the lines the probe writes and compares them with C's exactly. C's output + * comes from two builds of the library: {@code normmap_probe.json} from one with the compiler's + * default flags, which contracts a multiply and an add into a fused multiply-add, and {@code + * normmap_probe_nocontract.json} from one built with {@code -ffp-contract=off}. Java never fuses + * them, so a row whose value the contraction changes is listed in {@code deferred/oracle-rows.txt} + * (as {@code probes/normmap_probe/ }, counting the case's {@code fwd} + * or {@code inv} lines from 0) and compared with the second build's value; {@link + * #contractionRowsAreThoseListed} checks that the two builds differ in exactly those rows. + */ +class NormMapProbeTest { + + private static final double BAD = AstObject.AST__BAD; + + private static final String PROBE = "normmap_probe"; + + /** The prefix of this probe's entries in {@code deferred/oracle-rows.txt}. */ + static final String ROWS_PREFIX = "probes/" + PROBE + "/"; + + private static final Map FUSED = ProbeOutput.load(PROBE); + + private static final Map UNFUSED = ProbeOutput.load(PROBE + "_nocontract"); + + // ------------------------------------------------------------------ + // Comparison with the probe + // ------------------------------------------------------------------ + + private static String probeCase(Map cases, String name) { + String text = cases.get(name); + if (text == null) { + throw new IllegalStateException("no probe case " + name); + } + return withoutSource(text); + } + + /** The case without the lines naming the C source of an error, which Java cannot give. */ + private static String withoutSource(String text) { + StringBuilder sb = new StringBuilder(); + for (String line : text.split("\n", -1)) { + if (!line.startsWith("!! ") && !line.isEmpty()) { + sb.append(line).append('\n'); + } + } + return sb.toString(); + } + + /** The rows of {@code name} in direction {@code forward} that {@code oracle-rows.txt} lists. */ + private static Set listedRows(String name, boolean forward) { + String key = TransformOracleTest.sectionKey(ROWS_PREFIX + name, forward); + TransformOracleTest.ExcusedRows rows = + TransformOracleTest.committedOracleRows().get(key); + return rows == null ? Collections.emptySet() : rows.rows; + } + + /** + * The row each line of {@code text} is, as {@code fwd } or {@code inv }, the row being + * the line's place among the case's lines of that direction, or empty for a line that is not a + * transformed point. + */ + private static List rowKinds(String text) { + List out = new ArrayList<>(); + int nfwd = 0; + int ninv = 0; + for (String line : text.split("\n", -1)) { + if (line.startsWith("fwd ")) { + out.add("fwd " + nfwd++); + } else if (line.startsWith("inv ")) { + out.add("inv " + ninv++); + } else { + out.add(""); + } + } + return out; + } + + /** + * What C gives for case {@code name}: the default build's lines, with the unfused build's in + * the rows {@code oracle-rows.txt} lists, which must differ between the two builds. + */ + private static String expected(String name) { + String[] fused = probeCase(FUSED, name).split("\n", -1); + String[] unfused = probeCase(UNFUSED, name).split("\n", -1); + assertEquals(fused.length, unfused.length, name); + Set fwd = listedRows(name, true); + Set inv = listedRows(name, false); + List kinds = rowKinds(probeCase(FUSED, name)); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < fused.length; i++) { + String kind = kinds.get(i); + boolean listed = kind.startsWith("fwd ") + ? fwd.contains(Integer.parseInt(kind.substring(4))) + : kind.startsWith("inv ") && inv.contains(Integer.parseInt(kind.substring(4))); + sb.append(listed ? unfused[i] : fused[i]); + if (i < fused.length - 1) { + sb.append('\n'); + } + } + return sb.toString(); + } + + private static void assertCase(String name, String got) { + assertEquals(expected(name), got, name); + } + + private static String g(double v) { + return CFormat.format("%.17g", v); + } + + private static int flag(boolean b) { + return b ? 1 : 0; + } + + /** The dump of {@code obj}, as the probe's {@code astShow} writes it. */ + private static String show(AstObject obj) { + StringBuilder sb = new StringBuilder(); + for (String l : ChannelText.dump(obj).split("\n", -1)) { + if (!l.isEmpty()) { + sb.append(ProbeOutput.trimLines(l)).append('\n'); + } + } + return sb.toString(); + } + + /** The probe's lines for an error: its message and status. */ + private static String error(AstException e) { + StringBuilder sb = new StringBuilder(); + for (String line : ProbeOutput.trimLines(e.getMsgText()).split("\n", -1)) { + sb.append("! ").append(line).append('\n'); + } + return sb.append("status ").append(e.getStatus()).append('\n').toString(); + } + + /** The transformation of the points {@code in[coord][point]}, one line each. */ + private static String tran(Mapping m, boolean forward, double[]... in) { + int npt = in[0].length; + int nout = forward ? m.getNout() : m.getNin(); + double[][] out = m.tranP(npt, in.length, in, forward, nout); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < npt; i++) { + sb.append(forward ? "fwd" : "inv"); + for (double[] c : in) { + sb.append(' ').append(g(c[i])); + } + sb.append(" ->"); + for (double[] c : out) { + sb.append(' ').append(g(c[i])); + } + sb.append('\n'); + } + return sb.toString(); + } + + private static String both(Mapping m, double[]... in) { + return tran(m, true, in) + tran(m, false, in); + } + + /** The class of the simplified Mapping, whether it is the Mapping itself, and its dump. */ + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) // astSame compares the Objects. + private static String simp(Mapping m) { + Mapping s = m.simplify(); + return "-- simplified " + s.astClass() + " same " + flag(s == m) + "\n" + show(s); + } + + /** The probe's {@code split}: the outputs and dump of the split, or the error. */ + private static String split(Mapping m, int... in) { + int[] out = new int[m.getNout()]; + Mapping sm; + try { + sm = m.mapSplit(in, out); + } catch (AstException e) { + return error(e); + } + if (sm == null) { + return "-- no split\n"; + } + StringBuilder sb = new StringBuilder("-- outputs"); + for (int i = 0; i < sm.getNout(); i++) { + sb.append(' ').append(out[i]); + } + return sb.append('\n').append(show(sm)).toString(); + } + + // ------------------------------------------------------------------ + // The two builds of C + // ------------------------------------------------------------------ + + /** The name {@link #rowKinds} gives the rows of an entry of kind {@code kind}. */ + private static String rowKind(String kind) { + if ("forward".equals(kind)) { + return "fwd"; + } else if ("inverse".equals(kind)) { + return "inv"; + } else { + return kind; + } + } + + /** + * The rows in which the default and unfused builds of C differ are exactly those {@code + * oracle-rows.txt} lists for this probe, so that each listed row is shown to depend on the + * contraction and no other does. + */ + @Test + void contractionRowsAreThoseListed() { + assertEquals(FUSED.keySet(), UNFUSED.keySet()); + Set differing = new TreeSet<>(); + for (String name : FUSED.keySet()) { + String[] fused = probeCase(FUSED, name).split("\n", -1); + String[] unfused = probeCase(UNFUSED, name).split("\n", -1); + assertEquals(fused.length, unfused.length, name); + List kinds = rowKinds(probeCase(FUSED, name)); + for (int i = 0; i < fused.length; i++) { + if (!fused[i].equals(unfused[i])) { + assertFalse(kinds.get(i).isEmpty(), name + ": a line that is not a row differs: " + fused[i]); + differing.add(name + " " + kinds.get(i)); + } + } + } + Set listed = new TreeSet<>(); + for (TransformOracleTest.ExcusedRows x : + TransformOracleTest.committedOracleRows().values()) { + if (x.relpath.startsWith(ROWS_PREFIX)) { + for (int row : x.rows) { + listed.add(x.relpath.substring(ROWS_PREFIX.length()) + " " + rowKind(x.kind) + " " + row); + } + } + } + assertEquals(differing, listed); + assertFalse(listed.isEmpty()); + } + + // ------------------------------------------------------------------ + // NormMap + // ------------------------------------------------------------------ + + private static final double PI = Math.acos(-1.0); + + private static NormMap permuted() { + return NormMapTest.permutedCmpframeNormmap(); + } + + @Test + void normalisesOnASkyFrame() { + double[] lon = {3.0 * PI, -0.5, 7.0, 1.0, 1.0, -1.0, 0.5, 2.0 * PI, -7.5, 100.0, BAD, 1.0, BAD, 0.0, -2.0 * PI}; + double[] lat = {0.25, 0.3, 0.0, 2.0, -2.0, 1.7, 3.5, 0.0, -3.5, -100.0, 0.5, BAD, BAD, 0.0, -0.5 * PI}; + assertCase("nm_sky", both(new NormMap(new SkyFrame()), lon, lat)); + } + + @Test + void normalisesOnACmpFrame() { + double[][] in = { + {2.0, -2.0, 1.6, BAD, 0.5, 3.5, BAD}, + {3.0e4, 5.0, BAD, 1.0, -1.0, 2.0, BAD}, + {1.0, 7.0, -1.0, 7.0, 7.0, -0.5, BAD} + }; + assertCase("nm_cmp_permuted", both(permuted(), in)); + double[][] plain = {{5.0, -1.0, BAD, 1.0e10}, {7.0, -0.5, 7.0, -4.0}, {2.0, -2.0, BAD, 1.6}}; + assertCase("nm_cmp_plain", both(new NormMap(new CmpFrame(new Frame(1), new SkyFrame())), plain)); + } + + @Test + void leavesAPlainFramesValues() { + double[][] in = {{1.0e10, BAD, 7.0}, {-3.0, 2.0, BAD}}; + assertCase("nm_frame", both(new NormMap(new Frame(2)), in)); + } + + @Test + void dumpsAsC() { + NormMap nm = new NormMap(new SkyFrame()); + String text = show(nm); + nm.invert(); + assertCase("nm_dump", text + show(nm)); + } + + @Test + void simplifiesAsC() { + assertCase("nm_simplify_frame", simp(new NormMap(new Frame(2)))); + assertCase("nm_simplify_cmpframe_of_frames", simp(new NormMap(new CmpFrame(new Frame(1), new Frame(1))))); + assertCase("nm_simplify_sky", simp(new NormMap(new SkyFrame()))); + assertCase( + "nm_simplify_between", + simp(new CmpMap( + new CmpMap(new ZoomMap(2, 2.0), new NormMap(new SkyFrame()), true), + new ZoomMap(2, 0.5), + true))); + assertCase( + "nm_simplify_between_frames", + simp(new CmpMap( + new CmpMap(new ZoomMap(2, 2.0), new NormMap(new Frame(2)), true), new ZoomMap(2, 0.5), true))); + + NormMap nm = new NormMap(new SkyFrame()); + Mapping inv = (Mapping) nm.copy(); + inv.invert(); + assertCase("nm_simplify_cancel", simp(new CmpMap(nm, inv, true)) + simp(new CmpMap(inv, nm, true))); + + SkyFrame gal = new SkyFrame(); + gal.setSystem("Galactic"); + NormMap nm2 = new NormMap(gal); + nm2.invert(); + assertCase("nm_simplify_unequal", simp(new CmpMap(new NormMap(new SkyFrame()), nm2, true))); + + NormMap m = permuted(); + assertCase( + "nm_simplify_four", + simp(new CmpMap( + new CmpMap(m, (Mapping) m.copy(), true), new CmpMap(m, (Mapping) m.copy(), true), true))); + + NormMap p = new NormMap(new SkyFrame()); + Mapping pinv = (Mapping) p.copy(); + pinv.invert(); + assertCase("nm_simplify_parallel", simp(new CmpMap(p, pinv, false))); + } + + @Test + void splitsAsC() { + NormMap m = permuted(); + assertCase( + "nm_split", + split(m, 1, 3) + + split(m, 3, 1) + + split(m, 2) + + split(m, 1, 2, 3) + + split(m, 2, 1, 3) + + split(m, 4) + + split(m, 1, 1)); + } + + @Test + void ratesAsC() { + NormMap m = permuted(); + double[] at = {2.0, 3.0e4, 1.0}; + StringBuilder sb = new StringBuilder(); + for (int i = 1; i <= 3; i++) { + for (int j = 1; j <= 3; j++) { + sb.append("rate ") + .append(i) + .append(' ') + .append(j) + .append(' ') + .append(g(m.rate(at, i, j))) + .append('\n'); + } + } + assertCase("nm_rate", sb.toString()); + } + + @Test + void comparesAsC() { + NormMap nm = new NormMap(new SkyFrame()); + NormMap same = new NormMap(new SkyFrame()); + Mapping inv = (Mapping) nm.copy(); + inv.invert(); + NormMap flat = new NormMap(new Frame(2)); + SkyFrame galFrame = new SkyFrame(); + galFrame.setSystem("Galactic"); + NormMap gal = new NormMap(galFrame); + String got = "same " + flag(nm.astEqual(same)) + "\ncopy " + flag(nm.astEqual(nm.copy())) + "\ninverted " + + flag(nm.astEqual(inv)) + "\nplain frame " + flag(nm.astEqual(flat)) + "\ngalactic " + + flag(nm.astEqual(gal)) + "\nunitmap " + flag(flat.astEqual(new UnitMap(2))) + "\n"; + assertCase("nm_equal", got); + } + + @Test + void testnormmapAsC() { + NormMap m = permuted(); + List got = new ArrayList<>(); + got.add("Nin " + m.getNin() + " Nout " + m.getNout() + " TranForward " + flag(m.getTranForward()) + + " TranInverse " + flag(m.getTranInverse())); + Mapping m2 = (Mapping) m.copy(); + m2.invert(); + got.add("cancel " + new CmpMap(m, m2, true).simplify().astClass()); + double[][] bt = m.tranP(1, 3, new double[][] {{2.0}, {3.0e4}, {1.0}}, true, 3); + got.add("tran " + g(bt[0][0]) + " " + g(bt[1][0]) + " " + g(bt[2][0])); + Mapping four = + new CmpMap(new CmpMap(m, (Mapping) m.copy(), true), new CmpMap(m, (Mapping) m.copy(), true), true); + got.add("four " + four.simplify().astClass()); + got.add("frame " + new NormMap(new Frame(2)).simplify().astClass()); + assertCase("testnormmap", String.join("\n", got) + "\n"); + } + + // ------------------------------------------------------------------ + // UnitNormMap + // ------------------------------------------------------------------ + + @Test + void twoAxesAsC() { + double[][] fwd = { + {1.0, Math.nextAfter(1.0, 2.0), 1.0, Math.nextAfter(1.0, 0.0), 5.0, BAD, 1.0, 1.0e300, -3.0, 1.0e-300}, + {-1.0, -1.0, Math.nextAfter(-1.0, -2.0), Math.nextAfter(-1.0, 0.0), 2.0, 2.0, BAD, -1.0e300, 2.0, -1.0} + }; + double[][] inv = { + {0.8, 0.6, 999.0, BAD, 0.6, BAD, 0.6, 0.6, 0.3, -0.7071067811865475}, + {0.6, 0.8, -42.0, 0.8, 0.8, BAD, BAD, 0.8, 0.4, -0.7071067811865475}, + {5.0, 0.0, 0.0, 5.0, BAD, 0.0, 0.0, -5.0, 1.0e300, 7.0710678118654755} + }; + UnitNormMap m = new UnitNormMap(2, new double[] {1.0, -1.0}); + assertCase("unm_2d", tran(m, true, fwd) + tran(m, false, inv)); + } + + @Test + void oneAxisAsC() { + double[][] fwd = {{2.0, Math.nextAfter(2.0, 3.0), Math.nextAfter(2.0, 1.0), 5.0, -1.0, BAD, 1.0e308}}; + double[][] inv = {{1.0, -1.0, 5.0, BAD, 1.0, BAD, 0.5}, {3.0, 3.0, 0.0, 0.0, BAD, 3.0, 4.0}}; + UnitNormMap m = new UnitNormMap(1, new double[] {2.0}); + assertCase("unm_1d", tran(m, true, fwd) + tran(m, false, inv)); + } + + @Test + void threeAxesAsC() { + double[][] fwd = { + {-1.0, Math.nextAfter(-1.0, 0.0), -22.0, BAD, 0.0, -1.0}, + {1.0, 1.0, 3.0, 1.0, 0.0, 1.0}, + {2.0, 2.0, 0.5, 2.0, 0.0, Math.nextAfter(2.0, 3.0)} + }; + double[][] inv = { + {0.6, 1.0, BAD, 0.1, -0.9538200416655874}, + {0.8, 0.0, 0.0, 0.2, 0.0908400039681512}, + {0.0, 0.0, 0.0, 0.3, -0.28614601249967625}, + {5.0, 0.0, 1.0, 1.0e-300, 22.01136070305997} + }; + UnitNormMap m = new UnitNormMap(3, new double[] {-1.0, 1.0, 2.0}); + assertCase("unm_3d", tran(m, true, fwd) + tran(m, false, inv)); + } + + /** + * Fixture {@code neg_unitnormmap_inv_fwd_diffcentre}'s inverse at its zero sample: the inverse + * of the second UnitNormMap lands on the centre of the first exactly only when its multiply-add + * is not fused. + */ + @Test + void inverseThroughAnotherCentreAsC() { + double[][] inv = { + {-0.7071067811865475, 0.7071067811865475}, + {-0.7071067811865475, 0.7071067811865475}, + {7.0710678118654755, 1414206.4913052833} + }; + UnitNormMap a = new UnitNormMap(2, new double[] {0.0, 1.0}); + a.invert(); + UnitNormMap b = new UnitNormMap(2, new double[] {5.0, 6.0}); + assertCase("unm_inv_fwd_diffcentre", tran(new CmpMap(a, b, true), false, inv)); + assertCase("unm_inv_diffcentre_second", tran(b, false, inv)); + } + + @Test + void unitNormMapDumpsAsC() { + UnitNormMap m = new UnitNormMap(3, new double[] {1.5, -2.0, 0.0}); + String text = show(m); + m.invert(); + assertCase("unm_dump", text + show(m)); + } + + @Test + void unitNormMapSimplifiesAsC() { + double[] sh = {3.0, -1.0}; + double[] zero = {0.0, 0.0}; + double[] one = {1.0, 1.0}; + UnitNormMap u1 = new UnitNormMap(2, new double[] {1.0, 2.0}); + Mapping u1i = (Mapping) u1.copy(); + u1i.invert(); + UnitNormMap u2 = new UnitNormMap(2, new double[] {4.0, 6.0}); + Mapping u2i = (Mapping) u2.copy(); + u2i.invert(); + ShiftMap shift = new ShiftMap(sh); + Mapping shifti = (Mapping) shift.copy(); + shifti.invert(); + WinMap win1 = new WinMap(2, zero, one, sh, new double[] {4.0, 0.0}); + WinMap win2 = new WinMap(2, zero, one, sh, new double[] {5.0, 0.0}); + Mapping win1i = (Mapping) win1.copy(); + win1i.invert(); + assertCase("unm_simplify_shift_fwd", simp(new CmpMap(shift, u2, true))); + assertCase("unm_simplify_shift_inverted_fwd", simp(new CmpMap(shifti, u2, true))); + assertCase("unm_simplify_fwd_shift", simp(new CmpMap(u1, new ShiftMap(new double[] {1.0, 2.0, 3.0}), true))); + assertCase("unm_simplify_inv_shift", simp(new CmpMap(u1i, shift, true))); + assertCase("unm_simplify_inv_shift_inverted", simp(new CmpMap(u1i, shifti, true))); + assertCase("unm_simplify_win_fwd", simp(new CmpMap(win1, u1, true))); + assertCase("unm_simplify_win_inverted_fwd", simp(new CmpMap(win1i, u1, true))); + assertCase("unm_simplify_win_nonunit_fwd", simp(new CmpMap(win2, u1, true))); + assertCase("unm_simplify_inv_win", simp(new CmpMap(u1i, win1, true))); + assertCase("unm_simplify_inv_win_nonunit", simp(new CmpMap(u1i, win2, true))); + assertCase("unm_simplify_fwd_inv_same", simp(new CmpMap(u1, u1i, true))); + assertCase("unm_simplify_inv_fwd_same", simp(new CmpMap(u1i, u1, true))); + assertCase("unm_simplify_fwd_inv_diff", simp(new CmpMap(u1, u2i, true))); + assertCase("unm_simplify_inv_fwd_diff", simp(new CmpMap(u1i, u2, true))); + assertCase("unm_simplify_parallel", simp(new CmpMap(u1, u1i, false))); + assertCase( + "unm_simplify_shift_zoom_unm", + simp(new CmpMap(new CmpMap(new ZoomMap(2, 3.0), shift, true), u1, true))); + assertCase("unm_simplify_unm_later_pair", simp(new CmpMap(new CmpMap(u1, new UnitMap(3), true), u1i, true))); + + // unitnormmap.c's MakeMergedMap compares with its own EQUAL macro, 1.0E9 epsilons. + UnitNormMap u3i = new UnitNormMap(2, new double[] {1.0, 2.0 + 2.0e-7}); + u3i.invert(); + assertCase("unm_simplify_near_centres", simp(new CmpMap(u1, u3i, true))); + WinMap win3 = new WinMap(2, zero, one, sh, new double[] {3.0 + 1.00000001, -1.0 + 1.00000001}); + assertCase("unm_simplify_win_near_unit", simp(new CmpMap(win3, u1, true))); + } + + @Test + void unitNormMapComparesAsC() { + UnitNormMap a = new UnitNormMap(2, new double[] {1.0, 2.0}); + Mapping ai = (Mapping) a.copy(); + ai.invert(); + String got = "same " + flag(a.astEqual(new UnitNormMap(2, new double[] {1.0, 2.0}))) + "\ncentre " + + flag(a.astEqual(new UnitNormMap(2, new double[] {1.0, 3.0}))) + "\ndimension " + + flag(a.astEqual(new UnitNormMap(3, new double[] {1.0, 2.0, 0.0}))) + "\ninverted " + + flag(a.astEqual(ai)) + "\nboth inverted " + flag(ai.astEqual(ai.copy())) + "\none ulp " + + flag(a.astEqual(new UnitNormMap(2, new double[] {1.0, Math.nextAfter(2.0, 3.0)}))) + "\n"; + assertCase("unm_equal", got); + } + + @Test + void aUnitNormMapNeedsAnAxisAsC() { + AstException e = assertThrows(AstException.class, () -> new UnitNormMap(0, new double[] {0.0})); + assertCase("unm_error_no_axes", error(e)); + } + + /** testunitnormmap.c's {@code differ}. */ + private static boolean differ(double aa, double bb) { + double diff = Math.abs(aa - bb); + double tol = Math.abs(0.5 * (aa + bb)) * 1.0e-14; + if (tol < 1.0e-14) { + tol = 1.0e-14; + } + return diff > tol; + } + + /** testunitnormmap.c's {@code checkroundtrip}. */ + private static int roundtrip(Mapping map, double[] pos) { + int good = 1; + int nin = map.getNin(); + int nout = map.getNout(); + double[][] p = new double[nin][1]; + for (int i = 0; i < nin; i++) { + p[i][0] = pos[i]; + } + double[][] out = map.tranP(1, nin, p, true, nout); + double[][] in = map.tranP(1, nout, out, false, nin); + for (int i = 0; i < nin; i++) { + if (differ(in[i][0], pos[i])) { + good = 0; + } + } + Mapping mapinv = (Mapping) map.copy(); + mapinv.invert(); + in = new CmpMap(map, mapinv, true).tranP(1, nin, p, true, nin); + for (int i = 0; i < nin; i++) { + if (differ(in[i][0], pos[i])) { + good = 0; + } + } + return good; + } + + @Test + void testunitnormmapAsC() { + double[] centre = {-1.0, 1.0, 2.0}; + double[] frompos = {-22.0, 3.0, 0.5}; + List got = new ArrayList<>(); + for (int nin = 1; nin <= 3; nin++) { + UnitNormMap map = new UnitNormMap(nin, centre); + got.add("nin " + nin + " Nin " + map.getNin() + " Nout " + map.getNout() + " IsLinear " + + flag(map.isLinear())); + got.add("roundtrip " + roundtrip(map, frompos) + " centre " + roundtrip(map, centre)); + Mapping invmap = (Mapping) map.copy(); + invmap.invert(); + Mapping smap = new CmpMap(map, invmap, true).simplify(); + got.add("fwd inv " + smap.astClass() + " " + smap.getNin()); + smap = new CmpMap(invmap, map, true).simplify(); + got.add("inv fwd " + smap.astClass() + " " + smap.getNin()); + double[][] p = new double[nin][1]; + for (int i = 0; i < nin; i++) { + p[i][0] = frompos[i]; + } + double[][] topos = map.tranP(1, nin, p, true, nin + 1); + String tran = "tran"; + for (int i = 0; i <= nin; i++) { + tran = tran.concat(" ").concat(g(topos[i][0])); + } + got.add(tran); + } + assertCase("testunitnormmap", String.join("\n", got) + "\n"); + } + + @Test + void testsimplifyAsC() { + double[] centre1 = {2.0, -1.0, 0.0}; + double[] centre2 = {-1.0, 6.0, 4.0}; + double[] shift = {3.0, 7.0, -9.0}; + double[] zeros = {0.0, 0.0, 0.0}; + double[] ones = {1.0, 1.0, 1.0}; + double[][] testpoints = {{1.0, 3.0, -5.0}, {2.0, 3.0, 99.0}, {-6.0, -5.0, -7.0}, {30.0, 21.0, 37.0}}; + UnitNormMap unm1 = new UnitNormMap(3, centre1); + Mapping unm1inv = (Mapping) unm1.copy(); + unm1inv.setInvert(true); + UnitNormMap unm2 = new UnitNormMap(3, centre2); + Mapping unm2inv = (Mapping) unm2.copy(); + unm2inv.setInvert(true); + ShiftMap shiftmap = new ShiftMap(shift); + double[] a = new double[3]; + for (int i = 0; i < 3; i++) { + a[i] = ones[i] + shift[i]; + } + WinMap winmap1 = new WinMap(3, zeros, shift, ones, a); + for (int i = 0; i < 3; i++) { + a[i] = 2 * ones[i] + shift[i]; + } + WinMap winmap2 = new WinMap(3, zeros, shift, ones, a); + Mapping[][] pairs = { + {unm1, unm2inv}, + {shiftmap, unm2}, + {winmap1, unm1}, + {winmap2, unm1}, + {unm1inv, shiftmap}, + {unm1inv, winmap1}, + {unm1inv, winmap2} + }; + for (int i = 0; i < pairs.length; i++) { + CmpMap cmp = new CmpMap(pairs[i][0], pairs[i][1], true); + Mapping s = cmp.simplify(); + int nin = cmp.getNin(); + double[][] in = new double[nin][]; + System.arraycopy(testpoints, 0, in, 0, nin); + String got = "-- " + s.astClass() + " Nin " + nin + " " + s.getNin() + " Nout " + cmp.getNout() + " " + + s.getNout() + "\n" + tran(cmp, true, in) + "-- simplified\n" + tran(s, true, in); + assertCase("testsimplify_" + i, got); + } + } +} diff --git a/src/test/java/uk/ac/starlink/ast/NormMapTest.java b/src/test/java/uk/ac/starlink/ast/NormMapTest.java new file mode 100644 index 0000000..2d6293b --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/NormMapTest.java @@ -0,0 +1,206 @@ +package uk.ac.starlink.ast; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static uk.ac.starlink.ast.MappingTestData.fromRows; +import static uk.ac.starlink.ast.MappingTestData.point; +import static uk.ac.starlink.ast.MappingTestData.transformRows; + +import org.junit.jupiter.api.Test; + +/** + * Translation of Rust {@code tests/test_normmap.rs} (C's {@code normmap.c} and {@code + * testnormmap.c}): a NormMap normalises with its Frame in both directions, passes bad values to the + * Frame, cancels with its inverse, merges with an equal NormMap, becomes a UnitMap when its Frame + * is a plain Frame, has unit rates, and is written and read back. {@code NormMapProbeTest} holds + * the values C gives. + */ +class NormMapTest { + + private static final double BAD = AstObject.AST__BAD; + + @Test + void normmapBasicConstruction() { + NormMap nm = new NormMap(new SkyFrame()); + assertEquals(2, nm.getNin()); + assertEquals(2, nm.getNout()); + assertTrue(nm.getTranForward()); + assertTrue(nm.getTranInverse()); + assertFalse(nm.getInvert()); + } + + @Test + void normmapSkyframeNormalisation() { + NormMap nm = new NormMap(new SkyFrame()); + double[] out = point(transformRows(nm, true, new double[] {3.0 * Math.PI, 0.25}), 0); + assertTrue(out[0] >= 0.0 && out[0] <= 2.0 * Math.PI, "lon = " + out[0]); + assertEquals(Math.PI, out[0], 1e-10); + assertEquals(0.25, out[1], 1e-10); + } + + @Test + void normmapForwardEqualsInverse() { + NormMap nm = new NormMap(new SkyFrame()); + double[] fwd = point(transformRows(nm, true, new double[] {-0.5, 0.3}), 0); + double[] inv = point(transformRows(nm, false, new double[] {-0.5, 0.3}), 0); + assertEquals(fwd[0], inv[0], 1e-15); + assertEquals(fwd[1], inv[1], 1e-15); + } + + @Test + void normmapBadValuePropagation() { + NormMap nm = new NormMap(new SkyFrame()); + double[][] out = + transformRows(nm, true, new double[] {BAD, 0.5}, new double[] {1.0, BAD}, new double[] {BAD, BAD}); + assertEquals(BAD, point(out, 0)[0]); + assertEquals(BAD, point(out, 1)[1]); + assertEquals(BAD, point(out, 2)[0]); + assertEquals(BAD, point(out, 2)[1]); + } + + @Test + void normmapBasicFrameSimplifiesToUnit() { + Mapping simplified = new NormMap(new Frame(3)).simplify(); + assertInstanceOf(UnitMap.class, simplified); + assertEquals(3, simplified.getNin()); + assertEquals(3, simplified.getNout()); + } + + @Test + void normmapInverseCancel() { + NormMap nm1 = new NormMap(new SkyFrame()); + NormMap nm2 = new NormMap(new SkyFrame()); + nm2.invert(); + assertInstanceOf(UnitMap.class, new CmpMap(nm1, nm2, true).simplify()); + } + + @Test + void normmapDuplicateElimination() { + NormMap nm1 = new NormMap(new SkyFrame()); + NormMap nm2 = new NormMap(new SkyFrame()); + assertInstanceOf(NormMap.class, new CmpMap(nm1, nm2, true).simplify()); + } + + @Test + void normmapEqual() { + NormMap nm1 = new NormMap(new SkyFrame()); + NormMap nm2 = new NormMap(new SkyFrame()); + assertTrue(nm1.astEqual(nm2)); + NormMap nm3 = new NormMap(new SkyFrame()); + nm3.invert(); + assertFalse(nm1.astEqual(nm3)); + assertFalse(nm1.astEqual(new NormMap(new Frame(2)))); + } + + @Test + void normmapSerializationRoundtrip() { + NormMap nm = new NormMap(new SkyFrame()); + String text = ChannelText.dump(nm); + assertTrue(text.contains("NormMap")); + assertTrue(text.contains("SkyFrame")); + Mapping back = (Mapping) ChannelText.read(text); + assertTrue(nm.astEqual(back)); + } + + @Test + void normmapRate() { + NormMap nm = new NormMap(new SkyFrame()); + double[] at = {1.0, 0.5}; + assertEquals(1.0, nm.rate(at, 1, 1)); + assertEquals(1.0, nm.rate(at, 2, 2)); + assertEquals(0.0, nm.rate(at, 1, 2)); + assertEquals(0.0, nm.rate(at, 2, 1)); + } + + @Test + void normmapInvertedTransform() { + NormMap nm = new NormMap(new SkyFrame()); + nm.invert(); + assertEquals(Math.PI, point(transformRows(nm, true, new double[] {3.0 * Math.PI, 0.1}), 0)[0], 1e-10); + assertEquals(Math.PI, point(transformRows(nm, false, new double[] {3.0 * Math.PI, 0.1}), 0)[0], 1e-10); + } + + @Test + void normmapMultiplePoints() { + NormMap nm = new NormMap(new SkyFrame()); + double[][] out = transformRows( + nm, + true, + new double[] {0.0, 0.0}, + new double[] {Math.PI, 0.5}, + new double[] {2.0 * Math.PI + 0.1, -0.3}, + new double[] {-0.1, 0.0}); + assertEquals(0.0, point(out, 0)[0], 1e-10); + assertEquals(Math.PI, point(out, 1)[0], 1e-10); + assertEquals(0.1, point(out, 2)[0], 1e-10); + assertEquals(2.0 * Math.PI - 0.1, point(out, 3)[0], 1e-10); + } + + /** + * The NormMap testnormmap.c builds: on a CmpFrame of a SpecFrame and a SkyFrame (C's defaults, + * wavelength and ICRS), with its axes permuted to the order 3, 1, 2: sky latitude, wavelength, + * sky longitude. + */ + static NormMap permutedCmpframeNormmap() { + CmpFrame f = new CmpFrame(new SpecFrame(), new SkyFrame()); + f.permAxes(new int[] {3, 1, 2}); + return new NormMap(f); + } + + /** + * testnormmap.c Errors 1-9: dimensions, both directions defined, cancellation against the + * inverse, normalisation of a latitude past the pole across the permuted axes, and four copies + * in series reducing to one. + */ + @Test + void normmapOnAPermutedCmpframe() { + NormMap m = permutedCmpframeNormmap(); + assertEquals(3, m.getNin(), "Error 1"); + assertEquals(3, m.getNout(), "Error 2"); + assertTrue(m.getTranForward(), "Error 3"); + assertTrue(m.getTranInverse(), "Error 4"); + + Mapping m2 = (Mapping) m.copy(); + m2.invert(); + assertInstanceOf(UnitMap.class, new CmpMap(m, m2, true).simplify(), "Error 5"); + + // Axis 1 is the sky latitude, 2 the wavelength and 3 the longitude: a latitude of 2 rad is + // past the pole, so it folds to pi - 2 and the longitude moves round by pi. + double[][] out = m.tranP(1, 3, fromRows(new double[] {2.0, 3.0e4, 1.0}), true, 3); + assertEquals(1.14159265, out[0][0], 1.0e-6, "Error 6"); + assertEquals(3.0e4, out[1][0], "Error 7"); + assertEquals(4.14159265, out[2][0], 1.0e-6, "Error 8"); + + Mapping four = new CmpMap( + new CmpMap((Mapping) m.copy(), (Mapping) m.copy(), true), + new CmpMap((Mapping) m.copy(), (Mapping) m.copy(), true), + true); + assertInstanceOf(NormMap.class, four.simplify(), "Error 9"); + } + + // ------------------------------------------------------------------ + // Loading (not in the Rust tests) + // ------------------------------------------------------------------ + + private static int loadError(String text) { + return assertThrows(AstException.class, () -> ChannelText.read(text)).getStatus(); + } + + /** + * A description without a Frame, or whose Frame has other than one axis per input and output, + * is refused. The pinned C stores what it reads: without a Frame its transformation fails, and + * with three inputs and outputs and a 2-axis Frame it transforms, normalising the Frame's two + * axes, but its merge and split take the NormMap to have two. + */ + @Test + void loadingRefusesAMissingOrMismatchedFrame() { + String noFrame = " Begin NormMap\n Nin = 2\n IsA Mapping\n End NormMap\n"; + assertEquals(AstException.AST__LDERR, loadError(noFrame)); + String text = ChannelText.dump(new NormMap(new Frame(2))); + assertEquals(AstException.AST__LDERR, loadError(text.replace(" Nin = 2", " Nin = 3"))); + assertInstanceOf(NormMap.class, ChannelText.read(text)); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/NumericRateTest.java b/src/test/java/uk/ac/starlink/ast/NumericRateTest.java index b4920a1..23846cf 100644 --- a/src/test/java/uk/ac/starlink/ast/NumericRateTest.java +++ b/src/test/java/uk/ac/starlink/ast/NumericRateTest.java @@ -13,10 +13,40 @@ * *

{@code numericRateMatchesTheTanDerivatives} is not in the Rust file: it checks the rates of a * TAN WcsMap, which is nonlinear, against its derivatives, which they match to within 3e-8 - * relative. The {@code numeric_rate_chebymap_*} tests need a ChebyMap, which is not yet ported. + * relative. */ class NumericRateTest { + /** + * 3 T1(x) over [-1, 1] is 3x: the rate is 3, at 0 as well, where the interval C starts from is + * small enough to keep the samples inside the ChebyMap's box (probe case {@code t_rate}). + */ + @Test + void numericRateChebymapQuadratic() { + ChebyMap m = new ChebyMap( + 1, 1, 1, new double[] {3.0, 1.0, 1.0}, 0, null, new double[] {-1.0}, new double[] {1.0}, null, null); + assertEquals(3.0, m.rate(new double[] {0.5}, 1, 1), 1e-4, "chebymap linear rate at x=0.5"); + assertEquals(3.0, m.rate(new double[] {0.0}, 1, 1), 1e-4, "chebymap linear rate at x=0"); + } + + /** x^3 = (3 T1(x) + T3(x)) / 4 over [-1, 1]: the rate is 0.75 at 0.5 and 0 at 0. */ + @Test + void numericRateChebymapCubic() { + ChebyMap m = new ChebyMap( + 1, + 1, + 2, + new double[] {0.75, 1.0, 1.0, 0.25, 1.0, 3.0}, + 0, + null, + new double[] {-1.0}, + new double[] {1.0}, + null, + null); + assertEquals(0.75, m.rate(new double[] {0.5}, 1, 1), 1e-3, "chebymap cubic rate at x=0.5"); + assertTrue(Math.abs(m.rate(new double[] {0.0}, 1, 1)) < 1e-4, "chebymap cubic rate at x=0"); + } + @Test void numericRateLinearMapping() { ZoomMap zoom = new ZoomMap(2, 3.0); diff --git a/src/test/java/uk/ac/starlink/ast/ObjectIdOracleTest.java b/src/test/java/uk/ac/starlink/ast/ObjectIdOracleTest.java index ba45fa1..69db194 100644 --- a/src/test/java/uk/ac/starlink/ast/ObjectIdOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/ObjectIdOracleTest.java @@ -26,13 +26,15 @@ * frame}, {@code skyframe}, {@code frameset}, {@code frameset_frame_id}, {@code * frameset_part_ids}, {@code cmpframe}, {@code fitschan}, {@code cmpmap_unsimplifiable}, {@code * tranmap}, {@code ratemap}, {@code circle}, {@code cmpregion}, {@code cmpregion_part_ids}, - * {@code prism}, {@code prism_part_ids}, {@code selectormap} and {@code selectormap_part_ids}. + * {@code prism}, {@code prism_part_ids}, {@code selectormap}, {@code selectormap_part_ids} and + * {@code normmap}: every case of the file. * {@code simplify} returns the ZoomMap itself, as C's {@code astSimplify} returns a Mapping it cannot simplify, recording it as * simplified, and a CmpMap shares its components, as C's does, so the Rust test's exclusions for * copies do not arise for them. A case whose dump differs from C's is listed in {@link #EXCLUDED}, * and {@code excluded_cases_still_differ} fails when it matches. A SelectorMap copies its Regions, * as C's does, so their IDs are not in its dump, and {@code selectormap_part_ids}, which the Rust - * test excludes, matches C. The remaining cases need NormMap, which is not in jniast. + * test excludes, matches C. A NormMap holds the Frame it is given, as C's {@code astClone} does, + * so the Frame's ID is in its dump. */ class ObjectIdOracleTest { @@ -63,7 +65,8 @@ class ObjectIdOracleTest { "prism", "prism_part_ids", "selectormap", - "selectormap_part_ids"); + "selectormap_part_ids", + "normmap"); /** The cases whose dump differs from C's, with the reason. */ private static final String[][] EXCLUDED = {}; @@ -202,6 +205,11 @@ private static AstObject object(String name) { t.setID("t"); return t; } + case "normmap": { + NormMap n = new NormMap(frame(2, "nf")); + n.setID("n"); + return n; + } case "ratemap": { RateMap r = new RateMap(zoom(2.0, "rz"), 1, 1); r.setID("r"); diff --git a/src/test/java/uk/ac/starlink/ast/PolyBadTest.java b/src/test/java/uk/ac/starlink/ast/PolyBadTest.java index dbf2903..9c163d5 100644 --- a/src/test/java/uk/ac/starlink/ast/PolyBadTest.java +++ b/src/test/java/uk/ac/starlink/ast/PolyBadTest.java @@ -11,13 +11,12 @@ import uk.ac.starlink.ast.testsupport.ProbeData; /** - * Translation of Rust {@code tests/test_poly_bad.rs}: PolyMaps treat bad values as C does - * (polymap.c {@code Transform} and {@code PolyPowers}): a bad or NaN input spoils only the terms - * that use a power of it above zero, and a bad coefficient spoils its output, so outputs that use - * none of these stay good. Each case's forward and inverse transformations equal C's bit for bit, - * from {@code oracle/poly_bad.json}, through both the bad-value path and the NaN protocol. - * - *

The ChebyMap cases ({@code chebymap_*}) need a class outside the first phase. + * Translation of Rust {@code tests/test_poly_bad.rs}: PolyMaps and ChebyMaps treat bad values as C + * does (polymap.c {@code Transform} and {@code PolyPowers}, chebymap.c {@code PolyPowers}): a bad + * or NaN input, or a ChebyMap input outside its bounding box, spoils only the terms that use a + * power of it above zero, and a bad coefficient spoils its output, so outputs that use none of + * these stay good. Each case's forward and inverse transformations equal C's bit for bit, from + * {@code oracle/poly_bad.json}, through both the bad-value path and the NaN protocol. */ class PolyBadTest { @@ -71,9 +70,6 @@ void badValuesMatchTheCLibrary() { int ran = 0; for (JsonNode c : ProbeData.load("poly_bad").get("CASES")) { String name = c.get(0).asText(); - if (!name.startsWith("polymap_")) { - continue; - } List lines = new ArrayList<>(); for (JsonNode l : c.get(1)) { lines.add(l.asText()); @@ -105,6 +101,6 @@ void badValuesMatchTheCLibrary() { ran++; } assertTrue(failures.isEmpty(), String.join("\n", failures)); - assertEquals(4, ran, "cases run"); + assertEquals(6, ran, "cases run"); } } diff --git a/src/test/java/uk/ac/starlink/ast/PolyMapTest.java b/src/test/java/uk/ac/starlink/ast/PolyMapTest.java index 743b10f..8e351b5 100644 --- a/src/test/java/uk/ac/starlink/ast/PolyMapTest.java +++ b/src/test/java/uk/ac/starlink/ast/PolyMapTest.java @@ -646,20 +646,24 @@ private static String invertAttrs(String when, Mapping p, Mapping q) { } /** - * A PolyMap that cancels against its neighbour is left with the Invert attribute the list - * applied it with, as in C: polymap.c {@code MapMerge} sets the nominated PolyMap's Invert - * attribute to the list's value and sets it back only when the pair does not cancel. The - * inverted series CmpMap applies the copy, which is inverted, forward, so the copy is left with - * Invert 0 (docs/rust-c-differences.md, "Cancelling a PolyMap with its inverse"). The neighbour's - * Invert attribute is put back as it was, set or unset, where C's {@code astSetInvert} leaves it - * set, so the PolyMap compared with the copy is not set afterwards. + * Simplifying a series CmpMap of a PolyMap and an inverted copy of it, and the inverse of that + * CmpMap, leaves both PolyMaps, which the CmpMap shares and the caller holds, as they were: each + * Invert attribute is put back as it was, set or unset. C's polymap.c {@code MapMerge} at the + * pin leaves the cancelled PolyMap with the value the list applied it with (so the copy ends + * with Invert 0 in the inverted series), and every Invert attribute it compared set + * (docs/rust-c-differences.md, "Cancelling a PolyMap with its inverse"); the hardening PR + * (Starlink/ast #104) sets the cancelled PolyMap back. */ @Test - void aCancelledPolymapIsLeftWithTheListsInvertValue() { - assertEquals(POLYMAP_CANCEL_PROBE.get("series"), cancel(false)); - String want = POLYMAP_CANCEL_PROBE.get("inverted_series"); - assertTrue(want.contains("after p 0 set 1 q 0 set 1\n"), want); - assertEquals(want.replace("after p 0 set 1", "after p 0 set 0"), cancel(true)); + void simplifyingLeavesThePolymapsAsTheyWere() { + for (String name : new String[] {"series", "inverted_series"}) { + String c = POLYMAP_CANCEL_PROBE.get(name); + String before = c.substring(c.indexOf("before "), c.indexOf('\n', c.indexOf("before "))); + String after = c.substring(c.indexOf("after "), c.indexOf('\n', c.indexOf("after "))); + assertTrue(after.startsWith("after p 0 set 1 q "), c); + assertEquals( + c.replace(after, before.replace("before", "after")), cancel(name.startsWith("inverted")), name); + } } @Test diff --git a/src/test/java/uk/ac/starlink/ast/RemoveRegionsOracleTest.java b/src/test/java/uk/ac/starlink/ast/RemoveRegionsOracleTest.java index 98a271c..ba2e7cc 100644 --- a/src/test/java/uk/ac/starlink/ast/RemoveRegionsOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/RemoveRegionsOracleTest.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.databind.JsonNode; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.Test; import uk.ac.starlink.ast.testsupport.ProbeData; @@ -13,22 +12,16 @@ /** * Translation of Rust {@code tests/test_remove_regions_oracle.rs}: removing the Regions from a * Mapping gives what C's {@code astRemoveRegions} gives. Each class removes them from its own - * components (cmpmap.c, tranmap.c, ratemap.c, region.c {@code RemoveRegions}), a series CmpMap + * components (cmpmap.c, tranmap.c, ratemap.c, normmap.c, region.c {@code RemoveRegions}), a series CmpMap * drops a component that became a UnitMap, and a parallel CmpMap or a TranMap of two UnitMaps * becomes one UnitMap. Each case's Mapping is read from C's dump, and the dump of the result must * equal C's ({@code oracle/remove_regions.json}, from {@code * tools/oracle_fixtures/remove_regions_probe.c}). - * - *

The cases {@code normmap_region} and {@code normmap_cmpframe} need NormMap, which jniast does - * not have, and are skipped by name. */ class RemoveRegionsOracleTest { private static final JsonNode DATA = ProbeData.load("remove_regions"); - /** The cases that need a class astjava does not have. */ - private static final List SKIPPED = Arrays.asList("normmap_region", "normmap_cmpframe"); - private static String text(JsonNode lines) { StringBuilder sb = new StringBuilder(); for (JsonNode l : lines) { @@ -41,14 +34,8 @@ private static String text(JsonNode lines) { void removingRegionsMatchesTheCLibrary() { List failures = new ArrayList<>(); int ran = 0; - int skipped = 0; for (JsonNode c : DATA.get("CASES")) { String name = c.get(0).textValue(); - if (SKIPPED.contains(name)) { - // NormMap (not in jniast). - skipped++; - continue; - } Mapping map = (Mapping) ChannelText.read(text(c.get(1))); String got = ChannelText.dump(map.removeRegions()); String want = text(c.get(2)); @@ -58,7 +45,6 @@ void removingRegionsMatchesTheCLibrary() { ran++; } assertTrue(failures.isEmpty(), String.join("\n", failures)); - assertEquals(9, ran, "cases run"); - assertEquals(SKIPPED.size(), skipped, "cases skipped"); + assertEquals(11, ran, "cases run"); } } diff --git a/src/test/java/uk/ac/starlink/ast/SplineMapCApiTest.java b/src/test/java/uk/ac/starlink/ast/SplineMapCApiTest.java new file mode 100644 index 0000000..3b8b81c --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/SplineMapCApiTest.java @@ -0,0 +1,226 @@ +package uk.ac.starlink.ast; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.fasterxml.jackson.databind.JsonNode; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.Fixtures; +import uk.ac.starlink.ast.testsupport.ProbeData; + +/** + * Translation of Rust {@code tests/test_splinemap_c_api.rs}, which follows C's {@code + * testsplinemap_c.c}: a SplineMap built from the coefficients in SciPy's order, the order C's + * {@code astSplineMap}, and the Java constructor, take, read from the fixture {@code + * programs/testsplinemap/2dspline_c.dat} that the C test reads, and fitted there by {@code + * scipy.interpolate.RectBivariateSpline}. + * + *

Rust's {@code from_scipy} is the Java constructor, and its {@code coeffs} is {@link + * SplineMap#splineCoeffs}. Rust has a second constructor, taking the coefficients in CMLIB's order, + * which C's public API and Java lack; its test becomes one of the coefficients given back to the + * constructor. Where Rust refuses an axis other than 1 or 2, the test checks C's behaviour, which + * gives the second output's coefficients ({@code SplineMapProbeTest}, case {@code knots_coeffs}). + */ +class SplineMapCApiTest { + + private static final double BAD = AstObject.AST__BAD; + + private static final int NX = 150; + private static final int NY = 100; + private static final int K = 4; + + /** testsplinemap_c.c's relative tolerance. */ + private static final double TOL = 1.0e-11; + + private static final double[] XIN = {0.0, 12.5, 12.0, 1.0, 15.0, 1.0, 95.0, 149.5, 151.2, 77.77}; + private static final double[] YIN = {-1.0, 8.8, 8.0, 1.0, 15.0, 76.0, 100.0, 99.8, 82.3, 54.3}; + + /** + * The positions SciPy's {@code RectBivariateSpline} gives, with bad values where the input is + * outside the knots, since CMLIB does not extrapolate (testsplinemap_c.c, whose literals are + * written here in the shortest form that reads as the same double). + */ + private static final double[] UEXP = { + BAD, + 12.049767072857646, + 11.921107191183191, + 1.7788366846173014, + 14.441169003602148, + 0.30566103317717114, + 95.24464880295238, + 147.72545905681767, + BAD, + 77.68709057730592 + }; + + private static final double[] VEXP = { + BAD, + 6.4394741329528635, + 5.788762120688823, + 1.5841275134629758, + 14.580876752701611, + 77.43010929535424, + 102.707899556638, + 99.94739777629977, + BAD, + 57.237295512435686 + }; + + /** The knots and coefficients of {@code 2dspline_c.dat}, in the order the file holds them. */ + private static final class Spline { + final double[] tx = new double[NX + K]; + final double[] ty = new double[NY + K]; + final double[] cu = new double[NX * NY]; + final double[] cv = new double[NX * NY]; + } + + private static Spline readSpline() { + String[] values = + Fixtures.read("programs/testsplinemap/2dspline_c.dat").trim().split("\\s+", -1); + Spline s = new Spline(); + int k = 0; + for (double[] a : new double[][] {s.tx, s.ty, s.cu, s.cv}) { + for (int i = 0; i < a.length; i++) { + a[i] = Double.parseDouble(values[k++]); + } + } + assertEquals(k, values.length, "2dspline_c.dat holds more values than the spline"); + return s; + } + + private static SplineMap scipySplineMap(Spline s) { + return new SplineMap(K, K, NX, NY, s.tx, s.ty, s.cu, s.cv); + } + + /** testsplinemap_c.c Errors 100 and 101: the coefficients come back in the order they were given. */ + @Test + void coeffsAreReturnedInScipyOrder() { + Spline s = readSpline(); + SplineMap sm = scipySplineMap(s); + assertArrayEquals(s.cu, sm.splineCoeffs(1)); + assertArrayEquals(s.cv, sm.splineCoeffs(2)); + } + + /** The coefficients ignore the Invert attribute; any axis but 1 gives the second output's, as in C. */ + @Test + void coeffsIgnoreInvertAndTakeAnyOtherAxisAsTheSecond() { + Spline s = readSpline(); + SplineMap sm = scipySplineMap(s); + sm.invert(); + assertArrayEquals(s.cu, sm.splineCoeffs(1)); + for (int axis : new int[] {0, 3}) { + assertArrayEquals(s.cv, sm.splineCoeffs(axis), "axis " + axis); + } + } + + /** + * The coefficients a SplineMap gives back build the same SplineMap; given in the other order, + * the same values build a different (transposed) one, without error. + */ + @Test + void coefficientsGivenBackBuildTheSameSplineMap() { + Spline s = readSpline(); + SplineMap sm = scipySplineMap(s); + SplineMap again = new SplineMap(K, K, NX, NY, s.tx, s.ty, sm.splineCoeffs(1), sm.splineCoeffs(2)); + assertTrue(sm.astEqual(again)); + double[] cuT = new double[NX * NY]; + double[] cvT = new double[NX * NY]; + for (int j = 0; j < NY; j++) { + for (int i = 0; i < NX; i++) { + cuT[i + j * NX] = s.cu[j + i * NY]; + cvT[i + j * NX] = s.cv[j + i * NY]; + } + } + assertFalse(sm.astEqual(new SplineMap(K, K, NX, NY, s.tx, s.ty, cuT, cvT))); + } + + /** testsplinemap_c.c Errors 1-8: forward against SciPy, and the iterative inverse back to the input. */ + @Test + void forwardMatchesScipyAndInverseRecoversTheInput() { + SplineMap sm = scipySplineMap(readSpline()); + double[][] out = sm.tran2(XIN.length, XIN, YIN, true); + for (int i = 0; i < XIN.length; i++) { + double[] got = {out[0][i], out[1][i]}; + double[] exp = {UEXP[i], VEXP[i]}; + for (int c = 0; c < 2; c++) { + if (exp[c] == BAD) { + assertEquals(BAD, got[c], "point " + i); + } else { + assertTrue(Math.abs(got[c] - exp[c]) <= TOL * Math.abs(exp[c]), "point " + i + ": " + got[c]); + } + } + } + double[][] rec = sm.tran2(XIN.length, out[0], out[1], false); + for (int i = 0; i < XIN.length; i++) { + if (out[0][i] != BAD && out[1][i] != BAD) { + assertTrue( + Math.abs(rec[0][i] - XIN[i]) <= TOL * Math.abs(XIN[i]) + && Math.abs(rec[1][i] - YIN[i]) <= TOL * Math.abs(YIN[i]), + "point " + i + ": (" + rec[0][i] + ", " + rec[1][i] + ")"); + } else { + assertEquals(BAD, rec[0][i], "point " + i); + assertEquals(BAD, rec[1][i], "point " + i); + } + } + } + + /** + * testsplinemap_c.c Errors 9 and 10: an order-1 spline has a singular Jacobian, so its inverse + * gives bad values without an error. + */ + @Test + void orderOneInverseIsBad() { + SplineMap sm = new SplineMap( + 1, 1, 1, 1, new double[] {0.0, 1.0}, new double[] {0.0, 1.0}, new double[] {1.5}, new double[] {2.5}); + double[][] rec = sm.tran2(1, new double[] {0.5}, new double[] {0.5}, false); + assertEquals(BAD, rec[0][0]); + assertEquals(BAD, rec[1][0]); + } + + /** + * testsplinemap_c.c Errors 11-13: the spline u = 2x, v = 3y has du/dx = 2, and inverted, dx/du = + * 0.5 and dx/dv = 0, found numerically as C's parent Rate does (to testsplinemap_c.c's + * tolerances). + */ + @Test + void invertedRateIsTheInverseRate() { + double[] knots = {0.0, 0.0, 1.0, 1.0}; + SplineMap sm = new SplineMap( + 2, 2, 2, 2, knots, knots.clone(), new double[] {0.0, 0.0, 2.0, 2.0}, new double[] {0.0, 3.0, 0.0, 3.0}); + assertEquals(2.0, sm.rate(new double[] {0.5, 0.5}, 1, 1), 1.0e-12); + sm.invert(); + assertEquals(0.5, sm.rate(new double[] {1.0, 1.5}, 1, 1), 1.0e-6); + assertEquals(0.0, sm.rate(new double[] {1.0, 1.5}, 1, 2), 1.0e-6); + } + + /** + * The forward transformation, and the iterative inverse of its results, bit for bit against C's + * ({@code oracle/spline_inverse.json}, from the Rust repository's {@code + * spline_inverse_probe.c}). That probe's values are those of a C library that does not contract + * a multiply and an add into a fused multiply-add: built with the compiler's default flags, + * which contract them, C gives different last bits in 8 of the 40 values. + */ + @Test + void forwardAndInverseMatchTheCLibraryBitForBit() { + SplineMap sm = scipySplineMap(readSpline()); + JsonNode consts = ProbeData.load("spline_inverse"); + double[][] fwd = sm.tran2(XIN.length, XIN, YIN, true); + double[][] inv = sm.tran2(XIN.length, fwd[0], fwd[1], false); + assertBits(consts.get("U"), fwd[0], "forward u"); + assertBits(consts.get("V"), fwd[1], "forward v"); + assertBits(consts.get("X"), inv[0], "inverse x"); + assertBits(consts.get("Y"), inv[1], "inverse y"); + } + + private static void assertBits(JsonNode want, double[] got, String what) { + assertEquals(want.size(), got.length, what); + for (int i = 0; i < got.length; i++) { + assertEquals( + Double.doubleToLongBits(ProbeData.toDouble(want.get(i))), + Double.doubleToLongBits(got[i]), + what + " " + i + ": " + got[i]); + } + } +} diff --git a/src/test/java/uk/ac/starlink/ast/SplineMapProbeTest.java b/src/test/java/uk/ac/starlink/ast/SplineMapProbeTest.java new file mode 100644 index 0000000..346299a --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/SplineMapProbeTest.java @@ -0,0 +1,1093 @@ +package uk.ac.starlink.ast; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.Fixtures; +import uk.ac.starlink.ast.testsupport.ProbeOutput; + +/** + * SplineMap behaviour against C, from {@code probes/splinemap_probe.c}: whether an Object is a + * SplineMap, and its dump; its attributes, set, tested, cleared and given as strings, the read-only + * ones refused; the IsSimple flag after each setter and clearer; the values it gives inside, on the + * edges of and outside the knots, with OutUnit unset and set, in both directions; positions whose + * inverse does not converge within InvNiter, with InvTol changed; an order-1 SplineMap; a + * SplineMap whose knots along X are not repeated at the ends; {@code splineKnots} and {@code + * splineCoeffs} of each axis, also inverted; its simplification with its inverse, in both orders, + * in the same direction, in parallel, with a WinMap, inside an inverted CmpMap and with a different + * OutUnit; its comparisons; its rates, also inverted; a dump read back; and the FITS-WCS writes of + * the {@code lsst2.ast} FrameSet that Rust's {@code test_fitschan_wcs_write.rs} makes. + * + *

Each case writes the lines the probe writes and compares them with C's exactly. C's output + * comes from two builds of the library: {@code splinemap_probe.json} from one with the compiler's + * default flags, which contracts a multiply and an add into a fused multiply-add, and {@code + * splinemap_probe_nocontract.json} from one built with {@code -ffp-contract=off}. Java never fuses + * them, so a line whose value the contraction changes is listed in {@code deferred/oracle-rows.txt} + * and compared with the second build's: a transformed point as {@code + * probes/splinemap_probe/ }, counting the case's {@code fwd} or + * {@code inv} lines from 0, and any other line as {@code probes/splinemap_probe/ other + * }, counting the case's other lines from 0. {@link #contractionRowsAreThoseListed} checks + * that the two builds differ in exactly those lines. + * + *

Where the pinned C reads beyond its arrays, or combines bad values arithmetically, at a + * position its splines do not cover or on the limits of the range they cover, Java follows the PR + * that hardens C (Starlink/ast #104), whose {@code Db2val} and {@code Dbvalu} it ports, and whose + * library built the same way as the second gives {@code splinemap_probe_pr104.json}: the rows + * {@link #PR104_ROWS} names take its lines, and so do its cases {@link #PR104_CASES}, which the + * pinned C cannot evaluate. {@link #pr104DiffersOnlyInTheNamedRows} checks that the PR's library + * differs from the pinned C's in exactly those rows. + */ +class SplineMapProbeTest { + + private static final double BAD = AstObject.AST__BAD; + + private static final String PROBE = "splinemap_probe"; + + /** The prefix of this probe's entries in {@code deferred/oracle-rows.txt}. */ + static final String ROWS_PREFIX = "probes/" + PROBE + "/"; + + private static final Map FUSED = ProbeOutput.load(PROBE); + + private static final Map UNFUSED = ProbeOutput.load(PROBE + "_nocontract"); + + private static final Map PR104 = ProbeOutput.load(PROBE + "_pr104"); + + /** The cases built only against the hardening PR's library. */ + private static final List PR104_CASES = Arrays.asList("pr_open_knots_x", "pr_open_knots_y"); + + /** + * The rows of the pinned cases where the hardening PR's lines differ from the pinned C's, and + * Java gives the PR's: in {@code tran_open_knots_x}, the positions within the knots along X + * outside the range the spline covers, x = 0, 0.5, 3.5 and 4, forward and inverse, with OutUnit + * set (with it unset both give bad at y = 0.5, the pinned C by chance), and the rate at x = 0.5 + * with OutUnit set; in {@code tran_zero_width_x}, the values and rates on a range + * covered along X of zero width, other than the rates the order-1 spline gives as zero + * derivatives without evaluating it; and in {@code tran_linear_edges} and {@code order1}, the + * upper limit along y of a spline with a single knot interval along y, where the pinned C's + * {@code Db2val} gives bad and the PR's the value there. + */ + private static final Map> PR104_ROWS = merged( + rows("tran_linear_edges", "forward 1", "forward 3", "forward 4", "forward 7", "forward 9", "forward 10"), + rows("order1", "forward 2"), + rows( + "tran_open_knots_x", + "forward 11", + "forward 12", + "forward 17", + "forward 18", + "inverse 6", + "inverse 7", + "other 0"), + rows( + "tran_zero_width_x", + "forward 0", + "forward 1", + "forward 2", + "forward 3", + "forward 4", + "forward 5", + "other 0", + "other 1", + "other 2", + "other 3", + "other 5", + "other 7")); + + private static Map> rows(String name, String... kinds) { + Map> m = new TreeMap<>(); + m.put(name, new TreeSet<>(Arrays.asList(kinds))); + return m; + } + + @SafeVarargs + private static Map> merged(Map>... parts) { + Map> m = new TreeMap<>(); + for (Map> part : parts) { + m.putAll(part); + } + return m; + } + + private static Set named(Map> m, String name) { + Set rows = m.get(name); + return rows == null ? Collections.emptySet() : rows; + } + + // ------------------------------------------------------------------ + // Comparison with the probe + // ------------------------------------------------------------------ + + private static String probeCase(Map cases, String name) { + String text = cases.get(name); + if (text == null) { + throw new IllegalStateException("no probe case " + name); + } + return withoutSource(text); + } + + /** + * The case without the lines naming the C source of an error, which Java cannot give: the + * first line of a report ({@code !! }), and the line naming the routine when C writes it below + * the first message. + */ + private static String withoutSource(String text) { + StringBuilder sb = new StringBuilder(); + for (String line : text.split("\n", -1)) { + if (!line.startsWith("!! ") && !line.startsWith("! AST: Error in routine ") && !line.isEmpty()) { + sb.append(line).append('\n'); + } + } + return sb.toString(); + } + + /** The rows of {@code name} of {@code kind} (forward, inverse or other) that are listed. */ + private static Set listedRows(String name, String kind) { + TransformOracleTest.ExcusedRows rows = + TransformOracleTest.committedOracleRows().get(ROWS_PREFIX + name + " " + kind); + return rows == null ? Collections.emptySet() : rows.rows; + } + + /** + * The row each line of {@code text} is: {@code forward } for its n-th {@code fwd} line, + * {@code inverse } for its n-th {@code inv} line, and {@code other } for its n-th other + * line. + */ + private static List rowKinds(String text) { + List out = new ArrayList<>(); + int nfwd = 0; + int ninv = 0; + int nother = 0; + for (String line : text.split("\n", -1)) { + if (line.startsWith("fwd ")) { + out.add("forward " + nfwd++); + } else if (line.startsWith("inv ")) { + out.add("inverse " + ninv++); + } else { + out.add("other " + nother++); + } + } + return out; + } + + /** + * What C gives for case {@code name}: the default build's lines, with the unfused build's in + * the rows {@code oracle-rows.txt} lists and the hardening PR's in the rows {@link #PR104_ROWS} + * names; for a case of {@link #PR104_CASES}, the hardening PR's lines. + */ + private static String expected(String name) { + if (PR104_CASES.contains(name)) { + return probeCase(PR104, name); + } + String[] fused = probeCase(FUSED, name).split("\n", -1); + String[] unfused = probeCase(UNFUSED, name).split("\n", -1); + String[] pr104 = probeCase(PR104, name).split("\n", -1); + assertEquals(fused.length, unfused.length, name); + assertEquals(fused.length, pr104.length, name); + List kinds = rowKinds(probeCase(FUSED, name)); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < fused.length; i++) { + String kind = kinds.get(i); + int space = kind.indexOf(' '); + boolean listed = + listedRows(name, kind.substring(0, space)).contains(Integer.parseInt(kind.substring(space + 1))); + if (named(PR104_ROWS, name).contains(kind)) { + sb.append(pr104[i]); + } else { + sb.append(listed ? unfused[i] : fused[i]); + } + if (i < fused.length - 1) { + sb.append('\n'); + } + } + return sb.toString(); + } + + private static void assertCase(String name, Object got) { + assertEquals(expected(name), got.toString(), name); + } + + private static String g(double v) { + return CFormat.format("%.17g", v); + } + + private static int flag(boolean b) { + return b ? 1 : 0; + } + + /** The dump of {@code obj}, as the probe's {@code astShow} writes it. */ + private static String show(AstObject obj) { + StringBuilder sb = new StringBuilder(); + for (String l : ChannelText.dump(obj).split("\n", -1)) { + if (!l.isEmpty()) { + sb.append(ProbeOutput.trimLines(l)).append('\n'); + } + } + return sb.toString(); + } + + /** The probe's lines for an error: its message and status. */ + private static String error(AstException e) { + StringBuilder sb = new StringBuilder(); + for (String line : ProbeOutput.trimLines(e.getMsgText()).split("\n", -1)) { + sb.append("! ").append(line).append('\n'); + } + return sb.append("status ").append(e.getStatus()).append('\n').toString(); + } + + /** What the probe prints for an action that may fail: nothing, or the error. */ + private static String attempt(Runnable action) { + try { + action.run(); + return ""; + } catch (AstException e) { + return error(e); + } + } + + /** + * The probe's {@code tran}: the transformation of {@code npt} points given coordinate by + * coordinate in {@code in}, one line each, or the error. + */ + private static String tran(Mapping m, int npt, double[] in, boolean forward) { + double[] out; + try { + out = m.tranN(npt, 2, in, forward, 2); + } catch (AstException e) { + return error(e); + } + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < npt; i++) { + sb.append(forward ? "fwd " : "inv ") + .append(g(in[i])) + .append(' ') + .append(g(in[npt + i])) + .append(" -> ") + .append(g(out[i])) + .append(' ') + .append(g(out[npt + i])) + .append('\n'); + } + return sb.toString(); + } + + /** The probe's {@code roundtrip}: points forward, then the results in the inverse direction. */ + private static String roundtrip(Mapping m, int npt, double[] in) { + return tran(m, npt, in, true) + tran(m, npt, m.tranN(npt, 2, in, true, 2), false); + } + + /** The class of the simplified Mapping, whether it is the Mapping itself, and its dump. */ + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) // astSame compares the Objects. + private static String simp(Mapping m) { + Mapping s = m.simplify(); + return "-- simplified " + s.astClass() + " same " + flag(s == m) + "\n" + show(s); + } + + private static String equal(String label, AstObject a, AstObject b) { + return "equal " + label + " " + flag(a.astEqual(b)) + "\n"; + } + + private static final String[] ATTRIBUTE_NAMES = { + "InvNiter", "InvTol", "OutUnit", "SplineKx", "SplineKy", "SplineNx", "SplineNy" + }; + + /** The probe's {@code attrs}: each attribute as a string, and whether it is set. */ + private static String attrs(SplineMap sm) { + StringBuilder sb = new StringBuilder(); + for (String name : ATTRIBUTE_NAMES) { + sb.append(name) + .append(' ') + .append(sm.getC(name)) + .append(" test ") + .append(flag(sm.test(name))) + .append('\n'); + } + return sb.toString(); + } + + private static String issimple(String label, Mapping m) { + return "IsSimple " + label + " " + m.getI("IsSimple") + "\n"; + } + + /** The probe's {@code mark_simple}: simplifying a lone SplineMap flags the SplineMap itself. */ + private static void markSimple(Mapping m) { + assertSame(m, m.simplify()); + } + + private static String knots(SplineMap sm, int axis) { + StringBuilder sb = new StringBuilder("knots ").append(axis); + for (double v : sm.splineKnots(axis)) { + sb.append(' ').append(g(v)); + } + return sb.append('\n').toString(); + } + + private static String coeffs(SplineMap sm, int axis) { + StringBuilder sb = new StringBuilder("coeffs ").append(axis); + for (double v : sm.splineCoeffs(axis)) { + sb.append(' ').append(g(v)); + } + return sb.append('\n').toString(); + } + + private static String rate(Mapping m, double x, double y, int ax1, int ax2) { + double r; + try { + r = m.rate(new double[] {x, y}, ax1, ax2); + } catch (AstException e) { + return error(e); + } + return "rate " + g(x) + " " + g(y) + " " + ax1 + " " + ax2 + " -> " + g(r) + "\n"; + } + + private static String invertAttrs(String na, Mapping a, String nb, Mapping b) { + return "Invert " + na + " " + a.getI("Invert") + " test " + flag(a.test("Invert")) + " " + nb + " " + + b.getI("Invert") + " test " + flag(b.test("Invert")) + "\n"; + } + + private static double[] d(double... v) { + return v; + } + + private static T inverted(T m) { + m.invert(); + return m; + } + + private static final double[] CUBIC_TX = {0.0, 0.0, 0.0, 0.0, 1.5, 3.0, 3.0, 3.0, 3.0}; + private static final double[] CUBIC_TY = {0.0, 0.0, 0.0, 0.0, 1.5, 3.0, 4.5, 4.5, 4.5, 4.5}; + private static final double[] CUBIC_CU = { + 0.00, 0.01, 0.02, 0.01, 0.00, -0.01, + 0.51, 0.52, 0.49, 0.50, 0.53, 0.50, + 1.52, 1.48, 1.50, 1.53, 1.49, 1.51, + 2.49, 2.51, 2.52, 2.48, 2.50, 2.52, + 3.01, 3.00, 2.99, 3.02, 3.01, 3.00 + }; + private static final double[] CUBIC_CV = { + 0.01, 0.50, 1.52, 3.01, 3.98, 4.50, 0.00, 0.52, 1.49, 2.99, 4.01, 4.51, -0.01, 0.49, 1.50, 3.02, 4.02, 4.49, + 0.02, 0.51, 1.51, 2.98, 3.99, 4.50, 0.00, 0.50, 1.48, 3.00, 4.00, 4.52 + }; + + /** The probe's bicubic SplineMap over [0, 3] x [0, 4.5]. */ + private static SplineMap cubic() { + return new SplineMap(4, 4, 5, 6, CUBIC_TX, CUBIC_TY, CUBIC_CU, CUBIC_CV); + } + + /** The linear SplineMap u = 2x, v = 3y over the unit square, of testsplinemap_c.c. */ + private static SplineMap linear() { + double[] tk = {0.0, 0.0, 1.0, 1.0}; + return new SplineMap(2, 2, 2, 2, tk, tk, d(0.0, 0.0, 2.0, 2.0), d(0.0, 3.0, 0.0, 3.0)); + } + + /** The text of a case, built a piece at a time. */ + private static final class Lines { + private final List parts = new ArrayList<>(); + + Lines add(String text) { + parts.add(text); + return this; + } + + @Override + public String toString() { + return String.join("", parts); + } + } + + // ------------------------------------------------------------------ + // The two builds of C + // ------------------------------------------------------------------ + + /** + * The lines in which the default and unfused builds of C differ are exactly those {@code + * oracle-rows.txt} lists for this probe, so that each listed line is shown to depend on the + * contraction and no other does. + */ + @Test + void contractionRowsAreThoseListed() { + assertEquals(FUSED.keySet(), UNFUSED.keySet()); + Set differing = new TreeSet<>(); + for (String name : FUSED.keySet()) { + String[] fused = probeCase(FUSED, name).split("\n", -1); + String[] unfused = probeCase(UNFUSED, name).split("\n", -1); + assertEquals(fused.length, unfused.length, name); + List kinds = rowKinds(probeCase(FUSED, name)); + for (int i = 0; i < fused.length; i++) { + if (!fused[i].equals(unfused[i])) { + differing.add(name + " " + kinds.get(i)); + } + } + } + Set listed = new TreeSet<>(); + for (TransformOracleTest.ExcusedRows x : + TransformOracleTest.committedOracleRows().values()) { + if (x.relpath.startsWith(ROWS_PREFIX)) { + for (int row : x.rows) { + listed.add(x.relpath.substring(ROWS_PREFIX.length()) + " " + x.kind + " " + row); + } + } + } + assertEquals(differing, listed); + assertFalse(listed.isEmpty()); + } + + /** + * The hardening PR's library differs from the pinned C's, both unfused, in exactly the rows + * {@link #PR104_ROWS} names, and it has every case of the pinned C's and the cases {@link + * #PR104_CASES}. + */ + @Test + void pr104DiffersOnlyInTheNamedRows() { + Set cases = new TreeSet<>(UNFUSED.keySet()); + cases.addAll(PR104_CASES); + assertEquals(cases, new TreeSet<>(PR104.keySet())); + Set differing = new TreeSet<>(); + Set named = new TreeSet<>(); + for (String name : UNFUSED.keySet()) { + String[] unfused = probeCase(UNFUSED, name).split("\n", -1); + String[] pr104 = probeCase(PR104, name).split("\n", -1); + assertEquals(unfused.length, pr104.length, name); + List kinds = rowKinds(probeCase(UNFUSED, name)); + for (int i = 0; i < unfused.length; i++) { + if (!unfused[i].equals(pr104[i])) { + differing.add(name + " " + kinds.get(i)); + } + } + for (String kind : named(PR104_ROWS, name)) { + named.add(name + " " + kind); + } + } + assertEquals(named, differing); + } + + // ------------------------------------------------------------------ + // The class and its attributes + // ------------------------------------------------------------------ + + @Test + void isASplineMap() { + // Declared as an Object, so that each test is of the class. + AstObject sm = cubic(); + Mapping m = (Mapping) sm; + String got = "IsASplineMap " + flag(sm instanceof SplineMap) + " IsAMapping " + flag(sm instanceof Mapping) + + " Nin " + m.getNin() + " Nout " + m.getNout() + " IsLinear " + m.getI("IsLinear") + "\n" + show(sm); + assertCase("isa", got); + } + + @Test + void constructorRefusesWhatCRefuses() { + double[] t4 = {0.0, 0.0, 1.0, 1.0}; + double[] tbad = {0.0, 1.0, 0.5, 1.0}; + double[] c4 = new double[4]; + double[] t14 = new double[14]; + double[] c49 = new double[49]; + Lines got = new Lines() + .add(attempt(() -> new SplineMap(0, 2, 2, 2, t4, t4, c4, c4))) + .add(attempt(() -> new SplineMap(7, 7, 7, 7, t14, t14, c49, c49))) + .add(attempt(() -> new SplineMap(2, 0, 2, 2, t4, t4, c4, c4))) + .add(attempt(() -> new SplineMap(2, 7, 2, 7, t4, t14, c49, c49))) + .add(attempt(() -> new SplineMap(2, 2, 1, 2, t4, t4, c4, c4))) + .add(attempt(() -> new SplineMap(2, 2, 2, 1, t4, t4, c4, c4))) + .add(attempt(() -> new SplineMap(2, 2, 2, 2, tbad, t4, c4, c4))) + .add(attempt(() -> new SplineMap(2, 2, 2, 2, t4, tbad, c4, c4))) + .add(attempt(() -> new SplineMap(2, 2, 2, 2, tbad, tbad, c4, c4))); + assertCase("ctor_errors", got); + } + + @Test + void attributeDefaults() { + assertCase("attrs_default", attrs(cubic())); + } + + @Test + void attributesAreSetAndCleared() { + SplineMap sm = cubic(); + Lines got = new Lines(); + sm.set("InvNiter=10, InvTol=1.0E-8, OutUnit=1"); + got.add(attrs(sm)).add(show(sm)); + sm.setI("OutUnit", 5); + sm.setI("InvNiter", -3); + got.add(attrs(sm)); + sm.setD("InvTol", BAD); + got.add(attrs(sm)); + sm.clear("InvNiter"); + sm.clear("InvTol"); + sm.clear("OutUnit"); + got.add(attrs(sm)).add(show(sm)); + assertCase("attrs_set", got); + } + + @Test + void readOnlyAttributesAreRefused() { + SplineMap sm = cubic(); + Lines got = new Lines() + .add(attempt(() -> sm.set("SplineKx=3"))) + .add(attempt(() -> sm.setI("SplineNy", 3))) + .add(attempt(() -> sm.clear("SplineKy"))) + .add(attempt(() -> sm.clear("SplineNx"))) + .add("test " + flag(sm.test("SplineKx")) + " " + flag(sm.test("SplineKy")) + " " + + flag(sm.test("SplineNx")) + " " + flag(sm.test("SplineNy")) + "\n"); + assertCase("attrs_readonly", got); + } + + @Test + void aSharedSplineMapRefusesChanges() { + SplineMap sm = cubic(); + CmpMap cmp = new CmpMap(sm, new UnitMap(2), true); + Lines got = new Lines() + .add(attempt(() -> sm.setI("InvNiter", 3))) + .add(attempt(() -> sm.setD("InvTol", 1.0e-3))) + .add(attempt(() -> sm.clear("OutUnit"))) + .add(attrs(sm)); + assertCase("attrs_shared", got); + assertEquals(2, cmp.getNin()); + } + + @Test + void settersAndClearersDiscardTheSimplifiedRecord() { + String[] settings = {"InvNiter=6", "InvTol=1.0E-6", "OutUnit=0"}; + String[] names = {"InvNiter", "InvTol", "OutUnit"}; + Lines got = new Lines(); + for (int i = 0; i < 3; i++) { + SplineMap s = cubic(); + markSimple(s); + got.add(issimple("marked", s)); + s.set(settings[i]); + got.add(issimple(settings[i], s)); + markSimple(s); + s.set(settings[i]); + got.add(issimple("same value", s)); + s.clear(names[i]); + got.add(issimple("cleared", s)); + markSimple(s); + s.clear(names[i]); + got.add(issimple("cleared again", s)); + } + SplineMap s = cubic(); + markSimple(s); + s.set("OutUnit=1"); + markSimple(s); + s.set("OutUnit=7"); + got.add(issimple("OutUnit=7 after 1", s)); + s.set("InvNiter=-3"); + markSimple(s); + s.setD("InvTol", BAD); + got.add(issimple("InvTol bad while unset", s)); + s.invert(); + got.add(issimple("inverted", s)); + s.invert(); + got.add(issimple("inverted back", s)); + assertCase("issimple", got); + } + + // ------------------------------------------------------------------ + // Transformations + // ------------------------------------------------------------------ + + @Test + void transformsInsideTheKnots() { + double[] in = {0.25, 1.0, 1.5, 2.2, 2.9, 0.1, 0.3, 2.0, 1.5, 4.4, 0.05, 3.7}; + assertCase("tran_inside", roundtrip(cubic(), 6, in)); + } + + @Test + void transformsOnAndOutsideTheEdgesWithOutUnitUnsetAndSet() { + double[] in = { + -0.5, 3.5, 1.0, 1.0, 0.0, 3.0, 0.0, 3.0, 1.0, 3.0, BAD, 1.0, 1.0, 1.0, -0.5, 5.0, 0.0, 4.5, 4.5, 0.0, 4.5, + 2.0, 1.0, BAD + }; + double[] inv = {-0.5, 3.5, 1.0, 1.0, 3.0, 3.01, 0.0, -0.01, 2.99, 1.0, 1.0, -0.5, 5.0, 4.5, 4.52, 0.0, 0.0, 4.49 + }; + SplineMap sm = cubic(); + Lines got = new Lines().add(tran(sm, 12, in, true)).add(tran(sm, 9, inv, false)); + sm.setI("OutUnit", 1); + got.add(tran(sm, 12, in, true)).add(tran(sm, 9, inv, false)); + sm.invert(); + got.add(tran(sm, 9, inv, true)).add(tran(sm, 12, in, false)); + assertCase("tran_outside", got); + } + + /** + * On the upper edges in X and Y of a spline with a single knot interval along each, the values + * are the spline's, as the hardening PR gives them ({@link #PR104_ROWS}), where the pinned C + * gives bad values on the upper edge in Y. + */ + @Test + void transformsOnTheEdgesOfALinearSpline() { + double[] in = {0.0, 1.0, 1.0, 0.5, 0.0, 1.0, 0.0, 1.0, 0.5, 1.0, 1.0, 0.0}; + double[] inv = {0.0, 2.0, 2.0, 1.0, 1.9999999, 1.5, 0.0, 3.0, 1.5, 3.0, 1.5, 2.9999999}; + SplineMap sm = linear(); + Lines got = new Lines().add(tran(sm, 6, in, true)).add(tran(sm, 6, inv, false)); + sm.setI("OutUnit", 1); + got.add(tran(sm, 6, in, true)).add(tran(sm, 6, inv, false)); + assertCase("tran_linear_edges", got); + } + + /** + * Knots along X that are not repeated at the ends: inside the box of the knots but outside the + * interval the spline covers, the values are those outside the knots, bad, or with OutUnit set + * the input, as the hardening PR gives them ({@link #PR104_ROWS}). + */ + @Test + void transformsWithKnotsNotRepeatedAtTheEnds() { + double[] tx = {0.0, 1.0, 2.0, 3.0, 4.0}; + double[] ty = {0.0, 0.0, 1.0, 1.0}; + double[] in = { + -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 3.0, 3.5, 4.0, 4.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 + }; + double[] inv = {1.5, 2.5, 0.5, 3.5, 0.5, 0.5, 0.5, 0.5}; + SplineMap sm = + new SplineMap(2, 2, 3, 2, tx, ty, d(1.0, 1.0, 2.0, 2.0, 3.0, 3.0), d(0.0, 1.0, 0.0, 1.0, 0.0, 1.0)); + Lines got = new Lines().add(tran(sm, 10, in, true)).add(tran(sm, 4, inv, false)); + sm.setI("OutUnit", 1); + got.add(tran(sm, 10, in, true)) + .add(tran(sm, 4, inv, false)) + .add(rate(sm, 0.5, 0.5, 1, 1)) + .add(rate(sm, 2.0, 0.5, 1, 1)); + assertCase("tran_open_knots_x", got); + } + + /** + * Knots along X whose covered range has zero width, of order 2 (knots 0, 1, 1, 2) and of order + * 1 (knots 1, 1): on that range, x = 1, the values and rates are bad, as the hardening PR gives + * them ({@link #PR104_ROWS}), where the pinned C evaluates the knot interval of zero width + * before it, giving NaN and infinite values for order 2 and the first coefficient for order 1. + * The rates of the order-1 spline with respect to x are zero, its derivatives of order 1. + */ + @Test + void transformsOnACoveredRangeOfZeroWidth() { + double[] ty = {0.0, 0.0, 1.0, 1.0}; + double[] in = {1.0, 1.0, 1.0, 0.0, 0.25, 0.5}; + SplineMap sm2 = + new SplineMap(2, 2, 2, 2, d(0.0, 1.0, 1.0, 2.0), ty, d(0.0, 0.0, 2.0, 2.0), d(0.0, 3.0, 0.0, 3.0)); + SplineMap sm1 = new SplineMap(1, 2, 1, 2, d(1.0, 1.0), ty, d(1.5, 1.5), d(0.0, 3.0)); + Lines got = new Lines(); + for (SplineMap sm : new SplineMap[] {sm2, sm1}) { + got.add(tran(sm, 3, in, true)); + for (int ax1 = 1; ax1 <= 2; ax1++) { + for (int ax2 = 1; ax2 <= 2; ax2++) { + got.add(rate(sm, 1.0, 0.5, ax1, ax2)); + } + } + } + assertCase("tran_zero_width_x", got); + } + + /** The open_knot_cases of the probe, from the hardening PR's library. */ + private static String openKnotCase(SplineMap sm, int nin, double[] in, int ninv, double[] inv, double[] rates) { + Lines got = new Lines().add(tran(sm, nin, in, true)).add(tran(sm, ninv, inv, false)); + for (int i = 0; i < rates.length; i += 4) { + got.add(rate(sm, rates[i], rates[i + 1], (int) rates[i + 2], (int) rates[i + 3])); + } + return got.toString(); + } + + /** + * Knots along X not repeated at the ends, at fractional y: within the knots but outside the + * range the spline covers along X, the values are those outside the knots, which the pinned C + * gives only by chance. + */ + @Test + void transformsOutsideTheRangeCoveredAlongX() { + double[] tx = {0.0, 1.0, 2.0, 3.0, 4.0}; + double[] ty = {0.0, 0.0, 1.0, 1.0}; + double[] in = {0.5, 0.5, 0.5, 3.5, 0.0, 4.0, 2.0, 1.0, 3.0, 0.1, 0.3, 0.7, 0.3, 0.7, 0.3, 0.3, 0.6, 0.6}; + double[] inv = {0.4, 3.6, 2.5, 1.0, 3.0, 0.3, 0.3, 0.3, 0.7, 0.7}; + double[] rates = {0.5, 0.3, 1, 1, 0.5, 0.3, 2, 2}; + SplineMap sm = + new SplineMap(2, 2, 3, 2, tx, ty, d(1.0, 1.0, 2.0, 2.0, 3.0, 3.0), d(0.0, 1.0, 0.0, 1.0, 0.0, 1.0)); + String got = openKnotCase(sm, 9, in, 5, inv, rates); + sm.setI("OutUnit", 1); + assertCase("pr_open_knots_x", got + openKnotCase(sm, 9, in, 5, inv, rates)); + } + + /** + * Knots along Y not repeated at the ends: outside the range the spline covers along Y the + * values are those outside the knots, and on its upper limit, y = 3, the spline's value. + */ + @Test + void transformsOutsideTheRangeCoveredAlongY() { + double[] tx = {0.0, 0.0, 4.0, 4.0}; + double[] ty = {0.0, 1.0, 2.0, 3.0, 4.0}; + double[] in = { + 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 0.0, 4.0, 4.0, 2.0, 0.5, 1.0, 2.0, 2.5, 3.0, 3.5, 4.0, 2.0, 2.0, 3.0, 5.0 + }; + double[] inv = {2.0, 2.0, 2.0, 1.0, 4.0, 2.0, 2.5, 0.5, 2.9999, 3.0}; + double[] rates = {2.0, 3.0, 2, 2, 2.0, 0.5, 2, 2}; + SplineMap sm = + new SplineMap(2, 2, 2, 3, tx, ty, d(0.0, 0.0, 0.0, 4.0, 4.0, 4.0), d(1.0, 2.0, 3.0, 1.0, 2.0, 3.0)); + String got = openKnotCase(sm, 11, in, 5, inv, rates); + sm.setI("OutUnit", 1); + assertCase("pr_open_knots_y", got + openKnotCase(sm, 11, in, 5, inv, rates)); + } + + @Test + void inverseWithChangedIterationsAndTolerance() { + double[] in = {0.25, 1.0, 1.5, 2.2, 2.9, 0.0, 3.0, 2.0, 0.3, 2.0, 1.5, 4.4, 0.05, 2.0, 2.0, 0.0}; + SplineMap sm = cubic(); + double[] out = sm.tranN(8, 2, in, true, 2); + String[] settings = { + "InvNiter=1", + "InvNiter=2", + "InvNiter=3", + "InvNiter=1, InvTol=1.0E-3", + "InvNiter=2, InvTol=0.1", + "InvNiter=6, InvTol=1.0E-14", + "InvNiter=20, InvTol=1.0E-17", + "InvNiter=0", + "InvNiter=-3", + "InvTol=0", + "InvTol=-1", + "InvNiter=1, OutUnit=1", + "InvNiter=2, OutUnit=1" + }; + Lines got = new Lines(); + for (String setting : settings) { + sm.clear("InvNiter,InvTol,OutUnit"); + sm.set(setting); + got.add("-- " + setting + "\n").add(tran(sm, 8, out, false)); + } + assertCase("inv_iterations", got); + } + + @Test + void inverseOfPositionsBeyondTheKnots() { + double[] inv = {-0.02, 3.02, 3.0, 1.0, 0.0, -1.0, 4.0, 1.5, 1.0, 1.0, 4.52, -0.02, 0.0, 2.0, 5.0, 4.6}; + SplineMap sm = cubic(); + Lines got = new Lines().add(tran(sm, 8, inv, false)); + sm.set("InvNiter=20"); + got.add(tran(sm, 8, inv, false)); + sm.clear("InvNiter"); + sm.setI("OutUnit", 1); + got.add(tran(sm, 8, inv, false)); + assertCase("inv_outside", got); + } + + @Test + void orderOneSplineMap() { + double[] t = {0.0, 1.0}; + double[] in = {0.5, 0.0, 1.0, 1.5, 0.5, 0.0, 1.0, 0.5}; + SplineMap sm = new SplineMap(1, 1, 1, 1, t, t, d(1.5), d(2.5)); + Lines got = new Lines().add(tran(sm, 4, in, true)).add(tran(sm, 4, in, false)); + sm.setI("OutUnit", 1); + got.add(tran(sm, 4, in, false)).add(rate(sm, 0.5, 0.5, 1, 1)).add(rate(sm, 0.5, 0.5, 2, 1)); + assertCase("order1", got); + } + + @Test + void rates() { + SplineMap sm = cubic(); + Lines got = new Lines(); + for (int ax1 = 1; ax1 <= 2; ax1++) { + for (int ax2 = 1; ax2 <= 2; ax2++) { + got.add(rate(sm, 1.2, 2.7, ax1, ax2)) + .add(rate(sm, 3.0, 4.5, ax1, ax2)) + .add(rate(sm, -1.0, 2.0, ax1, ax2)); + } + } + got.add(rate(sm, BAD, 2.0, 1, 1)).add(rate(sm, 1.0, 2.0, 3, 1)).add(rate(sm, 1.0, 2.0, 1, 0)); + sm.setI("OutUnit", 1); + for (int ax1 = 1; ax1 <= 2; ax1++) { + for (int ax2 = 1; ax2 <= 2; ax2++) { + got.add(rate(sm, -1.0, 2.0, ax1, ax2)); + } + } + sm.clear("OutUnit"); + sm.invert(); + for (int ax1 = 1; ax1 <= 2; ax1++) { + for (int ax2 = 1; ax2 <= 2; ax2++) { + got.add(rate(sm, 1.2, 2.7, ax1, ax2)); + } + } + assertCase("rate", got); + } + + @Test + void ratesOfTestsplinemap() { + SplineMap sm = linear(); + Lines got = new Lines().add(rate(sm, 0.5, 0.5, 1, 1)); + sm.invert(); + got.add(rate(sm, 1.0, 1.5, 1, 1)).add(rate(sm, 1.0, 1.5, 1, 2)); + assertCase("rate_testsplinemap", got); + } + + // ------------------------------------------------------------------ + // Knots and coefficients + // ------------------------------------------------------------------ + + /** Any axis but 1 gives the second axis's knots and the second output's coefficients, as in C. */ + @Test + void knotsAndCoefficientsOfEachAxis() { + SplineMap sm = cubic(); + Lines got = new Lines(); + for (int axis = 0; axis <= 3; axis++) { + got.add(knots(sm, axis)).add(coeffs(sm, axis)); + } + sm.invert(); + got.add(knots(sm, 1)).add(coeffs(sm, 2)); + assertCase("knots_coeffs", got); + } + + // ------------------------------------------------------------------ + // Simplification and comparison + // ------------------------------------------------------------------ + + @Test + void simplifiesWithItsInverse() { + SplineMap sm = cubic(); + SplineMap smi = inverted(cubic()); + assertCase("simp_inverse_after", simp(new CmpMap(sm, smi, true))); + assertCase("simp_inverse_before", simp(new CmpMap(smi, sm, true))); + assertCase("simp_same_direction", simp(new CmpMap(sm, (Mapping) sm.copy(), true))); + assertCase("simp_parallel", simp(new CmpMap(sm, smi, false))); + assertCase("simp_unit_between", simp(new CmpMap(new CmpMap(sm, new UnitMap(2), true), smi, true))); + assertCase("simp_different_coeffs", simp(new CmpMap(sm, inverted(linear()), true))); + SplineMap ou = (SplineMap) smi.copy(); + ou.setI("OutUnit", 1); + ou.setI("InvNiter", 2); + assertCase("simp_outunit_differs", simp(new CmpMap(sm, ou, true))); + } + + @Test + void doesNotSimplifyWithAWinMap() { + double[] a = {0.0, 0.0}; + double[] b = {1.0, 1.0}; + double[] c = {1.0, 2.0}; + double[] e = {3.0, 5.0}; + SplineMap sm = cubic(); + assertCase( + "simp_winmap", + simp(new CmpMap(sm, new WinMap(2, a, b, c, e), true)) + + simp(new CmpMap(new WinMap(2, a, b, c, e), sm, true))); + } + + /** + * C's text with a line of its {@code Invert} attributes after a simplification, {@code cAfter}, + * replaced by the line Java gives, {@code javaAfter}: each SplineMap as it was before, set or + * unset, where C leaves the SplineMap that cancelled with the list's value and every attribute + * it compared set (docs/rust-c-differences.md, "SplineMap merges change Invert attributes"). + */ + private static String withJavaAfter(String c, String cAfter, String javaAfter) { + assertTrue(c.contains(cAfter + "\n"), c); + int at = c.lastIndexOf(cAfter + "\n"); + return c.substring(0, at) + javaAfter + c.substring(at + cAfter.length()); + } + + /** + * Simplifying an inverted CmpMap of a SplineMap and its inverse leaves both SplineMaps, which + * the caller holds, as they were, where C leaves the second with the Invert attribute the merge + * gave it, and so transforming in the other direction, and the first with its attribute set + * (docs/c-library-bugs.md, "Simplifying a CmpMap changes the Invert attribute of a component it + * holds"). + */ + @Test + void simplifyingAnInvertedCmpMapLeavesTheSplineMapsAsTheyWere() { + double[] pt = {1.2, 2.7}; + SplineMap a = cubic(); + SplineMap b = inverted(cubic()); + CmpMap cmp = new CmpMap(a, b, true); + cmp.invert(); + Lines got = new Lines() + .add(tran(cmp, 1, pt, true)) + .add(invertAttrs("a", a, "b", b)) + .add(simp(cmp)) + .add(invertAttrs("a", a, "b", b)) + .add(tran(cmp, 1, pt, true)); + assertEquals( + withJavaAfter( + expected("simp_inverted_cmpmap"), + "Invert a 0 test 1 b 0 test 1", + "Invert a 0 test 0 b 1 test 1"), + got.toString()); + } + + /** + * Simplifying a CmpMap of a SplineMap and its inverse, in either order, leaves both SplineMaps + * as they were, where C leaves each Invert attribute it compared set. + */ + @Test + void simplifyingLeavesNoInvertAttributeSet() { + SplineMap a = cubic(); + SplineMap b = inverted(cubic()); + Lines got = new Lines().add(simp(new CmpMap(a, b, true))).add(invertAttrs("a", a, "b", b)); + SplineMap a2 = cubic(); + SplineMap b2 = inverted(cubic()); + got.add(simp(new CmpMap(b2, a2, true))).add(invertAttrs("b", b2, "a", a2)); + assertEquals( + withJavaAfter( + withJavaAfter( + expected("simp_cmpmap_attrs"), + "Invert b 1 test 1 a 0 test 1", + "Invert b 1 test 1 a 0 test 0"), + "Invert a 0 test 1 b 1 test 1", + "Invert a 0 test 0 b 1 test 1"), + got.toString()); + } + + @Test + void comparisons() { + SplineMap sm = cubic(); + SplineMap smi = inverted(cubic()); + SplineMap other = cubic(); + Lines got = new Lines() + .add(equal("copy", sm, sm.copy())) + .add(equal("same values", sm, other)) + .add(equal("inverted", sm, smi)); + got.add(equal("inverted twice", sm, inverted((SplineMap) smi.copy()))); + other.set("OutUnit=1, InvNiter=2, InvTol=0.5"); + got.add(equal("attributes differ", sm, other)) + .add(equal("different", sm, linear())) + .add(equal("unitmap", sm, new UnitMap(2))); + double[] cu = CUBIC_CU.clone(); + double[] tx = CUBIC_TX.clone(); + cu[7] += 1.0e-13; + got.add(equal("coefficient within tolerance", sm, new SplineMap(4, 4, 5, 6, CUBIC_TX, CUBIC_TY, cu, CUBIC_CV))); + cu[7] += 1.0e-9; + got.add(equal("coefficient beyond tolerance", sm, new SplineMap(4, 4, 5, 6, CUBIC_TX, CUBIC_TY, cu, CUBIC_CV))); + tx[4] = 1.6; + got.add(equal("knot", sm, new SplineMap(4, 4, 5, 6, tx, CUBIC_TY, CUBIC_CU, CUBIC_CV))); + assertCase("equal", got); + } + + // ------------------------------------------------------------------ + // Dumps read back + // ------------------------------------------------------------------ + + @Test + void aDumpReadBackKeepsTheSimplifiedRecord() { + SplineMap sm = cubic(); + sm.set("InvNiter=9, InvTol=1.0E-9, OutUnit=1"); + sm.invert(); + markSimple(sm); + SplineMap back = (SplineMap) ChannelText.read(ChannelText.dump(sm)); + Lines got = new Lines() + .add(show(back)) + .add(issimple("loaded", back)) + .add(equal("loaded", back, sm)) + .add(attrs(back)); + assertCase("load_roundtrip", got); + } + + @Test + void aDumpWithMissingItems() { + SplineMap sm = (SplineMap) ChannelText.read(" Begin SplineMap\n Nin = 2\n IsA Mapping\n" + + " KX = 1\n KY = 1\n NX = 1\n NY = 1\n" + + " TX1 = 0\n TX2 = 1\n TY1 = 0\n TY2 = 2\n" + + " CU1 = 4\n End SplineMap\n"); + Lines got = new Lines().add(show(sm)).add(attrs(sm)).add(tran(sm, 1, d(0.5, 0.5), true)); + assertCase("load_defaults", got); + } + + // ------------------------------------------------------------------ + // FITS-WCS writes of lsst2.ast + // ------------------------------------------------------------------ + + /** + * The probe's {@code fits_write}: {@code fs} written FITS-WCS into a FitsChan holding NAXIS1 and + * NAXIS2 of 1000, at FitsTol {@code tol} (the default if 0), and the keywords of the cards. + */ + private static String fitsWrite(AstObject fs, double tol, boolean cdMatrix) { + FitsChan fc = new FitsChan(); + fc.setEncoding("FITS-WCS"); + if (tol > 0.0) { + fc.setD("FitsTol", tol); + } + if (cdMatrix) { + fc.setCDMatrix(true); + } + fc.putFits("NAXIS1 = 1000", false); + fc.putFits("NAXIS2 = 1000", false); + int n = fc.write(fs); + StringBuilder sb = new StringBuilder("written ").append(n).append("\nkeywords"); + fc.clear("Card"); + for (String card = fc.findFits("%f", true); card != null; card = fc.findFits("%f", true)) { + sb.append(' ').append(card.substring(0, Math.min(8, card.length())).trim()); + } + return sb.append('\n').toString(); + } + + private static FrameSet readLsst2() { + return (FrameSet) ChannelText.read(Fixtures.read("wcsconv/inputs/lsst2.ast")); + } + + @Test + void writesTheLsst2FrameSet() { + FrameSet fs = readLsst2(); + assertCase("fits_lsst2_tight", fitsWrite(fs, 1.0e-4, false)); + assertCase("fits_lsst2_default", fitsWrite(fs, 0.0, false)); + + Frame detector = new Frame(2); + detector.set("Ident=detector"); + FrameSet outer = new FrameSet(detector); + outer.addFrame(FrameSet.AST__BASE, fs, new SkyFrame()); + int sky = outer.getNframe(); + Frame grid = new Frame(2); + grid.setDomain("GRID"); + outer.addFrame(FrameSet.AST__BASE, new ShiftMap(d(1.0, 1.0)), grid); + outer.setBase(outer.getNframe()); + outer.setCurrent(sky); + assertCase("fits_lsst2_wrapped", fitsWrite(outer, 1.0e-4, true)); + + FrameSet alt = readLsst2(); + int altSky = alt.getNframe(); + Frame myalt = new Frame(2); + myalt.set("Domain=MYALT,Ident=A"); + alt.addFrame(FrameSet.AST__BASE, new UnitMap(2), myalt); + alt.setCurrent(altSky); + assertCase("fits_lsst2_alternate", fitsWrite(alt, 0.0, false) + fitsWrite(alt, 1.0e-4, false)); + } + + @Test + void everyCaseIsRead() { + List read = Arrays.asList( + "isa", + "ctor_errors", + "attrs_default", + "attrs_set", + "attrs_readonly", + "attrs_shared", + "issimple", + "tran_inside", + "tran_outside", + "tran_linear_edges", + "tran_open_knots_x", + "tran_zero_width_x", + "inv_iterations", + "inv_outside", + "order1", + "rate", + "rate_testsplinemap", + "knots_coeffs", + "simp_inverse_after", + "simp_inverse_before", + "simp_same_direction", + "simp_parallel", + "simp_winmap", + "simp_unit_between", + "simp_different_coeffs", + "simp_outunit_differs", + "simp_inverted_cmpmap", + "simp_cmpmap_attrs", + "equal", + "load_roundtrip", + "load_defaults", + "fits_lsst2_tight", + "fits_lsst2_default", + "fits_lsst2_wrapped", + "fits_lsst2_alternate"); + assertEquals(new ArrayList<>(FUSED.keySet()), read); + List pr104 = new ArrayList<>(read); + pr104.addAll(PR104_CASES); + assertEquals(new ArrayList<>(PR104.keySet()), pr104); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/SplineMapTest.java b/src/test/java/uk/ac/starlink/ast/SplineMapTest.java new file mode 100644 index 0000000..8449671 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/SplineMapTest.java @@ -0,0 +1,294 @@ +package uk.ac.starlink.ast; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +/** + * Translation of Rust {@code tests/test_splinemap.rs}, and of the unit test in Rust {@code + * mappings/splinemap.rs}. + * + *

Rust's {@code SplineMap::new} takes the coefficients with the X index varying fastest (CMLIB's + * order); the Java constructor, like C's {@code astSplineMap}, takes them with the Y index varying + * fastest (SciPy's order), so each set of coefficients here is the transpose of Rust's. Rust's + * {@code tx}, {@code ty}, {@code cu} and {@code cv} accessors are {@link SplineMap#splineKnots} and + * {@link SplineMap#splineCoeffs}, which give the coefficients in the constructor's order. + */ +class SplineMapTest { + + private static final double BAD = AstObject.AST__BAD; + + /** + * An order-1 SplineMap over the unit square whose outputs are the constants {@code cu} and + * {@code cv}. + */ + private static SplineMap constantSpline(double cu, double cv) { + return new SplineMap(1, 1, 1, 1, d(0.0, 1.0), d(0.0, 1.0), d(cu), d(cv)); + } + + /** A linear (order 2) SplineMap over the unit square giving u = x, v = y. */ + private static SplineMap identitySpline() { + double[] knots = {0.0, 0.0, 1.0, 1.0}; + return new SplineMap(2, 2, 2, 2, knots, knots.clone(), d(0.0, 0.0, 1.0, 1.0), d(0.0, 1.0, 0.0, 1.0)); + } + + /** A linear SplineMap over the unit square giving u = x + 0.01, v = y + 0.02. */ + private static SplineMap perturbedIdentity() { + double[] knots = {0.0, 0.0, 1.0, 1.0}; + return new SplineMap(2, 2, 2, 2, knots, knots.clone(), d(0.01, 0.01, 1.01, 1.01), d(0.02, 1.02, 0.02, 1.02)); + } + + private static double[] d(double... v) { + return v; + } + + /** The transformation of the points {@code (x[i], y[i])}, as {@code {u, v}}. */ + private static double[][] tran(Mapping m, double[] x, double[] y, boolean forward) { + return m.tran2(x.length, x, y, forward); + } + + @Test + void basicProperties() { + SplineMap m = constantSpline(1.0, 2.0); + assertEquals(2, m.getNin()); + assertEquals(2, m.getNout()); + assertEquals(1, m.getSplineKx()); + assertEquals(1, m.getSplineKy()); + assertEquals(1, m.getSplineNx()); + assertEquals(1, m.getSplineNy()); + assertArrayEquals(d(0.0, 1.0), m.splineKnots(1)); + assertArrayEquals(d(0.0, 1.0), m.splineKnots(2)); + assertArrayEquals(d(1.0), m.splineCoeffs(1)); + assertArrayEquals(d(2.0), m.splineCoeffs(2)); + assertFalse(m.getInvert()); + assertEquals(6, m.getInvNiter()); + assertEquals(1.0e-6, m.getInvTol(), 1.0e-15); + assertFalse(m.getOutUnit()); + } + + @Test + void forwardConstant() { + double[][] out = tran(constantSpline(1.0, 2.0), d(0.2, 0.5, 0.8), d(0.3, 0.5, 0.7), true); + for (int i = 0; i < 3; i++) { + assertEquals(1.0, out[0][i], 1.0e-10, "point " + i); + assertEquals(2.0, out[1][i], 1.0e-10, "point " + i); + } + } + + @Test + void forwardIdentity() { + double[] x = {0.1, 0.3, 0.7, 0.9}; + double[] y = {0.2, 0.4, 0.6, 0.8}; + double[][] out = tran(identitySpline(), x, y, true); + for (int i = 0; i < 4; i++) { + assertEquals(x[i], out[0][i], 1.0e-10, "point " + i); + assertEquals(y[i], out[1][i], 1.0e-10, "point " + i); + } + } + + @Test + void forwardOutsideDomain() { + double[][] out = tran(identitySpline(), d(1.5), d(0.5), true); + assertEquals(BAD, out[0][0]); + assertEquals(BAD, out[1][0]); + } + + @Test + void forwardOutsideWithOutUnit() { + SplineMap m = identitySpline(); + m.setOutUnit(true); + double[][] out = tran(m, d(1.5), d(0.5), true); + assertEquals(1.5, out[0][0], 1.0e-10); + assertEquals(0.5, out[1][0], 1.0e-10); + } + + @Test + void inverseRoundTrip() { + SplineMap m = perturbedIdentity(); + double[][] fwd = tran(m, d(0.5), d(0.5), true); + assertEquals(0.51, fwd[0][0], 1.0e-10); + assertEquals(0.52, fwd[1][0], 1.0e-10); + double[][] inv = tran(m, fwd[0], fwd[1], false); + assertEquals(0.5, inv[0][0], 1.0e-6); + assertEquals(0.5, inv[1][0], 1.0e-6); + } + + @Test + void inverseMultiplePoints() { + SplineMap m = perturbedIdentity(); + double[] x = {0.2, 0.4, 0.6, 0.8}; + double[] y = {0.3, 0.5, 0.7, 0.9}; + double[][] fwd = tran(m, x, y, true); + double[][] inv = tran(m, fwd[0], fwd[1], false); + for (int i = 0; i < 4; i++) { + assertEquals(x[i], inv[0][i], 1.0e-6, "point " + i); + assertEquals(y[i], inv[1][i], 1.0e-6, "point " + i); + } + } + + @Test + void invertFlag() { + SplineMap m = perturbedIdentity(); + assertFalse(m.getInvert()); + m.invert(); + assertTrue(m.getInvert()); + double[][] out = tran(m, d(0.51), d(0.52), true); + assertEquals(0.5, out[0][0], 1.0e-6); + assertEquals(0.5, out[1][0], 1.0e-6); + } + + @Test + void equal() { + SplineMap m1 = perturbedIdentity(); + SplineMap m2 = perturbedIdentity(); + assertTrue(m1.astEqual(m2)); + assertTrue(m2.astEqual(m1)); + assertFalse(m1.astEqual(identitySpline())); + } + + @Test + void equalInvertedNotEqual() { + SplineMap m2 = perturbedIdentity(); + m2.invert(); + assertFalse(perturbedIdentity().astEqual(m2)); + } + + @Test + void serialisationRoundTrip() { + SplineMap m = perturbedIdentity(); + SplineMap m2 = assertInstanceOf(SplineMap.class, ChannelText.read(ChannelText.dump(m))); + assertTrue(m.astEqual(m2)); + assertEquals(2, m2.getSplineKx()); + assertEquals(2, m2.getSplineKy()); + assertEquals(2, m2.getSplineNx()); + assertEquals(2, m2.getSplineNy()); + } + + @Test + void serialisationRoundTripWithAttributes() { + SplineMap m = perturbedIdentity(); + m.setInvNiter(10); + m.setInvTol(1.0e-8); + m.setOutUnit(true); + SplineMap m2 = assertInstanceOf(SplineMap.class, ChannelText.read(ChannelText.dump(m))); + assertEquals(10, m2.getInvNiter()); + assertEquals(1.0e-8, m2.getInvTol(), 1.0e-15); + assertTrue(m2.getOutUnit()); + } + + @Test + void inverseCancellationSimplify() { + SplineMap m2 = perturbedIdentity(); + m2.invert(); + Mapping simp = new CmpMap(perturbedIdentity(), m2, true).simplify(); + assertInstanceOf(UnitMap.class, simp); + } + + @Test + void noCancellationSameDirection() { + Mapping simp = new CmpMap(perturbedIdentity(), perturbedIdentity(), true).simplify(); + assertFalse(simp instanceof UnitMap); + } + + @Test + void noCancellationDifferentCoeffs() { + SplineMap m2 = identitySpline(); + m2.invert(); + Mapping simp = new CmpMap(perturbedIdentity(), m2, true).simplify(); + assertFalse(simp instanceof UnitMap); + } + + @Test + void badInputForward() { + double[][] out = tran(identitySpline(), d(BAD), d(0.5), true); + assertEquals(BAD, out[0][0]); + assertEquals(BAD, out[1][0]); + } + + @Test + void badInputInverse() { + double[][] out = tran(perturbedIdentity(), d(BAD), d(0.5), false); + assertEquals(BAD, out[0][0]); + assertEquals(BAD, out[1][0]); + } + + @Test + void rateForward() { + SplineMap m = identitySpline(); + double[] at = {0.5, 0.5}; + assertEquals(1.0, m.rate(at, 1, 1), 1.0e-6); + assertEquals(0.0, m.rate(at, 1, 2), 1.0e-6); + assertEquals(0.0, m.rate(at, 2, 1), 1.0e-6); + assertEquals(1.0, m.rate(at, 2, 2), 1.0e-6); + } + + @Test + void setInvNiterAndTol() { + SplineMap m = perturbedIdentity(); + m.setInvNiter(10); + assertEquals(10, m.getInvNiter()); + m.setInvTol(1.0e-8); + assertEquals(1.0e-8, m.getInvTol(), 1.0e-15); + } + + @Test + void copyIsEqual() { + SplineMap m = perturbedIdentity(); + assertTrue(m.astEqual(m.copy())); + } + + /** + * The lower edge and a point just inside the upper edge give good values; on the upper edge in + * Y, (1, 1), the pinned C gives bad values for this spline, which has a single knot interval + * along Y, and the PR that hardens it, which Java follows, the spline's value ({@code + * SplineMapProbeTest}, case {@code tran_linear_edges}). + */ + @Test + void edgeOfDomain() { + double[][] out = tran(identitySpline(), d(0.0, 0.999), d(0.0, 0.999), true); + assertEquals(0.0, out[0][0], 1.0e-10); + assertEquals(0.0, out[1][0], 1.0e-10); + assertEquals(0.999, out[0][1], 1.0e-10); + assertEquals(0.999, out[1][1], 1.0e-10); + } + + /** + * A NaN input is bad, in both directions and for the rate, with OutUnit set or not, as for + * every Mapping; the pinned C reads beyond its arrays for a NaN, and the PR that hardens it gives + * the default value, the NaN itself with OutUnit set. + */ + @Test + void nanInputIsBad() { + double nan = Double.NaN; + for (boolean outUnit : new boolean[] {false, true}) { + SplineMap m = perturbedIdentity(); + m.setOutUnit(outUnit); + for (boolean forward : new boolean[] {true, false}) { + double[][] out = tran(m, d(nan, 0.5), d(0.5, nan), forward); + for (int c = 0; c < 2; c++) { + assertEquals(BAD, out[c][0], "OutUnit " + outUnit + " forward " + forward); + assertEquals(BAD, out[c][1], "OutUnit " + outUnit + " forward " + forward); + } + } + assertEquals(BAD, m.rate(d(nan, 0.5), 1, 1)); + assertEquals(BAD, m.rate(d(0.5, nan), 2, 2)); + } + } + + /** + * A derivative of the spline's order or higher is zero, not bad (splinemap.c {@code Dbvalu}): + * an order-1 spline is constant on each piece. + */ + @Test + void dbvaluHighOrderDerivativeIsZero() { + double[] t = {0.0, 1.0}; + double[] a = {1.5}; + double[] work = new double[3]; + assertEquals(1.5, SplineMap.dbvalu(t, 0, a, 0, 1, 1, 0, 0.5, 0, work, 0, new int[2])); + assertEquals(0.0, SplineMap.dbvalu(t, 0, a, 0, 1, 1, 1, 0.5, 0, work, 0, new int[2])); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/TranDefinednessTest.java b/src/test/java/uk/ac/starlink/ast/TranDefinednessTest.java index aaee6ce..41a7851 100644 --- a/src/test/java/uk/ac/starlink/ast/TranDefinednessTest.java +++ b/src/test/java/uk/ac/starlink/ast/TranDefinednessTest.java @@ -11,8 +11,6 @@ * Translation of Rust {@code tests/test_tran_definedness.rs}: which directions a Mapping defines, * its TranForward and TranInverse attributes, in its current orientation, a CmpMap combining its * components'. - * - *

{@code chebymap_forward_only_has_no_inverse} needs a class not yet ported. */ class TranDefinednessTest { @@ -42,6 +40,18 @@ void polymapIterInverseProvidesInverse() { assertTrue(pm.getTranInverse()); } + /** + * A ChebyMap never uses an iterative inverse (chebymap.c {@code GetIterInverse} gives 0), so a + * forward-only ChebyMap has no inverse. + */ + @Test + void chebymapForwardOnlyHasNoInverse() { + ChebyMap cm = new ChebyMap( + 1, 1, 1, new double[] {1.0, 1.0, 1.0}, 0, null, new double[] {0.0}, new double[] {1.0}, null, null); + assertTrue(cm.getTranForward()); + assertFalse(cm.getTranInverse()); + } + @Test void polymapInvertSwapsDefinedness() { PolyMap pm = fwdOnlyPolymap(); diff --git a/src/test/java/uk/ac/starlink/ast/TransformOracleTest.java b/src/test/java/uk/ac/starlink/ast/TransformOracleTest.java index f2d0810..3d0d978 100644 --- a/src/test/java/uk/ac/starlink/ast/TransformOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/TransformOracleTest.java @@ -85,10 +85,11 @@ class TransformOracleTest { * failed both the direct and the aliased comparison. {@code * referenceRtripGapsAreExactlyTheRecordedSet} checks this against the oracle files alone. * - *

tnx-cheb has no inverse: its TNX Chebyshev distortion builds a ChebyMap, which cannot - * represent its own Jacobian, so sky to pixel is BAD for every row (both relpaths name the same - * object). tsc row 10 is a 360-degree alias: the image is wider than the quad-cube period. - * total_hi row 3 is an all-sky CAR header whose corner pixel does not recover. + *

tnx-cheb holds no ChebyMap: C turns the TNX Chebyshev distortion into the polynomial of a + * TPN WcsMap, and C's own recorded sky to pixel values, though finite, recover the recorded pixel + * in no row (both relpaths name the same object). tsc row 10 is a 360-degree alias: the image + * is wider than the quad-cube period. total_hi row 3 is an all-sky CAR header whose corner + * pixel does not recover. */ private static final Map> RTRIP_REFERENCE_GAPS_LICENSED = rtripGaps(); @@ -521,15 +522,23 @@ static Overrides committedOverrides() { static final class ExcusedRows { final String relpath; final boolean forward; + + /** + * What the rows count: {@code forward} or {@code inverse}, or, for a probe's rows, {@code + * other}, the case's lines that are not transformed points. + */ + final String kind; + final SortedSet rows; final String cause; /** Whether the rows may match C on some runtimes (a cause starting {@link #MAY_MATCH}). */ final boolean mayMatch; - ExcusedRows(String relpath, boolean forward, SortedSet rows, String cause) { + ExcusedRows(String relpath, String kind, SortedSet rows, String cause) { this.relpath = relpath; - this.forward = forward; + this.forward = "forward".equals(kind); + this.kind = kind; this.rows = Collections.unmodifiableSortedSet(rows); this.cause = cause; this.mayMatch = cause.startsWith(MAY_MATCH); @@ -545,7 +554,9 @@ static String sectionKey(String relpath, boolean forward) { * Parses the text of {@code deferred/oracle-rows.txt}: lines {@code * | }, the rows numbered from 0 and separated by commas, with {@code #} comments * and blank lines ignored; a cause starting {@link #MAY_MATCH} marks rows that may match C on - * some runtimes. The result is keyed by {@link #sectionKey}. + * some runtimes. An entry of a probe's rows ({@link #isProbeRows}) may instead give {@code + * other} for the direction, counting the case's lines that are not transformed points. The + * result is keyed by {@link #sectionKey}, or the probe entry and {@code other}. * * @throws IllegalArgumentException for a malformed line, or a section listed twice */ @@ -566,13 +577,10 @@ private static Map oracleRowsFrom(Map entri throw new IllegalArgumentException( what + ": expected \" | \": " + e.getKey()); } - boolean forward; - if ("forward".equals(toks[1])) { - forward = true; - } else if ("inverse".equals(toks[1])) { - forward = false; - } else { - throw new IllegalArgumentException(what + ": direction must be forward or inverse: " + e.getKey()); + String kind = toks[1]; + if (!"forward".equals(kind) && !"inverse".equals(kind) && !("other".equals(kind) && isProbeRows(toks[0]))) { + throw new IllegalArgumentException( + what + ": direction must be forward or inverse, or other for a probe: " + e.getKey()); } SortedSet rows = new TreeSet<>(); String list = toks[2]; @@ -597,8 +605,8 @@ private static Map oracleRowsFrom(Map entri } i = j + 1; } - String key = sectionKey(toks[0], forward); - if (out.put(key, new ExcusedRows(toks[0], forward, rows, e.getValue())) != null) { + String key = toks[0] + " " + kind; + if (out.put(key, new ExcusedRows(toks[0], kind, rows, e.getValue())) != null) { throw new IllegalArgumentException(what + ": " + key + " listed twice"); } } @@ -1033,7 +1041,57 @@ static boolean isSlamapSection(String relpath) { } static boolean isSimplifySection(String relpath) { - return !isHeadSection(relpath) && !isSlamapSection(relpath); + return !isHeadSection(relpath) && !isSlamapSection(relpath) && !isProbeRows(relpath); + } + + /** + * Whether an entry of {@code deferred/oracle-rows.txt} names rows of a C probe's output ({@code + * probes//}), which the probe's own test reads, rather than an oracle section. + */ + static boolean isProbeRows(String relpath) { + return relpath.startsWith("probes/"); + } + + /** + * The probes whose rows {@code deferred/oracle-rows.txt} may list, each with the prefix of its + * entries ({@code probes//}) that the test reading and checking them declares as its + * {@code ROWS_PREFIX}. + */ + static final Map PROBE_ROW_TESTS = probeRowTests(); + + private static Map probeRowTests() { + Map m = new TreeMap<>(); + m.put("chebymap_probe", ChebyMapProbeTest.ROWS_PREFIX); + m.put("normmap_probe", NormMapProbeTest.ROWS_PREFIX); + m.put("splinemap_probe", SplineMapProbeTest.ROWS_PREFIX); + return Collections.unmodifiableMap(m); + } + + /** + * What is wrong with the probe entries of {@code listed}: an entry naming a probe that no test + * in {@code owners} reads, or a registered prefix that is not its probe's. + */ + static List unclaimedProbeRows(Map listed, Map owners) { + List problems = new ArrayList<>(); + for (ExcusedRows x : listed.values()) { + if (!isProbeRows(x.relpath)) { + continue; + } + String rest = x.relpath.substring("probes/".length()); + int slash = rest.indexOf('/'); + String probe = slash < 0 ? rest : rest.substring(0, slash); + if (!owners.containsKey(probe)) { + problems.add(ORACLE_ROWS + ".txt names " + x.relpath + ", of probe " + probe + + ", which no test in PROBE_ROW_TESTS reads"); + } + } + for (Map.Entry e : owners.entrySet()) { + if (!("probes/" + e.getKey() + "/").equals(e.getValue())) { + problems.add("PROBE_ROW_TESTS gives " + e.getValue() + " for " + e.getKey() + ", not probes/" + + e.getKey() + "/"); + } + } + return problems; } /** The fixtures of an oracle's reports, each with its sections, in oracle order. */ @@ -1455,10 +1513,16 @@ void malformedOracleRowLinesAreHardErrors() { "a.head inverse 1, | cause", "a.head inverse x | cause", "a.head inverse 1,1 | cause", - "a.head inverse 1 | cause\na.head inverse 2 | cause"); + "a.head inverse 1 | cause\na.head inverse 2 | cause", + "a.head other 1 | cause"); for (String line : bad) { assertThrows(IllegalArgumentException.class, () -> parseOracleRows(line + "\n", "test"), line); } + // A probe's lines that are not transformed points are a third kind of rows. + ExcusedRows other = + parseOracleRows("probes/p/case other 2 | c\n", "test").get("probes/p/case other"); + assertEquals("other", other.kind); + assertFalse(other.forward); // The two directions of one fixture are two sections. assertEquals( 2, @@ -1466,6 +1530,20 @@ void malformedOracleRowLinesAreHardErrors() { .size()); } + @Test + void everyProbeRowEntryIsReadByItsProbeTest() { + List problems = unclaimedProbeRows(committedOracleRows(), PROBE_ROW_TESTS); + assertTrue(problems.isEmpty(), String.join("\n", problems)); + Map other = parseOracleRows("probes/other_probe/case forward 0 | c\n", "test"); + assertEquals(1, unclaimedProbeRows(other, PROBE_ROW_TESTS).size()); + assertEquals( + 1, + unclaimedProbeRows( + Collections.emptyMap(), + Collections.singletonMap("other_probe", NormMapProbeTest.ROWS_PREFIX)) + .size()); + } + @Test void parsesCommittedOracleRows() { for (ExcusedRows x : committedOracleRows().values()) { @@ -1530,6 +1608,14 @@ void oracleRowEntriesMustNameComparedSections() { 1, excusedRowEntryProblems(listed, npoints, TransformOracleTest::isSimplifySection) .size()); + // Rows of a probe's output belong to no gate. + Map probeRows = parseOracleRows("probes/p/case forward 0 | c\n", "test"); + for (Predicate gate : Arrays.>asList( + TransformOracleTest::isHeadSection, + TransformOracleTest::isSlamapSection, + TransformOracleTest::isSimplifySection)) { + assertTrue(excusedRowEntryProblems(probeRows, npoints, gate).isEmpty()); + } } // ------------------------------------------------------------------ diff --git a/src/test/java/uk/ac/starlink/ast/UnitNormMapTest.java b/src/test/java/uk/ac/starlink/ast/UnitNormMapTest.java new file mode 100644 index 0000000..b37fe74 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/UnitNormMapTest.java @@ -0,0 +1,447 @@ +package uk.ac.starlink.ast; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static uk.ac.starlink.ast.MappingTestData.point; +import static uk.ac.starlink.ast.MappingTestData.transformRows; + +import java.util.Arrays; +import org.junit.jupiter.api.Test; + +/** + * Translation of Rust {@code tests/test_unitnormmap.rs} (C's {@code unitnormmap.c} and {@code + * testunitnormmap.c}): the unit vector and norm of the forward transformation, the vector of the + * inverse, the zero-norm and bad cases, inversion, comparison, dumps, and the merges with + * ShiftMaps, WinMaps and other UnitNormMaps. Rust's {@code try_merge} tests, a Rust-only API, + * simplify the pair in a CmpMap instead, which reaches the same merge (unitnormmap.c {@code + * MapMerge}). {@code NormMapProbeTest} holds the values C gives. + */ +class UnitNormMapTest { + + private static final double BAD = AstObject.AST__BAD; + + private static UnitNormMap unm(double... centre) { + return new UnitNormMap(centre.length, centre); + } + + private static UnitNormMap inverted(UnitNormMap m) { + m.invert(); + return m; + } + + private static double[] fwd(Mapping m, double... p) { + return point(transformRows(m, true, p), 0); + } + + private static double[] inv(Mapping m, double... p) { + return point(transformRows(m, false, p), 0); + } + + // ------------------------------------------------------------------ + // Forward transformation + // ------------------------------------------------------------------ + + @Test + void forwardBasicOrigin() { + UnitNormMap m = unm(0.0, 0.0); + assertEquals(2, m.getNin()); + assertEquals(3, m.getNout()); + double[] p = fwd(m, 3.0, 4.0); + assertEquals(3, p.length); + assertEquals(0.6, p[0], 1e-14); + assertEquals(0.8, p[1], 1e-14); + assertEquals(5.0, p[2], 1e-14); + } + + @Test + void forwardWithCentre() { + double[] p = fwd(unm(1.0, -1.0), 5.0, 2.0); + assertEquals(0.8, p[0], 1e-14); + assertEquals(0.6, p[1], 1e-14); + assertEquals(5.0, p[2], 1e-14); + } + + @Test + void forwardZeroVector() { + assertArrayEquals(new double[] {BAD, BAD, 0.0}, fwd(unm(1.0, 2.0), 1.0, 2.0)); + } + + @Test + void forwardBadInput() { + assertArrayEquals(new double[] {BAD, BAD, BAD}, fwd(unm(0.0, 0.0), BAD, 4.0)); + } + + @Test + void forwardMultiplePoints() { + double[][] out = + transformRows(unm(0.0, 0.0, 0.0), true, new double[] {1.0, 0.0, 0.0}, new double[] {0.0, 0.0, 0.0}); + double[] p0 = point(out, 0); + assertEquals(1.0, p0[0], 1e-14); + assertEquals(0.0, p0[1], 1e-14); + assertEquals(0.0, p0[2], 1e-14); + assertEquals(1.0, p0[3], 1e-14); + assertArrayEquals(new double[] {BAD, BAD, BAD, 0.0}, point(out, 1)); + } + + // ------------------------------------------------------------------ + // Inverse transformation + // ------------------------------------------------------------------ + + @Test + void inverseBasic() { + double[] p = inv(unm(0.0, 0.0), 0.6, 0.8, 5.0); + assertEquals(3.0, p[0], 1e-14); + assertEquals(4.0, p[1], 1e-14); + } + + @Test + void inverseWithCentre() { + double[] p = inv(unm(1.0, -1.0), 0.8, 0.6, 5.0); + assertEquals(5.0, p[0], 1e-14); + assertEquals(2.0, p[1], 1e-14); + } + + @Test + void inverseZeroNorm() { + assertArrayEquals(new double[] {3.0, 7.0}, inv(unm(3.0, 7.0), 999.0, -42.0, 0.0)); + } + + @Test + void inverseBadNorm() { + assertArrayEquals(new double[] {BAD, BAD}, inv(unm(0.0, 0.0), 0.6, 0.8, BAD)); + } + + @Test + void inverseBadComponent() { + double[] p = inv(unm(0.0, 0.0), BAD, 0.8, 5.0); + assertEquals(BAD, p[0]); + assertEquals(4.0, p[1], 1e-14); + } + + // ------------------------------------------------------------------ + // Round trips + // ------------------------------------------------------------------ + + @Test + void roundtripForwardInverse() { + UnitNormMap m = unm(2.0, -3.0, 1.5); + double[] mid = fwd(m, 5.0, -1.0, 4.0); + double[] p = inv(m, mid); + assertEquals(5.0, p[0], 1e-12); + assertEquals(-1.0, p[1], 1e-12); + assertEquals(4.0, p[2], 1e-12); + } + + @Test + void roundtripInverseForward() { + UnitNormMap m = unm(1.0, 1.0); + double[] mid = inv(m, 0.6, 0.8, 10.0); + double[] p = fwd(m, mid); + assertEquals(0.6, p[0], 1e-12); + assertEquals(0.8, p[1], 1e-12); + assertEquals(10.0, p[2], 1e-12); + } + + // ------------------------------------------------------------------ + // Inversion + // ------------------------------------------------------------------ + + @Test + void invertedNinNout() { + UnitNormMap m = unm(0.0, 0.0); + assertEquals(2, m.getNin()); + assertEquals(3, m.getNout()); + assertFalse(m.getInvert()); + m.invert(); + assertEquals(3, m.getNin()); + assertEquals(2, m.getNout()); + assertTrue(m.getInvert()); + } + + @Test + void invertedTransform() { + double[] p = fwd(inverted(unm(0.0, 0.0)), 0.6, 0.8, 5.0); + assertEquals(3.0, p[0], 1e-14); + assertEquals(4.0, p[1], 1e-14); + } + + // ------------------------------------------------------------------ + // Comparison + // ------------------------------------------------------------------ + + @Test + void equalSame() { + assertTrue(unm(1.0, 2.0, 3.0).astEqual(unm(1.0, 2.0, 3.0))); + } + + @Test + void equalDifferentCentre() { + assertFalse(unm(1.0, 2.0).astEqual(unm(1.0, 3.0))); + } + + @Test + void equalDifferentDim() { + assertFalse(unm(1.0, 2.0).astEqual(unm(1.0, 2.0, 0.0))); + } + + @Test + void equalDifferentInvert() { + assertFalse(unm(1.0, 2.0).astEqual(inverted(unm(1.0, 2.0)))); + } + + // ------------------------------------------------------------------ + // Dumps + // ------------------------------------------------------------------ + + @Test + void serializationRoundtrip() { + UnitNormMap m = unm(1.5, -2.0, 0.0); + String s = ChannelText.dump(m); + assertTrue(s.contains("UnitNormMap")); + assertTrue(s.contains("Ctr1")); + assertTrue(s.contains("Ctr2")); + // A zero centre is not written. + assertFalse(s.contains("Ctr3")); + UnitNormMap back = assertInstanceOf(UnitNormMap.class, ChannelText.read(s)); + assertTrue(m.astEqual(back)); + assertArrayEquals(new double[] {1.5, -2.0, 0.0}, back.getCentre()); + } + + @Test + void serializationInvertedRoundtrip() { + UnitNormMap m = inverted(unm(10.0, 20.0)); + String s = ChannelText.dump(m); + assertTrue(s.contains("Invert")); + UnitNormMap back = assertInstanceOf(UnitNormMap.class, ChannelText.read(s)); + assertTrue(m.astEqual(back)); + assertTrue(back.getInvert()); + } + + // ------------------------------------------------------------------ + // Merges + // ------------------------------------------------------------------ + + private static Mapping series(Mapping a, Mapping b) { + return new CmpMap(a, b, true).simplify(); + } + + @Test + void mergeInverseCancelSameCentre() { + Mapping r = series(unm(1.0, 2.0), inverted(unm(1.0, 2.0))); + assertInstanceOf(UnitMap.class, r); + assertEquals(2, r.getNin()); + } + + @Test + void mergeDifferentCentreToShift() { + Mapping r = series(unm(1.0, 2.0), inverted(unm(4.0, 6.0))); + assertInstanceOf(ShiftMap.class, r); + assertEquals(2, r.getNin()); + double[] p = fwd(r, 0.0, 0.0); + assertEquals(3.0, p[0], 1e-14); + assertEquals(4.0, p[1], 1e-14); + } + + @Test + void mergeUnitnormmapInvPlusShift() { + Mapping r = series(inverted(unm(1.0, 2.0)), new ShiftMap(new double[] {3.0, -1.0})); + UnitNormMap merged = assertInstanceOf(UnitNormMap.class, r); + assertTrue(merged.getInvert()); + assertArrayEquals(new double[] {4.0, 1.0}, merged.getCentre(), 1e-14); + } + + @Test + void mergeShiftPlusUnitnormmapFwd() { + Mapping r = series(new ShiftMap(new double[] {3.0, -1.0}), unm(5.0, 10.0)); + UnitNormMap merged = assertInstanceOf(UnitNormMap.class, r); + assertFalse(merged.getInvert()); + assertArrayEquals(new double[] {2.0, 11.0}, merged.getCentre(), 1e-14); + } + + @Test + void mergeWinmapUnitScalePlusUnitnormmapFwd() { + WinMap win = new WinMap(new double[] {2.0, 3.0}, new double[] {1.0, 1.0}); + UnitNormMap merged = assertInstanceOf(UnitNormMap.class, series(win, unm(5.0, 10.0))); + assertFalse(merged.getInvert()); + assertArrayEquals(new double[] {3.0, 7.0}, merged.getCentre(), 1e-14); + } + + @Test + void noMergeWinmapNonUnitScale() { + WinMap win = new WinMap(new double[] {2.0, 3.0}, new double[] {2.0, 1.0}); + assertInstanceOf(CmpMap.class, series(win, unm(5.0, 10.0))); + } + + @Test + void mergeUnitnormmapInvPlusWinmapUnitScale() { + WinMap win = new WinMap(new double[] {3.0, -1.0}, new double[] {1.0, 1.0}); + UnitNormMap merged = assertInstanceOf(UnitNormMap.class, series(inverted(unm(1.0, 2.0)), win)); + assertTrue(merged.getInvert()); + assertArrayEquals(new double[] {4.0, 1.0}, merged.getCentre(), 1e-14); + } + + @Test + void noMergeParallel() { + assertInstanceOf(CmpMap.class, new CmpMap(unm(0.0, 0.0), unm(0.0, 0.0), false).simplify()); + } + + // ------------------------------------------------------------------ + // One axis and large values + // ------------------------------------------------------------------ + + @Test + void oneDimensional() { + UnitNormMap m = unm(2.0); + assertEquals(1, m.getNin()); + assertEquals(2, m.getNout()); + double[] p = fwd(m, 5.0); + assertEquals(1.0, p[0], 1e-14); + assertEquals(3.0, p[1], 1e-14); + p = fwd(m, -1.0); + assertEquals(-1.0, p[0], 1e-14); + assertEquals(3.0, p[1], 1e-14); + } + + @Test + void largeValuesNoOverflow() { + double big = 1.0e300; + double[] p = fwd(unm(0.0, 0.0), big, big); + double expected = 1.0 / Math.sqrt(2.0); + assertEquals(expected, p[0], 1e-10); + assertEquals(expected, p[1], 1e-10); + double expectedNorm = big * Math.sqrt(2.0); + assertTrue(Math.abs(p[2] - expectedNorm) / expectedNorm < 1e-10); + } + + // ------------------------------------------------------------------ + // testunitnormmap.c + // ------------------------------------------------------------------ + + /** testunitnormmap.c's {@code differ}: a relative difference of 1e-14, with a floor of 1e-14. */ + private static boolean differ(double a, double b) { + return Math.abs(a - b) > Math.max(Math.abs(0.5 * (a + b)) * 1.0e-14, 1.0e-14); + } + + /** + * C's {@code checkroundtrip} (testunitnormmap.c): {@code pos} survives the forward then inverse + * transformation, and the series CmpMap of the Mapping and its inverse. + */ + private static boolean roundTrips(UnitNormMap map, double[] pos) { + double[] back = inv(map, fwd(map, pos)); + Mapping invmap = (Mapping) map.copy(); + invmap.invert(); + double[] through = fwd(new CmpMap(map, invmap, true), pos); + for (int i = 0; i < pos.length; i++) { + if (differ(back[i], pos[i]) || differ(through[i], pos[i])) { + return false; + } + } + return true; + } + + /** + * Errors 5, 6 and 6b of testunitnormmap.c for one to three axes. At the centre the forward + * transformation gives bad unit components and a zero norm, and the inverse gives the centre + * back, because a zero norm takes precedence over bad components (unitnormmap.c inverse). + */ + @Test + void notLinearAndRoundTripsIncludingTheCentre() { + double[] centre = {-1.0, 1.0, 2.0}; + double[] frompos = {-22.0, 3.0, 0.5}; + for (int nin = 1; nin <= 3; nin++) { + UnitNormMap map = new UnitNormMap(nin, centre); + assertFalse(map.isLinear(), "Error 5, nin=" + nin); + assertEquals("0", map.getC("IsLinear"), "Error 5, nin=" + nin); + assertTrue(roundTrips(map, Arrays.copyOf(frompos, nin)), "Error 6, nin=" + nin); + assertTrue(roundTrips(map, Arrays.copyOf(centre, nin)), "Error 6b, nin=" + nin); + } + } + + /** + * testunitnormmap.c {@code testsimplify}: seven series pairs of UnitNormMaps, a ShiftMap and + * unit-scale WinMaps, each simplified to C's class with the same inputs, outputs and + * transformed values (C's {@code differ}). + */ + @Test + void cTestsimplify() { + double[] centre1 = {2.0, -1.0, 0.0}; + double[] centre2 = {-1.0, 6.0, 4.0}; + double[] shift = {3.0, 7.0, -9.0}; + double[] zeros = {0.0, 0.0, 0.0}; + double[] ones = {1.0, 1.0, 1.0}; + UnitNormMap unm1 = new UnitNormMap(3, centre1); + UnitNormMap unm1inv = (UnitNormMap) unm1.copy(); + unm1inv.setInvert(true); + UnitNormMap unm2 = new UnitNormMap(3, centre2); + UnitNormMap unm2inv = (UnitNormMap) unm2.copy(); + unm2inv.setInvert(true); + ShiftMap shiftmap = new ShiftMap(shift); + double[] a = new double[3]; + for (int i = 0; i < 3; i++) { + a[i] = ones[i] + shift[i]; + } + WinMap winmap1 = new WinMap(3, zeros, shift, ones, a); + for (int i = 0; i < 3; i++) { + a[i] = 2 * ones[i] + shift[i]; + } + WinMap winmap2 = new WinMap(3, zeros, shift, ones, a); + Mapping[][] cases = { + {unm1, unm2inv}, + {shiftmap, unm2}, + {winmap1, unm1}, + {winmap2, unm1}, + {unm1inv, shiftmap}, + {unm1inv, winmap1}, + {unm1inv, winmap2} + }; + String[] cls = {"ShiftMap", "UnitNormMap", "UnitNormMap", "CmpMap", "UnitNormMap", "UnitNormMap", "CmpMap"}; + double[][] testpoints = {{1.0, 3.0, -5.0}, {2.0, 3.0, 99.0}, {-6.0, -5.0, -7.0}, {30.0, 21.0, 37.0}}; + for (int i = 0; i < cases.length; i++) { + CmpMap cmp = new CmpMap(cases[i][0], cases[i][1], true); + Mapping simp = cmp.simplify(); + assertEquals(cls[i], simp.astClass(), "case " + i + ": Simplify error 1"); + int nin = cmp.getNin(); + int nout = cmp.getNout(); + assertEquals(nin, simp.getNin(), "case " + i + ": Simplify error 2"); + assertEquals(nout, simp.getNout(), "case " + i + ": Simplify error 3"); + double[][] in = Arrays.copyOf(testpoints, nin); + double[][] o1 = cmp.tranP(3, nin, in, true, nout); + double[][] o2 = simp.tranP(3, nin, in, true, nout); + for (int j = 0; j < nout; j++) { + for (int k = 0; k < 3; k++) { + assertFalse( + differ(o1[j][k], o2[j][k]), + "case " + i + ": Simplify error 4: " + o1[j][k] + " vs " + o2[j][k]); + } + } + } + } + + // ------------------------------------------------------------------ + // Loading (not in the Rust tests) + // ------------------------------------------------------------------ + + /** + * A description with no inputs is refused with C's message, and one without one more output + * than inputs is refused too: the pinned C stores two inputs and four outputs, and its forward + * transformation then leaves the third output unwritten. + */ + @Test + void loadingRefusesBadCounts() { + String text = ChannelText.dump(unm(1.0, 2.0)); + assertInstanceOf(UnitNormMap.class, ChannelText.read(text)); + AstException e = + assertThrows(AstException.class, () -> ChannelText.read(text.replace(" Nout = 3", " Nout = 4"))); + assertEquals(AstException.AST__LDERR, e.getStatus()); + e = assertThrows( + AstException.class, + () -> ChannelText.read( + text.replace(" Nin = 2", " Nin = 0").replace(" Nout = 3", " Nout = 1"))); + assertEquals(AstException.AST__LDERR, e.getStatus()); + assertTrue(e.getMsgText().contains("The UnitNormMap has 0 axes - it must have at least one."), e.getMsgText()); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/XphMapTest.java b/src/test/java/uk/ac/starlink/ast/XphMapTest.java new file mode 100644 index 0000000..be12e7b --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/XphMapTest.java @@ -0,0 +1,491 @@ +package uk.ac.starlink.ast; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.fasterxml.jackson.databind.JsonNode; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.ProbeData; +import uk.ac.starlink.ast.testsupport.ProbeOutput; + +/** + * Translation of Rust {@code tests/test_xphmap.rs} (C's {@code testxphmap.c} and {@code + * xphmap.c}): an XphMap of each projection type loads, is written and read back and compares + * equal, an HPX12 XphMap's inverse recovers every point its forward transformation accepts, an + * unknown projection type is refused, only an HPX12 XphMap is linear, a value that is not finite + * is bad, and each type's transformations match C's bit for bit over the half-pixel grid of the + * {@code xphmap} oracle ({@code oracle/xphmap.json}). The tests from {@code probes/xphmap_probe.c} + * hold C's dumps, comparisons and simplifications; the others check the constructor's and the + * loader's refusals. + * + *

XphMap has no public constructor, in C or here, so most XphMaps are read from a dump, as the C + * test reads them. + */ +class XphMapTest { + + private static final double BAD = AstObject.AST__BAD; + + private static final Map PROBE = ProbeOutput.load("xphmap_probe"); + + private static String dump(int order, String type) { + return " Begin XphMap\n Nin = 2\n IsA Mapping\n Order = " + order + "\n Type = \"" + type + + "\"\n End XphMap\n"; + } + + private static XphMap load(int order, String type) { + return assertInstanceOf(XphMap.class, ChannelText.read(dump(order, type))); + } + + // ------------------------------------------------------------------ + // test_xphmap.rs + // ------------------------------------------------------------------ + + /** + * testxphmap.c {@code check_type}: each projection name loads as an XphMap of two inputs and + * outputs, a re-dump keeps its Order and Type, and two loads of the same dump are equal. + */ + @Test + void everyProjectionTypeLoadsAndRoundTrips() { + String[] types = {"HPX0", "HPX12", "XPHN", "XPHS"}; + int[] orders = {14, 8, 10, 10}; + for (int k = 0; k < types.length; k++) { + XphMap map = load(orders[k], types[k]); + assertEquals(2, map.getNin(), types[k]); + assertEquals(2, map.getNout(), types[k]); + String text = ChannelText.dump(map); + assertTrue(text.contains("Type = \"" + types[k] + "\""), types[k] + ": " + text); + assertTrue(text.contains("Order = " + orders[k]), types[k] + ": " + text); + assertTrue(load(orders[k], types[k]).astEqual(map), types[k]); + } + } + + /** + * testxphmap.c {@code check_transform}: an HPX12 XphMap's inverse recovers every point its + * forward transformation accepts, over a scan of the projection. + */ + @Test + void hpx12RoundTripsEveryGoodPoint() { + XphMap map = load(8, "HPX12"); + double lim = 5.0 * (1 << 8); + List pts = new ArrayList<>(); + for (double x = 0.0; x <= lim; x += 37.0) { + for (double y = 0.0; y <= lim; y += 37.0) { + pts.add(new double[] {x, y}); + } + } + int n = pts.size(); + double[] xin = new double[n]; + double[] yin = new double[n]; + for (int i = 0; i < n; i++) { + xin[i] = pts.get(i)[0]; + yin[i] = pts.get(i)[1]; + } + double[][] mid = map.tran2(n, xin, yin, true); + double[][] back = map.tran2(n, mid[0], mid[1], false); + int ngood = 0; + for (int i = 0; i < n; i++) { + if (mid[0][i] == BAD || mid[1][i] == BAD) { + continue; + } + ngood++; + assertTrue( + Math.abs(back[0][i] - xin[i]) <= 1.0e-8 && Math.abs(back[1][i] - yin[i]) <= 1.0e-8, + "(" + xin[i] + ", " + yin[i] + ") round tripped to (" + back[0][i] + ", " + back[1][i] + ")"); + } + assertTrue(ngood >= 20, "only " + ngood + " of " + n + " scanned points were on the sphere"); + } + + /** testxphmap.c {@code check_bad_type}: a Type that is not a projection name is refused, with C's AST__OPT. */ + @Test + void anUnknownTypeIsRefused() { + AstException e = assertThrows(AstException.class, () -> ChannelText.read(dump(8, "NOSUCHPROJECTION"))); + assertEquals(AstException.AST__OPT, e.getStatus()); + } + + /** Each projection type's forward and inverse transformations against C's, bit for bit, over the oracle's grid. */ + @Test + void transformationsMatchTheCLibraryBitForBit() { + JsonNode consts = ProbeData.load("xphmap"); + int order = consts.get("ORDER").asInt(); + int steps = consts.get("STEPS").asInt(); + int n = steps * steps; + double[] xin = new double[n]; + double[] yin = new double[n]; + for (int i = 0; i < steps; i++) { + for (int j = 0; j < steps; j++) { + xin[i * steps + j] = -1.0 + 0.5 * i; + yin[i * steps + j] = -1.0 + 0.5 * j; + } + } + List failures = new ArrayList<>(); + int ncase = 0; + for (JsonNode c : consts.get("CASES")) { + ncase++; + String type = c.get(0).asText(); + boolean forward = c.get(1).asBoolean(); + double[][] got = load(order, type).tran2(n, xin, yin, forward); + for (int i = 0; i < n; i++) { + double wantX = ProbeData.toDouble(c.get(2).get(i)); + double wantY = ProbeData.toDouble(c.get(3).get(i)); + if (Double.doubleToRawLongBits(got[0][i]) != Double.doubleToRawLongBits(wantX) + || Double.doubleToRawLongBits(got[1][i]) != Double.doubleToRawLongBits(wantY)) { + failures.add(type + (forward ? " forward" : " inverse") + ": (" + xin[i] + ", " + yin[i] + + ") gave (" + got[0][i] + ", " + got[1][i] + "), C (" + wantX + ", " + wantY + ")"); + } + } + } + assertEquals(8, ncase); + assertTrue(failures.isEmpty(), failures.size() + " differ:\n" + String.join("\n", failures)); + } + + /** xphmap.c {@code GetIsLinear}: only an HPX12 XphMap is linear. */ + @Test + void onlyHpx12IsLinear() { + assertFalse(load(4, "HPX0").isLinear()); + assertTrue(load(4, "HPX12").isLinear()); + assertFalse(load(4, "XPHN").isLinear()); + assertFalse(load(4, "XPHS").isLinear()); + } + + /** + * A NaN or infinite input is bad, as for every Mapping, in both directions and for every + * projection; it is not taken as a position in a cell. + */ + @Test + void aNonFiniteInputGivesBadOutputs() { + for (String type : new String[] {"HPX0", "HPX12", "XPHN", "XPHS"}) { + XphMap map = load(3, type); + for (boolean forward : new boolean[] {true, false}) { + for (double v : new double[] {Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY}) { + double[][] pts = {{v, 5.0}, {5.0, v}}; + for (double[] pt : pts) { + double[][] out = map.tran2(1, new double[] {pt[0]}, new double[] {pt[1]}, forward); + assertEquals(BAD, out[0][0], type + " forward=" + forward + " input " + pt[0] + "," + pt[1]); + assertEquals(BAD, out[1][0], type + " forward=" + forward + " input " + pt[0] + "," + pt[1]); + } + } + } + } + } + + // ------------------------------------------------------------------ + // probes/xphmap_probe.c + // ------------------------------------------------------------------ + + private static String show(AstObject obj) { + StringBuilder sb = new StringBuilder(); + for (String l : ChannelText.dump(obj).split("\n", -1)) { + if (!l.isEmpty()) { + sb.append(ProbeOutput.trimLines(l)).append('\n'); + } + } + return sb.toString(); + } + + private static int flag(boolean b) { + return b ? 1 : 0; + } + + private static String g(double v) { + return CFormat.format("%.17g", v); + } + + private static final double[] XIN = {1.0, 3.0, 4.25, 6.5, 9.0, 0.5}; + private static final double[] YIN = {4.0, 2.5, 6.75, 7.0, 9.5, 0.5}; + + private static String tran(String label, Mapping map) { + double[][] out = map.tran2(XIN.length, XIN, YIN, true); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < XIN.length; i++) { + sb.append(label) + .append(' ') + .append(g(XIN[i])) + .append(' ') + .append(g(YIN[i])) + .append(" -> ") + .append(g(out[0][i])) + .append(' ') + .append(g(out[1][i])) + .append('\n'); + } + return sb.toString(); + } + + private static String simplify(Mapping cmp) { + Mapping simp = cmp.simplify(); + return "class " + simp.astClass() + "\n" + tran("cmp", cmp) + tran("simp", simp); + } + + private static String invertAttrs(String when, Mapping p, Mapping q) { + return when + " p " + p.getI("Invert") + " set " + (p.test("Invert") ? 1 : 0) + " q " + q.getI("Invert") + + " set " + (q.test("Invert") ? 1 : 0) + "\n"; + } + + /** The series CmpMap of {@code a} and {@code b}, simplified, with their Invert attributes before and after. */ + private static String cancel(Mapping a, Mapping b) { + CmpMap cmp = new CmpMap(a, b, true); + String before = invertAttrs("before", a, b); + return before + simplify(cmp) + invertAttrs("after", a, b); + } + + /** + * C's text with the {@code after} line's Invert attributes set as Java leaves them: each as it + * was before, set or unset, where C's {@code astSetInvert} leaves both set + * (docs/rust-c-differences.md, "XphMap merges leave Invert attributes set"). + */ + private static String withJavaAfter(String c, String cAfter, String javaAfter) { + assertTrue(c.contains(cAfter + "\n"), c); + return c.replace(cAfter + "\n", javaAfter + "\n"); + } + + @Test + void probeDumpsAndIsLinear() { + String[] types = {"HPX0", "HPX12", "XPHN", "XPHS"}; + for (int k = 0; k < types.length; k++) { + XphMap a = load(k == 0 ? 0 : 3 + k, types[k]); + assertEquals(PROBE.get("dump_" + types[k]), show(a) + "IsLinear " + a.getI("IsLinear") + "\n", types[k]); + } + XphMap inv = load(2, "XPHS"); + inv.invert(); + assertEquals(PROBE.get("dump_inverted"), show(inv)); + String dflt = " Begin XphMap\n Nin = 2\n IsA Mapping\n End XphMap\n"; + assertEquals(PROBE.get("dump_default"), show(ChannelText.read(dflt))); + assertEquals(PROBE.get("type_case"), show(load(3, "xphn "))); + } + + @Test + void probeUnknownType() { + AstException e = assertThrows(AstException.class, () -> load(3, "XPHQ")); + String want = PROBE.get("type_unknown"); + assertTrue(want.contains("! " + e.getMsgText().split("\n", -1)[0] + "\n"), e.getMsgText() + "\n" + want); + assertTrue(want.endsWith("status " + e.getStatus() + "\n"), want); + } + + @Test + void probeEqual() { + XphMap a = load(3, "XPHN"); + XphMap b = load(3, "XPHN"); + XphMap order = load(4, "XPHN"); + XphMap type = load(3, "XPHS"); + XphMap c = load(3, "XPHN"); + c.invert(); + XphMap d = load(3, "XPHN"); + d.invert(); + String got = "same " + flag(a.astEqual(b)) + "\n" + + "order " + flag(a.astEqual(order)) + "\n" + + "type " + flag(a.astEqual(type)) + "\n" + + "inverted " + flag(a.astEqual(c)) + "\n" + + "both inverted " + flag(d.astEqual(c)) + "\n"; + assertEquals(PROBE.get("equal"), got); + } + + @Test + void probeCancel() { + XphMap a = load(1, "XPHN"); + XphMap b = load(1, "XPHN"); + b.invert(); + assertEquals( + withJavaAfter(PROBE.get("cancel"), "after p 0 set 1 q 1 set 1", "after p 0 set 0 q 1 set 1"), + cancel(a, b)); + } + + @Test + void probeCancelInverseFirst() { + XphMap a = load(1, "HPX0"); + XphMap b = load(1, "HPX0"); + a.invert(); + assertEquals( + withJavaAfter( + PROBE.get("cancel_inverse_first"), "after p 1 set 1 q 0 set 1", "after p 1 set 1 q 0 set 0"), + cancel(a, b)); + } + + @Test + void probeNoCancelSameDirection() { + assertEquals( + withJavaAfter( + PROBE.get("no_cancel_same_direction"), + "after p 0 set 1 q 0 set 1", + "after p 0 set 0 q 0 set 0"), + cancel(load(1, "XPHS"), load(1, "XPHS"))); + } + + @Test + void probeNoCancelOrdersOrTypes() { + XphMap b = load(2, "XPHN"); + b.invert(); + assertEquals(PROBE.get("no_cancel_orders"), simplify(new CmpMap(load(1, "XPHN"), b, true))); + XphMap c = load(1, "XPHS"); + c.invert(); + assertEquals(PROBE.get("no_cancel_types"), simplify(new CmpMap(load(1, "XPHN"), c, true))); + } + + /** + * A CmpMap holding one XphMap twice does not cancel: its simplification gives each place its + * own object, as C's {@code SeparateMappings} (cmpmap.c) does, so the comparison is not of an + * object with itself. + */ + @Test + void probeSameObjectTwice() { + XphMap a = load(1, "XPHN"); + String want = PROBE.get("same_object_twice"); + assertEquals( + withJavaAfter(want, "after p 0 set 1", "after p 0 set 0"), + simplify(new CmpMap(a, a, true)) + "after p " + a.getI("Invert") + " set " + (a.test("Invert") ? 1 : 0) + + "\n"); + } + + @Test + void probeSameObjectThenInverse() { + XphMap a = load(1, "XPHN"); + CmpMap b = new CmpMap(a, new UnitMap(2), true); + b.invert(); + String want = PROBE.get("same_object_then_inverse"); + assertEquals( + withJavaAfter(want, "after p 0 set 1", "after p 0 set 0"), + simplify(new CmpMap(a, b, true)) + "after p " + a.getI("Invert") + " set " + (a.test("Invert") ? 1 : 0) + + "\n"); + } + + @Test + void probeParallelDoesNotMerge() { + XphMap b = load(1, "XPHN"); + b.invert(); + Mapping s = new CmpMap(load(1, "XPHN"), b, false).simplify(); + assertEquals(PROBE.get("parallel"), "class " + s.astClass() + " nin " + s.getNin() + "\n"); + } + + @Test + void probeThreeInSeries() { + XphMap b = load(1, "XPHS"); + b.invert(); + CmpMap cmp2 = new CmpMap(load(1, "XPHS"), b, true); + assertEquals(PROBE.get("three_in_series"), simplify(new CmpMap(load(1, "HPX0"), cmp2, true))); + } + + // ------------------------------------------------------------------ + // Constructor and loader checks + // ------------------------------------------------------------------ + + @Test + void theConstructorTakesOrderAndType() { + XphMap m = new XphMap(5, XphMap.AST__XPHS); + assertEquals(2, m.getNin()); + assertEquals(2, m.getNout()); + assertTrue(m.astEqual(load(5, "XPHS"))); + assertTrue(new XphMap(XphMap.AST__MXORDHPX, XphMap.AST__HPX0).astEqual(load(27, "HPX0"))); + } + + /** astInitXphMap refuses an order or type out of range with AST__INTER. */ + @Test + void theConstructorRefusesAnOrderOrTypeOutOfRange() { + AstException e = assertThrows(AstException.class, () -> new XphMap(-1, XphMap.AST__HPX12)); + assertEquals(AstException.AST__INTER, e.getStatus()); + assertEquals( + "astInitXphMap(XphMap): Invalid order supplied (-1) (internal programming error).", e.getMsgText()); + e = assertThrows(AstException.class, () -> new XphMap(28, XphMap.AST__HPX12)); + assertEquals(AstException.AST__INTER, e.getStatus()); + e = assertThrows(AstException.class, () -> new XphMap(3, 4)); + assertEquals(AstException.AST__INTER, e.getStatus()); + assertEquals( + "astInitXphMap(XphMap): Invalid projection type supplied (4) (internal programming error).", + e.getMsgText()); + e = assertThrows(AstException.class, () -> new XphMap(3, -1)); + assertEquals(AstException.AST__INTER, e.getStatus()); + } + + /** The loader refuses an order the constructor would refuse, which the transformation uses as a shift count. */ + @Test + void theLoaderRefusesAnOrderOutOfRange() { + for (int order : new int[] {-1, 28, 40}) { + AstException e = assertThrows(AstException.class, () -> load(order, "HPX12"), "order " + order); + assertEquals(AstException.AST__LDERR, e.getStatus()); + assertTrue( + e.getMsgText() + .contains("astLoad(XphMap): The HEALPix order read for a XphMap (" + order + + ") is not in the range 0 to 27."), + e.getMsgText()); + } + assertEquals(27, load(27, "HPX12").getOrder()); + assertEquals(0, load(0, "HPX12").getOrder()); + } + + /** The loader refuses numbers of inputs and outputs other than two, which the transformation relies on. */ + @Test + void theLoaderRefusesOtherNumbersOfInputsAndOutputs() { + String[] dumps = { + dump(3, "XPHN").replace("Nin = 2", "Nin = 3"), + dump(3, "XPHN").replace("Nin = 2", "Nin = 1"), + dump(3, "XPHN").replace("Nin = 2", "Nin = 2\n Nout = 3"), + }; + String[] counts = {"(3) and outputs (3)", "(1) and outputs (1)", "(2) and outputs (3)"}; + for (int i = 0; i < dumps.length; i++) { + String d = dumps[i]; + AstException e = assertThrows(AstException.class, () -> ChannelText.read(d), d); + assertEquals(AstException.AST__LDERR, e.getStatus()); + assertTrue( + e.getMsgText() + .contains("astLoad(XphMap): Invalid numbers of inputs " + counts[i] + + " read for a XphMap - there should be 2 and 2."), + e.getMsgText()); + } + } + + /** + * A position far beyond the range of an {@code int} is placed in its grid cell as any other + * position is: in the north-polar gore 3 of an XPH projection the difference of the cell + * indices of (3e9, 5e9) is far outside the gore, so the position is bad, and (3e9, 3e9) is + * on the gore's diagonal, so it transforms. The pinned C converts the indices to {@code int}, + * which saturates on AArch64, and transforms (3e9, 5e9) to (4999999998, -2999999989) + * (docs/rust-c-differences.md, "XphMap positions far from the grid"). + */ + @Test + void aPositionFarFromTheGridIsPlacedInItsCell() { + XphMap map = load(1, "XPHN"); + double[][] out = map.tran2(2, new double[] {3.0e9, 3.0e9}, new double[] {5.0e9, 3.0e9}, true); + assertEquals(BAD, out[0][0]); + assertEquals(BAD, out[1][0]); + assertEquals(3.0e9 - 2.0, out[0][1]); + assertEquals(11.0 - 3.0e9, out[1][1]); + out = map.tran2(1, new double[] {-3.0e9}, new double[] {-3.0e9}, false); + assertEquals(BAD, out[0][0]); + } + + /** + * A position less than one facet left of or below the grid is placed in a bottom-left facet and + * transformed, as C does (docs/c-library-bugs.md, "An XphMap accepts positions up to a facet + * left of or below its grid"); the values are those of the reproducer {@code + * docs/c-library-bugs/xphmap_off_grid.c} run against the pinned C. One more cell out is bad. + */ + @Test + void positionsUpToAFacetOffTheGridAreAccepted() { + double[][] out = load(1, "HPX12").tran2(1, new double[] {0.0}, new double[] {4.0}, true); + assertEquals(0.0, out[0][0]); + assertEquals(4.0, out[1][0]); + out = load(1, "HPX0").tran2(1, new double[] {0.0}, new double[] {4.0}, true); + assertEquals(4.0, out[0][0]); + assertEquals(8.0, out[1][0]); + out = load(2, "HPX12").tran2(2, new double[] {-2.0, -3.0}, new double[] {8.5, 8.5}, true); + assertEquals(-2.0, out[0][0]); + assertEquals(8.5, out[1][0]); + assertEquals(BAD, out[0][1]); + assertEquals(BAD, out[1][1]); + } + + @Test + void aCopyIsEqualAndIndependent() { + XphMap a = load(4, "HPX0"); + XphMap c = (XphMap) a.copy(); + assertTrue(a.astEqual(c)); + c.invert(); + assertFalse(a.astEqual(c)); + assertFalse(a.getInvert()); + assertEquals(ChannelText.dump(a), ChannelText.dump(load(4, "HPX0"))); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/testsupport/NativeClassesTest.java b/src/test/java/uk/ac/starlink/ast/testsupport/NativeClassesTest.java index 7216955..b629220 100644 --- a/src/test/java/uk/ac/starlink/ast/testsupport/NativeClassesTest.java +++ b/src/test/java/uk/ac/starlink/ast/testsupport/NativeClassesTest.java @@ -12,33 +12,31 @@ class NativeClassesTest { private static final String DUMP = " Begin FrameSet \t# Set of inter-related coordinate systems\n" + " IsA Object\n" + " Frm1 = \t# Frame number 1\n" - + " Begin XphMap \t# Xph Mapping\n" + + " Begin Moc \t# Multi-order coverage\n" + " Ax1 = \n" - + " Begin SplineMap\n" - + " End SplineMap\n" - + " End XphMap\n" + + " Begin Table\n" + + " End Table\n" + + " End Moc\n" + " Map2 = \n" + " Begin CmpMap\n" + " MapA = \n" + " Begin ZoomMap\n" + " End ZoomMap\n" + " MapB = \n" - + " Begin XphMap\n" - + " End XphMap\n" + + " Begin Moc\n" + + " End Moc\n" + " End CmpMap\n" + " End FrameSet\n"; @Test void listsTheBegunClassesInOrder() { - assertEquals( - Arrays.asList("FrameSet", "XphMap", "SplineMap", "CmpMap", "ZoomMap", "XphMap"), - NativeClasses.begun(DUMP)); + assertEquals(Arrays.asList("FrameSet", "Moc", "Table", "CmpMap", "ZoomMap", "Moc"), NativeClasses.begun(DUMP)); } @Test void missingClassesAreSortedWithoutRepeats() { - assertEquals(Arrays.asList("SplineMap", "XphMap"), NativeClasses.missing(DUMP)); - assertEquals("needs SplineMap, XphMap", NativeClasses.needs(DUMP)); + assertEquals(Arrays.asList("Moc", "Table"), NativeClasses.missing(DUMP)); + assertEquals("needs Moc, Table", NativeClasses.needs(DUMP)); } @Test @@ -52,11 +50,11 @@ void aDumpOfLoadableClassesNeedsNothing() { void aFitsHeaderNeedsTheClassesOfItsBegastCards() { String header = "BEGAST_A= 'FrameSet' / Set of inter-related coordinate systems\n" + "BEGAST_B= 'Frame ' / Coordinate system description\n" - + "BEGAST_C= 'ChebyMap' / Chebyshev polynomial transformation\n" - + "BEGAST_D= 'SplineMap'\n" - + "BEGAST_E= 'ChebyMap'\n" + + "BEGAST_C= 'Moc ' / Multi-Order Coverage map\n" + + "BEGAST_D= 'Table '\n" + + "BEGAST_E= 'Moc '\n" + "CTYPE1 = 'RA---TAN'\n"; - assertEquals("needs ChebyMap, SplineMap", NativeClasses.needsInFitsHeader(header)); + assertEquals("needs Moc, Table", NativeClasses.needsInFitsHeader(header)); assertNull(NativeClasses.needsInFitsHeader("BEGAST_A= 'ZoomMap '\nZOOM_A = 2.0\n")); } } diff --git a/src/test/resources/astjava-api.txt b/src/test/resources/astjava-api.txt new file mode 100644 index 0000000..78f6aba --- /dev/null +++ b/src/test/resources/astjava-api.txt @@ -0,0 +1,27 @@ +# The public and protected API of the public classes of this library that jniast lacks, in the +# format of jniast-api.txt: ||||(), sorted. +# Each class's API is what jniast's generator (JMaker.pm) would make from the C prologue (the +# spec's "Decisions already made"). JniastApiTest fails on a public class in neither this file +# nor jniast-api.txt, on a public or protected member of a class listed here that is not listed, +# and on a listed member that does not exist. +ChebyMap|constructor|public||(int,int,int,double[],int,double[],double[],double[],double[],double[]) +ChebyMap|method|public|double[][]|chebyDomain(boolean) +ChebyMap|type|public|class|ChebyMap +NormMap|constructor|public||(Frame) +NormMap|type|public|class|NormMap +SplineMap|constructor|public||(int,int,int,int,double[],double[],double[],double[]) +SplineMap|method|public|boolean|getOutUnit() +SplineMap|method|public|double[]|splineCoeffs(int) +SplineMap|method|public|double[]|splineKnots(int) +SplineMap|method|public|double|getInvTol() +SplineMap|method|public|int|getInvNiter() +SplineMap|method|public|int|getSplineKx() +SplineMap|method|public|int|getSplineKy() +SplineMap|method|public|int|getSplineNx() +SplineMap|method|public|int|getSplineNy() +SplineMap|method|public|void|setInvNiter(int) +SplineMap|method|public|void|setInvTol(double) +SplineMap|method|public|void|setOutUnit(boolean) +SplineMap|type|public|class|SplineMap +UnitNormMap|constructor|public||(int,double[]) +UnitNormMap|type|public|class|UnitNormMap diff --git a/src/test/resources/deferred/framesets.txt b/src/test/resources/deferred/framesets.txt index 56656e8..9c631f9 100644 --- a/src/test/resources/deferred/framesets.txt +++ b/src/test/resources/deferred/framesets.txt @@ -1,4 +1,3 @@ # Fixtures of fixtures/oracle/framesets.oracle whose sections do not all match C: # | # Rewritten by TransformOracleTest with -Dast.writeDeferred=true. -wcsconv/inputs/lsst2.ast | needs SplineMap diff --git a/src/test/resources/deferred/full-dumps.txt b/src/test/resources/deferred/full-dumps.txt index bb4e9b5..54824a4 100644 --- a/src/test/resources/deferred/full-dumps.txt +++ b/src/test/resources/deferred/full-dumps.txt @@ -1,65 +1,3 @@ # Native fixtures whose Full = 1 dump differs from C's: # | # Rewritten by FixtureFullDumpOracleTest with -Dast.writeDeferred=true. -simplify/cap_cheby_consolidate.map | needs ChebyMap -simplify/cap_cheby_consolidate.simp | needs ChebyMap -simplify/cap_matrixmap_04.map | needs ChebyMap -simplify/cap_normmap_cmpframe.map | needs NormMap -simplify/cap_normmap_cmpframe.simp | needs NormMap -simplify/cap_permmap_01.map | needs NormMap -simplify/cap_permmap_01.simp | needs NormMap -simplify/cap_unitnormmap_01.map | needs UnitNormMap -simplify/cap_unitnormmap_01.simp | needs UnitNormMap -simplify/cap_xphmap_01.map | needs XphMap -simplify/cap_xphmap_02.map | needs XphMap -simplify/cap_xphmap_02.simp | needs XphMap -simplify/cheby_linear_lone_reduce.map | needs ChebyMap -simplify/chebymap_inverse_cancel.map | needs ChebyMap -simplify/neg_cheby_quadratic_no_reduce.map | needs ChebyMap -simplify/neg_chebymap_standalone.map | needs ChebyMap -simplify/neg_normmap_diff_frame.map | needs NormMap -simplify/neg_normmap_different_frames.map | needs NormMap -simplify/neg_normmap_inv_diff_frame.map | needs NormMap -simplify/neg_normmap_nonnorm_neighbour.map | needs NormMap -simplify/neg_normmap_parallel_sky.map | needs NormMap -simplify/neg_normmap_parallel.map | needs NormMap -simplify/neg_spline_different_coeffs.map | needs SplineMap -simplify/neg_spline_nonspline_neighbour.map | needs SplineMap -simplify/neg_spline_parallel.map | needs SplineMap -simplify/neg_spline_same_direction.map | needs SplineMap -simplify/neg_unitnormmap_flanked.map | needs UnitNormMap -simplify/neg_unitnormmap_fwd_shift.map | needs UnitNormMap -simplify/neg_unitnormmap_inv_fwd_diffcentre.map | needs UnitNormMap -simplify/neg_unitnormmap_nonmergeable.map | needs UnitNormMap -simplify/neg_unitnormmap_nonunit_scale.map | needs UnitNormMap -simplify/neg_unitnormmap_parallel.map | needs UnitNormMap -simplify/neg_unitnormmap_same_dir.map | needs UnitNormMap -simplify/neg_unitnormmap_shift_inv.map | needs UnitNormMap -simplify/neg_xph_nonxph_neighbour.map | needs XphMap -simplify/neg_xph_not_opposite.map | needs XphMap -simplify/neg_xph_parallel.map | needs XphMap -simplify/normmap_basic_frame_to_unit.map | needs NormMap -simplify/normmap_duplicate_elim.map | needs NormMap -simplify/normmap_duplicate_elim.simp | needs NormMap -simplify/normmap_inverse_cancel_upper.map | needs NormMap -simplify/normmap_inverse_cancel.map | needs NormMap -simplify/spline_inverse_cancel.map | needs SplineMap -simplify/unitnormmap_diff_centre_to_shift.map | needs UnitNormMap -simplify/unitnormmap_fwd_winmap_refused.map | needs UnitNormMap -simplify/unitnormmap_fwd_winmap_refused.simp | needs UnitNormMap -simplify/unitnormmap_inv_fwd_cancel.map | needs UnitNormMap -simplify/unitnormmap_inv_shift_merge.map | needs UnitNormMap -simplify/unitnormmap_inv_shift_merge.simp | needs UnitNormMap -simplify/unitnormmap_inv_winmap_merge.map | needs UnitNormMap -simplify/unitnormmap_inv_winmap_merge.simp | needs UnitNormMap -simplify/unitnormmap_inverse_cancel.map | needs UnitNormMap -simplify/unitnormmap_shift_fwd_merge.map | needs UnitNormMap -simplify/unitnormmap_shift_fwd_merge.simp | needs UnitNormMap -simplify/unitnormmap_shift_merge_tail.map | needs UnitNormMap -simplify/unitnormmap_shift_merge_tail.simp | needs UnitNormMap -simplify/unitnormmap_winmap_fwd_merge.map | needs UnitNormMap -simplify/unitnormmap_winmap_fwd_merge.simp | needs UnitNormMap -simplify/unitnormmap_winmap_inv_refused.map | needs UnitNormMap -simplify/unitnormmap_winmap_inv_refused.simp | needs UnitNormMap -simplify/xph_inverse_cancel.map | needs XphMap -wcsconv/inputs/lsst2.ast | needs SplineMap diff --git a/src/test/resources/deferred/oracle-rows.txt b/src/test/resources/deferred/oracle-rows.txt index a4a90a1..a21e062 100644 --- a/src/test/resources/deferred/oracle-rows.txt +++ b/src/test/resources/deferred/oracle-rows.txt @@ -7,3 +7,36 @@ # A cause starting "runtime Math:" marks rows whose outcome hangs on the last bit of an elementary # function of java.lang.Math, which is not C's libm and differs between platforms: such a row is # not reported when it matches C, since on another runtime it may not. +# Rows of a C probe's output are listed the same way, as probes// +# , counting the case's "fwd" or "inv" lines from 0, or as probes// other , +# counting the case's other lines from 0; the probe's test reads them, the gates of +# TransformOracleTest leave them alone, and its PROBE_ROW_TESTS must name the test of each probe. +probes/chebymap_probe/t_polytran_wide inverse 0,1,3,4 | fused multiply-add: the fit's values come through contracted arithmetic: chebymap.c FitPoly1DInit and FitPoly2DInit's x*scl*scale + off and recurrence, PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1 in the samples, and cminpack's lmder; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/t_polytran_wide other 2,3,4,5,6,7,8,9,26,27,28,29,30,31,32,33 | fused multiply-add: the fit's values come through contracted arithmetic: chebymap.c FitPoly1DInit and FitPoly2DInit's x*scl*scale + off and recurrence, PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1 in the samples, and cminpack's lmder; these lines are the fitted coefficients and their dump; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/t_2d_unit inverse 0,1,2,3 | fused multiply-add: the fit's values come through contracted arithmetic: chebymap.c FitPoly1DInit and FitPoly2DInit's x*scl*scale + off and recurrence, PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1 in the samples, and cminpack's lmder; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/t_2d_unit other 7,8,10 | fused multiply-add: the fit's values come through contracted arithmetic: chebymap.c FitPoly1DInit and FitPoly2DInit's x*scl*scale + off and recurrence, PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1 in the samples, and cminpack's lmder; these lines are the fitted coefficients; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/t_2d_nonunit forward 1,2,4,6,7 | fused multiply-add: the default build of C fuses chebymap.c PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/t_2d_nonunit inverse 0,1,2,3 | fused multiply-add: the fit's values come through contracted arithmetic: chebymap.c FitPoly1DInit and FitPoly2DInit's x*scl*scale + off and recurrence, PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1 in the samples, and cminpack's lmder; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/t_2d_nonunit other 7,8,9,10,11,12,13,14,15,19 | fused multiply-add: the fit's values come through contracted arithmetic: chebymap.c FitPoly1DInit and FitPoly2DInit's x*scl*scale + off and recurrence, PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1 in the samples, and cminpack's lmder; these lines are the fitted coefficients and the fit's inverse domain, the range of contracted forward values; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/t_linear_1d inverse 1 | fused multiply-add: the default build of C fuses winmap.c's inverse x*b + a, with b = 1/scale and a = -shift*b; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/t_linear_2d forward 2,3 | fused multiply-add: the default build of C fuses chebymap.c PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/t_linear_2d inverse 0,1,2,3 | fused multiply-add: the inputs are the ChebyMap's forward values, which the default build of C fuses in chebymap.c PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1, and winmap.c's inverse x*b + a is fused too; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/outside_box forward 0 | fused multiply-add: the default build of C fuses chebymap.c PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/outside_box inverse 10 | fused multiply-add: the default build of C fuses chebymap.c PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/domain_no_inverse other 1,2 | fused multiply-add: MapBox finds the inverse domain from forward values, which the default build of C fuses in chebymap.c PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/simp_poly_win forward 1 | fused multiply-add: the default build of C fuses winmap.c's forward x*b + a and chebymap.c PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/rate_cubic other 0 | fused multiply-add: mapping.c's Rate differences forward values, which the default build of C fuses in chebymap.c PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/polytran_own_box inverse 0,1 | fused multiply-add: the fit's values come through contracted arithmetic: chebymap.c FitPoly1DInit and FitPoly2DInit's x*scl*scale + off and recurrence, PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1 in the samples, and cminpack's lmder; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/chebymap_probe/polytran_own_box other 3,4,5,6,7 | fused multiply-add: the fit's values come through contracted arithmetic: chebymap.c FitPoly1DInit and FitPoly2DInit's x*scl*scale + off and recurrence, PolyPowers's x*scale + offset and 2.0*x*Tn - Tn-1 in the samples, and cminpack's lmder; these lines are the fitted coefficients; built with -ffp-contract=off it gives Java's values (probes/chebymap_probe_nocontract.json) +probes/normmap_probe/testsimplify_0 forward 1,2 | fused multiply-add: the default build of C fuses unitnormmap.c's inverse in*norm + centre; built with -ffp-contract=off it gives Java's values (probes/normmap_probe_nocontract.json) +probes/normmap_probe/testsimplify_3 forward 1,4 | fused multiply-add: the default build of C fuses winmap.c's forward x*b + a; built with -ffp-contract=off it gives Java's values (probes/normmap_probe_nocontract.json) +probes/normmap_probe/unm_2d inverse 9 | fused multiply-add: the default build of C fuses unitnormmap.c's inverse in*norm + centre; built with -ffp-contract=off it gives Java's values (probes/normmap_probe_nocontract.json) +probes/normmap_probe/unm_inv_diffcentre_second inverse 0 | fused multiply-add: the default build of C fuses unitnormmap.c's inverse in*norm + centre; built with -ffp-contract=off it gives Java's values (probes/normmap_probe_nocontract.json) +probes/normmap_probe/unm_inv_fwd_diffcentre inverse 0 | fused multiply-add: the default build of C fuses unitnormmap.c's inverse in*norm + centre, which then misses the next UnitNormMap's centre by a rounding residue, so its zero-norm guard does not fire; built with -ffp-contract=off it gives Java's values (probes/normmap_probe_nocontract.json) +probes/splinemap_probe/tran_inside forward 3,4,5 | fused multiply-add: the default build of C fuses splinemap.c Dbvalu's B-spline step work[jj+1]*dm + work[jj]*dp; built with -ffp-contract=off it gives Java's values (probes/splinemap_probe_nocontract.json) +probes/splinemap_probe/tran_inside inverse 0,1,2,3,4,5 | fused multiply-add: the inverse is iterative, and the default build of C fuses splinemap.c IterInverse's first guess 2*u - a and its convergence test's x*x + y*y and splinemap.c Dbvalu's B-spline step work[jj+1]*dm + work[jj]*dp; built with -ffp-contract=off it gives Java's values (probes/splinemap_probe_nocontract.json) +probes/splinemap_probe/tran_outside inverse 4,8,13,17 | fused multiply-add: the inverse is iterative, and the default build of C fuses splinemap.c IterInverse's first guess 2*u - a and its convergence test's x*x + y*y and splinemap.c Dbvalu's B-spline step work[jj+1]*dm + work[jj]*dp; built with -ffp-contract=off it gives Java's values (probes/splinemap_probe_nocontract.json) +probes/splinemap_probe/tran_outside forward 28,32 | fused multiply-add: the SplineMap is inverted, so these are its iterative inverse, and the default build of C fuses splinemap.c IterInverse's first guess 2*u - a and its convergence test's x*x + y*y and splinemap.c Dbvalu's B-spline step work[jj+1]*dm + work[jj]*dp; built with -ffp-contract=off it gives Java's values (probes/splinemap_probe_nocontract.json) +probes/splinemap_probe/inv_iterations inverse 3,4,8,9,10,11,12,13,15,16,17,18,19,20,21,23,24,26,27,28,29,31,32,34,35,36,37,38,39,40,41,42,43,44,46,47,50,51,52,59,60,67,68,74,75,76,80,82,83,84,85,86,87,91,92,96,97,98,99,100,101,103 | fused multiply-add: the inverse is iterative, and the default build of C fuses splinemap.c IterInverse's first guess 2*u - a and its convergence test's x*x + y*y and splinemap.c Dbvalu's B-spline step work[jj+1]*dm + work[jj]*dp, in the forward values of the points it inverts too; built with -ffp-contract=off it gives Java's values (probes/splinemap_probe_nocontract.json) +probes/splinemap_probe/rate other 3,21,22,23,24 | fused multiply-add: line 3 is a derivative, in which the default build of C fuses splinemap.c Dbvalu's B-spline step work[jj+1]*dm + work[jj]*dp; lines 21 to 24 are rates of the inverted SplineMap, which mapping.c's Rate finds by differencing its iterative inverse, in which C fuses splinemap.c IterInverse's first guess 2*u - a and its convergence test's x*x + y*y and splinemap.c Dbvalu's B-spline step work[jj+1]*dm + work[jj]*dp; built with -ffp-contract=off it gives Java's values (probes/splinemap_probe_nocontract.json) +probes/splinemap_probe/simp_inverted_cmpmap forward 0,1 | fused multiply-add: the CmpMap applies the SplineMap forward and its iterative inverse, and the default build of C fuses splinemap.c Dbvalu's B-spline step work[jj+1]*dm + work[jj]*dp and splinemap.c IterInverse's first guess 2*u - a and its convergence test's x*x + y*y; built with -ffp-contract=off it gives Java's values (probes/splinemap_probe_nocontract.json) diff --git a/src/test/resources/deferred/read-warnings.txt b/src/test/resources/deferred/read-warnings.txt index 7c3c64f..ebda632 100644 --- a/src/test/resources/deferred/read-warnings.txt +++ b/src/test/resources/deferred/read-warnings.txt @@ -3,65 +3,3 @@ # Rewritten by FixtureReadWarningsOracleTest with -Dast.writeDeferred=true. ./programs/testmocchan/backcompat_json.ast | needs MocChan ./programs/testmocchan/backcompat_string.ast | needs MocChan -./simplify/cap_cheby_consolidate.map | needs ChebyMap -./simplify/cap_cheby_consolidate.simp | needs ChebyMap -./simplify/cap_matrixmap_04.map | needs ChebyMap -./simplify/cap_normmap_cmpframe.map | needs NormMap -./simplify/cap_normmap_cmpframe.simp | needs NormMap -./simplify/cap_permmap_01.map | needs NormMap -./simplify/cap_permmap_01.simp | needs NormMap -./simplify/cap_unitnormmap_01.map | needs UnitNormMap -./simplify/cap_unitnormmap_01.simp | needs UnitNormMap -./simplify/cap_xphmap_01.map | needs XphMap -./simplify/cap_xphmap_02.map | needs XphMap -./simplify/cap_xphmap_02.simp | needs XphMap -./simplify/cheby_linear_lone_reduce.map | needs ChebyMap -./simplify/chebymap_inverse_cancel.map | needs ChebyMap -./simplify/neg_cheby_quadratic_no_reduce.map | needs ChebyMap -./simplify/neg_chebymap_standalone.map | needs ChebyMap -./simplify/neg_normmap_diff_frame.map | needs NormMap -./simplify/neg_normmap_different_frames.map | needs NormMap -./simplify/neg_normmap_inv_diff_frame.map | needs NormMap -./simplify/neg_normmap_nonnorm_neighbour.map | needs NormMap -./simplify/neg_normmap_parallel.map | needs NormMap -./simplify/neg_normmap_parallel_sky.map | needs NormMap -./simplify/neg_spline_different_coeffs.map | needs SplineMap -./simplify/neg_spline_nonspline_neighbour.map | needs SplineMap -./simplify/neg_spline_parallel.map | needs SplineMap -./simplify/neg_spline_same_direction.map | needs SplineMap -./simplify/neg_unitnormmap_flanked.map | needs UnitNormMap -./simplify/neg_unitnormmap_fwd_shift.map | needs UnitNormMap -./simplify/neg_unitnormmap_inv_fwd_diffcentre.map | needs UnitNormMap -./simplify/neg_unitnormmap_nonmergeable.map | needs UnitNormMap -./simplify/neg_unitnormmap_nonunit_scale.map | needs UnitNormMap -./simplify/neg_unitnormmap_parallel.map | needs UnitNormMap -./simplify/neg_unitnormmap_same_dir.map | needs UnitNormMap -./simplify/neg_unitnormmap_shift_inv.map | needs UnitNormMap -./simplify/neg_xph_nonxph_neighbour.map | needs XphMap -./simplify/neg_xph_not_opposite.map | needs XphMap -./simplify/neg_xph_parallel.map | needs XphMap -./simplify/normmap_basic_frame_to_unit.map | needs NormMap -./simplify/normmap_duplicate_elim.map | needs NormMap -./simplify/normmap_duplicate_elim.simp | needs NormMap -./simplify/normmap_inverse_cancel.map | needs NormMap -./simplify/normmap_inverse_cancel_upper.map | needs NormMap -./simplify/spline_inverse_cancel.map | needs SplineMap -./simplify/unitnormmap_diff_centre_to_shift.map | needs UnitNormMap -./simplify/unitnormmap_fwd_winmap_refused.map | needs UnitNormMap -./simplify/unitnormmap_fwd_winmap_refused.simp | needs UnitNormMap -./simplify/unitnormmap_inv_fwd_cancel.map | needs UnitNormMap -./simplify/unitnormmap_inv_shift_merge.map | needs UnitNormMap -./simplify/unitnormmap_inv_shift_merge.simp | needs UnitNormMap -./simplify/unitnormmap_inv_winmap_merge.map | needs UnitNormMap -./simplify/unitnormmap_inv_winmap_merge.simp | needs UnitNormMap -./simplify/unitnormmap_inverse_cancel.map | needs UnitNormMap -./simplify/unitnormmap_shift_fwd_merge.map | needs UnitNormMap -./simplify/unitnormmap_shift_fwd_merge.simp | needs UnitNormMap -./simplify/unitnormmap_shift_merge_tail.map | needs UnitNormMap -./simplify/unitnormmap_shift_merge_tail.simp | needs UnitNormMap -./simplify/unitnormmap_winmap_fwd_merge.map | needs UnitNormMap -./simplify/unitnormmap_winmap_fwd_merge.simp | needs UnitNormMap -./simplify/unitnormmap_winmap_inv_refused.map | needs UnitNormMap -./simplify/unitnormmap_winmap_inv_refused.simp | needs UnitNormMap -./simplify/xph_inverse_cancel.map | needs XphMap -./wcsconv/inputs/lsst2.ast | needs SplineMap diff --git a/src/test/resources/deferred/rust-tests.txt b/src/test/resources/deferred/rust-tests.txt index 9e9b6f4..0240bc6 100644 --- a/src/test/resources/deferred/rust-tests.txt +++ b/src/test/resources/deferred/rust-tests.txt @@ -7,45 +7,6 @@ tests/error_model.rs::display_includes_context | Rust-only API (AstError context tests/error_model.rs::new_tracked_captures_location | Rust-only API (AstError source location) tests/error_model.rs::new_has_no_location | Rust-only API (AstError source location) src/keymap/serial.rs::a_non_ascii_key_does_not_panic_the_presize_filter | Rust-only API (HashMap presizing) -tests/test_nan_protocol.rs::nan_protocol_normmap | NormMap (out of scope) -tests/test_nan_protocol.rs::nan_protocol_unitnormmap | UnitNormMap (out of scope) -tests/test_nan_protocol.rs::nan_protocol_carries_a_bad_output_of_a_mapping_without_its_own_nan_path | XphMap (out of scope) -tests/test_bulk_kernels.rs::unitnormmap_kernel_keeps_each_points_state_across_blocks | UnitNormMap (out of scope) -tests/test_bulk_kernels.rs::unitnormmap_inverse_kernel_keeps_each_points_state | UnitNormMap (out of scope) -tests/test_bulk_kernels.rs::unitnormmap_forward_kernel_matches_c_for_each_axis_count | UnitNormMap (out of scope) -tests/test_bulk_kernels.rs::transforms_that_fill_every_output_leave_surplus_axes_alone | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::forward_basic_origin | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::forward_with_centre | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::forward_zero_vector | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::forward_bad_input | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::forward_multiple_points | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::inverse_basic | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::inverse_with_centre | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::inverse_zero_norm | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::inverse_bad_norm | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::inverse_bad_component | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::roundtrip_forward_inverse | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::roundtrip_inverse_forward | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::inverted_nin_nout | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::inverted_transform | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::equal_same | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::equal_different_centre | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::equal_different_dim | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::equal_different_invert | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::serialization_roundtrip | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::serialization_inverted_roundtrip | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::merge_inverse_cancel_same_centre | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::merge_different_centre_to_shift | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::merge_unitnormmap_inv_plus_shift | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::merge_shift_plus_unitnormmap_fwd | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::merge_winmap_unit_scale_plus_unitnormmap_fwd | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::no_merge_winmap_non_unit_scale | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::merge_unitnormmap_inv_plus_winmap_unit_scale | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::no_merge_parallel | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::one_dimensional | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::large_values_no_overflow | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::not_linear_and_round_trips_including_the_centre | UnitNormMap (out of scope) -tests/test_unitnormmap.rs::c_testsimplify | UnitNormMap (out of scope) tests/points.rs::a_view_over_columns_reads_points_and_axes | Rust-only API (Points) tests/points.rs::no_axes_is_ncoin | Rust-only API (Points) tests/points.rs::one_short_axis_is_ncpin | Rust-only API (Points) @@ -74,27 +35,13 @@ tests/pointset.rs::a_point_set_and_its_views_agree | Rust-only API (PointSet) tests/pointset.rs::a_point_set_of_no_points_has_empty_axes | Rust-only API (PointSet) tests/pointset.rs::axis_iter_returns_column | Rust-only API (PointSet) tests/pointset.rs::view_and_into_ndarray | Rust-only API (PointSet) -tests/test_constructor_checks.rs::a_splinemap_checks_its_arguments | SplineMap (out of scope) -tests/test_constructor_checks.rs::a_unitnormmap_needs_a_centre | UnitNormMap (out of scope) -tests/test_equal.rs::chebymap_same | ChebyMap (out of scope) -tests/test_equal.rs::chebymap_different_bounds | ChebyMap (out of scope) tests/test_tran_grid_oracle.rs::quadratic_fits_match_c | astQuadApprox (out-of-scope method) tests/test_tran_grid_oracle.rs::quadratic_fit_needs_two_inputs | astQuadApprox (out-of-scope method) -tests/test_map_split.rs::normmap_split_picks_axes | NormMap (out of scope) -tests/test_map_split.rs::normmap_split_full_inputs_via_default | NormMap (out of scope) -tests/test_map_split.rs::normmap_split_refuses_out_of_range_and_repeated_axes | NormMap (out of scope) -tests/test_tran_definedness.rs::chebymap_forward_only_has_no_inverse | ChebyMap (out of scope) -tests/test_numeric_rate.rs::numeric_rate_chebymap_quadratic | ChebyMap (out of scope) -tests/test_numeric_rate.rs::numeric_rate_chebymap_cubic | ChebyMap (out of scope) src/mappings/linear_approx.rs::returns_correct_type | Rust-only API (LinearFit) tests/test_transform_oracle.rs::fma_substitutions_replace_rows_that_really_differ | Rust-only API (FMA_SUBSTITUTIONS_LICENSED is empty; a row that differs for that cause goes on the deferred lists) tests/test_transform_oracle.rs::transform_oracle_report | Rust-only API (ignored investigative JSON report; the gates list every failure) tests/test_transform_memory.rs::from_rows_needs_only_the_point_set | Rust-only API (allocation counting by a global allocator) tests/test_transform_memory.rs::splitting_a_view_allocates_nothing | Rust-only API (allocation counting by a global allocator) -tests/test_native_roundtrip_all.rs::round_trip_chebymap | ChebyMap (out of scope) -tests/test_native_roundtrip_all.rs::round_trip_unitnormmap | UnitNormMap (out of scope) -tests/test_native_roundtrip_all.rs::round_trip_normmap | NormMap (out of scope) -tests/test_native_roundtrip_all.rs::round_trip_splinemap | SplineMap (out of scope) src/erfa/c2s.rs::c2s_kernel_is_within_one_ulp_of_c2s | hardware SIMD src/erfa/s2c.rs::s2c_kernel_is_within_its_derived_bound_of_the_exact_value | hardware SIMD src/erfa/fk45z.rs::fk45z_kernel_is_within_bound_of_fk45z | hardware SIMD @@ -152,7 +99,6 @@ tests/test_timemap.rs::cvt_type_codes_match_c | Rust-only API (TimeCvtType integ tests/test_timemap.rs::cvt_type_from_int | Rust-only API (TimeCvtType integer codes) tests/test_timemap.rs::cvt_type_inverse | Rust-only API (TimeCvtType::inverse) tests/test_basicframe.rs::map_from_returns_unit | Rust-only API (Frame::map_from) -tests/test_frame_equality.rs::normmap_pair_over_cosmetically_different_frames_cancels | NormMap (out of scope) tests/test_frameset.rs::debug_formatting | Rust-only API (Debug) src/frames/skyframe.rs::skyframe_is_send | Rust-only API (Send trait bound) tests/test_skyframe.rs::skyframe_is_send | Rust-only API (Send) @@ -163,9 +109,6 @@ tests/test_timeframe.rs::test_map_from_timescale_change | Rust-only API (Frame:: tests/test_show_tostring_oracle.rs::a_concrete_class_writes_what_its_anyobject_writes | Rust-only API (AnyObject) tests/test_show_tostring_oracle.rs::try_from_returns_the_class_and_rejects_another | Rust-only API (AnyObject) tests/test_show_tostring_oracle.rs::try_from_unboxes_boxed_variants | Rust-only API (AnyObject) -tests/test_clear_on_set.rs::spline_inv_niter_discards_the_record | SplineMap (out of scope) -tests/test_clear_on_set.rs::spline_inv_tol_discards_the_record | SplineMap (out of scope) -tests/test_clear_on_set.rs::spline_out_unit_discards_the_record | SplineMap (out of scope) tests/test_channel_dump_oracle.rs::a_clone_shares_the_sink | MocChan (not in jniast) tests/test_channel_dump_oracle.rs::a_channel_read_from_a_dump_has_no_source | MocChan (not in jniast) tests/test_fixture_full_dump_oracle.rs::write_full_dumps | Rust-only API (ignored test writing the port's text for comparison by hand; the gate lists every difference) @@ -180,10 +123,6 @@ tests/test_serialisation.rs::any_object_skyframe_not_a_mapping | Rust-only API ( tests/test_serialisation.rs::a_keymap_is_neither_a_mapping_nor_a_frame_nor_a_region | Rust-only API (AnyObject) tests/test_fitschan_read.rs::unset_system_still_leaves_system_unset | Rust-only API (SkyFrame::unset_system) tests/test_fitschan_c_inline.rs::show_fits_succeeds | astShowFits (out-of-scope method; jniast has no showFits) -tests/test_fitschan_wcs_write.rs::a_splinemap_frameset_writes_nothing_at_a_tight_fits_tol | SplineMap (out of scope) -tests/test_fitschan_wcs_write.rs::the_as_fits_wcs_wrapping_of_a_splinemap_frameset_also_writes_nothing | SplineMap (out of scope) -tests/test_fitschan_wcs_write.rs::alternate_descriptions_are_withheld_when_the_primary_cannot_be_written | SplineMap (out of scope) -tests/test_fitschan_wcs_write.rs::a_splinemap_frameset_writes_a_complete_header_at_the_default_fits_tol | SplineMap (out of scope) tests/test_fitschan_tab.rs::tab_spectrum | needs FitsTable tests/test_fitschan_tab.rs::check_tab | needs FitsTable tests/test_fitschan_tab.rs::check_tab_sparse | needs FitsTable diff --git a/src/test/resources/deferred/serialisation.txt b/src/test/resources/deferred/serialisation.txt index 96dee06..1bc17cf 100644 --- a/src/test/resources/deferred/serialisation.txt +++ b/src/test/resources/deferred/serialisation.txt @@ -1,66 +1,5 @@ # Native fixtures that do not round-trip through a Channel: # | # Rewritten by SerialisationCorpusTest with -Dast.writeDeferred=true. -simplify/cap_cheby_consolidate.map | needs ChebyMap -simplify/cap_cheby_consolidate.simp | needs ChebyMap -simplify/cap_matrixmap_04.map | needs ChebyMap -simplify/cap_normmap_cmpframe.map | needs NormMap -simplify/cap_normmap_cmpframe.simp | needs NormMap -simplify/cap_permmap_01.map | needs NormMap -simplify/cap_permmap_01.simp | needs NormMap -simplify/cap_unitnormmap_01.map | needs UnitNormMap -simplify/cap_unitnormmap_01.simp | needs UnitNormMap -simplify/cap_xphmap_01.map | needs XphMap -simplify/cap_xphmap_02.map | needs XphMap -simplify/cap_xphmap_02.simp | needs XphMap -simplify/cheby_linear_lone_reduce.map | needs ChebyMap -simplify/chebymap_inverse_cancel.map | needs ChebyMap -simplify/neg_cheby_quadratic_no_reduce.map | needs ChebyMap -simplify/neg_chebymap_standalone.map | needs ChebyMap -simplify/neg_normmap_diff_frame.map | needs NormMap -simplify/neg_normmap_different_frames.map | needs NormMap -simplify/neg_normmap_inv_diff_frame.map | needs NormMap -simplify/neg_normmap_nonnorm_neighbour.map | needs NormMap -simplify/neg_normmap_parallel.map | needs NormMap -simplify/neg_normmap_parallel_sky.map | needs NormMap -simplify/neg_spline_different_coeffs.map | needs SplineMap -simplify/neg_spline_nonspline_neighbour.map | needs SplineMap -simplify/neg_spline_parallel.map | needs SplineMap -simplify/neg_spline_same_direction.map | needs SplineMap -simplify/neg_unitnormmap_flanked.map | needs UnitNormMap -simplify/neg_unitnormmap_fwd_shift.map | needs UnitNormMap -simplify/neg_unitnormmap_inv_fwd_diffcentre.map | needs UnitNormMap -simplify/neg_unitnormmap_nonmergeable.map | needs UnitNormMap -simplify/neg_unitnormmap_nonunit_scale.map | needs UnitNormMap -simplify/neg_unitnormmap_parallel.map | needs UnitNormMap -simplify/neg_unitnormmap_same_dir.map | needs UnitNormMap -simplify/neg_unitnormmap_shift_inv.map | needs UnitNormMap -simplify/neg_xph_nonxph_neighbour.map | needs XphMap -simplify/neg_xph_not_opposite.map | needs XphMap -simplify/neg_xph_parallel.map | needs XphMap -simplify/normmap_basic_frame_to_unit.map | needs NormMap -simplify/normmap_duplicate_elim.map | needs NormMap -simplify/normmap_duplicate_elim.simp | needs NormMap -simplify/normmap_inverse_cancel.map | needs NormMap -simplify/normmap_inverse_cancel_upper.map | needs NormMap -simplify/spline_inverse_cancel.map | needs SplineMap -simplify/unitnormmap_diff_centre_to_shift.map | needs UnitNormMap -simplify/unitnormmap_fwd_winmap_refused.map | needs UnitNormMap -simplify/unitnormmap_fwd_winmap_refused.simp | needs UnitNormMap -simplify/unitnormmap_inv_fwd_cancel.map | needs UnitNormMap -simplify/unitnormmap_inv_shift_merge.map | needs UnitNormMap -simplify/unitnormmap_inv_shift_merge.simp | needs UnitNormMap -simplify/unitnormmap_inv_winmap_merge.map | needs UnitNormMap -simplify/unitnormmap_inv_winmap_merge.simp | needs UnitNormMap -simplify/unitnormmap_inverse_cancel.map | needs UnitNormMap -simplify/unitnormmap_shift_fwd_merge.map | needs UnitNormMap -simplify/unitnormmap_shift_fwd_merge.simp | needs UnitNormMap -simplify/unitnormmap_shift_merge_tail.map | needs UnitNormMap -simplify/unitnormmap_shift_merge_tail.simp | needs UnitNormMap -simplify/unitnormmap_winmap_fwd_merge.map | needs UnitNormMap -simplify/unitnormmap_winmap_fwd_merge.simp | needs UnitNormMap -simplify/unitnormmap_winmap_inv_refused.map | needs UnitNormMap -simplify/unitnormmap_winmap_inv_refused.simp | needs UnitNormMap -simplify/xph_inverse_cancel.map | needs XphMap programs/testmocchan/backcompat_json.ast | needs MocChan programs/testmocchan/backcompat_string.ast | needs MocChan diff --git a/src/test/resources/deferred/simplify-cases.txt b/src/test/resources/deferred/simplify-cases.txt index 78d1ccf..8885e43 100644 --- a/src/test/resources/deferred/simplify-cases.txt +++ b/src/test/resources/deferred/simplify-cases.txt @@ -1,51 +1,3 @@ # Rows of fixtures/simplify/cases.txt whose simplification does not match C: # | # Rewritten by SimplifyRegressionTest with -Dast.writeDeferred=true. -spline_inverse_cancel | needs SplineMap -normmap_basic_frame_to_unit | needs NormMap -normmap_inverse_cancel | needs NormMap -normmap_duplicate_elim | needs NormMap -unitnormmap_inverse_cancel | needs UnitNormMap -unitnormmap_diff_centre_to_shift | needs UnitNormMap -neg_spline_same_direction | needs SplineMap -neg_normmap_parallel | needs NormMap -neg_normmap_different_frames | needs NormMap -neg_spline_parallel | needs SplineMap -neg_spline_nonspline_neighbour | needs SplineMap -neg_normmap_nonnorm_neighbour | needs NormMap -neg_spline_different_coeffs | needs SplineMap -normmap_inverse_cancel_upper | needs NormMap -unitnormmap_inv_fwd_cancel | needs UnitNormMap -cap_normmap_cmpframe | needs NormMap -cap_matrixmap_04 | needs ChebyMap -cap_permmap_01 | needs NormMap -cap_unitnormmap_01 | needs UnitNormMap -cap_xphmap_01 | needs XphMap -cap_xphmap_02 | needs XphMap -neg_normmap_diff_frame | needs NormMap -neg_normmap_inv_diff_frame | needs NormMap -neg_normmap_parallel_sky | needs NormMap -xph_inverse_cancel | needs XphMap -neg_xph_parallel | needs XphMap -neg_xph_nonxph_neighbour | needs XphMap -neg_xph_not_opposite | needs XphMap -unitnormmap_shift_fwd_merge | needs UnitNormMap -unitnormmap_winmap_fwd_merge | needs UnitNormMap -unitnormmap_inv_shift_merge | needs UnitNormMap -unitnormmap_inv_winmap_merge | needs UnitNormMap -neg_unitnormmap_nonmergeable | needs UnitNormMap -neg_unitnormmap_inv_fwd_diffcentre | needs UnitNormMap -neg_unitnormmap_shift_inv | needs UnitNormMap -neg_unitnormmap_fwd_shift | needs UnitNormMap -neg_unitnormmap_same_dir | needs UnitNormMap -neg_unitnormmap_parallel | needs UnitNormMap -neg_unitnormmap_flanked | needs UnitNormMap -unitnormmap_winmap_inv_refused | needs UnitNormMap -unitnormmap_fwd_winmap_refused | needs UnitNormMap -unitnormmap_shift_merge_tail | needs UnitNormMap -chebymap_inverse_cancel | needs ChebyMap -neg_chebymap_standalone | needs ChebyMap -cheby_linear_lone_reduce | needs ChebyMap -neg_cheby_quadratic_no_reduce | needs ChebyMap -cap_cheby_consolidate | needs ChebyMap -neg_unitnormmap_nonunit_scale | needs UnitNormMap diff --git a/src/test/resources/deferred/simplify.txt b/src/test/resources/deferred/simplify.txt index a4fa448..c10c260 100644 --- a/src/test/resources/deferred/simplify.txt +++ b/src/test/resources/deferred/simplify.txt @@ -1,63 +1,3 @@ # Fixtures of fixtures/oracle/simplify_fixtures.oracle whose sections do not all match C: # | # Rewritten by TransformOracleTest with -Dast.writeDeferred=true. -simplify/cap_cheby_consolidate.map | needs ChebyMap -simplify/cap_cheby_consolidate.simp | needs ChebyMap -simplify/cap_normmap_cmpframe.map | needs NormMap -simplify/cap_normmap_cmpframe.simp | needs NormMap -simplify/cap_permmap_01.map | needs NormMap -simplify/cap_permmap_01.simp | needs NormMap -simplify/cap_unitnormmap_01.map | needs UnitNormMap -simplify/cap_unitnormmap_01.simp | needs UnitNormMap -simplify/cap_xphmap_01.map | needs XphMap -simplify/cap_xphmap_02.map | needs XphMap -simplify/cap_xphmap_02.simp | needs XphMap -simplify/cheby_linear_lone_reduce.map | needs ChebyMap -simplify/chebymap_inverse_cancel.map | needs ChebyMap -simplify/neg_cheby_quadratic_no_reduce.map | needs ChebyMap -simplify/neg_chebymap_standalone.map | needs ChebyMap -simplify/neg_normmap_diff_frame.map | needs NormMap -simplify/neg_normmap_different_frames.map | needs NormMap -simplify/neg_normmap_inv_diff_frame.map | needs NormMap -simplify/neg_normmap_nonnorm_neighbour.map | needs NormMap -simplify/neg_normmap_parallel.map | needs NormMap -simplify/neg_normmap_parallel_sky.map | needs NormMap -simplify/neg_spline_different_coeffs.map | needs SplineMap -simplify/neg_spline_nonspline_neighbour.map | needs SplineMap -simplify/neg_spline_parallel.map | needs SplineMap -simplify/neg_spline_same_direction.map | needs SplineMap -simplify/neg_unitnormmap_flanked.map | needs UnitNormMap -simplify/neg_unitnormmap_fwd_shift.map | needs UnitNormMap -simplify/neg_unitnormmap_inv_fwd_diffcentre.map | needs UnitNormMap -simplify/neg_unitnormmap_nonmergeable.map | needs UnitNormMap -simplify/neg_unitnormmap_nonunit_scale.map | needs UnitNormMap -simplify/neg_unitnormmap_parallel.map | needs UnitNormMap -simplify/neg_unitnormmap_same_dir.map | needs UnitNormMap -simplify/neg_unitnormmap_shift_inv.map | needs UnitNormMap -simplify/neg_xph_nonxph_neighbour.map | needs XphMap -simplify/neg_xph_not_opposite.map | needs XphMap -simplify/neg_xph_parallel.map | needs XphMap -simplify/normmap_basic_frame_to_unit.map | needs NormMap -simplify/normmap_duplicate_elim.map | needs NormMap -simplify/normmap_duplicate_elim.simp | needs NormMap -simplify/normmap_inverse_cancel.map | needs NormMap -simplify/normmap_inverse_cancel_upper.map | needs NormMap -simplify/spline_inverse_cancel.map | needs SplineMap -simplify/unitnormmap_diff_centre_to_shift.map | needs UnitNormMap -simplify/unitnormmap_fwd_winmap_refused.map | needs UnitNormMap -simplify/unitnormmap_fwd_winmap_refused.simp | needs UnitNormMap -simplify/unitnormmap_inv_fwd_cancel.map | needs UnitNormMap -simplify/unitnormmap_inv_shift_merge.map | needs UnitNormMap -simplify/unitnormmap_inv_shift_merge.simp | needs UnitNormMap -simplify/unitnormmap_inv_winmap_merge.map | needs UnitNormMap -simplify/unitnormmap_inv_winmap_merge.simp | needs UnitNormMap -simplify/unitnormmap_inverse_cancel.map | needs UnitNormMap -simplify/unitnormmap_shift_fwd_merge.map | needs UnitNormMap -simplify/unitnormmap_shift_fwd_merge.simp | needs UnitNormMap -simplify/unitnormmap_shift_merge_tail.map | needs UnitNormMap -simplify/unitnormmap_shift_merge_tail.simp | needs UnitNormMap -simplify/unitnormmap_winmap_fwd_merge.map | needs UnitNormMap -simplify/unitnormmap_winmap_fwd_merge.simp | needs UnitNormMap -simplify/unitnormmap_winmap_inv_refused.map | needs UnitNormMap -simplify/unitnormmap_winmap_inv_refused.simp | needs UnitNormMap -simplify/xph_inverse_cancel.map | needs XphMap diff --git a/src/test/resources/deferred/wcsconv.txt b/src/test/resources/deferred/wcsconv.txt index f487199..6663e25 100644 --- a/src/test/resources/deferred/wcsconv.txt +++ b/src/test/resources/deferred/wcsconv.txt @@ -1,4 +1,3 @@ # Rows of fixtures/wcsconv/cases.txt that do not match C: # | # Rewritten by WcsconvTest with -Dast.writeDeferred=true. -lsst2_fits-wcs | needs SplineMap diff --git a/src/test/resources/oracle/mapping_bad.json b/src/test/resources/oracle/mapping_bad.json new file mode 100644 index 0000000..2b52af2 --- /dev/null +++ b/src/test/resources/oracle/mapping_bad.json @@ -0,0 +1,8 @@ +{ + "source": "crates/starlink-ast/tests/mapping_bad_oracle/cases.rs", + "generator": "tools/oracle_fixtures/mapping_bad_probe.c", + "rustCommit": "10f61689f19a5f1eacc7e653c7eab9b03809939f", + "consts": { + "CASES": [["normmap_skyframe",[" Begin NormMap \t# Normalise axis values"," Nin = 2 \t# Number of input coordinates"," IsA Mapping \t# Mapping between coordinate systems"," Frame = \t# Frame defining the normalisation"," Begin SkyFrame \t# Description of celestial coordinate system","# Title = \"ICRS coordinates\" \t# Title of coordinate system"," Naxes = 2 \t# Number of coordinate axes","# Domain = \"SKY\" \t# Coordinate system domain","# Epoch = 2000 \t# Julian epoch of observation","# Lbl1 = \"Right ascension\" \t# Label for axis 1","# Lbl2 = \"Declination\" \t# Label for axis 2","# System = \"ICRS\" \t# Coordinate system type","# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1","# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2","# Dir1 = 0 \t# Plot axis 1 in reverse direction","# Bot2 = -1.5707963267948966 \t# Lowest legal axis value","# Top2 = 1.5707963267948966 \t# Highest legal axis value"," Ax1 = \t# Axis number 1"," Begin SkyAxis \t# Celestial coordinate axis"," End SkyAxis"," Ax2 = \t# Axis number 2"," Begin SkyAxis \t# Celestial coordinate axis"," End SkyAxis"," IsA Frame \t# Coordinate system description","# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]"," End SkyFrame"," End NormMap"],[7.0,"BAD","BAD",0.3,-1.0,2.0,7.0,"NaN","NaN",0.2,3.0,0.1,"BAD","BAD"],[0.7168146928204138,"BAD","BAD",0.3,2.141592653589793,1.1415926535897931,0.7168146928204138,"BAD","BAD",0.2,3.0,0.1,"BAD","BAD"],[0.7168146928204138,"BAD","BAD",0.3,2.141592653589793,1.1415926535897931,0.7168146928204138,"BAD","BAD",0.2,3.0,0.1,"BAD","BAD"]],["normmap_cmpframe",[" Begin NormMap \t# Normalise axis values"," Nin = 3 \t# Number of input coordinates"," IsA Mapping \t# Mapping between coordinate systems"," Frame = \t# Frame defining the normalisation"," Begin CmpFrame \t# Compound coordinate system description","# Title = \"3-d compound coordinate system\" \t# Title of coordinate system","# Naxes = 3 \t# Number of coordinate axes","# Domain = \"SKY-\" \t# Coordinate system domain","# Lbl1 = \"Right ascension\" \t# Label for axis 1","# Lbl2 = \"Declination\" \t# Label for axis 2","# Lbl3 = \"Axis 3\" \t# Label for axis 3","# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1","# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2","# Dir1 = 0 \t# Plot axis 1 in reverse direction"," IsA Frame \t# Coordinate system description"," FrameA = \t# First component Frame"," Begin SkyFrame \t# Description of celestial coordinate system"," Naxes = 2 \t# Number of coordinate axes"," Ax1 = \t# Axis number 1"," Begin SkyAxis \t# Celestial coordinate axis"," End SkyAxis"," Ax2 = \t# Axis number 2"," Begin SkyAxis \t# Celestial coordinate axis"," End SkyAxis"," IsA Frame \t# Coordinate system description"," End SkyFrame"," FrameB = \t# Second component Frame"," Begin Frame \t# Coordinate system description"," Naxes = 1 \t# Number of coordinate axes"," Ax1 = \t# Axis number 1"," Begin Axis \t# Coordinate axis"," End Axis"," End Frame"," End CmpFrame"," End NormMap"],[7.0,"BAD",5.0,"BAD",0.3,5.0,-1.0,2.0,"BAD",7.0,"NaN",1.0,"NaN",0.2,2.0,3.0,0.1,"NaN","BAD","BAD","BAD"],[0.7168146928204138,"BAD",5.0,"BAD",0.3,5.0,2.141592653589793,1.1415926535897931,"BAD",0.7168146928204138,"BAD",1.0,"BAD",0.2,2.0,3.0,0.1,"BAD","BAD","BAD","BAD"],[0.7168146928204138,"BAD",5.0,"BAD",0.3,5.0,2.141592653589793,1.1415926535897931,"BAD",0.7168146928204138,"BAD",1.0,"BAD",0.2,2.0,3.0,0.1,"BAD","BAD","BAD","BAD"]],["shiftmap_bad_shift",[" Begin ShiftMap \t# Shift each coordinate axis"," Nin = 2 \t# Number of input coordinates"," IsA Mapping \t# Mapping between coordinate systems"," Sft1 = \t# Shift for axis 1"," Sft2 = 1.5 \t# Shift for axis 2"," End ShiftMap"],[7.0,"BAD","BAD",0.3,-1.0,2.0,7.0,"NaN","NaN",0.2,3.0,0.1,"BAD","BAD"],["BAD","BAD","BAD",1.8,"BAD",3.5,"BAD","BAD","BAD",1.7,"BAD",1.6,"BAD","BAD"],["BAD","BAD","BAD",-1.2,"BAD",0.5,"BAD","BAD","BAD",-1.3,"BAD",-1.4,"BAD","BAD"]],["matrixmap_diagonal_zero",[" Begin MatrixMap \t# Matrix transformation"," Nin = 2 \t# Number of input coordinates"," IsA Mapping \t# Mapping between coordinate systems"," M0 = 0 \t# Forward matrix value"," M1 = 2 \t# Forward matrix value"," IM1 = 0.5 \t# Inverse matrix value"," Form = \"Diagonal\" \t# Matrix storage form"," End MatrixMap"],[7.0,"BAD","BAD",0.3,-1.0,2.0,7.0,"NaN","NaN",0.2,3.0,0.1,"BAD","BAD"],[0.0,"BAD","BAD",0.6,-0.0,4.0,0.0,"BAD","BAD",0.4,0.0,0.2,"BAD","BAD"],["BAD","BAD","BAD",0.15,"BAD",1.0,"BAD","BAD","BAD",0.1,"BAD",0.05,"BAD","BAD"]],["matrixmap_diagonal_bad",[" Begin MatrixMap \t# Matrix transformation"," Nin = 2 \t# Number of input coordinates"," IsA Mapping \t# Mapping between coordinate systems"," M1 = 2 \t# Forward matrix value"," IM1 = 0.5 \t# Inverse matrix value"," Form = \"Diagonal\" \t# Matrix storage form"," End MatrixMap"],[7.0,"BAD","BAD",0.3,-1.0,2.0,7.0,"NaN","NaN",0.2,3.0,0.1,"BAD","BAD"],["BAD","BAD","BAD",0.6,"BAD",4.0,"BAD","BAD","BAD",0.4,"BAD",0.2,"BAD","BAD"],["BAD","BAD","BAD",0.15,"BAD",1.0,"BAD","BAD","BAD",0.1,"BAD",0.05,"BAD","BAD"]],["matrixmap_full_zero",[" Begin MatrixMap \t# Matrix transformation"," Nin = 2 \t# Number of input coordinates"," IsA Mapping \t# Mapping between coordinate systems"," M0 = 1 \t# Forward matrix value"," M1 = 0.5 \t# Forward matrix value"," M2 = 0 \t# Forward matrix value"," M3 = 2 \t# Forward matrix value"," IM0 = 1 \t# Inverse matrix value"," IM1 = -0.25 \t# Inverse matrix value"," IM2 = 0 \t# Inverse matrix value"," IM3 = 0.5 \t# Inverse matrix value"," Form = \"Full\" \t# Matrix storage form"," End MatrixMap"],[7.0,"BAD","BAD",0.3,-1.0,2.0,7.0,"NaN","NaN",0.2,3.0,0.1,"BAD","BAD"],["BAD","BAD","BAD",0.6,0.0,4.0,"BAD","BAD","BAD",0.4,3.05,0.2,"BAD","BAD"],["BAD","BAD","BAD",0.15,-1.5,1.0,"BAD","BAD","BAD",0.1,2.975,0.05,"BAD","BAD"]],["matrixmap_full_bad",[" Begin MatrixMap \t# Matrix transformation"," Nin = 2 \t# Number of input coordinates"," IsA Mapping \t# Mapping between coordinate systems"," M0 = 1 \t# Forward matrix value"," M2 = 0 \t# Forward matrix value"," M3 = 2 \t# Forward matrix value"," Form = \"Full\" \t# Matrix storage form"," End MatrixMap"],[7.0,"BAD","BAD",0.3,-1.0,2.0,7.0,"NaN","NaN",0.2,3.0,0.1,"BAD","BAD"],["BAD","BAD","BAD",0.6,"BAD",4.0,"BAD","BAD","BAD",0.4,"BAD",0.2,"BAD","BAD"],null]] + } +} diff --git a/src/test/resources/oracle/spline_inverse.json b/src/test/resources/oracle/spline_inverse.json new file mode 100644 index 0000000..b1cf55d --- /dev/null +++ b/src/test/resources/oracle/spline_inverse.json @@ -0,0 +1,11 @@ +{ + "source": "crates/starlink-ast/tests/spline_inverse_oracle/cases.rs", + "generator": "tools/oracle_fixtures/spline_inverse_probe.c", + "rustCommit": "10f61689f19a5f1eacc7e653c7eab9b03809939f", + "consts": { + "U": ["BAD",12.049767072857644,11.921107191183193,1.7788366846173014,14.44116900360215,0.3056610331771712,95.24464880295238,147.7254590568177,"BAD",77.68709057730592], + "V": ["BAD",6.439474132952863,5.788762120688824,1.5841275134629758,14.580876752701613,77.43010929535424,102.707899556638,99.94739777629978,"BAD",57.23729551243569], + "X": ["BAD",12.500000000000059,12.000000000000075,1.0000000000000149,15.0,1.000000000000241,94.99999999999999,149.50000000000782,"BAD",77.77000000023686], + "Y": ["BAD",8.80000000000005,8.000000000000062,1.00000000000001,15.0,75.99999999999987,99.99999999999999,99.79999999999349,"BAD",54.29999999981005] + } +} diff --git a/src/test/resources/oracle/xphmap.json b/src/test/resources/oracle/xphmap.json new file mode 100644 index 0000000..e7a852b --- /dev/null +++ b/src/test/resources/oracle/xphmap.json @@ -0,0 +1,10 @@ +{ + "source": "crates/starlink-ast/tests/xphmap_oracle/cases.rs", + "generator": "tools/oracle_fixtures/xphmap_probe.c", + "rustCommit": "10f61689f19a5f1eacc7e653c7eab9b03809939f", + "consts": { + "ORDER": 1, + "STEPS": 25, + "CASES": [["HPX0",true,["BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.5,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.0,5.0,5.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.5,5.5,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.0,6.0,6.0,6.0,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,1.0,1.0,1.0,1.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.5,9.5,9.5,9.5,9.5,9.5,9.5,9.5,1.5,1.5,1.5,1.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.0,10.0,10.0,10.0,10.0,10.0,2.0,2.0,2.0,2.0,2.0,2.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.5,10.5,10.5,10.5,10.5,10.5,2.5,2.5,2.5,2.5,2.5,2.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.0,6.0,6.0,6.0,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD"],["BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD"]],["HPX0",false,["BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.5,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.0,5.0,5.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.5,5.5,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.0,6.0,6.0,6.0,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,1.0,1.0,1.0,1.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.5,9.5,9.5,9.5,9.5,9.5,9.5,9.5,1.5,1.5,1.5,1.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.0,10.0,10.0,10.0,10.0,10.0,2.0,2.0,2.0,2.0,2.0,2.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.5,10.5,10.5,10.5,10.5,10.5,2.5,2.5,2.5,2.5,2.5,2.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.0,6.0,6.0,6.0,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD"],["BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD"]],["HPX12",true,["BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.0,0.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.5,0.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.0,1.0,1.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.5,1.5,1.5,1.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.0,2.0,2.0,2.0,2.0,2.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.5,2.5,2.5,2.5,2.5,2.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.5,9.5,9.5,9.5,9.5,9.5,9.5,9.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.0,10.0,10.0,10.0,10.0,10.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.5,10.5,10.5,10.5,10.5,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD"],["BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD"]],["HPX12",false,["BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.0,0.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.5,0.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.0,1.0,1.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.5,1.5,1.5,1.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.0,2.0,2.0,2.0,2.0,2.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.5,2.5,2.5,2.5,2.5,2.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.5,9.5,9.5,9.5,9.5,9.5,9.5,9.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.0,10.0,10.0,10.0,10.0,10.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.5,10.5,10.5,10.5,10.5,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD"],["BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,9.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD"]],["XPHN",true,[12.0,11.5,11.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,12.0,11.5,11.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.5,9.5,9.5,9.5,9.5,9.5,9.5,9.5,"BAD","BAD",12.0,11.5,11.0,10.5,10.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,"BAD","BAD",12.0,11.5,11.0,10.5,10.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,"BAD","BAD","BAD","BAD",12.0,11.5,11.0,10.5,10.0,9.5,9.0,"BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,"BAD","BAD","BAD","BAD",12.0,11.5,11.0,10.5,10.0,9.5,9.0,"BAD","BAD","BAD","BAD",7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD",11.5,11.0,10.5,10.0,9.5,9.0,8.5,8.0,"BAD","BAD",7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD",11.5,11.0,10.5,10.0,9.5,9.0,8.5,8.0,"BAD","BAD",6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.5,10.0,9.5,9.0,8.5,8.0,7.5,7.0,6.0,6.0,6.0,6.0,6.0,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.5,10.0,9.5,9.0,8.5,8.0,7.5,7.0,5.5,5.5,5.5,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.5,9.0,8.5,8.0,7.5,7.0,5.0,5.0,5.0,5.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.5,9.0,8.5,8.0,7.5,7.0,6.5,3.0,3.5,4.0,4.5,5.0,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.0,1.0,1.0,3.0,3.5,4.0,4.5,5.0,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.5,1.5,1.5,1.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.0,2.0,2.0,2.0,2.0,2.0,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.5,2.5,2.5,2.5,2.5,2.5,"BAD","BAD",4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,"BAD","BAD",4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,"BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD",4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,"BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD",4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.5,7.0,7.5,8.0,8.5,9.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.5,7.0,7.5,8.0,8.5,9.0,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,6.0,6.0,6.0,6.0,6.0,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.0,6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.5,9.0,7.0,7.0,7.0,7.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.5,9.0],[5.0,5.0,5.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.0,4.5,4.0,3.5,3.0,2.5,2.0,5.5,5.5,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.0,5.5,5.0,4.5,4.0,3.5,3.0,"BAD","BAD",6.0,6.0,6.0,6.0,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.0,5.5,5.0,4.5,4.0,3.5,3.0,"BAD","BAD",6.5,6.5,6.5,6.5,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.5,7.0,6.5,6.0,5.5,5.0,4.5,4.0,"BAD","BAD","BAD","BAD",7.0,7.0,7.0,7.0,7.0,7.0,7.0,"BAD","BAD","BAD","BAD","BAD","BAD",7.5,7.0,6.5,6.0,5.5,5.0,4.5,4.0,"BAD","BAD","BAD","BAD",7.5,7.5,7.5,7.5,7.5,7.5,7.5,"BAD","BAD","BAD","BAD",8.5,8.0,7.5,7.0,6.5,6.0,5.5,5.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,"BAD","BAD",8.5,8.0,7.5,7.0,6.5,6.0,5.5,5.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,"BAD","BAD",8.5,8.0,7.5,7.0,6.5,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,8.5,8.0,7.5,7.0,6.5,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.5,9.5,9.5,9.5,9.5,9.5,9.5,9.5,8.5,8.0,7.5,7.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.0,10.0,10.0,10.0,10.0,10.0,8.5,8.0,7.5,7.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.5,10.5,10.5,10.5,10.5,10.5,10.5,6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,6.0,6.0,6.0,6.0,6.0,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD",4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD",4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD",3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,"BAD","BAD","BAD",0.0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,"BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,"BAD","BAD","BAD",0.0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.5,2.5,2.5,2.5,2.5,2.5,2.5,-1.0,-0.5,0.0,0.5,1.0,1.5,2.0,2.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.0,2.0,2.0,2.0,2.0,2.0,2.0,-1.0,-0.5,0.0,0.5,1.0,1.5,2.0,2.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.5,1.5,1.5,1.5,1.5,-1.0,-0.5,0.0,0.5,1.0,1.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.0,1.0,1.0,1.0,-1.0,-0.5,0.0,0.5,1.0,1.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.5,0.5,0.5,-1.0,-0.5,0.0,0.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.0,0.0,0.0]],["XPHN",false,["BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.5,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.0,5.0,5.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.5,5.5,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.0,6.0,6.0,6.0,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,6.0,5.5,5.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,6.0,5.5,5.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,7.0,6.5,6.0,5.5,5.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,7.0,6.5,6.0,5.5,5.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,7.5,7.0,6.5,6.0,5.5,5.0,4.5,4.0,4.0,4.0,4.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,7.5,7.0,6.5,6.0,5.5,5.0,4.5,3.5,3.5,3.5,3.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,7.5,7.0,6.5,6.0,5.5,3.0,3.0,3.0,3.0,3.0,3.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,7.5,7.0,6.5,6.0,5.5,2.5,2.5,2.5,2.5,2.5,2.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.0,1.0,1.0,1.0,1.0,2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.5,0.5,0.5,0.5,0.5,0.5,2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD"],["BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.0,2.5,3.0,3.5,4.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.0,5.0,5.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.5,5.5,5.5,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,6.0,6.0,6.0,6.0,6.0,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.0,0.5,1.0,1.5,2.0,2.5,3.0,3.5,6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,6.0,5.5,5.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,6.0,5.5,5.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.0,8.0,8.0,8.0,8.0,7.0,6.5,6.0,5.5,5.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.5,8.5,8.5,8.5,8.5,8.5,7.0,6.5,6.0,5.5,5.0,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,7.5,7.0,6.5,6.0,5.5,5.0,4.5,4.0,4.0,4.0,4.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,7.5,7.0,6.5,6.0,5.5,5.0,4.5,3.5,3.5,3.5,3.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,7.5,7.0,6.5,6.0,5.5,3.0,3.0,3.0,3.0,3.0,3.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,7.5,7.0,6.5,6.0,5.5,2.5,2.5,2.5,2.5,2.5,2.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.0,2.0,2.0,2.0,2.0,2.0,2.0,2.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.5,1.5,1.5,1.5,1.5,1.5,1.5,1.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.0,1.0,1.0,1.0,1.0,1.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.5,0.5,0.5,0.5,0.5,0.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD"]],["XPHS",true,[3.0,3.5,4.0,4.5,5.0,5.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.0,5.0,5.0,5.0,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.5,5.5,5.5,5.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.0,6.0,6.0,6.0,6.0,6.0,"BAD","BAD",4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD",4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,"BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,"BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD",7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,"BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD",8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD",8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,9.5,9.5,9.5,9.5,9.5,9.5,9.5,9.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,10.0,10.0,10.0,10.0,10.0,10.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.5,6.5,6.5,6.5,6.5,10.5,10.5,10.5,10.5,10.5,10.5,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.0,6.0,6.0,6.0,6.0,4.5,4.0,3.5,3.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,4.5,4.0,3.5,3.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,4.5,4.0,3.5,3.0,2.5,2.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,"BAD","BAD",4.5,4.0,3.5,3.0,2.5,2.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,"BAD","BAD",4.5,4.0,3.5,3.0,2.5,2.0,1.5,1.0,"BAD","BAD","BAD","BAD","BAD","BAD",3.5,3.5,3.5,3.5,3.5,3.5,3.5,"BAD","BAD","BAD","BAD",4.5,4.0,3.5,3.0,2.5,2.0,1.5,1.0,"BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.0,3.0,3.0,3.0,3.0,3.0,"BAD","BAD","BAD","BAD","BAD","BAD",3.5,3.0,2.5,2.0,1.5,1.0,0.5,0.0,"BAD","BAD","BAD","BAD",2.5,2.5,2.5,2.5,2.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.5,3.0,2.5,2.0,1.5,1.0,0.5,0.0,"BAD","BAD","BAD","BAD",2.0,2.0,2.0,2.0,2.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.5,2.0,1.5,1.0,0.5,0.0,-0.5,-1.0,"BAD","BAD",1.5,1.5,1.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",2.5,2.0,1.5,1.0,0.5,0.0,-0.5,-1.0,"BAD","BAD",1.0,1.0,1.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.5,1.0,0.5,0.0,-0.5,-1.0,-1.5,-2.0,0.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",1.5,1.0,0.5,0.0,-0.5,-1.0,-1.5,-2.0,0.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",0.5,0.0,-0.5,-1.0,-1.5,-2.0],[10.0,10.0,10.0,10.0,10.0,10.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",11.0,11.5,12.0,12.5,13.0,9.5,9.5,9.5,9.5,9.5,9.5,9.5,9.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",11.0,11.5,12.0,12.5,13.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,9.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.0,10.5,11.0,11.5,12.0,12.5,13.0,"BAD","BAD",8.5,8.5,8.5,8.5,8.5,8.5,8.5,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",10.0,10.5,11.0,11.5,12.0,12.5,13.0,"BAD","BAD",8.0,8.0,8.0,8.0,8.0,8.0,8.0,8.0,"BAD","BAD","BAD","BAD","BAD","BAD",9.0,9.5,10.0,10.5,11.0,11.5,12.0,12.5,"BAD","BAD","BAD","BAD","BAD",7.5,7.5,7.5,7.5,7.5,7.5,7.5,7.5,"BAD","BAD","BAD","BAD",9.0,9.5,10.0,10.5,11.0,11.5,12.0,12.5,"BAD","BAD","BAD","BAD","BAD",7.0,7.0,7.0,7.0,7.0,7.0,7.0,7.0,"BAD","BAD",8.0,8.5,9.0,9.5,10.0,10.5,11.0,11.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD",8.0,8.5,9.0,9.5,10.0,10.5,11.0,11.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.0,6.0,6.0,6.0,6.0,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.5,5.5,5.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.0,5.0,5.0,7.0,7.5,8.0,8.5,9.0,9.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.0,4.5,4.0,3.5,3.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.0,4.5,4.0,3.5,3.0,1.0,1.0,1.0,1.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.0,5.5,5.0,4.5,4.0,3.5,3.0,1.5,1.5,1.5,1.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.0,5.5,5.0,4.5,4.0,3.5,3.0,2.0,2.0,2.0,2.0,2.0,2.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.5,7.0,6.5,6.0,5.5,5.0,4.5,4.0,"BAD","BAD",2.5,2.5,2.5,2.5,2.5,2.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.5,7.0,6.5,6.0,5.5,5.0,4.5,4.0,"BAD","BAD",3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,"BAD","BAD","BAD","BAD","BAD","BAD",8.0,7.5,7.0,6.5,6.0,5.5,5.0,"BAD","BAD","BAD","BAD",3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,"BAD","BAD","BAD","BAD","BAD","BAD",8.0,7.5,7.0,6.5,6.0,5.5,5.0,"BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,"BAD","BAD","BAD","BAD",8.0,7.5,7.0,6.5,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,"BAD","BAD","BAD","BAD",8.0,7.5,7.0,6.5,6.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,"BAD","BAD",8.0,7.5,7.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,"BAD","BAD",8.0,7.5,7.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,8.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.5,6.5,6.5,6.5,6.5,6.5,6.5,8.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.0,7.0,7.0,7.0,7.0]],["XPHS",false,["BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,8.0,8.0,8.0,8.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,7.5,7.5,7.5,7.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,7.0,7.0,7.0,7.0,7.0,7.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.5,5.0,5.5,6.0,6.5,7.0,7.5,6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,2.0,1.5,1.0,0.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.0,1.5,1.0,0.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.0,5.0,5.0,5.0,5.0,3.0,2.5,2.0,1.5,1.0,0.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.5,4.5,4.5,4.5,4.5,4.5,3.0,2.5,2.0,1.5,1.0,0.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,3.5,3.0,2.5,2.0,1.5,1.0,0.5,1.0,1.0,1.0,1.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,3.5,3.0,2.5,2.0,1.5,1.0,0.5,1.5,1.5,1.5,1.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,3.5,3.0,2.5,2.0,1.5,2.0,2.0,2.0,2.0,2.0,2.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,3.5,3.0,2.5,2.0,1.5,2.5,2.5,2.5,2.5,2.5,2.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.0,4.0,4.0,4.0,4.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.5,4.5,4.5,4.5,4.5,4.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD"],["BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",9.0,9.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.5,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",8.0,8.0,8.0,8.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.5,7.5,7.5,7.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",7.0,7.0,7.0,7.0,7.0,7.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.5,6.5,6.5,6.5,6.5,6.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",6.0,6.0,6.0,6.0,6.0,6.0,6.0,6.0,2.0,1.5,1.0,0.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.5,5.5,5.5,5.5,5.5,5.5,5.5,5.5,2.0,1.5,1.0,0.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.0,5.0,5.0,5.0,5.0,5.0,5.0,3.0,2.5,2.0,1.5,1.0,0.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.5,4.5,4.5,4.5,4.5,4.5,4.5,4.5,3.0,2.5,2.0,1.5,1.0,0.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,3.5,3.0,2.5,2.0,1.5,1.0,0.5,1.0,1.0,1.0,1.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,3.5,3.0,2.5,2.0,1.5,1.0,0.5,1.5,1.5,1.5,1.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,3.5,3.0,2.5,2.0,1.5,2.0,2.0,2.0,2.0,2.0,2.0,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,3.5,3.0,2.5,2.0,1.5,2.5,2.5,2.5,2.5,2.5,2.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",3.5,3.5,3.5,3.5,3.5,3.5,3.5,3.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.0,4.0,4.0,4.0,4.0,4.0,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",4.5,4.5,4.5,4.5,4.5,4.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,8.0,8.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD",5.0,5.5,6.0,6.5,7.0,7.5,"BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD","BAD"]]] + } +} diff --git a/src/test/resources/probes/chebymap_probe.c b/src/test/resources/probes/chebymap_probe.c new file mode 100644 index 0000000..c02485a --- /dev/null +++ b/src/test/resources/probes/chebymap_probe.c @@ -0,0 +1,761 @@ +/* chebymap_probe -- ChebyMap behaviour of the pinned C library that no + * fixture or oracle holds. + * + * Whether a ChebyMap is a PolyMap (astIsAPolyMap) and its dump; the values + * it gives inside, on the edge of and outside its bounding box, and for + * bad and NaN inputs, in both directions; a ChebyMap with no inverse + * coefficients, with IterInverse unset, set and cleared (C's ChebyMap + * never uses an iterative inverse); astChebyDomain of each direction, of + * an inverted ChebyMap, of one with no inverse coefficients (found by + * astMapBox), of one with neither and of one whose box has no width + * that C can represent; astSimplify of a ChebyMap next to a PolyMap, a + * WinMap and its own inverse, in series and in parallel; its comparisons; + * the constructor's and loader's errors; astPolyTran with the ChebyMap's + * own box; and the checks of testchebymap.c, with every value printed. + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * The probe is built from the repository root against two builds of the C + * library at 3d3f255f on macOS AArch64 (Apple clang 21), made with + * cmake -S reference/starlink-ast -B -DCMAKE_BUILD_TYPE=Release + * -DBUILD_TESTING=OFF [-DCMAKE_C_FLAGS=-ffp-contract=off] + * The first, with the compiler's default flags, contracts a*b+c into a + * fused multiply-add (chebymap.c's normalisation and recurrence among + * others); the second does not. Each is linked with its static libraries: + * cc -std=c11 -I -o chebymap_probe + * src/test/resources/probes/chebymap_probe.c /libast.a + * /libast_pal.a /libast_err.a /libast_grf3d.a + * /libast_grf_2.0.a /libast_grf_3.2.a + * /libast_grf_5.6.a /libast_cminpack.a -lyaml -lm + * and run as ./chebymap_probe > chebymap_probe.txt 2>&1; the output, with + * trailing white space removed from every line, is stored as the "output" + * string of chebymap_probe.json (default flags) and of + * chebymap_probe_nocontract.json (-ffp-contract=off), since the dumps hold + * C's item names, which the spelling check rejects. The two differ only + * in the lines deferred/oracle-rows.txt lists for this probe. The library + * built with CMake's default (unoptimised) flags gives the second output. */ +#include +#include +#include +#include +#include "ast.h" + +#define BAD AST__BAD + +static void head( const char *name ) { + printf( "== %s\n", name ); +} + +/* Reports a failed call, then clears the status. */ +static int failed( void ) { + if( !astOK ) { + printf( "status %d\n", astStatus ); + astClearStatus; + return 1; + } + return 0; +} + +static void show( AstObject *obj ) { + astShow( obj ); + failed(); +} + +/* Transforms npt points of nin coordinates, given coordinate by coordinate + in "in", and prints one line per point. */ +static void tran( AstMapping *m, int npt, int nin, const double *in, int forward ) { + double out[ 4 * 32 ]; + int nout = astGetI( m, forward ? "Nout" : "Nin" ); + astTranN( m, npt, nin, npt, in, forward, nout, npt, out ); + if( failed() ) return; + for( int i = 0; i < npt; i++ ) { + printf( "%s", forward ? "fwd" : "inv" ); + for( int j = 0; j < nin; j++ ) printf( " %.17g", in[ j*npt + i ] ); + printf( " ->" ); + for( int j = 0; j < nout; j++ ) printf( " %.17g", out[ j*npt + i ] ); + printf( "\n" ); + } +} + +/* The class of the simplified Mapping, whether it is the Mapping itself, + and its dump. */ +static void simp( AstMapping *m ) { + AstMapping *s = astSimplify( m ); + if( failed() ) return; + printf( "-- simplified %s same %d\n", astGetC( s, "Class" ), astSame( s, m ) ); + show( (AstObject *) s ); +} + +/* astChebyDomain in one direction. */ +static void domain( AstChebyMap *cm, int forward ) { + double lbnd[ 4 ], ubnd[ 4 ]; + int naxes = astGetI( cm, forward ? "Nin" : "Nout" ); + astChebyDomain( cm, forward, lbnd, ubnd ); + if( failed() ) return; + printf( "domain %d", forward ); + for( int i = 0; i < naxes; i++ ) printf( " %.17g", lbnd[ i ] ); + printf( " :" ); + for( int i = 0; i < naxes; i++ ) printf( " %.17g", ubnd[ i ] ); + printf( "\n" ); +} + +/* astPolyCoeffs in one direction, one line per coefficient. */ +static void coeffs( AstPolyMap *pm, int forward ) { + double cofs[ 400 ]; + int nco; + int naxes = astGetI( pm, forward ? "Nin" : "Nout" ); + astPolyCoeffs( pm, forward, 400, cofs, &nco ); + if( failed() ) return; + printf( "coeffs %d n %d\n", forward, nco ); + for( int i = 0; i < nco; i++ ) { + printf( "cof" ); + for( int j = 0; j < 2 + naxes; j++ ) printf( " %.17g", cofs[ i*( 2 + naxes ) + j ] ); + printf( "\n" ); + } +} + +/* The iterative inverse attributes and the definedness of each direction. */ +static void iter( AstMapping *m ) { + printf( "IterInverse %d set %d TranForward %d TranInverse %d\n", + astGetI( m, "IterInverse" ), astTest( m, "IterInverse" ), + astGetI( m, "TranForward" ), astGetI( m, "TranInverse" ) ); + failed(); +} + +static void equal( const char *label, AstObject *a, AstObject *b ) { + printf( "equal %s %d\n", label, astEqual( a, b ) ); + failed(); +} + +/* testchebymap.c's coefficient sets. */ +/* f(x) = 1.5*T0(x') - 1.0*T2(x') + 2.0*T3(x') + 1.3*T4(x') */ +static double coeffs_1[] = { 1.5, 1, 0, -1.0, 1, 2, 2.0, 1, 3, 1.3, 1, 4 }; +/* f(x) = 1.0*T0(x') - 2.0*T1(x') */ +static double coeffs_2[] = { 1.0, 1, 0, -2.0, 1, 1 }; +/* fx(x,y) = 1.0*T0(x')T0(y') - 2.0*T1(x')T2(y') + T1(y') + fy(x,y) = 1.5*T0(x')T0(y') - 2.5*T1(x')T2(y') */ +static double coeffs_3[] = { 1.0, 1, 0, 0, -2.0, 1, 1, 2, 1.0, 1, 0, 1, 1.5, 2, 0, 0, -2.5, 2, 1, 2 }; +/* fx(x,y) = T1(x') + T1(y'), fy(x,y) = T1(x') - T1(y') */ +static double coeffs_4[] = { 1.0, 1, 1, 0, 1.0, 1, 0, 1, 1.0, 2, 1, 0, -1.0, 2, 0, 1 }; + +/* The checks of testchebymap.c, in its order, each value printed. */ +static void testchebymap_cases( void ) { + double lbnd[ 2 ] = { -1.0, -1.0 }, ubnd[ 2 ] = { 1.0, 1.0 }; + double xin[ 5 ] = { -1.0, -0.5, 0.0, 0.5, 1.0 }; + AstChebyMap *cm, *cm2, *cm3; + + for( int n = 1; n <= 4; n++ ) { + char name[ 32 ]; + snprintf( name, sizeof name, "t_eval_%d", n ); + head( name ); + cm = astChebyMap( 1, 1, n, coeffs_1, 0, NULL, lbnd, ubnd, lbnd, ubnd, " " ); + tran( (AstMapping *) cm, 5, 1, xin, 1 ); + if( n == 4 ) iter( (AstMapping *) cm ); + } + + head( "t_polytran_1d" ); + cm = astChebyMap( 1, 1, 2, coeffs_2, 0, NULL, lbnd, ubnd, lbnd, ubnd, " " ); + cm2 = (AstChebyMap *) astPolyTran( cm, 0, 0.01, 0.01, 5, lbnd, ubnd ); + if( !failed() && cm2 ) { + double xout[ 5 ]; + printf( "-- class %s\n", astGetC( cm2, "Class" ) ); + tran( (AstMapping *) cm2, 5, 1, xin, 1 ); + astTran1( cm2, 5, xin, 1, xout ); + tran( (AstMapping *) cm2, 5, 1, xout, 0 ); + domain( cm2, 0 ); + domain( cm2, 1 ); + coeffs( (AstPolyMap *) cm2, 0 ); + iter( (AstMapping *) cm2 ); + show( (AstObject *) cm2 ); + } + + head( "t_polytran_wide" ); + lbnd[ 0 ] = -100.0; + ubnd[ 0 ] = 100.0; + cm = astChebyMap( 1, 1, 4, coeffs_1, 0, NULL, lbnd, ubnd, lbnd, ubnd, " " ); + { + double fit_lbnd = -5.0, fit_ubnd = 50.0; + double x[ 5 ] = { 0.0, 10.0, 20.0, 30.0, 40.0 }, xout[ 5 ]; + cm2 = (AstChebyMap *) astPolyTran( cm, 0, 0.01, 0.01, 10, &fit_lbnd, &fit_ubnd ); + if( !failed() && cm2 ) { + tran( (AstMapping *) cm2, 5, 1, x, 1 ); + astTran1( cm2, 5, x, 1, xout ); + tran( (AstMapping *) cm2, 5, 1, xout, 0 ); + domain( cm2, 0 ); + coeffs( (AstPolyMap *) cm2, 0 ); + cm3 = astCopy( cm2 ); + equal( "copy", (AstObject *) cm2, (AstObject *) cm3 ); + { + char *text = astToString( cm2 ); + AstObject *back = astFromString( text ); + if( !failed() ) equal( "read", back, (AstObject *) cm2 ); + text = astFree( text ); + } + show( (AstObject *) cm2 ); + } + } + + head( "t_2d_unit" ); + lbnd[ 0 ] = -1.0; + ubnd[ 0 ] = 1.0; + cm = astChebyMap( 2, 2, 4, coeffs_4, 0, NULL, lbnd, ubnd, lbnd, ubnd, " " ); + cm2 = astCopy( cm ); + astInvert( cm2 ); + simp( (AstMapping *) astCmpMap( cm, cm2, 1, " " ) ); + { + double in[ 2 ][ 4 ] = { { 0.5, 0.0, -0.5, 0.0 }, { 0.0, 0.5, 0.0, -0.5 } }; + double out[ 2 ][ 4 ]; + tran( (AstMapping *) cm, 4, 2, &in[ 0 ][ 0 ], 1 ); + astTran2( cm, 4, in[ 0 ], in[ 1 ], 1, out[ 0 ], out[ 1 ] ); + cm2 = (AstChebyMap *) astPolyTran( cm, 0, 0.01, 0.01, 10, lbnd, ubnd ); + if( !failed() && cm2 ) { + tran( (AstMapping *) cm2, 4, 2, &out[ 0 ][ 0 ], 0 ); + coeffs( (AstPolyMap *) cm2, 0 ); + domain( cm2, 0 ); + } + } + + head( "t_2d_nonunit" ); + lbnd[ 0 ] = 0.0; + lbnd[ 1 ] = 0.0; + ubnd[ 0 ] = 10.0; + ubnd[ 1 ] = 10.0; + cm = astChebyMap( 2, 2, 5, coeffs_3, 0, NULL, lbnd, ubnd, lbnd, ubnd, " " ); + { + double in[ 2 ][ 4 ] = { { 0.0, 2.0, 6.0, 10.0 }, { 2.0, 5.0, 8.0, 0.0 } }; + double fit[ 2 ][ 4 ] = { { 4.0, 4.5, 5.0, 5.5 }, { 6.0, 5.5, 5.0, 4.5 } }; + double out[ 2 ][ 4 ]; + double tlbnd[ 2 ] = { 4.0, 4.0 }, tubnd[ 2 ] = { 6.0, 6.0 }; + tran( (AstMapping *) cm, 4, 2, &in[ 0 ][ 0 ], 1 ); + cm2 = (AstChebyMap *) astPolyTran( cm, 0, 0.01, 0.01, 10, tlbnd, tubnd ); + if( !failed() && cm2 ) { + tran( (AstMapping *) cm2, 4, 2, &fit[ 0 ][ 0 ], 1 ); + astTran2( cm2, 4, fit[ 0 ], fit[ 1 ], 1, out[ 0 ], out[ 1 ] ); + tran( (AstMapping *) cm2, 4, 2, &out[ 0 ][ 0 ], 0 ); + coeffs( (AstPolyMap *) cm2, 1 ); + coeffs( (AstPolyMap *) cm2, 0 ); + domain( cm, 1 ); + domain( cm, 0 ); + domain( cm2, 1 ); + domain( cm2, 0 ); + } + } + + head( "t_inverted_domain" ); + { + double fc[] = { 1.0, 1, 1, 0, 1.0, 2, 0, 1, 0.25, 2, 1, 1 }; + double flb[] = { 0.0, -1.0 }, fub[] = { 1.0, 2.0 }; + AstChebyMap *fcm = astChebyMap( 2, 2, 3, fc, 0, NULL, flb, fub, NULL, NULL, " " ); + domain( fcm, 1 ); + domain( fcm, 0 ); + astInvert( fcm ); + domain( fcm, 1 ); + domain( fcm, 0 ); + } + + head( "t_rate" ); + { + double rate_coeffs[] = { 3.0, 1, 1 }; + double rlbnd = -1.0, rubnd = 1.0; + double at[ 3 ] = { 0.5, 0.0, 1.0 }; + AstChebyMap *rcm = astChebyMap( 1, 1, 1, rate_coeffs, 0, NULL, &rlbnd, &rubnd, &rlbnd, &rubnd, " " ); + for( int i = 0; i < 3; i++ ) { + printf( "rate %.17g -> %.17g\n", at[ i ], astRate( rcm, at + i, 1, 1 ) ); + failed(); + } + } + + head( "t_linear_1d" ); + { + double lin_coeffs[] = { 2.0, 1, 1 }; + double lin_lbnd = 0.0, lin_ubnd = 10.0; + double lx[ 3 ] = { 0.0, 1.0, 10.0 }, lref[ 3 ]; + AstChebyMap *lcm = astChebyMap( 1, 1, 1, lin_coeffs, 0, NULL, &lin_lbnd, &lin_ubnd, NULL, NULL, " " ); + AstMapping *lsm = astSimplify( lcm ); + simp( (AstMapping *) lcm ); + tran( (AstMapping *) lcm, 3, 1, lx, 1 ); + tran( lsm, 3, 1, lx, 1 ); + astTran1( lcm, 3, lx, 1, lref ); + tran( lsm, 3, 1, lref, 0 ); + } + + head( "t_linear_2d" ); + { + double lin2_coeffs[] = { 3.0, 1, 1, 0, 0.5, 1, 0, 0, -1.0, 2, 0, 1, 2.0, 2, 0, 0 }; + double lin2_lbnd[ 2 ] = { 0.0, -5.0 }, lin2_ubnd[ 2 ] = { 10.0, 5.0 }; + double l2[ 2 ][ 4 ] = { { 0.0, 10.0, 3.0, 7.5 }, { -5.0, 5.0, 1.0, -2.0 } }; + double ref[ 2 ][ 4 ]; + AstChebyMap *lcm2 = astChebyMap( 2, 2, 4, lin2_coeffs, 0, NULL, lin2_lbnd, lin2_ubnd, NULL, NULL, " " ); + AstMapping *lsm2 = astSimplify( lcm2 ); + simp( (AstMapping *) lcm2 ); + tran( (AstMapping *) lcm2, 4, 2, &l2[ 0 ][ 0 ], 1 ); + tran( lsm2, 4, 2, &l2[ 0 ][ 0 ], 1 ); + astTran2( lcm2, 4, l2[ 0 ], l2[ 1 ], 1, ref[ 0 ], ref[ 1 ] ); + tran( lsm2, 4, 2, &ref[ 0 ][ 0 ], 0 ); + } +} + +/* A 2-D ChebyMap with both transformations: forward over [0,10]x[-2,2], + inverse over [-1,3]x[0,8]. */ +static AstChebyMap *both_ways( void ) { + double fc[] = { 1.0, 1, 1, 0, 0.5, 1, 2, 1, -0.25, 2, 0, 3, 2.0, 2, 0, 0 }; + double ic[] = { 3.0, 1, 1, 0, 1.5, 1, 0, 0, 0.75, 2, 2, 1 }; + double flb[] = { 0.0, -2.0 }, fub[] = { 10.0, 2.0 }; + double ilb[] = { -1.0, 0.0 }, iub[] = { 3.0, 8.0 }; + return astChebyMap( 2, 2, 4, fc, 3, ic, flb, fub, ilb, iub, " " ); +} + +/* A 1-D quadratic ChebyMap with no inverse coefficients: 1 + T1 + 0.5 T2 + over [0,10]. */ +static AstChebyMap *quadratic( void ) { + double fc[] = { 1.0, 1, 0, 1.0, 1, 1, 0.5, 1, 2 }; + double lb = 0.0, ub = 10.0; + return astChebyMap( 1, 1, 3, fc, 0, NULL, &lb, &ub, NULL, NULL, " " ); +} + +static void focus_cases( void ) { + AstChebyMap *cm; + + head( "isa" ); + cm = quadratic(); + printf( "IsAPolyMap %d IsAChebyMap %d IsAMapping %d Class %s\n", astIsAPolyMap( cm ), + astIsAChebyMap( cm ), astIsAMapping( cm ), astGetC( cm, "Class" ) ); + { + double pc[] = { 1.0, 1, 1 }; + AstPolyMap *pm = astPolyMap( 1, 1, 1, pc, 0, NULL, " " ); + printf( "PolyMap IsAChebyMap %d\n", astIsAChebyMap( pm ) ); + } + show( (AstObject *) cm ); + + /* Review Focus 3: points inside, on the edge of and outside the box, and + bad and NaN values, in both directions. */ + head( "outside_box" ); + cm = both_ways(); + { + double qnan = nan( "" ); + double in[ 2 ][ 12 ] = { + { 5.0, 0.0, 10.0, nextafter( 0.0, -1.0 ), nextafter( 10.0, 20.0 ), -1.0, 11.0, 5.0, 5.0, BAD, qnan, 1.0e300 }, + { 0.5, -2.0, 2.0, 0.0, 0.0, 0.0, 0.0, 2.5, BAD, 1.0, 1.0, 0.0 } }; + double inv[ 2 ][ 10 ] = { + { 1.0, -1.0, 3.0, -1.5, 3.5, 1.0, 1.0, BAD, qnan, nextafter( 3.0, 4.0 ) }, + { 4.0, 0.0, 8.0, 4.0, 4.0, -0.5, BAD, 4.0, 4.0, 4.0 } }; + tran( (AstMapping *) cm, 12, 2, &in[ 0 ][ 0 ], 1 ); + tran( (AstMapping *) cm, 10, 2, &inv[ 0 ][ 0 ], 0 ); + astInvert( cm ); + tran( (AstMapping *) cm, 10, 2, &inv[ 0 ][ 0 ], 1 ); + tran( (AstMapping *) cm, 12, 2, &in[ 0 ][ 0 ], 0 ); + } + + /* Review Focus 3: no inverse coefficients; IterInverse unset, set and + cleared. */ + head( "no_inverse" ); + cm = quadratic(); + { + double y[ 2 ] = { 1.0, 2.0 }; + iter( (AstMapping *) cm ); + tran( (AstMapping *) cm, 2, 1, y, 0 ); + astSetI( cm, "IterInverse", 1 ); + failed(); + iter( (AstMapping *) cm ); + printf( "-- attribute %s\n", astGetC( cm, "IterInverse" ) ); + tran( (AstMapping *) cm, 2, 1, y, 0 ); + show( (AstObject *) cm ); + astSetI( cm, "IterInverse", 0 ); + iter( (AstMapping *) cm ); + show( (AstObject *) cm ); + astClear( cm, "IterInverse" ); + iter( (AstMapping *) cm ); + astSetI( cm, "NiterInverse", 7 ); + astSetD( cm, "TolInverse", 1.0e-9 ); + show( (AstObject *) cm ); + } + + head( "no_inverse_polymap" ); + { + double fc[] = { 1.0, 1, 0, 1.0, 1, 1, 0.5, 1, 2 }; + double y[ 2 ] = { 1.0, 2.0 }; + AstPolyMap *pm = astPolyMap( 1, 1, 3, fc, 0, NULL, " " ); + iter( (AstMapping *) pm ); + tran( (AstMapping *) pm, 2, 1, y, 0 ); + } + + head( "iterinverse_unequal" ); + { + double fc[] = { 1.0, 1, 1, 0, 1.0, 1, 0, 1 }; + double lb[] = { 0.0, 0.0 }, ub[] = { 1.0, 1.0 }; + AstChebyMap *c21 = astChebyMap( 2, 1, 2, fc, 0, NULL, lb, ub, NULL, NULL, " " ); + iter( (AstMapping *) c21 ); + astSetI( c21, "IterInverse", 1 ); + failed(); + iter( (AstMapping *) c21 ); + } + + /* astChebyDomain. */ + head( "domain_both" ); + cm = both_ways(); + domain( cm, 1 ); + domain( cm, 0 ); + astInvert( cm ); + domain( cm, 1 ); + domain( cm, 0 ); + + head( "domain_no_inverse" ); + cm = quadratic(); + domain( cm, 1 ); + domain( cm, 0 ); + astInvert( cm ); + domain( cm, 1 ); + domain( cm, 0 ); + + head( "domain_no_forward" ); + { + double ic[] = { 2.0, 1, 1, 1.0, 1, 0 }; + double lb = -4.0, ub = 4.0; + cm = astChebyMap( 1, 1, 0, NULL, 2, ic, NULL, NULL, &lb, &ub, " " ); + iter( (AstMapping *) cm ); + domain( cm, 1 ); + domain( cm, 0 ); + show( (AstObject *) cm ); + } + + head( "domain_neither" ); + { + double lb[] = { 0.0, 0.0 }, ub[] = { 1.0, 1.0 }; + cm = astChebyMap( 2, 2, 0, NULL, 0, NULL, lb, ub, lb, ub, " " ); + iter( (AstMapping *) cm ); + domain( cm, 1 ); + domain( cm, 0 ); + show( (AstObject *) cm ); + } + + head( "domain_bad_coefficient" ); + { + double fc[] = { BAD, 1, 1 }; + double lb = 0.0, ub = 1.0, x[ 2 ] = { 0.0, 0.5 }; + cm = astChebyMap( 1, 1, 1, fc, 0, NULL, &lb, &ub, NULL, NULL, " " ); + tran( (AstMapping *) cm, 2, 1, x, 1 ); + domain( cm, 1 ); + domain( cm, 0 ); + } + + head( "domain_infinite_width" ); + { + double fc[] = { 1.0, 1, 0, 2.0, 1, 1 }; + double lb = -1.0e308, ub = 1.0e308, x[ 3 ] = { -1.0e308, 0.0, 5.0 }; + cm = astChebyMap( 1, 1, 2, fc, 0, NULL, &lb, &ub, NULL, NULL, " " ); + tran( (AstMapping *) cm, 3, 1, x, 1 ); + domain( cm, 1 ); + show( (AstObject *) cm ); + } + + /* Review Focus 3: simplification next to a PolyMap, a WinMap and its own + inverse. */ + head( "simp_alone" ); + simp( (AstMapping *) quadratic() ); + + head( "simp_poly_win" ); + { + double pc[] = { 1.0, 1, 1, 0.1, 1, 3 }; + double ina = 0.0, inb = 1.0, outa = 2.0, outb = 4.0; + AstPolyMap *pm = astPolyMap( 1, 1, 2, pc, 0, NULL, " " ); + AstWinMap *wm = astWinMap( 1, &ina, &inb, &outa, &outb, " " ); + AstMapping *m = (AstMapping *) astCmpMap( astCmpMap( wm, quadratic(), 1, " " ), pm, 1, " " ); + double x[ 3 ] = { 0.0, 0.5, 1.0 }; + simp( m ); + tran( m, 3, 1, x, 1 ); + } + + head( "simp_linear_win" ); + { + double fc[] = { 4.0, 1, 1, 1.0, 1, 0 }; + double lb = 2.0, ub = 6.0; + double ina = 0.0, inb = 1.0, outa = 2.0, outb = 6.0; + AstChebyMap *lin = astChebyMap( 1, 1, 2, fc, 0, NULL, &lb, &ub, NULL, NULL, " " ); + AstWinMap *wm = astWinMap( 1, &ina, &inb, &outa, &outb, " " ); + AstMapping *m = (AstMapping *) astCmpMap( wm, lin, 1, " " ); + double x[ 4 ] = { 0.0, 0.25, 1.0, 2.0 }; + simp( m ); + tran( m, 4, 1, x, 1 ); + } + + head( "simp_cancel" ); + { + AstChebyMap *a = both_ways(); + AstChebyMap *b = both_ways(); + astInvert( b ); + simp( (AstMapping *) astCmpMap( a, b, 1, " " ) ); + simp( (AstMapping *) astCmpMap( b, a, 1, " " ) ); + simp( (AstMapping *) astCmpMap( a, b, 0, " " ) ); + } + + head( "simp_no_cancel_bounds" ); + { + double fc[] = { 1.0, 1, 0, 1.0, 1, 1, 0.5, 1, 2 }; + double lb = 0.0, ub = 20.0; + AstChebyMap *a = quadratic(); + AstChebyMap *b = astChebyMap( 1, 1, 3, fc, 0, NULL, &lb, &ub, NULL, NULL, " " ); + astInvert( b ); + simp( (AstMapping *) astCmpMap( a, b, 1, " " ) ); + astInvert( b ); + b = quadratic(); + astInvert( b ); + simp( (AstMapping *) astCmpMap( a, b, 1, " " ) ); + } + + /* A ChebyMap and an inverted PolyMap with the same coefficients. */ + head( "simp_cheby_poly_same_coeffs" ); + { + double fc[] = { 1.0, 1, 0, 1.0, 1, 1, 0.5, 1, 2 }; + double x[ 3 ] = { 0.0, 5.0, 10.0 }; + AstMapping *m; + AstPolyMap *pm = astPolyMap( 1, 1, 3, fc, 0, NULL, " " ); + astInvert( pm ); + m = (AstMapping *) astCmpMap( quadratic(), pm, 1, " " ); + equal( "cheby_poly", (AstObject *) quadratic(), (AstObject *) astPolyMap( 1, 1, 3, fc, 0, NULL, " " ) ); + equal( "poly_cheby", (AstObject *) astPolyMap( 1, 1, 3, fc, 0, NULL, " " ), (AstObject *) quadratic() ); + tran( m, 3, 1, x, 1 ); + simp( m ); + cm = quadratic(); + astInvert( cm ); + m = (AstMapping *) astCmpMap( astPolyMap( 1, 1, 3, fc, 0, NULL, " " ), cm, 1, " " ); + simp( m ); + } + + head( "simp_consolidate" ); + { + double fc[] = { 1.0, 1, 0, 2.0, 1, 2, 0.5, 1, 0, 0.0, 1, 1, -1.0, 1, 2, 3.0, 1, 3 }; + double ic[] = { 1.0, 1, 1, 2.0, 1, 1 }; + double lb = -3.0, ub = 5.0, ilb = 0.0, iub = 4.0; + double x[ 3 ] = { -3.0, 1.0, 5.0 }; + AstChebyMap *c = astChebyMap( 1, 1, 6, fc, 2, ic, &lb, &ub, &ilb, &iub, " " ); + tran( (AstMapping *) c, 3, 1, x, 1 ); + simp( (AstMapping *) c ); + astInvert( c ); + simp( (AstMapping *) c ); + } + + head( "simp_parallel_win" ); + { + double ina = 0.0, inb = 1.0, outa = 2.0, outb = 4.0; + AstWinMap *wm = astWinMap( 1, &ina, &inb, &outa, &outb, " " ); + simp( (AstMapping *) astCmpMap( quadratic(), wm, 0, " " ) ); + } + + /* Comparisons. */ + head( "equal" ); + { + double fc[] = { 1.0, 1, 0, 1.0, 1, 1, 0.5, 1, 2 }; + double lb = 0.0, ub = 20.0; + AstChebyMap *a = both_ways(), *b = both_ways(); + AstChebyMap *c; + double ic[] = { 3.0, 1, 1, 0, 1.5, 1, 0, 0, 0.75, 2, 2, 1 }; + double fcb[] = { 1.0, 1, 1, 0, 0.5, 1, 2, 1, -0.25, 2, 0, 3, 2.0, 2, 0, 0 }; + double flb[] = { 0.0, -2.0 }, fub[] = { 10.0, 2.0 }; + double ilb[] = { -1.0, 0.0 }, iub[] = { 3.0, 9.0 }; + equal( "same", (AstObject *) a, (AstObject *) b ); + c = astChebyMap( 2, 2, 4, fcb, 3, ic, flb, fub, ilb, iub, " " ); + equal( "inverse_bounds", (AstObject *) a, (AstObject *) c ); + fub[ 0 ] = 11.0; + iub[ 1 ] = 8.0; + c = astChebyMap( 2, 2, 4, fcb, 3, ic, flb, fub, ilb, iub, " " ); + equal( "forward_bounds", (AstObject *) a, (AstObject *) c ); + astInvert( b ); + equal( "inverted", (AstObject *) a, (AstObject *) b ); + astInvert( a ); + equal( "both_inverted", (AstObject *) a, (AstObject *) b ); + c = astChebyMap( 1, 1, 3, fc, 0, NULL, &lb, &ub, NULL, NULL, " " ); + equal( "bounds_1d", (AstObject *) quadratic(), (AstObject *) c ); + equal( "no_inverse_vs_inverse", (AstObject *) quadratic(), + (AstObject *) astChebyMap( 1, 1, 3, fc, 1, fc, &lb, &ub, &lb, &ub, " " ) ); + } + + /* The comparisons of test_equal.rs. */ + head( "equal_rust" ); + { + double fc[] = { 1.0, 1, 1 }; + double l1 = -1.0, u1 = 1.0, l2 = -2.0, u2 = 2.0; + AstChebyMap *a = astChebyMap( 1, 1, 1, fc, 0, NULL, &l1, &u1, NULL, NULL, " " ); + AstChebyMap *b = astChebyMap( 1, 1, 1, fc, 0, NULL, &l1, &u1, NULL, NULL, " " ); + AstChebyMap *c = astChebyMap( 1, 1, 1, fc, 0, NULL, &l2, &u2, NULL, NULL, " " ); + equal( "chebymap_same", (AstObject *) a, (AstObject *) b ); + equal( "chebymap_different_bounds", (AstObject *) a, (AstObject *) c ); + } + + /* The rates of test_numeric_rate.rs's cubic. */ + head( "rate_cubic" ); + { + double fc[] = { 0.75, 1, 1, 0.25, 1, 3 }; + double lb = -1.0, ub = 1.0; + double at[ 2 ] = { 0.5, 0.0 }; + cm = astChebyMap( 1, 1, 2, fc, 0, NULL, &lb, &ub, NULL, NULL, " " ); + for( int i = 0; i < 2; i++ ) { + printf( "rate %.17g -> %.17g\n", at[ i ], astRate( cm, at + i, 1, 1 ) ); + failed(); + } + } + + /* The constructor's errors. */ + head( "ctor_zero_width_forward" ); + { + double fc[] = { 1.0, 1, 1, 0 }; + double lb[] = { 0.0, 3.0 }, ub[] = { 1.0, 3.0 }; + cm = astChebyMap( 2, 1, 1, fc, 0, NULL, lb, ub, NULL, NULL, " " ); + failed(); + } + head( "ctor_zero_width_inverse" ); + { + double fc[] = { 1.0, 1, 1 }; + double ic[] = { 1.0, 1, 1, 0 }; + double lb = 0.0, ub = 1.0, ilb[] = { 0.0, 2.0 }, iub[] = { 1.0, 2.0 }; + cm = astChebyMap( 1, 2, 1, fc, 1, ic, &lb, &ub, ilb, iub, " " ); + failed(); + } + head( "ctor_zero_width_unused" ); + { + double fc[] = { 1.0, 1, 1 }; + double lb = 0.0, ub = 1.0, ilb = 2.0, iub = 2.0; + cm = astChebyMap( 1, 1, 1, fc, 0, NULL, &lb, &ub, &ilb, &iub, " " ); + if( !failed() ) show( (AstObject *) cm ); + } + head( "ctor_reversed" ); + { + double fc[] = { 1.0, 1, 1 }; + double lb = 10.0, ub = 0.0, x[ 4 ] = { 0.0, 2.5, 10.0, -1.0 }; + cm = astChebyMap( 1, 1, 1, fc, 0, NULL, &lb, &ub, NULL, NULL, " " ); + tran( (AstMapping *) cm, 4, 1, x, 1 ); + domain( cm, 1 ); + show( (AstObject *) cm ); + } + head( "ctor_bad_output" ); + { + double fc[] = { 1.0, 2, 1 }; + double lb = 0.0, ub = 1.0; + cm = astChebyMap( 1, 1, 1, fc, 0, NULL, &lb, &ub, NULL, NULL, " " ); + failed(); + } + head( "ctor_bad_power" ); + { + double fc[] = { 1.0, 1, 1 }; + double ic[] = { 1.0, 1, -1 }; + double lb = 0.0, ub = 1.0; + cm = astChebyMap( 1, 1, 1, fc, 1, ic, &lb, &ub, &lb, &ub, " " ); + failed(); + } + head( "ctor_no_axes" ); + { + cm = astChebyMap( 0, 1, 0, NULL, 0, NULL, NULL, NULL, NULL, NULL, " " ); + if( !failed() ) show( (AstObject *) cm ); + } + + /* The loader. */ + head( "load_standard_polynomial" ); + { + AstObject *o = astFromString( " Begin ChebyMap\n Nin = 1\n IsA Mapping\n" + " MPF1 = 2\n NCF1 = 2\n CF1 = 1\n CF2 = 3\n" + " PF2 = 2\n IsA PolyMap\n End ChebyMap\n" ); + double x[ 3 ] = { -2.0, 0.5, 4.0 }; + if( !failed() ) { + tran( (AstMapping *) o, 3, 1, x, 1 ); + domain( (AstChebyMap *) o, 1 ); + show( o ); + } + } + head( "load_insufficient" ); + { + astFromString( " Begin ChebyMap\n Nin = 1\n IsA Mapping\n" + " MPF1 = 1\n NCF1 = 1\n CF1 = 1\n PF1 = 1\n" + " IsA PolyMap\n FSCL1 = 2\n End ChebyMap\n" ); + failed(); + } + head( "load_insufficient_inverse" ); + { + astFromString( " Begin ChebyMap\n Nin = 2\n IsA Mapping\n" + " MPI1 = 1\n MPI2 = 0\n NCI1 = 1\n NCI2 = 0\n CI1 = 1\n PI1 = 1\n" + " IsA PolyMap\n ISCL1 = 2\n ISCL2 = 2\n IOFF1 = 0\n End ChebyMap\n" ); + failed(); + } + head( "load_unused_scales" ); + { + AstObject *o = astFromString( " Begin ChebyMap\n Nin = 1\n IsA Mapping\n" + " MPF1 = 1\n NCF1 = 1\n CF1 = 1\n PF1 = 1\n" + " IsA PolyMap\n FSCL1 = 0.5\n FOFF1 = -1\n" + " ISCL1 = 2\n IOFF1 = 0\n End ChebyMap\n" ); + if( !failed() ) show( o ); + } + + /* astPolyTran with the ChebyMap's own box, and without one. */ + head( "polytran_own_box" ); + { + double x[ 3 ] = { 0.0, 4.0, 10.0 }; + double y[ 3 ]; + double fc[] = { 1.0, 1, 0, 2.0, 1, 1, 0.1, 1, 2 }; + double lb = 0.0, ub = 10.0; + AstChebyMap *fit; + cm = astChebyMap( 1, 1, 3, fc, 0, NULL, &lb, &ub, NULL, NULL, " " ); + fit = (AstChebyMap *) astPolyTran( cm, 0, 1.0e-3, 1.0e-2, 8, NULL, NULL ); + if( !failed() && !fit ) printf( "-- no fit\n" ); + if( fit ) { + printf( "-- class %s\n", astGetC( fit, "Class" ) ); + tran( (AstMapping *) fit, 3, 1, x, 1 ); + astTran1( fit, 3, x, 1, y ); + tran( (AstMapping *) fit, 3, 1, y, 0 ); + domain( fit, 0 ); + coeffs( (AstPolyMap *) fit, 0 ); + } + } + head( "polytran_forward_own_box" ); + { + double fc[] = { 2.0, 1, 1, 0.5, 1, 0 }; + double ic[] = { 0.5, 1, 1, 0.1, 1, 2 }; + double lb = 0.0, ub = 4.0, ilb = -1.0, iub = 3.0; + double y[ 3 ] = { -1.0, 1.0, 3.0 }; + AstChebyMap *fit; + cm = astChebyMap( 1, 1, 2, fc, 2, ic, &lb, &ub, &ilb, &iub, " " ); + fit = (AstChebyMap *) astPolyTran( cm, 1, 1.0e-3, 1.0e-2, 8, NULL, NULL ); + if( !failed() && !fit ) printf( "-- no fit\n" ); + if( fit ) { + tran( (AstMapping *) fit, 3, 1, y, 0 ); + domain( fit, 1 ); + domain( fit, 0 ); + } + } + head( "polytran_no_box" ); + { + cm = quadratic(); + astPolyTran( cm, 1, 1.0e-6, 1.0e-4, 6, NULL, NULL ); + failed(); + astInvert( cm ); + astPolyTran( cm, 0, 1.0e-6, 1.0e-4, 6, NULL, NULL ); + failed(); + } + + /* astChebyDomain of ChebyMaps with different numbers of inputs and + outputs, not inverted (inverted, C reads beyond the boxes; see + docs/c-library-bugs.md). */ + head( "domain_unequal" ); + { + double fc[] = { 1.0, 1, 1, 2.0, 2, 1 }; + double ic[] = { 1.0, 1, 1, 0 }; + double flb[] = { 0.0 }, fub[] = { 10.0 }, ilb[] = { -1.0, -2.0 }, iub[] = { 1.0, 2.0 }; + double fc2[] = { 1.0, 1, 1, 0, 1.0, 1, 0, 1 }; + double lb2[] = { 0.0, 0.0 }, ub2[] = { 1.0, 1.0 }; + cm = astChebyMap( 1, 2, 2, fc, 1, ic, flb, fub, ilb, iub, " " ); + domain( cm, 1 ); + domain( cm, 0 ); + cm = astChebyMap( 1, 2, 2, fc, 0, NULL, flb, fub, NULL, NULL, " " ); + domain( cm, 1 ); + domain( cm, 0 ); + cm = astChebyMap( 2, 1, 2, fc2, 0, NULL, lb2, ub2, NULL, NULL, " " ); + domain( cm, 1 ); + domain( cm, 0 ); + } +} + +int main( void ) { + setvbuf( stdout, NULL, _IONBF, 0 ); + astBegin; + testchebymap_cases(); + focus_cases(); + astEnd; + return 0; +} diff --git a/src/test/resources/probes/chebymap_probe.json b/src/test/resources/probes/chebymap_probe.json new file mode 100644 index 0000000..492b873 --- /dev/null +++ b/src/test/resources/probes/chebymap_probe.json @@ -0,0 +1,4 @@ +{ + "source": "probes/chebymap_probe.c", + "output": "== t_eval_1\nfwd -1 -> 1.5\nfwd -0.5 -> 1.5\nfwd 0 -> 1.5\nfwd 0.5 -> 1.5\nfwd 1 -> 1.5\n== t_eval_2\nfwd -1 -> 0.5\nfwd -0.5 -> 2\nfwd 0 -> 2.5\nfwd 0.5 -> 2\nfwd 1 -> 0.5\n== t_eval_3\nfwd -1 -> -1.5\nfwd -0.5 -> 4\nfwd 0 -> 2.5\nfwd 0.5 -> 0\nfwd 1 -> 2.5\n== t_eval_4\nfwd -1 -> -0.19999999999999996\nfwd -0.5 -> 3.3500000000000001\nfwd 0 -> 3.7999999999999998\nfwd 0.5 -> -0.65000000000000002\nfwd 1 -> 3.7999999999999998\nIterInverse 0 set 0 TranForward 1 TranInverse 0\n== t_polytran_1d\n-- class ChebyMap\nfwd -1 -> 3\nfwd -0.5 -> 2\nfwd 0 -> 1\nfwd 0.5 -> 0\nfwd 1 -> -1\ninv 3 -> -1.0000000000000004\ninv 2 -> -0.50000000000000022\ninv 1 -> 0\ninv 0 -> 0.50000000000000022\ninv -1 -> 1.0000000000000004\ndomain 0 -1 : 3\ndomain 1 -1 : 1\ncoeffs 0 n 1\ncof -1.0000000000000004 1 1\nIterInverse 0 set 0 TranForward 1 TranInverse 1\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 1 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 2 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = -2 \t# Coeff 2 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n MPI1 = 1 \t# Max. power of output 1 in any inverse polynomial\n NCI1 = 1 \t# No. of coeff.s for inverse polynomial 1\n CI1 = -1.0000000000000004 \t# Coeff 1 of inverse polynomial 1\n PI1 = 1 \t# Power of o/p 1 for coeff 1 of inv poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 1 \t# Scale factor on input 1\n FOFF1 = 0 \t# Offset on input 1\n ISCL1 = 0.5 \t# Scale factor on output 1\n IOFF1 = -0.5 \t# Offset on output 1\n End ChebyMap\n== t_polytran_wide\nfwd 0 -> 3.7999999999999998\nfwd 10 -> 3.0850399999999998\nfwd 20 -> 2.1846399999999999\nfwd 30 -> 1.1842400000000004\nfwd 40 -> 0.19423999999999975\ninv 3.7999999999999998 -> -0.0075981256996209279\ninv 3.0850399999999998 -> 9.9973475613528713\ninv 2.1846399999999999 -> 20.004157355882469\ninv 1.1842400000000004 -> 29.995130038254715\ninv 0.19423999999999975 -> 40.005253600361996\ndomain 0 -0.65000000000000002 : 4.0680650000000007\ncoeffs 0 n 8\ncof 23.814978696967241 1 0\ncof -26.230209692867916 1 1\ncof -1.1288905288276232 1 2\ncof -1.1011969819219984 1 3\ncof -0.15204435455042389 1 4\ncof -0.14131207735235335 1 5\ncof -0.030103890571179605 1 6\ncof -0.024955396132600539 1 7\nequal copy 1\nequal read 1\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 4 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 4 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1.5 \t# Coeff 1 of forward polynomial 1\n CF2 = -1 \t# Coeff 2 of forward polynomial 1\n CF3 = 2 \t# Coeff 3 of forward polynomial 1\n CF4 = 1.3 \t# Coeff 4 of forward polynomial 1\n PF2 = 2 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 3 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n PF4 = 4 \t# Power of i/p 1 for coeff 4 of fwd poly 1\n MPI1 = 7 \t# Max. power of output 1 in any inverse polynomial\n NCI1 = 8 \t# No. of coeff.s for inverse polynomial 1\n CI1 = 23.814978696967241 \t# Coeff 1 of inverse polynomial 1\n CI2 = -26.230209692867916 \t# Coeff 2 of inverse polynomial 1\n CI3 = -1.1288905288276232 \t# Coeff 3 of inverse polynomial 1\n CI4 = -1.1011969819219984 \t# Coeff 4 of inverse polynomial 1\n CI5 = -0.15204435455042389 \t# Coeff 5 of inverse polynomial 1\n CI6 = -0.14131207735235335 \t# Coeff 6 of inverse polynomial 1\n CI7 = -0.030103890571179605 \t# Coeff 7 of inverse polynomial 1\n CI8 = -0.024955396132600539 \t# Coeff 8 of inverse polynomial 1\n PI2 = 1 \t# Power of o/p 1 for coeff 2 of inv poly 1\n PI3 = 2 \t# Power of o/p 1 for coeff 3 of inv poly 1\n PI4 = 3 \t# Power of o/p 1 for coeff 4 of inv poly 1\n PI5 = 4 \t# Power of o/p 1 for coeff 5 of inv poly 1\n PI6 = 5 \t# Power of o/p 1 for coeff 6 of inv poly 1\n PI7 = 6 \t# Power of o/p 1 for coeff 7 of inv poly 1\n PI8 = 7 \t# Power of o/p 1 for coeff 8 of inv poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.01 \t# Scale factor on input 1\n FOFF1 = 0 \t# Offset on input 1\n ISCL1 = 0.42390259566156885 \t# Scale factor on output 1\n IOFF1 = -0.72446331281998022 \t# Offset on output 1\n End ChebyMap\n== t_2d_unit\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\nfwd 0.5 0 -> 0.5 0.5\nfwd 0 0.5 -> 0.5 -0.5\nfwd -0.5 0 -> -0.5 -0.5\nfwd 0 -0.5 -> -0.5 0.5\ninv 0.5 0.5 -> 0.5 -1.9428902930940239e-16\ninv 0.5 -0.5 -> 0 0.50000000000000011\ninv -0.5 -0.5 -> -0.5 1.9428902930940239e-16\ninv -0.5 0.5 -> 0 -0.50000000000000011\ncoeffs 0 n 4\ncof 1 1 1 0\ncof 1 1 0 1\ncof 0.99999999999999989 2 1 0\ncof -1.0000000000000007 2 0 1\ndomain 0 -2 -2 : 2 2\n== t_2d_nonunit\nfwd 0 2 -> -0.16000000000000003 0.79999999999999993\nfwd 2 5 -> -0.1999999999999999 0\nfwd 6 8 -> 1.712 1.6399999999999999\nfwd 10 0 -> -2 -1\nfwd 4 6 -> 0.83200000000000018 1.04\nfwd 4.5 5.5 -> 0.90400000000000014 1.2550000000000001\nfwd 5 5 -> 1 1.5000000000000002\nfwd 5.5 4.5 -> 1.0960000000000003 1.7450000000000001\ninv 0.83200000000000018 1.04 -> 4.0005814314033143 6.0000000000000036\ninv 0.90400000000000014 1.2550000000000001 -> 4.4997368998464662 5.5000000000000018\ninv 1 1.5000000000000002 -> 4.9999999999999929 4.9999999999999991\ninv 1.0960000000000003 1.7450000000000001 -> 5.5002631001535187 4.5000000000000009\ncoeffs 1 n 5\ncof 1 1 0 0\ncof -2 1 1 2\ncof 1 1 0 1\ncof 1.5 2 0 0\ncof -2.5 2 1 2\ncoeffs 0 n 9\ncof 4.9999999999999929 1 0 0\ncof -0.49350547962218333 1 1 0\ncof 1.6087143065711373 1 0 1\ncof 0.35096188953506652 1 2 1\ncof -0.49350547962220132 1 1 2\ncof 0.086743961923991697 1 0 3\ncof 5 2 0 0\ncof 2.8400000000000025 2 1 0\ncof -1.9967346938775543 2 0 1\ndomain 1 0 0 : 10 10\ndomain 0 -2 -1 : 4 4\ndomain 1 0 0 : 10 10\ndomain 0 0.43200000000000005 1.0008163265306123 : 1.5679999999999998 1.9991836734693882\n== t_inverted_domain\ndomain 1 0 -1.0000000000000002 : 1 2\ndomain 0 -1 -1.25 : 1 1.25\ndomain 1 -1 -1.25 : 1 1.25\ndomain 0 0 -1.0000000000000002 : 1 2\n== t_rate\nrate 0.5 -> 3\nrate 0 -> 3\nrate 1 -> 3\n== t_linear_1d\n-- simplified WinMap same 0\n Begin WinMap \t# Map one window on to another\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = -2 \t# Shift for axis 1\n Scl1 = 0.40000000000000002 \t# Scale factor for axis 1\n End WinMap\nfwd 0 -> -2\nfwd 1 -> -1.6000000000000001\nfwd 10 -> 2\nfwd 0 -> -2\nfwd 1 -> -1.6000000000000001\nfwd 10 -> 2\ninv -2 -> 0\ninv -1.6000000000000001 -> 0.99999999999999978\ninv 2 -> 10\n== t_linear_2d\n-- simplified WinMap same 0\n Begin WinMap \t# Map one window on to another\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = -2.5 \t# Shift for axis 1\n Scl1 = 0.60000000000000009 \t# Scale factor for axis 1\n Sft2 = 2 \t# Shift for axis 2\n Scl2 = -0.20000000000000001 \t# Scale factor for axis 2\n End WinMap\nfwd 0 -5 -> -2.5 3\nfwd 10 5 -> 3.5 1\nfwd 3 1 -> -0.69999999999999996 1.8\nfwd 7.5 -2 -> 2.0000000000000004 2.3999999999999999\nfwd 0 -5 -> -2.5 3\nfwd 10 5 -> 3.5000000000000009 1\nfwd 3 1 -> -0.69999999999999973 1.8\nfwd 7.5 -2 -> 2.0000000000000009 2.3999999999999999\ninv -2.5 3 -> -2.2204460492503131e-16 -5\ninv 3.5 1 -> 9.9999999999999982 5\ninv -0.69999999999999996 1.8 -> 2.9999999999999996 0.99999999999999978\ninv 2.0000000000000004 2.3999999999999999 -> 7.5 -1.9999999999999996\n== isa\nIsAPolyMap 1 IsAChebyMap 1 IsAMapping 1 Class ChebyMap\nPolyMap IsAChebyMap 0\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n== outside_box\nfwd 5 0.5 -> -0.12499999999999994 2.171875\nfwd 0 -2 -> -1.5 2.25\nfwd 10 2 -> 1.5 1.75\nfwd -4.9406564584124654e-324 0 -> -1 2\nfwd 10.000000000000002 0 -> -1.7976931348623157e+308 2\nfwd -1 0 -> -1.7976931348623157e+308 2\nfwd 11 0 -> -1.7976931348623157e+308 2\nfwd 5 2.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 5 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 2.25\nfwd nan 1 -> -1.7976931348623157e+308 2.25\nfwd 1.0000000000000001e+300 0 -> -1.7976931348623157e+308 2\ninv 1 4 -> 1.5 0\ninv -1 0 -> -1.5 -0.75\ninv 3 8 -> 4.5 0.75\ninv -1.5 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.5 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 -0.5 -> 1.5 -1.7976931348623157e+308\ninv 1 -1.7976931348623157e+308 -> 1.5 -1.7976931348623157e+308\ninv -1.7976931348623157e+308 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv nan 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0000000000000004 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 4 -> 1.5 0\nfwd -1 0 -> -1.5 -0.75\nfwd 3 8 -> 4.5 0.75\nfwd -1.5 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 3.5 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -0.5 -> 1.5 -1.7976931348623157e+308\nfwd 1 -1.7976931348623157e+308 -> 1.5 -1.7976931348623157e+308\nfwd -1.7976931348623157e+308 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd nan 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 3.0000000000000004 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 5 0.5 -> -0.12499999999999994 2.171875\ninv 0 -2 -> -1.5 2.25\ninv 10 2 -> 1.5 1.75\ninv -4.9406564584124654e-324 0 -> -1 2\ninv 10.000000000000002 0 -> -1.7976931348623157e+308 2\ninv -1 0 -> -1.7976931348623157e+308 2\ninv 11 0 -> -1.7976931348623157e+308 2\ninv 5 2.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 5 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 2.25\ninv nan 1 -> -1.7976931348623157e+308 2.25\ninv 1.0000000000000001e+300 0 -> -1.7976931348623157e+308 2\n== no_inverse\nIterInverse 0 set 0 TranForward 1 TranInverse 0\n!! AST: Error in routine tran at line 69 in file src/test/resources/probes/chebymap_probe.c.\n! astTranN(ChebyMap): An inverse coordinate transformation is not defined by the ChebyMap supplied.\nstatus 233933698\nIterInverse 0 set 1 TranForward 1 TranInverse 0\n-- attribute 0\n!! AST: Error in routine tran at line 69 in file src/test/resources/probes/chebymap_probe.c.\n! astTranN(ChebyMap): An inverse coordinate transformation is not defined by the ChebyMap supplied.\nstatus 233933698\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IterInv = 1 \t# Use an iterative inverse\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\nIterInverse 0 set 1 TranForward 1 TranInverse 0\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IterInv = 0 \t# Do not use an iterative inverse\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\nIterInverse 0 set 0 TranForward 1 TranInverse 0\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n NiterInv = 7 \t# Max number of iterations for iterative inverse\n TolInv = 1.0000000000000001e-09 \t# Target relative error for iterative inverse\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n== no_inverse_polymap\nIterInverse 1 set 0 TranForward 1 TranInverse 1\ninv 1 -> 0\ninv 2 -> 0.73205080756887742\n== iterinverse_unequal\nIterInverse 0 set 0 TranForward 1 TranInverse 0\n!! AST: Error in routine focus_cases at line 388 in file src/test/resources/probes/chebymap_probe.c.\n! astSetIterInverse(ChebyMap):Cannot use an iterative inverse because the ChebyMap has unequal numbers of inputs and outputs.\nstatus 233933170\nIterInverse 0 set 0 TranForward 1 TranInverse 0\n== domain_both\ndomain 1 0 -2 : 10 2\ndomain 0 -1 0 : 3 8\ndomain 1 -1 0 : 3 8\ndomain 0 0 -2 : 10 2\n== domain_no_inverse\ndomain 1 0 : 10\ndomain 0 0.24999999999999994 : 2.5\ndomain 1 0.24999999999999994 : 2.5\ndomain 0 0 : 10\n== domain_no_forward\nIterInverse 0 set 0 TranForward 0 TranInverse 1\ndomain 1 -1 : 3\ndomain 0 -4 : 4\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MPI1 = 1 \t# Max. power of output 1 in any inverse polynomial\n NCI1 = 2 \t# No. of coeff.s for inverse polynomial 1\n CI1 = 2 \t# Coeff 1 of inverse polynomial 1\n CI2 = 1 \t# Coeff 2 of inverse polynomial 1\n PI1 = 1 \t# Power of o/p 1 for coeff 1 of inv poly 1\n IsA PolyMap \t# Polynomial transformation\n ISCL1 = 0.25 \t# Scale factor on output 1\n IOFF1 = 0 \t# Offset on output 1\n End ChebyMap\n== domain_neither\nIterInverse 0 set 0 TranForward 0 TranInverse 0\ndomain 1 -1.7976931348623157e+308 -1.7976931348623157e+308 : -1.7976931348623157e+308 -1.7976931348623157e+308\ndomain 0 -1.7976931348623157e+308 -1.7976931348623157e+308 : -1.7976931348623157e+308 -1.7976931348623157e+308\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n End ChebyMap\n== domain_bad_coefficient\nfwd 0 -> -1.7976931348623157e+308\nfwd 0.5 -> -1.7976931348623157e+308\ndomain 1 0 : 1\n! AST: Error in routine domain at line 93 in file src/test/resources/probes/chebymap_probe.c.\n! astInitMatrixMap(MatrixMap): Supplied matrix contains only bad values.\nstatus 233933490\n== domain_infinite_width\nfwd -1e+308 -> 1\nfwd 0 -> 1\nfwd 5 -> 1\ndomain 1 -1.7976931348623157e+308 : -1.7976931348623157e+308\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 1 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 2 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 2 \t# Coeff 2 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0 \t# Scale factor on input 1\n FOFF1 = 0 \t# Offset on input 1\n End ChebyMap\n== simp_alone\n-- simplified ChebyMap same 1\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n== simp_poly_win\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Inv = 0 \t# Inverse transformation not defined\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin CmpMap \t# Compound Mapping\n Nin = 1 \t# Number of input coordinates\n Inv = 0 \t# Inverse transformation not defined\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 2 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n End CmpMap\n MapB = \t# Second component Mapping\n Begin PolyMap \t# Polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 3 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 2 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 0.10000000000000001 \t# Coeff 2 of forward polynomial 1\n PF1 = 1 \t# Power of i/p 1 for coeff 1 of fwd poly 1\n PF2 = 3 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n End PolyMap\n End CmpMap\nfwd 0 -> 0.26175760000000003\nfwd 0.5 -> 0.26175760000000009\nfwd 1 -> 0.34393040000000002\n== simp_linear_win\n-- simplified WinMap same 0\n Begin WinMap \t# Map one window on to another\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = -3 \t# Shift for axis 1\n Scl1 = 8 \t# Scale factor for axis 1\n End WinMap\nfwd 0 -> -3\nfwd 0.25 -> -1\nfwd 1 -> 5\nfwd 2 -> -1.7976931348623157e+308\n== simp_cancel\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 4 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Series = 0 \t# Component Mappings applied in parallel\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n MPF2 = 3 \t# Max. power of input 2 in any forward polynomial\n NCF1 = 2 \t# No. of coeff.s for forward polynomial 1\n NCF2 = 2 \t# No. of coeff.s for forward polynomial 2\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 0.5 \t# Coeff 2 of forward polynomial 1\n CF3 = -0.25 \t# Coeff 1 of forward polynomial 2\n CF4 = 2 \t# Coeff 2 of forward polynomial 2\n PF1 = 1 \t# Power of i/p 1 for coeff 1 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF4 = 1 \t# Power of i/p 2 for coeff 2 of fwd poly 1\n PF6 = 3 \t# Power of i/p 2 for coeff 1 of fwd poly 2\n MPI1 = 2 \t# Max. power of output 1 in any inverse polynomial\n MPI2 = 1 \t# Max. power of output 2 in any inverse polynomial\n NCI1 = 2 \t# No. of coeff.s for inverse polynomial 1\n NCI2 = 1 \t# No. of coeff.s for inverse polynomial 2\n CI1 = 3 \t# Coeff 1 of inverse polynomial 1\n CI2 = 1.5 \t# Coeff 2 of inverse polynomial 1\n CI3 = 0.75 \t# Coeff 1 of inverse polynomial 2\n PI1 = 1 \t# Power of o/p 1 for coeff 1 of inv poly 1\n PI5 = 2 \t# Power of o/p 1 for coeff 1 of inv poly 2\n PI6 = 1 \t# Power of o/p 2 for coeff 1 of inv poly 2\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FSCL2 = 0.5 \t# Scale factor on input 2\n FOFF1 = -1 \t# Offset on input 1\n FOFF2 = 0 \t# Offset on input 2\n ISCL1 = 0.5 \t# Scale factor on output 1\n ISCL2 = 0.25 \t# Scale factor on output 2\n IOFF1 = -0.5 \t# Offset on output 1\n IOFF2 = -1 \t# Offset on output 2\n End ChebyMap\n MapB = \t# Second component Mapping\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n MPF2 = 3 \t# Max. power of input 2 in any forward polynomial\n NCF1 = 2 \t# No. of coeff.s for forward polynomial 1\n NCF2 = 2 \t# No. of coeff.s for forward polynomial 2\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 0.5 \t# Coeff 2 of forward polynomial 1\n CF3 = -0.25 \t# Coeff 1 of forward polynomial 2\n CF4 = 2 \t# Coeff 2 of forward polynomial 2\n PF1 = 1 \t# Power of i/p 1 for coeff 1 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF4 = 1 \t# Power of i/p 2 for coeff 2 of fwd poly 1\n PF6 = 3 \t# Power of i/p 2 for coeff 1 of fwd poly 2\n MPI1 = 2 \t# Max. power of output 1 in any inverse polynomial\n MPI2 = 1 \t# Max. power of output 2 in any inverse polynomial\n NCI1 = 2 \t# No. of coeff.s for inverse polynomial 1\n NCI2 = 1 \t# No. of coeff.s for inverse polynomial 2\n CI1 = 3 \t# Coeff 1 of inverse polynomial 1\n CI2 = 1.5 \t# Coeff 2 of inverse polynomial 1\n CI3 = 0.75 \t# Coeff 1 of inverse polynomial 2\n PI1 = 1 \t# Power of o/p 1 for coeff 1 of inv poly 1\n PI5 = 2 \t# Power of o/p 1 for coeff 1 of inv poly 2\n PI6 = 1 \t# Power of o/p 2 for coeff 1 of inv poly 2\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FSCL2 = 0.5 \t# Scale factor on input 2\n FOFF1 = -1 \t# Offset on input 1\n FOFF2 = 0 \t# Offset on input 2\n ISCL1 = 0.5 \t# Scale factor on output 1\n ISCL2 = 0.25 \t# Scale factor on output 2\n IOFF1 = -0.5 \t# Offset on output 1\n IOFF2 = -1 \t# Offset on output 2\n End ChebyMap\n End CmpMap\n== simp_no_cancel_bounds\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Fwd = 0 \t# Forward transformation not defined\n Inv = 0 \t# Inverse transformation not defined\n IsA Mapping \t# Mapping between coordinate systems\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n MapB = \t# Second component Mapping\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.10000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n End CmpMap\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_cheby_poly_same_coeffs\nequal cheby_poly 1\nequal poly_cheby 1\nfwd 0 -> -0.96875\nfwd 5 -> -0.96875\nfwd 10 -> 1.000000000000002\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_consolidate\nfwd -3 -> -0.5\nfwd 1 -> 0.5\nfwd 5 -> 5.5\n-- simplified ChebyMap same 0\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 3 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1.5 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 3 \t# Coeff 3 of forward polynomial 1\n PF2 = 2 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 3 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n MPI1 = 1 \t# Max. power of output 1 in any inverse polynomial\n NCI1 = 1 \t# No. of coeff.s for inverse polynomial 1\n CI1 = 3 \t# Coeff 1 of inverse polynomial 1\n PI1 = 1 \t# Power of o/p 1 for coeff 1 of inv poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.25 \t# Scale factor on input 1\n FOFF1 = -0.25 \t# Offset on input 1\n ISCL1 = 0.5 \t# Scale factor on output 1\n IOFF1 = -1 \t# Offset on output 1\n End ChebyMap\n-- simplified ChebyMap same 0\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 3 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1.5 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 3 \t# Coeff 3 of forward polynomial 1\n PF2 = 2 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 3 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n MPI1 = 1 \t# Max. power of output 1 in any inverse polynomial\n NCI1 = 1 \t# No. of coeff.s for inverse polynomial 1\n CI1 = 3 \t# Coeff 1 of inverse polynomial 1\n PI1 = 1 \t# Power of o/p 1 for coeff 1 of inv poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.25 \t# Scale factor on input 1\n FOFF1 = -0.25 \t# Offset on input 1\n ISCL1 = 0.5 \t# Scale factor on output 1\n IOFF1 = -1 \t# Offset on output 1\n End ChebyMap\n== simp_parallel_win\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Inv = 0 \t# Inverse transformation not defined\n IsA Mapping \t# Mapping between coordinate systems\n Series = 0 \t# Component Mappings applied in parallel\n MapA = \t# First component Mapping\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n MapB = \t# Second component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 2 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n End WinMap\n End CmpMap\n== equal\nequal same 1\nequal inverse_bounds 0\nequal forward_bounds 0\nequal inverted 0\nequal both_inverted 1\nequal bounds_1d 0\nequal no_inverse_vs_inverse 0\n== equal_rust\nequal chebymap_same 1\nequal chebymap_different_bounds 0\n== rate_cubic\nrate 0.5 -> 0.75\nrate 0 -> 0\n== ctor_zero_width_forward\n!! AST: Error in routine focus_cases at line 602 in file src/test/resources/probes/chebymap_probe.c.\n! astInitChebyMap(ChebyMap): Input bounding box has zero width on input axis 2.\nstatus 233933194\n== ctor_zero_width_inverse\n!! AST: Error in routine focus_cases at line 610 in file src/test/resources/probes/chebymap_probe.c.\n! astInitChebyMap(ChebyMap): Output bounding box has zero width on output axis 2.\nstatus 233933194\n== ctor_zero_width_unused\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 1 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 1 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n PF1 = 1 \t# Power of i/p 1 for coeff 1 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 2 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n== ctor_reversed\nfwd 0 -> 1\nfwd 2.5 -> 0.5\nfwd 10 -> -1\nfwd -1 -> -1.7976931348623157e+308\ndomain 1 10 : -0\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 1 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 1 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n PF1 = 1 \t# Power of i/p 1 for coeff 1 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = -0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = 1 \t# Offset on input 1\n End ChebyMap\n== ctor_bad_output\n!! AST: Error in routine focus_cases at line 633 in file src/test/resources/probes/chebymap_probe.c.\n! astInitPolyMap(ChebyMap): Forward coefficient 1 referred to an illegal output coordinate 2.\n! This number should be in the range 1 to 1.\nstatus 233933770\n== ctor_bad_power\n!! AST: Error in routine focus_cases at line 641 in file src/test/resources/probes/chebymap_probe.c.\n! astInitPolyMap(ChebyMap): Inverse coefficient 1 has a negative power (-1) for output coordinate 1.\n! All powers should be zero or positive.\nstatus 233933226\n== ctor_no_axes\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nout = 1 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n End ChebyMap\n== load_standard_polynomial\nfwd -2 -> 13\nfwd 0.5 -> 1.75\nfwd 4 -> 49\ndomain 1 -1.7976931348623157e+308 : -1.7976931348623157e+308\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 2 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 3 \t# Coeff 2 of forward polynomial 1\n PF2 = 2 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n End ChebyMap\n== load_insufficient\n!! AST: Error in routine focus_cases at line 667 in file src/test/resources/probes/chebymap_probe.c.\n! astLoadChebyMap: insufficient scale and offset values for the forward transformation in loaded ChebyMap.\n! Error while reading a ChebyMap from a Channel.\nstatus 233933594\n== load_insufficient_inverse\n!! AST: Error in routine focus_cases at line 674 in file src/test/resources/probes/chebymap_probe.c.\n! astLoadChebyMap: insufficient scale and offset values for the inverse transformation in loaded ChebyMap.\n! Error while reading a ChebyMap from a Channel.\nstatus 233933594\n== load_unused_scales\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 1 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 1 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n PF1 = 1 \t# Power of i/p 1 for coeff 1 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.5 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n== polytran_own_box\n-- class ChebyMap\nfwd 0 -> -0.90000000000000002\nfwd 4 -> 0.50800000000000012\nfwd 10 -> 3.1000000000000001\ninv -0.90000000000000002 -> 0.00029275439351055454\ninv 0.50800000000000012 -> 4.0004107319250224\ninv 3.1000000000000001 -> 9.9998243576116508\ndomain 0 -0.89999999999999991 : 3.1000000000000001\ncoeffs 0 n 5\ncof 5.2506428244361656 1 0\ncof 4.9750358930191645 1 1\ncof -0.24747092519706251 1 2\ncof 0.02472990858990471 1 3\ncof -0.0031133432365233215 1 4\n== polytran_forward_own_box\ninv -1 -> -0.40000000000000002\ninv 1 -> -0.10000000000000001\ninv 3 -> 0.59999999999999998\ndomain 1 -0.40000000000000002 : 0.59999999999999998\ndomain 0 -1 : 3\n== polytran_no_box\n!! AST: Error in routine focus_cases at line 725 in file src/test/resources/probes/chebymap_probe.c.\n! astPolyTran(ChebyMap): The inverse transformation is not a Chebyshev polynomial and therefore requires a user-supplied bounding box. But no lower bounds were supplied.\nstatus 233934426\n!! AST: Error in routine focus_cases at line 728 in file src/test/resources/probes/chebymap_probe.c.\n! astPolyTran(ChebyMap): The inverse transformation is not a Chebyshev polynomial and therefore requires a user-supplied bounding box. But no lower bounds were supplied.\nstatus 233934426\n== domain_unequal\ndomain 1 0 : 10\ndomain 0 -1 -2 : 1 2\ndomain 1 0 : 10\ndomain 0 -1 -2 : 1 2\ndomain 1 0 0 : 1 1\ndomain 0 -2 : 2\n" +} diff --git a/src/test/resources/probes/chebymap_probe_nocontract.json b/src/test/resources/probes/chebymap_probe_nocontract.json new file mode 100644 index 0000000..b87382e --- /dev/null +++ b/src/test/resources/probes/chebymap_probe_nocontract.json @@ -0,0 +1,4 @@ +{ + "source": "probes/chebymap_probe.c", + "output": "== t_eval_1\nfwd -1 -> 1.5\nfwd -0.5 -> 1.5\nfwd 0 -> 1.5\nfwd 0.5 -> 1.5\nfwd 1 -> 1.5\n== t_eval_2\nfwd -1 -> 0.5\nfwd -0.5 -> 2\nfwd 0 -> 2.5\nfwd 0.5 -> 2\nfwd 1 -> 0.5\n== t_eval_3\nfwd -1 -> -1.5\nfwd -0.5 -> 4\nfwd 0 -> 2.5\nfwd 0.5 -> 0\nfwd 1 -> 2.5\n== t_eval_4\nfwd -1 -> -0.19999999999999996\nfwd -0.5 -> 3.3500000000000001\nfwd 0 -> 3.7999999999999998\nfwd 0.5 -> -0.65000000000000002\nfwd 1 -> 3.7999999999999998\nIterInverse 0 set 0 TranForward 1 TranInverse 0\n== t_polytran_1d\n-- class ChebyMap\nfwd -1 -> 3\nfwd -0.5 -> 2\nfwd 0 -> 1\nfwd 0.5 -> 0\nfwd 1 -> -1\ninv 3 -> -1.0000000000000004\ninv 2 -> -0.50000000000000022\ninv 1 -> 0\ninv 0 -> 0.50000000000000022\ninv -1 -> 1.0000000000000004\ndomain 0 -1 : 3\ndomain 1 -1 : 1\ncoeffs 0 n 1\ncof -1.0000000000000004 1 1\nIterInverse 0 set 0 TranForward 1 TranInverse 1\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 1 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 2 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = -2 \t# Coeff 2 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n MPI1 = 1 \t# Max. power of output 1 in any inverse polynomial\n NCI1 = 1 \t# No. of coeff.s for inverse polynomial 1\n CI1 = -1.0000000000000004 \t# Coeff 1 of inverse polynomial 1\n PI1 = 1 \t# Power of o/p 1 for coeff 1 of inv poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 1 \t# Scale factor on input 1\n FOFF1 = 0 \t# Offset on input 1\n ISCL1 = 0.5 \t# Scale factor on output 1\n IOFF1 = -0.5 \t# Offset on output 1\n End ChebyMap\n== t_polytran_wide\nfwd 0 -> 3.7999999999999998\nfwd 10 -> 3.0850399999999998\nfwd 20 -> 2.1846399999999999\nfwd 30 -> 1.1842400000000004\nfwd 40 -> 0.19423999999999975\ninv 3.7999999999999998 -> -0.0075981256996200848\ninv 3.0850399999999998 -> 9.9973475613528979\ninv 2.1846399999999999 -> 20.004157355882469\ninv 1.1842400000000004 -> 29.995130038254729\ninv 0.19423999999999975 -> 40.005253600361975\ndomain 0 -0.65000000000000002 : 4.0680650000000007\ncoeffs 0 n 8\ncof 23.814978696967255 1 0\ncof -26.23020969286793 1 1\ncof -1.1288905288276112 1 2\ncof -1.1011969819220182 1 3\ncof -0.15204435455042245 1 4\ncof -0.14131207735235876 1 5\ncof -0.030103890571181447 1 6\ncof -0.02495539613259163 1 7\nequal copy 1\nequal read 1\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 4 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 4 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1.5 \t# Coeff 1 of forward polynomial 1\n CF2 = -1 \t# Coeff 2 of forward polynomial 1\n CF3 = 2 \t# Coeff 3 of forward polynomial 1\n CF4 = 1.3 \t# Coeff 4 of forward polynomial 1\n PF2 = 2 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 3 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n PF4 = 4 \t# Power of i/p 1 for coeff 4 of fwd poly 1\n MPI1 = 7 \t# Max. power of output 1 in any inverse polynomial\n NCI1 = 8 \t# No. of coeff.s for inverse polynomial 1\n CI1 = 23.814978696967255 \t# Coeff 1 of inverse polynomial 1\n CI2 = -26.23020969286793 \t# Coeff 2 of inverse polynomial 1\n CI3 = -1.1288905288276112 \t# Coeff 3 of inverse polynomial 1\n CI4 = -1.1011969819220182 \t# Coeff 4 of inverse polynomial 1\n CI5 = -0.15204435455042245 \t# Coeff 5 of inverse polynomial 1\n CI6 = -0.14131207735235876 \t# Coeff 6 of inverse polynomial 1\n CI7 = -0.030103890571181447 \t# Coeff 7 of inverse polynomial 1\n CI8 = -0.02495539613259163 \t# Coeff 8 of inverse polynomial 1\n PI2 = 1 \t# Power of o/p 1 for coeff 2 of inv poly 1\n PI3 = 2 \t# Power of o/p 1 for coeff 3 of inv poly 1\n PI4 = 3 \t# Power of o/p 1 for coeff 4 of inv poly 1\n PI5 = 4 \t# Power of o/p 1 for coeff 5 of inv poly 1\n PI6 = 5 \t# Power of o/p 1 for coeff 6 of inv poly 1\n PI7 = 6 \t# Power of o/p 1 for coeff 7 of inv poly 1\n PI8 = 7 \t# Power of o/p 1 for coeff 8 of inv poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.01 \t# Scale factor on input 1\n FOFF1 = 0 \t# Offset on input 1\n ISCL1 = 0.42390259566156885 \t# Scale factor on output 1\n IOFF1 = -0.72446331281998022 \t# Offset on output 1\n End ChebyMap\n== t_2d_unit\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\nfwd 0.5 0 -> 0.5 0.5\nfwd 0 0.5 -> 0.5 -0.5\nfwd -0.5 0 -> -0.5 -0.5\nfwd 0 -0.5 -> -0.5 0.5\ninv 0.5 0.5 -> 0.49999999999999978 -2.7755575615628914e-17\ninv 0.5 -0.5 -> 0 0.5\ninv -0.5 -0.5 -> -0.49999999999999978 2.7755575615628914e-17\ninv -0.5 0.5 -> 0 -0.5\ncoeffs 0 n 4\ncof 0.99999999999999956 1 1 0\ncof 0.99999999999999956 1 0 1\ncof 0.99999999999999989 2 1 0\ncof -1 2 0 1\ndomain 0 -2 -2 : 2 2\n== t_2d_nonunit\nfwd 0 2 -> -0.16000000000000003 0.79999999999999993\nfwd 2 5 -> -0.19999999999999996 0\nfwd 6 8 -> 1.7120000000000002 1.6400000000000001\nfwd 10 0 -> -2 -1\nfwd 4 6 -> 0.83200000000000029 1.0400000000000003\nfwd 4.5 5.5 -> 0.90400000000000014 1.2550000000000001\nfwd 5 5 -> 1 1.5\nfwd 5.5 4.5 -> 1.0960000000000001 1.7450000000000001\ninv 0.83200000000000029 1.0400000000000003 -> 4.0005814314033241 5.9999999999999929\ninv 0.90400000000000014 1.2550000000000001 -> 4.4997368998464706 5.4999999999999947\ninv 1 1.5 -> 4.9999999999999964 4.9999999999999973\ninv 1.0960000000000001 1.7450000000000001 -> 5.5002631001535232 4.5\ncoeffs 1 n 5\ncof 1 1 0 0\ncof -2 1 1 2\ncof 1 1 0 1\ncof 1.5 2 0 0\ncof -2.5 2 1 2\ncoeffs 0 n 9\ncof 4.9999999999999973 1 0 0\ncof -0.49350547962216651 1 1 0\ncof 1.6087143065711225 1 0 1\ncof 0.35096188953506308 1 2 1\ncof -0.49350547962218982 1 1 2\ncof 0.08674396192398813 1 0 3\ncof 4.9999999999999973 2 0 0\ncof 2.8399999999999888 2 1 0\ncof -1.9967346938775425 2 0 1\ndomain 1 0 0 : 10 10\ndomain 0 -2 -1 : 4 4\ndomain 1 0 0 : 10 10\ndomain 0 0.43200000000000011 1.0008163265306123 : 1.5680000000000001 1.9991836734693882\n== t_inverted_domain\ndomain 1 0 -1.0000000000000002 : 1 2\ndomain 0 -1 -1.25 : 1 1.25\ndomain 1 -1 -1.25 : 1 1.25\ndomain 0 0 -1.0000000000000002 : 1 2\n== t_rate\nrate 0.5 -> 3\nrate 0 -> 3\nrate 1 -> 3\n== t_linear_1d\n-- simplified WinMap same 0\n Begin WinMap \t# Map one window on to another\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = -2 \t# Shift for axis 1\n Scl1 = 0.40000000000000002 \t# Scale factor for axis 1\n End WinMap\nfwd 0 -> -2\nfwd 1 -> -1.6000000000000001\nfwd 10 -> 2\nfwd 0 -> -2\nfwd 1 -> -1.6000000000000001\nfwd 10 -> 2\ninv -2 -> 0\ninv -1.6000000000000001 -> 1\ninv 2 -> 10\n== t_linear_2d\n-- simplified WinMap same 0\n Begin WinMap \t# Map one window on to another\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = -2.5 \t# Shift for axis 1\n Scl1 = 0.60000000000000009 \t# Scale factor for axis 1\n Sft2 = 2 \t# Shift for axis 2\n Scl2 = -0.20000000000000001 \t# Scale factor for axis 2\n End WinMap\nfwd 0 -5 -> -2.5 3\nfwd 10 5 -> 3.5 1\nfwd 3 1 -> -0.69999999999999973 1.8\nfwd 7.5 -2 -> 2 2.3999999999999999\nfwd 0 -5 -> -2.5 3\nfwd 10 5 -> 3.5000000000000009 1\nfwd 3 1 -> -0.69999999999999973 1.8\nfwd 7.5 -2 -> 2.0000000000000009 2.3999999999999999\ninv -2.5 3 -> 0 -5\ninv 3.5 1 -> 10 5\ninv -0.69999999999999973 1.8 -> 3 1\ninv 2 2.3999999999999999 -> 7.4999999999999991 -2\n== isa\nIsAPolyMap 1 IsAChebyMap 1 IsAMapping 1 Class ChebyMap\nPolyMap IsAChebyMap 0\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n== outside_box\nfwd 5 0.5 -> -0.125 2.171875\nfwd 0 -2 -> -1.5 2.25\nfwd 10 2 -> 1.5 1.75\nfwd -4.9406564584124654e-324 0 -> -1 2\nfwd 10.000000000000002 0 -> -1.7976931348623157e+308 2\nfwd -1 0 -> -1.7976931348623157e+308 2\nfwd 11 0 -> -1.7976931348623157e+308 2\nfwd 5 2.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 5 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 2.25\nfwd nan 1 -> -1.7976931348623157e+308 2.25\nfwd 1.0000000000000001e+300 0 -> -1.7976931348623157e+308 2\ninv 1 4 -> 1.5 0\ninv -1 0 -> -1.5 -0.75\ninv 3 8 -> 4.5 0.75\ninv -1.5 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.5 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 -0.5 -> 1.5 -1.7976931348623157e+308\ninv 1 -1.7976931348623157e+308 -> 1.5 -1.7976931348623157e+308\ninv -1.7976931348623157e+308 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv nan 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0000000000000004 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 4 -> 1.5 0\nfwd -1 0 -> -1.5 -0.75\nfwd 3 8 -> 4.5 0.75\nfwd -1.5 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 3.5 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -0.5 -> 1.5 -1.7976931348623157e+308\nfwd 1 -1.7976931348623157e+308 -> 1.5 -1.7976931348623157e+308\nfwd -1.7976931348623157e+308 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd nan 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 3.0000000000000004 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 5 0.5 -> -0.125 2.171875\ninv 0 -2 -> -1.5 2.25\ninv 10 2 -> 1.5 1.75\ninv -4.9406564584124654e-324 0 -> -1 2\ninv 10.000000000000002 0 -> -1.7976931348623157e+308 2\ninv -1 0 -> -1.7976931348623157e+308 2\ninv 11 0 -> -1.7976931348623157e+308 2\ninv 5 2.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 5 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 2.25\ninv nan 1 -> -1.7976931348623157e+308 2.25\ninv 1.0000000000000001e+300 0 -> -1.7976931348623157e+308 2\n== no_inverse\nIterInverse 0 set 0 TranForward 1 TranInverse 0\n!! AST: Error in routine tran at line 69 in file src/test/resources/probes/chebymap_probe.c.\n! astTranN(ChebyMap): An inverse coordinate transformation is not defined by the ChebyMap supplied.\nstatus 233933698\nIterInverse 0 set 1 TranForward 1 TranInverse 0\n-- attribute 0\n!! AST: Error in routine tran at line 69 in file src/test/resources/probes/chebymap_probe.c.\n! astTranN(ChebyMap): An inverse coordinate transformation is not defined by the ChebyMap supplied.\nstatus 233933698\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IterInv = 1 \t# Use an iterative inverse\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\nIterInverse 0 set 1 TranForward 1 TranInverse 0\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IterInv = 0 \t# Do not use an iterative inverse\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\nIterInverse 0 set 0 TranForward 1 TranInverse 0\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n NiterInv = 7 \t# Max number of iterations for iterative inverse\n TolInv = 1.0000000000000001e-09 \t# Target relative error for iterative inverse\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n== no_inverse_polymap\nIterInverse 1 set 0 TranForward 1 TranInverse 1\ninv 1 -> 0\ninv 2 -> 0.73205080756887742\n== iterinverse_unequal\nIterInverse 0 set 0 TranForward 1 TranInverse 0\n!! AST: Error in routine focus_cases at line 388 in file src/test/resources/probes/chebymap_probe.c.\n! astSetIterInverse(ChebyMap):Cannot use an iterative inverse because the ChebyMap has unequal numbers of inputs and outputs.\nstatus 233933170\nIterInverse 0 set 0 TranForward 1 TranInverse 0\n== domain_both\ndomain 1 0 -2 : 10 2\ndomain 0 -1 0 : 3 8\ndomain 1 -1 0 : 3 8\ndomain 0 0 -2 : 10 2\n== domain_no_inverse\ndomain 1 0 : 10\ndomain 0 0.25 : 2.5\ndomain 1 0.25 : 2.5\ndomain 0 0 : 10\n== domain_no_forward\nIterInverse 0 set 0 TranForward 0 TranInverse 1\ndomain 1 -1 : 3\ndomain 0 -4 : 4\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MPI1 = 1 \t# Max. power of output 1 in any inverse polynomial\n NCI1 = 2 \t# No. of coeff.s for inverse polynomial 1\n CI1 = 2 \t# Coeff 1 of inverse polynomial 1\n CI2 = 1 \t# Coeff 2 of inverse polynomial 1\n PI1 = 1 \t# Power of o/p 1 for coeff 1 of inv poly 1\n IsA PolyMap \t# Polynomial transformation\n ISCL1 = 0.25 \t# Scale factor on output 1\n IOFF1 = 0 \t# Offset on output 1\n End ChebyMap\n== domain_neither\nIterInverse 0 set 0 TranForward 0 TranInverse 0\ndomain 1 -1.7976931348623157e+308 -1.7976931348623157e+308 : -1.7976931348623157e+308 -1.7976931348623157e+308\ndomain 0 -1.7976931348623157e+308 -1.7976931348623157e+308 : -1.7976931348623157e+308 -1.7976931348623157e+308\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n End ChebyMap\n== domain_bad_coefficient\nfwd 0 -> -1.7976931348623157e+308\nfwd 0.5 -> -1.7976931348623157e+308\ndomain 1 0 : 1\n! AST: Error in routine domain at line 93 in file src/test/resources/probes/chebymap_probe.c.\n! astInitMatrixMap(MatrixMap): Supplied matrix contains only bad values.\nstatus 233933490\n== domain_infinite_width\nfwd -1e+308 -> 1\nfwd 0 -> 1\nfwd 5 -> 1\ndomain 1 -1.7976931348623157e+308 : -1.7976931348623157e+308\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 1 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 2 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 2 \t# Coeff 2 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0 \t# Scale factor on input 1\n FOFF1 = 0 \t# Offset on input 1\n End ChebyMap\n== simp_alone\n-- simplified ChebyMap same 1\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n== simp_poly_win\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Inv = 0 \t# Inverse transformation not defined\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin CmpMap \t# Compound Mapping\n Nin = 1 \t# Number of input coordinates\n Inv = 0 \t# Inverse transformation not defined\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 2 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n End CmpMap\n MapB = \t# Second component Mapping\n Begin PolyMap \t# Polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 3 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 2 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 0.10000000000000001 \t# Coeff 2 of forward polynomial 1\n PF1 = 1 \t# Power of i/p 1 for coeff 1 of fwd poly 1\n PF2 = 3 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n End PolyMap\n End CmpMap\nfwd 0 -> 0.26175760000000003\nfwd 0.5 -> 0.26175760000000003\nfwd 1 -> 0.34393040000000002\n== simp_linear_win\n-- simplified WinMap same 0\n Begin WinMap \t# Map one window on to another\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = -3 \t# Shift for axis 1\n Scl1 = 8 \t# Scale factor for axis 1\n End WinMap\nfwd 0 -> -3\nfwd 0.25 -> -1\nfwd 1 -> 5\nfwd 2 -> -1.7976931348623157e+308\n== simp_cancel\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 4 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Series = 0 \t# Component Mappings applied in parallel\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n MPF2 = 3 \t# Max. power of input 2 in any forward polynomial\n NCF1 = 2 \t# No. of coeff.s for forward polynomial 1\n NCF2 = 2 \t# No. of coeff.s for forward polynomial 2\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 0.5 \t# Coeff 2 of forward polynomial 1\n CF3 = -0.25 \t# Coeff 1 of forward polynomial 2\n CF4 = 2 \t# Coeff 2 of forward polynomial 2\n PF1 = 1 \t# Power of i/p 1 for coeff 1 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF4 = 1 \t# Power of i/p 2 for coeff 2 of fwd poly 1\n PF6 = 3 \t# Power of i/p 2 for coeff 1 of fwd poly 2\n MPI1 = 2 \t# Max. power of output 1 in any inverse polynomial\n MPI2 = 1 \t# Max. power of output 2 in any inverse polynomial\n NCI1 = 2 \t# No. of coeff.s for inverse polynomial 1\n NCI2 = 1 \t# No. of coeff.s for inverse polynomial 2\n CI1 = 3 \t# Coeff 1 of inverse polynomial 1\n CI2 = 1.5 \t# Coeff 2 of inverse polynomial 1\n CI3 = 0.75 \t# Coeff 1 of inverse polynomial 2\n PI1 = 1 \t# Power of o/p 1 for coeff 1 of inv poly 1\n PI5 = 2 \t# Power of o/p 1 for coeff 1 of inv poly 2\n PI6 = 1 \t# Power of o/p 2 for coeff 1 of inv poly 2\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FSCL2 = 0.5 \t# Scale factor on input 2\n FOFF1 = -1 \t# Offset on input 1\n FOFF2 = 0 \t# Offset on input 2\n ISCL1 = 0.5 \t# Scale factor on output 1\n ISCL2 = 0.25 \t# Scale factor on output 2\n IOFF1 = -0.5 \t# Offset on output 1\n IOFF2 = -1 \t# Offset on output 2\n End ChebyMap\n MapB = \t# Second component Mapping\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n MPF2 = 3 \t# Max. power of input 2 in any forward polynomial\n NCF1 = 2 \t# No. of coeff.s for forward polynomial 1\n NCF2 = 2 \t# No. of coeff.s for forward polynomial 2\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 0.5 \t# Coeff 2 of forward polynomial 1\n CF3 = -0.25 \t# Coeff 1 of forward polynomial 2\n CF4 = 2 \t# Coeff 2 of forward polynomial 2\n PF1 = 1 \t# Power of i/p 1 for coeff 1 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF4 = 1 \t# Power of i/p 2 for coeff 2 of fwd poly 1\n PF6 = 3 \t# Power of i/p 2 for coeff 1 of fwd poly 2\n MPI1 = 2 \t# Max. power of output 1 in any inverse polynomial\n MPI2 = 1 \t# Max. power of output 2 in any inverse polynomial\n NCI1 = 2 \t# No. of coeff.s for inverse polynomial 1\n NCI2 = 1 \t# No. of coeff.s for inverse polynomial 2\n CI1 = 3 \t# Coeff 1 of inverse polynomial 1\n CI2 = 1.5 \t# Coeff 2 of inverse polynomial 1\n CI3 = 0.75 \t# Coeff 1 of inverse polynomial 2\n PI1 = 1 \t# Power of o/p 1 for coeff 1 of inv poly 1\n PI5 = 2 \t# Power of o/p 1 for coeff 1 of inv poly 2\n PI6 = 1 \t# Power of o/p 2 for coeff 1 of inv poly 2\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FSCL2 = 0.5 \t# Scale factor on input 2\n FOFF1 = -1 \t# Offset on input 1\n FOFF2 = 0 \t# Offset on input 2\n ISCL1 = 0.5 \t# Scale factor on output 1\n ISCL2 = 0.25 \t# Scale factor on output 2\n IOFF1 = -0.5 \t# Offset on output 1\n IOFF2 = -1 \t# Offset on output 2\n End ChebyMap\n End CmpMap\n== simp_no_cancel_bounds\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Fwd = 0 \t# Forward transformation not defined\n Inv = 0 \t# Inverse transformation not defined\n IsA Mapping \t# Mapping between coordinate systems\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n MapB = \t# Second component Mapping\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.10000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n End CmpMap\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_cheby_poly_same_coeffs\nequal cheby_poly 1\nequal poly_cheby 1\nfwd 0 -> -0.96875\nfwd 5 -> -0.96875\nfwd 10 -> 1.000000000000002\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_consolidate\nfwd -3 -> -0.5\nfwd 1 -> 0.5\nfwd 5 -> 5.5\n-- simplified ChebyMap same 0\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 3 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1.5 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 3 \t# Coeff 3 of forward polynomial 1\n PF2 = 2 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 3 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n MPI1 = 1 \t# Max. power of output 1 in any inverse polynomial\n NCI1 = 1 \t# No. of coeff.s for inverse polynomial 1\n CI1 = 3 \t# Coeff 1 of inverse polynomial 1\n PI1 = 1 \t# Power of o/p 1 for coeff 1 of inv poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.25 \t# Scale factor on input 1\n FOFF1 = -0.25 \t# Offset on input 1\n ISCL1 = 0.5 \t# Scale factor on output 1\n IOFF1 = -1 \t# Offset on output 1\n End ChebyMap\n-- simplified ChebyMap same 0\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 3 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1.5 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 3 \t# Coeff 3 of forward polynomial 1\n PF2 = 2 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 3 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n MPI1 = 1 \t# Max. power of output 1 in any inverse polynomial\n NCI1 = 1 \t# No. of coeff.s for inverse polynomial 1\n CI1 = 3 \t# Coeff 1 of inverse polynomial 1\n PI1 = 1 \t# Power of o/p 1 for coeff 1 of inv poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.25 \t# Scale factor on input 1\n FOFF1 = -0.25 \t# Offset on input 1\n ISCL1 = 0.5 \t# Scale factor on output 1\n IOFF1 = -1 \t# Offset on output 1\n End ChebyMap\n== simp_parallel_win\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Inv = 0 \t# Inverse transformation not defined\n IsA Mapping \t# Mapping between coordinate systems\n Series = 0 \t# Component Mappings applied in parallel\n MapA = \t# First component Mapping\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 3 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 1 \t# Coeff 2 of forward polynomial 1\n CF3 = 0.5 \t# Coeff 3 of forward polynomial 1\n PF2 = 1 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n PF3 = 2 \t# Power of i/p 1 for coeff 3 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n MapB = \t# Second component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 2 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n End WinMap\n End CmpMap\n== equal\nequal same 1\nequal inverse_bounds 0\nequal forward_bounds 0\nequal inverted 0\nequal both_inverted 1\nequal bounds_1d 0\nequal no_inverse_vs_inverse 0\n== equal_rust\nequal chebymap_same 1\nequal chebymap_different_bounds 0\n== rate_cubic\nrate 0.5 -> 0.74999999839999998\nrate 0 -> 0\n== ctor_zero_width_forward\n!! AST: Error in routine focus_cases at line 602 in file src/test/resources/probes/chebymap_probe.c.\n! astInitChebyMap(ChebyMap): Input bounding box has zero width on input axis 2.\nstatus 233933194\n== ctor_zero_width_inverse\n!! AST: Error in routine focus_cases at line 610 in file src/test/resources/probes/chebymap_probe.c.\n! astInitChebyMap(ChebyMap): Output bounding box has zero width on output axis 2.\nstatus 233933194\n== ctor_zero_width_unused\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 1 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 1 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n PF1 = 1 \t# Power of i/p 1 for coeff 1 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 2 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n== ctor_reversed\nfwd 0 -> 1\nfwd 2.5 -> 0.5\nfwd 10 -> -1\nfwd -1 -> -1.7976931348623157e+308\ndomain 1 10 : -0\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 1 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 1 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n PF1 = 1 \t# Power of i/p 1 for coeff 1 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = -0.20000000000000001 \t# Scale factor on input 1\n FOFF1 = 1 \t# Offset on input 1\n End ChebyMap\n== ctor_bad_output\n!! AST: Error in routine focus_cases at line 633 in file src/test/resources/probes/chebymap_probe.c.\n! astInitPolyMap(ChebyMap): Forward coefficient 1 referred to an illegal output coordinate 2.\n! This number should be in the range 1 to 1.\nstatus 233933770\n== ctor_bad_power\n!! AST: Error in routine focus_cases at line 641 in file src/test/resources/probes/chebymap_probe.c.\n! astInitPolyMap(ChebyMap): Inverse coefficient 1 has a negative power (-1) for output coordinate 1.\n! All powers should be zero or positive.\nstatus 233933226\n== ctor_no_axes\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nout = 1 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n End ChebyMap\n== load_standard_polynomial\nfwd -2 -> 13\nfwd 0.5 -> 1.75\nfwd 4 -> 49\ndomain 1 -1.7976931348623157e+308 : -1.7976931348623157e+308\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 2 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 2 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n CF2 = 3 \t# Coeff 2 of forward polynomial 1\n PF2 = 2 \t# Power of i/p 1 for coeff 2 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n End ChebyMap\n== load_insufficient\n!! AST: Error in routine focus_cases at line 667 in file src/test/resources/probes/chebymap_probe.c.\n! astLoadChebyMap: insufficient scale and offset values for the forward transformation in loaded ChebyMap.\n! Error while reading a ChebyMap from a Channel.\nstatus 233933594\n== load_insufficient_inverse\n!! AST: Error in routine focus_cases at line 674 in file src/test/resources/probes/chebymap_probe.c.\n! astLoadChebyMap: insufficient scale and offset values for the inverse transformation in loaded ChebyMap.\n! Error while reading a ChebyMap from a Channel.\nstatus 233933594\n== load_unused_scales\n Begin ChebyMap \t# Chebyshev polynomial transformation\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MPF1 = 1 \t# Max. power of input 1 in any forward polynomial\n NCF1 = 1 \t# No. of coeff.s for forward polynomial 1\n CF1 = 1 \t# Coeff 1 of forward polynomial 1\n PF1 = 1 \t# Power of i/p 1 for coeff 1 of fwd poly 1\n IsA PolyMap \t# Polynomial transformation\n FSCL1 = 0.5 \t# Scale factor on input 1\n FOFF1 = -1 \t# Offset on input 1\n End ChebyMap\n== polytran_own_box\n-- class ChebyMap\nfwd 0 -> -0.90000000000000002\nfwd 4 -> 0.50800000000000012\nfwd 10 -> 3.1000000000000001\ninv -0.90000000000000002 -> 0.00029275439351432626\ninv 0.50800000000000012 -> 4.0004107319250251\ninv 3.1000000000000001 -> 9.9998243576116508\ndomain 0 -0.89999999999999991 : 3.1000000000000001\ncoeffs 0 n 5\ncof 5.2506428244361683 1 0\ncof 4.9750358930191636 1 1\ncof -0.24747092519706226 1 2\ncof 0.024729908589904526 1 3\ncof -0.0031133432365235362 1 4\n== polytran_forward_own_box\ninv -1 -> -0.40000000000000002\ninv 1 -> -0.10000000000000001\ninv 3 -> 0.59999999999999998\ndomain 1 -0.40000000000000002 : 0.59999999999999998\ndomain 0 -1 : 3\n== polytran_no_box\n!! AST: Error in routine focus_cases at line 725 in file src/test/resources/probes/chebymap_probe.c.\n! astPolyTran(ChebyMap): The inverse transformation is not a Chebyshev polynomial and therefore requires a user-supplied bounding box. But no lower bounds were supplied.\nstatus 233934426\n!! AST: Error in routine focus_cases at line 728 in file src/test/resources/probes/chebymap_probe.c.\n! astPolyTran(ChebyMap): The inverse transformation is not a Chebyshev polynomial and therefore requires a user-supplied bounding box. But no lower bounds were supplied.\nstatus 233934426\n== domain_unequal\ndomain 1 0 : 10\ndomain 0 -1 -2 : 1 2\ndomain 1 0 : 10\ndomain 0 -1 -2 : 1 2\ndomain 1 0 0 : 1 1\ndomain 0 -2 : 2\n" +} diff --git a/src/test/resources/probes/normmap_probe.c b/src/test/resources/probes/normmap_probe.c new file mode 100644 index 0000000..e31186c --- /dev/null +++ b/src/test/resources/probes/normmap_probe.c @@ -0,0 +1,551 @@ +/* normmap_probe -- NormMap and UnitNormMap behaviour of the pinned C + * library that no fixture or oracle holds. + * + * NormMap: the values a NormMap of a SkyFrame, of a CmpFrame holding a + * SkyFrame (permuted, as testnormmap.c builds it, and not permuted) and of + * a plain Frame gives for longitudes outside 0 to 2*pi, latitudes past a + * pole and points bad on one axis, in both directions; its dump; its + * simplification alone (a plain Frame gives a UnitMap, a CmpFrame of plain + * Frames does not), between two other Mappings, next to its inverse, in a + * run of four, and in parallel; its split, rate and comparisons; and the + * checks of testnormmap.c. + * + * UnitNormMap: the unit vector and norm a UnitNormMap of one, two and three + * axes gives for its own centre, a point one ulp from it, a bad coordinate + * and other points, and the inverse for a zero, bad and other norms; the + * inverse of a CmpMap of an inverted UnitNormMap and a UnitNormMap whose + * centre the first one reconstructs (fixture + * neg_unitnormmap_inv_fwd_diffcentre); its dump; its simplification next + * to a ShiftMap, a WinMap and another UnitNormMap on either side; its + * comparisons; the constructor's error; and the checks of testunitnormmap.c + * (testsimplify with every value printed, one case each). + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * The probe is built from the repository root against two builds of the C + * library at 3d3f255f on macOS AArch64 (Apple clang 21), made with + * cmake -S reference/starlink-ast -B -DCMAKE_BUILD_TYPE=Release + * -DBUILD_TESTING=OFF [-DCMAKE_C_FLAGS=-ffp-contract=off] + * The first, with the compiler's default flags, contracts a*b+c into a + * fused multiply-add (unitnormmap.c's inverse among others); the second + * does not. Each is linked with its static libraries: + * cc -std=c11 -I -o normmap_probe + * src/test/resources/probes/normmap_probe.c /libast.a + * /libast_pal.a /libast_err.a /libast_grf3d.a + * /libast_grf_2.0.a /libast_grf_3.2.a + * /libast_grf_5.6.a /libast_cminpack.a -lyaml -lm + * and run as ./normmap_probe > normmap_probe.txt 2>&1; the output, with + * trailing white space removed from every line, is stored as the "output" + * string of normmap_probe.json (default flags) and of + * normmap_probe_nocontract.json (-ffp-contract=off), since the dumps hold + * C's item names, which the spelling check rejects. The two differ only + * in the rows deferred/oracle-rows.txt lists for this probe. */ +#include +#include +#include +#include +#include "ast.h" + +#define BAD AST__BAD + +static void head( const char *name ) { + printf( "== %s\n", name ); +} + +/* Reports a failed call, then clears the status. */ +static int failed( void ) { + if( !astOK ) { + printf( "status %d\n", astStatus ); + astClearStatus; + return 1; + } + return 0; +} + +/* Transforms npt points of nin coordinates, given coordinate by coordinate + in "in", and prints one line per point. */ +static void tran( AstMapping *m, int npt, int nin, const double *in, int forward ) { + double out[ 8 * 64 ]; + int nout = astGetI( m, forward ? "Nout" : "Nin" ); + astTranN( m, npt, nin, npt, in, forward, nout, npt, out ); + if( failed() ) return; + for( int i = 0; i < npt; i++ ) { + printf( "%s", forward ? "fwd" : "inv" ); + for( int j = 0; j < nin; j++ ) printf( " %.17g", in[ j*npt + i ] ); + printf( " ->" ); + for( int j = 0; j < nout; j++ ) printf( " %.17g", out[ j*npt + i ] ); + printf( "\n" ); + } +} + +/* Transforms in both directions. */ +static void both( AstMapping *m, int npt, int nin, const double *in ) { + tran( m, npt, nin, in, 1 ); + tran( m, npt, nin, in, 0 ); +} + +/* The class of the simplified Mapping, whether it is the Mapping itself, + and its dump. */ +static void simp( AstMapping *m ) { + AstMapping *s = astSimplify( m ); + if( failed() ) return; + printf( "-- simplified %s same %d\n", astGetC( s, "Class" ), astSame( s, m ) ); + astShow( s ); + failed(); +} + +static void show( AstObject *obj ) { + astShow( obj ); + failed(); +} + +/* The NormMap testnormmap.c builds: a CmpFrame of a SpecFrame and a + SkyFrame, with its axes in the order 3, 1, 2 (sky latitude, wavelength, + sky longitude). */ +static AstNormMap *permuted( void ) { + int perm[ 3 ] = { 3, 1, 2 }; + AstFrame *f = (AstFrame *) astCmpFrame( astSpecFrame( " " ), astSkyFrame( " " ), " " ); + astPermAxes( f, perm ); + return astNormMap( f, " " ); +} + +/* Splits a NormMap and prints the outputs and the Mapping. */ +static void split( AstMapping *m, int nin, const int *in ) { + int out[ 8 ]; + AstMapping *sm = NULL; + astMapSplit( m, nin, in, out, &sm ); + if( failed() ) return; + if( !sm ) { + printf( "-- no split\n" ); + return; + } + printf( "-- outputs" ); + for( int i = 0; i < astGetI( sm, "Nout" ); i++ ) printf( " %d", out[ i ] ); + printf( "\n" ); + show( (AstObject *) sm ); +} + +/* testunitnormmap.c's differ. */ +static int differ( double aa, double bb ) { + double diff = fabs( aa - bb ); + double tol = fabs( 0.5*( aa + bb ) ) * 1.0e-14; + if( tol < 1.0e-14 ) tol = 1.0e-14; + return diff > tol; +} + +/* testunitnormmap.c's checkroundtrip, printing whether it holds. */ +static int roundtrip( AstMapping *map, const double *pos ) { + int good = 1; + double out[ 7 ], in[ 7 ]; + int nin = astGetI( map, "Nin" ); + int nout = astGetI( map, "Nout" ); + astTranN( map, 1, nin, 1, pos, 1, nout, 1, out ); + astTranN( map, 1, nout, 1, out, 0, nin, 1, in ); + for( int i = 0; i < nin; i++ ) if( differ( in[ i ], pos[ i ] ) ) good = 0; + AstMapping *mapinv = astCopy( map ); + astInvert( mapinv ); + AstMapping *cmp = (AstMapping *) astCmpMap( map, mapinv, 1, " " ); + astTranN( cmp, 1, nin, 1, pos, 1, nin, 1, in ); + for( int i = 0; i < nin; i++ ) if( differ( in[ i ], pos[ i ] ) ) good = 0; + return good; +} + +static void normmap_cases( void ) { + double pi = acos( -1.0 ); + + /* Review Focus 1: a NormMap of a SkyFrame. */ + head( "nm_sky" ); + { + double in[ 2 ][ 15 ] = { + { 3.0*pi, -0.5, 7.0, 1.0, 1.0, -1.0, 0.5, 2.0*pi, -7.5, 100.0, BAD, 1.0, BAD, 0.0, -2.0*pi }, + { 0.25, 0.3, 0.0, 2.0, -2.0, 1.7, 3.5, 0.0, -3.5, -100.0, 0.5, BAD, BAD, 0.0, -0.5*pi } }; + both( (AstMapping *) astNormMap( astSkyFrame( " " ), " " ), 15, 2, &in[ 0 ][ 0 ] ); + } + + /* Review Focus 1: a NormMap of a permuted CmpFrame holding a SkyFrame + (latitude, wavelength, longitude). */ + head( "nm_cmp_permuted" ); + { + double in[ 3 ][ 7 ] = { + { 2.0, -2.0, 1.6, BAD, 0.5, 3.5, BAD }, + { 3.0e4, 5.0, BAD, 1.0, -1.0, 2.0, BAD }, + { 1.0, 7.0, -1.0, 7.0, 7.0, -0.5, BAD } }; + both( (AstMapping *) permuted(), 7, 3, &in[ 0 ][ 0 ] ); + } + + /* A CmpFrame of a plain Frame and a SkyFrame, not permuted. */ + head( "nm_cmp_plain" ); + { + double in[ 3 ][ 4 ] = { + { 5.0, -1.0, BAD, 1.0e10 }, + { 7.0, -0.5, 7.0, -4.0 }, + { 2.0, -2.0, BAD, 1.6 } }; + AstFrame *f = (AstFrame *) astCmpFrame( astFrame( 1, " " ), astSkyFrame( " " ), " " ); + both( (AstMapping *) astNormMap( f, " " ), 4, 3, &in[ 0 ][ 0 ] ); + } + + /* A plain Frame, whose normalisation does nothing. */ + head( "nm_frame" ); + { + double in[ 2 ][ 3 ] = { { 1.0e10, BAD, 7.0 }, { -3.0, 2.0, BAD } }; + both( (AstMapping *) astNormMap( astFrame( 2, " " ), " " ), 3, 2, &in[ 0 ][ 0 ] ); + } + + head( "nm_dump" ); + { + AstNormMap *nm = astNormMap( astSkyFrame( " " ), " " ); + show( (AstObject *) nm ); + astInvert( nm ); + show( (AstObject *) nm ); + } + + /* Simplification. */ + head( "nm_simplify_frame" ); + simp( (AstMapping *) astNormMap( astFrame( 2, " " ), " " ) ); + head( "nm_simplify_cmpframe_of_frames" ); + simp( (AstMapping *) astNormMap( astCmpFrame( astFrame( 1, " " ), astFrame( 1, " " ), " " ), " " ) ); + head( "nm_simplify_sky" ); + simp( (AstMapping *) astNormMap( astSkyFrame( " " ), " " ) ); + head( "nm_simplify_between" ); + { + AstMapping *nm = (AstMapping *) astNormMap( astSkyFrame( " " ), " " ); + AstMapping *m = (AstMapping *) astCmpMap( + astCmpMap( astZoomMap( 2, 2.0, " " ), nm, 1, " " ), astZoomMap( 2, 0.5, " " ), 1, " " ); + simp( m ); + } + head( "nm_simplify_between_frames" ); + { + AstMapping *nm = (AstMapping *) astNormMap( astFrame( 2, " " ), " " ); + AstMapping *m = (AstMapping *) astCmpMap( + astCmpMap( astZoomMap( 2, 2.0, " " ), nm, 1, " " ), astZoomMap( 2, 0.5, " " ), 1, " " ); + simp( m ); + } + head( "nm_simplify_cancel" ); + { + AstMapping *nm = (AstMapping *) astNormMap( astSkyFrame( " " ), " " ); + AstMapping *inv = astCopy( nm ); + astInvert( inv ); + simp( (AstMapping *) astCmpMap( nm, inv, 1, " " ) ); + simp( (AstMapping *) astCmpMap( inv, nm, 1, " " ) ); + } + head( "nm_simplify_unequal" ); + { + AstMapping *nm = (AstMapping *) astNormMap( astSkyFrame( " " ), " " ); + AstMapping *nm2 = (AstMapping *) astNormMap( astSkyFrame( "System=Galactic" ), " " ); + astInvert( nm2 ); + simp( (AstMapping *) astCmpMap( nm, nm2, 1, " " ) ); + } + head( "nm_simplify_four" ); + { + AstMapping *m = (AstMapping *) permuted(); + simp( (AstMapping *) astCmpMap( astCmpMap( m, astCopy( m ), 1, " " ), + astCmpMap( m, astCopy( m ), 1, " " ), 1, " " ) ); + } + head( "nm_simplify_parallel" ); + { + AstMapping *nm = (AstMapping *) astNormMap( astSkyFrame( " " ), " " ); + AstMapping *inv = astCopy( nm ); + astInvert( inv ); + simp( (AstMapping *) astCmpMap( nm, inv, 0, " " ) ); + } + + /* Splits of the permuted NormMap. */ + head( "nm_split" ); + { + AstMapping *m = (AstMapping *) permuted(); + int in1[] = { 1, 3 }, in2[] = { 3, 1 }, in3[] = { 2 }, in4[] = { 1, 2, 3 }, in5[] = { 2, 1, 3 }; + int in6[] = { 4 }, in7[] = { 1, 1 }; + split( m, 2, in1 ); + split( m, 2, in2 ); + split( m, 1, in3 ); + split( m, 3, in4 ); + split( m, 3, in5 ); + split( m, 1, in6 ); + split( m, 2, in7 ); + } + + head( "nm_rate" ); + { + AstMapping *m = (AstMapping *) permuted(); + double at[ 3 ] = { 2.0, 3.0e4, 1.0 }; + for( int i = 1; i <= 3; i++ ) { + for( int j = 1; j <= 3; j++ ) { + double r = astRate( m, at, i, j ); + if( failed() ) continue; + printf( "rate %d %d %.17g\n", i, j, r ); + } + } + } + + head( "nm_equal" ); + { + AstMapping *nm = (AstMapping *) astNormMap( astSkyFrame( " " ), " " ); + AstMapping *same = (AstMapping *) astNormMap( astSkyFrame( " " ), " " ); + AstMapping *inv = astCopy( nm ); + astInvert( inv ); + AstMapping *flat = (AstMapping *) astNormMap( astFrame( 2, " " ), " " ); + AstMapping *gal = (AstMapping *) astNormMap( astSkyFrame( "System=Galactic" ), " " ); + printf( "same %d\n", astEqual( nm, same ) ); + printf( "copy %d\n", astEqual( nm, astCopy( nm ) ) ); + printf( "inverted %d\n", astEqual( nm, inv ) ); + printf( "plain frame %d\n", astEqual( nm, flat ) ); + printf( "galactic %d\n", astEqual( nm, gal ) ); + printf( "unitmap %d\n", astEqual( flat, astUnitMap( 2, " " ) ) ); + } + + /* testnormmap.c, each check printed. */ + head( "testnormmap" ); + { + double at[ 3 ] = { 2.0, 3.0e4, 1.0 }, bt[ 3 ]; + AstMapping *m = (AstMapping *) permuted(); + printf( "Nin %d Nout %d TranForward %d TranInverse %d\n", (int) astGetI( m, "Nin" ), + (int) astGetI( m, "Nout" ), (int) astGetL( m, "TranForward" ), (int) astGetL( m, "TranInverse" ) ); + AstMapping *m2 = astCopy( m ); + astInvert( m2 ); + AstMapping *m3 = astSimplify( astCmpMap( m, m2, 1, " " ) ); + printf( "cancel %s\n", astGetC( m3, "Class" ) ); + astTranN( m, 1, 3, 1, at, 1, 3, 1, bt ); + printf( "tran %.17g %.17g %.17g\n", bt[ 0 ], bt[ 1 ], bt[ 2 ] ); + m2 = (AstMapping *) astCmpMap( astCmpMap( m, astCopy( m ), 1, " " ), + astCmpMap( m, astCopy( m ), 1, " " ), 1, " " ); + printf( "four %s\n", astGetC( astSimplify( m2 ), "Class" ) ); + m = (AstMapping *) astNormMap( astFrame( 2, " " ), " " ); + printf( "frame %s\n", astGetC( astSimplify( m ), "Class" ) ); + failed(); + } +} + +static void unitnormmap_cases( void ) { + /* Review Focus 2: two axes, centre ( 1, -1 ). */ + head( "unm_2d" ); + { + double c[ 2 ] = { 1.0, -1.0 }; + double fwd[ 2 ][ 10 ] = { + { 1.0, nextafter( 1.0, 2.0 ), 1.0, nextafter( 1.0, 0.0 ), 5.0, BAD, 1.0, 1.0e300, -3.0, 1.0e-300 }, + { -1.0, -1.0, nextafter( -1.0, -2.0 ), nextafter( -1.0, 0.0 ), 2.0, 2.0, BAD, -1.0e300, 2.0, -1.0 } }; + double inv[ 3 ][ 10 ] = { + { 0.8, 0.6, 999.0, BAD, 0.6, BAD, 0.6, 0.6, 0.3, -0.70710678118654746 }, + { 0.6, 0.8, -42.0, 0.8, 0.8, BAD, BAD, 0.8, 0.4, -0.70710678118654746 }, + { 5.0, 0.0, 0.0, 5.0, BAD, 0.0, 0.0, -5.0, 1.0e300, 7.0710678118654755 } }; + AstMapping *m = (AstMapping *) astUnitNormMap( 2, c, " " ); + tran( m, 10, 2, &fwd[ 0 ][ 0 ], 1 ); + tran( m, 10, 3, &inv[ 0 ][ 0 ], 0 ); + } + + /* One axis, centre 2. */ + head( "unm_1d" ); + { + double c[ 1 ] = { 2.0 }; + double fwd[ 1 ][ 7 ] = { { 2.0, nextafter( 2.0, 3.0 ), nextafter( 2.0, 1.0 ), 5.0, -1.0, BAD, 1.0e308 } }; + double inv[ 2 ][ 7 ] = { + { 1.0, -1.0, 5.0, BAD, 1.0, BAD, 0.5 }, + { 3.0, 3.0, 0.0, 0.0, BAD, 3.0, 4.0 } }; + AstMapping *m = (AstMapping *) astUnitNormMap( 1, c, " " ); + tran( m, 7, 1, &fwd[ 0 ][ 0 ], 1 ); + tran( m, 7, 2, &inv[ 0 ][ 0 ], 0 ); + } + + /* Three axes, centre ( -1, 1, 2 ). */ + head( "unm_3d" ); + { + double c[ 3 ] = { -1.0, 1.0, 2.0 }; + double fwd[ 3 ][ 6 ] = { + { -1.0, nextafter( -1.0, 0.0 ), -22.0, BAD, 0.0, -1.0 }, + { 1.0, 1.0, 3.0, 1.0, 0.0, 1.0 }, + { 2.0, 2.0, 0.5, 2.0, 0.0, nextafter( 2.0, 3.0 ) } }; + double inv[ 4 ][ 5 ] = { + { 0.6, 1.0, BAD, 0.1, -0.95382004166558744 }, + { 0.8, 0.0, 0.0, 0.2, 0.0908400039681512 }, + { 0.0, 0.0, 0.0, 0.3, -0.28614601249967623 }, + { 5.0, 0.0, 1.0, 1.0e-300, 22.01136070305997 } }; + AstMapping *m = (AstMapping *) astUnitNormMap( 3, c, " " ); + tran( m, 6, 3, &fwd[ 0 ][ 0 ], 1 ); + tran( m, 5, 4, &inv[ 0 ][ 0 ], 0 ); + } + + /* The inverse of fixture neg_unitnormmap_inv_fwd_diffcentre at its + zero sample: UnitNormMap ( 0, 1 ) inverted, then UnitNormMap ( 5, 6 ). */ + head( "unm_inv_fwd_diffcentre" ); + { + double c1[ 2 ] = { 0.0, 1.0 }, c2[ 2 ] = { 5.0, 6.0 }; + double inv[ 3 ][ 2 ] = { + { -0.70710678118654746, 0.70710678118654746 }, + { -0.70710678118654746, 0.70710678118654746 }, + { 7.0710678118654755, 1414206.4913052833 } }; + AstMapping *a = (AstMapping *) astUnitNormMap( 2, c1, " " ); + astInvert( a ); + AstMapping *b = (AstMapping *) astUnitNormMap( 2, c2, " " ); + tran( (AstMapping *) astCmpMap( a, b, 1, " " ), 2, 3, &inv[ 0 ][ 0 ], 0 ); + head( "unm_inv_diffcentre_second" ); + tran( b, 2, 3, &inv[ 0 ][ 0 ], 0 ); + } + + head( "unm_dump" ); + { + double c[ 3 ] = { 1.5, -2.0, 0.0 }; + AstUnitNormMap *m = astUnitNormMap( 3, c, " " ); + show( (AstObject *) m ); + astInvert( m ); + show( (AstObject *) m ); + } + + /* Simplification next to a ShiftMap, WinMaps and another UnitNormMap. */ + { + double c1[ 2 ] = { 1.0, 2.0 }, c2[ 2 ] = { 4.0, 6.0 }, sh[ 2 ] = { 3.0, -1.0 }; + double zero[ 2 ] = { 0.0, 0.0 }, one[ 2 ] = { 1.0, 1.0 }; + double b1[ 2 ] = { 4.0, 0.0 }, b2[ 2 ] = { 5.0, 0.0 }; + AstMapping *u1 = (AstMapping *) astUnitNormMap( 2, c1, " " ); + AstMapping *u1i = astCopy( u1 ); + astInvert( u1i ); + AstMapping *u2 = (AstMapping *) astUnitNormMap( 2, c2, " " ); + AstMapping *u2i = astCopy( u2 ); + astInvert( u2i ); + AstMapping *shift = (AstMapping *) astShiftMap( 2, sh, " " ); + AstMapping *shifti = astCopy( shift ); + astInvert( shifti ); + AstMapping *win1 = (AstMapping *) astWinMap( 2, zero, one, sh, b1, " " ); + AstMapping *win2 = (AstMapping *) astWinMap( 2, zero, one, sh, b2, " " ); + AstMapping *win1i = astCopy( win1 ); + astInvert( win1i ); + head( "unm_simplify_shift_fwd" ); + simp( (AstMapping *) astCmpMap( shift, u2, 1, " " ) ); + head( "unm_simplify_shift_inverted_fwd" ); + simp( (AstMapping *) astCmpMap( shifti, u2, 1, " " ) ); + head( "unm_simplify_fwd_shift" ); + simp( (AstMapping *) astCmpMap( u1, astShiftMap( 3, (double[]){ 1.0, 2.0, 3.0 }, " " ), 1, " " ) ); + head( "unm_simplify_inv_shift" ); + simp( (AstMapping *) astCmpMap( u1i, shift, 1, " " ) ); + head( "unm_simplify_inv_shift_inverted" ); + simp( (AstMapping *) astCmpMap( u1i, shifti, 1, " " ) ); + head( "unm_simplify_win_fwd" ); + simp( (AstMapping *) astCmpMap( win1, u1, 1, " " ) ); + head( "unm_simplify_win_inverted_fwd" ); + simp( (AstMapping *) astCmpMap( win1i, u1, 1, " " ) ); + head( "unm_simplify_win_nonunit_fwd" ); + simp( (AstMapping *) astCmpMap( win2, u1, 1, " " ) ); + head( "unm_simplify_inv_win" ); + simp( (AstMapping *) astCmpMap( u1i, win1, 1, " " ) ); + head( "unm_simplify_inv_win_nonunit" ); + simp( (AstMapping *) astCmpMap( u1i, win2, 1, " " ) ); + head( "unm_simplify_fwd_inv_same" ); + simp( (AstMapping *) astCmpMap( u1, u1i, 1, " " ) ); + head( "unm_simplify_inv_fwd_same" ); + simp( (AstMapping *) astCmpMap( u1i, u1, 1, " " ) ); + head( "unm_simplify_fwd_inv_diff" ); + simp( (AstMapping *) astCmpMap( u1, u2i, 1, " " ) ); + head( "unm_simplify_inv_fwd_diff" ); + simp( (AstMapping *) astCmpMap( u1i, u2, 1, " " ) ); + head( "unm_simplify_parallel" ); + simp( (AstMapping *) astCmpMap( u1, u1i, 0, " " ) ); + head( "unm_simplify_shift_zoom_unm" ); + simp( (AstMapping *) astCmpMap( astCmpMap( astZoomMap( 2, 3.0, " " ), shift, 1, " " ), u1, 1, " " ) ); + head( "unm_simplify_unm_later_pair" ); + simp( (AstMapping *) astCmpMap( astCmpMap( u1, astUnitMap( 3, " " ), 1, " " ), u1i, 1, " " ) ); + + /* unitnormmap.c's MakeMergedMap compares centres and WinMap scales + with its own EQUAL macro (a tolerance of 1.0E9 epsilons), not + astEQUAL (1.0E5). */ + double c3[ 2 ] = { 1.0, 2.0 + 2.0e-7 }, b3[ 2 ] = { 3.0 + 1.00000001, -1.0 + 1.00000001 }; + AstMapping *u3i = (AstMapping *) astUnitNormMap( 2, c3, " " ); + astInvert( u3i ); + head( "unm_simplify_near_centres" ); + simp( (AstMapping *) astCmpMap( u1, u3i, 1, " " ) ); + head( "unm_simplify_win_near_unit" ); + simp( (AstMapping *) astCmpMap( astWinMap( 2, zero, one, sh, b3, " " ), u1, 1, " " ) ); + } + + head( "unm_equal" ); + { + double c1[ 2 ] = { 1.0, 2.0 }, c2[ 2 ] = { 1.0, 3.0 }, c3[ 3 ] = { 1.0, 2.0, 0.0 }; + double c4[ 2 ] = { 1.0, nextafter( 2.0, 3.0 ) }; + AstMapping *a = (AstMapping *) astUnitNormMap( 2, c1, " " ); + AstMapping *ai = astCopy( a ); + astInvert( ai ); + printf( "same %d\n", astEqual( a, astUnitNormMap( 2, c1, " " ) ) ); + printf( "centre %d\n", astEqual( a, astUnitNormMap( 2, c2, " " ) ) ); + printf( "dimension %d\n", astEqual( a, astUnitNormMap( 3, c3, " " ) ) ); + printf( "inverted %d\n", astEqual( a, ai ) ); + printf( "both inverted %d\n", astEqual( ai, astCopy( ai ) ) ); + printf( "one ulp %d\n", astEqual( a, astUnitNormMap( 2, c4, " " ) ) ); + } + + head( "unm_error_no_axes" ); + { + double c[ 1 ] = { 0.0 }; + astUnitNormMap( 0, c, " " ); + failed(); + } + + /* testunitnormmap.c's main loop, each check printed. */ + head( "testunitnormmap" ); + { + double centre[] = { -1.0, 1.0, 2.0 }, frompos[] = { -22.0, 3.0, 0.5 }, topos[ 4 ]; + for( int nin = 1; nin <= 3; nin++ ) { + AstMapping *map = (AstMapping *) astUnitNormMap( nin, centre, " " ); + printf( "nin %d Nin %d Nout %d IsLinear %d\n", nin, (int) astGetI( map, "Nin" ), + (int) astGetI( map, "Nout" ), (int) astGetL( map, "IsLinear" ) ); + printf( "roundtrip %d centre %d\n", roundtrip( map, frompos ), roundtrip( map, centre ) ); + AstMapping *invmap = astCopy( map ); + astInvert( invmap ); + AstMapping *smap = astSimplify( astCmpMap( map, invmap, 1, " " ) ); + printf( "fwd inv %s %d\n", astGetC( smap, "Class" ), astGetI( smap, "Nin" ) ); + smap = astSimplify( astCmpMap( invmap, map, 1, " " ) ); + printf( "inv fwd %s %d\n", astGetC( smap, "Class" ), astGetI( smap, "Nin" ) ); + astTranN( map, 1, nin, 1, frompos, 1, nin + 1, 1, topos ); + printf( "tran" ); + for( int i = 0; i <= nin; i++ ) printf( " %.17g", topos[ i ] ); + printf( "\n" ); + failed(); + } + } + + /* testunitnormmap.c's testsimplify: each case's class, counts and the + values of the CmpMap and of its simplification at C's test points. */ + { + double centre1[] = { 2.0, -1.0, 0.0 }, centre2[] = { -1.0, 6.0, 4.0 }; + double shift[] = { 3.0, 7.0, -9.0 }, zeros[] = { 0.0, 0.0, 0.0 }, ones[] = { 1.0, 1.0, 1.0 }; + double a[ 3 ]; + double testpoints[] = { 1.0, 3.0, -5.0, 2.0, 3.0, 99.0, -6.0, -5.0, -7.0, 30.0, 21.0, 37.0 }; + AstMapping *map1[ 7 ], *map2[ 7 ]; + AstMapping *unm1 = (AstMapping *) astUnitNormMap( 3, centre1, " " ); + AstMapping *unm1inv = astCopy( unm1 ); + astSetL( unm1inv, "Invert", 1 ); + AstMapping *unm2 = (AstMapping *) astUnitNormMap( 3, centre2, " " ); + AstMapping *unm2inv = astCopy( unm2 ); + astSetL( unm2inv, "Invert", 1 ); + AstMapping *shiftmap = (AstMapping *) astShiftMap( 3, shift, " " ); + for( int i = 0; i < 3; i++ ) a[ i ] = ones[ i ] + shift[ i ]; + AstMapping *winmap1 = (AstMapping *) astWinMap( 3, zeros, shift, ones, a, " " ); + for( int i = 0; i < 3; i++ ) a[ i ] = 2*ones[ i ] + shift[ i ]; + AstMapping *winmap2 = (AstMapping *) astWinMap( 3, zeros, shift, ones, a, " " ); + map1[ 0 ] = unm1; map2[ 0 ] = unm2inv; + map1[ 1 ] = shiftmap; map2[ 1 ] = unm2; + map1[ 2 ] = winmap1; map2[ 2 ] = unm1; + map1[ 3 ] = winmap2; map2[ 3 ] = unm1; + map1[ 4 ] = unm1inv; map2[ 4 ] = shiftmap; + map1[ 5 ] = unm1inv; map2[ 5 ] = winmap1; + map1[ 6 ] = unm1inv; map2[ 6 ] = winmap2; + for( int i = 0; i < 7; i++ ) { + char name[ 32 ]; + sprintf( name, "testsimplify_%d", i ); + head( name ); + AstMapping *cmp = (AstMapping *) astCmpMap( map1[ i ], map2[ i ], 1, " " ); + AstMapping *s = astSimplify( cmp ); + int nin = astGetI( cmp, "Nin" ); + printf( "-- %s Nin %d %d Nout %d %d\n", astGetC( s, "Class" ), nin, + astGetI( s, "Nin" ), astGetI( cmp, "Nout" ), astGetI( s, "Nout" ) ); + tran( cmp, 3, nin, testpoints, 1 ); + printf( "-- simplified\n" ); + tran( s, 3, nin, testpoints, 1 ); + } + } +} + +int main( void ) { + setvbuf( stdout, NULL, _IONBF, 0 ); + astBegin; + normmap_cases(); + unitnormmap_cases(); + astEnd; + return 0; +} diff --git a/src/test/resources/probes/normmap_probe.json b/src/test/resources/probes/normmap_probe.json new file mode 100644 index 0000000..723b71e --- /dev/null +++ b/src/test/resources/probes/normmap_probe.json @@ -0,0 +1,4 @@ +{ + "source": "probes/normmap_probe.c", + "output": "== nm_sky\nfwd 9.4247779607693793 0.25 -> 3.1415926535897931 0.25\nfwd -0.5 0.29999999999999999 -> 5.7831853071795862 0.29999999999999999\nfwd 7 0 -> 0.71681469282041377 0\nfwd 1 2 -> 4.1415926535897931 1.1415926535897931\nfwd 1 -2 -> 4.1415926535897931 -1.1415926535897931\nfwd -1 1.7 -> 2.1415926535897931 1.4415926535897932\nfwd 0.5 3.5 -> 3.6415926535897931 -0.35840734641020688\nfwd 6.2831853071795862 0 -> 0 0\nfwd -7.5 -3.5 -> 1.9247779607693793 0.35840734641020688\nfwd 100 -100 -> 5.7522203923062065 0.53096491487337971\nfwd -1.7976931348623157e+308 0.5 -> -1.7976931348623157e+308 0.5\nfwd 1 -1.7976931348623157e+308 -> 1 -1.7976931348623157e+308\nfwd -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 0 -> 0 0\nfwd -6.2831853071795862 -1.5707963267948966 -> -0 -1.5707963267948966\ninv 9.4247779607693793 0.25 -> 3.1415926535897931 0.25\ninv -0.5 0.29999999999999999 -> 5.7831853071795862 0.29999999999999999\ninv 7 0 -> 0.71681469282041377 0\ninv 1 2 -> 4.1415926535897931 1.1415926535897931\ninv 1 -2 -> 4.1415926535897931 -1.1415926535897931\ninv -1 1.7 -> 2.1415926535897931 1.4415926535897932\ninv 0.5 3.5 -> 3.6415926535897931 -0.35840734641020688\ninv 6.2831853071795862 0 -> 0 0\ninv -7.5 -3.5 -> 1.9247779607693793 0.35840734641020688\ninv 100 -100 -> 5.7522203923062065 0.53096491487337971\ninv -1.7976931348623157e+308 0.5 -> -1.7976931348623157e+308 0.5\ninv 1 -1.7976931348623157e+308 -> 1 -1.7976931348623157e+308\ninv -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> 0 0\ninv -6.2831853071795862 -1.5707963267948966 -> -0 -1.5707963267948966\n== nm_cmp_permuted\nfwd 2 30000 1 -> 1.1415926535897931 30000 4.1415926535897931\nfwd -2 5 7 -> -1.1415926535897931 5 3.8584073464102069\nfwd 1.6000000000000001 -1.7976931348623157e+308 -1 -> 1.541592653589793 -1.7976931348623157e+308 2.1415926535897931\nfwd -1.7976931348623157e+308 1 7 -> -1.7976931348623157e+308 1 0.71681469282041377\nfwd 0.5 -1 7 -> 0.5 -1 0.71681469282041377\nfwd 3.5 2 -0.5 -> -0.35840734641020688 2 2.6415926535897931\nfwd -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2 30000 1 -> 1.1415926535897931 30000 4.1415926535897931\ninv -2 5 7 -> -1.1415926535897931 5 3.8584073464102069\ninv 1.6000000000000001 -1.7976931348623157e+308 -1 -> 1.541592653589793 -1.7976931348623157e+308 2.1415926535897931\ninv -1.7976931348623157e+308 1 7 -> -1.7976931348623157e+308 1 0.71681469282041377\ninv 0.5 -1 7 -> 0.5 -1 0.71681469282041377\ninv 3.5 2 -0.5 -> -0.35840734641020688 2 2.6415926535897931\ninv -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308\n== nm_cmp_plain\nfwd 5 7 2 -> 5 3.8584073464102069 1.1415926535897931\nfwd -1 -0.5 -2 -> -1 2.6415926535897931 -1.1415926535897931\nfwd -1.7976931348623157e+308 7 -1.7976931348623157e+308 -> -1.7976931348623157e+308 0.71681469282041377 -1.7976931348623157e+308\nfwd 10000000000 -4 1.6000000000000001 -> 10000000000 5.4247779607693793 1.541592653589793\ninv 5 7 2 -> 5 3.8584073464102069 1.1415926535897931\ninv -1 -0.5 -2 -> -1 2.6415926535897931 -1.1415926535897931\ninv -1.7976931348623157e+308 7 -1.7976931348623157e+308 -> -1.7976931348623157e+308 0.71681469282041377 -1.7976931348623157e+308\ninv 10000000000 -4 1.6000000000000001 -> 10000000000 5.4247779607693793 1.541592653589793\n== nm_frame\nfwd 10000000000 -3 -> 10000000000 -3\nfwd -1.7976931348623157e+308 2 -> -1.7976931348623157e+308 2\nfwd 7 -1.7976931348623157e+308 -> 7 -1.7976931348623157e+308\ninv 10000000000 -3 -> 10000000000 -3\ninv -1.7976931348623157e+308 2 -> -1.7976931348623157e+308 2\ninv 7 -1.7976931348623157e+308 -> 7 -1.7976931348623157e+308\n== nm_dump\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n== nm_simplify_frame\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== nm_simplify_cmpframe_of_frames\n-- simplified NormMap same 1\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin CmpFrame \t# Compound coordinate system description\n# Title = \"2-d compound coordinate system\" \t# Title of coordinate system\n# Naxes = 2 \t# Number of coordinate axes\n# Domain = \"CMP\" \t# Coordinate system domain\n# Lbl1 = \"Axis 1\" \t# Label for axis 1\n# Lbl2 = \"Axis 2\" \t# Label for axis 2\n IsA Frame \t# Coordinate system description\n FrameA = \t# First component Frame\n Begin Frame \t# Coordinate system description\n Naxes = 1 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n End Axis\n End Frame\n FrameB = \t# Second component Frame\n Begin Frame \t# Coordinate system description\n Naxes = 1 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n End Axis\n End Frame\n End CmpFrame\n End NormMap\n== nm_simplify_sky\n-- simplified NormMap same 1\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n== nm_simplify_between\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin ZoomMap \t# Zoom about the origin\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Zoom = 2 \t# Zoom factor\n End ZoomMap\n MapB = \t# Second component Mapping\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n End CmpMap\n MapB = \t# Second component Mapping\n Begin ZoomMap \t# Zoom about the origin\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Zoom = 0.5 \t# Zoom factor\n End ZoomMap\n End CmpMap\n== nm_simplify_between_frames\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== nm_simplify_cancel\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== nm_simplify_unequal\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n MapB = \t# Second component Mapping\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"IAU (1958) galactic coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Galactic longitude\" \t# Label for axis 1\n# Lbl2 = \"Galactic latitude\" \t# Label for axis 2\n System = \"GALACTIC\" \t# Coordinate system type\n# Uni1 = \"degrees\" \t# Units for axis 1\n# Uni2 = \"degrees\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n End CmpMap\n== nm_simplify_four\n-- simplified NormMap same 0\n Begin NormMap \t# Normalise axis values\n Nin = 3 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin CmpFrame \t# Compound coordinate system description\n# Title = \"3-d compound coordinate system\" \t# Title of coordinate system\n# Naxes = 3 \t# Number of coordinate axes\n# Domain = \"SPECTRUM-SKY\" \t# Coordinate system domain\n# Lbl1 = \"Wavelength\" \t# Label for axis 1\n# Lbl2 = \"Right ascension\" \t# Label for axis 2\n# Lbl3 = \"Declination\" \t# Label for axis 3\n# Uni1 = \"Angstrom\" \t# Units for axis 1\n# Uni2 = \"hh:mm:ss.s\" \t# Units for axis 2\n# Uni3 = \"ddd:mm:ss\" \t# Units for axis 3\n# Dir2 = 0 \t# Plot axis 2 in reverse direction\n IsA Frame \t# Coordinate system description\n Axp1 = 3 \t# Axis 1 permuted to use internal axis 3\n Axp2 = 1 \t# Axis 2 permuted to use internal axis 1\n Axp3 = 2 \t# Axis 3 permuted to use internal axis 2\n FrameA = \t# First component Frame\n Begin SpecFrame \t# Description of spectral coordinate system\n Naxes = 1 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n End Axis\n IsA Frame \t# Coordinate system description\n End SpecFrame\n FrameB = \t# Second component Frame\n Begin SkyFrame \t# Description of celestial coordinate system\n Naxes = 2 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n End SkyFrame\n End CmpFrame\n End NormMap\n== nm_simplify_parallel\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 4 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Series = 0 \t# Component Mappings applied in parallel\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n MapB = \t# Second component Mapping\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n End CmpMap\n== nm_split\n-- outputs 1 3\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Prm1 = 2 \t# Axis 1 permuted to use internal axis 2\n Prm2 = 1 \t# Axis 2 permuted to use internal axis 1\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n-- outputs 3 1\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n-- outputs 2\n Begin NormMap \t# Normalise axis values\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SpecFrame \t# Description of spectral coordinate system\n# Title = \"Wavelength\" \t# Title of coordinate system\n Naxes = 1 \t# Number of coordinate axes\n# Domain = \"SPECTRUM\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Wavelength\" \t# Label for axis 1\n# System = \"WAVE\" \t# Coordinate system type\n# Uni1 = \"Angstrom\" \t# Units for axis 1\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n End Axis\n IsA Frame \t# Coordinate system description\n# SoR = \"Heliocentric\" \t# Standard of rest\n End SpecFrame\n End NormMap\n-- outputs 1 2 3\n Begin NormMap \t# Normalise axis values\n Nin = 3 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin CmpFrame \t# Compound coordinate system description\n# Title = \"3-d compound coordinate system\" \t# Title of coordinate system\n# Naxes = 3 \t# Number of coordinate axes\n# Domain = \"SPECTRUM-SKY\" \t# Coordinate system domain\n# Lbl1 = \"Wavelength\" \t# Label for axis 1\n# Lbl2 = \"Right ascension\" \t# Label for axis 2\n# Lbl3 = \"Declination\" \t# Label for axis 3\n# Uni1 = \"Angstrom\" \t# Units for axis 1\n# Uni2 = \"hh:mm:ss.s\" \t# Units for axis 2\n# Uni3 = \"ddd:mm:ss\" \t# Units for axis 3\n# Dir2 = 0 \t# Plot axis 2 in reverse direction\n IsA Frame \t# Coordinate system description\n Axp1 = 3 \t# Axis 1 permuted to use internal axis 3\n Axp2 = 1 \t# Axis 2 permuted to use internal axis 1\n Axp3 = 2 \t# Axis 3 permuted to use internal axis 2\n FrameA = \t# First component Frame\n Begin SpecFrame \t# Description of spectral coordinate system\n Naxes = 1 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n End Axis\n IsA Frame \t# Coordinate system description\n End SpecFrame\n FrameB = \t# Second component Frame\n Begin SkyFrame \t# Description of celestial coordinate system\n Naxes = 2 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n End SkyFrame\n End CmpFrame\n End NormMap\n-- outputs 1 2 3\n Begin CmpMap \t# Compound Mapping\n Nin = 3 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin PermMap \t# Coordinate permutation\n Nin = 3 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Out1 = 2 \t# Output coordinate 1 = input coordinate 2\n Out2 = 1 \t# Output coordinate 2 = input coordinate 1\n Out3 = 3 \t# Output coordinate 3 = input coordinate 3\n In1 = 2 \t# Input coordinate 1 = output coordinate 2\n In2 = 1 \t# Input coordinate 2 = output coordinate 1\n In3 = 3 \t# Input coordinate 3 = output coordinate 3\n End PermMap\n MapB = \t# Second component Mapping\n Begin NormMap \t# Normalise axis values\n Nin = 3 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin CmpFrame \t# Compound coordinate system description\n# Title = \"3-d compound coordinate system\" \t# Title of coordinate system\n# Naxes = 3 \t# Number of coordinate axes\n# Domain = \"SPECTRUM-SKY\" \t# Coordinate system domain\n# Lbl1 = \"Wavelength\" \t# Label for axis 1\n# Lbl2 = \"Right ascension\" \t# Label for axis 2\n# Lbl3 = \"Declination\" \t# Label for axis 3\n# Uni1 = \"Angstrom\" \t# Units for axis 1\n# Uni2 = \"hh:mm:ss.s\" \t# Units for axis 2\n# Uni3 = \"ddd:mm:ss\" \t# Units for axis 3\n# Dir2 = 0 \t# Plot axis 2 in reverse direction\n IsA Frame \t# Coordinate system description\n Axp1 = 3 \t# Axis 1 permuted to use internal axis 3\n Axp2 = 1 \t# Axis 2 permuted to use internal axis 1\n Axp3 = 2 \t# Axis 3 permuted to use internal axis 2\n FrameA = \t# First component Frame\n Begin SpecFrame \t# Description of spectral coordinate system\n Naxes = 1 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n End Axis\n IsA Frame \t# Coordinate system description\n End SpecFrame\n FrameB = \t# Second component Frame\n Begin SkyFrame \t# Description of celestial coordinate system\n Naxes = 2 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n End SkyFrame\n End CmpFrame\n End NormMap\n End CmpMap\n!! AST: Error in routine split at line 116 in file src/test/resources/probes/normmap_probe.c.\n! astMapSplit(NormMap): One of the supplied Mapping input indices has value 4 which is invalid; it should be in the range 1 to 3.\nstatus 233933178\n!! AST: Error in routine split at line 116 in file src/test/resources/probes/normmap_probe.c.\n! astPickAxes(CmpFrame): Invalid axis selection - each axis may be selected only once.\nstatus 233933682\n== nm_rate\nrate 1 1 1\nrate 1 2 0\nrate 1 3 0\nrate 2 1 0\nrate 2 2 1\nrate 2 3 0\nrate 3 1 0\nrate 3 2 0\nrate 3 3 1\n== nm_equal\nsame 1\ncopy 1\ninverted 0\nplain frame 0\ngalactic 0\nunitmap 0\n== testnormmap\nNin 3 Nout 3 TranForward 1 TranInverse 1\ncancel UnitMap\ntran 1.1415926535897931 30000 4.1415926535897931\nfour NormMap\nframe UnitMap\n== unm_2d\nfwd 1 -1 -> -1.7976931348623157e+308 -1.7976931348623157e+308 0\nfwd 1.0000000000000002 -1 -> 1 0 2.2204460492503131e-16\nfwd 1 -1.0000000000000002 -> 0 -1 2.2204460492503131e-16\nfwd 0.99999999999999989 -0.99999999999999989 -> -0.70710678118654746 0.70710678118654746 1.5700924586837752e-16\nfwd 5 2 -> 0.80000000000000004 0.59999999999999998 5\nfwd -1.7976931348623157e+308 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1.0000000000000001e+300 -1.0000000000000001e+300 -> 0.70710678118654746 -0.70710678118654746 1.4142135623730952e+300\nfwd -3 2 -> -0.80000000000000004 0.59999999999999998 5\nfwd 1e-300 -1 -> -1 0 1\ninv 0.80000000000000004 0.59999999999999998 5 -> 5 2\ninv 0.59999999999999998 0.80000000000000004 0 -> 1 -1\ninv 999 -42 0 -> 1 -1\ninv -1.7976931348623157e+308 0.80000000000000004 5 -> -1.7976931348623157e+308 3\ninv 0.59999999999999998 0.80000000000000004 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -1.7976931348623157e+308 -1.7976931348623157e+308 0 -> 1 -1\ninv 0.59999999999999998 -1.7976931348623157e+308 0 -> 1 -1\ninv 0.59999999999999998 0.80000000000000004 -5 -> -2 -5\ninv 0.29999999999999999 0.40000000000000002 1.0000000000000001e+300 -> 3.0000000000000002e+299 4.0000000000000002e+299\ninv -0.70710678118654746 -0.70710678118654746 7.0710678118654755 -> -3.9999999999999996 -6\n== unm_1d\nfwd 2 -> -1.7976931348623157e+308 0\nfwd 2.0000000000000004 -> 1 4.4408920985006262e-16\nfwd 1.9999999999999998 -> -1 2.2204460492503131e-16\nfwd 5 -> 1 3\nfwd -1 -> -1 3\nfwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1e+308 -> 1 1e+308\ninv 1 3 -> 5\ninv -1 3 -> -1\ninv 5 0 -> 2\ninv -1.7976931348623157e+308 0 -> 2\ninv 1 -1.7976931348623157e+308 -> -1.7976931348623157e+308\ninv -1.7976931348623157e+308 3 -> -1.7976931348623157e+308\ninv 0.5 4 -> 4\n== unm_3d\nfwd -1 1 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 0\nfwd -0.99999999999999989 1 2 -> 1 0 0 1.1102230246251565e-16\nfwd -22 3 0.5 -> -0.99298827419494395 0.094570311828089892 -0.070927733871067419 21.148285982556597\nfwd -1.7976931348623157e+308 1 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 0 0 -> 0.40824829046386307 -0.40824829046386307 -0.81649658092772615 2.4494897427831779\nfwd -1 1 2.0000000000000004 -> 0 0 1 4.4408920985006262e-16\ninv 0.59999999999999998 0.80000000000000004 0 5 -> 2 5 2\ninv 1 0 0 0 -> -1 1 2\ninv -1.7976931348623157e+308 0 0 1 -> -1.7976931348623157e+308 1 2\ninv 0.10000000000000001 0.20000000000000001 0.29999999999999999 1e-300 -> -1 1 2\ninv -0.95382004166558743 0.090840003968151201 -0.28614601249967625 22.011360703059971 -> -21.994876982908934 2.9995120936103752 -4.2984630948726812\n== unm_inv_fwd_diffcentre\ninv -0.70710678118654746 -0.70710678118654746 7.0710678118654755 -> 0.75853844164804163 0.65162829323331306 3.4075347438225656e-16\ninv 0.70710678118654746 0.70710678118654746 1414206.4913052833 -> 0.70710678118654746 0.70710678118654746 1414213.5623730952\n== unm_inv_diffcentre_second\ninv -0.70710678118654746 -0.70710678118654746 7.0710678118654755 -> 2.5847460944407276e-16 1.0000000000000002\ninv 0.70710678118654746 0.70710678118654746 1414206.4913052833 -> 1000000 1000001\n== unm_dump\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 3 \t# Number of input coordinates\n Nout = 4 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1.5 \t# Centre for axis 1\n Ctr2 = -2 \t# Centre for axis 2\n End UnitNormMap\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 3 \t# Number of input coordinates\n Nout = 4 \t# Number of output coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1.5 \t# Centre for axis 1\n Ctr2 = -2 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_shift_fwd\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 7 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_shift_inverted_fwd\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 7 \t# Centre for axis 1\n Ctr2 = 5 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_fwd_shift\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 2 \t# Centre for axis 2\n End UnitNormMap\n MapB = \t# Second component Mapping\n Begin ShiftMap \t# Shift each coordinate axis\n Nin = 3 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 1 \t# Shift for axis 1\n Sft2 = 2 \t# Shift for axis 2\n Sft3 = 3 \t# Shift for axis 3\n End ShiftMap\n End CmpMap\n== unm_simplify_inv_shift\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 4 \t# Centre for axis 1\n Ctr2 = 1 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_inv_shift_inverted\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = -2 \t# Centre for axis 1\n Ctr2 = 3 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_win_fwd\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = -2 \t# Centre for axis 1\n Ctr2 = 3 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_win_inverted_fwd\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 4 \t# Centre for axis 1\n Ctr2 = 1 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_win_nonunit_fwd\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 3 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n Sft2 = -1 \t# Shift for axis 2\n End WinMap\n MapB = \t# Second component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 2 \t# Centre for axis 2\n End UnitNormMap\n End CmpMap\n== unm_simplify_inv_win\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 4 \t# Centre for axis 1\n Ctr2 = 1 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_inv_win_nonunit\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 3 \t# Number of input coordinates\n Nout = 2 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n InvA = 1 \t# First Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 2 \t# Centre for axis 2\n End UnitNormMap\n MapB = \t# Second component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 3 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n Sft2 = -1 \t# Shift for axis 2\n End WinMap\n End CmpMap\n== unm_simplify_fwd_inv_same\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== unm_simplify_inv_fwd_same\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 3 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== unm_simplify_fwd_inv_diff\n-- simplified ShiftMap same 0\n Begin ShiftMap \t# Shift each coordinate axis\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 3 \t# Shift for axis 1\n Sft2 = 4 \t# Shift for axis 2\n End ShiftMap\n== unm_simplify_inv_fwd_diff\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 3 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n InvA = 1 \t# First Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 2 \t# Centre for axis 2\n End UnitNormMap\n MapB = \t# Second component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 4 \t# Centre for axis 1\n Ctr2 = 6 \t# Centre for axis 2\n End UnitNormMap\n End CmpMap\n== unm_simplify_parallel\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 5 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Series = 0 \t# Component Mappings applied in parallel\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 2 \t# Centre for axis 2\n End UnitNormMap\n MapB = \t# Second component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 2 \t# Centre for axis 2\n End UnitNormMap\n End CmpMap\n== unm_simplify_shift_zoom_unm\n-- simplified CmpMap same 0\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 3 \t# Shift for axis 1\n Scl1 = 3 \t# Scale factor for axis 1\n Sft2 = -1 \t# Shift for axis 2\n Scl2 = 3 \t# Scale factor for axis 2\n End WinMap\n MapB = \t# Second component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 2 \t# Centre for axis 2\n End UnitNormMap\n End CmpMap\n== unm_simplify_unm_later_pair\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== unm_simplify_near_centres\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== unm_simplify_win_near_unit\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = -2 \t# Centre for axis 1\n Ctr2 = 3 \t# Centre for axis 2\n End UnitNormMap\n== unm_equal\nsame 1\ncentre 0\ndimension 0\ninverted 0\nboth inverted 1\none ulp 1\n== unm_error_no_axes\n!! AST: Error in routine unitnormmap_cases at line 475 in file src/test/resources/probes/normmap_probe.c.\n! The centre must have at least one axis\nstatus 233933234\n== testunitnormmap\nnin 1 Nin 1 Nout 2 IsLinear 0\nroundtrip 1 centre 1\nfwd inv UnitMap 1\ninv fwd UnitMap 2\ntran -1 21\nnin 2 Nin 2 Nout 3 IsLinear 0\nroundtrip 1 centre 1\nfwd inv UnitMap 2\ninv fwd UnitMap 3\ntran -0.99549547259395232 0.094809092627995459 21.095023109728984\nnin 3 Nin 3 Nout 4 IsLinear 0\nroundtrip 1 centre 1\nfwd inv UnitMap 3\ninv fwd UnitMap 4\ntran -0.99298827419494395 0.094570311828089892 -0.070927733871067419 21.148285982556597\n== testsimplify_0\n-- ShiftMap Nin 3 3 Nout 3 3\nfwd 1 2 -6 -> -2 9 -2\nfwd 3 3 -5 -> 3.6945384697121866e-17 10 -0.99999999999999967\nfwd -5 99 -7 -> -8 106 -2.9999999999999996\n-- simplified\nfwd 1 2 -6 -> -2 9 -2\nfwd 3 3 -5 -> 0 10 -1\nfwd -5 99 -7 -> -8 106 -3\n== testsimplify_1\n-- UnitNormMap Nin 3 3 Nout 4 4\nfwd 1 2 -6 -> 0.2515773027133138 0.15094638162798829 -0.95599375031059242 19.874606914351791\nfwd 3 3 -5 -> 0.35491408859437573 0.20280805062535756 -0.91263622781410902 19.723082923316017\nfwd -5 99 -7 -> -0.0098053353578868921 0.98053353578868929 -0.19610670715773784 101.98529305738155\n-- simplified\nfwd 1 2 -6 -> 0.2515773027133138 0.15094638162798829 -0.95599375031059242 19.874606914351791\nfwd 3 3 -5 -> 0.35491408859437573 0.20280805062535756 -0.91263622781410902 19.723082923316017\nfwd -5 99 -7 -> -0.0098053353578868921 0.98053353578868929 -0.19610670715773784 101.98529305738155\n== testsimplify_2\n-- UnitNormMap Nin 3 3 Nout 4 4\nfwd 1 2 -6 -> 0 0.62469504755442429 -0.78086880944303039 6.4031242374328485\nfwd 3 3 -5 -> 0.29814239699997197 0.7453559924999299 -0.59628479399994394 6.7082039324993694\nfwd -5 99 -7 -> -0.059197396424209757 0.99648950647419754 -0.059197396424209757 101.35580891098448\n-- simplified\nfwd 1 2 -6 -> 0 0.62469504755442429 -0.78086880944303039 6.4031242374328485\nfwd 3 3 -5 -> 0.29814239699997197 0.7453559924999299 -0.59628479399994394 6.7082039324993694\nfwd -5 99 -7 -> -0.059197396424209757 0.99648950647419754 -0.059197396424209757 101.35580891098448\n== testsimplify_3\n-- CmpMap Nin 3 3 Nout 4 4\nfwd 1 2 -6 -> 0.054610890497456016 0.70214002068157799 -0.70994157646692879 6.1037886453959391\nfwd 3 3 -5 -> 0.42285582882198119 0.76516769024929931 -0.48550113679560797 7.0946166412263771\nfwd -5 99 -7 -> -0.06636892047339979 0.99677049506012849 -0.045207815394924487 115.51591636539295\n-- simplified\nfwd 1 2 -6 -> 0.054610890497456016 0.70214002068157799 -0.70994157646692879 6.1037886453959391\nfwd 3 3 -5 -> 0.42285582882198119 0.76516769024929931 -0.48550113679560797 7.0946166412263771\nfwd -5 99 -7 -> -0.06636892047339979 0.99677049506012849 -0.045207815394924487 115.51591636539295\n== testsimplify_4\n-- UnitNormMap Nin 4 4 Nout 3 3\nfwd 1 2 -6 30 -> 35 66 -189\nfwd 3 3 -5 21 -> 68 69 -114\nfwd -5 99 -7 37 -> -180 3669 -268\n-- simplified\nfwd 1 2 -6 30 -> 35 66 -189\nfwd 3 3 -5 21 -> 68 69 -114\nfwd -5 99 -7 37 -> -180 3669 -268\n== testsimplify_5\n-- UnitNormMap Nin 4 4 Nout 3 3\nfwd 1 2 -6 30 -> 33 60 -179\nfwd 3 3 -5 21 -> 66 63 -104\nfwd -5 99 -7 37 -> -182 3663 -258\n-- simplified\nfwd 1 2 -6 30 -> 33 60 -179\nfwd 3 3 -5 21 -> 66 63 -104\nfwd -5 99 -7 37 -> -182 3663 -258\n== testsimplify_6\n-- CmpMap Nin 4 4 Nout 3 3\nfwd 1 2 -6 30 -> 43.666666666666664 68.428571428571431 -159\nfwd 3 3 -5 21 -> 87.666666666666657 71.857142857142847 -92.333333333333329\nfwd -5 99 -7 37 -> -243 4186.1428571428569 -229.2222222222222\n-- simplified\nfwd 1 2 -6 30 -> 43.666666666666664 68.428571428571431 -159\nfwd 3 3 -5 21 -> 87.666666666666657 71.857142857142847 -92.333333333333329\nfwd -5 99 -7 37 -> -243 4186.1428571428569 -229.2222222222222\n" +} diff --git a/src/test/resources/probes/normmap_probe_nocontract.json b/src/test/resources/probes/normmap_probe_nocontract.json new file mode 100644 index 0000000..918b462 --- /dev/null +++ b/src/test/resources/probes/normmap_probe_nocontract.json @@ -0,0 +1,4 @@ +{ + "source": "probes/normmap_probe.c", + "output": "== nm_sky\nfwd 9.4247779607693793 0.25 -> 3.1415926535897931 0.25\nfwd -0.5 0.29999999999999999 -> 5.7831853071795862 0.29999999999999999\nfwd 7 0 -> 0.71681469282041377 0\nfwd 1 2 -> 4.1415926535897931 1.1415926535897931\nfwd 1 -2 -> 4.1415926535897931 -1.1415926535897931\nfwd -1 1.7 -> 2.1415926535897931 1.4415926535897932\nfwd 0.5 3.5 -> 3.6415926535897931 -0.35840734641020688\nfwd 6.2831853071795862 0 -> 0 0\nfwd -7.5 -3.5 -> 1.9247779607693793 0.35840734641020688\nfwd 100 -100 -> 5.7522203923062065 0.53096491487337971\nfwd -1.7976931348623157e+308 0.5 -> -1.7976931348623157e+308 0.5\nfwd 1 -1.7976931348623157e+308 -> 1 -1.7976931348623157e+308\nfwd -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 0 -> 0 0\nfwd -6.2831853071795862 -1.5707963267948966 -> -0 -1.5707963267948966\ninv 9.4247779607693793 0.25 -> 3.1415926535897931 0.25\ninv -0.5 0.29999999999999999 -> 5.7831853071795862 0.29999999999999999\ninv 7 0 -> 0.71681469282041377 0\ninv 1 2 -> 4.1415926535897931 1.1415926535897931\ninv 1 -2 -> 4.1415926535897931 -1.1415926535897931\ninv -1 1.7 -> 2.1415926535897931 1.4415926535897932\ninv 0.5 3.5 -> 3.6415926535897931 -0.35840734641020688\ninv 6.2831853071795862 0 -> 0 0\ninv -7.5 -3.5 -> 1.9247779607693793 0.35840734641020688\ninv 100 -100 -> 5.7522203923062065 0.53096491487337971\ninv -1.7976931348623157e+308 0.5 -> -1.7976931348623157e+308 0.5\ninv 1 -1.7976931348623157e+308 -> 1 -1.7976931348623157e+308\ninv -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> 0 0\ninv -6.2831853071795862 -1.5707963267948966 -> -0 -1.5707963267948966\n== nm_cmp_permuted\nfwd 2 30000 1 -> 1.1415926535897931 30000 4.1415926535897931\nfwd -2 5 7 -> -1.1415926535897931 5 3.8584073464102069\nfwd 1.6000000000000001 -1.7976931348623157e+308 -1 -> 1.541592653589793 -1.7976931348623157e+308 2.1415926535897931\nfwd -1.7976931348623157e+308 1 7 -> -1.7976931348623157e+308 1 0.71681469282041377\nfwd 0.5 -1 7 -> 0.5 -1 0.71681469282041377\nfwd 3.5 2 -0.5 -> -0.35840734641020688 2 2.6415926535897931\nfwd -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2 30000 1 -> 1.1415926535897931 30000 4.1415926535897931\ninv -2 5 7 -> -1.1415926535897931 5 3.8584073464102069\ninv 1.6000000000000001 -1.7976931348623157e+308 -1 -> 1.541592653589793 -1.7976931348623157e+308 2.1415926535897931\ninv -1.7976931348623157e+308 1 7 -> -1.7976931348623157e+308 1 0.71681469282041377\ninv 0.5 -1 7 -> 0.5 -1 0.71681469282041377\ninv 3.5 2 -0.5 -> -0.35840734641020688 2 2.6415926535897931\ninv -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308\n== nm_cmp_plain\nfwd 5 7 2 -> 5 3.8584073464102069 1.1415926535897931\nfwd -1 -0.5 -2 -> -1 2.6415926535897931 -1.1415926535897931\nfwd -1.7976931348623157e+308 7 -1.7976931348623157e+308 -> -1.7976931348623157e+308 0.71681469282041377 -1.7976931348623157e+308\nfwd 10000000000 -4 1.6000000000000001 -> 10000000000 5.4247779607693793 1.541592653589793\ninv 5 7 2 -> 5 3.8584073464102069 1.1415926535897931\ninv -1 -0.5 -2 -> -1 2.6415926535897931 -1.1415926535897931\ninv -1.7976931348623157e+308 7 -1.7976931348623157e+308 -> -1.7976931348623157e+308 0.71681469282041377 -1.7976931348623157e+308\ninv 10000000000 -4 1.6000000000000001 -> 10000000000 5.4247779607693793 1.541592653589793\n== nm_frame\nfwd 10000000000 -3 -> 10000000000 -3\nfwd -1.7976931348623157e+308 2 -> -1.7976931348623157e+308 2\nfwd 7 -1.7976931348623157e+308 -> 7 -1.7976931348623157e+308\ninv 10000000000 -3 -> 10000000000 -3\ninv -1.7976931348623157e+308 2 -> -1.7976931348623157e+308 2\ninv 7 -1.7976931348623157e+308 -> 7 -1.7976931348623157e+308\n== nm_dump\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n== nm_simplify_frame\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== nm_simplify_cmpframe_of_frames\n-- simplified NormMap same 1\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin CmpFrame \t# Compound coordinate system description\n# Title = \"2-d compound coordinate system\" \t# Title of coordinate system\n# Naxes = 2 \t# Number of coordinate axes\n# Domain = \"CMP\" \t# Coordinate system domain\n# Lbl1 = \"Axis 1\" \t# Label for axis 1\n# Lbl2 = \"Axis 2\" \t# Label for axis 2\n IsA Frame \t# Coordinate system description\n FrameA = \t# First component Frame\n Begin Frame \t# Coordinate system description\n Naxes = 1 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n End Axis\n End Frame\n FrameB = \t# Second component Frame\n Begin Frame \t# Coordinate system description\n Naxes = 1 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n End Axis\n End Frame\n End CmpFrame\n End NormMap\n== nm_simplify_sky\n-- simplified NormMap same 1\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n== nm_simplify_between\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin ZoomMap \t# Zoom about the origin\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Zoom = 2 \t# Zoom factor\n End ZoomMap\n MapB = \t# Second component Mapping\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n End CmpMap\n MapB = \t# Second component Mapping\n Begin ZoomMap \t# Zoom about the origin\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Zoom = 0.5 \t# Zoom factor\n End ZoomMap\n End CmpMap\n== nm_simplify_between_frames\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== nm_simplify_cancel\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== nm_simplify_unequal\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n MapB = \t# Second component Mapping\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"IAU (1958) galactic coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Galactic longitude\" \t# Label for axis 1\n# Lbl2 = \"Galactic latitude\" \t# Label for axis 2\n System = \"GALACTIC\" \t# Coordinate system type\n# Uni1 = \"degrees\" \t# Units for axis 1\n# Uni2 = \"degrees\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n End CmpMap\n== nm_simplify_four\n-- simplified NormMap same 0\n Begin NormMap \t# Normalise axis values\n Nin = 3 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin CmpFrame \t# Compound coordinate system description\n# Title = \"3-d compound coordinate system\" \t# Title of coordinate system\n# Naxes = 3 \t# Number of coordinate axes\n# Domain = \"SPECTRUM-SKY\" \t# Coordinate system domain\n# Lbl1 = \"Wavelength\" \t# Label for axis 1\n# Lbl2 = \"Right ascension\" \t# Label for axis 2\n# Lbl3 = \"Declination\" \t# Label for axis 3\n# Uni1 = \"Angstrom\" \t# Units for axis 1\n# Uni2 = \"hh:mm:ss.s\" \t# Units for axis 2\n# Uni3 = \"ddd:mm:ss\" \t# Units for axis 3\n# Dir2 = 0 \t# Plot axis 2 in reverse direction\n IsA Frame \t# Coordinate system description\n Axp1 = 3 \t# Axis 1 permuted to use internal axis 3\n Axp2 = 1 \t# Axis 2 permuted to use internal axis 1\n Axp3 = 2 \t# Axis 3 permuted to use internal axis 2\n FrameA = \t# First component Frame\n Begin SpecFrame \t# Description of spectral coordinate system\n Naxes = 1 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n End Axis\n IsA Frame \t# Coordinate system description\n End SpecFrame\n FrameB = \t# Second component Frame\n Begin SkyFrame \t# Description of celestial coordinate system\n Naxes = 2 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n End SkyFrame\n End CmpFrame\n End NormMap\n== nm_simplify_parallel\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 4 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Series = 0 \t# Component Mappings applied in parallel\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n MapB = \t# Second component Mapping\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n End CmpMap\n== nm_split\n-- outputs 1 3\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Prm1 = 2 \t# Axis 1 permuted to use internal axis 2\n Prm2 = 1 \t# Axis 2 permuted to use internal axis 1\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n-- outputs 3 1\n Begin NormMap \t# Normalise axis values\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SkyFrame \t# Description of celestial coordinate system\n# Title = \"ICRS coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n# Domain = \"SKY\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Right ascension\" \t# Label for axis 1\n# Lbl2 = \"Declination\" \t# Label for axis 2\n# System = \"ICRS\" \t# Coordinate system type\n# Uni1 = \"hh:mm:ss.s\" \t# Units for axis 1\n# Uni2 = \"ddd:mm:ss\" \t# Units for axis 2\n# Dir1 = 0 \t# Plot axis 1 in reverse direction\n# Bot2 = -1.5707963267948966 \t# Lowest legal axis value\n# Top2 = 1.5707963267948966 \t# Highest legal axis value\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n# SkyTol = 0.001 \t# Smallest significant separation [arc-sec]\n End SkyFrame\n End NormMap\n-- outputs 2\n Begin NormMap \t# Normalise axis values\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin SpecFrame \t# Description of spectral coordinate system\n# Title = \"Wavelength\" \t# Title of coordinate system\n Naxes = 1 \t# Number of coordinate axes\n# Domain = \"SPECTRUM\" \t# Coordinate system domain\n# Epoch = 2000 \t# Julian epoch of observation\n# Lbl1 = \"Wavelength\" \t# Label for axis 1\n# System = \"WAVE\" \t# Coordinate system type\n# Uni1 = \"Angstrom\" \t# Units for axis 1\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n End Axis\n IsA Frame \t# Coordinate system description\n# SoR = \"Heliocentric\" \t# Standard of rest\n End SpecFrame\n End NormMap\n-- outputs 1 2 3\n Begin NormMap \t# Normalise axis values\n Nin = 3 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin CmpFrame \t# Compound coordinate system description\n# Title = \"3-d compound coordinate system\" \t# Title of coordinate system\n# Naxes = 3 \t# Number of coordinate axes\n# Domain = \"SPECTRUM-SKY\" \t# Coordinate system domain\n# Lbl1 = \"Wavelength\" \t# Label for axis 1\n# Lbl2 = \"Right ascension\" \t# Label for axis 2\n# Lbl3 = \"Declination\" \t# Label for axis 3\n# Uni1 = \"Angstrom\" \t# Units for axis 1\n# Uni2 = \"hh:mm:ss.s\" \t# Units for axis 2\n# Uni3 = \"ddd:mm:ss\" \t# Units for axis 3\n# Dir2 = 0 \t# Plot axis 2 in reverse direction\n IsA Frame \t# Coordinate system description\n Axp1 = 3 \t# Axis 1 permuted to use internal axis 3\n Axp2 = 1 \t# Axis 2 permuted to use internal axis 1\n Axp3 = 2 \t# Axis 3 permuted to use internal axis 2\n FrameA = \t# First component Frame\n Begin SpecFrame \t# Description of spectral coordinate system\n Naxes = 1 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n End Axis\n IsA Frame \t# Coordinate system description\n End SpecFrame\n FrameB = \t# Second component Frame\n Begin SkyFrame \t# Description of celestial coordinate system\n Naxes = 2 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n End SkyFrame\n End CmpFrame\n End NormMap\n-- outputs 1 2 3\n Begin CmpMap \t# Compound Mapping\n Nin = 3 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin PermMap \t# Coordinate permutation\n Nin = 3 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Out1 = 2 \t# Output coordinate 1 = input coordinate 2\n Out2 = 1 \t# Output coordinate 2 = input coordinate 1\n Out3 = 3 \t# Output coordinate 3 = input coordinate 3\n In1 = 2 \t# Input coordinate 1 = output coordinate 2\n In2 = 1 \t# Input coordinate 2 = output coordinate 1\n In3 = 3 \t# Input coordinate 3 = output coordinate 3\n End PermMap\n MapB = \t# Second component Mapping\n Begin NormMap \t# Normalise axis values\n Nin = 3 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Frame = \t# Frame defining the normalisation\n Begin CmpFrame \t# Compound coordinate system description\n# Title = \"3-d compound coordinate system\" \t# Title of coordinate system\n# Naxes = 3 \t# Number of coordinate axes\n# Domain = \"SPECTRUM-SKY\" \t# Coordinate system domain\n# Lbl1 = \"Wavelength\" \t# Label for axis 1\n# Lbl2 = \"Right ascension\" \t# Label for axis 2\n# Lbl3 = \"Declination\" \t# Label for axis 3\n# Uni1 = \"Angstrom\" \t# Units for axis 1\n# Uni2 = \"hh:mm:ss.s\" \t# Units for axis 2\n# Uni3 = \"ddd:mm:ss\" \t# Units for axis 3\n# Dir2 = 0 \t# Plot axis 2 in reverse direction\n IsA Frame \t# Coordinate system description\n Axp1 = 3 \t# Axis 1 permuted to use internal axis 3\n Axp2 = 1 \t# Axis 2 permuted to use internal axis 1\n Axp3 = 2 \t# Axis 3 permuted to use internal axis 2\n FrameA = \t# First component Frame\n Begin SpecFrame \t# Description of spectral coordinate system\n Naxes = 1 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n End Axis\n IsA Frame \t# Coordinate system description\n End SpecFrame\n FrameB = \t# Second component Frame\n Begin SkyFrame \t# Description of celestial coordinate system\n Naxes = 2 \t# Number of coordinate axes\n Ax1 = \t# Axis number 1\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n Ax2 = \t# Axis number 2\n Begin SkyAxis \t# Celestial coordinate axis\n End SkyAxis\n IsA Frame \t# Coordinate system description\n End SkyFrame\n End CmpFrame\n End NormMap\n End CmpMap\n!! AST: Error in routine split at line 116 in file src/test/resources/probes/normmap_probe.c.\n! astMapSplit(NormMap): One of the supplied Mapping input indices has value 4 which is invalid; it should be in the range 1 to 3.\nstatus 233933178\n!! AST: Error in routine split at line 116 in file src/test/resources/probes/normmap_probe.c.\n! astPickAxes(CmpFrame): Invalid axis selection - each axis may be selected only once.\nstatus 233933682\n== nm_rate\nrate 1 1 1\nrate 1 2 0\nrate 1 3 0\nrate 2 1 0\nrate 2 2 1\nrate 2 3 0\nrate 3 1 0\nrate 3 2 0\nrate 3 3 1\n== nm_equal\nsame 1\ncopy 1\ninverted 0\nplain frame 0\ngalactic 0\nunitmap 0\n== testnormmap\nNin 3 Nout 3 TranForward 1 TranInverse 1\ncancel UnitMap\ntran 1.1415926535897931 30000 4.1415926535897931\nfour NormMap\nframe UnitMap\n== unm_2d\nfwd 1 -1 -> -1.7976931348623157e+308 -1.7976931348623157e+308 0\nfwd 1.0000000000000002 -1 -> 1 0 2.2204460492503131e-16\nfwd 1 -1.0000000000000002 -> 0 -1 2.2204460492503131e-16\nfwd 0.99999999999999989 -0.99999999999999989 -> -0.70710678118654746 0.70710678118654746 1.5700924586837752e-16\nfwd 5 2 -> 0.80000000000000004 0.59999999999999998 5\nfwd -1.7976931348623157e+308 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1.0000000000000001e+300 -1.0000000000000001e+300 -> 0.70710678118654746 -0.70710678118654746 1.4142135623730952e+300\nfwd -3 2 -> -0.80000000000000004 0.59999999999999998 5\nfwd 1e-300 -1 -> -1 0 1\ninv 0.80000000000000004 0.59999999999999998 5 -> 5 2\ninv 0.59999999999999998 0.80000000000000004 0 -> 1 -1\ninv 999 -42 0 -> 1 -1\ninv -1.7976931348623157e+308 0.80000000000000004 5 -> -1.7976931348623157e+308 3\ninv 0.59999999999999998 0.80000000000000004 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -1.7976931348623157e+308 -1.7976931348623157e+308 0 -> 1 -1\ninv 0.59999999999999998 -1.7976931348623157e+308 0 -> 1 -1\ninv 0.59999999999999998 0.80000000000000004 -5 -> -2 -5\ninv 0.29999999999999999 0.40000000000000002 1.0000000000000001e+300 -> 3.0000000000000002e+299 4.0000000000000002e+299\ninv -0.70710678118654746 -0.70710678118654746 7.0710678118654755 -> -4 -6\n== unm_1d\nfwd 2 -> -1.7976931348623157e+308 0\nfwd 2.0000000000000004 -> 1 4.4408920985006262e-16\nfwd 1.9999999999999998 -> -1 2.2204460492503131e-16\nfwd 5 -> 1 3\nfwd -1 -> -1 3\nfwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1e+308 -> 1 1e+308\ninv 1 3 -> 5\ninv -1 3 -> -1\ninv 5 0 -> 2\ninv -1.7976931348623157e+308 0 -> 2\ninv 1 -1.7976931348623157e+308 -> -1.7976931348623157e+308\ninv -1.7976931348623157e+308 3 -> -1.7976931348623157e+308\ninv 0.5 4 -> 4\n== unm_3d\nfwd -1 1 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 0\nfwd -0.99999999999999989 1 2 -> 1 0 0 1.1102230246251565e-16\nfwd -22 3 0.5 -> -0.99298827419494395 0.094570311828089892 -0.070927733871067419 21.148285982556597\nfwd -1.7976931348623157e+308 1 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 0 0 -> 0.40824829046386307 -0.40824829046386307 -0.81649658092772615 2.4494897427831779\nfwd -1 1 2.0000000000000004 -> 0 0 1 4.4408920985006262e-16\ninv 0.59999999999999998 0.80000000000000004 0 5 -> 2 5 2\ninv 1 0 0 0 -> -1 1 2\ninv -1.7976931348623157e+308 0 0 1 -> -1.7976931348623157e+308 1 2\ninv 0.10000000000000001 0.20000000000000001 0.29999999999999999 1e-300 -> -1 1 2\ninv -0.95382004166558743 0.090840003968151201 -0.28614601249967625 22.011360703059971 -> -21.994876982908934 2.9995120936103752 -4.2984630948726812\n== unm_inv_fwd_diffcentre\ninv -0.70710678118654746 -0.70710678118654746 7.0710678118654755 -> -1.7976931348623157e+308 -1.7976931348623157e+308 0\ninv 0.70710678118654746 0.70710678118654746 1414206.4913052833 -> 0.70710678118654746 0.70710678118654746 1414213.5623730952\n== unm_inv_diffcentre_second\ninv -0.70710678118654746 -0.70710678118654746 7.0710678118654755 -> 0 1\ninv 0.70710678118654746 0.70710678118654746 1414206.4913052833 -> 1000000 1000001\n== unm_dump\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 3 \t# Number of input coordinates\n Nout = 4 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1.5 \t# Centre for axis 1\n Ctr2 = -2 \t# Centre for axis 2\n End UnitNormMap\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 3 \t# Number of input coordinates\n Nout = 4 \t# Number of output coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1.5 \t# Centre for axis 1\n Ctr2 = -2 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_shift_fwd\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 7 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_shift_inverted_fwd\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 7 \t# Centre for axis 1\n Ctr2 = 5 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_fwd_shift\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 2 \t# Centre for axis 2\n End UnitNormMap\n MapB = \t# Second component Mapping\n Begin ShiftMap \t# Shift each coordinate axis\n Nin = 3 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 1 \t# Shift for axis 1\n Sft2 = 2 \t# Shift for axis 2\n Sft3 = 3 \t# Shift for axis 3\n End ShiftMap\n End CmpMap\n== unm_simplify_inv_shift\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 4 \t# Centre for axis 1\n Ctr2 = 1 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_inv_shift_inverted\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = -2 \t# Centre for axis 1\n Ctr2 = 3 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_win_fwd\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = -2 \t# Centre for axis 1\n Ctr2 = 3 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_win_inverted_fwd\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 4 \t# Centre for axis 1\n Ctr2 = 1 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_win_nonunit_fwd\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 3 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n Sft2 = -1 \t# Shift for axis 2\n End WinMap\n MapB = \t# Second component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 2 \t# Centre for axis 2\n End UnitNormMap\n End CmpMap\n== unm_simplify_inv_win\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 4 \t# Centre for axis 1\n Ctr2 = 1 \t# Centre for axis 2\n End UnitNormMap\n== unm_simplify_inv_win_nonunit\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 3 \t# Number of input coordinates\n Nout = 2 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n InvA = 1 \t# First Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 2 \t# Centre for axis 2\n End UnitNormMap\n MapB = \t# Second component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 3 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n Sft2 = -1 \t# Shift for axis 2\n End WinMap\n End CmpMap\n== unm_simplify_fwd_inv_same\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== unm_simplify_inv_fwd_same\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 3 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== unm_simplify_fwd_inv_diff\n-- simplified ShiftMap same 0\n Begin ShiftMap \t# Shift each coordinate axis\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 3 \t# Shift for axis 1\n Sft2 = 4 \t# Shift for axis 2\n End ShiftMap\n== unm_simplify_inv_fwd_diff\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 3 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n InvA = 1 \t# First Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 2 \t# Centre for axis 2\n End UnitNormMap\n MapB = \t# Second component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 4 \t# Centre for axis 1\n Ctr2 = 6 \t# Centre for axis 2\n End UnitNormMap\n End CmpMap\n== unm_simplify_parallel\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 5 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Series = 0 \t# Component Mappings applied in parallel\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 2 \t# Centre for axis 2\n End UnitNormMap\n MapB = \t# Second component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 2 \t# Centre for axis 2\n End UnitNormMap\n End CmpMap\n== unm_simplify_shift_zoom_unm\n-- simplified CmpMap same 0\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 3 \t# Shift for axis 1\n Scl1 = 3 \t# Scale factor for axis 1\n Sft2 = -1 \t# Shift for axis 2\n Scl2 = 3 \t# Scale factor for axis 2\n End WinMap\n MapB = \t# Second component Mapping\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = 1 \t# Centre for axis 1\n Ctr2 = 2 \t# Centre for axis 2\n End UnitNormMap\n End CmpMap\n== unm_simplify_unm_later_pair\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== unm_simplify_near_centres\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== unm_simplify_win_near_unit\n-- simplified UnitNormMap same 0\n Begin UnitNormMap \t# Compute unit vector and norm relative to a centre\n Nin = 2 \t# Number of input coordinates\n Nout = 3 \t# Number of output coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Ctr1 = -2 \t# Centre for axis 1\n Ctr2 = 3 \t# Centre for axis 2\n End UnitNormMap\n== unm_equal\nsame 1\ncentre 0\ndimension 0\ninverted 0\nboth inverted 1\none ulp 1\n== unm_error_no_axes\n!! AST: Error in routine unitnormmap_cases at line 475 in file src/test/resources/probes/normmap_probe.c.\n! The centre must have at least one axis\nstatus 233933234\n== testunitnormmap\nnin 1 Nin 1 Nout 2 IsLinear 0\nroundtrip 1 centre 1\nfwd inv UnitMap 1\ninv fwd UnitMap 2\ntran -1 21\nnin 2 Nin 2 Nout 3 IsLinear 0\nroundtrip 1 centre 1\nfwd inv UnitMap 2\ninv fwd UnitMap 3\ntran -0.99549547259395232 0.094809092627995459 21.095023109728984\nnin 3 Nin 3 Nout 4 IsLinear 0\nroundtrip 1 centre 1\nfwd inv UnitMap 3\ninv fwd UnitMap 4\ntran -0.99298827419494395 0.094570311828089892 -0.070927733871067419 21.148285982556597\n== testsimplify_0\n-- ShiftMap Nin 3 3 Nout 3 3\nfwd 1 2 -6 -> -2 9 -2\nfwd 3 3 -5 -> 0 10 -1\nfwd -5 99 -7 -> -8 106 -3\n-- simplified\nfwd 1 2 -6 -> -2 9 -2\nfwd 3 3 -5 -> 0 10 -1\nfwd -5 99 -7 -> -8 106 -3\n== testsimplify_1\n-- UnitNormMap Nin 3 3 Nout 4 4\nfwd 1 2 -6 -> 0.2515773027133138 0.15094638162798829 -0.95599375031059242 19.874606914351791\nfwd 3 3 -5 -> 0.35491408859437573 0.20280805062535756 -0.91263622781410902 19.723082923316017\nfwd -5 99 -7 -> -0.0098053353578868921 0.98053353578868929 -0.19610670715773784 101.98529305738155\n-- simplified\nfwd 1 2 -6 -> 0.2515773027133138 0.15094638162798829 -0.95599375031059242 19.874606914351791\nfwd 3 3 -5 -> 0.35491408859437573 0.20280805062535756 -0.91263622781410902 19.723082923316017\nfwd -5 99 -7 -> -0.0098053353578868921 0.98053353578868929 -0.19610670715773784 101.98529305738155\n== testsimplify_2\n-- UnitNormMap Nin 3 3 Nout 4 4\nfwd 1 2 -6 -> 0 0.62469504755442429 -0.78086880944303039 6.4031242374328485\nfwd 3 3 -5 -> 0.29814239699997197 0.7453559924999299 -0.59628479399994394 6.7082039324993694\nfwd -5 99 -7 -> -0.059197396424209757 0.99648950647419754 -0.059197396424209757 101.35580891098448\n-- simplified\nfwd 1 2 -6 -> 0 0.62469504755442429 -0.78086880944303039 6.4031242374328485\nfwd 3 3 -5 -> 0.29814239699997197 0.7453559924999299 -0.59628479399994394 6.7082039324993694\nfwd -5 99 -7 -> -0.059197396424209757 0.99648950647419754 -0.059197396424209757 101.35580891098448\n== testsimplify_3\n-- CmpMap Nin 3 3 Nout 4 4\nfwd 1 2 -6 -> 0.054610890497456016 0.70214002068157799 -0.70994157646692879 6.1037886453959391\nfwd 3 3 -5 -> 0.42285582882198119 0.76516769024929931 -0.48550113679560802 7.0946166412263771\nfwd -5 99 -7 -> -0.06636892047339979 0.99677049506012849 -0.045207815394924487 115.51591636539295\n-- simplified\nfwd 1 2 -6 -> 0.054610890497456016 0.70214002068157799 -0.70994157646692879 6.1037886453959391\nfwd 3 3 -5 -> 0.42285582882198119 0.76516769024929931 -0.48550113679560802 7.0946166412263771\nfwd -5 99 -7 -> -0.06636892047339979 0.99677049506012849 -0.045207815394924487 115.51591636539295\n== testsimplify_4\n-- UnitNormMap Nin 4 4 Nout 3 3\nfwd 1 2 -6 30 -> 35 66 -189\nfwd 3 3 -5 21 -> 68 69 -114\nfwd -5 99 -7 37 -> -180 3669 -268\n-- simplified\nfwd 1 2 -6 30 -> 35 66 -189\nfwd 3 3 -5 21 -> 68 69 -114\nfwd -5 99 -7 37 -> -180 3669 -268\n== testsimplify_5\n-- UnitNormMap Nin 4 4 Nout 3 3\nfwd 1 2 -6 30 -> 33 60 -179\nfwd 3 3 -5 21 -> 66 63 -104\nfwd -5 99 -7 37 -> -182 3663 -258\n-- simplified\nfwd 1 2 -6 30 -> 33 60 -179\nfwd 3 3 -5 21 -> 66 63 -104\nfwd -5 99 -7 37 -> -182 3663 -258\n== testsimplify_6\n-- CmpMap Nin 4 4 Nout 3 3\nfwd 1 2 -6 30 -> 43.666666666666664 68.428571428571431 -159\nfwd 3 3 -5 21 -> 87.666666666666657 71.857142857142847 -92.333333333333329\nfwd -5 99 -7 37 -> -243 4186.1428571428569 -229.2222222222222\n-- simplified\nfwd 1 2 -6 30 -> 43.666666666666664 68.428571428571431 -159\nfwd 3 3 -5 21 -> 87.666666666666657 71.857142857142847 -92.333333333333329\nfwd -5 99 -7 37 -> -243 4186.1428571428569 -229.2222222222222\n" +} diff --git a/src/test/resources/probes/splinemap_probe.c b/src/test/resources/probes/splinemap_probe.c new file mode 100644 index 0000000..1dbae03 --- /dev/null +++ b/src/test/resources/probes/splinemap_probe.c @@ -0,0 +1,811 @@ +/* splinemap_probe -- SplineMap behaviour of the pinned C library that no + * fixture or oracle holds. + * + * Whether an Object is a SplineMap, and its dump; its attributes, set, + * tested, cleared and given as strings, the read-only ones refused; the + * IsSimple flag after each setter and clearer; the values it gives inside, + * on the edges of and outside the knots, with OutUnit unset and set, in + * both directions; positions whose inverse does not converge within + * InvNiter, with InvTol changed; an order-1 SplineMap; a SplineMap whose + * knots along X are not repeated at the ends, and two whose range covered + * along X has zero width; astSplineKnots and + * astSplineCoeffs of each axis, also inverted; astSimplify of a SplineMap + * with its inverse, in both orders, in the same direction, in parallel, + * with a WinMap, inside an inverted CmpMap and with a different OutUnit; + * its comparisons; its rates, also inverted; a dump read back; and the + * FITS-WCS writes of the lsst2.ast FrameSet that test_fitschan_wcs_write.rs + * makes. + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * The probe is run against four builds of the C library on macOS AArch64 + * (Apple clang 21): + * 1. 3d3f255f (the pin), Release, the compiler's default flags, which + * contract a*b+c into a fused multiply-add (splinemap.c's Dbvalu + * among others): splinemap_probe.json; + * 2. 3d3f255f, Release, -ffp-contract=off: splinemap_probe_nocontract.json; + * 3. 3d3f255f, CMake's default (unoptimised) flags, which gives the + * output of the second exactly (checked, not committed); + * 4. 1d0714fb, the tip of the PR that hardens C (Starlink/ast #104), + * Release, -ffp-contract=off, with the probe built with -DPR104: + * splinemap_probe_pr104.json. + * Each library is made with + * cmake -S -B [-DCMAKE_BUILD_TYPE=Release] + * -DBUILD_TESTING=OFF [-DCMAKE_C_FLAGS=-ffp-contract=off] + * where is reference/starlink-ast for the first three and a + * checkout of 1d0714fb for the fourth, and the probe is linked with its + * static libraries: + * cc -std=c11 [-DPR104] -I -o splinemap_probe + * src/test/resources/probes/splinemap_probe.c /libast.a + * /libast_pal.a /libast_err.a /libast_grf3d.a + * /libast_grf_2.0.a /libast_grf_3.2.a + * /libast_grf_5.6.a /libast_cminpack.a -lyaml -lm + * and run from the repository root as + * ./splinemap_probe > splinemap_probe.txt 2>&1 + * The output, with trailing white space removed from every line, is stored + * as the "output" string of the JSON file named above, since the dumps hold + * C's item names, which the spelling check rejects. The first two differ + * only in the lines deferred/oracle-rows.txt lists for this probe. The + * fourth adds the cases of open_knot_cases, which evaluate positions the + * splines do not cover, where the pinned C reads beyond its arrays, so they + * are not built against it. */ +#include +#include +#include +#include "ast.h" + +#define BAD AST__BAD + +static void head( const char *name ) { + printf( "== %s\n", name ); +} + +/* Reports a failed call, then clears the status. */ +static int failed( void ) { + if( !astOK ) { + printf( "status %d\n", astStatus ); + astClearStatus; + return 1; + } + return 0; +} + +static void show( AstObject *obj ) { + astShow( obj ); + failed(); +} + +/* Transforms npt points of two coordinates, given coordinate by coordinate + in "in", and prints one line per point. */ +static void tran( AstMapping *m, int npt, const double *in, int forward ) { + double out[ 2 * 32 ]; + astTranN( m, npt, 2, npt, in, forward, 2, npt, out ); + if( failed() ) return; + for( int i = 0; i < npt; i++ ) { + printf( "%s %.17g %.17g -> %.17g %.17g\n", forward ? "fwd" : "inv", + in[ i ], in[ npt + i ], out[ i ], out[ npt + i ] ); + } +} + +/* Transforms npt points forward, then the results in the inverse + direction. */ +static void roundtrip( AstMapping *m, int npt, const double *in ) { + double out[ 2 * 32 ]; + tran( m, npt, in, 1 ); + astTranN( m, npt, 2, npt, in, 1, 2, npt, out ); + if( failed() ) return; + tran( m, npt, out, 0 ); +} + +/* The class of the simplified Mapping, whether it is the Mapping itself, + and its dump. */ +static void simp( AstMapping *m ) { + AstMapping *s = astSimplify( m ); + if( failed() ) return; + printf( "-- simplified %s same %d\n", astGetC( s, "Class" ), astSame( s, m ) ); + show( (AstObject *) s ); +} + +static void equal( const char *label, AstObject *a, AstObject *b ) { + printf( "equal %s %d\n", label, astEqual( a, b ) ); + failed(); +} + +/* Each attribute of a SplineMap as a string, and whether it is set. */ +static void attrs( AstSplineMap *sm ) { + static const char *names[] = { "InvNiter", "InvTol", "OutUnit", "SplineKx", + "SplineKy", "SplineNx", "SplineNy" }; + for( int i = 0; i < 7; i++ ) { + const char *v = astGetC( sm, names[ i ] ); + if( failed() ) continue; + printf( "%s %s test %d\n", names[ i ], v, astTest( sm, names[ i ] ) ); + failed(); + } +} + +/* The IsSimple attribute of a Mapping. */ +static void issimple( const char *label, AstMapping *m ) { + printf( "IsSimple %s %d\n", label, astGetI( m, "IsSimple" ) ); + failed(); +} + +/* Records that a SplineMap has been simplified: astSimplify of a lone + SplineMap gives the SplineMap itself, flagged, and the extra reference + is annulled so that the SplineMap's attributes can still be set. */ +static void mark_simple( AstMapping *m ) { + AstMapping *s = astSimplify( m ); + if( !failed() ) astAnnul( s ); +} + +/* The knots of one axis, as many as the SplineMap has. */ +static void knots( AstSplineMap *sm, int axis ) { + double k[ 32 ]; + int n = axis == 1 ? astGetI( sm, "SplineNx" ) + astGetI( sm, "SplineKx" ) + : astGetI( sm, "SplineNy" ) + astGetI( sm, "SplineKy" ); + astSplineKnots( sm, axis, n, k ); + if( failed() ) return; + printf( "knots %d", axis ); + for( int i = 0; i < n; i++ ) printf( " %.17g", k[ i ] ); + printf( "\n" ); +} + +/* The coefficients of one output, as many as the SplineMap has. */ +static void coeffs( AstSplineMap *sm, int axis ) { + double c[ 64 ]; + int n = astGetI( sm, "SplineNx" ) * astGetI( sm, "SplineNy" ); + astSplineCoeffs( sm, axis, n, c ); + if( failed() ) return; + printf( "coeffs %d", axis ); + for( int i = 0; i < n; i++ ) printf( " %.17g", c[ i ] ); + printf( "\n" ); +} + +static void rate( AstMapping *m, double x, double y, int ax1, int ax2 ) { + double at[ 2 ] = { x, y }; + double r = astRate( m, at, ax1, ax2 ); + if( failed() ) return; + printf( "rate %.17g %.17g %d %d -> %.17g\n", x, y, ax1, ax2, r ); +} + +/* A bicubic SplineMap over [0, 3] x [0, 4.5] whose outputs are its inputs + perturbed by up to 0.03; the coefficients are in SciPy's order, the Y + index varying fastest, as astSplineMap takes them. */ +#define CUBIC_NX 5 +#define CUBIC_NY 6 +static const double cubic_tx[ CUBIC_NX + 4 ] = { 0.0, 0.0, 0.0, 0.0, 1.5, 3.0, 3.0, 3.0, 3.0 }; +static const double cubic_ty[ CUBIC_NY + 4 ] = { 0.0, 0.0, 0.0, 0.0, 1.5, 3.0, 4.5, 4.5, 4.5, 4.5 }; +static const double cubic_cu[ CUBIC_NX * CUBIC_NY ] = { + 0.00, 0.01, 0.02, 0.01, 0.00, -0.01, + 0.51, 0.52, 0.49, 0.50, 0.53, 0.50, + 1.52, 1.48, 1.50, 1.53, 1.49, 1.51, + 2.49, 2.51, 2.52, 2.48, 2.50, 2.52, + 3.01, 3.00, 2.99, 3.02, 3.01, 3.00 }; +static const double cubic_cv[ CUBIC_NX * CUBIC_NY ] = { + 0.01, 0.50, 1.52, 3.01, 3.98, 4.50, + 0.00, 0.52, 1.49, 2.99, 4.01, 4.51, + -0.01, 0.49, 1.50, 3.02, 4.02, 4.49, + 0.02, 0.51, 1.51, 2.98, 3.99, 4.50, + 0.00, 0.50, 1.48, 3.00, 4.00, 4.52 }; + +static AstSplineMap *cubic( void ) { + return astSplineMap( 4, 4, CUBIC_NX, CUBIC_NY, cubic_tx, cubic_ty, cubic_cu, + cubic_cv, " " ); +} + +/* The linear SplineMap u = 2x, v = 3y over the unit square, of + testsplinemap_c.c, with a single knot interval on each axis. */ +static AstSplineMap *linear( void ) { + double tk[ 4 ] = { 0.0, 0.0, 1.0, 1.0 }; + double cu[ 4 ] = { 0.0, 0.0, 2.0, 2.0 }; + double cv[ 4 ] = { 0.0, 3.0, 0.0, 3.0 }; + return astSplineMap( 2, 2, 2, 2, tk, tk, cu, cv, " " ); +} + +/* Writes a FrameSet FITS-WCS into a FitsChan holding NAXIS1 and NAXIS2 of + 1000, at FitsTol "tol" (the default if 0), and prints the number written + and the keywords of the cards. */ +static void fits_write( AstObject *fs, double tol, int cdmatrix ) { + char card[ 81 ]; + AstFitsChan *fc = astFitsChan( NULL, NULL, "Encoding=FITS-WCS" ); + if( tol > 0.0 ) astSetD( fc, "FitsTol", tol ); + if( cdmatrix ) astSetI( fc, "CDMatrix", 1 ); + astPutFits( fc, "NAXIS1 = 1000", 0 ); + astPutFits( fc, "NAXIS2 = 1000", 0 ); + int n = astWrite( fc, fs ); + if( failed() ) return; + printf( "written %d\n", n ); + astClear( fc, "Card" ); + printf( "keywords" ); + while( astFindFits( fc, "%f", card, 1 ) ) { + card[ 8 ] = 0; + for( int i = 7; i >= 0 && card[ i ] == ' '; i-- ) card[ i ] = 0; + printf( " %s", card ); + } + printf( "\n" ); + failed(); +} + +static AstObject *read_lsst2( void ) { + AstChannel *ch = astChannel( NULL, NULL, + "SourceFile=reference/starlink-ast/ast_tester/fixtures/wcsconv/inputs/lsst2.ast" ); + AstObject *obj = astRead( ch ); + failed(); + return obj; +} + +static void class_cases( void ) { + AstSplineMap *sm = cubic(); + + head( "isa" ); + printf( "IsASplineMap %d IsAMapping %d Nin %d Nout %d IsLinear %d\n", + astIsASplineMap( sm ), astIsAMapping( sm ), astGetI( sm, "Nin" ), + astGetI( sm, "Nout" ), astGetI( sm, "IsLinear" ) ); + show( (AstObject *) sm ); + + head( "ctor_errors" ); + { + double t4[ 4 ] = { 0.0, 0.0, 1.0, 1.0 }; + double tbad[ 4 ] = { 0.0, 1.0, 0.5, 1.0 }; + double c4[ 4 ] = { 0.0, 0.0, 0.0, 0.0 }; + double t14[ 14 ] = { 0 }; + double c49[ 49 ] = { 0 }; + astSplineMap( 0, 2, 2, 2, t4, t4, c4, c4, " " ); + failed(); + astSplineMap( 7, 7, 7, 7, t14, t14, c49, c49, " " ); + failed(); + astSplineMap( 2, 0, 2, 2, t4, t4, c4, c4, " " ); + failed(); + astSplineMap( 2, 7, 2, 7, t4, t14, c49, c49, " " ); + failed(); + astSplineMap( 2, 2, 1, 2, t4, t4, c4, c4, " " ); + failed(); + astSplineMap( 2, 2, 2, 1, t4, t4, c4, c4, " " ); + failed(); + astSplineMap( 2, 2, 2, 2, tbad, t4, c4, c4, " " ); + failed(); + astSplineMap( 2, 2, 2, 2, t4, tbad, c4, c4, " " ); + failed(); + astSplineMap( 2, 2, 2, 2, tbad, tbad, c4, c4, " " ); + failed(); + } + + head( "attrs_default" ); + attrs( sm ); + + head( "attrs_set" ); + astSet( sm, "InvNiter=10, InvTol=1.0E-8, OutUnit=1" ); + failed(); + attrs( sm ); + show( (AstObject *) sm ); + astSetI( sm, "OutUnit", 5 ); + astSetI( sm, "InvNiter", -3 ); + failed(); + attrs( sm ); + astSetD( sm, "InvTol", BAD ); + failed(); + attrs( sm ); + astClear( sm, "InvNiter" ); + astClear( sm, "InvTol" ); + astClear( sm, "OutUnit" ); + failed(); + attrs( sm ); + show( (AstObject *) sm ); + + head( "attrs_readonly" ); + astSet( sm, "SplineKx=3" ); + failed(); + astSetI( sm, "SplineNy", 3 ); + failed(); + astClear( sm, "SplineKy" ); + failed(); + astClear( sm, "SplineNx" ); + failed(); + printf( "test %d %d %d %d\n", astTest( sm, "SplineKx" ), astTest( sm, "SplineKy" ), + astTest( sm, "SplineNx" ), astTest( sm, "SplineNy" ) ); + failed(); + + head( "attrs_shared" ); + { + AstCmpMap *cmp = astCmpMap( sm, astUnitMap( 2, " " ), 1, " " ); + astSetI( sm, "InvNiter", 3 ); + failed(); + astSetD( sm, "InvTol", 1.0e-3 ); + failed(); + astClear( sm, "OutUnit" ); + failed(); + attrs( sm ); + astAnnul( cmp ); + } + + head( "issimple" ); + { + static const char *settings[] = { "InvNiter=6", "InvTol=1.0E-6", "OutUnit=0" }; + static const char *names[] = { "InvNiter", "InvTol", "OutUnit" }; + for( int i = 0; i < 3; i++ ) { + AstSplineMap *s = cubic(); + mark_simple( (AstMapping *) s ); + issimple( "marked", (AstMapping *) s ); + astSet( s, "%s", settings[ i ] ); + issimple( settings[ i ], (AstMapping *) s ); + mark_simple( (AstMapping *) s ); + astSet( s, "%s", settings[ i ] ); + issimple( "same value", (AstMapping *) s ); + astClear( s, names[ i ] ); + issimple( "cleared", (AstMapping *) s ); + mark_simple( (AstMapping *) s ); + astClear( s, names[ i ] ); + issimple( "cleared again", (AstMapping *) s ); + failed(); + } + } + { + AstSplineMap *s = cubic(); + mark_simple( (AstMapping *) s ); + astSet( s, "OutUnit=1" ); + mark_simple( (AstMapping *) s ); + astSet( s, "OutUnit=7" ); + issimple( "OutUnit=7 after 1", (AstMapping *) s ); + astSet( s, "InvNiter=-3" ); + mark_simple( (AstMapping *) s ); + astSetD( s, "InvTol", BAD ); + issimple( "InvTol bad while unset", (AstMapping *) s ); + astInvert( s ); + issimple( "inverted", (AstMapping *) s ); + astInvert( s ); + issimple( "inverted back", (AstMapping *) s ); + failed(); + } +} + +static void transform_cases( void ) { + AstSplineMap *sm; + + head( "tran_inside" ); + { + double in[] = { 0.25, 1.0, 1.5, 2.2, 2.9, 0.1, + 0.3, 2.0, 1.5, 4.4, 0.05, 3.7 }; + sm = cubic(); + roundtrip( (AstMapping *) sm, 6, in ); + } + + head( "tran_outside" ); + { + double in[] = { -0.5, 3.5, 1.0, 1.0, 0.0, 3.0, 0.0, 3.0, 1.0, 3.0, BAD, 1.0, + 1.0, 1.0, -0.5, 5.0, 0.0, 4.5, 4.5, 0.0, 4.5, 2.0, 1.0, BAD }; + double inv[] = { -0.5, 3.5, 1.0, 1.0, 3.0, 3.01, 0.0, -0.01, 2.99, + 1.0, 1.0, -0.5, 5.0, 4.5, 4.52, 0.0, 0.0, 4.49 }; + sm = cubic(); + tran( (AstMapping *) sm, 12, in, 1 ); + tran( (AstMapping *) sm, 9, inv, 0 ); + astSetI( sm, "OutUnit", 1 ); + tran( (AstMapping *) sm, 12, in, 1 ); + tran( (AstMapping *) sm, 9, inv, 0 ); + astInvert( sm ); + tran( (AstMapping *) sm, 9, inv, 1 ); + tran( (AstMapping *) sm, 12, in, 0 ); + } + + head( "tran_linear_edges" ); + { + double in[] = { 0.0, 1.0, 1.0, 0.5, 0.0, 1.0, + 0.0, 1.0, 0.5, 1.0, 1.0, 0.0 }; + double inv[] = { 0.0, 2.0, 2.0, 1.0, 1.9999999, 1.5, + 0.0, 3.0, 1.5, 3.0, 1.5, 2.9999999 }; + sm = linear(); + tran( (AstMapping *) sm, 6, in, 1 ); + tran( (AstMapping *) sm, 6, inv, 0 ); + astSetI( sm, "OutUnit", 1 ); + tran( (AstMapping *) sm, 6, in, 1 ); + tran( (AstMapping *) sm, 6, inv, 0 ); + } + + /* Knots along X that are not repeated at the ends: the spline of order + 2 with 3 coefficients is defined from knot 2 to knot 4 (1 to 3), + inside the box of the knots (0 to 4). */ + head( "tran_open_knots_x" ); + { + double tx[ 5 ] = { 0.0, 1.0, 2.0, 3.0, 4.0 }; + double ty[ 4 ] = { 0.0, 0.0, 1.0, 1.0 }; + double cu[ 6 ] = { 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 }; + double cv[ 6 ] = { 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 }; + double in[] = { -0.5, 0.0, 0.5, 1.0, 1.5, 2.0, 3.0, 3.5, 4.0, 4.5, + 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 }; + double inv[] = { 1.5, 2.5, 0.5, 3.5, + 0.5, 0.5, 0.5, 0.5 }; + sm = astSplineMap( 2, 2, 3, 2, tx, ty, cu, cv, " " ); + tran( (AstMapping *) sm, 10, in, 1 ); + tran( (AstMapping *) sm, 4, inv, 0 ); + astSetI( sm, "OutUnit", 1 ); + tran( (AstMapping *) sm, 10, in, 1 ); + tran( (AstMapping *) sm, 4, inv, 0 ); + rate( (AstMapping *) sm, 0.5, 0.5, 1, 1 ); + rate( (AstMapping *) sm, 2.0, 0.5, 1, 1 ); + } + + /* Knots along X whose covered range has zero width: of order 2 with + knots 0, 1, 1, 2 and of order 1 with knots 1, 1, each covering only + x = 1. On that limit the pinned C's Dbvalu steps back to the first + knot interval, of zero width, and evaluates it (0/0 for order 2); the + hardening PR gives bad there. */ + head( "tran_zero_width_x" ); + { + double tx2[ 4 ] = { 0.0, 1.0, 1.0, 2.0 }; + double tx1[ 2 ] = { 1.0, 1.0 }; + double ty[ 4 ] = { 0.0, 0.0, 1.0, 1.0 }; + double cu2[ 4 ] = { 0.0, 0.0, 2.0, 2.0 }; + double cv2[ 4 ] = { 0.0, 3.0, 0.0, 3.0 }; + double cu1[ 2 ] = { 1.5, 1.5 }; + double cv1[ 2 ] = { 0.0, 3.0 }; + double in[] = { 1.0, 1.0, 1.0, 0.0, 0.25, 0.5 }; + sm = astSplineMap( 2, 2, 2, 2, tx2, ty, cu2, cv2, " " ); + tran( (AstMapping *) sm, 3, in, 1 ); + for( int ax1 = 1; ax1 <= 2; ax1++ ) { + for( int ax2 = 1; ax2 <= 2; ax2++ ) { + rate( (AstMapping *) sm, 1.0, 0.5, ax1, ax2 ); + } + } + sm = astSplineMap( 1, 2, 1, 2, tx1, ty, cu1, cv1, " " ); + tran( (AstMapping *) sm, 3, in, 1 ); + for( int ax1 = 1; ax1 <= 2; ax1++ ) { + for( int ax2 = 1; ax2 <= 2; ax2++ ) { + rate( (AstMapping *) sm, 1.0, 0.5, ax1, ax2 ); + } + } + } + + head( "inv_iterations" ); + { + double in[] = { 0.25, 1.0, 1.5, 2.2, 2.9, 0.0, 3.0, 2.0, + 0.3, 2.0, 1.5, 4.4, 0.05, 2.0, 2.0, 0.0 }; + double out[ 16 ]; + sm = cubic(); + astTranN( sm, 8, 2, 8, in, 1, 2, 8, out ); + failed(); + static const char *settings[] = { "InvNiter=1", "InvNiter=2", "InvNiter=3", + "InvNiter=1, InvTol=1.0E-3", + "InvNiter=2, InvTol=0.1", + "InvNiter=6, InvTol=1.0E-14", + "InvNiter=20, InvTol=1.0E-17", + "InvNiter=0", "InvNiter=-3", + "InvTol=0", "InvTol=-1", + "InvNiter=1, OutUnit=1", + "InvNiter=2, OutUnit=1" }; + for( int i = 0; i < 13; i++ ) { + astClear( sm, "InvNiter,InvTol,OutUnit" ); + astSet( sm, "%s", settings[ i ] ); + printf( "-- %s\n", settings[ i ] ); + tran( (AstMapping *) sm, 8, out, 0 ); + } + } + + /* Positions whose inverse leaves the knots, where the guesses are + held to the knots, with OutUnit unset and set. */ + head( "inv_outside" ); + { + double inv[] = { -0.02, 3.02, 3.0, 1.0, 0.0, -1.0, 4.0, 1.5, + 1.0, 1.0, 4.52, -0.02, 0.0, 2.0, 5.0, 4.6 }; + sm = cubic(); + tran( (AstMapping *) sm, 8, inv, 0 ); + astSet( sm, "InvNiter=20" ); + tran( (AstMapping *) sm, 8, inv, 0 ); + astClear( sm, "InvNiter" ); + astSetI( sm, "OutUnit", 1 ); + tran( (AstMapping *) sm, 8, inv, 0 ); + } + + head( "order1" ); + { + double tx1[ 2 ] = { 0.0, 1.0 }; + double cu1[ 1 ] = { 1.5 }; + double cv1[ 1 ] = { 2.5 }; + double in[] = { 0.5, 0.0, 1.0, 1.5, 0.5, 0.0, 1.0, 0.5 }; + sm = astSplineMap( 1, 1, 1, 1, tx1, tx1, cu1, cv1, " " ); + tran( (AstMapping *) sm, 4, in, 1 ); + tran( (AstMapping *) sm, 4, in, 0 ); + astSetI( sm, "OutUnit", 1 ); + tran( (AstMapping *) sm, 4, in, 0 ); + rate( (AstMapping *) sm, 0.5, 0.5, 1, 1 ); + rate( (AstMapping *) sm, 0.5, 0.5, 2, 1 ); + } + + head( "rate" ); + sm = cubic(); + for( int ax1 = 1; ax1 <= 2; ax1++ ) { + for( int ax2 = 1; ax2 <= 2; ax2++ ) { + rate( (AstMapping *) sm, 1.2, 2.7, ax1, ax2 ); + rate( (AstMapping *) sm, 3.0, 4.5, ax1, ax2 ); + rate( (AstMapping *) sm, -1.0, 2.0, ax1, ax2 ); + } + } + rate( (AstMapping *) sm, BAD, 2.0, 1, 1 ); + rate( (AstMapping *) sm, 1.0, 2.0, 3, 1 ); + rate( (AstMapping *) sm, 1.0, 2.0, 1, 0 ); + astSetI( sm, "OutUnit", 1 ); + for( int ax1 = 1; ax1 <= 2; ax1++ ) { + for( int ax2 = 1; ax2 <= 2; ax2++ ) { + rate( (AstMapping *) sm, -1.0, 2.0, ax1, ax2 ); + } + } + astClear( sm, "OutUnit" ); + astInvert( sm ); + for( int ax1 = 1; ax1 <= 2; ax1++ ) { + for( int ax2 = 1; ax2 <= 2; ax2++ ) { + rate( (AstMapping *) sm, 1.2, 2.7, ax1, ax2 ); + } + } + + head( "rate_testsplinemap" ); + sm = linear(); + rate( (AstMapping *) sm, 0.5, 0.5, 1, 1 ); + astInvert( sm ); + rate( (AstMapping *) sm, 1.0, 1.5, 1, 1 ); + rate( (AstMapping *) sm, 1.0, 1.5, 1, 2 ); +} + +static void accessor_cases( void ) { + AstSplineMap *sm = cubic(); + + head( "knots_coeffs" ); + for( int axis = 0; axis <= 3; axis++ ) { + knots( sm, axis ); + coeffs( sm, axis ); + } + astInvert( sm ); + knots( sm, 1 ); + coeffs( sm, 2 ); +} + +static void simplify_cases( void ) { + AstSplineMap *sm = cubic(); + AstSplineMap *smi = astCopy( sm ); + AstSplineMap *other = cubic(); + AstCmpMap *cmp; + double win_a[ 2 ] = { 0.0, 0.0 }, win_b[ 2 ] = { 1.0, 1.0 }; + double win_c[ 2 ] = { 1.0, 2.0 }, win_d[ 2 ] = { 3.0, 5.0 }; + double pt[] = { 1.2, 2.7 }; + + astInvert( smi ); + + head( "simp_inverse_after" ); + simp( (AstMapping *) astCmpMap( sm, smi, 1, " " ) ); + + head( "simp_inverse_before" ); + simp( (AstMapping *) astCmpMap( smi, sm, 1, " " ) ); + + head( "simp_same_direction" ); + simp( (AstMapping *) astCmpMap( sm, astCopy( sm ), 1, " " ) ); + + head( "simp_parallel" ); + simp( (AstMapping *) astCmpMap( sm, smi, 0, " " ) ); + + head( "simp_winmap" ); + simp( (AstMapping *) astCmpMap( sm, astWinMap( 2, win_a, win_b, win_c, win_d, " " ), 1, " " ) ); + simp( (AstMapping *) astCmpMap( astWinMap( 2, win_a, win_b, win_c, win_d, " " ), sm, 1, " " ) ); + + head( "simp_unit_between" ); + simp( (AstMapping *) astCmpMap( astCmpMap( sm, astUnitMap( 2, " " ), 1, " " ), smi, 1, " " ) ); + + head( "simp_different_coeffs" ); + { + AstSplineMap *lin = linear(); + astInvert( lin ); + simp( (AstMapping *) astCmpMap( sm, lin, 1, " " ) ); + } + + head( "simp_outunit_differs" ); + { + AstSplineMap *ou = astCopy( smi ); + astSetI( ou, "OutUnit", 1 ); + astSetI( ou, "InvNiter", 2 ); + simp( (AstMapping *) astCmpMap( sm, ou, 1, " " ) ); + } + + /* The SplineMaps are shared with the CmpMap: what the simplification + leaves in their Invert attributes, and what the CmpMap then gives. */ + head( "simp_inverted_cmpmap" ); + { + AstSplineMap *a = cubic(); + AstSplineMap *b = cubic(); + astInvert( b ); + cmp = astCmpMap( a, b, 1, " " ); + astInvert( cmp ); + tran( (AstMapping *) cmp, 1, pt, 1 ); + printf( "Invert a %d test %d b %d test %d\n", astGetI( a, "Invert" ), + astTest( a, "Invert" ), astGetI( b, "Invert" ), astTest( b, "Invert" ) ); + simp( (AstMapping *) cmp ); + printf( "Invert a %d test %d b %d test %d\n", astGetI( a, "Invert" ), + astTest( a, "Invert" ), astGetI( b, "Invert" ), astTest( b, "Invert" ) ); + tran( (AstMapping *) cmp, 1, pt, 1 ); + } + head( "simp_cmpmap_attrs" ); + { + AstSplineMap *a = cubic(); + AstSplineMap *b = cubic(); + astInvert( b ); + cmp = astCmpMap( a, b, 1, " " ); + simp( (AstMapping *) cmp ); + printf( "Invert a %d test %d b %d test %d\n", astGetI( a, "Invert" ), + astTest( a, "Invert" ), astGetI( b, "Invert" ), astTest( b, "Invert" ) ); + a = cubic(); + b = cubic(); + astInvert( b ); + cmp = astCmpMap( b, a, 1, " " ); + simp( (AstMapping *) cmp ); + printf( "Invert b %d test %d a %d test %d\n", astGetI( b, "Invert" ), + astTest( b, "Invert" ), astGetI( a, "Invert" ), astTest( a, "Invert" ) ); + } + + head( "equal" ); + equal( "copy", (AstObject *) sm, astCopy( sm ) ); + equal( "same values", (AstObject *) sm, (AstObject *) other ); + equal( "inverted", (AstObject *) sm, (AstObject *) smi ); + { + AstSplineMap *twice = astCopy( smi ); + astInvert( twice ); + equal( "inverted twice", (AstObject *) sm, (AstObject *) twice ); + astSet( other, "OutUnit=1, InvNiter=2, InvTol=0.5" ); + equal( "attributes differ", (AstObject *) sm, (AstObject *) other ); + equal( "different", (AstObject *) sm, (AstObject *) linear() ); + equal( "unitmap", (AstObject *) sm, (AstObject *) astUnitMap( 2, " " ) ); + } + { + double cu[ CUBIC_NX * CUBIC_NY ], cv[ CUBIC_NX * CUBIC_NY ], tx[ CUBIC_NX + 4 ]; + memcpy( cu, cubic_cu, sizeof cu ); + memcpy( cv, cubic_cv, sizeof cv ); + memcpy( tx, cubic_tx, sizeof tx ); + cu[ 7 ] += 1.0e-13; + equal( "coefficient within tolerance", (AstObject *) sm, + (AstObject *) astSplineMap( 4, 4, CUBIC_NX, CUBIC_NY, cubic_tx, cubic_ty, cu, cv, " " ) ); + cu[ 7 ] += 1.0e-9; + equal( "coefficient beyond tolerance", (AstObject *) sm, + (AstObject *) astSplineMap( 4, 4, CUBIC_NX, CUBIC_NY, cubic_tx, cubic_ty, cu, cv, " " ) ); + tx[ 4 ] = 1.6; + equal( "knot", (AstObject *) sm, + (AstObject *) astSplineMap( 4, 4, CUBIC_NX, CUBIC_NY, tx, cubic_ty, cubic_cu, cubic_cv, " " ) ); + } +} + +static void load_cases( void ) { + head( "load_roundtrip" ); + { + AstSplineMap *sm = cubic(); + astSet( sm, "InvNiter=9, InvTol=1.0E-9, OutUnit=1" ); + astInvert( sm ); + mark_simple( (AstMapping *) sm ); + char *text = astToString( sm ); + AstObject *back = astFromString( text ); + if( !failed() ) { + show( back ); + issimple( "loaded", (AstMapping *) back ); + equal( "loaded", back, (AstObject *) sm ); + attrs( (AstSplineMap *) back ); + } + text = astFree( text ); + } + head( "load_defaults" ); + { + AstObject *o = astFromString( " Begin SplineMap\n Nin = 2\n IsA Mapping\n" + " KX = 1\n KY = 1\n NX = 1\n NY = 1\n" + " TX1 = 0\n TX2 = 1\n TY1 = 0\n TY2 = 2\n" + " CU1 = 4\n End SplineMap\n" ); + if( !failed() ) { + double in[] = { 0.5, 0.5 }; + show( o ); + attrs( (AstSplineMap *) o ); + tran( (AstMapping *) o, 1, in, 1 ); + } + } +} + +static void fits_cases( void ) { + AstFrameSet *fs; + + head( "fits_lsst2_tight" ); + fs = (AstFrameSet *) read_lsst2(); + fits_write( (AstObject *) fs, 1.0e-4, 0 ); + + head( "fits_lsst2_default" ); + fits_write( (AstObject *) fs, 0.0, 0 ); + + head( "fits_lsst2_wrapped" ); + { + AstFrame *detector = astFrame( 2, "Ident=detector" ); + AstFrameSet *outer = astFrameSet( detector, " " ); + int sky; + astAddFrame( outer, AST__BASE, fs, astSkyFrame( " " ) ); + sky = astGetI( outer, "Nframe" ); + astAddFrame( outer, AST__BASE, astShiftMap( 2, (double[]){ 1.0, 1.0 }, " " ), + astFrame( 2, "Domain=GRID" ) ); + astSetI( outer, "Base", astGetI( outer, "Nframe" ) ); + astSetI( outer, "Current", sky ); + failed(); + fits_write( (AstObject *) outer, 1.0e-4, 1 ); + } + + head( "fits_lsst2_alternate" ); + { + AstFrameSet *alt = (AstFrameSet *) read_lsst2(); + int sky = astGetI( alt, "Nframe" ); + astAddFrame( alt, AST__BASE, astUnitMap( 2, " " ), astFrame( 2, "Domain=MYALT,Ident=A" ) ); + astSetI( alt, "Current", sky ); + failed(); + fits_write( (AstObject *) alt, 0.0, 0 ); + fits_write( (AstObject *) alt, 1.0e-4, 0 ); + } +} + +#ifdef PR104 +/* Positions within the knots that the splines do not cover, which the + pinned C evaluates from bad values combined arithmetically along X, or + from coefficients and knots beyond its arrays along Y; built only + against the hardening PR's library (-DPR104), which gives the default + value there. */ +static void open_knot_cases( void ) { + AstSplineMap *sm; + + /* Knots along X not repeated at the ends, as in tran_open_knots_x, + at fractional y. */ + head( "pr_open_knots_x" ); + { + double tx[ 5 ] = { 0.0, 1.0, 2.0, 3.0, 4.0 }; + double ty[ 4 ] = { 0.0, 0.0, 1.0, 1.0 }; + double cu[ 6 ] = { 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 }; + double cv[ 6 ] = { 0.0, 1.0, 0.0, 1.0, 0.0, 1.0 }; + double in[] = { 0.5, 0.5, 0.5, 3.5, 0.0, 4.0, 2.0, 1.0, 3.0, + 0.1, 0.3, 0.7, 0.3, 0.7, 0.3, 0.3, 0.6, 0.6 }; + double inv[] = { 0.4, 3.6, 2.5, 1.0, 3.0, + 0.3, 0.3, 0.3, 0.7, 0.7 }; + sm = astSplineMap( 2, 2, 3, 2, tx, ty, cu, cv, " " ); + tran( (AstMapping *) sm, 9, in, 1 ); + tran( (AstMapping *) sm, 5, inv, 0 ); + rate( (AstMapping *) sm, 0.5, 0.3, 1, 1 ); + rate( (AstMapping *) sm, 0.5, 0.3, 2, 2 ); + astSetI( sm, "OutUnit", 1 ); + tran( (AstMapping *) sm, 9, in, 1 ); + tran( (AstMapping *) sm, 5, inv, 0 ); + rate( (AstMapping *) sm, 0.5, 0.3, 1, 1 ); + rate( (AstMapping *) sm, 0.5, 0.3, 2, 2 ); + } + + /* Knots along Y not repeated at the ends: the spline of order 2 with + 3 coefficients covers y from 1 to 3 of the knots' 0 to 4; y = 3 is + the upper limit of what it covers but not of the knots. */ + head( "pr_open_knots_y" ); + { + double tx[ 4 ] = { 0.0, 0.0, 4.0, 4.0 }; + double ty[ 5 ] = { 0.0, 1.0, 2.0, 3.0, 4.0 }; + double cu[ 6 ] = { 0.0, 0.0, 0.0, 4.0, 4.0, 4.0 }; + double cv[ 6 ] = { 1.0, 2.0, 3.0, 1.0, 2.0, 3.0 }; + double in[] = { 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 0.0, 4.0, 4.0, 2.0, + 0.5, 1.0, 2.0, 2.5, 3.0, 3.5, 4.0, 2.0, 2.0, 3.0, 5.0 }; + double inv[] = { 2.0, 2.0, 2.0, 1.0, 4.0, + 2.0, 2.5, 0.5, 2.9999, 3.0 }; + sm = astSplineMap( 2, 2, 2, 3, tx, ty, cu, cv, " " ); + tran( (AstMapping *) sm, 11, in, 1 ); + tran( (AstMapping *) sm, 5, inv, 0 ); + rate( (AstMapping *) sm, 2.0, 3.0, 2, 2 ); + rate( (AstMapping *) sm, 2.0, 0.5, 2, 2 ); + astSetI( sm, "OutUnit", 1 ); + tran( (AstMapping *) sm, 11, in, 1 ); + tran( (AstMapping *) sm, 5, inv, 0 ); + rate( (AstMapping *) sm, 2.0, 3.0, 2, 2 ); + rate( (AstMapping *) sm, 2.0, 0.5, 2, 2 ); + } +} +#endif + +int main( void ) { + setvbuf( stdout, NULL, _IONBF, 0 ); + astBegin; + class_cases(); + transform_cases(); + accessor_cases(); + simplify_cases(); + load_cases(); + fits_cases(); +#ifdef PR104 + open_knot_cases(); +#endif + astEnd; + return 0; +} diff --git a/src/test/resources/probes/splinemap_probe.json b/src/test/resources/probes/splinemap_probe.json new file mode 100644 index 0000000..b2a913d --- /dev/null +++ b/src/test/resources/probes/splinemap_probe.json @@ -0,0 +1,4 @@ +{ + "source": "probes/splinemap_probe.c", + "output": "== isa\nIsASplineMap 1 IsAMapping 1 Nin 2 Nout 2 IsLinear 0\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n== ctor_errors\n!! AST: Error in routine class_cases at line 252 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied spline order in the X direction (0) is invalid - it must be in the range [1,6].\nstatus 233933170\n!! AST: Error in routine class_cases at line 254 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied spline order in the X direction (7) is invalid - it must be in the range [1,6].\nstatus 233933170\n!! AST: Error in routine class_cases at line 256 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied spline order in the Y direction (0) is invalid - it must be in the range [1,6].\nstatus 233933170\n!! AST: Error in routine class_cases at line 258 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied spline order in the Y direction (7) is invalid - it must be in the range [1,6].\nstatus 233933170\n!! AST: Error in routine class_cases at line 260 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied number of coefficients in the X direction (1) is too small - it must be larger than or equal to 2.\nstatus 233933170\n!! AST: Error in routine class_cases at line 262 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied number of coefficients in the Y direction (1) is too small - it must be larger than or equal to 2.\nstatus 233933170\n!! AST: Error in routine class_cases at line 264 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied knots in the X direction are not monotonic increasing.\nstatus 233933170\n!! AST: Error in routine class_cases at line 266 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied knots in the Y direction are not monotonic increasing.\nstatus 233933170\n!! AST: Error in routine class_cases at line 268 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied knots in the X direction are not monotonic increasing.\nstatus 233933170\n== attrs_default\nInvNiter 6 test 0\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 0 test 0\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n== attrs_set\nInvNiter 10 test 1\nInvTol 1e-08 test 1\nOutUnit 1 test 1\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n NiterInv = 10 \t# Max number of iterations for iterative inverse\n OutUnit = 1 \t# How to handle out-of-bounds points\n TolInv = 1e-08 \t# Target relative error for iterative inverse\n End SplineMap\nInvNiter -3 test 1\nInvTol 1e-08 test 1\nOutUnit 1 test 1\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\nInvNiter -3 test 1\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 1 test 1\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\nInvNiter 6 test 0\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 0 test 0\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n== attrs_readonly\n!! AST: Error in routine class_cases at line 295 in file src/test/resources/probes/splinemap_probe.c.\n! astSet: The setting \"splinekx=3\" is invalid for a SplineMap.\n! This is a read-only attribute.\nstatus 233933578\n!! AST: Error in routine class_cases at line 297 in file src/test/resources/probes/splinemap_probe.c.\n! astSet: The setting \"splineny=3\" is invalid for a SplineMap.\n! This is a read-only attribute.\nstatus 233933578\n!! AST: Error in routine class_cases at line 299 in file src/test/resources/probes/splinemap_probe.c.\n! astClear: Invalid attempt to clear the \"splineky\" value for a SplineMap.\n! This is a read-only attribute.\nstatus 233933578\n!! AST: Error in routine class_cases at line 301 in file src/test/resources/probes/splinemap_probe.c.\n! astClear: Invalid attempt to clear the \"splinenx\" value for a SplineMap.\n! This is a read-only attribute.\nstatus 233933578\ntest 0 0 0 0\n== attrs_shared\n!! AST: Error in routine class_cases at line 310 in file src/test/resources/probes/splinemap_probe.c.\n! astSet(SplineMap): The InvNiterattribute of the supplied SplineMap cannot be changed because the SplineMap has been cloned (programming error).\nstatus 233934418\n!! AST: Error in routine class_cases at line 312 in file src/test/resources/probes/splinemap_probe.c.\n! astSet(SplineMap): The InvTolattribute of the supplied SplineMap cannot be changed because the SplineMap has been cloned (programming error).\nstatus 233934418\n!! AST: Error in routine class_cases at line 314 in file src/test/resources/probes/splinemap_probe.c.\n! astClear(SplineMap): The OutUnitattribute of the supplied SplineMap cannot be cleared because the SplineMap has been cloned (programming error).\nstatus 233934418\nInvNiter 6 test 0\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 0 test 0\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n== issimple\nIsSimple marked 1\nIsSimple InvNiter=6 0\nIsSimple same value 1\nIsSimple cleared 0\nIsSimple cleared again 0\nIsSimple marked 1\nIsSimple InvTol=1.0E-6 0\nIsSimple same value 1\nIsSimple cleared 0\nIsSimple cleared again 0\nIsSimple marked 1\nIsSimple OutUnit=0 0\nIsSimple same value 1\nIsSimple cleared 0\nIsSimple cleared again 0\nIsSimple OutUnit=7 after 1 1\nIsSimple InvTol bad while unset 1\nIsSimple inverted 0\nIsSimple inverted back 1\n== tran_inside\nfwd 0.25 0.29999999999999999 -> 0.25827344135802466 0.30636676697530862\nfwd 1 2 -> 1.0024565614997714 1.9990249199817101\nfwd 1.5 1.5 -> 1.5025000000000002 1.5010416666666668\nfwd 2.2000000000000002 4.4000000000000004 -> 2.2116397807407409 4.3996876820484694\nfwd 2.8999999999999999 0.050000000000000003 -> 2.9059816087517145 0.053345760784179248\nfwd 0.10000000000000001 3.7000000000000002 -> 0.10507215246456331 3.6940085707178785\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999999999994 0.29999999999999999\ninv 1.0024565614997714 1.9990249199817101 -> 1 2\ninv 1.5025000000000002 1.5010416666666668 -> 1.5000000000000004 1.5000000000000002\ninv 2.2116397807407409 4.3996876820484694 -> 2.2000000000000006 4.4000000000000012\ninv 2.9059816087517145 0.053345760784179248 -> 2.8999999999999999 0.050000000000000003\ninv 0.10507215246456331 3.6940085707178785 -> 0.099999999999999978 3.6999999999999997\n== tran_outside\nfwd -0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 3.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 0 -> 0 0.01\nfwd 3 4.5 -> 3 4.5199999999999996\nfwd 0 4.5 -> -0.01 4.5\nfwd 3 0 -> 3.0099999999999998 0\nfwd 1 4.5 -> 1.0048148148148146 4.5014814814814814\nfwd 3 2 -> 3.0019444444444443 1.9890123456790123\nfwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 -0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5 -> 2.9996029999260014 4.4807747790225338\ninv 3.0099999999999998 4.5199999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.01 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9900000000000002 4.4900000000000002 -> 2.989038575953578 4.4715407702744541\nfwd -0.5 1 -> -0.5 1\nfwd 3.5 1 -> 3.5 1\nfwd 1 -0.5 -> 1 -0.5\nfwd 1 5 -> 1 5\nfwd 0 0 -> 0 0.01\nfwd 3 4.5 -> 3 4.5199999999999996\nfwd 0 4.5 -> -0.01 4.5\nfwd 3 0 -> 3.0099999999999998 0\nfwd 1 4.5 -> 1.0048148148148146 4.5014814814814814\nfwd 3 2 -> 3.0019444444444443 1.9890123456790123\nfwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 -0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5 -> 2.9996029999260014 4.4807747790225338\ninv 3.0099999999999998 4.5199999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.01 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9900000000000002 4.4900000000000002 -> 2.989038575953578 4.4715407702744541\nfwd -0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 3.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 3 4.5 -> 2.9996029999260014 4.4807747790225338\nfwd 3.0099999999999998 4.5199999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd -0.01 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 2.9900000000000002 4.4900000000000002 -> 2.989038575953578 4.4715407702744541\ninv -0.5 1 -> -0.5 1\ninv 3.5 1 -> 3.5 1\ninv 1 -0.5 -> 1 -0.5\ninv 1 5 -> 1 5\ninv 0 0 -> 0 0.01\ninv 3 4.5 -> 3 4.5199999999999996\ninv 0 4.5 -> -0.01 4.5\ninv 3 0 -> 3.0099999999999998 0\ninv 1 4.5 -> 1.0048148148148146 4.5014814814814814\ninv 3 2 -> 3.0019444444444443 1.9890123456790123\ninv -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n== tran_linear_edges\nfwd 0 0 -> 0 0\nfwd 1 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0.5 -> 2 1.5\nfwd 0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0 -> 2 0\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2 3 -> 0.99999999999999989 0.99999999999999989\ninv 2 1.5 -> 0.99999999999999989 0.5\ninv 1 3 -> 0.5 0.99999999999999989\ninv 1.9999998999999999 1.5 -> 0.99999994999999997 0.5\ninv 1.5 2.9999999000000002 -> 0.75 0.99999996666666668\nfwd 0 0 -> 0 0\nfwd 1 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0.5 -> 2 1.5\nfwd 0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0 -> 2 0\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2 3 -> 0.99999999999999989 0.99999999999999989\ninv 2 1.5 -> 0.99999999999999989 0.5\ninv 1 3 -> 0.5 0.99999999999999989\ninv 1.9999998999999999 1.5 -> 0.99999994999999997 0.5\ninv 1.5 2.9999999000000002 -> 0.75 0.99999996666666668\n== tran_open_knots_x\nfwd -0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0.5 -> 1 0.5\nfwd 1.5 0.5 -> 1.5 0.5\nfwd 2 0.5 -> 2 0.5\nfwd 3 0.5 -> 3 0.5\nfwd 3.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 4 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 4.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 0.5 -> 1.5 0.5\ninv 2.5 0.5 -> 2.5 0.5\ninv 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd -0.5 0.5 -> -0.5 0.5\nfwd 0 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0.5 -> 1 0.5\nfwd 1.5 0.5 -> 1.5 0.5\nfwd 2 0.5 -> 2 0.5\nfwd 3 0.5 -> 3 0.5\nfwd 3.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 4 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 4.5 0.5 -> 4.5 0.5\ninv 1.5 0.5 -> 1.5 0.5\ninv 2.5 0.5 -> 2.5 0.5\ninv 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nrate 0.5 0.5 1 1 -> -1.7976931348623157e+308\nrate 2 0.5 1 1 -> 1\n== tran_zero_width_x\nfwd 1 0 -> nan nan\nfwd 1 0.25 -> nan nan\nfwd 1 0.5 -> nan nan\nrate 1 0.5 1 1 -> inf\nrate 1 0.5 1 2 -> nan\nrate 1 0.5 2 1 -> nan\nrate 1 0.5 2 2 -> nan\nfwd 1 0 -> 1.5 0\nfwd 1 0.25 -> 1.5 0.75\nfwd 1 0.5 -> 1.5 1.5\nrate 1 0.5 1 1 -> 0\nrate 1 0.5 1 2 -> 0\nrate 1 0.5 2 1 -> 0\nrate 1 0.5 2 2 -> 3\n== inv_iterations\n-- InvNiter=1\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5025000000000002 1.5010416666666668 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.2116397807407409 4.3996876820484694 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179248 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvNiter=2\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999999999994 0.29999999999999999\ninv 1.0024565614997714 1.9990249199817101 -> 1 2\ninv 1.5025000000000002 1.5010416666666668 -> 1.5000000000000004 1.5000000000000002\ninv 2.2116397807407409 4.3996876820484694 -> 2.2000000000000006 4.4000000000000012\ninv 2.9059816087517145 0.053345760784179248 -> 2.8999999999999999 0.050000000000000003\ninv 0.015401234567901234 2.0144753086419751 -> 1.1658707069795999e-17 1.9999999999999998\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000000000000013 2.0000000000000031\ninv 2.0033333333333334 0.0066666666666666671 -> 2.0000000000000004 -3.3991037325954404e-18\n-- InvNiter=3\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999999999994 0.29999999999999999\ninv 1.0024565614997714 1.9990249199817101 -> 1 2\ninv 1.5025000000000002 1.5010416666666668 -> 1.5000000000000004 1.5000000000000002\ninv 2.2116397807407409 4.3996876820484694 -> 2.2000000000000006 4.4000000000000012\ninv 2.9059816087517145 0.053345760784179248 -> 2.8999999999999999 0.050000000000000003\ninv 0.015401234567901234 2.0144753086419751 -> 1.1658707069795999e-17 1.9999999999999998\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000000000000013 2.0000000000000031\ninv 2.0033333333333334 0.0066666666666666671 -> 2.0000000000000004 -3.3991037325954404e-18\n-- InvNiter=1, InvTol=1.0E-3\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999981266283 0.29999999987131848\ninv 1.0024565614997714 1.9990249199817101 -> 1.0000000000003448 2.0000000000004232\ninv 1.5025000000000002 1.5010416666666668 -> 1.5000000000015923 1.5000000000006586\ninv 2.2116397807407409 4.3996876820484694 -> 2.2000000001514723 4.3999999999341819\ninv 2.9059816087517145 0.053345760784179248 -> 2.9000000027029982 0.04999999842757117\ninv 0.015401234567901234 2.0144753086419751 -> 1.4656241097490974e-08 2.0000000086811034\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> 2.0000000000861475 -7.3439887051979409e-11\n-- InvNiter=2, InvTol=0.1\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999981266283 0.29999999987131848\ninv 1.0024565614997714 1.9990249199817101 -> 1.0000000000003448 2.0000000000004232\ninv 1.5025000000000002 1.5010416666666668 -> 1.5000000000015923 1.5000000000006586\ninv 2.2116397807407409 4.3996876820484694 -> 2.2000000001514723 4.3999999999341819\ninv 2.9059816087517145 0.053345760784179248 -> 2.9000000027029982 0.04999999842757117\ninv 0.015401234567901234 2.0144753086419751 -> 1.4656241097490974e-08 2.0000000086811034\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000004080050022 2.0000007290690731\ninv 2.0033333333333334 0.0066666666666666671 -> 2.0000000000861475 -7.3439887051979409e-11\n-- InvNiter=6, InvTol=1.0E-14\ninv 0.25827344135802466 0.30636676697530862 -> 0.25000000000000006 0.29999999999999999\ninv 1.0024565614997714 1.9990249199817101 -> 1 2\ninv 1.5025000000000002 1.5010416666666668 -> 1.5000000000000002 1.5000000000000002\ninv 2.2116397807407409 4.3996876820484694 -> 2.2000000000000006 4.4000000000000004\ninv 2.9059816087517145 0.053345760784179248 -> 2.8999999999999999 0.050000000000000003\ninv 0.015401234567901234 2.0144753086419751 -> 5.331305994062551e-19 1.9999999999999998\ninv 3.0019444444444443 1.9890123456790123 -> 2.9999999999999996 1.9999999999999998\ninv 2.0033333333333334 0.0066666666666666671 -> 2 1.7017360748204109e-18\n-- InvNiter=20, InvTol=1.0E-17\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> 1 2\ninv 1.5025000000000002 1.5010416666666668 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.2116397807407409 4.3996876820484694 -> 2.2000000000000006 4.4000000000000004\ninv 2.9059816087517145 0.053345760784179248 -> 2.8999999999999999 0.050000000000000003\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvNiter=0\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5025000000000002 1.5010416666666668 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.2116397807407409 4.3996876820484694 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179248 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvNiter=-3\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5025000000000002 1.5010416666666668 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.2116397807407409 4.3996876820484694 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179248 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvTol=0\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> 1 2\ninv 1.5025000000000002 1.5010416666666668 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.2116397807407409 4.3996876820484694 -> 2.2000000000000006 4.4000000000000004\ninv 2.9059816087517145 0.053345760784179248 -> 2.8999999999999999 0.050000000000000003\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvTol=-1\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999981266283 0.29999999987131848\ninv 1.0024565614997714 1.9990249199817101 -> 1.0000000000003448 2.0000000000004232\ninv 1.5025000000000002 1.5010416666666668 -> 1.5000000000015923 1.5000000000006586\ninv 2.2116397807407409 4.3996876820484694 -> 2.2000000001514723 4.3999999999341819\ninv 2.9059816087517145 0.053345760784179248 -> 2.9000000027029982 0.04999999842757117\ninv 0.015401234567901234 2.0144753086419751 -> 1.4656241097490974e-08 2.0000000086811034\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000004080050022 2.0000007290690731\ninv 2.0033333333333334 0.0066666666666666671 -> 2.0000000000861475 -7.3439887051979409e-11\n-- InvNiter=1, OutUnit=1\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5025000000000002 1.5010416666666668 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.2116397807407409 4.3996876820484694 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179248 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvNiter=2, OutUnit=1\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999999999994 0.29999999999999999\ninv 1.0024565614997714 1.9990249199817101 -> 1 2\ninv 1.5025000000000002 1.5010416666666668 -> 1.5000000000000004 1.5000000000000002\ninv 2.2116397807407409 4.3996876820484694 -> 2.2000000000000006 4.4000000000000012\ninv 2.9059816087517145 0.053345760784179248 -> 2.8999999999999999 0.050000000000000003\ninv 0.015401234567901234 2.0144753086419751 -> 1.1658707069795999e-17 1.9999999999999998\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000000000000013 2.0000000000000031\ninv 2.0033333333333334 0.0066666666666666671 -> 2.0000000000000004 -3.3991037325954404e-18\n== inv_outside\ninv -0.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5199999999999996 -> 2.9999999999999996 4.4999999999999991\ninv 1 -0.02 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -1 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 4 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 4.5999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5199999999999996 -> 2.9999999999999996 4.4999999999999991\ninv 1 -0.02 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -1 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 4 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 4.5999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5199999999999996 -> 2.9999999999999996 4.4999999999999991\ninv 1 -0.02 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -1 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 4 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 4.5999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n== order1\nfwd 0.5 0.5 -> 1.5 2.5\nfwd 0 0 -> 1.5 2.5\nfwd 1 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nrate 0.5 0.5 1 1 -> 0\nrate 0.5 0.5 2 1 -> 0\n== rate\nrate 1.2 2.7000000000000002 1 1 -> 1.0017536\nrate 3 4.5 1 1 -> 0.95999999999999996\nrate -1 2 1 1 -> -1.7976931348623157e+308\nrate 1.2 2.7000000000000002 1 2 -> 0.0044655999999999316\nrate 3 4.5 1 2 -> -0.019999999999999574\nrate -1 2 1 2 -> -1.7976931348623157e+308\nrate 1.2 2.7000000000000002 2 1 -> 0.0047279999999999484\nrate 3 4.5 2 1 -> 0.039999999999999147\nrate -1 2 2 1 -> -1.7976931348623157e+308\nrate 1.2 2.7000000000000002 2 2 -> 1.0050559999999999\nrate 3 4.5 2 2 -> 1.0399999999999991\nrate -1 2 2 2 -> -1.7976931348623157e+308\nrate -1.7976931348623157e+308 2 1 1 -> -1.7976931348623157e+308\n!! AST: Error in routine rate at line 165 in file src/test/resources/probes/splinemap_probe.c.\n! astRate(SplineMap): Invalid output index (3) specified - should be in the range 1 to 2.\nstatus 233933178\n!! AST: Error in routine rate at line 165 in file src/test/resources/probes/splinemap_probe.c.\n! astRate(SplineMap): Invalid input index (0) specified - should be in the range 1 to 2.\nstatus 233933178\nrate -1 2 1 1 -> 1\nrate -1 2 1 2 -> 0\nrate -1 2 2 1 -> 0\nrate -1 2 2 2 -> 1\nrate 1.2 2.7000000000000002 1 1 -> 0.99817844933333333\nrate 1.2 2.7000000000000002 1 2 -> -0.0045150158518518519\nrate 1.2 2.7000000000000002 2 1 -> -0.0047695380000000002\nrate 1.2 2.7000000000000002 2 2 -> 0.99498388207407407\n== rate_testsplinemap\nrate 0.5 0.5 1 1 -> 2\nrate 1 1.5 1 1 -> 0.5\nrate 1 1.5 1 2 -> 0\n== knots_coeffs\nknots 0 0 0 0 0 1.5 3 4.5 4.5 4.5 4.5\ncoeffs 0 0.01 0.5 1.52 3.0099999999999998 3.98 4.5 0 0.52000000000000002 1.49 2.9900000000000002 4.0099999999999998 4.5099999999999998 -0.01 0.48999999999999999 1.5 3.02 4.0199999999999996 4.4900000000000002 0.02 0.51000000000000001 1.51 2.98 3.9900000000000002 4.5 0 0.5 1.48 3 4 4.5199999999999996\nknots 1 0 0 0 0 1.5 3 3 3 3\ncoeffs 1 0 0.01 0.02 0.01 0 -0.01 0.51000000000000001 0.52000000000000002 0.48999999999999999 0.5 0.53000000000000003 0.5 1.52 1.48 1.5 1.53 1.49 1.51 2.4900000000000002 2.5099999999999998 2.52 2.48 2.5 2.52 3.0099999999999998 3 2.9900000000000002 3.02 3.0099999999999998 3\nknots 2 0 0 0 0 1.5 3 4.5 4.5 4.5 4.5\ncoeffs 2 0.01 0.5 1.52 3.0099999999999998 3.98 4.5 0 0.52000000000000002 1.49 2.9900000000000002 4.0099999999999998 4.5099999999999998 -0.01 0.48999999999999999 1.5 3.02 4.0199999999999996 4.4900000000000002 0.02 0.51000000000000001 1.51 2.98 3.9900000000000002 4.5 0 0.5 1.48 3 4 4.5199999999999996\nknots 3 0 0 0 0 1.5 3 4.5 4.5 4.5 4.5\ncoeffs 3 0.01 0.5 1.52 3.0099999999999998 3.98 4.5 0 0.52000000000000002 1.49 2.9900000000000002 4.0099999999999998 4.5099999999999998 -0.01 0.48999999999999999 1.5 3.02 4.0199999999999996 4.4900000000000002 0.02 0.51000000000000001 1.51 2.98 3.9900000000000002 4.5 0 0.5 1.48 3 4 4.5199999999999996\nknots 1 0 0 0 0 1.5 3 3 3 3\ncoeffs 2 0.01 0.5 1.52 3.0099999999999998 3.98 4.5 0 0.52000000000000002 1.49 2.9900000000000002 4.0099999999999998 4.5099999999999998 -0.01 0.48999999999999999 1.5 3.02 4.0199999999999996 4.4900000000000002 0.02 0.51000000000000001 1.51 2.98 3.9900000000000002 4.5 0 0.5 1.48 3 4 4.5199999999999996\n== simp_inverse_after\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_inverse_before\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_same_direction\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n MapB = \t# Second component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n End CmpMap\n== simp_parallel\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 4 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Series = 0 \t# Component Mappings applied in parallel\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n MapB = \t# Second component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n End CmpMap\n== simp_winmap\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n MapB = \t# Second component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 1 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n Sft2 = 2 \t# Shift for axis 2\n Scl2 = 3 \t# Scale factor for axis 2\n End WinMap\n End CmpMap\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 1 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n Sft2 = 2 \t# Shift for axis 2\n Scl2 = 3 \t# Scale factor for axis 2\n End WinMap\n MapB = \t# Second component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n End CmpMap\n== simp_unit_between\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_different_coeffs\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n MapB = \t# Second component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n KX = 2 \t# Polynomial order in X direction\n KY = 2 \t# Polynomial order in Y direction\n NX = 2 \t# No. of coeffs in X direction\n NY = 2 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 1 \t# Knot 3 x position\n TX4 = 1 \t# Knot 4 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 1 \t# Knot 3 y position\n TY4 = 1 \t# Knot 4 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 2 \t# X coeff 2\n CU3 = 0 \t# X coeff 3\n CU4 = 2 \t# X coeff 4\n CV1 = 0 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = 3 \t# Y coeff 3\n CV4 = 3 \t# Y coeff 4\n End SplineMap\n End CmpMap\n== simp_outunit_differs\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_inverted_cmpmap\nfwd 1.2 2.7000000000000002 -> 1.2000000000000002 2.7000000000000011\nInvert a 0 test 0 b 1 test 1\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\nInvert a 0 test 1 b 0 test 1\nfwd 1.2 2.7000000000000002 -> 1.2000000000000002 2.7000000000000011\n== simp_cmpmap_attrs\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\nInvert a 0 test 1 b 1 test 1\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\nInvert b 1 test 1 a 0 test 1\n== equal\nequal copy 1\nequal same values 1\nequal inverted 0\nequal inverted twice 1\nequal attributes differ 1\nequal different 0\nequal unitmap 0\nequal coefficient within tolerance 1\nequal coefficient beyond tolerance 0\nequal knot 0\n== load_roundtrip\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n NiterInv = 9 \t# Max number of iterations for iterative inverse\n OutUnit = 1 \t# How to handle out-of-bounds points\n TolInv = 1.0000000000000001e-09 \t# Target relative error for iterative inverse\n End SplineMap\nIsSimple loaded 1\nequal loaded 1\nInvNiter 9 test 1\nInvTol 1.0000000000000001e-09 test 1\nOutUnit 1 test 1\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n== load_defaults\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 1 \t# Polynomial order in X direction\n KY = 1 \t# Polynomial order in Y direction\n NX = 1 \t# No. of coeffs in X direction\n NY = 1 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 1 \t# Knot 2 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 2 \t# Knot 2 y position\n CU1 = 4 \t# X coeff 1\n CV1 = \t# Y coeff 1\n End SplineMap\nInvNiter 6 test 0\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 0 test 0\nSplineKx 1 test 0\nSplineKy 1 test 0\nSplineNx 1 test 0\nSplineNy 1 test 0\nfwd 0.5 0.5 -> 4 -1.7976931348623157e+308\n== fits_lsst2_tight\nwritten 0\nkeywords NAXIS1 NAXIS2\n== fits_lsst2_default\nwritten 1\nkeywords NAXIS1 NAXIS2 WCSAXES CRPIX1 CRPIX2 CRVAL1 CRVAL2 CTYPE1 CTYPE2 CDELT1 CDELT2 PC1_1 PC1_2 PC2_1 PC2_2 RADESYS WCSAXESA WCSNAMEA CRPIX1A CRPIX2A CRVAL1A CRVAL2A CTYPE1A CTYPE2A CDELT1A CDELT2A PC1_1A PC1_2A PC2_1A PC2_2A\n== fits_lsst2_wrapped\nwritten 0\nkeywords NAXIS1 NAXIS2\n== fits_lsst2_alternate\nwritten 1\nkeywords NAXIS1 NAXIS2 WCSAXES CRPIX1 CRPIX2 CRVAL1 CRVAL2 CTYPE1 CTYPE2 CDELT1 CDELT2 PC1_1 PC1_2 PC2_1 PC2_2 RADESYS WCSAXESA WCSNAMEA CRPIX1A CRPIX2A CRVAL1A CRVAL2A CTYPE1A CTYPE2A CDELT1A CDELT2A WCSAXESB WCSNAMEB CRPIX1B CRPIX2B CRVAL1B CRVAL2B CTYPE1B CTYPE2B CDELT1B CDELT2B PC1_1B PC1_2B PC2_1B PC2_2B\nwritten 0\nkeywords NAXIS1 NAXIS2\n" +} diff --git a/src/test/resources/probes/splinemap_probe_nocontract.json b/src/test/resources/probes/splinemap_probe_nocontract.json new file mode 100644 index 0000000..7ea7db9 --- /dev/null +++ b/src/test/resources/probes/splinemap_probe_nocontract.json @@ -0,0 +1,4 @@ +{ + "source": "probes/splinemap_probe.c", + "output": "== isa\nIsASplineMap 1 IsAMapping 1 Nin 2 Nout 2 IsLinear 0\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n== ctor_errors\n!! AST: Error in routine class_cases at line 252 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied spline order in the X direction (0) is invalid - it must be in the range [1,6].\nstatus 233933170\n!! AST: Error in routine class_cases at line 254 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied spline order in the X direction (7) is invalid - it must be in the range [1,6].\nstatus 233933170\n!! AST: Error in routine class_cases at line 256 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied spline order in the Y direction (0) is invalid - it must be in the range [1,6].\nstatus 233933170\n!! AST: Error in routine class_cases at line 258 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied spline order in the Y direction (7) is invalid - it must be in the range [1,6].\nstatus 233933170\n!! AST: Error in routine class_cases at line 260 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied number of coefficients in the X direction (1) is too small - it must be larger than or equal to 2.\nstatus 233933170\n!! AST: Error in routine class_cases at line 262 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied number of coefficients in the Y direction (1) is too small - it must be larger than or equal to 2.\nstatus 233933170\n!! AST: Error in routine class_cases at line 264 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied knots in the X direction are not monotonic increasing.\nstatus 233933170\n!! AST: Error in routine class_cases at line 266 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied knots in the Y direction are not monotonic increasing.\nstatus 233933170\n!! AST: Error in routine class_cases at line 268 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied knots in the X direction are not monotonic increasing.\nstatus 233933170\n== attrs_default\nInvNiter 6 test 0\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 0 test 0\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n== attrs_set\nInvNiter 10 test 1\nInvTol 1e-08 test 1\nOutUnit 1 test 1\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n NiterInv = 10 \t# Max number of iterations for iterative inverse\n OutUnit = 1 \t# How to handle out-of-bounds points\n TolInv = 1e-08 \t# Target relative error for iterative inverse\n End SplineMap\nInvNiter -3 test 1\nInvTol 1e-08 test 1\nOutUnit 1 test 1\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\nInvNiter -3 test 1\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 1 test 1\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\nInvNiter 6 test 0\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 0 test 0\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n== attrs_readonly\n!! AST: Error in routine class_cases at line 295 in file src/test/resources/probes/splinemap_probe.c.\n! astSet: The setting \"splinekx=3\" is invalid for a SplineMap.\n! This is a read-only attribute.\nstatus 233933578\n!! AST: Error in routine class_cases at line 297 in file src/test/resources/probes/splinemap_probe.c.\n! astSet: The setting \"splineny=3\" is invalid for a SplineMap.\n! This is a read-only attribute.\nstatus 233933578\n!! AST: Error in routine class_cases at line 299 in file src/test/resources/probes/splinemap_probe.c.\n! astClear: Invalid attempt to clear the \"splineky\" value for a SplineMap.\n! This is a read-only attribute.\nstatus 233933578\n!! AST: Error in routine class_cases at line 301 in file src/test/resources/probes/splinemap_probe.c.\n! astClear: Invalid attempt to clear the \"splinenx\" value for a SplineMap.\n! This is a read-only attribute.\nstatus 233933578\ntest 0 0 0 0\n== attrs_shared\n!! AST: Error in routine class_cases at line 310 in file src/test/resources/probes/splinemap_probe.c.\n! astSet(SplineMap): The InvNiterattribute of the supplied SplineMap cannot be changed because the SplineMap has been cloned (programming error).\nstatus 233934418\n!! AST: Error in routine class_cases at line 312 in file src/test/resources/probes/splinemap_probe.c.\n! astSet(SplineMap): The InvTolattribute of the supplied SplineMap cannot be changed because the SplineMap has been cloned (programming error).\nstatus 233934418\n!! AST: Error in routine class_cases at line 314 in file src/test/resources/probes/splinemap_probe.c.\n! astClear(SplineMap): The OutUnitattribute of the supplied SplineMap cannot be cleared because the SplineMap has been cloned (programming error).\nstatus 233934418\nInvNiter 6 test 0\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 0 test 0\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n== issimple\nIsSimple marked 1\nIsSimple InvNiter=6 0\nIsSimple same value 1\nIsSimple cleared 0\nIsSimple cleared again 0\nIsSimple marked 1\nIsSimple InvTol=1.0E-6 0\nIsSimple same value 1\nIsSimple cleared 0\nIsSimple cleared again 0\nIsSimple marked 1\nIsSimple OutUnit=0 0\nIsSimple same value 1\nIsSimple cleared 0\nIsSimple cleared again 0\nIsSimple OutUnit=7 after 1 1\nIsSimple InvTol bad while unset 1\nIsSimple inverted 0\nIsSimple inverted back 1\n== tran_inside\nfwd 0.25 0.29999999999999999 -> 0.25827344135802466 0.30636676697530862\nfwd 1 2 -> 1.0024565614997714 1.9990249199817101\nfwd 1.5 1.5 -> 1.5025000000000002 1.5010416666666668\nfwd 2.2000000000000002 4.4000000000000004 -> 2.2116397807407409 4.3996876820484667\nfwd 2.8999999999999999 0.050000000000000003 -> 2.9059816087517145 0.053345760784179241\nfwd 0.10000000000000001 3.7000000000000002 -> 0.10507215246456331 3.694008570717878\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999999999989 0.29999999999999993\ninv 1.0024565614997714 1.9990249199817101 -> 1 1.9999999999999998\ninv 1.5025000000000002 1.5010416666666668 -> 1.5 1.5\ninv 2.2116397807407409 4.3996876820484667 -> 2.2000000000000002 4.3999999999999986\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000000000004 0.050000000000000024\ninv 0.10507215246456331 3.694008570717878 -> 0.099999999999999978 3.6999999999999993\n== tran_outside\nfwd -0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 3.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 0 -> 0 0.01\nfwd 3 4.5 -> 3 4.5199999999999996\nfwd 0 4.5 -> -0.01 4.5\nfwd 3 0 -> 3.0099999999999998 0\nfwd 1 4.5 -> 1.0048148148148146 4.5014814814814814\nfwd 3 2 -> 3.0019444444444443 1.9890123456790123\nfwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 -0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5 -> 2.9996029999260019 4.4807747790225338\ninv 3.0099999999999998 4.5199999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.01 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9900000000000002 4.4900000000000002 -> 2.9890385759535767 4.4715407702744541\nfwd -0.5 1 -> -0.5 1\nfwd 3.5 1 -> 3.5 1\nfwd 1 -0.5 -> 1 -0.5\nfwd 1 5 -> 1 5\nfwd 0 0 -> 0 0.01\nfwd 3 4.5 -> 3 4.5199999999999996\nfwd 0 4.5 -> -0.01 4.5\nfwd 3 0 -> 3.0099999999999998 0\nfwd 1 4.5 -> 1.0048148148148146 4.5014814814814814\nfwd 3 2 -> 3.0019444444444443 1.9890123456790123\nfwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 -0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5 -> 2.9996029999260019 4.4807747790225338\ninv 3.0099999999999998 4.5199999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.01 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9900000000000002 4.4900000000000002 -> 2.9890385759535767 4.4715407702744541\nfwd -0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 3.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 3 4.5 -> 2.9996029999260019 4.4807747790225338\nfwd 3.0099999999999998 4.5199999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd -0.01 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 2.9900000000000002 4.4900000000000002 -> 2.9890385759535767 4.4715407702744541\ninv -0.5 1 -> -0.5 1\ninv 3.5 1 -> 3.5 1\ninv 1 -0.5 -> 1 -0.5\ninv 1 5 -> 1 5\ninv 0 0 -> 0 0.01\ninv 3 4.5 -> 3 4.5199999999999996\ninv 0 4.5 -> -0.01 4.5\ninv 3 0 -> 3.0099999999999998 0\ninv 1 4.5 -> 1.0048148148148146 4.5014814814814814\ninv 3 2 -> 3.0019444444444443 1.9890123456790123\ninv -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n== tran_linear_edges\nfwd 0 0 -> 0 0\nfwd 1 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0.5 -> 2 1.5\nfwd 0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0 -> 2 0\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2 3 -> 0.99999999999999989 0.99999999999999989\ninv 2 1.5 -> 0.99999999999999989 0.5\ninv 1 3 -> 0.5 0.99999999999999989\ninv 1.9999998999999999 1.5 -> 0.99999994999999997 0.5\ninv 1.5 2.9999999000000002 -> 0.75 0.99999996666666668\nfwd 0 0 -> 0 0\nfwd 1 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0.5 -> 2 1.5\nfwd 0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0 -> 2 0\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2 3 -> 0.99999999999999989 0.99999999999999989\ninv 2 1.5 -> 0.99999999999999989 0.5\ninv 1 3 -> 0.5 0.99999999999999989\ninv 1.9999998999999999 1.5 -> 0.99999994999999997 0.5\ninv 1.5 2.9999999000000002 -> 0.75 0.99999996666666668\n== tran_open_knots_x\nfwd -0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0.5 -> 1 0.5\nfwd 1.5 0.5 -> 1.5 0.5\nfwd 2 0.5 -> 2 0.5\nfwd 3 0.5 -> 3 0.5\nfwd 3.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 4 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 4.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 0.5 -> 1.5 0.5\ninv 2.5 0.5 -> 2.5 0.5\ninv 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd -0.5 0.5 -> -0.5 0.5\nfwd 0 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0.5 -> 1 0.5\nfwd 1.5 0.5 -> 1.5 0.5\nfwd 2 0.5 -> 2 0.5\nfwd 3 0.5 -> 3 0.5\nfwd 3.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 4 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 4.5 0.5 -> 4.5 0.5\ninv 1.5 0.5 -> 1.5 0.5\ninv 2.5 0.5 -> 2.5 0.5\ninv 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nrate 0.5 0.5 1 1 -> -1.7976931348623157e+308\nrate 2 0.5 1 1 -> 1\n== tran_zero_width_x\nfwd 1 0 -> nan nan\nfwd 1 0.25 -> nan nan\nfwd 1 0.5 -> nan nan\nrate 1 0.5 1 1 -> inf\nrate 1 0.5 1 2 -> nan\nrate 1 0.5 2 1 -> nan\nrate 1 0.5 2 2 -> nan\nfwd 1 0 -> 1.5 0\nfwd 1 0.25 -> 1.5 0.75\nfwd 1 0.5 -> 1.5 1.5\nrate 1 0.5 1 1 -> 0\nrate 1 0.5 1 2 -> 0\nrate 1 0.5 2 1 -> 0\nrate 1 0.5 2 2 -> 3\n== inv_iterations\n-- InvNiter=1\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5025000000000002 1.5010416666666668 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.2116397807407409 4.3996876820484667 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179241 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvNiter=2\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999999999989 0.29999999999999993\ninv 1.0024565614997714 1.9990249199817101 -> 1 1.9999999999999998\ninv 1.5025000000000002 1.5010416666666668 -> 1.5 1.5\ninv 2.2116397807407409 4.3996876820484667 -> 2.2000000000000002 4.3999999999999986\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000000000004 0.050000000000000024\ninv 0.015401234567901234 2.0144753086419751 -> 2.7168747219304194e-18 1.9999999999999998\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000000000000013 2.0000000000000031\ninv 2.0033333333333334 0.0066666666666666671 -> 1.9999999999999998 6.1411669487870653e-18\n-- InvNiter=3\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999999999989 0.29999999999999993\ninv 1.0024565614997714 1.9990249199817101 -> 1 1.9999999999999998\ninv 1.5025000000000002 1.5010416666666668 -> 1.5 1.5\ninv 2.2116397807407409 4.3996876820484667 -> 2.2000000000000002 4.3999999999999986\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000000000004 0.050000000000000024\ninv 0.015401234567901234 2.0144753086419751 -> 2.7168747219304194e-18 1.9999999999999998\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000000000000013 2.0000000000000031\ninv 2.0033333333333334 0.0066666666666666671 -> 1.9999999999999998 6.1411669487870653e-18\n-- InvNiter=1, InvTol=1.0E-3\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999981266283 0.29999999987131842\ninv 1.0024565614997714 1.9990249199817101 -> 1.0000000000003448 2.0000000000004232\ninv 1.5025000000000002 1.5010416666666668 -> 1.5000000000015925 1.5000000000006584\ninv 2.2116397807407409 4.3996876820484667 -> 2.2000000001514728 4.3999999999341783\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000027029977 0.049999998427571142\ninv 0.015401234567901234 2.0144753086419751 -> 1.4656241101177261e-08 2.0000000086811034\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> 2.0000000000861475 -7.3439884454976393e-11\n-- InvNiter=2, InvTol=0.1\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999981266283 0.29999999987131842\ninv 1.0024565614997714 1.9990249199817101 -> 1.0000000000003448 2.0000000000004232\ninv 1.5025000000000002 1.5010416666666668 -> 1.5000000000015925 1.5000000000006584\ninv 2.2116397807407409 4.3996876820484667 -> 2.2000000001514728 4.3999999999341783\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000027029977 0.049999998427571142\ninv 0.015401234567901234 2.0144753086419751 -> 1.4656241101177261e-08 2.0000000086811034\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000004080050027 2.0000007290690727\ninv 2.0033333333333334 0.0066666666666666671 -> 2.0000000000861475 -7.3439884454976393e-11\n-- InvNiter=6, InvTol=1.0E-14\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999999999994 0.29999999999999999\ninv 1.0024565614997714 1.9990249199817101 -> 1.0000000000000004 2\ninv 1.5025000000000002 1.5010416666666668 -> 1.5 1.5\ninv 2.2116397807407409 4.3996876820484667 -> 2.1999999999999993 4.3999999999999995\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000000000008 0.050000000000000017\ninv 0.015401234567901234 2.0144753086419751 -> 5.331305994062551e-19 1.9999999999999998\ninv 3.0019444444444443 1.9890123456790123 -> 2.9999999999999996 1.9999999999999996\ninv 2.0033333333333334 0.0066666666666666671 -> 1.9999999999999998 6.1412679763126425e-18\n-- InvNiter=20, InvTol=1.0E-17\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> 1 2\ninv 1.5025000000000002 1.5010416666666668 -> 1.5 1.5\ninv 2.2116397807407409 4.3996876820484667 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179241 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvNiter=0\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5025000000000002 1.5010416666666668 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.2116397807407409 4.3996876820484667 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179241 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvNiter=-3\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5025000000000002 1.5010416666666668 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.2116397807407409 4.3996876820484667 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179241 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvTol=0\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> 1 2\ninv 1.5025000000000002 1.5010416666666668 -> 1.5 1.5\ninv 2.2116397807407409 4.3996876820484667 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179241 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvTol=-1\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999981266283 0.29999999987131842\ninv 1.0024565614997714 1.9990249199817101 -> 1.0000000000003448 2.0000000000004232\ninv 1.5025000000000002 1.5010416666666668 -> 1.5000000000015925 1.5000000000006584\ninv 2.2116397807407409 4.3996876820484667 -> 2.2000000001514728 4.3999999999341783\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000027029977 0.049999998427571142\ninv 0.015401234567901234 2.0144753086419751 -> 1.4656241101177261e-08 2.0000000086811034\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000004080050027 2.0000007290690727\ninv 2.0033333333333334 0.0066666666666666671 -> 2.0000000000861475 -7.3439884454976393e-11\n-- InvNiter=1, OutUnit=1\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5025000000000002 1.5010416666666668 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.2116397807407409 4.3996876820484667 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179241 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvNiter=2, OutUnit=1\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999999999989 0.29999999999999993\ninv 1.0024565614997714 1.9990249199817101 -> 1 1.9999999999999998\ninv 1.5025000000000002 1.5010416666666668 -> 1.5 1.5\ninv 2.2116397807407409 4.3996876820484667 -> 2.2000000000000002 4.3999999999999986\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000000000004 0.050000000000000024\ninv 0.015401234567901234 2.0144753086419751 -> 2.7168747219304194e-18 1.9999999999999998\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000000000000013 2.0000000000000031\ninv 2.0033333333333334 0.0066666666666666671 -> 1.9999999999999998 6.1411669487870653e-18\n== inv_outside\ninv -0.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5199999999999996 -> 2.9999999999999996 4.4999999999999991\ninv 1 -0.02 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -1 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 4 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 4.5999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5199999999999996 -> 2.9999999999999996 4.4999999999999991\ninv 1 -0.02 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -1 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 4 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 4.5999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5199999999999996 -> 2.9999999999999996 4.4999999999999991\ninv 1 -0.02 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -1 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 4 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 4.5999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n== order1\nfwd 0.5 0.5 -> 1.5 2.5\nfwd 0 0 -> 1.5 2.5\nfwd 1 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nrate 0.5 0.5 1 1 -> 0\nrate 0.5 0.5 2 1 -> 0\n== rate\nrate 1.2 2.7000000000000002 1 1 -> 1.0017536\nrate 3 4.5 1 1 -> 0.95999999999999996\nrate -1 2 1 1 -> -1.7976931348623157e+308\nrate 1.2 2.7000000000000002 1 2 -> 0.0044655999999999932\nrate 3 4.5 1 2 -> -0.019999999999999574\nrate -1 2 1 2 -> -1.7976931348623157e+308\nrate 1.2 2.7000000000000002 2 1 -> 0.0047279999999999484\nrate 3 4.5 2 1 -> 0.039999999999999147\nrate -1 2 2 1 -> -1.7976931348623157e+308\nrate 1.2 2.7000000000000002 2 2 -> 1.0050559999999999\nrate 3 4.5 2 2 -> 1.0399999999999991\nrate -1 2 2 2 -> -1.7976931348623157e+308\nrate -1.7976931348623157e+308 2 1 1 -> -1.7976931348623157e+308\n!! AST: Error in routine rate at line 165 in file src/test/resources/probes/splinemap_probe.c.\n! astRate(SplineMap): Invalid output index (3) specified - should be in the range 1 to 2.\nstatus 233933178\n!! AST: Error in routine rate at line 165 in file src/test/resources/probes/splinemap_probe.c.\n! astRate(SplineMap): Invalid input index (0) specified - should be in the range 1 to 2.\nstatus 233933178\nrate -1 2 1 1 -> 1\nrate -1 2 1 2 -> 0\nrate -1 2 2 1 -> 0\nrate -1 2 2 2 -> 1\nrate 1.2 2.7000000000000002 1 1 -> 0.99817844899999997\nrate 1.2 2.7000000000000002 1 2 -> -0.0045150157037037036\nrate 1.2 2.7000000000000002 2 1 -> -0.0047695383333333334\nrate 1.2 2.7000000000000002 2 2 -> 0.99498388296296292\n== rate_testsplinemap\nrate 0.5 0.5 1 1 -> 2\nrate 1 1.5 1 1 -> 0.5\nrate 1 1.5 1 2 -> 0\n== knots_coeffs\nknots 0 0 0 0 0 1.5 3 4.5 4.5 4.5 4.5\ncoeffs 0 0.01 0.5 1.52 3.0099999999999998 3.98 4.5 0 0.52000000000000002 1.49 2.9900000000000002 4.0099999999999998 4.5099999999999998 -0.01 0.48999999999999999 1.5 3.02 4.0199999999999996 4.4900000000000002 0.02 0.51000000000000001 1.51 2.98 3.9900000000000002 4.5 0 0.5 1.48 3 4 4.5199999999999996\nknots 1 0 0 0 0 1.5 3 3 3 3\ncoeffs 1 0 0.01 0.02 0.01 0 -0.01 0.51000000000000001 0.52000000000000002 0.48999999999999999 0.5 0.53000000000000003 0.5 1.52 1.48 1.5 1.53 1.49 1.51 2.4900000000000002 2.5099999999999998 2.52 2.48 2.5 2.52 3.0099999999999998 3 2.9900000000000002 3.02 3.0099999999999998 3\nknots 2 0 0 0 0 1.5 3 4.5 4.5 4.5 4.5\ncoeffs 2 0.01 0.5 1.52 3.0099999999999998 3.98 4.5 0 0.52000000000000002 1.49 2.9900000000000002 4.0099999999999998 4.5099999999999998 -0.01 0.48999999999999999 1.5 3.02 4.0199999999999996 4.4900000000000002 0.02 0.51000000000000001 1.51 2.98 3.9900000000000002 4.5 0 0.5 1.48 3 4 4.5199999999999996\nknots 3 0 0 0 0 1.5 3 4.5 4.5 4.5 4.5\ncoeffs 3 0.01 0.5 1.52 3.0099999999999998 3.98 4.5 0 0.52000000000000002 1.49 2.9900000000000002 4.0099999999999998 4.5099999999999998 -0.01 0.48999999999999999 1.5 3.02 4.0199999999999996 4.4900000000000002 0.02 0.51000000000000001 1.51 2.98 3.9900000000000002 4.5 0 0.5 1.48 3 4 4.5199999999999996\nknots 1 0 0 0 0 1.5 3 3 3 3\ncoeffs 2 0.01 0.5 1.52 3.0099999999999998 3.98 4.5 0 0.52000000000000002 1.49 2.9900000000000002 4.0099999999999998 4.5099999999999998 -0.01 0.48999999999999999 1.5 3.02 4.0199999999999996 4.4900000000000002 0.02 0.51000000000000001 1.51 2.98 3.9900000000000002 4.5 0 0.5 1.48 3 4 4.5199999999999996\n== simp_inverse_after\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_inverse_before\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_same_direction\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n MapB = \t# Second component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n End CmpMap\n== simp_parallel\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 4 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Series = 0 \t# Component Mappings applied in parallel\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n MapB = \t# Second component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n End CmpMap\n== simp_winmap\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n MapB = \t# Second component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 1 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n Sft2 = 2 \t# Shift for axis 2\n Scl2 = 3 \t# Scale factor for axis 2\n End WinMap\n End CmpMap\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 1 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n Sft2 = 2 \t# Shift for axis 2\n Scl2 = 3 \t# Scale factor for axis 2\n End WinMap\n MapB = \t# Second component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n End CmpMap\n== simp_unit_between\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_different_coeffs\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n MapB = \t# Second component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n KX = 2 \t# Polynomial order in X direction\n KY = 2 \t# Polynomial order in Y direction\n NX = 2 \t# No. of coeffs in X direction\n NY = 2 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 1 \t# Knot 3 x position\n TX4 = 1 \t# Knot 4 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 1 \t# Knot 3 y position\n TY4 = 1 \t# Knot 4 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 2 \t# X coeff 2\n CU3 = 0 \t# X coeff 3\n CU4 = 2 \t# X coeff 4\n CV1 = 0 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = 3 \t# Y coeff 3\n CV4 = 3 \t# Y coeff 4\n End SplineMap\n End CmpMap\n== simp_outunit_differs\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_inverted_cmpmap\nfwd 1.2 2.7000000000000002 -> 1.2 2.7000000000000011\nInvert a 0 test 0 b 1 test 1\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\nInvert a 0 test 1 b 0 test 1\nfwd 1.2 2.7000000000000002 -> 1.2 2.7000000000000011\n== simp_cmpmap_attrs\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\nInvert a 0 test 1 b 1 test 1\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\nInvert b 1 test 1 a 0 test 1\n== equal\nequal copy 1\nequal same values 1\nequal inverted 0\nequal inverted twice 1\nequal attributes differ 1\nequal different 0\nequal unitmap 0\nequal coefficient within tolerance 1\nequal coefficient beyond tolerance 0\nequal knot 0\n== load_roundtrip\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n NiterInv = 9 \t# Max number of iterations for iterative inverse\n OutUnit = 1 \t# How to handle out-of-bounds points\n TolInv = 1.0000000000000001e-09 \t# Target relative error for iterative inverse\n End SplineMap\nIsSimple loaded 1\nequal loaded 1\nInvNiter 9 test 1\nInvTol 1.0000000000000001e-09 test 1\nOutUnit 1 test 1\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n== load_defaults\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 1 \t# Polynomial order in X direction\n KY = 1 \t# Polynomial order in Y direction\n NX = 1 \t# No. of coeffs in X direction\n NY = 1 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 1 \t# Knot 2 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 2 \t# Knot 2 y position\n CU1 = 4 \t# X coeff 1\n CV1 = \t# Y coeff 1\n End SplineMap\nInvNiter 6 test 0\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 0 test 0\nSplineKx 1 test 0\nSplineKy 1 test 0\nSplineNx 1 test 0\nSplineNy 1 test 0\nfwd 0.5 0.5 -> 4 -1.7976931348623157e+308\n== fits_lsst2_tight\nwritten 0\nkeywords NAXIS1 NAXIS2\n== fits_lsst2_default\nwritten 1\nkeywords NAXIS1 NAXIS2 WCSAXES CRPIX1 CRPIX2 CRVAL1 CRVAL2 CTYPE1 CTYPE2 CDELT1 CDELT2 PC1_1 PC1_2 PC2_1 PC2_2 RADESYS WCSAXESA WCSNAMEA CRPIX1A CRPIX2A CRVAL1A CRVAL2A CTYPE1A CTYPE2A CDELT1A CDELT2A PC1_1A PC1_2A PC2_1A PC2_2A\n== fits_lsst2_wrapped\nwritten 0\nkeywords NAXIS1 NAXIS2\n== fits_lsst2_alternate\nwritten 1\nkeywords NAXIS1 NAXIS2 WCSAXES CRPIX1 CRPIX2 CRVAL1 CRVAL2 CTYPE1 CTYPE2 CDELT1 CDELT2 PC1_1 PC1_2 PC2_1 PC2_2 RADESYS WCSAXESA WCSNAMEA CRPIX1A CRPIX2A CRVAL1A CRVAL2A CTYPE1A CTYPE2A CDELT1A CDELT2A WCSAXESB WCSNAMEB CRPIX1B CRPIX2B CRVAL1B CRVAL2B CTYPE1B CTYPE2B CDELT1B CDELT2B PC1_1B PC1_2B PC2_1B PC2_2B\nwritten 0\nkeywords NAXIS1 NAXIS2\n" +} diff --git a/src/test/resources/probes/splinemap_probe_pr104.json b/src/test/resources/probes/splinemap_probe_pr104.json new file mode 100644 index 0000000..4b27caa --- /dev/null +++ b/src/test/resources/probes/splinemap_probe_pr104.json @@ -0,0 +1,4 @@ +{ + "source": "probes/splinemap_probe.c", + "output": "== isa\nIsASplineMap 1 IsAMapping 1 Nin 2 Nout 2 IsLinear 0\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n== ctor_errors\n!! AST: Error in routine class_cases at line 252 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied spline order in the X direction (0) is invalid - it must be in the range [1,6].\nstatus 233933170\n!! AST: Error in routine class_cases at line 254 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied spline order in the X direction (7) is invalid - it must be in the range [1,6].\nstatus 233933170\n!! AST: Error in routine class_cases at line 256 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied spline order in the Y direction (0) is invalid - it must be in the range [1,6].\nstatus 233933170\n!! AST: Error in routine class_cases at line 258 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied spline order in the Y direction (7) is invalid - it must be in the range [1,6].\nstatus 233933170\n!! AST: Error in routine class_cases at line 260 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied number of coefficients in the X direction (1) is too small - it must be larger than or equal to 2.\nstatus 233933170\n!! AST: Error in routine class_cases at line 262 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied number of coefficients in the Y direction (1) is too small - it must be larger than or equal to 2.\nstatus 233933170\n!! AST: Error in routine class_cases at line 264 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied knots in the X direction are not monotonic increasing.\nstatus 233933170\n!! AST: Error in routine class_cases at line 266 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied knots in the Y direction are not monotonic increasing.\nstatus 233933170\n!! AST: Error in routine class_cases at line 268 in file src/test/resources/probes/splinemap_probe.c.\n! astSplineMap: The supplied knots in the X direction are not monotonic increasing.\nstatus 233933170\n== attrs_default\nInvNiter 6 test 0\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 0 test 0\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n== attrs_set\nInvNiter 10 test 1\nInvTol 1e-08 test 1\nOutUnit 1 test 1\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n NiterInv = 10 \t# Max number of iterations for iterative inverse\n OutUnit = 1 \t# How to handle out-of-bounds points\n TolInv = 1e-08 \t# Target relative error for iterative inverse\n End SplineMap\nInvNiter -3 test 1\nInvTol 1e-08 test 1\nOutUnit 1 test 1\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\nInvNiter -3 test 1\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 1 test 1\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\nInvNiter 6 test 0\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 0 test 0\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n== attrs_readonly\n!! AST: Error in routine class_cases at line 295 in file src/test/resources/probes/splinemap_probe.c.\n! astSet: The setting \"splinekx=3\" is invalid for a SplineMap.\n! This is a read-only attribute.\nstatus 233933578\n!! AST: Error in routine class_cases at line 297 in file src/test/resources/probes/splinemap_probe.c.\n! astSet: The setting \"splineny=3\" is invalid for a SplineMap.\n! This is a read-only attribute.\nstatus 233933578\n!! AST: Error in routine class_cases at line 299 in file src/test/resources/probes/splinemap_probe.c.\n! astClear: Invalid attempt to clear the \"splineky\" value for a SplineMap.\n! This is a read-only attribute.\nstatus 233933578\n!! AST: Error in routine class_cases at line 301 in file src/test/resources/probes/splinemap_probe.c.\n! astClear: Invalid attempt to clear the \"splinenx\" value for a SplineMap.\n! This is a read-only attribute.\nstatus 233933578\ntest 0 0 0 0\n== attrs_shared\n!! AST: Error in routine class_cases at line 310 in file src/test/resources/probes/splinemap_probe.c.\n! astSet(SplineMap): The InvNiterattribute of the supplied SplineMap cannot be changed because the SplineMap has been cloned (programming error).\nstatus 233934418\n!! AST: Error in routine class_cases at line 312 in file src/test/resources/probes/splinemap_probe.c.\n! astSet(SplineMap): The InvTolattribute of the supplied SplineMap cannot be changed because the SplineMap has been cloned (programming error).\nstatus 233934418\n!! AST: Error in routine class_cases at line 314 in file src/test/resources/probes/splinemap_probe.c.\n! astClear(SplineMap): The OutUnitattribute of the supplied SplineMap cannot be cleared because the SplineMap has been cloned (programming error).\nstatus 233934418\nInvNiter 6 test 0\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 0 test 0\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n== issimple\nIsSimple marked 1\nIsSimple InvNiter=6 0\nIsSimple same value 1\nIsSimple cleared 0\nIsSimple cleared again 0\nIsSimple marked 1\nIsSimple InvTol=1.0E-6 0\nIsSimple same value 1\nIsSimple cleared 0\nIsSimple cleared again 0\nIsSimple marked 1\nIsSimple OutUnit=0 0\nIsSimple same value 1\nIsSimple cleared 0\nIsSimple cleared again 0\nIsSimple OutUnit=7 after 1 1\nIsSimple InvTol bad while unset 1\nIsSimple inverted 0\nIsSimple inverted back 1\n== tran_inside\nfwd 0.25 0.29999999999999999 -> 0.25827344135802466 0.30636676697530862\nfwd 1 2 -> 1.0024565614997714 1.9990249199817101\nfwd 1.5 1.5 -> 1.5025000000000002 1.5010416666666668\nfwd 2.2000000000000002 4.4000000000000004 -> 2.2116397807407409 4.3996876820484667\nfwd 2.8999999999999999 0.050000000000000003 -> 2.9059816087517145 0.053345760784179241\nfwd 0.10000000000000001 3.7000000000000002 -> 0.10507215246456331 3.694008570717878\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999999999989 0.29999999999999993\ninv 1.0024565614997714 1.9990249199817101 -> 1 1.9999999999999998\ninv 1.5025000000000002 1.5010416666666668 -> 1.5 1.5\ninv 2.2116397807407409 4.3996876820484667 -> 2.2000000000000002 4.3999999999999986\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000000000004 0.050000000000000024\ninv 0.10507215246456331 3.694008570717878 -> 0.099999999999999978 3.6999999999999993\n== tran_outside\nfwd -0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 3.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 0 -> 0 0.01\nfwd 3 4.5 -> 3 4.5199999999999996\nfwd 0 4.5 -> -0.01 4.5\nfwd 3 0 -> 3.0099999999999998 0\nfwd 1 4.5 -> 1.0048148148148146 4.5014814814814814\nfwd 3 2 -> 3.0019444444444443 1.9890123456790123\nfwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 -0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5 -> 2.9996029999260019 4.4807747790225338\ninv 3.0099999999999998 4.5199999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.01 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9900000000000002 4.4900000000000002 -> 2.9890385759535767 4.4715407702744541\nfwd -0.5 1 -> -0.5 1\nfwd 3.5 1 -> 3.5 1\nfwd 1 -0.5 -> 1 -0.5\nfwd 1 5 -> 1 5\nfwd 0 0 -> 0 0.01\nfwd 3 4.5 -> 3 4.5199999999999996\nfwd 0 4.5 -> -0.01 4.5\nfwd 3 0 -> 3.0099999999999998 0\nfwd 1 4.5 -> 1.0048148148148146 4.5014814814814814\nfwd 3 2 -> 3.0019444444444443 1.9890123456790123\nfwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 -0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5 -> 2.9996029999260019 4.4807747790225338\ninv 3.0099999999999998 4.5199999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.01 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9900000000000002 4.4900000000000002 -> 2.9890385759535767 4.4715407702744541\nfwd -0.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 3.5 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 -0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 3 4.5 -> 2.9996029999260019 4.4807747790225338\nfwd 3.0099999999999998 4.5199999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd -0.01 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 2.9900000000000002 4.4900000000000002 -> 2.9890385759535767 4.4715407702744541\ninv -0.5 1 -> -0.5 1\ninv 3.5 1 -> 3.5 1\ninv 1 -0.5 -> 1 -0.5\ninv 1 5 -> 1 5\ninv 0 0 -> 0 0.01\ninv 3 4.5 -> 3 4.5199999999999996\ninv 0 4.5 -> -0.01 4.5\ninv 3 0 -> 3.0099999999999998 0\ninv 1 4.5 -> 1.0048148148148146 4.5014814814814814\ninv 3 2 -> 3.0019444444444443 1.9890123456790123\ninv -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n== tran_linear_edges\nfwd 0 0 -> 0 0\nfwd 1 1 -> 2 3\nfwd 1 0.5 -> 2 1.5\nfwd 0.5 1 -> 1 3\nfwd 0 1 -> 0 3\nfwd 1 0 -> 2 0\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2 3 -> 0.99999999999999989 0.99999999999999989\ninv 2 1.5 -> 0.99999999999999989 0.5\ninv 1 3 -> 0.5 0.99999999999999989\ninv 1.9999998999999999 1.5 -> 0.99999994999999997 0.5\ninv 1.5 2.9999999000000002 -> 0.75 0.99999996666666668\nfwd 0 0 -> 0 0\nfwd 1 1 -> 2 3\nfwd 1 0.5 -> 2 1.5\nfwd 0.5 1 -> 1 3\nfwd 0 1 -> 0 3\nfwd 1 0 -> 2 0\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2 3 -> 0.99999999999999989 0.99999999999999989\ninv 2 1.5 -> 0.99999999999999989 0.5\ninv 1 3 -> 0.5 0.99999999999999989\ninv 1.9999998999999999 1.5 -> 0.99999994999999997 0.5\ninv 1.5 2.9999999000000002 -> 0.75 0.99999996666666668\n== tran_open_knots_x\nfwd -0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0.5 -> 1 0.5\nfwd 1.5 0.5 -> 1.5 0.5\nfwd 2 0.5 -> 2 0.5\nfwd 3 0.5 -> 3 0.5\nfwd 3.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 4 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 4.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 0.5 -> 1.5 0.5\ninv 2.5 0.5 -> 2.5 0.5\ninv 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd -0.5 0.5 -> -0.5 0.5\nfwd 0 0.5 -> 0 0.5\nfwd 0.5 0.5 -> 0.5 0.5\nfwd 1 0.5 -> 1 0.5\nfwd 1.5 0.5 -> 1.5 0.5\nfwd 2 0.5 -> 2 0.5\nfwd 3 0.5 -> 3 0.5\nfwd 3.5 0.5 -> 3.5 0.5\nfwd 4 0.5 -> 4 0.5\nfwd 4.5 0.5 -> 4.5 0.5\ninv 1.5 0.5 -> 1.5 0.5\ninv 2.5 0.5 -> 2.5 0.5\ninv 0.5 0.5 -> 0.5 0.5\ninv 3.5 0.5 -> 3.5 0.5\nrate 0.5 0.5 1 1 -> 1\nrate 2 0.5 1 1 -> 1\n== tran_zero_width_x\nfwd 1 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0.25 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nrate 1 0.5 1 1 -> -1.7976931348623157e+308\nrate 1 0.5 1 2 -> -1.7976931348623157e+308\nrate 1 0.5 2 1 -> -1.7976931348623157e+308\nrate 1 0.5 2 2 -> -1.7976931348623157e+308\nfwd 1 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0.25 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 1 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nrate 1 0.5 1 1 -> 0\nrate 1 0.5 1 2 -> -1.7976931348623157e+308\nrate 1 0.5 2 1 -> 0\nrate 1 0.5 2 2 -> -1.7976931348623157e+308\n== inv_iterations\n-- InvNiter=1\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5025000000000002 1.5010416666666668 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.2116397807407409 4.3996876820484667 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179241 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvNiter=2\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999999999989 0.29999999999999993\ninv 1.0024565614997714 1.9990249199817101 -> 1 1.9999999999999998\ninv 1.5025000000000002 1.5010416666666668 -> 1.5 1.5\ninv 2.2116397807407409 4.3996876820484667 -> 2.2000000000000002 4.3999999999999986\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000000000004 0.050000000000000024\ninv 0.015401234567901234 2.0144753086419751 -> 2.7168747219304194e-18 1.9999999999999998\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000000000000013 2.0000000000000031\ninv 2.0033333333333334 0.0066666666666666671 -> 1.9999999999999998 6.1411669487870653e-18\n-- InvNiter=3\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999999999989 0.29999999999999993\ninv 1.0024565614997714 1.9990249199817101 -> 1 1.9999999999999998\ninv 1.5025000000000002 1.5010416666666668 -> 1.5 1.5\ninv 2.2116397807407409 4.3996876820484667 -> 2.2000000000000002 4.3999999999999986\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000000000004 0.050000000000000024\ninv 0.015401234567901234 2.0144753086419751 -> 2.7168747219304194e-18 1.9999999999999998\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000000000000013 2.0000000000000031\ninv 2.0033333333333334 0.0066666666666666671 -> 1.9999999999999998 6.1411669487870653e-18\n-- InvNiter=1, InvTol=1.0E-3\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999981266283 0.29999999987131842\ninv 1.0024565614997714 1.9990249199817101 -> 1.0000000000003448 2.0000000000004232\ninv 1.5025000000000002 1.5010416666666668 -> 1.5000000000015925 1.5000000000006584\ninv 2.2116397807407409 4.3996876820484667 -> 2.2000000001514728 4.3999999999341783\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000027029977 0.049999998427571142\ninv 0.015401234567901234 2.0144753086419751 -> 1.4656241101177261e-08 2.0000000086811034\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> 2.0000000000861475 -7.3439884454976393e-11\n-- InvNiter=2, InvTol=0.1\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999981266283 0.29999999987131842\ninv 1.0024565614997714 1.9990249199817101 -> 1.0000000000003448 2.0000000000004232\ninv 1.5025000000000002 1.5010416666666668 -> 1.5000000000015925 1.5000000000006584\ninv 2.2116397807407409 4.3996876820484667 -> 2.2000000001514728 4.3999999999341783\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000027029977 0.049999998427571142\ninv 0.015401234567901234 2.0144753086419751 -> 1.4656241101177261e-08 2.0000000086811034\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000004080050027 2.0000007290690727\ninv 2.0033333333333334 0.0066666666666666671 -> 2.0000000000861475 -7.3439884454976393e-11\n-- InvNiter=6, InvTol=1.0E-14\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999999999994 0.29999999999999999\ninv 1.0024565614997714 1.9990249199817101 -> 1.0000000000000004 2\ninv 1.5025000000000002 1.5010416666666668 -> 1.5 1.5\ninv 2.2116397807407409 4.3996876820484667 -> 2.1999999999999993 4.3999999999999995\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000000000008 0.050000000000000017\ninv 0.015401234567901234 2.0144753086419751 -> 5.331305994062551e-19 1.9999999999999998\ninv 3.0019444444444443 1.9890123456790123 -> 2.9999999999999996 1.9999999999999996\ninv 2.0033333333333334 0.0066666666666666671 -> 1.9999999999999998 6.1412679763126425e-18\n-- InvNiter=20, InvTol=1.0E-17\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> 1 2\ninv 1.5025000000000002 1.5010416666666668 -> 1.5 1.5\ninv 2.2116397807407409 4.3996876820484667 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179241 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvNiter=0\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5025000000000002 1.5010416666666668 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.2116397807407409 4.3996876820484667 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179241 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvNiter=-3\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5025000000000002 1.5010416666666668 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.2116397807407409 4.3996876820484667 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179241 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvTol=0\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> 1 2\ninv 1.5025000000000002 1.5010416666666668 -> 1.5 1.5\ninv 2.2116397807407409 4.3996876820484667 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179241 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvTol=-1\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999981266283 0.29999999987131842\ninv 1.0024565614997714 1.9990249199817101 -> 1.0000000000003448 2.0000000000004232\ninv 1.5025000000000002 1.5010416666666668 -> 1.5000000000015925 1.5000000000006584\ninv 2.2116397807407409 4.3996876820484667 -> 2.2000000001514728 4.3999999999341783\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000027029977 0.049999998427571142\ninv 0.015401234567901234 2.0144753086419751 -> 1.4656241101177261e-08 2.0000000086811034\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000004080050027 2.0000007290690727\ninv 2.0033333333333334 0.0066666666666666671 -> 2.0000000000861475 -7.3439884454976393e-11\n-- InvNiter=1, OutUnit=1\ninv 0.25827344135802466 0.30636676697530862 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.0024565614997714 1.9990249199817101 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5025000000000002 1.5010416666666668 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.2116397807407409 4.3996876820484667 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.9059816087517145 0.053345760784179241 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.015401234567901234 2.0144753086419751 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.0019444444444443 1.9890123456790123 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.0033333333333334 0.0066666666666666671 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n-- InvNiter=2, OutUnit=1\ninv 0.25827344135802466 0.30636676697530862 -> 0.24999999999999989 0.29999999999999993\ninv 1.0024565614997714 1.9990249199817101 -> 1 1.9999999999999998\ninv 1.5025000000000002 1.5010416666666668 -> 1.5 1.5\ninv 2.2116397807407409 4.3996876820484667 -> 2.2000000000000002 4.3999999999999986\ninv 2.9059816087517145 0.053345760784179241 -> 2.9000000000000004 0.050000000000000024\ninv 0.015401234567901234 2.0144753086419751 -> 2.7168747219304194e-18 1.9999999999999998\ninv 3.0019444444444443 1.9890123456790123 -> 3.0000000000000013 2.0000000000000031\ninv 2.0033333333333334 0.0066666666666666671 -> 1.9999999999999998 6.1411669487870653e-18\n== inv_outside\ninv -0.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5199999999999996 -> 2.9999999999999996 4.4999999999999991\ninv 1 -0.02 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -1 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 4 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 4.5999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5199999999999996 -> 2.9999999999999996 4.4999999999999991\ninv 1 -0.02 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -1 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 4 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 4.5999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -0.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.02 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3 4.5199999999999996 -> 2.9999999999999996 4.4999999999999991\ninv 1 -0.02 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv -1 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 4 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 4.5999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n== order1\nfwd 0.5 0.5 -> 1.5 2.5\nfwd 0 0 -> 1.5 2.5\nfwd 1 1 -> 1.5 2.5\nfwd 1.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 0 0 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nrate 0.5 0.5 1 1 -> 0\nrate 0.5 0.5 2 1 -> 0\n== rate\nrate 1.2 2.7000000000000002 1 1 -> 1.0017536\nrate 3 4.5 1 1 -> 0.95999999999999996\nrate -1 2 1 1 -> -1.7976931348623157e+308\nrate 1.2 2.7000000000000002 1 2 -> 0.0044655999999999932\nrate 3 4.5 1 2 -> -0.019999999999999574\nrate -1 2 1 2 -> -1.7976931348623157e+308\nrate 1.2 2.7000000000000002 2 1 -> 0.0047279999999999484\nrate 3 4.5 2 1 -> 0.039999999999999147\nrate -1 2 2 1 -> -1.7976931348623157e+308\nrate 1.2 2.7000000000000002 2 2 -> 1.0050559999999999\nrate 3 4.5 2 2 -> 1.0399999999999991\nrate -1 2 2 2 -> -1.7976931348623157e+308\nrate -1.7976931348623157e+308 2 1 1 -> -1.7976931348623157e+308\n!! AST: Error in routine rate at line 165 in file src/test/resources/probes/splinemap_probe.c.\n! astRate(SplineMap): Invalid output index (3) specified - should be in the range 1 to 2.\nstatus 233933178\n!! AST: Error in routine rate at line 165 in file src/test/resources/probes/splinemap_probe.c.\n! astRate(SplineMap): Invalid input index (0) specified - should be in the range 1 to 2.\nstatus 233933178\nrate -1 2 1 1 -> 1\nrate -1 2 1 2 -> 0\nrate -1 2 2 1 -> 0\nrate -1 2 2 2 -> 1\nrate 1.2 2.7000000000000002 1 1 -> 0.99817844899999997\nrate 1.2 2.7000000000000002 1 2 -> -0.0045150157037037036\nrate 1.2 2.7000000000000002 2 1 -> -0.0047695383333333334\nrate 1.2 2.7000000000000002 2 2 -> 0.99498388296296292\n== rate_testsplinemap\nrate 0.5 0.5 1 1 -> 2\nrate 1 1.5 1 1 -> 0.5\nrate 1 1.5 1 2 -> 0\n== knots_coeffs\nknots 0 0 0 0 0 1.5 3 4.5 4.5 4.5 4.5\ncoeffs 0 0.01 0.5 1.52 3.0099999999999998 3.98 4.5 0 0.52000000000000002 1.49 2.9900000000000002 4.0099999999999998 4.5099999999999998 -0.01 0.48999999999999999 1.5 3.02 4.0199999999999996 4.4900000000000002 0.02 0.51000000000000001 1.51 2.98 3.9900000000000002 4.5 0 0.5 1.48 3 4 4.5199999999999996\nknots 1 0 0 0 0 1.5 3 3 3 3\ncoeffs 1 0 0.01 0.02 0.01 0 -0.01 0.51000000000000001 0.52000000000000002 0.48999999999999999 0.5 0.53000000000000003 0.5 1.52 1.48 1.5 1.53 1.49 1.51 2.4900000000000002 2.5099999999999998 2.52 2.48 2.5 2.52 3.0099999999999998 3 2.9900000000000002 3.02 3.0099999999999998 3\nknots 2 0 0 0 0 1.5 3 4.5 4.5 4.5 4.5\ncoeffs 2 0.01 0.5 1.52 3.0099999999999998 3.98 4.5 0 0.52000000000000002 1.49 2.9900000000000002 4.0099999999999998 4.5099999999999998 -0.01 0.48999999999999999 1.5 3.02 4.0199999999999996 4.4900000000000002 0.02 0.51000000000000001 1.51 2.98 3.9900000000000002 4.5 0 0.5 1.48 3 4 4.5199999999999996\nknots 3 0 0 0 0 1.5 3 4.5 4.5 4.5 4.5\ncoeffs 3 0.01 0.5 1.52 3.0099999999999998 3.98 4.5 0 0.52000000000000002 1.49 2.9900000000000002 4.0099999999999998 4.5099999999999998 -0.01 0.48999999999999999 1.5 3.02 4.0199999999999996 4.4900000000000002 0.02 0.51000000000000001 1.51 2.98 3.9900000000000002 4.5 0 0.5 1.48 3 4 4.5199999999999996\nknots 1 0 0 0 0 1.5 3 3 3 3\ncoeffs 2 0.01 0.5 1.52 3.0099999999999998 3.98 4.5 0 0.52000000000000002 1.49 2.9900000000000002 4.0099999999999998 4.5099999999999998 -0.01 0.48999999999999999 1.5 3.02 4.0199999999999996 4.4900000000000002 0.02 0.51000000000000001 1.51 2.98 3.9900000000000002 4.5 0 0.5 1.48 3 4 4.5199999999999996\n== simp_inverse_after\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_inverse_before\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_same_direction\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n MapB = \t# Second component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n End CmpMap\n== simp_parallel\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 4 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n Series = 0 \t# Component Mappings applied in parallel\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n MapB = \t# Second component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n End CmpMap\n== simp_winmap\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n MapB = \t# Second component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 1 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n Sft2 = 2 \t# Shift for axis 2\n Scl2 = 3 \t# Scale factor for axis 2\n End WinMap\n End CmpMap\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin WinMap \t# Map one window on to another\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 1 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n Sft2 = 2 \t# Shift for axis 2\n Scl2 = 3 \t# Scale factor for axis 2\n End WinMap\n MapB = \t# Second component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n End CmpMap\n== simp_unit_between\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_different_coeffs\n-- simplified CmpMap same 1\n Begin CmpMap \t# Compound Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n End SplineMap\n MapB = \t# Second component Mapping\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n KX = 2 \t# Polynomial order in X direction\n KY = 2 \t# Polynomial order in Y direction\n NX = 2 \t# No. of coeffs in X direction\n NY = 2 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 1 \t# Knot 3 x position\n TX4 = 1 \t# Knot 4 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 1 \t# Knot 3 y position\n TY4 = 1 \t# Knot 4 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 2 \t# X coeff 2\n CU3 = 0 \t# X coeff 3\n CU4 = 2 \t# X coeff 4\n CV1 = 0 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = 3 \t# Y coeff 3\n CV4 = 3 \t# Y coeff 4\n End SplineMap\n End CmpMap\n== simp_outunit_differs\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\n== simp_inverted_cmpmap\nfwd 1.2 2.7000000000000002 -> 1.2 2.7000000000000011\nInvert a 0 test 0 b 1 test 1\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\nInvert a 0 test 1 b 0 test 1\nfwd 1.2 2.7000000000000002 -> 1.2 2.7000000000000011\n== simp_cmpmap_attrs\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\nInvert a 0 test 1 b 1 test 1\n-- simplified UnitMap same 0\n Begin UnitMap \t# Unit (null) Mapping\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n IsA Mapping \t# Mapping between coordinate systems\n End UnitMap\nInvert b 1 test 1 a 0 test 1\n== equal\nequal copy 1\nequal same values 1\nequal inverted 0\nequal inverted twice 1\nequal attributes differ 1\nequal different 0\nequal unitmap 0\nequal coefficient within tolerance 1\nequal coefficient beyond tolerance 0\nequal knot 0\n== load_roundtrip\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsSimp = 1 \t# Mapping has been simplified\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n KX = 4 \t# Polynomial order in X direction\n KY = 4 \t# Polynomial order in Y direction\n NX = 5 \t# No. of coeffs in X direction\n NY = 6 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 0 \t# Knot 2 x position\n TX3 = 0 \t# Knot 3 x position\n TX4 = 0 \t# Knot 4 x position\n TX5 = 1.5 \t# Knot 5 x position\n TX6 = 3 \t# Knot 6 x position\n TX7 = 3 \t# Knot 7 x position\n TX8 = 3 \t# Knot 8 x position\n TX9 = 3 \t# Knot 9 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 0 \t# Knot 2 y position\n TY3 = 0 \t# Knot 3 y position\n TY4 = 0 \t# Knot 4 y position\n TY5 = 1.5 \t# Knot 5 y position\n TY6 = 3 \t# Knot 6 y position\n TY7 = 4.5 \t# Knot 7 y position\n TY8 = 4.5 \t# Knot 8 y position\n TY9 = 4.5 \t# Knot 9 y position\n TY10 = 4.5 \t# Knot 10 y position\n CU1 = 0 \t# X coeff 1\n CU2 = 0.51000000000000001 \t# X coeff 2\n CU3 = 1.52 \t# X coeff 3\n CU4 = 2.4900000000000002 \t# X coeff 4\n CU5 = 3.0099999999999998 \t# X coeff 5\n CU6 = 0.01 \t# X coeff 6\n CU7 = 0.52000000000000002 \t# X coeff 7\n CU8 = 1.48 \t# X coeff 8\n CU9 = 2.5099999999999998 \t# X coeff 9\n CU10 = 3 \t# X coeff 10\n CU11 = 0.02 \t# X coeff 11\n CU12 = 0.48999999999999999 \t# X coeff 12\n CU13 = 1.5 \t# X coeff 13\n CU14 = 2.52 \t# X coeff 14\n CU15 = 2.9900000000000002 \t# X coeff 15\n CU16 = 0.01 \t# X coeff 16\n CU17 = 0.5 \t# X coeff 17\n CU18 = 1.53 \t# X coeff 18\n CU19 = 2.48 \t# X coeff 19\n CU20 = 3.02 \t# X coeff 20\n CU21 = 0 \t# X coeff 21\n CU22 = 0.53000000000000003 \t# X coeff 22\n CU23 = 1.49 \t# X coeff 23\n CU24 = 2.5 \t# X coeff 24\n CU25 = 3.0099999999999998 \t# X coeff 25\n CU26 = -0.01 \t# X coeff 26\n CU27 = 0.5 \t# X coeff 27\n CU28 = 1.51 \t# X coeff 28\n CU29 = 2.52 \t# X coeff 29\n CU30 = 3 \t# X coeff 30\n CV1 = 0.01 \t# Y coeff 1\n CV2 = 0 \t# Y coeff 2\n CV3 = -0.01 \t# Y coeff 3\n CV4 = 0.02 \t# Y coeff 4\n CV5 = 0 \t# Y coeff 5\n CV6 = 0.5 \t# Y coeff 6\n CV7 = 0.52000000000000002 \t# Y coeff 7\n CV8 = 0.48999999999999999 \t# Y coeff 8\n CV9 = 0.51000000000000001 \t# Y coeff 9\n CV10 = 0.5 \t# Y coeff 10\n CV11 = 1.52 \t# Y coeff 11\n CV12 = 1.49 \t# Y coeff 12\n CV13 = 1.5 \t# Y coeff 13\n CV14 = 1.51 \t# Y coeff 14\n CV15 = 1.48 \t# Y coeff 15\n CV16 = 3.0099999999999998 \t# Y coeff 16\n CV17 = 2.9900000000000002 \t# Y coeff 17\n CV18 = 3.02 \t# Y coeff 18\n CV19 = 2.98 \t# Y coeff 19\n CV20 = 3 \t# Y coeff 20\n CV21 = 3.98 \t# Y coeff 21\n CV22 = 4.0099999999999998 \t# Y coeff 22\n CV23 = 4.0199999999999996 \t# Y coeff 23\n CV24 = 3.9900000000000002 \t# Y coeff 24\n CV25 = 4 \t# Y coeff 25\n CV26 = 4.5 \t# Y coeff 26\n CV27 = 4.5099999999999998 \t# Y coeff 27\n CV28 = 4.4900000000000002 \t# Y coeff 28\n CV29 = 4.5 \t# Y coeff 29\n CV30 = 4.5199999999999996 \t# Y coeff 30\n NiterInv = 9 \t# Max number of iterations for iterative inverse\n OutUnit = 1 \t# How to handle out-of-bounds points\n TolInv = 1.0000000000000001e-09 \t# Target relative error for iterative inverse\n End SplineMap\nIsSimple loaded 1\nequal loaded 1\nInvNiter 9 test 1\nInvTol 1.0000000000000001e-09 test 1\nOutUnit 1 test 1\nSplineKx 4 test 0\nSplineKy 4 test 0\nSplineNx 5 test 0\nSplineNy 6 test 0\n== load_defaults\n Begin SplineMap \t# Map using a bi-cubic spline\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n KX = 1 \t# Polynomial order in X direction\n KY = 1 \t# Polynomial order in Y direction\n NX = 1 \t# No. of coeffs in X direction\n NY = 1 \t# No. of coeffs in Y direction\n TX1 = 0 \t# Knot 1 x position\n TX2 = 1 \t# Knot 2 x position\n TY1 = 0 \t# Knot 1 y position\n TY2 = 2 \t# Knot 2 y position\n CU1 = 4 \t# X coeff 1\n CV1 = \t# Y coeff 1\n End SplineMap\nInvNiter 6 test 0\nInvTol 9.9999999999999995e-07 test 0\nOutUnit 0 test 0\nSplineKx 1 test 0\nSplineKy 1 test 0\nSplineNx 1 test 0\nSplineNy 1 test 0\nfwd 0.5 0.5 -> 4 -1.7976931348623157e+308\n== fits_lsst2_tight\nwritten 0\nkeywords NAXIS1 NAXIS2\n== fits_lsst2_default\nwritten 1\nkeywords NAXIS1 NAXIS2 WCSAXES CRPIX1 CRPIX2 CRVAL1 CRVAL2 CTYPE1 CTYPE2 CDELT1 CDELT2 PC1_1 PC1_2 PC2_1 PC2_2 RADESYS WCSAXESA WCSNAMEA CRPIX1A CRPIX2A CRVAL1A CRVAL2A CTYPE1A CTYPE2A CDELT1A CDELT2A PC1_1A PC1_2A PC2_1A PC2_2A\n== fits_lsst2_wrapped\nwritten 0\nkeywords NAXIS1 NAXIS2\n== fits_lsst2_alternate\nwritten 1\nkeywords NAXIS1 NAXIS2 WCSAXES CRPIX1 CRPIX2 CRVAL1 CRVAL2 CTYPE1 CTYPE2 CDELT1 CDELT2 PC1_1 PC1_2 PC2_1 PC2_2 RADESYS WCSAXESA WCSNAMEA CRPIX1A CRPIX2A CRVAL1A CRVAL2A CTYPE1A CTYPE2A CDELT1A CDELT2A WCSAXESB WCSNAMEB CRPIX1B CRPIX2B CRVAL1B CRVAL2B CTYPE1B CTYPE2B CDELT1B CDELT2B PC1_1B PC1_2B PC2_1B PC2_2B\nwritten 0\nkeywords NAXIS1 NAXIS2\n== pr_open_knots_x\nfwd 0.5 0.10000000000000001 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0.5 0.29999999999999999 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0.5 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 3.5 0.29999999999999999 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 4 0.29999999999999999 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 2 0.29999999999999999 -> 2 0.29999999999999999\nfwd 1 0.59999999999999998 -> 1 0.59999999999999998\nfwd 3 0.59999999999999998 -> 3 0.59999999999999998\ninv 0.40000000000000002 0.29999999999999999 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 3.6000000000000001 0.29999999999999999 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2.5 0.29999999999999999 -> 2.5 0.29999999999999999\ninv 1 0.69999999999999996 -> 1 0.69999999999999996\ninv 3 0.69999999999999996 -> 3 0.69999999999999996\nrate 0.5 0.29999999999999999 1 1 -> -1.7976931348623157e+308\nrate 0.5 0.29999999999999999 2 2 -> -1.7976931348623157e+308\nfwd 0.5 0.10000000000000001 -> 0.5 0.10000000000000001\nfwd 0.5 0.29999999999999999 -> 0.5 0.29999999999999999\nfwd 0.5 0.69999999999999996 -> 0.5 0.69999999999999996\nfwd 3.5 0.29999999999999999 -> 3.5 0.29999999999999999\nfwd 0 0.69999999999999996 -> 0 0.69999999999999996\nfwd 4 0.29999999999999999 -> 4 0.29999999999999999\nfwd 2 0.29999999999999999 -> 2 0.29999999999999999\nfwd 1 0.59999999999999998 -> 1 0.59999999999999998\nfwd 3 0.59999999999999998 -> 3 0.59999999999999998\ninv 0.40000000000000002 0.29999999999999999 -> 0.40000000000000002 0.29999999999999999\ninv 3.6000000000000001 0.29999999999999999 -> 3.6000000000000001 0.29999999999999999\ninv 2.5 0.29999999999999999 -> 2.5 0.29999999999999999\ninv 1 0.69999999999999996 -> 1 0.69999999999999996\ninv 3 0.69999999999999996 -> 3 0.69999999999999996\nrate 0.5 0.29999999999999999 1 1 -> 1\nrate 0.5 0.29999999999999999 2 2 -> 1\n== pr_open_knots_y\nfwd 2 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 2 1 -> 2 1\nfwd 2 2 -> 2 2\nfwd 2 2.5 -> 2 2.5\nfwd 2 3 -> 2 3\nfwd 2 3.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 2 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nfwd 0 2 -> 0 2\nfwd 4 2 -> 4 2\nfwd 4 3 -> 4 3\nfwd 2 5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 2 2 -> 2 2\ninv 2 2.5 -> 2 2.5\ninv 2 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ninv 1 2.9998999999999998 -> 1 2.9998999999999998\ninv 4 3 -> 4 3\nrate 2 3 2 2 -> 1\nrate 2 0.5 2 2 -> -1.7976931348623157e+308\nfwd 2 0.5 -> 2 0.5\nfwd 2 1 -> 2 1\nfwd 2 2 -> 2 2\nfwd 2 2.5 -> 2 2.5\nfwd 2 3 -> 2 3\nfwd 2 3.5 -> 2 3.5\nfwd 2 4 -> 2 4\nfwd 0 2 -> 0 2\nfwd 4 2 -> 4 2\nfwd 4 3 -> 4 3\nfwd 2 5 -> 2 5\ninv 2 2 -> 2 2\ninv 2 2.5 -> 2 2.5\ninv 2 0.5 -> 2 0.5\ninv 1 2.9998999999999998 -> 1 2.9998999999999998\ninv 4 3 -> 4 3\nrate 2 3 2 2 -> 1\nrate 2 0.5 2 2 -> 1\n" +} diff --git a/src/test/resources/probes/xphmap_probe.c b/src/test/resources/probes/xphmap_probe.c new file mode 100644 index 0000000..e675caf --- /dev/null +++ b/src/test/resources/probes/xphmap_probe.c @@ -0,0 +1,266 @@ +/* xphmap_probe -- XphMap behaviour of the pinned C library that the + * xphmap oracle and the fixtures do not hold. + * + * XphMap has no public constructor, so every XphMap is read from a dump. + * The probe prints: the dump of an XphMap of each projection type, of an + * inverted one and of one whose Type is given in lower case with trailing + * spaces; the error a Type that is no projection name gives; the + * IsLinear attribute of each type; astEqual of XphMaps that differ in + * order, type and Invert attribute; the simplification of a series CmpMap + * of an XphMap and an inverted copy of it (with the Invert attributes of + * both before and after), of an XphMap and an uninverted copy, of XphMaps + * of different orders and types, of the same XphMap twice (the CmpMap + * holding one object), of the same XphMap twice with the second + * application inverted, of an XphMap and an inverted copy in parallel, + * and of three XphMaps in series; with the transformation of a few + * points through the CmpMap and through its simplification. + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * The arithmetic of xphmap.c is additions and subtractions of whole and + * half numbers, with no multiplications, so a compiler's multiply-add + * contraction cannot change it; the probe was built from the repository + * root against three builds of the C library at 3d3f255f on macOS AArch64 + * (Apple clang 21): two made with + * cmake -S reference/starlink-ast -B -DCMAKE_BUILD_TYPE=Release + * -DBUILD_TESTING=OFF [-DCMAKE_C_FLAGS=-ffp-contract=off] + * (the compiler's default flags, which contract a*b+c, and + * -ffp-contract=off), and one unoptimised build, which does not contract; + * the three outputs are identical. Each is linked with its static + * libraries: + * cc -std=c11 -I -o xphmap_probe + * src/test/resources/probes/xphmap_probe.c /libast.a + * /libast_pal.a /libast_err.a /libast_grf3d.a + * /libast_grf_2.0.a /libast_grf_3.2.a + * /libast_grf_5.6.a /libast_cminpack.a -lyaml -lm + * and run as ./xphmap_probe > xphmap_probe.txt 2>&1; the output, with + * trailing white space removed from every line, is stored as the "output" + * string of xphmap_probe.json, since the dumps hold C's item names, which + * the spelling check rejects. */ +#include +#include +#include +#include "ast.h" + +#define NPT 6 + +static void head( const char *name ) { + printf( "== %s\n", name ); +} + +/* Reports a failed call, then clears the status. */ +static int failed( void ) { + if( !astOK ) { + printf( "status %d\n", astStatus ); + astClearStatus; + return 1; + } + return 0; +} + +static AstMapping *load( int order, const char *type ) { + char dump[ 256 ]; + snprintf( dump, sizeof dump, " Begin XphMap\n Nin = 2\n IsA Mapping\n" + " Order = %d\n Type = \"%s\"\n End XphMap\n", order, type ); + return astFromString( dump ); +} + +static void invert_attrs( const char *when, AstMapping *p, AstMapping *q ) { + printf( "%s p %d set %d q %d set %d\n", when, astGetI( p, "Invert" ), + astTest( p, "Invert" ), astGetI( q, "Invert" ), astTest( q, "Invert" ) ); +} + +/* Points over the order 1 layout, in and out of the used area. */ +static const double xin[ NPT ] = { 1.0, 3.0, 4.25, 6.5, 9.0, 0.5 }; +static const double yin[ NPT ] = { 4.0, 2.5, 6.75, 7.0, 9.5, 0.5 }; + +static void tran( const char *label, AstMapping *map ) { + double x[ NPT ], y[ NPT ]; + int i; + astTran2( map, NPT, xin, yin, 1, x, y ); + if( failed() ) return; + for( i = 0; i < NPT; i++ ) { + printf( "%s %.17g %.17g -> %.17g %.17g\n", label, xin[ i ], yin[ i ], x[ i ], y[ i ] ); + } +} + +/* Simplifies cmp, printing the class of the result and the transformation + of the points through the CmpMap and through the result. */ +static void simplify( AstMapping *cmp ) { + AstMapping *simp = astSimplify( cmp ); + if( failed() ) return; + printf( "class %s\n", astGetC( simp, "Class" ) ); + tran( "cmp", cmp ); + tran( "simp", simp ); + simp = astAnnul( simp ); +} + +int main( void ) { + int status = 0, k; + const char *types[] = { "HPX0", "HPX12", "XPHN", "XPHS" }; + AstMapping *a, *b, *c, *cmp, *cmp2; + + astWatch( &status ); + setvbuf( stdout, NULL, _IONBF, 0 ); + + for( k = 0; k < 4; k++ ) { + char name[ 32 ]; + snprintf( name, sizeof name, "dump_%s", types[ k ] ); + head( name ); + a = load( k == 0 ? 0 : 3 + k, types[ k ] ); + astShow( a ); + printf( "IsLinear %d\n", astGetI( a, "IsLinear" ) ); + failed(); + a = astAnnul( a ); + } + + head( "dump_inverted" ); + a = load( 2, "XPHS" ); + astInvert( a ); + astShow( a ); + a = astAnnul( a ); + + head( "dump_default" ); + a = astFromString( " Begin XphMap\n Nin = 2\n IsA Mapping\n End XphMap\n" ); + if( !failed() ) { + astShow( a ); + a = astAnnul( a ); + } + + head( "type_case" ); + a = load( 3, "xphn " ); + if( !failed() ) { + astShow( a ); + a = astAnnul( a ); + } + + head( "type_unknown" ); + a = load( 3, "XPHQ" ); + failed(); + + head( "equal" ); + a = load( 3, "XPHN" ); + b = load( 3, "XPHN" ); + printf( "same %d\n", astEqual( a, b ) ); + c = load( 4, "XPHN" ); + printf( "order %d\n", astEqual( a, c ) ); + c = astAnnul( c ); + c = load( 3, "XPHS" ); + printf( "type %d\n", astEqual( a, c ) ); + c = astAnnul( c ); + astInvert( b ); + printf( "inverted %d\n", astEqual( a, b ) ); + astInvert( a ); + printf( "both inverted %d\n", astEqual( a, b ) ); + a = astAnnul( a ); + b = astAnnul( b ); + + head( "cancel" ); + a = load( 1, "XPHN" ); + b = load( 1, "XPHN" ); + astInvert( b ); + cmp = (AstMapping *) astCmpMap( a, b, 1, " " ); + invert_attrs( "before", a, b ); + simplify( cmp ); + invert_attrs( "after", a, b ); + cmp = astAnnul( cmp ); + a = astAnnul( a ); + b = astAnnul( b ); + + head( "cancel_inverse_first" ); + a = load( 1, "HPX0" ); + b = load( 1, "HPX0" ); + astInvert( a ); + cmp = (AstMapping *) astCmpMap( a, b, 1, " " ); + invert_attrs( "before", a, b ); + simplify( cmp ); + invert_attrs( "after", a, b ); + cmp = astAnnul( cmp ); + a = astAnnul( a ); + b = astAnnul( b ); + + head( "no_cancel_same_direction" ); + a = load( 1, "XPHS" ); + b = load( 1, "XPHS" ); + cmp = (AstMapping *) astCmpMap( a, b, 1, " " ); + invert_attrs( "before", a, b ); + simplify( cmp ); + invert_attrs( "after", a, b ); + cmp = astAnnul( cmp ); + a = astAnnul( a ); + b = astAnnul( b ); + + head( "no_cancel_orders" ); + a = load( 1, "XPHN" ); + b = load( 2, "XPHN" ); + astInvert( b ); + cmp = (AstMapping *) astCmpMap( a, b, 1, " " ); + simplify( cmp ); + cmp = astAnnul( cmp ); + a = astAnnul( a ); + b = astAnnul( b ); + + head( "no_cancel_types" ); + a = load( 1, "XPHN" ); + b = load( 1, "XPHS" ); + astInvert( b ); + cmp = (AstMapping *) astCmpMap( a, b, 1, " " ); + simplify( cmp ); + cmp = astAnnul( cmp ); + a = astAnnul( a ); + b = astAnnul( b ); + + head( "same_object_twice" ); + a = load( 1, "XPHN" ); + cmp = (AstMapping *) astCmpMap( a, a, 1, " " ); + simplify( cmp ); + printf( "after p %d set %d\n", astGetI( a, "Invert" ), astTest( a, "Invert" ) ); + cmp = astAnnul( cmp ); + a = astAnnul( a ); + + head( "same_object_then_inverse" ); + a = load( 1, "XPHN" ); + /* A series CmpMap of the XphMap and an inverted CmpMap of it and a + UnitMap, so that the list holds the one object twice with opposite + Invert values. */ + c = (AstMapping *) astUnitMap( 2, " " ); + b = (AstMapping *) astCmpMap( a, c, 1, " " ); + c = astAnnul( c ); + astInvert( b ); + cmp = (AstMapping *) astCmpMap( a, b, 1, " " ); + simplify( cmp ); + printf( "after p %d set %d\n", astGetI( a, "Invert" ), astTest( a, "Invert" ) ); + cmp = astAnnul( cmp ); + b = astAnnul( b ); + a = astAnnul( a ); + + head( "parallel" ); + a = load( 1, "XPHN" ); + b = load( 1, "XPHN" ); + astInvert( b ); + cmp = (AstMapping *) astCmpMap( a, b, 0, " " ); + cmp2 = astSimplify( cmp ); + if( !failed() ) { + printf( "class %s nin %d\n", astGetC( cmp2, "Class" ), astGetI( cmp2, "Nin" ) ); + cmp2 = astAnnul( cmp2 ); + } + cmp = astAnnul( cmp ); + a = astAnnul( a ); + b = astAnnul( b ); + + head( "three_in_series" ); + a = load( 1, "XPHS" ); + b = load( 1, "XPHS" ); + c = load( 1, "HPX0" ); + astInvert( b ); + cmp2 = (AstMapping *) astCmpMap( a, b, 1, " " ); + cmp = (AstMapping *) astCmpMap( c, cmp2, 1, " " ); + simplify( cmp ); + cmp = astAnnul( cmp ); + cmp2 = astAnnul( cmp2 ); + a = astAnnul( a ); + b = astAnnul( b ); + c = astAnnul( c ); + + return status; +} diff --git a/src/test/resources/probes/xphmap_probe.json b/src/test/resources/probes/xphmap_probe.json new file mode 100644 index 0000000..2594752 --- /dev/null +++ b/src/test/resources/probes/xphmap_probe.json @@ -0,0 +1,4 @@ +{ + "source": "probes/xphmap_probe.c", + "output": "== dump_HPX0\n Begin XphMap \t# HPX variant mapping\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Order = 0 \t# HEALPix order\n Type = \"HPX0\" \t# HPX projection centred on RA=0h\n End XphMap\nIsLinear 0\n== dump_HPX12\n Begin XphMap \t# HPX variant mapping\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Order = 4 \t# HEALPix order\n Type = \"HPX12\" \t# HPX projection centred on RA=12h\n End XphMap\nIsLinear 1\n== dump_XPHN\n Begin XphMap \t# HPX variant mapping\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Order = 5 \t# HEALPix order\n Type = \"XPHN\" \t# XPH projection centred on north pole\n End XphMap\nIsLinear 0\n== dump_XPHS\n Begin XphMap \t# HPX variant mapping\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Order = 6 \t# HEALPix order\n Type = \"XPHS\" \t# XPH projection centred on south pole\n End XphMap\nIsLinear 0\n== dump_inverted\n Begin XphMap \t# HPX variant mapping\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Order = 2 \t# HEALPix order\n Type = \"XPHS\" \t# XPH projection centred on south pole\n End XphMap\n== dump_default\n Begin XphMap \t# HPX variant mapping\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Order = 19 \t# HEALPix order\n Type = \"HPX12\" \t# HPX projection centred on RA=12h\n End XphMap\n== type_case\n Begin XphMap \t# HPX variant mapping\n Nin = 2 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Order = 3 \t# HEALPix order\n Type = \"XPHN\" \t# XPH projection centred on north pole\n End XphMap\n== type_unknown\n!! AST: Error in routine load at line 65 in file src/test/resources/probes/xphmap_probe.c.\n! astRead(XphMap): Illegal value 'XPHQ' supplied for the XphMap component 'Type'.\n! Error while reading a XphMap from a Channel.\nstatus 233933602\n== equal\nsame 1\norder 0\ntype 0\ninverted 0\nboth inverted 1\n== cancel\nbefore p 0 set 0 q 1 set 1\nclass UnitMap\ncmp 1 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 3 2.5 -> 3 2.5\ncmp 4.25 6.75 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 6.5 7 -> 6.5 7\ncmp 9 9.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 1 4 -> 1 4\nsimp 3 2.5 -> 3 2.5\nsimp 4.25 6.75 -> 4.25 6.75\nsimp 6.5 7 -> 6.5 7\nsimp 9 9.5 -> 9 9.5\nsimp 0.5 0.5 -> 0.5 0.5\nafter p 0 set 1 q 1 set 1\n== cancel_inverse_first\nbefore p 1 set 1 q 0 set 0\nclass UnitMap\ncmp 1 4 -> 1 4\ncmp 3 2.5 -> 3 2.5\ncmp 4.25 6.75 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 6.5 7 -> 6.5 7\ncmp 9 9.5 -> 9 9.5\ncmp 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 1 4 -> 1 4\nsimp 3 2.5 -> 3 2.5\nsimp 4.25 6.75 -> 4.25 6.75\nsimp 6.5 7 -> 6.5 7\nsimp 9 9.5 -> 9 9.5\nsimp 0.5 0.5 -> 0.5 0.5\nafter p 1 set 1 q 0 set 1\n== no_cancel_same_direction\nbefore p 0 set 0 q 0 set 0\nclass CmpMap\ncmp 1 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 3 2.5 -> 3 2.5\ncmp 4.25 6.75 -> 0.25 6.25\ncmp 6.5 7 -> 6.5 7\ncmp 9 9.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 1 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 3 2.5 -> 3 2.5\nsimp 4.25 6.75 -> 0.25 6.25\nsimp 6.5 7 -> 6.5 7\nsimp 9 9.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nafter p 0 set 1 q 0 set 1\n== no_cancel_orders\nclass CmpMap\ncmp 1 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 3 2.5 -> 12 12.5\ncmp 4.25 6.75 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 6.5 7 -> 13 4.5\ncmp 9 9.5 -> 15.5 2\ncmp 0.5 0.5 -> 14.5 14.5\nsimp 1 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 3 2.5 -> 12 12.5\nsimp 4.25 6.75 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 6.5 7 -> 13 4.5\nsimp 9 9.5 -> 15.5 2\nsimp 0.5 0.5 -> 14.5 14.5\n== no_cancel_types\nclass CmpMap\ncmp 1 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 3 2.5 -> 2.5 7\ncmp 4.25 6.75 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 6.5 7 -> 6 2.5\ncmp 9 9.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 1 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 3 2.5 -> 2.5 7\nsimp 4.25 6.75 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 6.5 7 -> 6 2.5\nsimp 9 9.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n== same_object_twice\nclass CmpMap\ncmp 1 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 3 2.5 -> 7 2.5\ncmp 4.25 6.75 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 6.5 7 -> 1 4.5\ncmp 9 9.5 -> 3.5 2\ncmp 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 1 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 3 2.5 -> 7 2.5\nsimp 4.25 6.75 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 6.5 7 -> 1 4.5\nsimp 9 9.5 -> 3.5 2\nsimp 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nafter p 0 set 1\n== same_object_then_inverse\nclass UnitMap\ncmp 1 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 3 2.5 -> 3 2.5\ncmp 4.25 6.75 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 6.5 7 -> 6.5 7\ncmp 9 9.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 1 4 -> 1 4\nsimp 3 2.5 -> 3 2.5\nsimp 4.25 6.75 -> 4.25 6.75\nsimp 6.5 7 -> 6.5 7\nsimp 9 9.5 -> 9 9.5\nsimp 0.5 0.5 -> 0.5 0.5\nafter p 0 set 1\n== parallel\nclass CmpMap nin 4\n== three_in_series\nclass XphMap\ncmp 1 4 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 3 2.5 -> 7 6.5\ncmp 4.25 6.75 -> -1.7976931348623157e+308 -1.7976931348623157e+308\ncmp 6.5 7 -> 2.5 3\ncmp 9 9.5 -> 5 5.5\ncmp 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 1 4 -> 5 8\nsimp 3 2.5 -> 7 6.5\nsimp 4.25 6.75 -> -1.7976931348623157e+308 -1.7976931348623157e+308\nsimp 6.5 7 -> 2.5 3\nsimp 9 9.5 -> 5 5.5\nsimp 0.5 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308\n" +}