diff --git a/docs/reports/2026-11-17-phase5-report.md b/docs/reports/2026-11-17-phase5-report.md new file mode 100644 index 0000000..8c198e9 --- /dev/null +++ b/docs/reports/2026-11-17-phase5-report.md @@ -0,0 +1,213 @@ +# Pure-Java AST: phase 5 report + +## Summary + +Phase 5 ported the remaining jniast Mappings on 17 November 2026, following the plan [`2026-11-17-pure-java-ast-phase5-mappings.md`](../superpowers/plans/2026-11-17-pure-java-ast-phase5-mappings.md). +LutMap, MathMap, TranMap, RateMap, GrismMap, PcdMap, SwitchMap, IntraMap (with the `Transformer`, `Transformer1` and `Transformer2` interfaces) and DssMap now exist with jniast's public API, `astEqual` is ported for every class that has an `Equal` method, and `JniastApiTest` passes for all of them; the only exclusions are jniast's implicit `DssMap()` constructor and IntraMap's finalizer. +`FitsChan.read()` and `write()` now handle `-LOG`, `-GRI`, `-GRA` and (as far as LutMap goes) `-TAB` axes, and `MakeSFMapping` is ported, so SpecFluxFrame converts between any components that C converts. +SPLAT's SpecFluxFrame conversions now work: phase 4 left every conversion but the equal-components one throwing `needs RateMap`, and the SPLAT-style FrameSets now give C's Mapping, simplified Mapping and values. +SelectorMap was moved to phase 6: its only constructor and every use take Regions. +Of the 6 rows of C's FITS conversion regression table that phase 4 left, 5 now give C's cards (the sixth, `lsst2_fits-wcs`, needs SplineMap), and the 4 transform-oracle headers that waited for MathMap and GrismMap now read and transform as C's do. +The deferred lists lost between a third and a half of their entries (table below), and the 106 Rust tests that waited for `astEqual` are translated. +Porting found a dozen places where the pinned C library behaves in a way worth reporting upstream, among them a TranMap simplification that reverses a transformation, a GrismMap merge that uses the wrong ZoomMap direction, and a SwitchMap whose own native dump changes its inverse when read back; they are recorded in [`docs/rust-c-differences.md`](../rust-c-differences.md) (46 new entries) and listed below. +The user decided three points about IntraMap, which replaced the pre-flight design: I/O by function name only with no Java deserialisation, a static process-wide registry of weak references, and no lock around Transformer calls. +Against the branch base the work adds 10,321 lines of main code and 37,178 lines of tests, and removes 355 and 1,545; `mvn verify` passes with 3,796 tests on JDK 21, and the tests pass on the JDK 27 runtime. + +## What was ported + +| Task | What | Main lines | Test lines | +| --- | --- | ---: | ---: | +| 1 | `LutMap` (C's last-value cache, `MapMerge`, `Equal`, dump and loader) and the `-TAB` read as far as C's `GetNamedTable` | 833 | 2,475 | +| 2 | `MathMap` expressions and transformation: the compiler, every function, the random generators, `Equal`, dump and loader | 3,156 | 4,594 | +| 3 | `MathMap` `MapMerge` and `Equal`, and C's `astUnitMapper` for non-linear units | 163 | 1,622 | +| 4 | `-LOG` FITS axes read and written with C's MathMap (`FitsLogMap` deleted); the `-TAB` read gate | 55 | 1,017 | +| 5 | `TranMap` | 565 | 1,982 | +| 6 | `astEqual` for every class with an `Equal` method, and the Simplifier's recursion guard through it (inserted; see below) | 563 | 2,378 | +| 7 | `RateMap` | 373 | 2,096 | +| 8 | SpecFluxFrame conversions (`MakeSFMapping` after `MakeMap3`, `MakeMapF`, `MakeMapI`), SPLAT-style FrameSets | 88 | 7,664 | +| 9 | `GrismMap` and the `-GRI` and `-GRA` FITS read and write (`ExtractGrismMap`) | 1,056 | 2,132 | +| 10 | `PcdMap` | 778 | 3,524 | +| 11 | `SwitchMap`, and GrismMap's treatment of a non-finite input | 714 | 4,088 | +| 12 | `IntraMap`, `Transformer`, `Transformer1`, `Transformer2`, the registries, the `NeedsChannelizing` hooks in `Channel` and `FitsChan` | 1,300 | 1,199 | +| 13 | `DssMap` (loaded from dumps; no public constructor) | 734 | 2,243 | +| 14 | The remaining Rust tests, three carried items, the deferred sweep, the nested-series memory tests | 10 | 460 | +| 15 | This report | | | + +Lines are those each task's commits add, the fix commits included; summed (10,388 and 37,474), they exceed the branch totals by the lines a later task changed again. +The test lines of Task 8 include a 566 KB probe output of full dumps. +Each of Tasks 1 to 14 was done by one implementer subagent, reviewed by a second, and verified in the controlling session before it was recorded (the full test suite, the deferred lists changing only by removal or by a more specific class reason, and the C source for each finding). +The reviews found one Critical problem (Task 12, below) and nine Important ones; every one was fixed in a fix round. +Tasks 2, 3, 5, 7, 9 and 10 were approved at the first review; Task 9's review left a minor that the controller re-graded as a fix-round item, because two tests compared a bad value with a bad value. +Expected values that no fixture or oracle held were taken from probes run against the pinned C library; the probe sources and their outputs are committed under `src/test/resources/probes` (`lutmap_probe`, `mathmap_probe`, `mathmap_simplify_probe`, `fitslog_probe`, `alt_offset_probe`, `tranmap_probe`, `equal_probe`, `simplify_input_probe`, `ratemap_probe`, `specflux_probe`, `grismmap_probe`, `pcdmap_probe`, `switchmap_probe`, `intramap_load_probe`, `dssmap_probe`, `polymap_cancel_probe`). +The tasks were committed between 10:27 and 23:08 on 17 November. + +## Departures from the plan + +The [rulings](2026-11-17-phase5-rulings.md) give each with its reason and cost; these change what later work builds on. + +- **A new Task 6, `astEqual`, and a renumbering.** + After Task 5 the controller inserted a task to port `astEqual`, and the plan's old Tasks 6 to 14 became 7 to 15. + `ratemap.c` and `switchmap.c` call `astEqual` on the Mappings they hold, and a comparison of native text, which Task 5's `TranMap.equalTo` used, is a heuristic C lacks: ZoomMap(2) inverted equals ZoomMap(0.5) in C. + The task also replaced the Simplifier's text comparison in its recursion guard with `astEqual`, as C has it, and removed 106 `astEqual` entries from `rust-tests.txt`. + References in earlier ledger entries to "Task 7" (SpecFluxFrame) and "Task 13" (CmpMap `Equal`) mean Tasks 8 and 14. +- **SelectorMap moved to phase 6.** + The spec lists it in item 4, but its only constructor and every use take Regions (spec item 6). + The ten `test_switchmap.rs` tests whose forward selector is a SelectorMap of Boxes, and the three SelectorMap cases of `oracle/equal.json`, wait for it; so do the SwitchMap cases of `test_rate_oracle.rs`. +- **IntraMap's design changed after the review.** + The pre-flight ruling had the Transformer written into `IntraFlag` in jniast's printable encoding wherever the IntraMap sat in a dumped object, and the loader decoding it at any depth. + The Task 12 review found that this made reading any dump deserialise attacker-chosen classes, a Critical security finding: jniast's exposure was near zero because it channelizes only the top-level object and sits behind URITF registration. + The user then decided three points, which superseded the pre-flight ruling: + - IntraMap I/O is by function name only, as in C and Rust, with no Java deserialisation, and a code note marks where jniast's serialised-Transformer path would go (the user is "99% certain no-one has ever used a Java-only IntraMap in production"); + - constructing an IntraMap registers its Transformer by function name in a static process-wide registry of weak references, as C's `astIntraReg` table and jniast's `construct` do, so same-process round trips work (the per-read registry stays for C fixtures); + - no lock is held around Transformer calls, and the Javadoc says `tranP` may be called concurrently and must be thread-safe (the review had found that jniast and C both serialise these calls, through `AstLock` and `LOCK_MUTEX2`). + A later controller ruling made an identity-hash collision between two live Transformers take the next free name (`name#1`, ...) and not fail with `AST__MRITF`. +- **The `-TAB` read change belongs to Task 1.** + LutMap arrives there, so Task 1 carries the read to C's next step, `needs FitsTable`, and Task 4 only checks it; the five `test_fitschan_tab.rs` tests are listed with `needs FitsTable`. +- **`FitsLogMap` is deleted.** + C builds a MathMap for a `-LOG` axis and puts the same one in the returned Mapping, so a separate class would dump and simplify unlike C. +- **Phase 4's SpecFluxFrame rulings are undone.** + Every conversion that phase 4 had throw `needs RateMap` now checks C's Mapping and values from a probe. +- **Java follows C where phase 2 and the Rust port restore an Invert attribute.** + After a successful DssMap merge the WinMap keeps the list's Invert value, and after a cancellation the PolyMap does, as C leaves them (controller ruling); the PolyMap departure of phase 2 was brought into line in Task 14. + Where C's `astSetInvert` leaves an attribute set on a neighbour, Java puts it back set or unset as it was, the library-wide convention, which only `test("Invert")` can see. +- **The `brad` row left `simplify-cases.txt`.** + Task 1 gave it the reason `needs simplification` (C's CmpMap `Equal` changes a shared WcsMap's Invert); Task 6's review had the controller make `SimplifyRegressionTest` compare the input's dump after simplification with C's where a probe records it, which cleared the row without relaxing the shared gate. +- **Pinned C already contains fixes the Rust quirks file lists as open.** + They are TranMap's `RemoveRegions` axis count (`bf819d17`), PcdMap's inverted-ZoomMap `PcdZoom`, LutMap's value beyond the first entry (`ee96dc91`) and IntraMap's null dereference on a Full dump with no `IntraFlag` (`4fe377c3`); Java follows the pin. +- **Task 14 had nothing to translate.** + Every `rust-tests.txt` entry removed in the phase has a Java test of the same name; the task made three carried items, swept the lists, and listed four never-listed Rust files. +- **Nested-series memory tests run in a child JVM.** + The brief suggested `ThreadMXBean` allocated bytes, which measures total allocation (192 MiB with batching against 224 MiB without), so the tests bound peak heap with `-Xmx88m` in a child JVM instead. + +## Gates + +| Gate | Before | After | +| --- | --- | --- | +| `wcsconv/cases.txt` rows giving C's cards | 188 of 194 | 193 of 194 | +| `wcsconv.txt` entries | 6: MathMap 3, GrismMap 2, SplineMap 1 | 1: SplineMap 1 (`lsst2_fits-wcs`) | +| `headers.txt` entries (transform oracle) | 4: MathMap 3, GrismMap 1 | 0 | +| `framesets.txt` entries | 10 | 3 (Box, Circle, PointList, PointSet, Prism; Box, PointSet; SplineMap) | +| `full-dumps.txt` entries | 365 | 197 | +| `read-warnings.txt` entries | 384 | 199 | +| `serialisation.txt` entries | 383 | 198 | +| `simplify-cases.txt` entries | 255 | 125 | +| `simplify.txt` entries | 356 | 191 | +| `rust-tests.txt` entries | 336 | 222, after adding 5 `needs FitsTable` entries (Task 4) and 39 never-listed entries (Task 14: 32 UnitNormMap, 1 Box, 1 NullRegion, 5 Rust-only allocation-counting tests) | +| `FitsChanCursorOracleTest` cases run | 257 | 257 (`alt_axes_alt_offset` now runs, licensed at libm level, and moved from `needs MathMap` to the runtime-Math exclusions) | +| Tests | 3,229 | 3,796 | + +No entry of the lists still names LutMap, MathMap, TranMap, RateMap, GrismMap, PcdMap, SwitchMap, IntraMap, DssMap or `astEqual`; what remains names Regions (Box, Circle, Interval, PointList, PointSet, NullRegion, Prism, SelectorMap), UnitNormMap, NormMap, XphMap, ChebyMap, SplineMap, FitsTable, hardware SIMD or Rust-only API. +Per task, the deferred lists lost: Task 1 84 gate entries (and 6 Rust tests), Task 5 76 (`needs TranMap`) plus a narrowing, Task 6 106 `astEqual` entries, Task 7 86 (`needs RateMap`), Task 9 86, Task 10 127, Task 11 87, Task 12 40 (IntraMap fixtures, 10 in each of four lists), Task 13 31. +Rewriting the lists with `-Dast.writeDeferred=true` after the sweep changes nothing. +New C-probe suites: `LutMapTest` and `LutMapForwardOracleTest`, `MathMapTest` (probe `evaluate`, `simplify` and error cases), `FitsLogAxesTest`, `TranMapTest`, `EqualTest` (92 tests, with `oracle/equal.json`), `RateMapTest` and `RateOracleTest`, `SpecFluxFrameTest` (42 tests, native dumps of C's simplified Mappings), `GrismMapTest`, `PcdMapTest` (43 tests, every comparison exact), `SwitchMapTest`, `IntraMapTest` and `IntraMapOracleTest`, `DssMapTest` (23 tests). +Cases of earlier oracles that waited for these classes now run, among them the 1,088 SpecFluxFrame attribute cases that phase 4 skipped and the SpecFluxFrame cases of the `frame_class`, `frame_axis` and `integrity` oracles. +`mvn verify` passes on JDK 21 (3,796 tests, Checkstyle and PMD clean), and the tests pass on the JDK 27 runtime. + +## Tolerances and excuses + +Removed: none. +Added: + +| Where | What | Measured size and cause | +| --- | --- | --- | +| `MathMapTest` library functions | 2 ULP in the evaluate case, 4 ULP in transformations and Gaussian sequences; bad, zero, integer and non-libm values exact | Last bits of `sin`, `log` and the like between Java's `Math` and macOS libm; not measured per value | +| `MathMapTest` Gaussian sequences | Exact `%.17g` comparisons that depend on the last bit of `Math.log` | Pass on JDK 21 and 27 | +| `MathMapTest` errno-trapped values | 22 probe values listed explicitly (`ERRNO_TRAPPED`, `ERRNO_CASES`): Java gives AST__BAD where the pinned macOS C gives an infinity | C's `CATCH_MATHS_*` traps need glibc's `errno`; macOS's libm only sets `MATH_ERREXCEPT` (ruling) | +| Units MathMaps and the FluxFrame log conversion | 1e-14 relative | Last bits of `exp` and `log10`; dumps, labels and simplification structure exact | +| `FitsChanCursorOracleTest` `alt_axes_alt_offset` | CDELT1B within 1.5e-15 relative, PC2_1B within 2.3e-15 absolute (licensed at libm level) | The simplified pixel to SKY_POLE Mapping dumps identically to C's; outputs differ by at most 2.2e-16 rad (1 ULP of a unit-vector component) on a 101 by 11 grid, through the same SphMaps and TAN WcsMap whose 1-ULP differences already license `alt_axes_offset`'s CDELT2; PC2_1B passes only because a PC element is compared relative to 1 | +| `FitsLogAxesTest` pixel coordinates | 1e-12 absolute (largest measured 3.4e-13); cards within libm rounding | CDELT1 differs from C's by 3 ULP (`...397` against `...402`): the fit uses the axis's `exp` and `log` values, of which `java.lang.Math` gives a different last bit from macOS libm for 13 and 20 of the 1,024 pixels; the inverse multiplies the 5e-16 relative error by the distance from CRPIX; reading C's cards reproduces C's pixels exactly | +| `FitsChanWcsWriteTest.GRISM_RTOL`, `FitsWcsSpectralTest` | 1e-8 relative, on rate-derived lines only (`pixel` lines, the WinMap's `Sft1` and `Scl1`, `CDELT` cards); every other line, cards included, within libm rounding | The grism read divides by C's numerical `astRate`; `Math.asin` and `Math.tan` differ from libm by 1 ULP (up to 32 near CRVAL), and the rate's interval choice amplifies that to 1.7e-10 and 8e-10 relative in the AWAV-GRA and nm cases (measured with a side probe) | +| `DssMapTest` transformations | Pixel outputs within `LIBM_RTOL` of the plate coordinate (about 4e-10 pixel); the right-ascension wrap checked to 2 ULP | `Math.tan` differs from macOS libm by 1 ULP at the fixture's plate declination; the wrap test guards against a two-pi-sized error the relative tolerance cannot see | +| `PcdMapTest`, `LutMapTest` probe comparisons | Exact | No elementary function is involved | +| `FitsChanWriteTest.NOT_ROUND_TRIPPED` `freq-log.head` | Listed as DIFFERS | C's own round trip gives GHz where the header gives Hz (see the C quirk below); Java writes the same cards | + +## Defects found in the C library + +All are in the pinned library (`3d3f255f`); "probe" means a probe against it showed the behaviour, "reading" that it follows from the code. +Each is recorded in [`docs/rust-c-differences.md`](../rust-c-differences.md) with what Java does; Java follows C in every case that has a defined result, and gives a defined result where C's is undefined. +The first four are the ones most worth reporting upstream. + +| Where | Behaviour | Confirmed | +| --- | --- | --- | +| `tranmap.c` `MapMerge` | A TranMap whose two components are the same Mapping inverted when the TranMap was made simplifies to that component applied forward: the else branch copies the Mapping with its invert flag but leaves `invert_list[where]` at 0, so TranMap(inv M, inv M) becomes M forward, and the transformation changes (forward 2.5 gives 1.58 originally and 6.25 simplified) | Probe (`simp_equal_inverted_mathmaps`, `simp_equal_inverted_lutmaps`); the reviewer confirmed it in the source | +| `grismmap.c` `CanMerge` | Takes a ZoomMap's factor from the ZoomMap's own Invert attribute and not from the list's value, so a GrismMap beside an inverted ZoomMap simplifies to a GrismMap that does not transform as the pair | Probe (three cases); the reviewer confirmed it | +| `switchmap.c` `Dump` and loader | `Dump` writes `ISInv` only when it is true and not helpful, so it is never written when 0; the loader takes an absent `ISInv` as `FSInv`; every native round trip of a SwitchMap with `FSInv` 1 and `ISInv` 0 therefore reloads with the inverse selector inverted: `astEqual` is false and the inverse of 1000 changes from 1 to 47.45 | Probe (`dump_fsinv_set_isinv_unset`); the review corrected the first wording, which blamed a hand-edited dump | +| `switchmap.c` `MapMerge` | Sets the Invert attributes back in the order it set them, so a Mapping the SwitchMap holds twice keeps the value recorded for its first place | Task 11's probe cases | +| `switchmap.c` `astInitSwitchMap` | The route-Nout error prints the input counts: "Route Mapping number 2 has 1 output(s) but the first route Mapping has 1 output(s)." | Probe (`error_route_nout`) | +| `cmpmap.c` `Equal` | The non-expanded branch changes the Invert attribute of a component that is the same object in both lists and leaves it at the first list's value, so a shared WcsMap in `brad.map` ends with Invert 0 (transformations agree, because `Transform` resets each component's Invert) | lldb trace and probe | +| `ratemap.c` `MapMerge` | A RateMap beside its inverse, in a series CmpMap that defines neither direction, becomes a UnitMap that defines both: UnitMap(2) for R then inv(R), UnitMap(1) for inv(R) then R | Probe (`cancel_two_inputs_upper`, `cancel_two_inputs_lower`) | +| `lutmap.c` `Transform` | Keeps the last input and output of each direction and returns the kept output for the same input after LutInterp has changed; a copy keeps them too | Probe (`cache`, `cache_copy`) | +| `lutmap.c` `MapMerge` | Compares the nominated LutMap with its own Invert attribute and not the list's value: in an inverted series CmpMap a LutMap and a copy of itself become a UnitMap, which changes the transformation, and a LutMap and its inverse are kept; a linear table whose ends are equal is neither replaced nor cancelled | Probe (`inverted_cmp_lut_lut`, `inverted_cmp_lut_lutinv`) | +| `mathmap.c` `Equal` | Does not compare the last opcode of each function (`y=x+1` equals `y=x-1`, `max` equals `min`) and takes an opcode count of 0, 1, 62 or 63 as a constant; for a one-opcode function such as `y=` it reads past the constants and segfaults | Probe (`equal`) and a scratch probe for the segfault | +| `mathmap.c` Gaussian generator | The saved second Gaussian value and its state are static variables shared by every MathMap, so interleaved calls on two MathMaps, or on a MathMap and its copy, change each other's values; Java keeps the value in each MathMap's own context | Probe (`random_copies`, `gauss_two_mathmaps`) | +| `mathmap.c` `Rand` | A Seed below 1 gives values far outside 0 to 1 (64-bit `long` plus `LONG_MAX`) | Reading, mirrored | +| `mathmap.c` loader | A dump with `Nfwd` below the number of outputs or `Ninv` below the inputs reads out of bounds; Java refuses it with `AST__INNTF` | Reading | +| `mathmap.c` documentation | The prologue lists the unary operators above `**`, but `EvaluationSort` binds `**` tighter, so `-x**2` is `-(x**2)` | Probe (`evaluate`); documentation only | +| `matrixmap.c` `Equal` | Expands and recompresses both MatrixMaps, which can zero negligible elements of a MatrixMap stored in full form, so a comparison changes its arguments; the Simplifier's guard reaches it through shared components | Reading | +| `zoommap.c` `Equal` | Compares the stored factor, which is zero after Zoom is cleared and has an infinite reciprocal, so a cleared ZoomMap compares unequal to ZoomMap(1) | Reading | +| `pcdmap.c` `Equal`, `MapMerge` | `Equal` uses `astEQUAL` (floor 1e-12) and `MapMerge` and `CanMerge` use the file's own `EQUAL` (floor `1e5*DBL_MIN`), so a Disco of 1e-13 equals zero in `astEqual` but is not reduced to a UnitMap; `Equal` of PcdMaps and GrismMaps compares stored values, so an unset value differs from one set to its default | Probe (`small_disco`, `equal/small_vs_zero_disco`) | +| `dssmap.c` `MapMerge` | After a successful merge the WinMap it merged with keeps the list's Invert value (C annuls its pointer before the restore) | Probe (`invert_attr_both_inverted`: 1 becomes 0) | +| `dssmap.c` `platepos` | Adds its own `twopi`, 6.28318530717959, to a negative right ascension, a little more than the double nearest to two pi, so a wrapped value is about four ULP larger | Probe (`tran_pltra_small`: the round trip through `platepix` is 2.4e-10 pixel short) | +| `intramap.c` `astLoadIntraMap` | Checks the numbers of coordinates as the inverted IntraMap reports them, so an inverted non-square IntraMap reads back as `AST__BADNI` | Probe (`intramap_load_probe.c`) | +| `intramap.c` `Transform` | Holds `LOCK_MUTEX2` around every call of a registered function; not a defect, but the one place Java departs by design (no lock) | Reading | +| `tranmap.c` `Decompose` | Leaves the series flag unset (its documentation says zero), so the caller gets back the value it passed | Probe | +| `fitschan.c` `SpectralAxes` | Changes Hz to GHz for a narrow spectral range: `IsMapLinear` rejects the Hz to GHz ZoomMap over [1420399999.49, 1420400000.51] Hz because the GHz values are rounded at about 2e-7 of their range, so a `-LOG` axis with a tiny increment is written as linear GHz; the caller's FrameSet keeps its Unit | lldb trace, probes `freq_log_head_unit` and `write_log_unit_unitmap` | + +Rust-side findings, from the same work: Rust's `DssMap::try_merge` would, by reading, merge a WinMap on the wrong side (a forward DssMap followed by a WinMap), which C does not; Rust's `make_map*` for SpecFluxFrames raise `AST__BADUN` and skip the Domain check where C finds no conversion; Rust's `` of 15 is a Rust bug where C gives 17; and the Rust `c-library-quirks.md` wrongly lists GrismMap among the loaders that drop `IsSimp`. +That file belongs to a reference submodule and was not edited; the TranMap, RateMap, GrismMap, DssMap and gauss entries are candidates for it. + +Kept as C has them, since they are defined: `astInitMathMap`'s `AST__BADNI` status for `nout < 1`; MathMap's NaN made inside an expression passing to the output; ZoomMap `Equal` comparing the stored factor; FrameSet `Equal` ignoring the FrameSets' Invert attributes; the route-Nout message of SwitchMap. +Where C's behaviour is undefined, Java defines it: a negative `Nlut` loads an empty table, a one-opcode function's constants past the end match only when neither function has them, `PermMap` constants past the end give the bad value, and a double outside `int` range converts as Java's cast does. + +## Final review + +The whole-branch review (`c5468a2..423be1e`) found no Critical or Important issue and judged the branch ready to merge. +It read the cross-cutting changes, IntraMap and the FITS code in full, and judged LutMap, PcdMap, GrismMap, DssMap, TranMap and the MathMap parser mainly by differential fuzzing against the pinned C build, about 16,600 cases: + +- 11,000 MathMap expressions, valid and malformed: every status and message as C's; values as C's except 8 last-bit libm differences, once the C driver was linked with `exp`, `cosh`, `sinh`, `pow` and `ldexp` that set `errno` as glibc does (all 134 macOS inf/NaN-against-BAD differences then went away, so Java implements the Task 2 ruling exactly). +- 2,356 random Mappings mixing every new class: native dumps, simplified dumps and `astEqual` results identical. +- 293 objects through a NATIVE FitsChan: identical cards, and C's cards read back identically. +- 766 SpecFluxFrame conversions: identical. +- 2,200 mutated `-LOG` and grism headers: identical reads, warnings and errors; written grism values differ only through libm. + +Its five Minor findings are deferred: + +- A RateMap loaded from a dump without `Inv = 0` returns the forward rate when asked for the inverse, where C refuses it with AST__INTER (`RateMap.java:193-197`); AST always writes `Inv = 0`. +- After a failed transformation C leaves a SwitchMap's selector and route Invert attributes swapped and Java restores them; not yet in `docs/rust-c-differences.md`. +- For a RateMap's undefined direction C ends with AST__INTER after AST__TRNND and Java with AST__TRNND; not yet recorded. +- `IntraMap` wraps a Transformer's `Exception` but lets an `Error` through, as jniast did; its Javadoc does not say so. +- The minors carried in the rulings file. + +The fuzzing also found three C crashes, now in the PR #104 defect report with probes run against an ASan build of the PR tip: `mathmap.c` `Equal` reads through a NULL constant list for a one-opcode function such as `y=`; `astLoadMathMap` reads past its function array when `Nfwd` is below `Nout`; and RateMap `Transform` dereferences the result PointSet after its parent has failed, which a SwitchMap with an inverted RateMap route reaches from `astTran1`. +A fourth, the SpecFluxFrame dump overflow, is the FluxFrame `comm[50]` overflow already reported. + +## Gaps and risks + +- **SelectorMap and Regions.** + Phase 6 must port SelectorMap with Regions, SwitchMap's, TranMap's and RateMap's `RemoveRegions` (the pinned TranMap behaviour returns `astUnitMap( astGetNin( newmap1 ) )`), and translate the ten SwitchMap tests and three `equal.json` cases that wait for them. +- **FitsTable.** + A `-TAB` axis reads as far as `needs FitsTable`, and the five `test_fitschan_tab.rs` tests are untranslated, though the first two assertions of `check_tab` could run now. +- **IntraMap reachability and threading.** + A same-process read finds a Transformer through the process-wide table only while an IntraMap using it is reachable, and Java 8 has no `reachabilityFence`, so a round-trip test could in theory lose it first. + Two threads constructing the first IntraMaps of one Transformer at once, with a lapsed name earlier in its name chain, could get two names. + A Transformer that is not thread-safe gives wrong results when IntraMaps run on several threads, as the Javadoc says. + `IntraRegistry.lapse` is package-private only for a test. + A dump written in another process by jniast with a serialised Transformer reads back as a plain string and needs its Transformer registered. +- **MathMap's per-MathMap random state.** + This is the one place Java deliberately gives different results from C for MathMaps (interleaved `gauss` calls on two MathMaps), because Review Focus 2 needs a copy to give its original's sequence; mirroring C needs a synchronised static. +- **Overflow trapping follows glibc.** + An overflowing MathMap expression gives AST__BAD where the pinned macOS C gives an infinity; 30 expected values would revert if the ruling were reversed. +- **Tolerances above libm rounding.** + GrismMap's rate-derived lines are compared to 1e-8 and a real regression below that would pass; `alt_axes_alt_offset` is licensed at 1.5e-15 relative. +- **Rust literals in equality tests.** + The equality tests outside `EqualTest` (PermMapTest, CmpMapTest, WcsMapTest, PolyMapTest, MatrixMapTest, SpecMapTest, SpecFrameTest, TimeMapTest, TimeFrameTest, FrameEqualityTest, FluxFrameTest) still assert Rust's literals, though C's answers sit in `equal_probe.out` under the same names; those checked by eye agree, and `EqualTest.assertAsC` could take them. +- **Rust tests of earlier phases.** + A name scan found tests with no Java test of a matching name and no list entry (the `fitschan` unit tests `enc_iraf`, `enc_pc`, `fset_to_store/*` and `wcs_write/mod.rs`, 31 non-gate tests of `test_simplify_regression.rs`, some FITS oracle gates, the vmath kernels); they are probably translated under other names or covered by gates, but this was not verified. +- **Minor items left.** + `TranMap`'s constructor runs `count()` twice; `RateTest` and `TranGridTest` have ragged Javadoc; `PcdMapTest`'s NaN-protocol test treats bad and NaN interchangeably; `specflux_probe.out` is 566 KB of full dumps; the Rust repository's `c-library-quirks.md` has no gauss-statics entry. +- **Runtimes.** + The tests were run on JDK 21 and on the JDK 27 runtime, not on a Java 8 runtime; the child-JVM memory tests use only Java 8 API and HotSpot options but were not tried there. + +## Rulings + +Every decision made while executing the plan where it was wrong, unclear or silent, every departure from Rust or C and every C quirk kept is in [`2026-11-17-phase5-rulings.md`](2026-11-17-phase5-rulings.md), with its reason and its cost if wrong: 181 rulings, 163 by the implementers and 18 by the controller and the user. diff --git a/docs/reports/2026-11-17-phase5-rulings.md b/docs/reports/2026-11-17-phase5-rulings.md new file mode 100644 index 0000000..392e0f3 --- /dev/null +++ b/docs/reports/2026-11-17-phase5-rulings.md @@ -0,0 +1,269 @@ +# Phase 5: rulings + +These are the decisions made while executing the phase 5 plan ([`2026-11-17-pure-java-ast-phase5-mappings.md`](../superpowers/plans/2026-11-17-pure-java-ast-phase5-mappings.md)) where the plan was wrong, unclear or silent, or where the port departs from Rust or C or keeps a C quirk. +They are copied from the execution ledger (the controller's rulings and the user's decisions) 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, then the controller's, in the order they were made. +The plan's Task 6 (astEqual) was inserted during the phase, so the tasks are numbered as in the plan as it now stands: Tasks 1 to 5 are as first written, and what was Task 6 is Task 7. +Each ruling gives what was decided, why, and what it costs if wrong. +A later ruling can reverse an earlier one; a ruling that a later one replaced carries a bracketed note saying so. +There are 181 rulings, 163 by the implementers, 18 by the controller and the user. +The phase report is [`2026-11-17-phase5-report.md`](2026-11-17-phase5-report.md). + +## Plan review + +- Ruling: execute without a separate plan review — the user asked to "start on next phase" after phases 3 and 4 ran the same way — cost if wrong: the user redirects mid-phase. +- Ruling: SelectorMap is out of this phase although spec item 4 lists it — its only constructor and its every use take Regions (spec item 6) — cost if wrong: one more class in phase 6. +- Ruling: the -TAB read change belongs to Task 1 (where LutMap arrives); Task 4 only checks it as a gate — avoids two tasks editing the same branch — cost if wrong: none. +- Ruling: IntraMap writes its Transformer into IntraFlag in jniast's printable encoding wherever it sits in the dumped object, and the loader decodes it at any depth — jniast channelizes only the top-level object, so a nested IntraMap could not be read back in another process — cost if wrong: Task 12 restricts it to the top level. [superseded by the user decision of Task 12: name-only I/O, no Java deserialisation, because decoding at any depth let a dump make the reader deserialise attacker-chosen classes] + +## Task 1: LutMap + +### Implementer + +- Ruling: LutMap keeps C's last input and output per direction and returns the kept output for the same input even after LutInterp changes (copied by `copy()`, as C's memcpy) — transform-changing C quirks are copied (phase 2), and the rule "C wins" makes Rust's `lutmap_interp_change_applies_to_a_repeated_value` expect C's values from the probe — cost if wrong: a value transformed again after LutInterp changes gives the old method's result, as jniast/C does; recorded in rust-c-differences.md. +- Ruling: MapMerge's cancellation compares the nominated LutMap with its own Invert attribute, as C does, so an inverted series CmpMap of a LutMap and a copy of itself simplifies to a UnitMap (changing the transformation) and one of a LutMap and its inverse is kept (probed) — Rust folds the list value in — cost if wrong: such a Mapping changes on simplify, as in C; recorded as a C quirk. +- Ruling: a table GetLinear calls linear but whose ends are equal (constant, or within LutEpsilon) is neither replaced nor cancelled, as C's `if/else if` does (probed) — Rust tries the cancellation — cost if wrong: none for C parity; recorded. +- Ruling: the neighbour's Invert is put back with `setInvert(oldValue)` as C's `astSetInvert(neb, old_inv)`, not `swapInvert/restoreInvert`, so an unset Invert becomes set to the same value — cost if wrong: `test("Invert")` on a neighbouring LutMap after a simplification reads true, as in C. +- Ruling: Rust's `monotonic()` tests are translated as TranInverse checks (and the inverse results), since C exposes only TranInverse — cost if wrong: increasing vs decreasing is not asserted directly (the inverse tests cover both). +- Ruling: `GetMonotonic`'s inverse table holds exactly the good values; C sizes it from the bad values counted before its early break, which happens only for a non-monotonic table, whose inverse is undefined — cost if wrong: only a hand-edited dump declaring `Inv = 1` for a non-monotonic table differs (C would read uninitialised entries). +- Ruling: a negative `Nlut` in a dump loads an empty table (`Math.max(0, ...)`, as the other loaders here treat negative counts) where C's allocation would fail — cost if wrong: a corrupt dump reads instead of failing with AST__NOMEM. +- Ruling: `GetLinear` keeps C's arithmetic on bad entries (AST__BAD = -DBL_MAX enters the range and line), which is how C decides the non-finite-entry tables of `lutmap_non_finite_entries_not_linear` — cost if wrong: none; matches C's classes. +- Ruling: the -TAB read stops where C's `GetNamedTable` reports AST__NOTAB; jniast has no table source, so the only tables are a dumped FitsChan's `Tables` KeyMap, and an entry there throws `needs FitsTable` (C would use it as a FitsTable) — cost if wrong: none reachable without FitsTable. +- Ruling: the FITS-WCS read functions take the FitsChan instead of its TabOK value, as C's `TabMapping` receives `this` (common.md) — cost if wrong: none; one test helper passes `new FitsChan()`. +- Ruling: `IsMapTab1D`'s LutMap branch sets `interp` and throws `needs FitsTable` without building `premap`/`postmap` or copying the table, which C uses only to fill the FitsTable it creates next — cost if wrong: none observable (C's temporary `astSetInvert` on the list's Mappings also restores them). +- Ruling: `brad` in `simplify-cases.txt` changes from `needs LutMap` to `needs simplification` — traced with lldb in the pinned C: `cmpmap.c` `Equal` (non-expanded branch) saves and restores the Invert of two components that are the same object in the wrong order, leaving the shared WcsMap of `brad.map` with Invert 0, which `brad.simp` records; Java's recursion guard compares identity and text (phase 2 ruling, `astEqual` not ported), so its WcsMap keeps `Invert = 1`; the dumps differ in that one line and the transforms agree (`brad.map`/`brad.simp` left `simplify.txt`) — cost if wrong: one regression row stays deferred until CmpMap `Equal` is ported; recorded in rust-c-differences.md as a C quirk. +- Ruling: `unit_change_leaves_mappings_alone` is translated by setting `System(1)` of sparse.ast's current Frame to the value it has (any setting through a FrameSet marks integrity lost) in place of Rust's no-op `with_integrity` closure — cost if wrong: none; the dump is unchanged, as the test requires. +- Ruling: probe output is compared line by line with trailing white space removed, and committed that way, rather than adding an exclusion to `.pre-commit-config.yaml` — cost if wrong: trailing blanks of FITS cards are not compared (the test asserts each card is 80 characters). +- Ruling: `NativeClassesTest` uses SplineMap (absent until phase 9) where it used LutMap as an absent class — cost if wrong: none. + +### Controller + +- Ruling: accept brad's reason "needs simplification" — C's CmpMap Equal mutates a shared component's Invert, a C simplification artefact and not a missing class, and phase 2 used the same reason — cost if wrong: one entry re-labelled later. + +## Task 2: MathMap expressions and transformation + +### Implementer + +- Ruling: a MathMap's saved second Gaussian value is kept in its own random context (Rust's choice), not in C's static variables shared by every MathMap — Review Focus 2 requires a copy to give its original's sequence and threads on copies to agree, which C's shared state prevents (probe cases `random_copies`, `gauss_two_mathmaps` show C's behaviour; tests assert C's single-MathMap values) — cost if wrong: interleaved `gauss` calls on two MathMaps, or on a MathMap and its copy, give different values from C's; recorded as a C quirk. +- Ruling: C's `errno`-trapped maths errors (exp, cosh, sinh, tan, pow, ldexp) give AST__BAD when a finite argument gives a non-finite result, as a glibc build of C does (phase 3 precedent for FitsLogMap); the pinned macOS build gives inf/NaN, so the test lists those 22 probe values explicitly (`ERRNO_TRAPPED`, `ERRNO_CASES`) — cost if wrong: overflowing MathMap expressions give BAD where macOS C gives an infinity (or 0 after `!`). +- Ruling: `nout < 1` is reported with status AST__BADNI (C quirk mirrored; Rust uses BADNO) — cost if wrong: a caller testing for AST__BADNO does not see it, as in C. +- Ruling: `` loads `Math.E`, the correctly rounded `exp(1.0)` C's library gives, because Java's `Math.exp(1.0)` is one ulp high — cost if wrong: none for C parity. +- Ruling: library function values (sin, cos, log, ...) are compared with C to 2 ulp (evaluate case) or 4 ulp (transformations, gauss sequences); every bad, zero, integer and non-libm value is compared exactly — cost if wrong: a last-bit libm difference is accepted, as CLAUDE.md allows. +- Ruling: inputs that are not finite are bad (library rule, as LutMap), but a NaN or infinity made inside an expression (e.g. from the literal `1e999`) is passed through as C does; Rust replaces NaN outputs with BAD — cost if wrong: `y = 1e999-1e999` gives NaN, as C. +- Ruling: `DefaultSeed` uses `System.nanoTime()` in place of C's `clock()` and `System.identityHashCode(context)` in place of the context's address; the shared quick generator is a `static final AtomicLong` (C's mutex-protected static) — cost if wrong: only the unpredictable default seeds differ, which no test can pin. +- Ruling: a loaded dump with `Nfwd` below the number of outputs or `Ninv` below inputs is refused with AST__INNTF and `astInitMathMap`'s message naming `astLoadMathMap` (C reads out of bounds) — cost if wrong: a corrupt dump fails instead of being undefined behaviour. +- Ruling: Poisson's constants that C caches in static variables per mean are recomputed per call (same values; no shared mutable state) — cost if wrong: none. +- Ruling: the compiled function arrays are shared by a copy (never mutated), while C copies them; the random context is copied — cost if wrong: none observable. +- Ruling: `SimplifyRegressionTest.withoutRecords` also drops `AlSimp`, because C's `cmpmap.c` `Simplify` clears AllowSimplify on components it shares with the input (probe case `simplify_input_after`, built from `cap_restricted_component_flags.map`; `MathMapTest.simplifyClearsAllowSimplifyOnSharedComponents` checks Java does the same); without it `cap_restricted_component_flags` failed "simplify() changed the input's dump" though it matches C; it now passes — cost if wrong: a Java bug that clears AlSimp on an input where C does not would go unnoticed by this harness. +- Ruling: `math_inverse_cancel`, `cmpmap_parallel_in_series_merge` and `cap_mathmap_01` change from `needs MathMap` to `needs simplification`; each needs MathMap's `MapMerge` (a MathMap and its inverse with SimpFI/SimpIF cancelling to a UnitMap), which the brief leaves to Task 3 — cost if wrong: three regression rows stay deferred until Task 3. +- Ruling: in `rust-tests.txt` the untranslated MathMap entries get precise reasons: `test_cmpmap.rs` two tests `needs simplification`, `src/units/tests.rs` four tests `UnitsMapper MathMap conversion (out of scope)`, three FITS tests `FITS -LOG axis (out of scope)`; `tests/test_mathmap.rs::test_simplification_simpfi | needs simplification` is added (Rust's `try_merge`, Task 3's MapMerge) — cost if wrong: reasons only; Tasks 3 and 4 translate them. +- Ruling: Rust tests in other files that now run were translated here (as Task 1 did for LutMap): `nonlinear_mathmap_1d`, `numeric_rate_tan_at_zero`, `round_trip_mathmap`, `a_mathmap_needs_a_function_per_output`, six `test_clear_on_set.rs` cases, `polco_loads`, `polco2_loads`, `convert_stops_at_the_first_domain_that_gives_a_conversion`, `a_sip_description_is_rejected_when_it_is_not_linear_over_the_image`; MathMap's rate is mapping.c's numerical rate (C's mathmap.c has no `Rate`) — cost if wrong: none. +- Ruling: the probe draws an even number of Gaussian values from a fresh MathMap before its `mixed` case, so that C's shared saved value does not leak into it — cost if wrong: none; the leak is recorded separately. +- Ruling: C's `Rand` with a Seed below 1 (64-bit `long` + `LONG_MAX`) gives values far outside 0..1; mirrored, recorded as a C quirk — cost if wrong: such seeds give C's odd values. +- Ruling: Rust's `` of 15 is a Rust bug; Java gives C's `AST__DBL_DIG` of 17 — cost if wrong: none for C parity. + +### Controller + +- Ruling: keep glibc semantics for overflow and domain trapping — it is what mathmap.c's CATCH_MATHS_OVERFLOW and CATCH_MATHS_ERROR code asks for, and macOS's libm, which only sets MATH_ERREXCEPT, is the outlier — cost if wrong: 30 expected values revert to inf or NaN. + +## Task 3: MathMap simplification, equality and units + +- Ruling: `equalTo` mirrors C `Equal`'s loop bounds, so the last opcode of each function is not compared (`y=x+1` equals `y=x-1`, `max` equals `min`) and an opcode count equal to 0/1/62/63 consumes a constant — C quirk kept, confirmed by probe case `equal`, recorded in rust-c-differences.md (Rust compares texts and Invert flags) — cost if wrong: TranMap/RateMap/CmpMap equality built on it later would call such MathMaps equal, as C does. +- Ruling: where C's `Equal` reads past the end of a function's constants (a one-opcode function such as `y=`; C segfaults, verified with a scratch probe), Java treats a constant neither function has as matching and one only one has as not — C's behaviour is undefined — cost if wrong: `y=` equals `y=` in Java where C crashes. +- Ruling: `mapMerge` follows C (upper neighbour only, exact class name check), not Rust's `default_map_merge`, which also offers the reversed pair — cost if wrong: none seen; all 30 probe simplify cases match C. +- Ruling: the label-only `Units.relabel` path is removed and C's `astUnitMapper` (which builds and discards the Mapping) is used everywhere — cost if wrong: labels are made with an extra MathMap construction; values unchanged (suite passes). +- Ruling: SpecFluxFrame log-unit conversions now report `needs RateMap` (C's `MakeMapF` builds the RateMap first); tests renamed — cost if wrong: Task 6 inherits the reason. +- Ruling: rust-tests.txt's three FITS `-LOG` entries read `FITS -LOG algorithm (out-of-scope method)`: MathMap no longer explains them, the list's format names a class or method, and the FITS `-LOG` code is Task 4's — cost if wrong: wording only. +- Ruling: units-MathMap values and the FluxFrame log conversion are compared to C to 1e-14 relative (exp/log10 last bits); dumps, labels and simplification structure exactly — cost if wrong: a last-bit libm difference is accepted. +- Ruling: `equalTo` has no caller in the library yet (C's callers are CmpMap `Equal`, TranMap, RateMap and Regions, none ported); it is tested directly against the probe — cost if wrong: none until those classes use it. + +## Task 4: FITS logarithmic and tabular axes + +- Ruling: `FitsLogMap` deleted and C's MathMap used in `LogAxis` — C builds a MathMap and puts the same one in the returned `-LOG` Mapping; a separate class would dump and simplify unlike C — cost if wrong: none (the evaluation tests moved to MathMapTest's probe). +- Ruling: `test_fitschan_tab.rs` — all five tests listed `needs FitsTable`, none translated; each writes a `-TAB` table (or, for strict_sweep_error_asks_no_table_source, builds its header from such a write and uses a table source, which jniast lacks); check_tab's first two assertions (TabOK=0 write returns 0, no tables) would run but a partial translation was not made — cost if wrong: two assertions untested until FitsTable. +- Ruling: the `rust-tests.txt` reason is `needs FitsTable` as the brief words it, although the file's other class entries read ` (out of scope)` — cost if wrong: five entries reworded. +- Ruling: `freq-log.head` added to `FitsChanWriteTest.NOT_ROUND_TRIPPED` as DIFFERS — its log increment (1e-3 Hz at 1.42e9 Hz) is linear within FitsTol, and C itself writes it as linear FREQ in GHz (CRVAL1 1.4204, CDELT1 1e-12), so C's own round trip gives GHz where the header gives Hz; Java writes the same cards and reads back the same values (probe case `freq_log_head`, `FitsLogAxesTest.freqLogFixtureIsWrittenAsLinear`) — cost if wrong: none. +- Ruling: `FitsChanCursorOracleTest` `alt_axes_alt_offset` moved from `needs MathMap` to the `runtime Math:` exclusions with CDELT1B and PC2_1B licensed (RUNNABLE stays 257) — it now runs; the whole 700-line transcript matches C but for those two cards of the SKY_POLE offset description (CDELT1B 1.5e-15 relative, PC2_1B 2.3e-15 absolute), fitted through the same SphMaps and TAN WcsMap whose 1-ULP libm differences already license alt_axes_offset's CDELT2; the `-LOG` Mapping C builds for the absolute description fails MakeIntWorld and is not written, in C and here — cost if wrong: a real difference in that fit hidden at 1e-14. +- Ruling: `FitsLogAxesTest` compares numbers within libm rounding (`CValues.nativeStringsWithinLibmRounding`), and the pixel coordinates transformed back from world coordinates within 1e-11 absolute — the inverse is `Sr log(S/Sr)` with Sr ≈ 1.4e9, so one ULP of `log` moves the pixel by ~3e-12; the cards written (CDELT1 100070.42749198397 here, ...402 in C, 3 ULP) differ only within libm rounding — cost if wrong: a pixel error below 1e-11 hidden. [superseded by the 1e-12 ruling at the end of this task] +- Ruling: the probe output is committed as `probes/fitslog_probe.json` (`{"source", "output"}`), and `ProbeOutput.load` falls back to it when no `.out` exists — the raw output contains C's own spellings of an attribute name and of card comments, which the codespell hook rejects in text files and skips in JSON (as for every oracle JSON); the shared codespell configuration is not relaxed — cost if wrong: the file is renamed and the fallback removed if the user prefers a config exclusion. +- Ruling: Rust's `log_axis` omits SimpFI/SimpIF and adds range/finiteness checks C lacks; Java follows C, recorded in docs/rust-c-differences.md — cost if wrong: none. +- Ruling: tests that build `-LOG` FrameSets use MathMaps and PolyMaps where the old tests had to avoid MathMap (e.g. `detectsLogAxisAndReturnsInverseMapping` uses Rust's MathMap, with Java's `2.0`/`0.1` formatting in the expressions) — cost if wrong: none. +- Ruling (supersedes the pixel-tolerance ruling above): the -LOG pixel tolerance is 1e-12 — the CDELT1 card differs from C's by 3 ULP (libm differences in the fitted exp/log values), which the inverse multiplies by the pixel distance from CRPIX — cost if wrong: a pixel error below 1e-12 hidden. + +## Task 5: TranMap + +- Ruling: C quirk kept — `MapMerge` replaces a TranMap whose equal components were inverted when it was made with a copy of the first component applied forward, changing the transformation (probe cases `simp_equal_inverted_mathmaps`, `simp_equal_inverted_lutmaps`: original fwd 2.5 -> 1.58, simplified fwd 2.5 -> 6.25 in C and Java); Rust applies the copy inverted; recorded as a C quirk in docs/rust-c-differences.md — cost if wrong: one list value changed in `TranMap.simplifyAlone` if the user prefers Rust's (correct) behaviour; it should also go into the Rust repo's c-library-quirks.md, which I did not edit (reference submodule). +- Ruling: `TranMap.equalTo` compares components by identity or by native description without IsSimp (`Simplifier.guardKey`), not by each class's `Equal` — astEqual is not ported for every class and the simplifier already compares this way; nothing in the library calls it (CmpMap Equal is not ported); it gives C's result for every probe comparison — cost if wrong: differs from C for components whose class Equal treats different descriptions as equal (for example ZoomMap(2) inverted against ZoomMap(0.5)). +- Ruling: decomposing a TranMap gives series false — C's `Decompose` leaves the flag unset (probe gets back the 7 it set) and its documentation says zero; jniast passes an uninitialised int — cost if wrong: none for a correct caller. +- Ruling: a missing or non-Mapping `MapA`/`MapB` in a dump is AST__LDERR, as Java's CmpMap loader already does (C leaves NULL) — recorded by extending the CmpMap entry — cost if wrong: none. +- Ruling: a series merge with a following TranMap that keeps one of its unsimplified transient CmpMaps marks that CmpMap's components shared (`TranMap.keep`), as C's reference counts then have them; otherwise the transient CmpMaps leave them unshared, as C annuls them — cost if wrong: a component's SET1 attribute allowed or refused differently from C in that edge case. +- Ruling: Rust's `no_merge_parallel_tranmaps` and `no_merge_with_non_tranmap` call `try_merge`, a Rust-only API; translated as simplifications of the parallel and series CmpMaps they describe, compared with the probe's `simp_pair_parallel` and `simp_beside_zoommap` — cost if wrong: none. +- Ruling: `test_map_split_oracle.rs::issimp_component_exclusions_still_differ` stays deferred, narrowed to `RateMap (out of scope)` — its TranMap entry asserts the port still differs from C, but Java matches C byte for byte (`tranmap_full_permuted`), so that half has nothing to test; recorded in docs/rust-c-differences.md — cost if wrong: none. +- Ruling: `a_tranmap_needs_its_two_directions` stays deferred with `RateMap (out of scope)` — it builds its one-way Mappings from RateMaps; TranMapTest.constructorErrorsMatchC and TranDefinednessTest cover the same checks with a forward-only PolyMap — cost if wrong: none. +- Ruling: TranMap's RemoveRegions is not ported (no Region classes and no `removeRegions` in this library); the quirk "RESOLVED (upstream 80d66b0a): TranMap's RemoveRegions doubles its number of axes" is already fixed in the pin (commit bf819d17 "tranmap: RemoveRegions keeps the TranMap's number of axes"; pinned tranmap.c returns `astUnitMap( astGetNin( newmap1 ) )`), so phase 6 should port the pinned behaviour — cost if wrong: none now. +- Ruling: Java's `restoreInvert` puts back an unset Invert as unset where C's `astSetInvert` leaves it set to its value (the existing swapInvert/restoreInvert pattern of every MapMerge here); only `astTest(Invert)` could see it — cost if wrong: a test of the Invert attribute after simplification differs. + +## Task 6: astEqual (inserted) + +### Implementer + +- Ruling: object.c `Equal`'s class-name-and-structure-size test is Java class identity (`getClass()`) — why: same C class name implies the same structure size, and the brief asks for class identity — cost if wrong: a test-only subclass with jniast's class name would compare unequal to its parent where C, with one class, would compare equal. +- Ruling: CmpMap `Equal` sets and restores component Invert attributes with `swapInvert`/`restoreInvert` (exact set/unset state, the phase 2 convention) in C's order, first set first restored, so a shared component ends with the first list's value as in C — cost if wrong: only `testInvert` differs from C's `astSetInvert`, which leaves the attribute set. +- Ruling: the Simplifier guard compares against a snapshot of the stack, bottom first, `m.astEqual(entry)` — why: C indexes its array up to the depth at loop start, and nested simplifications push and pop before returning — cost if wrong: none, the snapshot and C's array hold the same entries during the loop. +- Ruling: ZoomMap `Equal` keeps C's quirk of comparing the stored factor (zero after Zoom is cleared; reciprocal infinite) — C quirk kept, recorded in docs/rust-c-differences.md — cost if wrong: a cleared ZoomMap compares unequal to ZoomMap(1) as in C. +- Ruling: FrameSet `Equal` ignores the FrameSets' Invert attributes, as C does (probe `frameset_inverted`: 1) — C quirk kept; Rust does the same, so no rust-c-differences entry — cost if wrong: an inverted FrameSet equals its original. +- Ruling: MatrixMap `Equal` expands and recompresses both MatrixMaps as C does, which may zero negligible elements of a MatrixMap stored in full form — C behaviour kept — cost if wrong: a comparison changes such a MatrixMap as in C. +- Ruling: PermMap `Equal` reads constants through `constantFor`, which gives the bad value past the end of the constants where C would read past its array — cost if wrong: none for PermMaps the constructor accepts. +- Ruling: the three SelectorMap cases of `oracle/equal.json` are skipped in `EqualTest.equalityMatchesTheCLibrary` (it asserts the 7 in-scope cases ran) — SelectorMap and Regions are phase 6 — cost if wrong: SelectorMap equality untested until then. +- Ruling: `chebymap_same` and `chebymap_different_bounds` re-listed as `ChebyMap (out of scope)` — ChebyMap is phase 9 — cost if wrong: none. +- Ruling: the `brad` row stays in `simplify-cases.txt`; the gate's "input unchanged" rule is not relaxed — why: C itself changes the input here, and relaxing the shared gate needs a decision — cost if wrong: the row stays listed although Java matches C (shown by `EqualTest.simplifyingBradChangesItsSharedWcsmapAsC`). +- Ruling: the Rust tests of other files (test_permmap.rs etc.) are added to their existing Java test classes with Rust's literal expectations; C's answer for each is in `equal_probe.out` and agrees with every one — cost if wrong: none. +- Ruling: the gate compares the whole input-after dump (without IsSimp/ReSimp) with C's only for rows the probe records, currently brad — cost if wrong: another row whose input C changes stays listed until the probe records it. + +### Controller + +- Ruling: insert a new Task 6, "astEqual", and renumber the old Tasks 6 to 14 as 7 to 15 — ratemap.c and switchmap.c call astEqual on the Mappings they hold, a native-text comparison is a heuristic C lacks (ZoomMap(2) inverted equals ZoomMap(0.5) in C), and the port also clears the 81 test_equal.rs entries — cost if wrong: one extra task, and the Simplifier recursion guard changes from text to astEqual (the simplify gates would show any regression). +- Ruling: the brad row leaves the deferred list — SimplifyRegressionTest compares the input's after-dump with C's recorded input_after (simplify_input_probe) where a probe exists, as its Javadoc says ("leave the input as C leaves it") and as the AlSimp allowance already does — cost if wrong: a gate allowance tied to one probe case. + +## Task 7: RateMap + +- Ruling: C quirk kept — `MapMerge` replaces a RateMap and its inverse in series (a CmpMap that defines neither direction) with UnitMaps, giving a UnitMap that defines both; for two inputs, R then inv(R) gives UnitMap(2) and inv(R) then R gives UnitMap(1) (probe cases `cancel_two_inputs_upper/lower`); Rust does the same; recorded as a C quirk in docs/rust-c-differences.md — cost if wrong: none for a correct caller, since neither the RateMap pair nor C defines a transformation to preserve. +- Ruling: Equal and the cancellation compare the encapsulated Mappings in their recorded orientations, as C does (probe `equal`/`mapping_inverted_after` = 1, `cancel_mapping_inverted_after` = UnitMap); Rust compares their current orientations; recorded in docs/rust-c-differences.md — cost if wrong: none (C is the reference). +- Ruling: a missing or non-Mapping `Map` in a RateMap dump is AST__LDERR (C leaves NULL), as Java's CmpMap and TranMap loaders do; recorded by extending that entry — cost if wrong: none. +- Ruling: `Transform` calls the public `Mapping.rate` with 1-based indices; its checks are `astRate_`'s (index ranges) plus an `at` length check that cannot fail here (the work array has Nin values); C's `AST__INTER` for the undefined direction is never reached because `validateTransformInto` (C's base Transform) refuses it with AST__TRNND first, as in C — cost if wrong: none. +- Ruling: RemoveRegions (`ratemap.c` RemoveRegions, audit RM-3) is not ported — this library has no Region classes and no `removeRegions`; phase 6 should port it with the Regions — cost if wrong: none now. +- Ruling: `test_map_split_oracle.rs::issimp_component_exclusions_still_differ` leaves rust-tests.txt untranslated: it asserts the port still differs from C for `ratemap_full_permuted` and `tranmap_full_permuted`, and Java matches C byte for byte for both, so it has nothing to check here; MapSplitOracleTest's Javadoc says so — cost if wrong: none. +- Ruling: `test_rate_oracle.rs::rates_match_the_c_library` is translated (RateOracleTest) for its RateMap and TranMap cases and stays listed, narrowed to `SwitchMap (out of scope)`, for its three SwitchMap cases — cost if wrong: none. +- Ruling: the five Rust tests calling `try_merge` (Rust-only API) are translated as simplifications of the CmpMaps they describe (series or parallel, the second inverted as `other_inv` says) — cost if wrong: none. +- Ruling: `ratemap_split_rejects_when_inverted` is translated as Rust wrote it (it tests the non-inverted split, since its name's case is unreachable through Rust's API); the inverted split itself is checked against C in RateMapTest (`split_inverted`: base full-set split) — cost if wrong: none. +- Ruling: as in TranMap, `restoreInvert` puts back an unset Invert as unset where C's `astSetInvert` leaves it set — cost if wrong: only `astTest(Invert)` after a comparison/simplification could differ. + +## Task 8: SpecFluxFrame conversions + +- Ruling: phase 4's "SpecFluxFrame conversions with differing components throw needs RateMap" (phase4-rulings lines 99, 100, 107, 108) is undone — every such test now checks C's Mapping and values from the probe — cost if wrong: none. +- Ruling: conversions are checked by the native dump of C's simplified Mapping as well as values, which makes the probe output 566 KB (limit 2048 KB) — it shows the port builds and simplifies C's Mapping, not just equal numbers — cost if wrong: a large resource; the dumps could be cut to a few cases. +- Ruling: the SPLAT FrameSets are converted with domain list `SPECTRUM-FLUX`, since with `""` C matches the two GRID base Frames first and gives a UnitMap (probed) — cost if wrong: none; both are C's behaviour. +- Ruling: tests outside the brief brought in — the SpecFluxFrame cases of `frame_class`, `frame_axis` and `integrity` oracles, skipped as "not yet ported" or needing a class; they pass (integrity needed this port; the attribute ones needed nothing) — cost if wrong: none. +- Ruling: `makeMap2` now builds its CmpMaps with the public constructor (components marked shared, C's `astClone`) instead of `transientCmpMap`, since its result is now part of the Mapping returned — cost if wrong: a nested component's SET1 attributes are immutable, as in C while the CmpMap holds them. +- Ruling: SpecFluxFrames whose SpecFrames do not convert give no conversion, as in C, not Rust's AST__BADUN error. + Recorded in docs/rust-c-differences.md. + Cost if wrong: none, because C is the reference. + +## Task 9: GrismMap and FITS grism axes + +### Implementer + +- Ruling: GrismMap's `CanMerge` takes a ZoomMap's factor from the ZoomMap's own Invert attribute, as C does, so the three probe cases simplify to a GrismMap that does not transform as the pair — C's behaviour is the reference and the probe pins it; recorded as a C quirk in `rust-c-differences.md` — cost if wrong: Java keeps a C bug a user could hit by inverting a ZoomMap beside a GrismMap. +- Ruling: `Equal` compares attributes as stored (unset differs from set to default), as C, not Rust's values in use — cost if wrong: none beyond C's own behaviour; recorded. +- Ruling: the jniast constructor leaves every attribute unset (C's `astGrismMap("")`), unlike Rust's `GrismMap::new`; Rust tests' `GrismMap::new(...)` are a test helper setting all eight through the jniast setters — cost if wrong: none (probe dumps match C). +- Ruling: the FITS grism probe comparisons allow a relative difference of 1e-8 (`FitsChanWcsWriteTest.GRISM_RTOL`, also used by `FitsWcsSpectralTest`) — the read divides by C's numerical `astRate`, whose interval choice is changed by 1-ULP (up to 32 near cancellation) differences of `Math.asin`/`Math.tan` from libm (measured with a side probe of the AWAV-GRA and nm cases: transforms differ by 1 or 32 ULP; rates by 1.7e-10 and 8e-10 relative); every card, class and structure must still match — cost if wrong: a numeric regression below 1e-8 in the grism read or write would pass these cases. +- Ruling: `try_grism_cascade_emits_gri_pv_and_chain` is translated through `spectralAxes` with a grism non-linear enough that the linear, `-X2P` and `-LOG` algorithms fail (Rust's helper does not exist here; with Rust's near-linear parameters C would write a linear axis) — cost if wrong: the test checks C's path rather than Rust's helper. +- Ruling: the 7 unit tests of Rust `fitschan/fset_to_store/grism.rs`, never listed in `rust-tests.txt`, are translated as `extractGrismMap` tests — cost if wrong: none. +- Ruling: the five Rust `try_merge` tests are translated as simplifications of the series or parallel CmpMap they describe, as earlier tasks did — cost if wrong: none (C behaviour also pinned by probe). +- Ruling: `setAttrib` converts GrismM with Java's `(int)` cast; C's double-to-int conversion is undefined outside the int range, where Java saturates — cost if wrong: none for values in range. +- Ruling: `extractGrismMap` sets each component's Invert attribute with `setInvert` and restores it with `setInvert`, leaving it set, exactly as C's `astSetInvert` calls do (not `swapInvert`) — cost if wrong: a component's Invert attribute is set rather than unset afterwards, invisible outside the simplified copy it belongs to. +- Ruling: `NativeClassesTest` uses XphMap (phase 9) as its absent class (carried from Task 7 review) — cost if wrong: none. +- Ruling: Rust's `grism_setters_recompute_the_constants` (G=1000, M=1, WaveR=6000: sinbeta_r 6e6, every output bad) and `nan_protocol_grismmap` (G=1e7, WaveR=5e-7, Eps=1: sinbeta_r about 9.25, every output bad or NaN) compared only bad values; the translations use the probe's in-range attributes, and the setter test compares against C's values instead of a second GrismMap built through the same setters — cost if wrong: none; the tests now exercise real values. +- Ruling: the 1e-8 tolerance is confined to rate-derived lines — cost if wrong: a numeric regression below 1e-8 in a rate-derived value of a grism read or write would pass. + +### Controller + +- Ruling: re-grade the review's minor 2 (ClearOnSetTest.grismSettersRecomputeTheConstants and NanProtocolTest.nanProtocolGrismmap compare BAD with BAD) as a fix-round item, because tests that assert nothing are not minor — cost if wrong: a short fix round. + +## Task 10: PcdMap + +- Ruling: `MapMerge` and `CanMerge` use pcdmap.c's own `EQUAL` (floor `1e5*DBL_MIN`), `Equal` uses `astEQUAL` (floor 1e-12), as C; Rust uses `ast_equal` for all three — C is the reference, probe cases `small_disco`, `tiny_disco`, `inverse_small_centre_offset` pin it; recorded — cost if wrong: none beyond C's own behaviour. +- Ruling: `Equal` compares stored values (unset differs from zero), as C, not Rust's values in use; recorded as a C quirk — cost if wrong: none beyond C's behaviour. +- Ruling: a non-finite input coordinate is bad in `transformInto` (C tests only `AST__BAD`), by the plan's rule already recorded under "Infinite input coordinates"; required by the translated `NanOutputsTest` — cost if wrong: a NaN input gives bad outputs instead of C's NaN. +- Ruling: jniast's constructor checks are ported as jniast's JNI layer makes them (`NullPointerException`, `IllegalArgumentException` with jniast's message) rather than `AstException` — cost if wrong: a caller catching `AstException` for a short centre array would not catch it (jniast's would not either). +- Ruling: `CanMerge` compares the list's Invert values directly instead of setting each Mapping's Invert attribute temporarily as C does (nothing it reads depends on Invert); `CanSwap`, `PcdZoom` and `PcdPerm` do swap the Invert attribute in and out as C does — cost if wrong: none. +- Ruling: the four Rust `try_merge` tests are translated as simplifications of the series CmpMaps they describe, as earlier tasks did — cost if wrong: none (probe pins C). +- Ruling: Rust `test_mapping.rs` (never listed in `rust-tests.txt`) is untouched except that its PcdMap half of `a_simplified_mapping_set_to_unit_simplifies_again` is translated into `PcdMapTest` — cost if wrong: none. +- Ruling: probe comparisons in `PcdMapTest` are exact, not within libm rounding, since no elementary function is involved — cost if wrong: a JVM whose double arithmetic differed would fail them (none does since Java 17's strict semantics; Java 8 on SSE2 is also exact). + +## Task 11: SwitchMap + +- Ruling: the selector value is converted as C does, `(int) round(sel) - 1` after excluding only `AST__BAD`, with Java's defined conversion standing in for C's undefined one — the brief asks for C's conversion and the probe shows C saturating on this platform — cost if wrong: none (every value gives the same route as C here and as Rust's range test). +- Ruling: `MapMerge` sets back the Invert attributes in C's order (the order it set them), so a Mapping held twice keeps the value recorded for its first place; C quirk kept and recorded — cost if wrong: a user's shared selector changes Invert after simplification, exactly as in C. +- Ruling: Invert attributes are restored set or unset as they were (`swapInvert`/`restoreInvert`), as every earlier phase 5 class does, where C's `astSetInvert` leaves them set — cost if wrong: `test("Invert")` differs from C afterwards. +- Ruling: an absent `ISInv` takes `FSInv`'s value and a dump without `RMap1` loads a SwitchMap of no routes, as C (Rust: 0 and AST__LDERR); recorded — cost if wrong: none beyond C's behaviour. +- Ruling: the route-Nout error keeps C's message with input counts, and the public constructor uses `astSwitchMapId_`'s message with two spaces (the library's own rebuilds use `astSwitchMap_`'s one space); recorded — cost if wrong: message text only. +- Ruling: a null `routemaps` array is a `NullPointerException` (jniast's `jniastCheckNotNull`), a null element AST__OBJIN with `astMakePointer`'s message, which is what jniast's call into the public `astSwitchMap` gives — cost if wrong: a caller expecting another exception type for a null element. +- Ruling: a component of a dump that is not a Mapping is AST__LDERR (C does not check), as the TranMap and RateMap loaders here do — cost if wrong: none (C would misbehave). +- Ruling: `RemoveRegions` is not ported: this library has no Region classes or `removeRegions` until phase 6 — cost if wrong: phase 6 must add SwitchMap's override. +- Ruling: no `transformIntoNan` override: C has no NaN path, and the base version (transformInto, BAD → NaN) is right because the selector and routes treat a NaN input as bad — cost if wrong: slower NaN-protocol transforms only. +- Ruling: the 10 `test_switchmap.rs` tests whose forward selector is a SelectorMap of Box Regions go to `rust-tests.txt` with `Box (Region, out of scope)` (C builds `astBox` before `astSelectorMap`), and `test_rate_oracle.rs` gets the same reason — cost if wrong: phase 6 picks them up by that reason. +- Ruling: Rust's `simplify_reporting_change` check is translated as `assertSame` plus dump equality, C's `compare` of the two dumps — cost if wrong: none. +- Ruling: `routeIndex` uses `FitsMakeIntWorld.roundHalfAway` (C's `round`), as `FitsWcsSpectral` and `FitsSipIntWorld` already do, rather than a fourth private copy — cost if wrong: a cross-class dependency on a FITS helper. +- Ruling: GrismMap treats a non-finite input as bad (separate commit), by the plan's rule recorded under "Infinite input coordinates" — cost if wrong: an infinite grism parameter gives BAD instead of C's finite wavelength. +- Ruling: the replaced probe case keeps the same SwitchMap and only drops the line filter, so it records what C's own round trip does — cost if wrong: none. + +## Task 12: IntraMap and the Transformer classes + +### Implementer + +- Ruling: C's astIntraReg table is process-wide; Java's IntraRegistry belongs to a Channel and is visible to loaders only during that Channel's read (thread-local), and is consulted only when Iflag holds no decodable Transformer — coordinator ruling (a) — cost if wrong: a program registering once per process must register with each Channel. [superseded by the process-wide weak registry of fix round 1] +- Ruling: Fname is the Transformer's class name + "#" + hex hashCode (jniast), and two IntraMaps with the same Fname are the same function for Equal and MapMerge (C compares `ifun`) — jniast registers exactly that name — cost if wrong: a hashCode collision within one class would merge IntraMaps of different Transformers. +- Ruling: IntraFlag is C's user attribute (unset by default), not jniast's internal pointer string — jniast's pointer is a JNI artefact — cost if wrong: in jniast a copy and its original were Equal and separately made IntraMaps never merged; here Equal needs IntraFlag set on both and same-Transformer IntraMaps merge. +- Ruling: the Dump writes the encoded Transformer as Iflag wherever the IntraMap is (controller ruling), overriding a user IntraFlag value; when the Transformer does not serialise, it writes C's IntraFlag — so toString, equals and nested writes never fail — cost if wrong: a user IntraFlag on a Serializable IntraMap is lost in a dump. [superseded by name-only I/O] +- Ruling: the loader stores Iflag as read in IntraFlag (C's `astLoadIntraMap`) and keeps the dump's Fname — C's loader — cost if wrong: a reloaded IntraMap reports the encoding through getC("IntraFlag"). [superseded by name-only I/O] +- Ruling: `channelize()` serialises the Transformer to check it can be written (NotSerializableException, or the IOException of serialisation) and changes nothing; `unChannelize()` does nothing — the Dump writes and the loader decodes the encoding at any depth — cost if wrong: code relying on jniast's side effects (IntraFlag holding the encoding after channelize, the Transformer replaced by a deserialised copy after a write) sees none. [superseded by name-only I/O] +- Ruling: Channel.write and FitsChan.write call channelize/unChannelize only on the top-level Object, as jni/Channel.c and jni/FitsChan.c do; a nested IntraMap with a non-Serializable Transformer is written by name without failing (as jniast) and reads back only with its function registered — cost if wrong: a write that cannot be read back succeeds. [kept; the calls remain for user classes] +- Ruling: FitsChan.write passes a channelize exception (such as NotSerializableException) on unchanged although it declares no IOException, as jniast's JNI code leaves it pending (checked: jni/FitsChan.c `write` calls `channelize` and `ASTCALL` skips `astWrite` while an exception is pending; jniast's `FitsChan.write` declares nothing); Channel.write does the same for any exception — coordinator condition — cost if wrong: callers see an undeclared checked exception, as with jniast. +- Ruling: as a consequence, `Channel.write` of a top-level IntraMap whose Transformer is not Serializable fails, including one read from a C dump by name; tests that compare such dumps with C use `Channel.text` — jniast's behaviour — cost if wrong: such an IntraMap can be written only inside another Object. [superseded by name-only I/O] +- Ruling: canTransformCoords false is IllegalArgumentException("Transformer will not map N -> M coordinates") as jniast's JNI code throws (its Javadoc says AstException; jniast's message has a stray double space, not kept); a null Transformer is NullPointerException — jniast's code — cost if wrong: callers catching AstException miss it. +- Ruling: a decoded Transformer that cannot map the dump's numbers of coordinates is AST__BADNI "astLoadIntraMap(): The Transformer read will not map N -> M coordinates." — jniast's unChannelize would throw IllegalArgumentException from construct; a loader error is an AstException — cost if wrong: different exception type for a corrupt dump. [superseded by name-only I/O, since nothing is decoded] +- Ruling: every transformation failure is AST__ITFER (jniast tranWrap), not the status a C function set nor Rust's error code; recorded in docs/rust-c-differences.md — cost if wrong: none for Java callers, who cannot set a status. +- Ruling: C's process-wide mutex around every IntraMap transformation (intramap.c `LOCK_MUTEX2`) is not reproduced — PMD forbids locks and jniast's ThreadTest runs IntraMaps across threads — cost if wrong: a Transformer that is not thread-safe is not protected when IntraMaps run on several threads. [superseded by the user decision of no lock, which gives the same result for a different reason] +- Ruling: the encoding is written without the four or eight trailing NUL characters jniast's `encodePrintable` leaves; decoding treats NUL and other non-alphabet ASCII as 0 as jniast's Inv64 does, and a non-ASCII byte (which makes jniast throw ArrayIndexOutOfBoundsException) as undecodable — cost if wrong: none known; jniast decodes our encoding. [superseded by name-only I/O] +- Ruling: IntraMap omits jniast's finalizer and listed in jniast-api-exclusions.txt — nothing native to free — cost if wrong: none. +- Ruling: FixtureReadWarningsOracleTest reads with no registrations, as its C probe does (C gives AST__URITF for the 10 IntraMap fixtures, which Java now matches) — matching the probe — cost if wrong: none. +- Ruling: quirk "RESOLVED (upstream 4fe377c3): writing an IntraMap with no IntraFlag with Full set to 1 dereferences a NULL pointer" is already fixed in the pinned C (intramap.c history 12-OCT-2026); Java writes the blank string and the oracle's Full=1 dump of "nofwd" matches — no difference recorded. +- Ruling: IntraMaps are written and read by function name only and no Java object is ever deserialised; IntraFlag is C's plain attribute — user decision — cost if wrong: a dump read in another process needs its Transformer registered with the Channel. +- Ruling: `channelize()`/`unChannelize()` are public no-ops kept for jniast's API, and Channel/FitsChan still call them on a top-level NeedsChannelizing object for user classes — user decision — cost if wrong: none for IntraMap. +- Ruling: a process-wide table of weak references, filled when an IntraMap is made (as jniast's `construct` calls `astIntraReg`), plays C's `tran_data`; the reading Channel's registry is consulted first — user decision — cost if wrong: a same-process read finds a Transformer only while an IntraMap using it is reachable. +- Ruling: Fname uses `System.identityHashCode`, not the Transformer's own `hashCode()` that jniast's JNI call dispatched to — user decision (identity hash) — cost if wrong: names differ from jniast's for Transformers overriding hashCode. +- Ruling: a second registration under a name held by a live entry is accepted only with the same Transformer (standing for C's function pointer), numbers of coordinates, flags and strings, otherwise AST__MRITF, as C's `IntraReg` compares a second registration; this applies to identity-hash collisions and to one Transformer made into IntraMaps with different numbers of coordinates, which jniast also refused — user decision (decide as C's IntraReg) — cost if wrong: on a rare identity-hash collision between two live Transformers of one class, the constructor throws AST__MRITF instead of a read silently using the wrong Transformer. [the identity-hash collision part is replaced by fix round 2] +- Ruling: the PMD suppression on the static table was not added: `MutableStaticState` does not flag a final field and PMD fails the build on an unnecessary suppression (`UnnecessaryWarningSuppression`); a comment beside the field cites intramap.c's static `tran_data` instead — user decision, adapted to the linter — cost if wrong: none. +- Ruling: no lock around Transformer calls; Transformers must be thread-safe, as the Javadoc now says — user decision — cost if wrong: a Transformer that is not thread-safe gives wrong results when IntraMaps run on several threads. + Correction to the earlier Ruling, whose reasoning was backwards: jniast did serialise these calls, through its global `AstLock` (the `ASTCALL` macro's `MonitorEnter`), as C's `LOCK_MUTEX2` does. +- Ruling: the loader compares the IntraMap's numbers of coordinates as its Invert attribute leaves them (`getNin`/`getNout`) with those registered, so an inverted non-square IntraMap reads as AST__BADNI (C quirk, probe `intramap_load_probe.c`) — user decision (follow C) — cost if wrong: such IntraMaps cannot be read back, as in C. +- Ruling: a RuntimeException from a Transformer method cannot escape from `Channel.read`, because the loader calls none; at construction one is passed on raw from the IntraMap constructor, as jniast passes on the pending Java exception — user decision (no raw exception from read) — cost if wrong: a constructor caller sees the Transformer's own exception. +- Ruling (replaces the Fix round 1 collision Ruling): an identity-hash collision between live Transformers gives the new IntraMap the next free name (`#1`, `#2`, ...) instead of AST__MRITF, since C's names are chosen by callers while these come from hash codes; MRITF remains for one Transformer registered with other details and for the per-Channel registry — user decision — cost if wrong: Fnames of colliding Transformers carry a suffix that depends on what else is live in the process. +- Ruling: every IntraMap of one Transformer has one function name, found by searching the whole name chain before a free name is taken — user decision (review) — cost if wrong: none known; two threads constructing the first IntraMaps of one Transformer at once while a lapsed name precedes its own could still give two names, since the chain search and the claim are separate atomic steps. + +### Controller + +- Ruling: option (a) of the implementer's question — a package-private name-to-Transformer lookup (C's astIntraReg), scoped to one read as Rust's with_registry, consulted only when Iflag holds no decodable Transformer; tests register Java Transformers for simplifyidentity and simplifyidentity2 — C has a registry, so this is C's mechanism and not a test-only hook, and there is no public API — cost if wrong: a small package-private registry to remove. +- Ruling: the design is accepted as proposed (Fname class#hash, IntraFlag as a C attribute, Iflag carries jniast's encoding when serialisable, channelize and unChannelize on top-level objects, ITFER with its cause, the NaN protocol), on one condition: FitsChan.write's exception behaviour follows jniast's FitsChan (its declared throws and its JNI code), and not a new UncheckedIOException if jniast differs — cost if wrong: an undeclared checked exception from FitsChan.write. [the serialisation parts are superseded by the user decisions below] +- User decision: IntraMap I/O is by name only, as in C and Rust, with no Java deserialisation, and a code note marks where jniast's serialised-Transformer path would go — the review found that reading any dump, NATIVE FitsChan included, deserialised attacker-chosen classes at any depth, where jniast's exposure was near zero (top-level only, behind URITF registration), and the user is "99% certain no-one has ever used a Java-only IntraMap in production" — cost if wrong: a dump read in another process needs its Transformer registered with the Channel. + This supersedes the pre-flight IntraMap ruling. +- User decision: constructing an IntraMap registers its Transformer by Fname in a static process-wide registry of weak references (C's astIntraReg table, as jniast's construct called it), so same-process round trips (jniast's AstTest) work; the per-read package-private registry stays for C fixtures — cost if wrong: a same-process read finds a Transformer only while an IntraMap using it is reachable. +- User decision: no lock around Transformer calls, and the Javadoc states that tranP may be called concurrently (copies share the Transformer) and must be thread-safe — the review had found that jniast serialised these calls through its global AstLock, as C does with LOCK_MUTEX2, but the spec says no locks — cost if wrong: a Transformer that is not thread-safe gives wrong results when IntraMaps run on several threads. +- Ruling: an Fname collision between two different live Transformers (identity-hash collision) must not make construction fail with AST__MRITF; a distinct name is chosen instead (a counter suffix) — Fname need only be unique in the process, and identity hashes collide among many live objects — cost if wrong: the Fname format differs from jniast's in rare cases. +- Ruling: in fix round 3, the suffix map that records the largest suffix a base name has had grows only on collisions, which bounds it by the number of collisions — accepted after the controller checked it — cost if wrong: none known. + +## Task 13: DssMap + +### Implementer + +- Ruling: jniast's implicit public `DssMap()` constructor is excluded in `jniast-api-exclusions.txt` — the brief says no public constructor, and jniast's default constructor only made a wrapper with no C object (C has no public constructor) — cost if wrong: a jniast caller using `new DssMap()` would not compile (it could never have got a working object from it). +- Ruling (corrected in fix round 1, controller ruling "follow C"): after a successful merge the WinMap's Invert attribute is left at the list's value, as C leaves it (C annuls its pointer before the restore); it is restored only when there is no merge — probe case `invert_attr_both_inverted` (1 -> 0) is now asserted as C gives it — cost if wrong: a WinMap shared with a simplified inverted CmpMap changes its Invert value, as in C (the CmpMaps' transformations are unaffected). +- Ruling: after a failed merge, whether the WinMap's Invert attribute is *set* (C's `astSetInvert` sets it even when it was unset) is not reproduced; Java restores set/unset exactly, as elsewhere in the project — cost if wrong: `test("Invert")` differs after simplification. +- Ruling: C's `astCopy` of the FitsChan returned by `astDssFits` inside `MapMerge` is not made; the FitsChan is new and private to the merge, so the copy has no observable effect — cost if wrong: none observable. +- Ruling: transformation tests compare with libm-rounding tolerance (pixel outputs relative to the ~4201 plate pixel coordinate) rather than exactly, because Java's `Math.tan` differs from macOS libm by 1 ulp at the fixture's plate declination — cost if wrong: a last-bit regression in platepos/platepix would go unnoticed; the RA-wrap test keeps a 2-ulp check against C to pin C's `twopi`. +- Ruling: a non-finite input coordinate gives bad outputs (project rule, docs "Infinite input coordinates"), where C tests only for AST__BAD — cost if wrong: infinite inputs give BAD instead of C's NaN. + +### Controller + +- Ruling: follow C and leave the swapped Invert on a successful DssMap merge (the WinMap keeps the list's value), as the project rule and the Task 6 and Task 11 rulings do — cost if wrong: one test value. +- Ruling: carry to Task 14 the phase 2 PolyMap Invert-restore departure (docs/rust-c-differences.md), now the only one of its kind, to be brought in line with C — cost if wrong: none. + +## Task 14: The remaining Rust tests, the deferred sweep and carried items + +- Ruling: a cancelled nominee PolyMap is left with the list's Invert value, set, as C; the neighbour (and an uncancelled nominee) is put back set or unset as it was, where C's astSetInvert leaves it set — the library-wide convention the DssMap, CmpMap and SwitchMap entries record — cost if wrong: `test("Invert")` on the neighbour differs from C after simplification. +- Ruling: the docs entry said C leaves the copy "with Invert unset"; the probe shows Invert set to 0; the entry now says so — cost if wrong: none (wording follows the probe). +- Ruling: SimplifyRegressionTest calls astEqual as C's harness does (reference first), not as Rust does (simplified first); both pass — cost if wrong: none today; a future asymmetric astEqual (WcsMap-like) would be judged by C's order. +- Ruling: item 3 converted EqualTest only (the brief's scope); see concerns — cost if wrong: other tests keep Rust literals that agree with C today. +- Ruling: four never-listed Rust files are added to rust-tests.txt (32 UnitNormMap, 1 Box, 1 NullRegion, 5 Rust-only allocation-counting tests), as common.md asks for tests of a Rust file never listed that need an absent class — cost if wrong: entries to remove when those classes arrive (phase 6/9). +- Ruling: the DeferredTest example reason changed from "needs MathMap" to "needs FitsTable" so the required grep finds nothing — cost if wrong: none (the test exercises the parser only). +- Ruling: the memory tests bound peak heap through a child JVM's -Xmx instead of the suggested getThreadAllocatedBytes, which measures total allocation, the same with or without batching (192 against 224 MiB) — cost if wrong: about a second of test time for three child JVMs, and a heap bound that could need adjusting if a future JVM uses much more heap for itself. diff --git a/docs/rust-c-differences.md b/docs/rust-c-differences.md index 07f886f..93e3ad0 100644 --- a/docs/rust-c-differences.md +++ b/docs/rust-c-differences.md @@ -105,10 +105,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:4004-4006`), so the PolyMap is left with the value the list applied it with: simplifying the inverse of a series CmpMap of a PolyMap and an inverted copy of it gives a UnitMap and leaves the copy with Invert unset. - Confirmed with the pinned library. +- **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`). - Rust: not compared. -- Java: restores the PolyMap's Invert attribute. +- 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. ### Cancelling WcsMaps whose projection parameters differ @@ -183,6 +183,13 @@ The entries are grouped by area, in the order the Java classes were ported. - Rust: as C. - Java: as C. +### Comparing two MatrixMaps changes them + +- **C quirk**: `Equal` (`matrixmap.c`) stores both MatrixMaps in full form for the comparison and then compresses them (`CompressMatrix`), which sets to zero each off-diagonal element no larger than sqrt(DBL_EPSILON) times the largest in its row and in its column, and stores a matrix that is then diagonal in diagonal form. + A MatrixMap that was never compressed, such as one read from a dump, can therefore be changed by being compared, and with it what the merge in the entry above does with it; the recursion guard of `Simplify` (`cmpmap.c`) compares the components of CmpMaps, which may share such a MatrixMap with the Mapping being simplified. +- Rust: `equal` (`mappings/matrix.rs`) compares without changing either MatrixMap. +- Java: as C. + ### Array arguments longer than needed - C and jniast: accept them and use the leading elements (WinMap corners, MatrixMap matrices, PermMap permutations). @@ -195,7 +202,7 @@ The entries are grouped by area, in the order the Java classes were ported. - Rust: refuses it at construction. - Java: as C. -### A CmpMap dump with a missing or non-Mapping component +### A CmpMap, TranMap or RateMap dump with a missing or non-Mapping component - C: leaves a NULL component. - Rust: raises AST__LDERR. @@ -303,6 +310,290 @@ The entries are grouped by area, in the order the Java classes were ported. - Rust: gives its own message. - Java: keeps C's message. +### The last value a LutMap transformed + +- **C quirk**: `Transform` (`lutmap.c`) keeps the last input and output of each direction in the LutMap, and gives the kept output for the same input in a later call, even after LutInterp has changed; a copy keeps them too, and only the constructor and the loader reset them (probe `src/test/resources/probes/lutmap_probe.c`, cases `cache` and `cache_copy`). +- Rust: keeps nothing, so each transformation uses the current LutInterp (`lutmap_interp_change_applies_to_a_repeated_value`). +- Java: as C. + +### Cancelling a LutMap with its inverse + +- **C quirk**: `MapMerge` (`lutmap.c`) compares the nominated LutMap, with its own Invert attribute, with the inverse of its neighbour applied as the list says; it does not use the Invert value the list gives the nominated LutMap. + In an inverted series CmpMap a LutMap followed by an inverted copy of itself is kept, and a LutMap followed by a copy of itself is replaced by a UnitMap, which changes the transformation (probe cases `inverted_cmp_lut_lutinv` and `inverted_cmp_lut_lut`). +- Rust: applies the list's Invert value to both LutMaps before comparing them. +- Java: as C. + +### A linear LutMap whose first and last entries are equal + +- C: `MapMerge` (`lutmap.c`) tries the cancellation with a neighbouring LutMap only for a table `GetLinear` finds not linear, so a constant table, or one linear within LutEpsilon whose ends are equal, is neither replaced by a WinMap nor cancelled (probe cases `flat_linear_lutinv` and `constant_lutinv`). +- Rust: `linear_equivalent` gives nothing for such a table, and the cancellation is then tried. +- Java: as C. + +### The number of entries of a loaded LutMap + +- C: `astLoadLutMap` takes 2 entries when the dump has no `Nlut` item. +- Rust: takes 0. +- Java: as C. + +### 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. + 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. + The change is seen by anything that uses the WcsMap on its own afterwards, and in dumps. +- 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. + +### The status of a MathMap with no outputs + +- **C quirk**: `astInitMathMap` reports a bad number of outputs with AST__BADNO and then its second line, "This number should be one or more.", with AST__BADNI, which replaces the status, so a caller sees AST__BADNI (probe `src/test/resources/probes/mathmap_probe.c`, case `count_errors`). +- Rust: reports AST__BADNO. +- Java: as C. + +### The messages of a MathMap's errors + +- C: each error names the method and class, quotes the expression up to the character where reading stopped, and adds a line naming the transformation function, as "Error in forward transformation function 3." (probe cases `expression_errors` and `function_errors`). +- Rust: has its own messages, with the same statuses. +- Java: as C. + +### The MathMap constant `` + +- C: loads `AST__DBL_DIG`, which is 17 (probe case `evaluate`). +- Rust: loads 15, `DBL_DIG`. +- Java: as C. + +### Maths library errors in a MathMap + +- C: traps the errors of `exp`, `cosh`, `sinh`, `tan`, `pow` and `ldexp` (in `<<` and `>>`) through `errno`, giving a bad value for an overflow and for an argument outside the domain (a negative number to a fractional power); `csch` and `sech` are then 0. + The macOS maths library sets no `errno`, so C built there gives the infinity or NaN instead, and a later operator acts on it: `!x**2` at 1e300 is 0 there (probe case `evaluate`). +- Rust: gives a bad value for any of these results that is not finite. +- Java: as C with a library that sets `errno` (glibc): a result that is not finite from finite arguments is bad. + +### A NaN made inside a MathMap expression + +- C: passes a NaN that an expression makes (such as `1e999-1e999`, whose constant overflows to infinity) to the output. +- Rust: replaces a NaN output by AST__BAD. +- Java: as C; an input that is not finite is bad, the rule for every Mapping. + +### The second value of a Gaussian pair + +- **C quirk**: `Gauss` (mathmap.c) keeps the second value of each pair it makes, and the flag saying it has one, in static variables shared by every MathMap, so the next `gauss` of any MathMap whose generator is active takes it. + A MathMap and its copy therefore give different Gaussian sequences, and two MathMaps used in turn take each other's values (probe cases `random_copies` and `gauss_two_mathmaps`); two threads using MathMaps at once race on it. +- Rust: keeps the value in each MathMap's random-number context. +- Java: as Rust, so a copy gives its original's sequence and a MathMap's sequence does not depend on other MathMaps; with one MathMap, or MathMaps whose generators are not yet active, the values are C's. + +### A MathMap Seed below 1 + +- **C quirk**: `Rand` makes a seed below 1 positive by adding `LONG_MAX`, which on a 64-bit `long` leaves the generators outside their ranges, so `rand(0,1)` gives values far outside 0 to 1 for several calls (Seed -7 gives -308527335.2 first; probe case `random_seeds`). +- Rust: the same. +- Java: as C. + +### A MathMap dump with fewer functions than its outputs or inputs + +- C: `astLoadMathMap` reads the counts `Nfwd` and `Ninv` (defaults the numbers of outputs and inputs) and compiles with them; a smaller count reads before the start of the function arrays. +- Rust: takes a count that is not positive as the default, and refuses a smaller one with AST__INNTF. +- Java: refuses a count smaller than the number of outputs or inputs with AST__INNTF and the message of `astInitMathMap`, naming `astLoadMathMap`. + +### The precedence of unary operators and `**` in a MathMap + +- **C quirk**: the `astMathMap` prologue, and jniast's MathMap Javadoc taken from it, list the unary operators `+ - ! .not.` above `**`, which says that `-x**2` is `(-x)**2`; `EvaluationSort` (mathmap.c) binds `**` tighter, so `-x**2` is `-(x**2)` and `x**-2` is `x**(-2)` (probe `src/test/resources/probes/mathmap_probe.c`, case `evaluate`). + The difference is in the documentation only. +- Rust: the parser follows the code, and its documentation lists `**` above the unary operators. +- Java: as Rust; MathMap's Javadoc lists `**` above the unary operators, as the code binds them. + +### Comparing two MathMaps + +- **C quirk**: `Equal` (mathmap.c) compares the compiled functions of the effective forward and inverse directions, but its loop over a function's opcode array starts at element 0, which holds the number of opcodes, and stops before the last opcode. + The last operation of a function is therefore never compared, so `y=x+1` equals `y=x-1` and `y=max(x,1)` equals `y=min(x,1)` (probe `src/test/resources/probes/mathmap_simplify_probe.c`, case `equal`). + A number of opcodes equal to the code of an operation that consumes a constant (0, 1, 62 or 63) consumes one as well; for a function of one operation that loads no constant, such as `y=`, C reads a list of constants that does not exist and crashes. +- Rust: `equal` compares the function texts and the Invert flags. +- Java: as C; where C reads past the end of the constants, a constant neither function has matches and one only one function has does not. + +### Simplifying a CmpMap clears AlSimp on the components it shares + +- C: `Simplify` (cmpmap.c) clears the flag that lets a restricted simplification use a Mapping on each component it joins into a new CmpMap; those components are shared with the input, so the input's components lose the flag too (probe case `simplify_input_after`, from `simplify/cap_restricted_component_flags.map`). +- Rust: copies the components, so the input keeps the flag. +- Java: as C. + +### A TranMap whose equal components were inverted when it was made + +- **C quirk**: `MapMerge` (`tranmap.c`) replaces a TranMap whose first component, in series with the inverse of its second, simplifies to a UnitMap with a copy of the first component. + The copy keeps the Invert value recorded when the TranMap was made, but the list entry it replaces stays applied forward, and the list's value is the one the result is given. + A TranMap of two equal Mappings that were inverted when it was made therefore becomes the first Mapping not inverted, which transforms the other way (probe `src/test/resources/probes/tranmap_probe.c`, cases `simp_equal_inverted_mathmaps`, and `simp_equal_inverted_lutmaps` at 3). + Two inverted ZoomMaps do not show it, because each simplifies on its own to a ZoomMap of the reciprocal factor first (case `simp_equal_inverted_components`). +- Rust: applies the copy inverted, so the transformation is kept. +- Java: as C. + +### Comparing two TranMaps + +- C: `Equal` (`tranmap.c`) sets each component to the Invert value its TranMap recorded and compares the components with `astEqual`, the `Equal` of their class. +- Rust: compares them with each class's `equal`. +- Java: as C. + +### The directions of a loaded TranMap + +- C: `astLoadTranMap` leaves TranForward and TranInverse to the Mapping part of the dump (`Fwd` and `Inv`, which a TranMap never writes, so both are defined). +- Rust: recomputes them from the components and the recorded Invert values. +- Java: as C. + +### The series flag of a decomposed TranMap + +- C: `Decompose` (`tranmap.c`) does not set the series flag, which its documentation gives as zero for a TranMap; the probe's `decompose` case gets back the value it set beforehand, and jniast's `decompose` passes an uninitialised one. +- Rust: its `Decomposition` has no series flag. +- Java: false. + +### The split of a TranMap of all its inputs, permuted + +- C: the base `MapSplit` (`mapping.c`) simplifies a PermMap and the TranMap in series; the TranMap's equal components make it a ZoomMap, which `astSimplify` records as simplified, so its dump has `IsSimp = 1` (oracle `map_split.json`, case `tranmap_full_permuted`). +- Rust: dumps the ZoomMap without that item, and its oracle test compares the case without `IsSimp` items. +- Java: as C. + +### The orientation in which RateMaps compare their Mappings + +- C: `Equal` (`ratemap.c`) sets each encapsulated Mapping to the Invert value its RateMap recorded when it was made and compares them with `astEqual`; `MapMerge` does the same before cancelling a RateMap with a neighbouring RateMap applied the other way. + A RateMap whose Mapping was inverted after the RateMap was made therefore equals, and cancels with, one made from a Mapping that was not (probe `src/test/resources/probes/ratemap_probe.c`, cases `equal` (`mapping_inverted_after`) and `cancel_mapping_inverted_after`). +- Rust: compares the encapsulated Mappings in their current orientations. +- Java: as C. + +### Cancelling a RateMap with its inverse + +- **C quirk**: `MapMerge` (`ratemap.c`) replaces a RateMap and a neighbouring RateMap of the same indices and an equal Mapping, applied in series the other way, with two UnitMaps, so that a series CmpMap of the two, which defines neither direction (a RateMap defines only one direction, so the pair defines neither), simplifies to a UnitMap that defines both. + For a Mapping of two inputs the RateMap followed by its inverse becomes a UnitMap of two axes, and the inverse followed by the RateMap a UnitMap of one (probe cases `cancel_two_inputs_upper` and `cancel_two_inputs_lower`). +- Rust: as C. +- Java: as C. + +### Comparing two ZoomMaps + +- **C quirk**: `Equal` (`zoommap.c`) compares the factors as stored, which is zero once the Zoom attribute has been cleared, though the factor is then 1: a ZoomMap whose Zoom is cleared does not equal a ZoomMap of factor 1. + For ZoomMaps with different Invert attributes it compares one factor with the reciprocal of the other, which for a cleared Zoom is infinite, and `astEQUAL` finds an infinite value equal to any finite value that is not bad (probe `src/test/resources/probes/equal_probe.c`, case `zoommap_cleared_zoom`). +- Rust: compares the factors in use, and, for different Invert attributes, their product with 1. +- Java: as C. + +### The attributes of a new GrismMap + +- C: `astGrismMap` leaves all eight attributes unset, so a new GrismMap's dump writes each as a comment holding its default; each can be tested and cleared, and setting `AST__BAD` (`INT_MAX` for GrismM) leaves it unset (`grismmap.c`). + The setters discard the records of simplification only when the value changes, and the loader re-applies each value read through them, so a dumped `IsSimp` card survives a read (probe `src/test/resources/probes/grismmap_probe.c`, case `dump_simplified`). +- Rust: `GrismMap::new` sets all eight attributes, and only `default_map` leaves them unset; there are no test or clear methods, the setters given the unset values acting as a clear. + Its loader keeps the `IsSimp` card as C's does, though `docs/issues/c-library-quirks.md` ("The `IsSimp` card does not survive being read back") counts GrismMap among the classes whose loaders discard it. +- Java: as C; jniast's constructor makes a GrismMap with no attribute set. + +### Comparing two GrismMaps + +- **C quirk**: `Equal` (`grismmap.c`) compares the attributes as stored, `AST__BAD` (or `INT_MAX` for GrismM) when unset, so a GrismMap with no attribute set does not equal one with each attribute set to its default, though the two transform alike (probe `src/test/resources/probes/grismmap_probe.c`, case `equal`, `default_vs_set_to_defaults`). +- Rust: compares the values in use. +- Java: as C. + +### Merging a GrismMap with a ZoomMap whose own Invert attribute is set + +- **C quirk**: `CanMerge` (`grismmap.c`) merges a GrismMap applied forward with a following ZoomMap, and a GrismMap applied inverted with a preceding one, scaling GrismG, GrismNRP and GrismWaveR by the ZoomMap's factor. + It takes the factor as the Zoom attribute, or its reciprocal when the ZoomMap's own Invert attribute differs from (following) or equals (preceding) the Invert value the simplification applies it with, so the factor is the right one only while the ZoomMap's own Invert attribute is unset or zero. + A GrismMap followed by a ZoomMap of factor 2 that was inverted before the two were combined therefore merges into a GrismMap for wavelengths scaled by 2 rather than by 1/2, and so does a ZoomMap inverted after the CmpMap was made, on either side: the simplified Mapping does not transform as the original (probe `src/test/resources/probes/grismmap_probe.c`, cases `inverted_zoom_after_forward`, `zoom_inverted_after_combining` and `zoom_inverted_after_combining_before`). + A ZoomMap inverted before it is combined that precedes the GrismMap is merged correctly, because the ZoomMap's own merge, which comes first, replaces it with a ZoomMap that is not inverted (case `inverted_zoom_before_inverted`). +- Rust: `grism_zoom_merge_at` in `mappings/simplify.rs` holds every Mapping of the list with its Invert attribute unset and takes the factor from the list's Invert value alone, so it merges these pairs correctly. +- Java: as C. + +### Comparing two PcdMaps + +- **C quirk**: `Equal` (`pcdmap.c`) compares Disco and the two PcdCen values as stored, `AST__BAD` when unset, so a PcdMap whose centre is unset does not equal one whose centre is set to zero, though the two transform alike (probe `src/test/resources/probes/pcdmap_probe.c`, case `equal`, `zero_vs_unset` and `small_vs_unset_disco`). +- Rust: compares the values in use. +- Java: as C. + +### When a PcdMap's coefficient is zero, and when two PcdMaps cancel + +- C: `MapMerge` and `CanMerge` (`pcdmap.c`) compare with the file's own `EQUAL` macro, whose floor is `1e5 * DBL_MIN` (about `2e-303`), not with `astEQUAL`, whose floor is `1e-12`. + So a PcdMap with a coefficient of `1e-13` is not replaced by a UnitMap (probe `src/test/resources/probes/pcdmap_probe.c`, case `small_disco`), though `astEqual` finds it equal to one with a coefficient of zero (case `equal`, `small_vs_zero_disco`), while one of `1e-310` is replaced (case `tiny_disco`); and PcdMaps applied in opposite directions whose centres differ by `1e-13` do not cancel (case `inverse_small_centre_offset`). +- Rust: `pcd_map_merge` (`mappings/simplify.rs`) and `PcdMap::try_merge` (`mappings/pcdmap.rs`) compare with `ast_equal`, which has `astEQUAL`'s floor, so they replace the PcdMap of coefficient `1e-13` with a UnitMap and cancel the pair whose centres differ by `1e-13`. +- Java: as C. + +### A SwitchMap selector value beyond the range of `int` + +- C: `GetRoute` and `Transform` (`switchmap.c`) exclude only `AST__BAD` and then take `(int) round( sel ) - 1` as the route index, so a selector value beyond the range of `int`, an infinity or a NaN makes the conversion undefined, and a conversion giving `INT_MIN` makes the `- 1` overflow, a second undefined step. + C's documented contract is that a nearest integer below 1 or above the number of routes picks no route. + The pinned library built on macOS aarch64 keeps to that contract for such values: `2147483648.5`, `4294967297`, `4294967298`, `±1e30` and `±DBL_MAX` pick no route, so there is no modular wrap into the routes (probe `src/test/resources/probes/switchmap_probe.c`, case `selector_values`); the probe cannot tell whether the conversion saturates or gives `INT_MIN`. +- Rust: compares the rounded value with 1 and the number of routes before converting, so such a value picks no route by definition. +- Java: converts as C does; Java's conversion is defined, giving 0 for a NaN and the nearest `int` for any other value, and `Integer.MIN_VALUE - 1` wraps to `Integer.MAX_VALUE`, so every such value gives an index outside the routes and picks no route, as the contract says and the probe shows. + +### Simplifying a SwitchMap that holds one Mapping twice + +- **C quirk**: `MapMerge` (`switchmap.c`) saves the Invert attribute of the forward selector, the inverse selector and each route Mapping in turn while setting each to the value the SwitchMap recorded, and sets them back in the same order, not the reverse. + When one Mapping is held twice, as when it is both selectors (`testswitchmap.c` section 2) or two routes, the value saved for its second place is the one just set for its first, so it is left with the value recorded for its first place instead of its own: a MathMap held as both selectors and inverted after the SwitchMap was made is no longer inverted after the SwitchMap is simplified (probe cases `simp_section2_shared_selector`, `simp_section2_shared_selector_inverted` and `simp_shared_route`). + The SwitchMap applies each Mapping with the value it recorded, so it transforms as before; anything that uses the Mapping on its own afterwards sees the change. +- Rust: holds its own copies, so nothing changes. +- Java: as C. + Java sets back each 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. + +### A SwitchMap round trip when only the forward selector was inverted + +- **C bug**: `Dump` (`switchmap.c`) writes `ISInv` with its set flag equal to its value and not as a helpful value, so `Channel` writes `ISInv = 0` not at all at Full 0, and only as a comment, which is never read back, at a higher Full; C's own dump therefore never carries `ISInv = 0`. + `astLoadSwitchMap` takes an absent `ISInv` to be the value of `FSInv`, so a SwitchMap whose forward selector was inverted when it was made and whose inverse selector was not reloads with its inverse selector inverted, its inverse transformation changed and `astEqual` false (probe `src/test/resources/probes/switchmap_probe.c`, case `dump_fsinv_set_isinv_unset`: the inverse transformation of 1000 is 1 before the round trip and 47.454545454545453 after). + An absent `RInv` is 0, and a dump without `RMap1` loads a SwitchMap of no route Mappings, which gives bad values everywhere. +- Rust: takes an absent `ISInv` to be 0, so its round trips keep the SwitchMap, and refuses a dump without route Mappings with AST__LDERR. +- Java: as C; a component that is not a Mapping is AST__LDERR, as for a CmpMap, TranMap or RateMap. + +### The messages of SwitchMap's constructor + +- **C quirk**: `astInitSwitchMap` reports a route Mapping with a different number of outputs from the first with the two numbers of inputs, as "Route Mapping number 2 has 1 output(s) but the first route Mapping has 1 output(s)." (probe case `error_route_nout`). + The public `astSwitchMap` reports no route Mappings with two spaces after the colon, the library's own with one. +- Rust: has its own messages, with the same statuses. +- Java: as C, the public constructor giving the public function's message. + +### The directions of a loaded IntraMap + +- C: `astLoadIntraMap` leaves TranForward and TranInverse to the Mapping part of the dump (`Fwd` and `Inv`); the registered function's AST__NOFWD and AST__NOINV flags decide them only when an IntraMap is made (`astInitIntraMap`). +- Rust: `has_forward` and `has_inverse` read the transformation's flags each time, so a dump whose `Fwd` or `Inv` disagrees with them reads back with the transformation's directions. +- Java: as C. + +### Registering a transformation function a second time + +- C: `IntraReg` accepts a second registration of a name only if the numbers of coordinates, the function, the flags and the purpose, author and contact strings are all the same, and otherwise reports AST__MRITF. + Its table is process-wide. +- Rust: `IntraRegistry::register` accepts a second registration of the same `Arc`, whatever else differs; the registry belongs to a Channel. +- Java: as C, comparing the Transformer object as C compares the function pointer. + Functions are registered with a Channel for its reads, and the process-wide table holds the Transformer of each IntraMap made in the process, weakly; a read looks in the Channel's first. + The process-wide names are made from identity hash codes, which two Transformers may share, so where C would refuse a name held by another function, making an IntraMap takes the next free name instead (`#1`, `#2`, ... added); the same Transformer with other details is still AST__MRITF. + +### Concurrent calls of an IntraMap's transformation function + +- C: `Transform` (`intramap.c`) holds `LOCK_MUTEX2` around each call of a registered function, so no two run at once; jniast's calls were serialised too, through its global `AstLock`. +- Rust: holds no lock, and requires `IntraTransform: Send + Sync`. +- Java: holds no lock; the Javadoc of Transformer and IntraMap says a Transformer must be thread-safe, since copies of an IntraMap share it (a user decision). + +### The numbers of coordinates `astLoadIntraMap` checks + +- **C quirk**: `astLoadIntraMap` compares the numbers of input and output coordinates the Mapping class's `GetNin` and `GetNout` give, which take account of the Invert attribute already loaded, with those registered. + An inverted IntraMap of a function with different numbers of inputs and outputs therefore cannot be read back: AST__BADNI (probe `src/test/resources/probes/intramap_load_probe.c`, case `inverted`). +- Rust: `IntraMap::from_node` does not compare the numbers of coordinates with the transformation's. +- Java: as C. + +### The status of an error from an IntraMap's transformation function + +- C: `Transform` (`intramap.c`) keeps the status the function set; jniast's `tranWrap` sets AST__ITFER for any exception the Transformer throws or any result of the wrong shape. +- Rust: keeps the code of the error the transformation returns. +- Java: AST__ITFER, as jniast, with the Transformer's exception as the cause. + +### The value of two pi in `platepos` + +- C: `platepos` (`dssmap.c`) adds its own `twopi`, 6.28318530717959, to a negative right ascension; it is a little more than the double nearest to two pi, so a wrapped right ascension is about four units in the last place larger (probe `src/test/resources/probes/dssmap_probe.c`, case `tran_pltra_small`, where the round trip through `platepix` comes back 2.4e-10 pixels short). +- Rust: adds `std::f64::consts::TAU`. +- Java: as C. + +### The side of a DssMap a WinMap merges from + +- C: `MapMerge` (`dssmap.c`) merges only a WinMap applied to the pixel coordinates: before the DssMap when the list applies it forward, after it when the list applies it inverted (probe cases `dssmap_then_winmap_4200` and `winmap_then_inverted_dssmap`, which do not merge). +- Rust (found by reading): `DssMap::try_merge` takes the formula from the DssMap's Invert value alone, and `default_map_merge` offers it the neighbour on either side, so a WinMap after a DssMap applied forward, or before one applied inverted, is folded in as if it were on the other side. +- Java: as C. + +### 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`). +- Rust: reads the terms of an owned WinMap, so nothing changes. +- Java: as C. + Java sets back the Invert attribute after a failed merge as it was, set or unset, where C's `astSetInvert` leaves it set, so the two differ only in what `test("Invert")` gives afterwards. + ## Units Rust's `src/units/` departs from C's `unit.c` in the following ways; Java follows C in each. @@ -453,12 +744,20 @@ Rust's `src/units/` departs from C's `unit.c` in the following ways; Java follow - Rust: gives the whole Title. - Java: as Rust. +### SpecFluxFrames whose SpecFrames do not convert + +- C: `MakeMap2`, `MakeMap3`, `MakeMapF` and `MakeMapI` (specfluxframe.c) find each component conversion with `astConvert`, which returns NULL when the Frames do not convert (SpecFrames in different Domains, say), so `MakeSFMapping` gives no match and the SpecFluxFrames do not convert. + `MakeSFMapping` gives a UnitMap when both components are `astEqual` (specfluxframe.c:1141-1163). +- Rust: `make_map2`, `make_map3`, `make_map_f` and `make_map_i` (`frames/specfluxframe.rs`) call `make_spec_mapping` and `make_flux_mapping` directly; `make_spec_mapping` (`frames/specframe.rs`) runs no Domain check and turns no Mapping into an AST__BADUN error. + Its comment calls the `astEqual` short-circuit a deliberate divergence from C, which it is not for the pinned C. +- Java: as C (`SpecFluxFrameTest.spectralDomainsThatDifferDoNotConvert`). + ### Casting between a CmpFrame and a SpecFluxFrame - C: `Cast` (cmpframe.c) copies a CmpFrame or SpecFluxFrame as an instance of any class of the CmpFrame family, a subclass included (`astCastCopy`), so a SpecFluxFrame template that matches no CmpFrame is cast into a plain CmpFrame and matched again, and a plain CmpFrame template that matches no SpecFluxFrame (the CmpFrame `ConvertX` gets from matching a SpecFluxFrame against a FluxFrame or SpecFrame) is cast into a SpecFluxFrame holding copies of its components, whose `Match` reaches `MakeSFMapping`. **C quirk**: `Cast` compares the classes through CmpFrame's own `class_vtab`, which is initialised only when a plain CmpFrame is first made, so in a process that has made SpecFluxFrames but no CmpFrame a SpecFluxFrame match that fails dereferences null in `astClassCompare` (probed: SIGSEGV converting a SpecFluxFrame whose SpecFrame has Domain `FOO` to a default one). - Rust: SpecFluxFrame has no `cast`, and `CmpFrame::cast` in `frames/cmpframe.rs` copies a CmpFrame only into a CmpFrame, so neither becomes the other and these conversions find nothing. -- Java: as C once a CmpFrame has been made: a FluxFrame or SpecFrame that does not match a SpecFluxFrame directly converts through `MakeSFMapping`, so it throws `needs RateMap` (or C's error, such as AST__ATSER from `GetSpecFrame`). +- Java: as C once a CmpFrame has been made: a FluxFrame or SpecFrame that does not match a SpecFluxFrame directly converts through `MakeSFMapping` (or gives C's error, such as AST__ATSER from `GetSpecFrame`). ## FitsChan @@ -945,7 +1244,6 @@ Rust's `src/units/` departs from C's `unit.c` in the following ways; Java follow - C: `SpectralAxes` tries each System of the `-X2P` algorithm (FREQ, WAVE, AWAV and VELO, the axis's own System among them) and of the grism algorithm (WAVE and AWAV in m) by setting it, and clearing or setting the Unit, through the FrameSet being written, which remaps its current Frame, and sets the original System and the linear Unit back after each, so the FrameSet's Mapping goes through each conversion and back, and a Unit that was not set is left set; it gives `IsMapTab1D` no unit (`fitschan.c` `SpectralAxes`). - Rust: `try_x2p_cascade` and `try_grism_cascade` in `fitschan/fset_to_store/spectral_axes.rs` convert clones of the SpecFrame and join the conversion to the pixel to world Mapping themselves, leaving the FrameSet unchanged; they skip the axis's own System, and pass to the next System when the reference value or the rate does not convert; `is_map_tab_1d` is given the linear Unit. - Java: as C (`FitsSpectralAxes`). - A FrameSet of this library's classes holds no GrismMap, so C's grism algorithm finds none, and only the attribute changes are made. ### The keywords `SpectralAxes` stores @@ -961,6 +1259,22 @@ Rust's `src/units/` departs from C's `unit.c` in the following ways; Java follow - Rust: as C. - Java: as C (`FitsSpectralAxes`, `FitsIsMapLinear`, `FitsFsetToStore.addVersion`). +### `SpectralAxes` changes Hz to GHz for a narrow spectral range + +**C quirk.** + +- C: `SpectralAxes` keeps the SpecFrame's Unit only if `IsMapLinear` finds the conversion from it to the default Unit linear over the spectral range of the image (`fitschan.c` `SpectralAxes`), and `IsMapLinear` requires every residual of its fit to be within 1e-7 of the range. + For a range that is narrow beside its values the conversion fails the test although it is a ZoomMap: the axis of `wcsconv/inputs/freq-log.head` spans about 1 Hz at 1.4204e9 Hz, so its values in GHz are rounded to about 2e-7 of their range, and C clears the Unit and writes the axis as `FREQ` in GHz (`CRVAL1 = 1.4204`, `CDELT1 = 1.000000023045475E-12`), where a range of 1e8 Hz keeps Hz. + The Unit is cleared on the FrameSet the write describes, which is not the caller's, so the caller's FrameSet keeps its Unit. +- Rust: as C (`is_map_linear` has the same tolerance, and `spectral_axes` makes the same test). +- Java: as C (`FitsSpectralAxes`, `FitsIsMapLinear`); probe `src/test/resources/probes/fitslog_probe.c` cases `freq_log_head` and `freq_log_head_unit`. + +### The MathMap of `LogAxis` + +- C: `LogAxis` makes the MathMap `logs=log(s)`, inverse `s=exp(logs)`, with SimpFI and SimpIF set, tests the axis with it and puts the same MathMap in the `-LOG` Mapping it returns; it tests neither the axis index nor whether the reference value is finite (`fitschan.c` `LogAxis`). +- Rust: `log_axis` in `fitschan/fset_to_store/log_axis.rs` makes the MathMap without SimpFI and SimpIF, and returns `None` for an axis index out of range or a reference value that is not finite. +- Java: as C (`FitsOtherAxes.logAxis`). + ## Test harness ### Round trips where C's own recorded inverse fails diff --git a/docs/superpowers/plans/2026-11-17-pure-java-ast-phase5-mappings.md b/docs/superpowers/plans/2026-11-17-pure-java-ast-phase5-mappings.md new file mode 100644 index 0000000..87d6bb4 --- /dev/null +++ b/docs/superpowers/plans/2026-11-17-pure-java-ast-phase5-mappings.md @@ -0,0 +1,283 @@ +# Pure-Java AST Phase 5 (The Remaining jniast Mappings) 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:** LutMap, MathMap, TranMap, RateMap, GrismMap, PcdMap, SwitchMap, IntraMap and DssMap work as C's do, with jniast's public API, and every place the earlier phases stop with `needs` one of them carries on as C does: SpecFluxFrame conversions, non-linear unit conversions, and FITS `-LOG`, `-TAB` and grism axes. + +**Architecture:** Port the Rust port's `mappings/{lutmap,mathmap/*,tranmap,ratemap,grismmap,pcdmap,switchmap,intramap,dssmap}.rs` onto the phase 1 to 4 classes, with SpecMap and TimeMap as the Java pattern for a Mapping class (attributes, `transformInto`, `mapMerge`, `rateAt`, `dump`, a loader in `ObjectRegistry`). +Take from C (`reference/starlink-ast/src/{lutmap,mathmap,tranmap,ratemap,grismmap,pcdmap,switchmap,intramap,dssmap}.c`) every part whose Rust structure follows from Rust's ownership rules. +The gates are the C test programs (`testlutmap.c`, `testratemap.c`, `testswitchmap.c`, through their Rust translations), the Rust repo's C-probe oracles, C's `wcsconv` rows and the deferred lists, each checked both ways. + +**Tech Stack:** as phases 1 to 4: 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 4). +The earlier plans' Shared Design sections and the rulings in `docs/reports/2026-11-1*-phase*-rulings.md` still apply where this plan does not change them. + +## Global Constraints + +- Every Global Constraint of the phase 1 plan applies unchanged (Java 8, no runtime dependencies, jniast signatures, 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: exactly jniast's constructors and methods for the classes of this phase: `LutMap(double[], double, double)`; `MathMap(int, int, String[], String[])` with `getSeed`/`setSeed`, `getSimpFI`/`setSimpFI`, `getSimpIF`/`setSimpIF`; `TranMap(Mapping, Mapping)`; `RateMap(Mapping, int, int)`; `GrismMap()` with the eight `getGrism*`/`setGrism*` pairs; `PcdMap(double, double[])` with `getDisco`/`setDisco`, `getPcdCen(int)`/`setPcdCen(int, double)`; `SwitchMap(Mapping, Mapping, Mapping[])`; `IntraMap(Transformer, int, int)`, `IntraMap(Transformer2)`, `IntraMap(Transformer1)`, `channelize()`, `unChannelize()`, `copy()`; the abstract classes `Transformer`, `Transformer1` and `Transformer2` and the interface `NeedsChannelizing` as jniast declares them; `DssMap` with no public constructor. + Every other attribute C has (LutInterp, LutEpsilon, and so on) is reached through the generic `AstObject` attribute methods, as in jniast. + Nothing else public is added. +- Before porting a class, read Rust `docs/porting-hazards.md`, its section in `docs/audits/mapping-c-parity.md`, and every entry naming it in `docs/issues/c-library-quirks.md` (search by name). + An entry marked RESOLVED upstream describes a fix made after the pin: read the pinned C to see whether the fix is already there (phase 4 found four that were, under other hashes); follow the pinned C, and record a real difference in `docs/rust-c-differences.md`. +- Rust comments cite older C line numbers; find each C function by name in the pinned source. +- Classes still absent after this phase: SelectorMap and the Regions (phase 6), FitsTable, NormMap, UnitNormMap, ChebyMap, XphMap, SplineMap, and the other AST classes jniast lacks (phase 9). + Each place C or Rust reaches one throws `UnsupportedOperationException` whose message ends `needs `, naming the first absent class C would build (the convention `Deferred.unavailableReason` reads). +- Values must match C to the oracle tolerances; when one does not, find the C function that computes it before touching the arithmetic (H7). + +## Review Focus + +1. A MathMap expression using each of C's operators and functions, with C's precedence (including the unary-above-`**` quirk), bad inputs, division by zero and out-of-domain arguments gives C's values, and each malformed expression gives C's status and message (test in Task 2). +2. MathMap's random-number functions: a MathMap and its copy give the same sequence for the same Seed, a copy's sequence does not disturb the original's, and two threads transforming two copies get identical results (test in Task 2). +3. A Transformer that throws, returns arrays of the wrong shape, or reports no forward or inverse transformation gives C's IntraMap error (AST__ITFER, AST__TRNND) and never a raw Java exception from inside the library (test in Task 12). +4. Every new class survives a NATIVE dump and read, through Channel and FitsChan, with each attribute set and unset, giving C's cards; a Mapping nested inside CmpMap, TranMap, RateMap or SwitchMap survives too (test in each class's task). +5. Simplifying CmpMaps that mix the new classes with the existing ones (LutMap beside WinMap and its own inverse, a MathMap and its inverse with SimpFI and SimpIF set, an inverted TranMap, a RateMap of a simplifiable Mapping, a SwitchMap whose route Mappings simplify) gives C's result (test in Tasks 1, 3, 5, 7 and 11). + +--- + +## Shared Design + +### Where the code goes + +- One public class per AST class, built as SpecMap and TimeMap are: attribute values and `getAttrib`/`setAttrib`/`testAttrib`/`clearAttrib`, `transformInto`, `mapMerge`, `rateAt` where C has a `Rate`, `equals` as C's `Equal`, `dump`/`dumpComment`, a loader in `ObjectRegistry`. +- Package-private helpers beside a class when it passes about 2,500 lines, named for the Rust module they port: `MathMapToken`, `MathMapParser`, `MathMapEvaluator`, `MathMapRandom` for `mathmap/{token,parser,evaluator,rng}.rs`. +- The FITS changes go into the phase 3 and 4 classes that throw `needs` today: `FitsWcsRead` (`-TAB` and logarithmic axes), `FitsWcsSpectral` (`-LOG`, `-GRI`, `-GRA`), `FitsOtherAxes` and `FitsSpectralAxes` (`LogAxis`, the grism branch), `UnitsMapper` (non-linear units), `SpecFluxFrame` (`MakeSFMapping`). + +### Taken from C rather than Rust + +1. TranMap, RateMap and SwitchMap hold the Mappings given, shared where C clones them and copied where C copies them; Rust's clones for borrowing are not reproduced. +2. MathMap keeps C's compiled form, one opcode list and constant list per function, so `Equal`, `MapMerge` and the dump follow C's comparison and card order. +3. MathMap's random-number state is C's per-MathMap `Rcontext`, copied by `astCopy` as C copies it. +4. IntraMap's Transformer is held by reference, as jniast does; C's process-wide `astIntraReg` table is not reproduced (Task 12 sets out the dump format). + +### Gates and deferred lists + +- The Rust test files of this phase (`test_lutmap.rs`, `test_lutmap_inverse.rs`, `test_mathmap.rs`, `test_tranmap.rs`, `test_ratemap.rs`, `test_grismmap.rs`, `test_pcdmap.rs`, `test_switchmap.rs`, `test_intramap.rs`) are not in `deferred/rust-tests.txt`, since phase 1 never listed them; each task translates its files and adds to `rust-tests.txt` only the tests that still need an absent class, with that reason. +- C-probe oracles `lutmap_forward_oracle`, `intramap_oracle` and `dss_merge_oracle` are converted by the task that needs them, from `tests//cases.rs` with the existing `CasesToJson`, as earlier phases did. +- `WcsconvTest`, `TransformOracleTest` (`headers.txt`), `SerialisationCorpusTest` (`serialisation.txt`, `full-dumps.txt`), `framesets.txt`, `simplify.txt`, `simplify-cases.txt` and `read-warnings.txt`: an entry whose only missing class arrives in a task passes in that task, or carries the next absent class as its reason; the lists stay stable on a rewrite (`-Dast.writeDeferred=true` makes no change). + +--- + +### Task 1: LutMap + +**Files:** +- Create: `LutMap.java` (Rust `mappings/lutmap.rs`; C `lutmap.c`) +- Modify: `ObjectRegistry.java`, `FitsWcsRead.java` (the `-TAB` branch that throws `needs LutMap` carries on to C's next step), `FitsMapTab.java` if it builds a LutMap C builds +- Test: `LutMapTest` (translates `test_lutmap.rs` and `test_lutmap_inverse.rs`, from `testlutmap.c`), `LutMapForwardOracleTest` (new, `lutmap_forward_oracle`), the deferred-list gates + +**Interfaces:** +- Produces: `public LutMap(double[] lut, double start, double inc)`; LutInterp and LutEpsilon attributes; package-private accessors for the table, start and increment that `FitsMapTab` and `MapMerge` use. + +- [ ] **Step 1: Write the failing tests:** the 54 tests of `test_lutmap.rs`, `test_lutmap_inverse.rs`, the oracle, a native round trip with LutInterp and LutEpsilon set and unset, the LutMap simplification cases of Review Focus 5 (`WinMap` and `ZoomMap` neighbours, a LutMap and its inverse), and a `-TAB` header read with TabOK 1 giving C's error now that LutMap exists. +- [ ] **Step 2: Run** `mvn test -Dtest='LutMapTest,LutMapForwardOracleTest'` — Expected: FAIL (no LutMap). +- [ ] **Step 3: Implement** C's forward interpolation (linear and nearest), its inverse (the monotonic search, the flat-section handling and LutEpsilon), its `MapMerge` and `Rate`, and its dump. +- [ ] **Step 4: Run** the Step 2 command, then `mvn -q test` — Expected: PASS; deferred lists rewritten with only `needs LutMap` entries gone or carrying the next reason. +- [ ] **Step 5: Commit** `Port LutMap`. + +### Task 2: MathMap expressions and transformation + +**Files:** +- Create: `MathMap.java`, `MathMapToken.java`, `MathMapParser.java`, `MathMapEvaluator.java`, `MathMapRandom.java` (Rust `mappings/mathmap/*`; C `mathmap.c`) +- Modify: `ObjectRegistry.java` +- Test: `MathMapTest` (translates the expression, transformation, attribute and error tests of `test_mathmap.rs`), the deferred-list gates + +**Interfaces:** +- Produces: `public MathMap(int nin, int nout, String[] fwd, String[] inv)`, `getSeed`/`setSeed`, `getSimpFI`/`setSimpFI`, `getSimpIF`/`setSimpIF`; package-private access to the compiled functions for Task 3's `Equal` and `MapMerge`. + +- [ ] **Step 1: Write the failing tests:** the `test_mathmap.rs` tests that need no simplification, Review Focus 1 (every operator and function C's symbol table lists, with bad and out-of-domain inputs, and each parse error), Review Focus 2 (Seed, copies, two threads), and a native round trip of a MathMap with intermediate variables, random functions and each attribute set and unset. +- [ ] **Step 2: Run** `mvn test -Dtest=MathMapTest` — Expected: FAIL (no MathMap). +- [ ] **Step 3: Implement** C's `ExtractExpressions`, `ExtractVariables`, `ParseVariable`, `CompileExpression` and `CompileMapping` (with C's error statuses and messages), `EvaluateFunction` and its virtual-machine opcodes, the random-number generator, and the dump. +- [ ] **Step 4: Run** the Step 2 command, then `mvn -q test` — Expected: PASS. +- [ ] **Step 5: Commit** `Port MathMap`. + +### Task 3: MathMap simplification, equality and units + +**Files:** +- Modify: `MathMap.java` (C `MapMerge`, `Equal`, `Rate`), `UnitsMapper.java` (C `astUnitMapper`'s MathMap for non-linear unit conversions) +- Test: `MathMapTest` (the rest of `test_mathmap.rs`), `UnitsMapperTest` or the existing units tests, the deferred-list gates + +**Interfaces:** +- Consumes: Task 2's compiled functions. +- Produces: MathMap simplification as C; `Units` conversions that need a MathMap (logarithmic and power units) give C's Mapping. + +- [ ] **Step 1: Write the failing tests:** the remaining `test_mathmap.rs` tests, the MathMap cases of Review Focus 5 (a MathMap beside its inverse with SimpFI and SimpIF each set and unset, two MathMaps with equal and unequal functions), and the unit conversions whose expected Mapping C builds as a MathMap (from the units tests and oracles that today expect `needs MathMap`). +- [ ] **Step 2: Run** `mvn test -Dtest='MathMapTest,Units*Test'` — Expected: FAIL. +- [ ] **Step 3: Implement** C's `MapMerge` (cancelling a MathMap and its inverse only as C's SimpFI and SimpIF allow), `Equal`, and the MathMap branch of `astUnitMapper`. +- [ ] **Step 4: Run** the Step 2 command, then `mvn -q test` — Expected: PASS; `needs MathMap` entries whose only missing class was MathMap pass or carry the next reason. +- [ ] **Step 5: Commit** `Simplify MathMaps and build them for non-linear units`. + +### Task 4: FITS logarithmic and tabular axes + +**Files:** +- Modify: `FitsWcsRead.java` (C `LogAxis`'s read side and the `-TAB` read), `FitsWcsSpectral.java` (`-LOG` spectral axes), `FitsOtherAxes.java` and `FitsSpectralAxes.java` (C `LogAxis` and the `-LOG` write branch) +- Test: `FitsWcsSpectralTest`, `FitsChanWcsWriteTest`, `TransformOracleTest`, `WcsconvTest`, the `rust-tests.txt` entries whose reason is `needs MathMap` or `needs LutMap` on a FITS path + +**Interfaces:** +- Consumes: Tasks 1 to 3. +- Produces: `-LOG` axes, spectral and other, read and written as C; `-TAB` reads go as far as C goes without a FitsTable (C's error when no table is available); `-TAB` writes still throw `needs FitsTable`. + +- [ ] **Step 1: Write the failing tests:** the `-LOG` read and write cases in `rust-tests.txt`, `headers.txt` and `wcsconv`, a `-LOG` spectral header read and written back in each encoding that accepts it, transforming as the original, and the `-TAB` read cases with C's outcome. +- [ ] **Step 2: Run** `mvn test -Dtest='FitsWcsSpectralTest,FitsChanWcsWriteTest,TransformOracleTest,WcsconvTest'` — Expected: FAIL. +- [ ] **Step 3: Implement** as C, in C's order of keyword use and warnings. +- [ ] **Step 4: Run** the Step 2 command, then `mvn -q test` — Expected: PASS. +- [ ] **Step 5: Commit** `Read and write logarithmic FITS axes`. + +### Task 5: TranMap + +**Files:** +- Create: `TranMap.java` (Rust `mappings/tranmap.rs`; C `tranmap.c`) +- Modify: `ObjectRegistry.java` +- Test: `TranMapTest` (translates `test_tranmap.rs`), the deferred-list gates + +**Interfaces:** +- Produces: `public TranMap(Mapping map1, Mapping map2)`; package-private access to the two Mappings and their Invert flags for `MapMerge` and dumps. + +- [ ] **Step 1: Write the failing tests:** the 31 tests of `test_tranmap.rs`, a native round trip with each component inverted, and the TranMap simplification cases of Review Focus 5. +- [ ] **Step 2: Run** `mvn test -Dtest=TranMapTest` — Expected: FAIL. +- [ ] **Step 3: Implement** as C, with C's `MapMerge` (including the TranMap-of-a-pair cases and `MapSplit`), `Rate`, `Equal` and dump. +- [ ] **Step 4: Run** the Step 2 command, then `mvn -q test` — Expected: PASS. +- [ ] **Step 5: Commit** `Port TranMap`. + +### Task 6: astEqual + +**Files:** +- Modify: `AstObject.java` and `Mapping.java` (C `object.c` and `mapping.c` `Equal`), every ported class whose C source has its own `Equal` (`unitmap.c`, `zoommap.c`, `shiftmap.c`, `winmap.c`, `matrixmap.c`, `permmap.c`, `polymap.c`, `sphmap.c`, `wcsmap.c`, `slamap.c`, `timemap.c`, `specmap.c`, `cmpmap.c`, `lutmap.c`, `mathmap.c`, `tranmap.c`, `frame.c`, `frameset.c`), and the existing `equalTo` methods, which become these overrides; `Simplifier.java` (the recursion guard compares with `astEqual` as `cmpmap.c` `Simplify` does) +- Test: `EqualTest` (translates `test_equal.rs` and `test_equal_oracle.rs`), the `astEqual (out-of-scope method)` entries of `rust-tests.txt`, the simplify gates + +**Interfaces:** +- Produces: package-private `boolean astEqual(AstObject that)` on `AstObject`, dispatching to each class's C `Equal`, for RateMap, SwitchMap and TranMap to compare the Mappings they hold; the public `equals` keeps jniast's text comparison. + +- [ ] **Step 1: Write the failing tests:** the 81 tests of `test_equal.rs`, `test_equal_oracle.rs`, every other `rust-tests.txt` entry whose reason is `astEqual (out-of-scope method)`, and C-probe cases where C's `Equal` and a text comparison disagree (an inverted ZoomMap(2) against ZoomMap(0.5), Mappings differing only in ID or Ident, MathMap's last-opcode quirk). +- [ ] **Step 2: Run** `mvn test -Dtest=EqualTest` — Expected: FAIL. +- [ ] **Step 3: Implement** each class's `Equal` as C has it, with C's quirks, and replace the text comparisons that stand in for `astEqual` (the Simplifier recursion guard, `TranMap`'s component comparison) where C calls `astEqual`. +- [ ] **Step 4: Run** the Step 2 command, then `mvn -q test` — Expected: PASS; the simplify gates unchanged or with entries leaving. +- [ ] **Step 5: Commit** `Port astEqual`. + +### Task 7: RateMap + +**Files:** +- Create: `RateMap.java` (Rust `mappings/ratemap.rs`; C `ratemap.c`) +- Modify: `ObjectRegistry.java`, `Rate.java` if C's RateMap uses a part of `astRate` not yet ported +- Test: `RateMapTest` (translates `test_ratemap.rs`, from `testratemap.c`), the deferred-list gates + +**Interfaces:** +- Produces: `public RateMap(Mapping map, int ax1, int ax2)`. + +- [ ] **Step 1: Write the failing tests:** the 32 tests of `test_ratemap.rs`, a native round trip, and the RateMap simplification cases of Review Focus 5. +- [ ] **Step 2: Run** `mvn test -Dtest=RateMapTest` — Expected: FAIL. +- [ ] **Step 3: Implement** as C, with its `MapMerge` (a RateMap of a simplified Mapping, of a UnitMap, and the cancellation C does), `Equal` and dump. +- [ ] **Step 4: Run** the Step 2 command, then `mvn -q test` — Expected: PASS. +- [ ] **Step 5: Commit** `Port RateMap`. + +### Task 8: SpecFluxFrame conversions + +**Files:** +- Modify: `SpecFluxFrame.java` (C `MakeSFMapping`, replacing the `needs RateMap` throws) +- Test: `SpecFluxFrameTest`, `SpecFluxCmpOracleTest`, `SpecFluxPrimaryOracleTest`, the `rust-tests.txt` and oracle cases that expect `needs RateMap` + +**Interfaces:** +- Consumes: Tasks 2, 3, 5, 6 and 7. +- Produces: conversions between any two SpecFluxFrames as C builds them. + +- [ ] **Step 1: Write the failing tests:** every case that expects `needs RateMap` now expects C's Mapping and values, including Jy to mJy at one spectral system, and FLXDN to FLXDNW across spectral systems and units; a FrameSet holding two SpecFluxFrames converts in both directions. +- [ ] **Step 2: Run** `mvn test -Dtest='SpecFluxFrameTest,SpecFluxCmpOracleTest,SpecFluxPrimaryOracleTest'` — Expected: FAIL. +- [ ] **Step 3: Implement** C's `MakeSFMapping` (the RateMap of the spectral Mapping, the MathMap that scales flux by it, and the TranMap that joins them). +- [ ] **Step 4: Run** the Step 2 command, then `mvn -q test` — Expected: PASS. +- [ ] **Step 5: Commit** `Convert between SpecFluxFrames with differing components`. + +### Task 9: GrismMap and FITS grism axes + +**Files:** +- Create: `GrismMap.java` (Rust `mappings/grismmap.rs`; C `grismmap.c`) +- Modify: `ObjectRegistry.java`, `FitsWcsSpectral.java` (`-GRI` and `-GRA` read), `FitsSpectralAxes.java` (C's `grism` branch, which extracts a GrismMap from the Mapping) +- Test: `GrismMapTest` (translates `test_grismmap.rs`), `FitsWcsSpectralTest`, `FitsChanWcsWriteTest`, `WcsconvTest`, the deferred-list gates + +**Interfaces:** +- Produces: `public GrismMap()` and the eight attribute pairs; FITS `-GRI`/`-GRA` read and write as C. + +- [ ] **Step 1: Write the failing tests:** the 22 tests of `test_grismmap.rs`, a native round trip with each attribute set and unset, the GrismMap simplification cases (C's `MapMerge` with ZoomMap and WinMap neighbours and its own inverse), and `-GRI` and `-GRA` headers read and written back, transforming as the original. +- [ ] **Step 2: Run** `mvn test -Dtest='GrismMapTest,FitsWcsSpectralTest,FitsChanWcsWriteTest,WcsconvTest'` — Expected: FAIL. +- [ ] **Step 3: Implement** as C. +- [ ] **Step 4: Run** the Step 2 command, then `mvn -q test` — Expected: PASS. +- [ ] **Step 5: Commit** `Port GrismMap and read and write grism axes`. + +### Task 10: PcdMap + +**Files:** +- Create: `PcdMap.java` (Rust `mappings/pcdmap.rs`; C `pcdmap.c`) +- Modify: `ObjectRegistry.java` +- Test: `PcdMapTest` (translates `test_pcdmap.rs`), the deferred-list gates + +**Interfaces:** +- Produces: `public PcdMap(double disco, double[] pcdcen)`, `getDisco`/`setDisco`, `getPcdCen(int)`/`setPcdCen(int, double)`. + +- [ ] **Step 1: Write the failing tests:** the 26 tests of `test_pcdmap.rs`, a native round trip, and the PcdMap simplification cases (C's `PcdZoom` and `PcdPerm` with ZoomMap and PermMap neighbours, inverted on either side). +- [ ] **Step 2: Run** `mvn test -Dtest=PcdMapTest` — Expected: FAIL. +- [ ] **Step 3: Implement** as C. +- [ ] **Step 4: Run** the Step 2 command, then `mvn -q test` — Expected: PASS. +- [ ] **Step 5: Commit** `Port PcdMap`. + +### Task 11: SwitchMap + +**Files:** +- Create: `SwitchMap.java` (Rust `mappings/switchmap.rs`; C `switchmap.c`) +- Modify: `ObjectRegistry.java` +- Test: `SwitchMapTest` (translates `test_switchmap.rs`, from `testswitchmap.c`), the deferred-list gates + +**Interfaces:** +- Produces: `public SwitchMap(Mapping fsmap, Mapping ismap, Mapping[] routemaps)`. + +- [ ] **Step 1: Write the failing tests:** the `test_switchmap.rs` tests whose selectors are not SelectorMaps (those go to `rust-tests.txt` with the Region class C builds first), a native round trip, and the SwitchMap simplification cases of Review Focus 5. +- [ ] **Step 2: Run** `mvn test -Dtest=SwitchMapTest` — Expected: FAIL. +- [ ] **Step 3: Implement** as C, including its conversion of selector values to route indices (the C quirk on range checks), `MapMerge`, `Equal` and dump. +- [ ] **Step 4: Run** the Step 2 command, then `mvn -q test` — Expected: PASS. +- [ ] **Step 5: Commit** `Port SwitchMap`. + +### Task 12: IntraMap and Transformers + +**Files:** +- Create: `IntraMap.java`, `Transformer.java`, `Transformer1.java`, `Transformer2.java`, `NeedsChannelizing.java` (jniast's Java classes for the API; Rust `mappings/intramap.rs` and C `intramap.c` for the Mapping) +- Modify: `ObjectRegistry.java`, `Channel.java` (jniast's channelize and unChannelize calls around a write and read) +- Test: `IntraMapTest` (translates `test_intramap.rs`), `IntraMapOracleTest` (new, `intramap_oracle`), the deferred-list gates + +**Interfaces:** +- Produces: the jniast API listed in Global Constraints. + +- [ ] **Step 1: Write the failing tests:** the 11 tests of `test_intramap.rs`, the oracle, Review Focus 3, a Serializable Transformer written and read back through Channel (top level and inside a CmpMap), and a non-Serializable Transformer's write failing as jniast's does. +- [ ] **Step 2: Run** `mvn test -Dtest='IntraMapTest,IntraMapOracleTest'` — Expected: FAIL. +- [ ] **Step 3: Implement** the Mapping as C's IntraMap (Fname, IntraFlag, the forward and inverse flags from the Transformer, SimpFI and SimpIF in `MapMerge`) and the serialisation of the Transformer in jniast's printable encoding, so a dump jniast wrote reads back. +- [ ] **Step 4: Run** the Step 2 command, then `mvn -q test` — Expected: PASS. +- [ ] **Step 5: Commit** `Port IntraMap and the Transformer classes`. + +### Task 13: DssMap + +**Files:** +- Create: `DssMap.java` (Rust `mappings/dssmap.rs`; C `dssmap.c`) +- Modify: `ObjectRegistry.java` +- Test: `DssMapTest` (the unit tests of `dssmap.rs`), `DssMergeOracleTest` (new, `dss_merge_oracle`), the deferred-list gates + +**Interfaces:** +- Produces: `DssMap` with no public constructor, loaded from dumps, transforming and merging as C. + +- [ ] **Step 1: Write the failing tests:** the unit tests, the oracle, the `serialisation.txt` and `full-dumps.txt` entries whose reason is `needs DssMap`, and a native round trip. +- [ ] **Step 2: Run** `mvn test -Dtest='DssMapTest,DssMergeOracleTest'` — Expected: FAIL. +- [ ] **Step 3: Implement** as C (the plate solution, its `MapMerge` with neighbouring WinMaps and ZoomMaps, and the dump that holds the FITS cards). +- [ ] **Step 4: Run** the Step 2 command, then `mvn -q test` — Expected: PASS. +- [ ] **Step 5: Commit** `Port DssMap`. + +### Task 14: The remaining Rust tests and the deferred sweep + +**Files:** +- Test: translations of every remaining test in `rust-tests.txt` whose reason names a class this phase adds (`test_equal.rs`, `test_cmpmap.rs`, `test_native_roundtrip_all.rs`, `test_map_split.rs`, `test_nan_protocol.rs`, `test_constructor_checks.rs`, `test_clear_on_set.rs` and the others the list names) + +- [ ] **Step 1: Translate** each test, expected values from C as the Rust test records them. +- [ ] **Step 2: Run** `mvn -q test -Dast.writeDeferred=true` and diff every `deferred/*.txt` against the branch base: no entry names a class this phase adds; every entry that changed reason names a class still absent. +- [ ] **Step 3: Run** `mvn verify` on JDK 21 and `mvn test -Djvm=` — Expected: PASS. +- [ ] **Step 4: Commit** `Translate the remaining Mapping Rust tests` and any list changes as `Sweep the deferred lists after phase 5`. + +### Task 15: The phase 5 report + +- [ ] **Step 1: Write** `docs/reports/2026-11-
-phase5-report.md` and `docs/reports/2026-11-
-phase5-rulings.md` in the form of the phase 4 report: what was ported, departures from the plan, gates before and after, tolerances with their traced causes, C defects found, final review, gaps and risks. +- [ ] **Step 2: Commit** `Report phase 5`. diff --git a/src/main/java/uk/ac/starlink/ast/AstObject.java b/src/main/java/uk/ac/starlink/ast/AstObject.java index f9484e6..fd0006c 100644 --- a/src/main/java/uk/ac/starlink/ast/AstObject.java +++ b/src/main/java/uk/ac/starlink/ast/AstObject.java @@ -251,6 +251,33 @@ public boolean sameObject(Object obj) { return obj == this; } + /** + * Whether {@code that} is equivalent to this Object, as C's {@code astEqual} (object.c {@code + * astEqual_}) decides it: the same object, or, if {@code that} is not null, an Object the + * {@code Equal} of this Object's class ({@link #equalTo}) finds equivalent. Unlike {@link + * #equals}, which compares descriptions, each class compares what it considers significant: a + * ZoomMap and an inverted ZoomMap of the reciprocal factor are equivalent, and Frames are + * equivalent when the conversion between them is a UnitMap. + */ + // C compares the pointers first: the same object, not an equal one. + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) + final boolean astEqual(AstObject that) { + return this == that || (that != null && equalTo(that)); + } + + /** + * C's {@code Equal} for this Object's class, which {@link #astEqual} calls with an Object other + * than this one. The base Object class's (object.c {@code Equal}) finds Objects equivalent when + * they are the same object, or of the same AST class: C compares the class names and the sizes + * of the structures, and objects of one AST class have structures of one size, so the class + * names ({@link #astClass}) decide. + */ + // C compares the pointers first, and then the class names, not any equals method. + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) + boolean equalTo(AstObject that) { + return this == that || astClass().equals(that.astClass()); + } + /** * Tests whether {@code obj} resembles this Object in all respects: whether it is of the same * class and is written to a Channel (with Full -1 and no comments) as the same text. This may diff --git a/src/main/java/uk/ac/starlink/ast/Channel.java b/src/main/java/uk/ac/starlink/ast/Channel.java index 0337f3f..a4590c9 100644 --- a/src/main/java/uk/ac/starlink/ast/Channel.java +++ b/src/main/java/uk/ac/starlink/ast/Channel.java @@ -109,6 +109,12 @@ private static final class Input { /** The warnings from the most recent read or write. */ private List warningList = new ArrayList<>(); + /** + * The transformation functions registered with this Channel for the IntraMaps it reads (C's + * {@code astIntraReg}), or null if none is. + */ + private IntraRegistry intraRegistry; + /** * Creates a Channel that reads from {@code in} and writes to {@code out}. * @@ -227,6 +233,26 @@ void deepCopy() { fdOut = null; fileReturned = new ArrayDeque<>(); warningList = new ArrayList<>(warningList); + if (intraRegistry != null) { + intraRegistry = intraRegistry.copy(); + } + } + + /** + * Registers {@code trans} as the transformation function called {@code name}, so that an + * IntraMap this Channel reads whose function has that name uses it, in preference to the + * process-wide table: C's {@code astIntraReg}, whose registrations are process-wide where + * these belong to the Channel. See {@link IntraRegistry#register}. + * + * @param nin the number of input coordinates of the function, or {@link IntraRegistry#AST__ANY} + * @param nout the number of output coordinates of the function, or {@link + * IntraRegistry#AST__ANY} + */ + void registerIntra(String name, int nin, int nout, Transformer trans) { + if (intraRegistry == null) { + intraRegistry = new IntraRegistry(); + } + intraRegistry.register(name, nin, nout, trans); } // ------------------------------------------------------------------ @@ -367,6 +393,9 @@ private static void closeQuietly(Closeable c) { * are discarded, and {@link #warnings} gives those of this one: each item in the description * that no class recognises is reported, as a warning or, with Strict set, as an error. * + *

An Object read that implements {@link NeedsChannelizing} has its {@code unChannelize} + * method called, as jniast's Channel calls it; an exception it throws is passed on unchanged. + * * @return the Object read, or null if there are no more Objects to read * @throws IOException if {@link #source} throws it * @throws AstException with status {@code AST__BADIN} if a line cannot be interpreted while @@ -381,12 +410,15 @@ public AstObject read() throws IOException { warningList.clear(); NativeStream reader = new NativeStream(this::readLine, astClass(), getStrict(), getReportLevel()); List returned = new ArrayList<>(); + AstObject obj; try { - return readObject(reader, mark -> returned.addAll(reader.lines.subList(mark, reader.lines.size()))); + obj = readObject(reader, mark -> returned.addAll(reader.lines.subList(mark, reader.lines.size()))); } finally { warningList = new ArrayList<>(reader.warnings); returnLines(returned); } + unChannelize(obj); + return obj; } /** @@ -400,6 +432,17 @@ AstObject readObject(NativeStream reader, IntConsumer rewind) throws IOException if (object == null) { return null; } + // The IntraMap loader finds the functions registered with this Channel while it reads. + IntraRegistry previous = IntraRegistry.enter(intraRegistry); + try { + return load(object, reader, rewind, cls); + } finally { + IntraRegistry.restore(previous); + } + } + + /** The Object {@code object} describes, loaded as {@link #readObject} loads it. */ + private static AstObject load(NativeStream.ReadObject object, NativeStream reader, IntConsumer rewind, String cls) { AstObject loaded; try { loaded = ObjectRegistry.load(object.node); @@ -435,12 +478,18 @@ AstObject readObject(NativeStream reader, IntConsumer rewind) throws IOException * Writes an Object to this Channel, after any written before, as AST's native text. The * warnings of the previous read or write are discarded. * + *

An Object that implements {@link NeedsChannelizing} has its {@code channelize} method + * called before it is written, and its {@code unChannelize} method after, as jniast's Channel + * calls them; an exception either throws is passed on unchanged, and one from {@code + * channelize} stops the write before anything is written. + * * @param obj the Object to write * @return the number of Objects written: 1 * @throws IOException if {@link #sink} throws it * @throws AstException with status {@code AST__WRERR} if the SinkFile cannot be opened */ public int write(AstObject obj) throws IOException { + channelize(obj); warningList.clear(); String text = NativeWriter.render(NativeNode.of(obj), options()); for (String line : NativeReader.lines(text)) { @@ -449,9 +498,55 @@ public int write(AstObject obj) throws IOException { if (fdOut != null) { fdOut.flush(); } + unChannelize(obj); return 1; } + /** + * Calls the {@code channelize} method of {@code obj} if it implements {@link + * NeedsChannelizing}, as jniast's Channel and FitsChan writes do (jni/Channel.c and + * jni/FitsChan.c {@code write}), passing on any exception unchanged, as the JNI code does + * whether or not the calling method declares it. + */ + // NeedsChannelizing.channelize is declared to throw any Exception. + @SuppressWarnings("PMD.AvoidCatchingGenericException") + static void channelize(AstObject obj) { + if (obj instanceof NeedsChannelizing) { + try { + ((NeedsChannelizing) obj).channelize(); + } catch (Exception e) { + throw Channel.passOn(e); + } + } + } + + /** + * Calls the {@code unChannelize} method of {@code obj} if it implements {@link + * NeedsChannelizing}, as jniast's Channel and FitsChan reads and writes do, passing on any + * exception unchanged. + */ + // NeedsChannelizing.unChannelize is declared to throw any Exception. + @SuppressWarnings("PMD.AvoidCatchingGenericException") + static void unChannelize(AstObject obj) { + if (obj instanceof NeedsChannelizing) { + try { + ((NeedsChannelizing) obj).unChannelize(); + } catch (Exception e) { + throw Channel.passOn(e); + } + } + } + + /** + * Throws {@code e} as it is, checked or not, as an exception pending in jniast's JNI code + * reaches the Java caller whatever the native method declares. + */ + // The cast is unchecked by design: the compiler takes E to be unchecked, and e is thrown as it is. + @SuppressWarnings({"unchecked", "TypeParameterUnusedInFormals"}) + private static RuntimeException passOn(Exception e) throws E { + throw (E) e; + } + /** The options this Channel writes with. */ ChannelOptions options() { return new ChannelOptions(getComment(), getFull(), getIndent()); diff --git a/src/main/java/uk/ac/starlink/ast/CmpMap.java b/src/main/java/uk/ac/starlink/ast/CmpMap.java index 183dcef..8b0037c 100644 --- a/src/main/java/uk/ac/starlink/ast/CmpMap.java +++ b/src/main/java/uk/ac/starlink/ast/CmpMap.java @@ -257,6 +257,101 @@ boolean mapList(boolean series, boolean invert, List maps, ListAs in C, the attributes are set back in the order they were set, so that when the two + * lists hold the same object in the same place it is left with the value the first list gives + * it. If neither CmpMap may be decomposed ({@link #doNotSimplify}), each is decomposed one level + * further ({@link #expandInto}) and copies of the Mappings are compared instead, leaving the + * Mappings unchanged. + */ + // C compares the pointers: each list holds the CmpMap itself when it was not decomposed. + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof CmpMap)) { + return false; + } + CmpMap other = (CmpMap) that; + if (series != other.series) { + return false; + } + List thisMaps = new ArrayList<>(); + List thisInverts = new ArrayList<>(); + mapList(series, getInvert(), thisMaps, thisInverts); + List thatMaps = new ArrayList<>(); + List thatInverts = new ArrayList<>(); + other.mapList(other.series, other.getInvert(), thatMaps, thatInverts); + boolean expanded = false; + if (thisMaps.size() == 1 && thatMaps.size() == 1 && thisMaps.get(0) == this && thatMaps.get(0) == other) { + thisMaps.clear(); + thisInverts.clear(); + thatMaps.clear(); + thatInverts.clear(); + expandInto(thisMaps, thisInverts); + other.expandInto(thatMaps, thatInverts); + expanded = true; + } + if (thisMaps.size() != thatMaps.size()) { + return false; + } + boolean result = false; + for (int i = 0; i < thisMaps.size(); i++) { + Mapping m1 = thisMaps.get(i); + Mapping m2 = thatMaps.get(i); + boolean inv1 = thisInverts.get(i); + boolean inv2 = thatInverts.get(i); + if (expanded) { + result = equalMapping(m1, inv1, m2, inv2); + } else { + int[] saved = swapInverts(m1, inv1, m2, inv2); + try { + result = m1.astEqual(m2); + } finally { + restoreInverts(m1, m2, saved); + } + } + if (!result) { + break; + } + } + return result; + } + + /** + * Whether copies of {@code a} and {@code b}, with their Invert attributes set to {@code + * invertA} and {@code invertB}, are equal (C's {@code EqualMapping}, cmpmap.c); {@code a} and + * {@code b} are not changed. + */ + private static boolean equalMapping(Mapping a, boolean invertA, Mapping b, boolean invertB) { + Mapping aCopy = (Mapping) a.copy(); + Mapping bCopy = (Mapping) b.copy(); + aCopy.setInvert(invertA); + bCopy.setInvert(invertB); + return aCopy.astEqual(bCopy); + } + + /** + * Appends the Mappings this CmpMap decomposes into one level down, even when it may not be + * decomposed (C's {@code ExpandCmpMap}, cmpmap.c): its components, in the order and with the + * Invert values {@link #decomposeInto} gives for its Invert attribute, each decomposed in the + * usual way ({@link #mapList}). + */ + private void expandInto(List maps, List inverts) { + boolean[] flags = new boolean[3]; + Mapping[] parts = decomposeInto(flags); + parts[0].mapList(series, flags[1], maps, inverts); + parts[1].mapList(series, flags[2], maps, inverts); + } + /** cmpmap.c {@code Simplify}: {@link Simplifier#simplifyCmpMap}. */ @Override Mapping simplifyStep() { diff --git a/src/main/java/uk/ac/starlink/ast/DssMap.java b/src/main/java/uk/ac/starlink/ast/DssMap.java new file mode 100644 index 0000000..d676802 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/DssMap.java @@ -0,0 +1,732 @@ +package uk.ac.starlink.ast; + +/** + * A Mapping which transforms between 2-dimensional pixel coordinates and an equatorial sky + * coordinate system (right ascension and declination) using a Digitised Sky Survey (DSS) + * astrometric plate solution. + * + *

The input coordinates are pixel numbers along the first and second dimensions of an image, + * where the centre of the first pixel is located at (1,1) and the spacing between pixel centres is + * unity. The output coordinates are right ascension and declination in radians. The celestial + * coordinate system used (FK4, FK5, etc.) is unspecified, and will usually be indicated by + * appropriate keywords in a FITS header. + * + *

The DssMap class has no constructor. A DssMap is made only by reading one from a Channel, or + * by simplifying a CmpMap in which a DssMap absorbs a neighbouring WinMap. Reading a FITS header + * with the DSS encoding gives a FrameSet whose Mapping holds a TPN projection, not a DssMap. + * + *

The DssMap class defines no attributes beyond those of every Mapping. + * + *

Ported from Rust {@code mappings/dssmap.rs} and C {@code dssmap.c}. The plate solution is + * computed by C's ports of the SAOimage routines {@code platepos} and {@code platepix} (Doug Mink, + * Smithsonian Astrophysical Observatory). + */ +public class DssMap extends Mapping { + + /** C's {@code AST__DD2R}: radians per degree. */ + private static final double AST__DD2R = 0.017453292519943295; + + /** C's {@code AST__DR2D}: degrees per radian. */ + private static final double AST__DR2D = 57.29577951308232; + + /** Radians per degree as {@code platepos} and {@code platepix} write it ({@code cond2r}). */ + private static final double COND2R = 1.745329252e-2; + + /** Arcseconds per radian as {@code platepos} and {@code platepix} write it ({@code cons2r}). */ + private static final double CONS2R = 206264.8062470964; + + /** Two pi as {@code platepos} writes it ({@code twopi}), a little more than the double nearest to two pi. */ + private static final double TWOPI = 6.28318530717959; + + /** The convergence tolerance (mm) of the Newton iteration in {@code platepix}. */ + private static final double TOLERANCE = 0.0000005; + + /** The most iterations {@code platepix} makes. */ + private static final int MAX_ITERATIONS = 50; + + /** The number of orientation coefficients, PPO1 to PPO6. */ + private static final int NORIENT = 6; + + /** The number of plate solution coefficients on each axis, AMDX1 to AMDX19 and AMDY1 to AMDY19. */ + private static final int NCOEFF = 19; + + /** The number of plate solution coefficients on each axis that must be given. */ + private static final int NCOEFF_REQUIRED = 13; + + // The plate solution, the members of C's WorldCoor structure that platepos and platepix use. + + /** Right ascension of the plate centre, radians ({@code plate_ra}). */ + private double plateRa; + + /** Declination of the plate centre, radians ({@code plate_dec}). */ + private double plateDec; + + /** Plate scale, arcseconds per millimetre ({@code plate_scale}). */ + private double plateScale; + + /** Pixel offset of the image corner on the first axis ({@code x_pixel_offset}). */ + private double xPixelOffset; + + /** Pixel offset of the image corner on the second axis ({@code y_pixel_offset}). */ + private double yPixelOffset; + + /** Pixel size on the first axis, microns ({@code x_pixel_size}). */ + private double xPixelSize; + + /** Pixel size on the second axis, microns ({@code y_pixel_size}). */ + private double yPixelSize; + + /** Orientation coefficients PPO1 to PPO6 ({@code ppo_coeff}). */ + private double[] ppoCoeff = new double[NORIENT]; + + /** Plate solution coefficients AMDX1 to AMDX19 ({@code amd_x_coeff}). */ + private double[] amdXCoeff = new double[NCOEFF]; + + /** Plate solution coefficients AMDY1 to AMDY19 ({@code amd_y_coeff}). */ + private double[] amdYCoeff = new double[NCOEFF]; + + /** + * C's {@code astDssMap} (dssmap.c): a DssMap with the plate solution the DSS cards of {@code + * fits} describe, read as C's {@code BuildWcs} reads them. + * + * @throws AstException with status {@code AST__BDFTS} if a card the plate solution needs is + * missing + */ + DssMap(FitsChan fits) { + super(2, 2, true, true); + buildWcs(fits, "astInitDssMap", "DssMap"); + } + + /** + * Loads a DssMap from its description, as C's {@code astLoadDssMap} does: the plate + * parameters, PPO3, PPO6 and the first 13 plate solution coefficients on each axis must be + * present; the other coefficients default to zero. + * + * @throws AstException with status {@code AST__RDERR} if a required item is missing + */ + DssMap(NativeNode node) { + super(node); + NativeNode part = node.section("DssMap"); + plateRa = readRequired(part, "PltRA", "Plate centre RA"); + plateDec = readRequired(part, "PltDec", "Plate centre Dec"); + plateScale = readRequired(part, "PltScl", "Plate scale"); + xPixelOffset = readRequired(part, "CNPix1", "X pixel offset"); + yPixelOffset = readRequired(part, "CNPix2", "Y pixel offset"); + xPixelSize = readRequired(part, "XPixSz", "X pixel size"); + yPixelSize = readRequired(part, "YPixSz", "Y pixel size"); + for (int i = 0; i < NORIENT; i++) { + String key = "PPO" + (i + 1); + if (i == 2 || i == 5) { + ppoCoeff[i] = readRequired(part, key, "orientation coefficient " + (i + 1)); + } else { + ppoCoeff[i] = readOptional(part, key); + } + } + readCoefficients(part, "AMDX", "X", amdXCoeff); + readCoefficients(part, "AMDY", "Y", amdYCoeff); + } + + /** + * The coefficients {@code 1} to {@code 19} into {@code coeff}, the first 13 + * required, as C's {@code astLoadDssMap} reads them. + */ + private static void readCoefficients(NativeNode part, String prefix, String axis, double[] coeff) { + for (int i = 0; i < NCOEFF; i++) { + String key = prefix + (i + 1); + if (i < NCOEFF_REQUIRED) { + coeff[i] = readRequired(part, key, "plate solution " + axis + " coefficient " + (i + 1)); + } else { + coeff[i] = readOptional(part, key); + } + } + } + + /** The value of a required item, or C's error if it is missing (its value read as bad). */ + private static double readRequired(NativeNode part, String key, String what) { + double value = part.readDouble(key, AST__BAD); + if (value == AST__BAD) { + throw Ast.err( + AstException.AST__RDERR, + "astRead(DssMap): '" + key + "' object (" + what + ") missing from input."); + } + return value; + } + + /** The value of an item that defaults to zero when it is missing (its value read as bad). */ + private static double readOptional(NativeNode part, String key) { + double value = part.readDouble(key, AST__BAD); + return value == AST__BAD ? 0.0 : value; + } + + /** Gives the copy its own coefficients, as C's {@code Copy} copies the WorldCoor structure. */ + @Override + void deepCopy() { + super.deepCopy(); + ppoCoeff = ppoCoeff.clone(); + amdXCoeff = amdXCoeff.clone(); + amdYCoeff = amdYCoeff.clone(); + } + + @Override + String dumpComment() { + return "DSS plate fit mapping"; + } + + /** Writes the plate solution, every value set, as C's {@code Dump} (dssmap.c) does. */ + @Override + void dump(NativeNode node) { + super.dump(node); + node.writeIsA("Mapping", "Mapping between coordinate systems"); + node.writeDouble("PltRA", true, true, plateRa, "Plate centre RA (radians)"); + node.writeDouble("PltDec", true, true, plateDec, "Plate centre Dec (radians)"); + node.writeDouble("PltScl", true, true, plateScale, "Plate scale (arcsec/mm)"); + node.writeDouble("CNPix1", true, true, xPixelOffset, "X Pixel offset (pixels)"); + node.writeDouble("CNPix2", true, true, yPixelOffset, "Y Pixel offset (pixels)"); + node.writeDouble("XPixSz", true, true, xPixelSize, "X Pixel size (microns)"); + node.writeDouble("YPixSz", true, true, yPixelSize, "Y Pixel size (microns)"); + for (int i = 0; i < NORIENT; i++) { + node.writeDouble("PPO" + (i + 1), true, true, ppoCoeff[i], "Orientation coefficients"); + } + for (int i = 0; i < NCOEFF; i++) { + node.writeDouble("AMDX" + (i + 1), true, true, amdXCoeff[i], "Plate solution X coefficients"); + } + for (int i = 0; i < NCOEFF; i++) { + node.writeDouble("AMDY" + (i + 1), true, true, amdYCoeff[i], "Plate solution Y coefficients"); + } + } + + // ------------------------------------------------------------------ + // The FITS cards of the plate solution + // ------------------------------------------------------------------ + + /** C's {@code NINT} (dssmap.c): the nearest integer, halves rounded away from zero. */ + private static int nint(double x) { + return (int) (x + (x > 0.0 ? 0.5 : -0.5)); + } + + /** The integral part of {@code x}, as C's {@code modf} gives it. */ + private static double intPart(double x) { + return x < 0.0 ? Math.ceil(x) : Math.floor(x); + } + + /** + * C's {@code BuildWcs} (dssmap.c): reads the plate solution from the DSS cards of {@code + * fits}, after SAOimage's {@code wcsinit}. The plate centre is read as hours or degrees, + * minutes and seconds, the declination negative when PLTDECSN starts with a minus sign; PPO3, + * PPO6 and the first 13 coefficients on each axis must be present, the others defaulting to + * zero. + * + * @throws AstException with status {@code AST__BDFTS} if a required card is missing + */ + private void buildWcs(FitsChan fits, String method, String cls) { + double rah = requiredCard(fits, "PLTRAH", method, cls); + double ram = requiredCard(fits, "PLTRAM", method, cls); + double ras = requiredCard(fits, "PLTRAS", method, cls); + double raHours = rah + (ram / 60.0) + (ras / 3600.0); + plateRa = AST__DD2R * 15.0 * raHours; + + String sign = fits.getFitsS("PLTDECSN"); + double dsign = sign != null && sign.startsWith("-") ? -1.0 : 1.0; + double decd = requiredCard(fits, "PLTDECD", method, cls); + double decm = requiredCard(fits, "PLTDECM", method, cls); + double decs = requiredCard(fits, "PLTDECS", method, cls); + double decDeg = dsign * (decd + (decm / 60.0) + (decs / 3600.0)); + plateDec = AST__DD2R * decDeg; + + plateScale = requiredCard(fits, "PLTSCALE", method, cls); + xPixelOffset = requiredCard(fits, "CNPIX1", method, cls); + yPixelOffset = requiredCard(fits, "CNPIX2", method, cls); + xPixelSize = requiredCard(fits, "XPIXELSZ", method, cls); + yPixelSize = requiredCard(fits, "YPIXELSZ", method, cls); + + for (int i = 0; i < NORIENT; i++) { + String name = "PPO" + (i + 1); + if (i == 2 || i == 5) { + ppoCoeff[i] = requiredCard(fits, name, method, cls); + } else { + Double v = fits.getFitsF(name); + ppoCoeff[i] = v == null ? 0.0 : v; + } + } + readCardCoefficients(fits, "AMDX", amdXCoeff, method, cls); + readCardCoefficients(fits, "AMDY", amdYCoeff, method, cls); + } + + /** The cards {@code 1} to {@code 19} into {@code coeff}, the first 13 required. */ + private static void readCardCoefficients(FitsChan fits, String prefix, double[] coeff, String method, String cls) { + for (int i = 0; i < NCOEFF; i++) { + String name = prefix + (i + 1); + if (i < NCOEFF_REQUIRED) { + coeff[i] = requiredCard(fits, name, method, cls); + } else { + Double v = fits.getFitsF(name); + coeff[i] = v == null ? 0.0 : v; + } + } + } + + /** The floating value of card {@code name}, or C's {@code BuildWcs} error if there is none. */ + private static double requiredCard(FitsChan fits, String name, String method, String cls) { + Double v = fits.getFitsF(name); + if (v == null) { + throw Ast.err( + AstException.AST__BDFTS, + method + "(" + cls + "): No value has been supplied for the FITS keyword '" + name + "'."); + } + return v; + } + + /** + * C's {@code astDssFits} (dssmap.c {@code DssFits}): a FitsChan with the DSS encoding holding + * the cards that describe this DssMap's plate solution. The plate centre is written as whole + * hours (or a sign and whole degrees) and minutes, each rounded by {@code NINT}, and seconds; + * the pixel offsets are rounded to whole pixels. + */ + FitsChan dssFits() { + FitsChan ret = new FitsChan(); + ret.setEncoding("DSS"); + + double ra = plateRa / (AST__DD2R * 15.0); + double rah = intPart(ra); + ra -= rah; + double ram = intPart(60.0 * ra); + ra = 60.0 * ra - ram; + double ras = 60.0 * ra; + ret.setFits("PLTRAH", nint(rah), "Plate centre RA", false); + ret.setFits("PLTRAM", nint(ram), " ", false); + ret.setFits("PLTRAS", ras, " ", false); + + double dec = plateDec / AST__DD2R; + if (dec < 0.0) { + dec = -dec; + ret.setFits("PLTDECSN", "-", "Plate centre DEC", false); + } else { + ret.setFits("PLTDECSN", "+", "Plate centre DEC", false); + } + double decd = intPart(dec); + dec -= decd; + double decm = intPart(60.0 * dec); + dec = 60.0 * dec - decm; + double decs = 60.0 * dec; + ret.setFits("PLTDECD", nint(decd), " ", false); + ret.setFits("PLTDECM", nint(decm), " ", false); + ret.setFits("PLTDECS", decs, " ", false); + + ret.setFits("PLTSCALE", plateScale, "Plate Scale arcsec per mm", false); + ret.setFits("CNPIX1", nint(xPixelOffset), "X corner (pixels)", false); + ret.setFits("CNPIX2", nint(yPixelOffset), "Y corner", false); + ret.setFits("XPIXELSZ", xPixelSize, "X pixel size (microns)", false); + ret.setFits("YPIXELSZ", yPixelSize, "Y pixel size (microns)", false); + + String comm = "Orientation Coefficients"; + for (int i = 0; i < NORIENT; i++) { + ret.setFits("PPO" + (i + 1), ppoCoeff[i], comm, false); + comm = " "; + } + comm = "Plate solution x coefficients"; + for (int i = 0; i < NCOEFF; i++) { + ret.setFits("AMDX" + (i + 1), amdXCoeff[i], comm, false); + comm = " "; + } + comm = "Plate solution y coefficients"; + for (int i = 0; i < NCOEFF; i++) { + ret.setFits("AMDY" + (i + 1), amdYCoeff[i], comm, false); + comm = " "; + } + return ret; + } + + // ------------------------------------------------------------------ + // Transformation + // ------------------------------------------------------------------ + + /** + * C's {@code Transform} (dssmap.c): the forward transformation gives the right ascension and + * declination ({@code platepos}, in degrees, converted to radians) of each pixel position, and + * the inverse the pixel position ({@code platepix}) of each sky position (converted to + * degrees). A point with a bad coordinate gives bad values on both axes; a coordinate that is + * not finite is bad (C tests only for {@link #AST__BAD}). {@code platepos} and {@code + * platepix} always report success, so no other point is bad. + */ + @Override + void transformInto(double[][] in, int npoint, boolean forward, double[][] out) { + validateTransformInto(in, npoint, forward, out); + double[] in0 = in[0]; + double[] in1 = in[1]; + double[] out0 = out[0]; + double[] out1 = out[1]; + double[] pos = new double[2]; + boolean fwd = effectiveForward(forward); + for (int p = 0; p < npoint; p++) { + if (isBad(in0[p]) || isBad(in1[p])) { + out0[p] = AST__BAD; + out1[p] = AST__BAD; + } else if (fwd) { + platepos(in0[p], in1[p], pos); + out0[p] = pos[0] * AST__DD2R; + out1[p] = pos[1] * AST__DD2R; + } else { + platepix(AST__DR2D * in0[p], AST__DR2D * in1[p], pos); + out0[p] = pos[0]; + out1[p] = pos[1]; + } + } + } + + /** + * SAOimage's {@code platepos} as C has it (dssmap.c): the right ascension and declination, in + * degrees, of image pixel ({@code xpix}, {@code ypix}), into {@code pos}. The magnitude and + * colour terms of the plate model (coefficients 14 to 19) are left out, and a right ascension + * below zero has two pi added. + */ + private void platepos(double xpix, double ypix, double[] pos) { + // Convert from image pixels to plate pixels. + double x = xpix + xPixelOffset - 1.0 + 0.5; + double y = ypix + yPixelOffset - 1.0 + 0.5; + + // Convert from pixels to millimetres. + double xmm = (ppoCoeff[2] - x * xPixelSize) / 1000.0; + double ymm = (y * yPixelSize - ppoCoeff[5]) / 1000.0; + double xmm2 = xmm * xmm; + double ymm2 = ymm * ymm; + double xmm3 = xmm * xmm2; + double ymm3 = ymm * ymm2; + double x2y2 = xmm2 + ymm2; + + // Compute coordinates from x, y and the plate model. + double[] ax = amdXCoeff; + double xi = ax[0] * xmm + + ax[1] * ymm + + ax[2] + + ax[3] * xmm2 + + ax[4] * xmm * ymm + + ax[5] * ymm2 + + ax[6] * x2y2 + + ax[7] * xmm3 + + ax[8] * xmm2 * ymm + + ax[9] * xmm * ymm2 + + ax[10] * ymm3 + + ax[11] * xmm * x2y2 + + ax[12] * xmm * x2y2 * x2y2; + + double[] ay = amdYCoeff; + double eta = ay[0] * ymm + + ay[1] * xmm + + ay[2] + + ay[3] * ymm2 + + ay[4] * xmm * ymm + + ay[5] * xmm2 + + ay[6] * x2y2 + + ay[7] * ymm3 + + ay[8] * ymm2 * xmm + + ay[9] * ymm * xmm2 + + ay[10] * xmm3 + + ay[11] * ymm * x2y2 + + ay[12] * ymm * x2y2 * x2y2; + + // Convert to radians. + double xir = xi / CONS2R; + double etar = eta / CONS2R; + + // Convert to RA and Dec. + double ctan = Math.tan(plateDec); + double ccos = Math.cos(plateDec); + double raoff = Math.atan2(xir / ccos, 1.0 - etar * ctan); + double ra = raoff + plateRa; + if (ra < 0.0) { + ra = ra + TWOPI; + } + pos[0] = ra / COND2R; + + double dec = Math.atan(Math.cos(raoff) / ((1.0 - (etar * ctan)) / (etar + ctan))); + pos[1] = dec / COND2R; + } + + /** + * SAOimage's {@code platepix} as C has it (dssmap.c): the image pixel position of the sky + * position ({@code xpos}, {@code ypos}), in degrees, into {@code pos}, by Newton's method on + * the plate model from the position the plate scale alone gives. The magnitude and colour + * terms are left out, and the position is not checked against the image's bounds. + */ + private void platepix(double xpos, double ypos, double[] pos) { + // Convert RA and Dec to standard coordinates on the plate. + double xr = xpos * COND2R; + double yr = ypos * COND2R; + double sypos = Math.sin(yr); + double cypos = Math.cos(yr); + double syplate = Math.sin(plateDec); + double cyplate = Math.cos(plateDec); + double sxdiff = Math.sin(xr - plateRa); + double cxdiff = Math.cos(xr - plateRa); + double div = (sypos * syplate) + (cypos * cyplate * cxdiff); + double xi = cypos * sxdiff * CONS2R / div; + double eta = ((sypos * cyplate) - (cypos * syplate * cxdiff)) * CONS2R / div; + + // Set the initial values of x and y. + double xmm = xi / plateScale; + double ymm = eta / plateScale; + + double[] ax = amdXCoeff; + double[] ay = amdYCoeff; + for (int i = 0; i < MAX_ITERATIONS; i++) { + // X plate model. + double xy = xmm * ymm; + double x2 = xmm * xmm; + double y2 = ymm * ymm; + double x2y = x2 * ymm; + double y2x = y2 * xmm; + double x2y2 = x2 + y2; + double cjunk = x2y2 * x2y2; + double x3 = x2 * xmm; + double y3 = y2 * ymm; + double x4 = x2 * x2; + double y4 = y2 * y2; + double f = ax[0] * xmm + + ax[1] * ymm + + ax[2] + + ax[3] * x2 + + ax[4] * xy + + ax[5] * y2 + + ax[6] * x2y2 + + ax[7] * x3 + + ax[8] * x2y + + ax[9] * y2x + + ax[10] * y3 + + ax[11] * xmm * x2y2 + + ax[12] * xmm * cjunk; + + // Derivative of the X model with respect to x. + double fx = ax[0] + + ax[3] * 2.0 * xmm + + ax[4] * ymm + + ax[6] * 2.0 * xmm + + ax[7] * 3.0 * x2 + + ax[8] * 2.0 * xy + + ax[9] * y2 + + ax[11] * (3.0 * x2 + y2) + + ax[12] * (5.0 * x4 + 6.0 * x2 * y2 + y4); + + // Derivative of the X model with respect to y. + double fy = ax[1] + + ax[4] * xmm + + ax[5] * 2.0 * ymm + + ax[6] * 2.0 * ymm + + ax[8] * x2 + + ax[9] * 2.0 * xy + + ax[10] * 3.0 * y2 + + ax[11] * 2.0 * xy + + ax[12] * 4.0 * xy * x2y2; + + // Y plate model. + double g = ay[0] * ymm + + ay[1] * xmm + + ay[2] + + ay[3] * y2 + + ay[4] * xy + + ay[5] * x2 + + ay[6] * x2y2 + + ay[7] * y3 + + ay[8] * y2x + + ay[9] * x2y + + ay[10] * x3 + + ay[11] * ymm * x2y2 + + ay[12] * ymm * cjunk; + + // Derivative of the Y model with respect to x. + double gx = ay[1] + + ay[4] * ymm + + ay[5] * 2.0 * xmm + + ay[6] * 2.0 * xmm + + ay[8] * y2 + + ay[9] * 2.0 * xy + + ay[10] * 3.0 * x2 + + ay[11] * 2.0 * xy + + ay[12] * 4.0 * xy * x2y2; + + // Derivative of the Y model with respect to y. + double gy = ay[0] + + ay[3] * 2.0 * ymm + + ay[4] * xmm + + ay[6] * 2.0 * ymm + + ay[7] * 3.0 * y2 + + ay[8] * 2.0 * xy + + ay[9] * x2 + + ay[11] * (x2 + 3.0 * y2) + + ay[12] * (5.0 * y4 + 6.0 * x2 * y2 + x4); + + f = f - xi; + g = g - eta; + double dx = ((-f * gy) + (g * fy)) / ((fx * gy) - (fy * gx)); + double dy = ((-g * fx) + (f * gx)) / ((fx * gy) - (fy * gx)); + xmm = xmm + dx; + ymm = ymm + dy; + if ((Math.abs(dx) < TOLERANCE) && (Math.abs(dy) < TOLERANCE)) { + break; + } + } + + // Convert mm from the plate centre to plate pixels. + double x = (ppoCoeff[2] - xmm * 1000.0) / xPixelSize; + double y = (ppoCoeff[5] + ymm * 1000.0) / yPixelSize; + + // Convert from plate pixels to image pixels. + pos[0] = x - xPixelOffset + 1.0 - 0.5; + pos[1] = y - yPixelOffset + 1.0 - 0.5; + } + + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + /** + * dssmap.c {@code Equal}: {@code that} is a DssMap with the same numbers of inputs and outputs + * and the same Invert attribute, whose pixel offsets and sizes, PPO3, PPO6, plate centre and + * first 13 coefficients on each axis are, to within {@code astEQUAL}, this one's. The plate + * scale and the other coefficients are not compared. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof DssMap)) { + return false; + } + DssMap other = (DssMap) that; + if (other.getNin() != getNin() || other.getNout() != getNout() || getInvert() != other.getInvert()) { + return false; + } + if (!(MappingHelpers.astEqual(xPixelOffset, other.xPixelOffset) + && MappingHelpers.astEqual(yPixelOffset, other.yPixelOffset) + && MappingHelpers.astEqual(ppoCoeff[2], other.ppoCoeff[2]) + && MappingHelpers.astEqual(ppoCoeff[5], other.ppoCoeff[5]) + && MappingHelpers.astEqual(xPixelSize, other.xPixelSize) + && MappingHelpers.astEqual(yPixelSize, other.yPixelSize) + && MappingHelpers.astEqual(plateDec, other.plateDec) + && MappingHelpers.astEqual(plateRa, other.plateRa))) { + return false; + } + for (int i = 0; i < NCOEFF_REQUIRED; i++) { + if (!MappingHelpers.astEqual(amdXCoeff[i], other.amdXCoeff[i]) + || !MappingHelpers.astEqual(amdYCoeff[i], other.amdYCoeff[i])) { + return false; + } + } + return true; + } + + // ------------------------------------------------------------------ + // Simplification + // ------------------------------------------------------------------ + + /** + * dssmap.c {@code MapMerge}: in series, a WinMap (exactly that class) applied to the pixel + * coordinates, before the DssMap if the list applies the DssMap forward and after it + * otherwise, folds into the pixel offsets and sizes, when its shift and scale terms on both + * axes are good and its scales non-zero, and the new pixel offsets are whole to within 0.01 of + * a pixel. The merged DssMap is made, as C makes it, from the FITS cards {@link #dssFits} + * writes with those four cards replaced, so the plate centre passes through its sexagesimal + * cards; it is applied with the Invert value of the DssMap it replaces. + * + *

As in C, the WinMap's Invert attribute is set to the value the list applies it with while + * its terms are read, and restored only when the two do not merge: when they merge, the WinMap, + * which may be shared with the Mapping being simplified, is left with the list's value + * (docs/rust-c-differences.md, "A DssMap merge leaves the WinMap's Invert attribute changed"). + */ + @Override + int mapMerge(MergeList list, int where, boolean series) { + if (!series) { + return -1; + } + int wmi = list.invert(where) ? where + 1 : where - 1; + if (wmi < 0 || wmi >= list.size() || list.map(wmi).getClass() != WinMap.class) { + return -1; + } + WinMap wm = (WinMap) list.map(wmi); + int oldWinv = wm.swapInvert(list.invert(wmi)); + boolean merged = false; + try { + merged = mergeWinMap(list, where, wmi, wm.winTerms()); + } finally { + // C annuls its pointer to the WinMap after a merge, which skips the restore. + if (!merged) { + wm.restoreInvert(oldWinv); + } + } + return merged ? Math.min(wmi, where) : -1; + } + + /** + * The part of {@link #mapMerge} after the WinMap's terms {@code terms} (shifts, scales) are + * read: merges the WinMap at {@code wmi} into the DssMap at {@code where} if C would, and + * says whether it did. + */ + private static boolean mergeWinMap(MergeList list, int where, int wmi, double[][] terms) { + double[] a = terms[0]; + double[] b = terms[1]; + if (a[0] == AST__BAD + || b[0] == AST__BAD + || b[0] == 0.0 + || a[1] == AST__BAD + || b[1] == AST__BAD + || b[1] == 0.0) { + return false; + } + + DssMap dm = (DssMap) list.map(where); + double cnpix1 = dm.xPixelOffset; + double cnpix2 = dm.yPixelOffset; + double xpixelsz = dm.xPixelSize; + double ypixelsz = dm.yPixelSize; + if (wmi == where - 1) { + xpixelsz *= b[0]; + ypixelsz *= b[1]; + cnpix1 = 0.5 + (cnpix1 + a[0] - 0.5) / b[0]; + cnpix2 = 0.5 + (cnpix2 + a[1] - 0.5) / b[1]; + } else { + xpixelsz /= b[0]; + ypixelsz /= b[1]; + cnpix1 = b[0] * (cnpix1 - 0.5) - a[0] + 0.5; + cnpix2 = b[1] * (cnpix2 - 0.5) - a[1] + 0.5; + } + + // The CNPIX1 and CNPIX2 cards are integers, so the merge is made only when the new + // values are whole to within one hundredth of a pixel. + if (Math.abs(cnpix1 - nint(cnpix1)) >= 0.01 || Math.abs(cnpix2 - nint(cnpix2)) >= 0.01) { + return false; + } + + FitsChan fits = dm.dssFits(); + boolean ok = replaceCard(fits, "CNPIX1", nint(cnpix1)); + ok = replaceCard(fits, "CNPIX2", nint(cnpix2)) && ok; + ok = replaceCard(fits, "XPIXELSZ", xpixelsz) && ok; + ok = replaceCard(fits, "YPIXELSZ", ypixelsz) && ok; + if (!ok) { + return false; + } + list.set(where, new DssMap(fits), list.invert(where)); + list.removeAt(wmi); + return true; + } + + /** + * Replaces the value of card {@code name}, searching from the first card, as C's {@code + * MapMerge} does with {@code astClearCard}, {@code astFindFits} and {@code astSetFitsI}; false + * if there is no such card. + */ + private static boolean replaceCard(FitsChan fits, String name, int value) { + fits.clear("Card"); + if (fits.findFits(name, false) == null) { + return false; + } + fits.setFits(name, value, null, true); + return true; + } + + /** {@link #replaceCard(FitsChan, String, int)} for a floating value ({@code astSetFitsF}). */ + private static boolean replaceCard(FitsChan fits, String name, double value) { + fits.clear("Card"); + if (fits.findFits(name, false) == null) { + return false; + } + fits.setFits(name, value, null, true); + return true; + } +} diff --git a/src/main/java/uk/ac/starlink/ast/FitsChan.java b/src/main/java/uk/ac/starlink/ast/FitsChan.java index 915c52f..3002c77 100644 --- a/src/main/java/uk/ac/starlink/ast/FitsChan.java +++ b/src/main/java/uk/ac/starlink/ast/FitsChan.java @@ -783,6 +783,9 @@ void setSourceFile(String name) { *

When the read fails or finds no Object, the cards it looked at are made available again, * unless the Clean attribute is set, when they are removed as after a successful read. * + *

An Object read that implements {@link NeedsChannelizing} has its {@code unChannelize} + * method called, as for a {@link Channel}. + * * @return the Object read, or null if there is none * @throws AstException as {@link Channel#read} does for the NATIVE encoding, with status {@code * AST__BADIN} also if a long string has a {@code CONTINUE} card missing; or the error of @@ -822,6 +825,7 @@ public AstObject read() { cardList.fixUsed(true, remove); } } + unChannelize(obj); return obj; } @@ -886,11 +890,19 @@ private AstObject readForeign(Encoding enc) { *

A write that writes nothing, or fails, leaves the cards and the current card as they were, * except that a card the write replaced before it failed is lost, as in C. * + *

An Object that implements {@link NeedsChannelizing} has its {@code channelize} and {@code + * unChannelize} methods called before and after it is written, as for a {@link Channel}; an + * exception either throws is passed on unchanged, although this method does not declare it, as + * jniast's FitsChan passes it on. An exception from {@code channelize} stops the write before + * anything is written. + * * @param obj the Object to write * @return the number of Objects written: 1, or 0 if the Object could not be written */ @Override public int write(AstObject obj) { + // jniast's FitsChan write (jni/FitsChan.c) channelizes the Object first. + channelize(obj); // fitschan.c Write, with astWrite's discarding of the warnings (channel.c astWrite_). clearWarnings(); readFromSource(); @@ -918,6 +930,7 @@ public int write(AstObject obj) { cardList.setPosition(card0); } } + unChannelize(obj); return ret; } @@ -1890,6 +1903,14 @@ int getIgnoreBadAlt() { return ignoreBadAlt == null ? 0 : ignoreBadAlt; } + /** + * The FitsTables a {@code -TAB} read looks for its tables in, keyed by extension name, C's + * {@code tables}, or null if none was stored. + */ + KeyMap getTables() { + return tables; + } + /** The TabOK attribute (default 0). */ int getTabOK() { return tabOk == null ? 0 : tabOk; diff --git a/src/main/java/uk/ac/starlink/ast/FitsLogMap.java b/src/main/java/uk/ac/starlink/ast/FitsLogMap.java deleted file mode 100644 index 6893417..0000000 --- a/src/main/java/uk/ac/starlink/ast/FitsLogMap.java +++ /dev/null @@ -1,42 +0,0 @@ -package uk.ac.starlink.ast; - -/** - * The MathMap C's {@code LogAxis} (fitschan.c) makes to test an axis for the {@code -LOG} - * algorithm: forward {@code logs=log(s)}, inverse {@code s=exp(logs)}, with SimpFI and SimpIF set. - * It computes what that MathMap computes, as mathmap.c's evaluator does it: the logarithm of a - * value that is not positive is bad, and so is an exponential that overflows. - * - *

A MathMap merges in simplification only with another MathMap (mathmap.c {@code MapMerge}). The - * Mappings this one meets come from FrameSets of this library, which hold no MathMap, so it never - * merges with anything; nor does C override any other Mapping method for MathMap but {@code - * Equal}, which nothing in {@code LogAxis} reaches. - */ -final class FitsLogMap extends Mapping { - - /** Constructs the Mapping, one input and one output, defined in both directions. */ - FitsLogMap() { - super(1, 1, true, true); - } - - @Override - void transformInto(double[][] in, int npoint, boolean forward, double[][] out) { - validateTransformInto(in, npoint, forward, out); - boolean fwd = effectiveForward(forward); - double[] a = in[0]; - double[] o = out[0]; - for (int p = 0; p < npoint; p++) { - double x = a[p]; - if (isBad(x)) { - o[p] = AST__BAD; - } else if (fwd) { - // mathmap.c OP_LOG: ( x > 0.0 ) ? log( x ) : AST__BAD. - o[p] = x > 0.0 ? Math.log(x) : AST__BAD; - } else { - // mathmap.c OP_EXP through CATCH_MATHS_OVERFLOW: an overflow, which only a finite - // argument reaches here, is AST__BAD. - double r = Math.exp(x); - o[p] = Double.isInfinite(r) ? AST__BAD : r; - } - } - } -} diff --git a/src/main/java/uk/ac/starlink/ast/FitsMapTab.java b/src/main/java/uk/ac/starlink/ast/FitsMapTab.java index b76e62d..9f01f9e 100644 --- a/src/main/java/uk/ac/starlink/ast/FitsMapTab.java +++ b/src/main/java/uk/ac/starlink/ast/FitsMapTab.java @@ -1,6 +1,8 @@ package uk.ac.starlink.ast; +import java.util.ArrayList; import java.util.Arrays; +import java.util.List; /** * Whether WCS axes of a pixel to WCS Mapping can be described by the {@code -TAB} algorithm of @@ -8,9 +10,9 @@ * ChangePermSplit} (fitschan.c). * *

C decides with the Mapping alone whether an axis can be tabulated, and then writes the table - * into a FitsTable. This library has neither FitsTable nor LutMap, so the decision is ported as C - * makes it, and where C would create or use a FitsTable an {@link UnsupportedOperationException} - * is thrown instead. + * into a FitsTable. This library has no FitsTable, so the decision is ported as C makes it, and + * where C would create or use a FitsTable an {@link UnsupportedOperationException} is thrown + * instead. * *

Ported from Rust {@code fitschan/fset_to_store/map_tab.rs}, following fitschan.c. */ @@ -29,9 +31,9 @@ private FitsMapTab() {} * failing that, by splitting off each input of {@code map} in turn until one feeds the output; * and failing that, by splitting the inverse again with every PermMap using its alternative * split. The output can be tabulated if exactly one grid axis feeds it and either the Mapping - * from the grid axis holds a LutMap (which no Mapping of this library does) or the number of - * pixels on the grid axis is known; C then samples the Mapping and stores the samples in a - * FitsTable. + * from the grid axis holds a LutMap applied forward in series, whose table C uses, or the + * number of pixels on the grid axis is known, when C samples the Mapping; either way C stores + * the table in a FitsTable. * *

When the inverse split gives more than one grid axis, C returns the split Mapping as it * is, with no table columns; that is kept. @@ -48,7 +50,8 @@ private FitsMapTab() {} * @param icolmain receives -1 in its first element: the main column C adds, which there is none of * @param icolindex receives -1 in its first element: the index column C adds, which there is * none of - * @param interp receives 0 in its first element: the interpolation method of a LutMap + * @param interp receives in its first element the LutInterp attribute of the LutMap whose table + * C uses, or 0 * @return C's Mapping, or null where C returns NULL (the output cannot be tabulated) * @throws UnsupportedOperationException where C would create a FitsTable to hold the table, * which needs FitsTable @@ -121,10 +124,28 @@ static Mapping isMapTab1D( // From the grid axis to the WCS axis. ret.invert(); - // C searches the Mappings in series for a non-inverted LutMap, whose table it would - // use; this library has no LutMap. Without one, C samples the Mapping when the number - // of pixels along the grid axis is known. - if (dim[ins[0]] != AST__BAD) { + // C searches the Mappings in series for a LutMap applied forward, whose table it + // uses, transformed by the Mappings after it, with the grid positions of its entries + // given by the inverse of the Mappings before it. + List maps = new ArrayList<>(); + List inverts = new ArrayList<>(); + ret.mapList(true, ret.getInvert(), maps, inverts); + int ilut = -1; + for (int imap = 0; imap < maps.size(); imap++) { + if (maps.get(imap) instanceof LutMap && !inverts.get(imap)) { + ilut = imap; + break; + } + } + if (ilut >= 0) { + interp[0] = ((LutMap) maps.get(ilut)).getLutInterp(); + // C combines the Mappings either side of the LutMap and takes its table, which are + // used only to fill the FitsTable it makes next. + throw new UnsupportedOperationException("IsMapTab1D(FitsChan): the look-up table for FITS-WCS axis " + + (iwcs + 1) + " (unit '" + colunit + "') needs FitsTable"); + } else if (dim[ins[0]] != AST__BAD) { + // Without a LutMap, C samples the Mapping, the number of pixels along the grid + // axis being known. double[] x = {1.0, dim[ins[0]]}; double[] v = ret.tran1(2, x, true); double[][] work = {{x[0]}, {v[0]}}; diff --git a/src/main/java/uk/ac/starlink/ast/FitsOtherAxes.java b/src/main/java/uk/ac/starlink/ast/FitsOtherAxes.java index 610d4ef..7294906 100644 --- a/src/main/java/uk/ac/starlink/ast/FitsOtherAxes.java +++ b/src/main/java/uk/ac/starlink/ast/FitsOtherAxes.java @@ -9,9 +9,8 @@ * algorithm, or, when TabOK is positive, with the {@code -TAB} algorithm; ForceTab passes over the * first two. An axis none of them describes is given the linear description, which makes the * pixel to intermediate world Mapping non-linear, so that {@link FitsMakeIntWorld#makeIntWorld} - * rejects it. The {@code -LOG} description needs a MathMap and the {@code -TAB} description a - * FitsTable, neither of which this library has, so where C would make one an {@link - * UnsupportedOperationException} is thrown. + * rejects it. The {@code -TAB} description needs a FitsTable, which this library does not have, + * so where C would make one an {@link UnsupportedOperationException} is thrown. * *

Ported from Rust {@code fitschan/fset_to_store/other_axes.rs} and {@code log_axis.rs}, * following fitschan.c. @@ -49,10 +48,8 @@ private FitsOtherAxes() {} * @param method the calling method, for messages * @param cls the class of the object written, for messages * @return the Mapping from the current Frame to intermediate world coordinates - * @throws UnsupportedOperationException where C would describe an axis with the {@code -LOG} - * algorithm (an axis that is not linear but whose logarithm is, with a CRVAL other than - * zero, and ForceTab not set), which needs MathMap, or with the {@code -TAB} algorithm, - * which needs FitsTable + * @throws UnsupportedOperationException where C would describe an axis with the {@code -TAB} + * algorithm, which needs FitsTable */ static Mapping otherAxes( FitsChan fc, @@ -176,23 +173,27 @@ static Mapping otherAxes( * output is logarithmic in the pixel coordinates over the box from {@code lbndP} to {@code * ubndP}, or null if it is not or {@code crval} is zero. * - *

As C does, the output is logarithmic if its logarithm, computed by the MathMap C makes - * here ({@link FitsLogMap}), is linear by {@link FitsIsMapLinear#isMapLinear}. + *

As C does, the output is logarithmic if its logarithm, computed by the MathMap {@code + * logs=log(s)} (inverse {@code s=exp(logs)}, SimpFI and SimpIF set), is linear by {@link + * FitsIsMapLinear#isMapLinear}. The Mapping returned is {@code w = Sr log(S/Sr)} with {@code + * Sr} the CRVAL: a ZoomMap by {@code 1/Sr}, the same MathMap and a ZoomMap by {@code Sr} in + * series, with UnitMaps in parallel for the other {@code nwcs - 1} axes. * * @return null if {@code crval} is zero or the output is not logarithmic - * @throws UnsupportedOperationException if the output is logarithmic, where C makes the {@code - * -LOG} Mapping, which holds that MathMap, so needs MathMap */ static Mapping logAxis(Mapping map, int iax, int nwcs, double[] lbndP, double[] ubndP, double crval) { if (crval == 0.0) { return null; } - Mapping tmap0 = new CmpMap(map, addUnitMaps(new FitsLogMap(), iax, nwcs), true); + MathMap tmap1 = new MathMap(1, 1, new String[] {"logs=log(s)"}, new String[] {"s=exp(logs)"}); + tmap1.set("simpfi=1,simpif=1"); + Mapping tmap0 = new CmpMap(map, addUnitMaps(tmap1, iax, nwcs), true); if (!FitsIsMapLinear.isMapLinear(tmap0, lbndP, ubndP, iax, null)) { return null; } - throw new UnsupportedOperationException( - "LogAxis(FitsChan): the -LOG description of world axis " + (iax + 1) + " needs MathMap"); + Mapping tmap3 = new CmpMap(new ZoomMap(1, 1.0 / crval), tmap1, true); + Mapping tmap4 = new CmpMap(tmap3, new ZoomMap(1, crval), true); + return addUnitMaps(tmap4, iax, nwcs); } /** diff --git a/src/main/java/uk/ac/starlink/ast/FitsSpectralAxes.java b/src/main/java/uk/ac/starlink/ast/FitsSpectralAxes.java index 4e52088..bf3192d 100644 --- a/src/main/java/uk/ac/starlink/ast/FitsSpectralAxes.java +++ b/src/main/java/uk/ac/starlink/ast/FitsSpectralAxes.java @@ -15,11 +15,10 @@ * *

C tries the {@code -X2P} and grism algorithms by setting the System and Unit of the axis * through the FrameSet, which remaps the current Frame, and setting them back, so the FrameSet is - * remapped as C remaps it. The {@code -LOG} description holds a MathMap and the {@code -TAB} - * description a FitsTable, which this library does not have; where C makes one, an {@link - * UnsupportedOperationException} is thrown. C's grism algorithm extracts a GrismMap from the - * pixel to wavelength Mapping; a FrameSet of this library's classes holds none, so it finds none, - * as C finds none in such a FrameSet. + * remapped as C remaps it. The {@code -TAB} description holds a FitsTable, which this library + * does not have; where C makes one, an {@link UnsupportedOperationException} is thrown. The grism + * algorithm extracts the GrismMap from the end of the pixel to wavelength Mapping ({@link + * #extractGrismMap}). * *

Ported from Rust {@code fitschan/fset_to_store/spectral_axes.rs}, following fitschan.c, whose * structure is kept where Rust's follows from its ownership rules: the FrameSet is changed in place @@ -29,6 +28,9 @@ final class FitsSpectralAxes { private static final double AST__BAD = AstObject.AST__BAD; + /** C's {@code AST__DR2D}: radians to degrees. */ + private static final double AST__DR2D = 57.29577951308232; + /** The speed of light in m/s, C's {@code AST__C}. */ private static final double AST__C = 2.99792458E8; @@ -68,8 +70,8 @@ private FitsSpectralAxes() {} * @param method the calling method, for messages * @param cls the class of the object written, for messages * @return the Mapping from the current Frame to intermediate world coordinates - * @throws UnsupportedOperationException where C describes an axis with the {@code -LOG} - * algorithm, which needs MathMap, or with the {@code -TAB} algorithm, which needs FitsTable + * @throws UnsupportedOperationException where C describes an axis with the {@code -TAB} + * algorithm, which needs FitsTable */ static Mapping spectralAxes( FitsChan fc, @@ -212,12 +214,53 @@ static Mapping spectralAxes( } } - // The grism algorithm, tried with the axis as vacuum and as air wavelength in m. - // C looks for a GrismMap producing the axis in the simplified pixel to wavelength - // Mapping (ExtractGrismMap); a FrameSet of this library's classes holds none. + // The grism algorithm, tried with the axis as vacuum and as air wavelength in m: + // the simplified pixel to wavelength Mapping must end in a GrismMap producing the + // axis (simplifying merges a ZoomMap that follows it into it), the rest of it + // linear on the axis. for (int ix = 0; ix < 2 && ctype == null; ix++) { fs.setC(systemAttr, ix == 0 ? "WAVE" : "AWAV"); fs.setC(unitAttr, "m"); + Mapping wmap = fs.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT) + .simplify(); + Mapping[] sansGrism = new Mapping[1]; + GrismMap gmap = extractGrismMap(wmap, iax, sansGrism); + if (gmap != null && FitsIsMapLinear.isMapLinear(sansGrism[0], lbndP, ubndP, iax, null)) { + // The reference value is the reference wavelength in m until it is + // converted to S below, as in C. + crval = gmap.getGrismWaveRValue(); + SpecFrame tfrm1 = (SpecFrame) specfrm.copy(); + fs.setC(systemAttr, origSystem); + fs.setC(unitAttr, linUnit); + FrameSet tfs1 = specfrm.convert(tfrm1, ""); + if (tfs1 != null) { + Mapping tmap3 = tfs1.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT); + crval = tmap3.tran1(1, new double[] {crval}, false)[0]; + + // From S to wavelength to the grism parameter: its value and rate + // of change with S at the reference point. + gmap.invert(); + Mapping tmap4 = new CmpMap(tmap3, gmap, true); + double gval = tmap4.tran1(1, new double[] {crval}, true)[0]; + double dgbyds = tmap4.rate(new double[] {crval}, 1, 1); + + // FITS-WCS paper III makes dS/dw unity at the reference point, so + // the grism parameter is dgbyds * w + gval. + Mapping tmap6 = new CmpMap(new ZoomMap(1, dgbyds), new ShiftMap(new double[] {gval}), true); + tmap6.invert(); + axmap = FitsOtherAxes.addUnitMaps(new CmpMap(tmap4, tmap6, true), iax, nwcs); + ctype = withCode(origSystem, ix == 0 ? "-GRI" : "-GRA"); + + // The parameters that differ from FITS-WCS paper III's defaults. + storeGrismPv(store, fitsI, 0, gmap.getGrismGValue(), 0.0, 1.0); + storeGrismPv(store, fitsI, 1, gmap.getGrismMValue(), 0.0, 1.0); + storeGrismPv(store, fitsI, 2, gmap.getGrismAlphaValue(), 0.0, AST__DR2D); + storeGrismPv(store, fitsI, 3, gmap.getGrismNRValue(), 1.0, 1.0); + storeGrismPv(store, fitsI, 4, gmap.getGrismNRPValue(), 0.0, 1.0); + storeGrismPv(store, fitsI, 5, gmap.getGrismEpsValue(), 0.0, AST__DR2D); + storeGrismPv(store, fitsI, 6, gmap.getGrismThetaValue(), 0.0, AST__DR2D); + } + } fs.setC(systemAttr, origSystem); fs.setC(unitAttr, linUnit); } @@ -331,6 +374,75 @@ static Mapping spectralAxes( return ret != null ? ret.simplify() : new UnitMap(nwcs); } + /** + * Sets PVi_m of the zero-based FITS axis {@code fitsI} to {@code value * scale}, unless {@code + * value} is {@code dflt}, FITS-WCS paper III's default for the grism parameter, as C's {@code + * SpectralAxes} does. + */ + private static void storeGrismPv(FitsStore store, int fitsI, int m, double value, double dflt, double scale) { + if (value != dflt) { + store.setPv(fitsI, m, value * scale); + } + } + + /** + * C's {@code ExtractGrismMap} (fitschan.c): the GrismMap, not inverted, that produces output + * {@code iax} (zero-based) of {@code map} directly, its output not changed by any Mapping + * after it; or null if there is none. A GrismMap is found in {@code map} itself or, within a + * CmpMap, in the second component of a series CmpMap or the component of a parallel CmpMap + * producing the output, each component set for the duration to the Invert value it had when + * the CmpMap was made, as C sets it, and set back to the value it had afterwards. The GrismMap + * is shared, not copied, as C clones it. + * + * @param newMap receives the Mapping {@code map} is with the GrismMap replaced by a UnitMap, + * sharing its other parts, or null if there is no GrismMap + */ + static GrismMap extractGrismMap(Mapping map, int iax, Mapping[] newMap) { + GrismMap ret = null; + newMap[0] = null; + if (map instanceof GrismMap) { + if (!map.getInvert()) { + ret = (GrismMap) map; + ret.markShared(); + newMap[0] = new UnitMap(1); + } + } else if (map instanceof CmpMap) { + boolean[] series = new boolean[1]; + boolean[] inverts = new boolean[2]; + Mapping[] parts = map.decompose(series, inverts); + Mapping mapa = parts[0]; + Mapping mapb = parts[1]; + boolean oldInva = mapa.getInvert(); + boolean oldInvb = mapb.getInvert(); + mapa.setInvert(inverts[0]); + mapb.setInvert(inverts[1]); + try { + Mapping[] newMapa = {null}; + Mapping[] newMapb = {null}; + if (series[0]) { + ret = extractGrismMap(mapb, iax, newMapb); + newMapa[0] = mapa; + } else { + int na = mapa.getNout(); + if (iax < na) { + ret = extractGrismMap(mapa, iax, newMapa); + newMapb[0] = mapb; + } else { + ret = extractGrismMap(mapb, iax - na, newMapb); + newMapa[0] = mapa; + } + } + if (ret != null) { + newMap[0] = new CmpMap(newMapa[0], newMapb[0], series[0]); + } + } finally { + mapa.setInvert(oldInva); + mapb.setInvert(oldInvb); + } + } + return ret; + } + /** * The CTYPE C makes for an algorithm: {@code code} in place of everything from the fifth * character of the System {@code system} on, as C's {@code strcpy( ctype + 4, code )} does diff --git a/src/main/java/uk/ac/starlink/ast/FitsWcsCelestial.java b/src/main/java/uk/ac/starlink/ast/FitsWcsCelestial.java index 7d4bacd..b62ce20 100644 --- a/src/main/java/uk/ac/starlink/ast/FitsWcsCelestial.java +++ b/src/main/java/uk/ac/starlink/ast/FitsWcsCelestial.java @@ -301,7 +301,7 @@ private static CelestialAxes findCelestialAxes(FitsStore store, char s, FitsWarn * them, so those raised before an error are kept. * *

Rust's {@code tab} argument (the look-up of {@code -TAB} axes) is not taken: with TabOK - * above zero a {@code -TAB} axis needs LutMap and the read stops before this is reached, and + * above zero a {@code -TAB} axis needs a table and the read stops before this is reached, and * otherwise there is no look-up, so C's {@code tabmap} is always null here, and neither its * projectionless {@code AST__WCSBAD} axes nor its modification of the look-up arise. * diff --git a/src/main/java/uk/ac/starlink/ast/FitsWcsRead.java b/src/main/java/uk/ac/starlink/ast/FitsWcsRead.java index 1c901f7..7637e11 100644 --- a/src/main/java/uk/ac/starlink/ast/FitsWcsRead.java +++ b/src/main/java/uk/ac/starlink/ast/FitsWcsRead.java @@ -19,9 +19,9 @@ * to intermediate world coordinate Mapping, then one Mapping over every axis for each class of * axis (celestial, spectral, the others) and any {@code -TAB} look-ups, all in series. * - *

Spectral axes are described by {@link FitsWcsSpectral}. The Mappings of {@code -TAB} axes when - * TabOK is above zero (LutMap), of {@code -LOG} axes (MathMap) and of grism axes (GrismMap) are - * not available: a header using them makes the read throw {@link UnsupportedOperationException}. + *

Spectral axes are described by {@link FitsWcsSpectral}, grism axes with a GrismMap. A {@code + * -TAB} axis when TabOK is above zero needs a table, + * which a FitsChan here holds only when read from a dump (see {@link #tabMapping}). * *

Ported from Rust {@code fitschan/wcs_read.rs} and the FITS-WCS branch of {@code * fitschan/mod.rs}'s {@code read}. @@ -51,7 +51,7 @@ private FitsWcsRead() {} * * @throws AstException as C's read reports it * @throws UnsupportedOperationException if the header has a {@code -TAB} axis with TabOK above - * zero, a {@code -LOG} axis with a non-zero CRVAL, or a {@code -GRI} or {@code -GRA} axis + * zero whose table the FitsChan holds, or a {@code -GRI} or {@code -GRA} axis */ static FrameSet read(FitsChan fc, FitsChan.Encoding encoding) { FitsCardList cards = fc.cards(); @@ -109,14 +109,7 @@ static FrameSet readDss(FitsChan fc) { FrameSet decoded; try { decoded = decodeWcsWithAltsInner( - stores, - fc.getDefB1950(), - fc.getIgnoreBadAlt() != 0, - fc.getIwc(), - cards, - fc.getTabOK(), - readWarnings, - cursors); + stores, fc.getDefB1950(), fc.getIgnoreBadAlt() != 0, fc.getIwc(), cards, fc, readWarnings, cursors); } catch (AstException e) { pushReadWarnings(fc, readWarnings, cursors, entry); throw e; @@ -154,7 +147,7 @@ private static FrameSet decodeWcsStores( st.carLin = carLin; } return decodeWcsWithAltsInner( - stores, defB1950, fc.getIgnoreBadAlt() != 0, fc.getIwc(), fc.cards(), fc.getTabOK(), warnings, cursors); + stores, defB1950, fc.getIgnoreBadAlt() != 0, fc.getIwc(), fc.cards(), fc, warnings, cursors); } /** @@ -380,7 +373,7 @@ private static final class MapFrm { * axes}}, which decide where C writes those warnings. * * @param cards the FitsChan's own cards, from which C reads RFVAL and NAXIS - * @param tabOk the FitsChan's TabOK attribute + * @param fc the FitsChan, whose TabOK attribute and tables the {@code -TAB} look-ups use * @return the FrameSet, or null with no pixel axes, when C's {@code FsetFromStore} makes * nothing */ @@ -390,7 +383,7 @@ static FrameSet decodeWcsWithAltsInner( boolean ignoreBadAlt, boolean iwc, FitsCardList cards, - int tabOk, + FitsChan fc, FitsWarnings warnings, List cursors) { int npix = stores.npix; @@ -401,7 +394,7 @@ static FrameSet decodeWcsWithAltsInner( int pixel = ret.getCurrent(); if (stores.primary != null) { cursors.add(new int[] {warnings.size(), stores.primary.naxis}); - MapFrm mf = wcsMapFrm(stores.primary, defB1950, iwc, cards, ' ', tabOk, warnings, cursors); + MapFrm mf = wcsMapFrm(stores.primary, defB1950, iwc, cards, ' ', fc, warnings, cursors); addFrame(ret, pixel, npix, mf); } int physical = ret.getCurrent(); @@ -411,7 +404,7 @@ static FrameSet decodeWcsWithAltsInner( cursors.add(new int[] {warnings.size(), alt.naxis}); MapFrm mf; try { - mf = wcsMapFrm(alt, defB1950, iwc, cards, letter, tabOk, warnings, cursors); + mf = wcsMapFrm(alt, defB1950, iwc, cards, letter, fc, warnings, cursors); } catch (AstException e) { if (!ignoreBadAlt) { throw e; @@ -441,10 +434,10 @@ static FrameSet decodeWcsInner( boolean iwc, FitsCardList cards, char s, - int tabOk, + FitsChan fc, FitsWarnings warnings, List cursors) { - MapFrm mf = wcsMapFrm(store, defB1950, iwc, cards, s, tabOk, warnings, cursors); + MapFrm mf = wcsMapFrm(store, defB1950, iwc, cards, s, fc, warnings, cursors); FrameSet fs = new FrameSet(pixelFrame(npix)); addFrame(fs, 1, npix, mf); fs.setBase(1); @@ -469,11 +462,11 @@ private static MapFrm wcsMapFrm( boolean iwc, FitsCardList cards, char s, - int tabOk, + FitsChan fc, FitsWarnings warnings, List cursors) { FitsStore store = store0.copy(); - tabMapping(store, tabOk); + tabMapping(fc, store, s); Mapping map1 = FitsWcsMatrix.buildPixelToIwc(store, cards, warnings, cursors); FitsWcsCelestial.CelestialResult celestial = FitsWcsCelestial.buildCelestialWithDefB1950( store, s, defB1950, readRfval(cards, store.naxis, s), warnings); @@ -525,26 +518,65 @@ private static Double[] readRfval(FitsCardList cards, int naxis, char s) { } /** - * C's {@code TabMapping} (fitschan.c:33898), which makes the look-up Mapping of every {@code - * -TAB} axis when TabOK is above zero; with TabOK at most zero it makes none, a non-spectral - * {@code -TAB} axis is read as linear, and a spectral one is refused by {@code WcsSpectral}. + * C's {@code TabMapping} (fitschan.c), which makes the look-up Mapping of every {@code -TAB} + * axis of axis description {@code s} when the TabOK attribute of {@code fc} is above zero; with + * TabOK at most zero it makes none, a non-spectral {@code -TAB} axis is read as linear, and a + * spectral one is refused by {@code WcsSpectral}. + * + *

For the first {@code -TAB} axis C reads the name of the extension holding its table + * (PS{@code i}_0, which has no default), the extension version and level (PV{@code i}_1 and + * PV{@code i}_2, default 1), and fetches the table ({@code GetNamedTable}). The table's columns + * then give the LutMaps of the look-up. No table source can be registered with a FitsChan here, + * as jniast offers none, so the table is one the FitsChan holds. * - * @throws UnsupportedOperationException for a {@code -TAB} axis with TabOK above zero, whose - * look-up needs LutMap + * @throws AstException with status {@code AST__NOFTS} if PS{@code i}_0 is not given, or + * {@code AST__NOTAB} if the FitsChan holds no table of that name + * @throws UnsupportedOperationException if the FitsChan holds a table of that name, whose use + * needs FitsTable */ - private static void tabMapping(FitsStore store, int tabOk) { - if (tabOk <= 0) { + private static void tabMapping(FitsChan fc, FitsStore store, char s) { + if (fc.getTabOK() <= 0) { return; } + // store.naxis is C's wcsaxes here: WCSAXES, or the number of pixel axes without it. for (int iaxis = 0; iaxis < store.naxis; iaxis++) { String ctype = store.ctype[iaxis]; if (ctype != null && ctype.length() > 4 && ctype.startsWith("-TAB", 4)) { - throw new UnsupportedOperationException( - "FitsChan: the -TAB axis " + (iaxis + 1) + " (CTYPE '" + ctype + "') needs LutMap"); + String extname = store.ps[iaxis][0]; + if (extname == null) { + throw Ast.err( + AstException.AST__NOFTS, + METHOD + "(" + fc.astClass() + "): No value can be found for PS" + (iaxis + 1) + "_0" + s + + "."); + } + Double dval = store.pv[iaxis][1]; + int extver = dval != null ? (int) (double) dval : 1; + dval = store.pv[iaxis][2]; + int extlevel = dval != null ? (int) (double) dval : 1; + namedTable(fc, extname, extver, extlevel); } } } + /** + * C's {@code GetNamedTable} (fitschan.c) with errors reported: the table the FitsChan holds + * under {@code extname}. + * + * @throws AstException with status {@code AST__NOTAB} if there is none + * @throws UnsupportedOperationException if there is one, whose use needs FitsTable + */ + private static void namedTable(FitsChan fc, String extname, int extver, int extlevel) { + KeyMap tables = fc.getTables(); + if (tables == null || !tables.mapHasKey(extname)) { + throw Ast.err( + AstException.AST__NOTAB, + METHOD + "(" + fc.astClass() + "): Failed to read FITS binary table from extension '" + extname + + "' (extver=" + extver + ", extlevel=" + extlevel + ")."); + } + throw new UnsupportedOperationException( + "FitsChan: the -TAB table in extension '" + extname + "' needs FitsTable"); + } + /** * The pixel Frame of a FITS-WCS read, with {@code npix} axes: Title "Pixel Coordinates", * Domain GRID and each axis labelled "Pixel axis n" (fitschan.c:12183-12187). @@ -655,25 +687,18 @@ private static boolean[] claimedAxes(FitsStore store, FitsWcsCelestial.Celestial } /** - * The IWC to WCS Mapping C's {@code WcsOthers} makes for an axis no other stage describes - * (fitschan.c:39355-39368): {@code LogWcs} for a CTYPE ending in {@code -LOG}, and otherwise - * {@code LinearWcs}, a ShiftMap adding CRVAL, or a UnitMap when CRVAL is zero or absent. A - * {@code -LOG} axis with a zero CRVAL has no logarithmic form, and {@code WcsOthers} gives it - * a UnitMap. - * - * @throws UnsupportedOperationException for a {@code -LOG} axis with a non-zero CRVAL, whose - * Mapping needs MathMap + * The IWC to WCS Mapping C's {@code WcsOthers} makes for an axis no other stage describes: + * {@code LogWcs} ({@link FitsWcsSpectral#logWcs}) for a CTYPE ending in {@code -LOG}, or a + * UnitMap when CRVAL is zero, which has no logarithmic form; and otherwise {@code LinearWcs}, + * a ShiftMap adding CRVAL, or a UnitMap when CRVAL is zero or absent. */ private static Mapping othersAxisMap(FitsStore store, int axis) { - double crval = store.crval[axis] != null ? store.crval[axis] : 0.0; String ctype = store.ctype[axis] != null ? store.ctype[axis] : "AXIS" + (axis + 1); if (ctype.length() > 3 && ctype.endsWith("-LOG")) { - if (crval != 0.0) { - throw new UnsupportedOperationException( - "FitsChan: the logarithmic axis " + (axis + 1) + " (CTYPE '" + ctype + "') needs MathMap"); - } - return new UnitMap(1); + Mapping map1 = FitsWcsSpectral.logWcs(store, axis); + return map1 != null ? map1 : new UnitMap(1); } + double crval = store.crval[axis] != null ? store.crval[axis] : 0.0; return crval != 0.0 ? new ShiftMap(new double[] {crval}) : new UnitMap(1); } diff --git a/src/main/java/uk/ac/starlink/ast/FitsWcsSpectral.java b/src/main/java/uk/ac/starlink/ast/FitsWcsSpectral.java index ecb457a..5de1d08 100644 --- a/src/main/java/uk/ac/starlink/ast/FitsWcsSpectral.java +++ b/src/main/java/uk/ac/starlink/ast/FitsWcsSpectral.java @@ -13,9 +13,9 @@ * RESTFRQ or RESTWAV, the observer's position from OBSGEO-X/Y/Z, the source velocity from SSYSSRC * and ZSOURCE, its standard of rest from SPECSYS and its Label from CNAME, in C's order. The * Mapping depends on the algorithm code: a linear axis adds CRVAL, a {@code -X2P} axis (C's {@code - * NonLinSpecWcs}) is linear in the system X and converted to the axis's own system, and the - * {@code -LOG} and {@code -GRI}/{@code -GRA} axes need MathMap and GrismMap, which are not - * available. + * NonLinSpecWcs}) is linear in the system X and converted to the axis's own system, a {@code + * -LOG} axis is exponential in the intermediate world coordinate (C's {@code LogWcs}), and a + * {@code -GRI} or {@code -GRA} axis is described by a GrismMap (C's {@code GrismSpecWcs}). * *

Ported from Rust {@code fitschan/wcs_spectral.rs}, following C's {@code WcsSpectral}, {@code * NonLinSpecWcs}, {@code GrismSpecWcs}, {@code LogWcs} and {@code DSBSetUp} (fitschan.c) where @@ -29,6 +29,12 @@ final class FitsWcsSpectral { /** The class C's read reports errors for. */ private static final String CLASS = "FitsChan"; + /** C's {@code AST__DD2R}: degrees to radians. */ + private static final double AST__DD2R = 0.017453292519943295; + + /** {@code AST__DBL_DIG}, the significant digits with which C writes a constant into a function. */ + private static final int DBL_DIG = 17; + private FitsWcsSpectral() {} /** What {@link #wcsSpectral} makes: the Mapping over every axis, and the Frame describing them. */ @@ -73,9 +79,6 @@ static boolean[] spectralAxes(FitsStore store) { * spectral, and the Frame * @throws AstException with status {@code AST__BDFTS} for an algorithm code that cannot be * implemented, as C reports it, or as the attribute settings report a bad keyword value - * @throws UnsupportedOperationException for a {@code -LOG} axis with a non-zero CRVAL, whose - * Mapping needs MathMap, or a {@code -GRI} or {@code -GRA} axis, whose Mapping needs - * GrismMap */ static Result wcsSpectral( FitsStore store, @@ -98,11 +101,11 @@ static Result wcsSpectral( if (algcode.isEmpty()) { map1 = linearWcs(store, i); } else if ("-LOG".equals(algcode)) { - map1 = logWcs(store, i, ctype); + map1 = logWcs(store, i); } else if (algcode.charAt(0) == '-' && algcode.length() > 2 && algcode.charAt(2) == '2') { map1 = nonLinSpecWcs(algcode, store, i, specfrm, warnings); } else if ("-GRI".equals(algcode) || "-GRA".equals(algcode)) { - map1 = grismSpecWcs(algcode, i, specfrm, ctype); + map1 = grismSpecWcs(algcode, store, i, specfrm); } else { // An algorithm code C does not know, which it reports below. map1 = null; @@ -318,20 +321,23 @@ private static Mapping linearWcs(FitsStore store, int i) { } /** - * C's {@code LogWcs} (fitschan.c:20904) for a spectral axis: a MathMap {@code S = Sr*exp(w/Sr)} - * with {@code Sr} the CRVAL, or null when CRVAL is zero or absent, which has no logarithmic - * form. + * C's {@code LogWcs} (fitschan.c): the Mapping from the intermediate world coordinate {@code w} + * of axis {@code i} to the logarithmic axis {@code S = Sr*exp(w/Sr)}, with {@code Sr} the + * CRVAL; a MathMap with the functions {@code s=Sr*exp(w/Sr)} and {@code w=Sr*log(s/Sr)}, + * {@code Sr} written with C's {@code %.17g} ({@code AST__DBL_DIG}), and SimpFI and SimpIF set. * - * @throws UnsupportedOperationException when CRVAL is not zero, since the MathMap is not - * available + * @return the MathMap, or null when CRVAL is zero or absent, which has no logarithmic form */ - private static Mapping logWcs(FitsStore store, int i, String ctype) { + static Mapping logWcs(FitsStore store, int i) { double crv = store.crval[i] != null ? store.crval[i] : 0.0; - if (crv != 0.0) { - throw new UnsupportedOperationException( - "FitsChan: the -LOG spectral axis " + (i + 1) + " (CTYPE '" + ctype + "') needs MathMap"); + if (crv == 0.0) { + return null; } - return null; + String sr = CFormat.format("%." + DBL_DIG + "g", crv); + MathMap ret = new MathMap( + 1, 1, new String[] {"s=" + sr + "*exp(w/" + sr + ")"}, new String[] {"w=" + sr + "*log(s/" + sr + ")"}); + ret.set("simpfi=1,simpif=1"); + return ret; } /** @@ -436,14 +442,19 @@ private static char requiredP(SpecFrame specfrm) { /** * C's {@code GrismSpecWcs} (fitschan.c:14424) for a {@code -GRI} (vacuum) or {@code -GRA} (air - * wavelength) axis: the Mapping is built from the conversion of the SpecFrame to wavelength in - * metres and a GrismMap. + * wavelength) axis {@code i}: the Mapping from the intermediate world coordinate {@code w} to + * the axis's system S. A GrismMap takes its GrismG, GrismM (rounded to the nearest integer), + * GrismAlpha, GrismNR, GrismNRP, GrismEps and GrismTheta from PVi_0 to PVi_6 (the angles in + * degrees), each absent one taking the default FITS-WCS paper III gives it, and its GrismWaveR + * from CRVAL (zero when absent) converted to the wavelength in metres. Inverted, after the + * conversion from S to that wavelength, it gives the grism parameter of S; {@code w} is the + * grism parameter less its value at CRVAL, divided by its rate of change with S there, so that + * S changes at unit rate with {@code w} at the reference point. * - * @return null when there is no conversion from the SpecFrame to wavelength - * @throws UnsupportedOperationException when there is one, since the GrismMap is not - * available + * @return null when the SpecFrame does not convert to the wavelength, or the rate of change is + * bad or zero */ - private static Mapping grismSpecWcs(String algcode, int i, SpecFrame specfrm, String ctype) { + private static Mapping grismSpecWcs(String algcode, FitsStore store, int i, SpecFrame specfrm) { SpecFrame wfrm = (SpecFrame) specfrm.copy(); wfrm.setSystemValue("-GRI".equals(algcode) ? SpecFrame.AST__WAVELEN : SpecFrame.AST__AIRWAVE); wfrm.setUnit(1, "m"); @@ -451,7 +462,43 @@ private static Mapping grismSpecWcs(String algcode, int i, SpecFrame specfrm, St if (fs == null) { return null; } - throw new UnsupportedOperationException( - "FitsChan: the " + algcode + " spectral axis " + (i + 1) + " (CTYPE '" + ctype + "') needs GrismMap"); + Mapping smap = fs.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT); + double crv = store.crval[i] != null ? store.crval[i] : 0.0; + double wcrv = smap.tran1(1, new double[] {crv}, true)[0]; + + GrismMap gmap = new GrismMap(); + Double pv = pvItem(store, i, 0); + gmap.setGrismGValue(pv != null ? pv : 0.0); + pv = pvItem(store, i, 1); + gmap.setGrismMValue(pv != null ? (int) FitsMakeIntWorld.roundHalfAway(pv) : 0); + pv = pvItem(store, i, 2); + gmap.setGrismAlphaValue(pv != null ? pv * AST__DD2R : 0.0); + pv = pvItem(store, i, 3); + gmap.setGrismNRValue(pv != null ? pv : 1.0); + pv = pvItem(store, i, 4); + gmap.setGrismNRPValue(pv != null ? pv : 0.0); + pv = pvItem(store, i, 5); + gmap.setGrismEpsValue(pv != null ? pv * AST__DD2R : 0.0); + pv = pvItem(store, i, 6); + gmap.setGrismThetaValue(pv != null ? pv * AST__DD2R : 0.0); + gmap.setGrismWaveRValue(wcrv); + + // From S to wavelength to the grism parameter. + gmap.invert(); + Mapping map1 = new CmpMap(smap, gmap, true); + double gcrv = gmap.tran1(1, new double[] {wcrv}, true)[0]; + double dg = map1.rate(new double[] {crv}, 1, 1); + if (dg == AstObject.AST__BAD || dg == 0.0) { + return null; + } + // From w to the grism parameter, then back to S. + Mapping map2 = new CmpMap(new ZoomMap(1, dg), new ShiftMap(new double[] {gcrv}), true); + map1.invert(); + return new CmpMap(map2, map1, true); + } + + /** C's {@code GetItem( &(store->pv), i, m, ... )}: PVi_m of the zero-based axis {@code i}, or null. */ + private static Double pvItem(FitsStore store, int i, int m) { + return m < store.pv[i].length ? store.pv[i][m] : null; } } diff --git a/src/main/java/uk/ac/starlink/ast/FluxFrame.java b/src/main/java/uk/ac/starlink/ast/FluxFrame.java index c589f57..8a0be4d 100644 --- a/src/main/java/uk/ac/starlink/ast/FluxFrame.java +++ b/src/main/java/uk/ac/starlink/ast/FluxFrame.java @@ -315,12 +315,10 @@ String getDensityUnit() { /** * Whether values in units {@code from} can be converted to units {@code to}, as C finds by - * asking {@code astUnitMapper} for the Mapping. The conversion is found without making the - * Mapping, which for some units, such as logarithmic ones, needs a class this library does - * not have. + * asking {@code astUnitMapper} for the Mapping. */ private static boolean unitsConvert(String from, String to) { - return Units.relabel(from, to, null) != null; + return Units.unitMapper(from, to) != null; } /** @@ -544,7 +542,8 @@ public String getLabel(int axis) { int system = systemValue(); String result = capitalised(system); if (testUnit(axis)) { - Units.LabelledMapping lm = Units.relabel(defUnit(system, "astGetLabel", astClass()), getUnit(axis), result); + Units.LabelledMapping lm = + Units.unitMapperLabel(defUnit(system, "astGetLabel", astClass()), getUnit(axis), result); if (lm != null && lm.label != null) { result = lm.label; } @@ -585,7 +584,7 @@ public String getSymbol(int axis) { } if (testUnit(axis)) { Units.LabelledMapping lm = - Units.relabel(defUnit(system, "astGetSymbol", astClass()), getUnit(axis), result); + Units.unitMapperLabel(defUnit(system, "astGetSymbol", astClass()), getUnit(axis), result); if (lm != null && lm.label != null) { result = lm.label; } @@ -630,7 +629,6 @@ public String getTitle() { * @return the Mapping, or null if there is none * @throws AstException with status {@code AST__BADUN} if either System follows from a Unit * that suits no flux System - * @throws UnsupportedOperationException if a units conversion needs a MathMap */ Mapping makeFluxMapping(FluxFrame result) { int rsysIn = systemValue(); diff --git a/src/main/java/uk/ac/starlink/ast/Frame.java b/src/main/java/uk/ac/starlink/ast/Frame.java index 55d46db..b862085 100644 --- a/src/main/java/uk/ac/starlink/ast/Frame.java +++ b/src/main/java/uk/ac/starlink/ast/Frame.java @@ -487,6 +487,21 @@ void deepCopy() { // The Frame as a Mapping // ------------------------------------------------------------------ + /** + * frame.c {@code Equal}: {@code that} is of the same class, and the conversion from {@code + * that} to this Frame ({@link #convert}) simplifies to a UnitMap. Attributes that only describe + * the axes, such as Title and Label, play no part, nor does the Invert attribute. + */ + @Override + boolean equalTo(AstObject that) { + if (!astClass().equals(that.astClass())) { + return false; + } + FrameSet fs = ((Frame) that).convert(this, ""); + return fs != null + && fs.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT).simplify() instanceof UnitMap; + } + /** * Gets the number of input coordinates, which is the number of axes. * @@ -2687,13 +2702,13 @@ void clearUnit(int axis) { */ private static void newUnit(Axis ax, String oldUnits, String newUnits) { if (ax.testAxisLabel()) { - Units.LabelledMapping lm = Units.relabel(oldUnits, newUnits, ax.getAxisLabel()); + Units.LabelledMapping lm = Units.unitMapperLabel(oldUnits, newUnits, ax.getAxisLabel()); if (lm != null && lm.label != null) { ax.setAxisLabel(lm.label); } } if (ax.testAxisSymbol()) { - Units.LabelledMapping lm = Units.relabel(oldUnits, newUnits, ax.getAxisSymbol()); + Units.LabelledMapping lm = Units.unitMapperLabel(oldUnits, newUnits, ax.getAxisSymbol()); if (lm != null && lm.label != null) { ax.setAxisSymbol(lm.label); } diff --git a/src/main/java/uk/ac/starlink/ast/FrameSet.java b/src/main/java/uk/ac/starlink/ast/FrameSet.java index 78cd033..ff7c75e 100644 --- a/src/main/java/uk/ac/starlink/ast/FrameSet.java +++ b/src/main/java/uk/ac/starlink/ast/FrameSet.java @@ -1647,6 +1647,34 @@ void addVariant(Mapping map, String name) { // The FrameSet as a Mapping // ------------------------------------------------------------------ + /** + * frameset.c {@code Equal}: {@code that} is of the same class, with the same numbers of Frames + * and nodes and the same Base and Current attributes as stored, whose Frames are equal ({@link + * #astEqual}) and at the same nodes, and whose Mappings are equal and join the same nodes with + * the same Invert values. The Invert attributes of the FrameSets play no part. + */ + @Override + boolean equalTo(AstObject that) { + if (!astClass().equals(that.astClass())) { + return false; + } + FrameSet other = (FrameSet) that; + if (nframe != other.nframe || nnode != other.nnode || base != other.base || current != other.current) { + return false; + } + for (int i = 0; i < nframe; i++) { + if (!frames[i].astEqual(other.frames[i]) || nodes[i] != other.nodes[i]) { + return false; + } + } + for (int i = 0; i < nnode - 1; i++) { + if (!maps[i].astEqual(other.maps[i]) || links[i] != other.links[i] || inverts[i] != other.inverts[i]) { + return false; + } + } + return true; + } + /** * Gets the number of input coordinates: the number of axes of the base Frame. * diff --git a/src/main/java/uk/ac/starlink/ast/GrismMap.java b/src/main/java/uk/ac/starlink/ast/GrismMap.java new file mode 100644 index 0000000..73e4a7c --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/GrismMap.java @@ -0,0 +1,879 @@ +package uk.ac.starlink.ast; + +/** + * A Mapping which transforms 1-dimensional coordinates using the spectral dispersion equation + * described in FITS-WCS paper III "Representation of spectral coordinates in FITS". This describes + * the dispersion produced by gratings, prisms and grisms. + * + *

When initially created, the forward transformation of a GrismMap transforms input "grism + * parameter" values into output wavelength values. The "grism parameter" is a dimensionless value + * which is linearly related to position on the detector. It is defined in FITS-WCS paper III as + * "the offset on the detector from the point of intersection of the camera axis, measured in units + * of the effective local length". The units in which wavelength values are expected or returned + * are those used for GrismWaveR, GrismNRP and GrismG. + * + *

The dispersion is described by eight attributes: GrismNR (the refractive index at the + * reference wavelength, default 1), GrismNRP (the rate of change of refractive index with + * wavelength, default 0), GrismWaveR (the reference wavelength, default 5000), GrismAlpha (the + * angle of incidence of the incoming light, in radians, default 0), GrismG (the grating ruling + * density, default 0), GrismM (the interference order, an integer, default 0), GrismEps (the angle + * between the normal and the dispersion plane, in radians, default 0) and GrismTheta (the angle + * between the normal to the detector plane and the reference ray, in radians, default 0). A new + * GrismMap has none of them set. Once the GrismMap is held by another Object, such as a CmpMap, + * none of them can be set or cleared. + * + *

Ported from Rust {@code mappings/grismmap.rs} and C {@code grismmap.c}. + */ +public class GrismMap extends Mapping { + + /** The value C stores in GrismM while it is unset, {@code INT_MAX}. */ + private static final int UNSET_M = Integer.MAX_VALUE; + + /** GrismNR, {@link #AST__BAD} while unset (C's {@code nr}). */ + private double nr = AST__BAD; + + /** GrismNRP, {@link #AST__BAD} while unset (C's {@code nrp}). */ + private double nrp = AST__BAD; + + /** GrismWaveR, {@link #AST__BAD} while unset (C's {@code waver}). */ + private double waver = AST__BAD; + + /** GrismAlpha, {@link #AST__BAD} while unset (C's {@code alpha}). */ + private double alpha = AST__BAD; + + /** GrismG, {@link #AST__BAD} while unset (C's {@code g}). */ + private double g = AST__BAD; + + /** GrismM, {@link #UNSET_M} while unset (C's {@code m}). */ + private int m = UNSET_M; + + /** GrismEps, {@link #AST__BAD} while unset (C's {@code eps}). */ + private double eps = AST__BAD; + + /** GrismTheta, {@link #AST__BAD} while unset (C's {@code theta}). */ + private double theta = AST__BAD; + + /** The constants the transformation uses, worked out from the attributes by {@link #updateConstants}. */ + private double k1; + + private double k2; + + private double k3; + + /** Creates a GrismMap with no attribute set, so that each takes its default value. */ + public GrismMap() { + super(1, 1, true, true); + updateConstants(); + } + + /** + * Loads a GrismMap from its description, as C's {@code astLoadGrismMap} does: each attribute + * read is set through its private setter, which, given the value just read, keeps the record + * of simplification the Mapping part set up. + */ + GrismMap(NativeNode node) { + super(node); + NativeNode part = node.section("GrismMap"); + nr = part.readDouble("GrmNR", AST__BAD); + if (testGrismNR()) { + setGrismNRValue(nr); + } + nrp = part.readDouble("GrmNRP", AST__BAD); + if (testGrismNRP()) { + setGrismNRPValue(nrp); + } + waver = part.readDouble("GrmWR", AST__BAD); + if (testGrismWaveR()) { + setGrismWaveRValue(waver); + } + alpha = part.readDouble("GrmAlp", AST__BAD); + if (testGrismAlpha()) { + setGrismAlphaValue(alpha); + } + g = part.readDouble("GrmG", AST__BAD); + if (testGrismG()) { + setGrismGValue(g); + } + m = part.readInt("GrmM", UNSET_M); + if (testGrismM()) { + setGrismMValue(m); + } + eps = part.readDouble("GrmEps", AST__BAD); + if (testGrismEps()) { + setGrismEpsValue(eps); + } + theta = part.readDouble("GrmTh", AST__BAD); + if (testGrismTheta()) { + setGrismThetaValue(theta); + } + updateConstants(); + } + + @Override + String dumpComment() { + return "Map 1-d coordinates using a spectral disperser"; + } + + /** + * Writes the eight attributes, each as a comment holding its default when it is unset, as C's + * {@code Dump} (grismmap.c) does; GrismM is written as a floating-point value. + */ + @Override + void dump(NativeNode node) { + super.dump(node); + node.writeIsA("Mapping", "Mapping between coordinate systems"); + node.writeDouble("GrmNR", testGrismNR(), true, getGrismNRValue(), "Refractive index at the ref. wavelength"); + node.writeDouble("GrmNRP", testGrismNRP(), true, getGrismNRPValue(), "Rate of change of refractive index"); + node.writeDouble("GrmWR", testGrismWaveR(), true, getGrismWaveRValue(), "Ref. wavelength"); + node.writeDouble( + "GrmAlp", testGrismAlpha(), true, getGrismAlphaValue(), "Angle of incidence of incoming light"); + node.writeDouble("GrmG", testGrismG(), true, getGrismGValue(), "Grating ruling density"); + node.writeDouble("GrmM", testGrismM(), true, getGrismMValue(), "The interference order"); + node.writeDouble( + "GrmEps", + testGrismEps(), + true, + getGrismEpsValue(), + "Angle between grating normal and dispersion plane"); + node.writeDouble( + "GrmTh", + testGrismTheta(), + true, + getGrismThetaValue(), + "Angle between detector normal and reference ray"); + } + + // ------------------------------------------------------------------ + // Derived constants + // ------------------------------------------------------------------ + + /** + * C's {@code UpdateConstants}: works out the constants the transformation uses from the + * attribute values, {@link #AST__BAD} for those that do not exist (when GrismEps makes the + * cosine zero, or the sine of the reference ray's angle is outside -1 to 1). + */ + private void updateConstants() { + double cnr = getGrismNRValue(); + double cnrp = getGrismNRPValue(); + double waveR = getGrismWaveRValue(); + double calpha = getGrismAlphaValue(); + double cg = getGrismGValue(); + int cm = getGrismMValue(); + double ceps = getGrismEpsValue(); + double ctheta = getGrismThetaValue(); + double coseps = Math.cos(ceps); + double sinalpha = Math.sin(calpha); + k1 = sinalpha * (cnr - cnrp * waveR); + if (coseps != 0.0) { + k2 = (cg * cm / coseps) - cnrp * sinalpha; + double sinbetaR = cg * cm * waveR / coseps - cnr * sinalpha; + if (sinbetaR < -1.0 || sinbetaR > 1.0) { + k3 = AST__BAD; + } else { + k3 = Math.asin(sinbetaR) + ctheta; + } + } else { + k2 = AST__BAD; + k3 = AST__BAD; + } + } + + // ------------------------------------------------------------------ + // Transformation + // ------------------------------------------------------------------ + + /** + * C's {@code Transform} (grismmap.c): the forward transformation gives the wavelength {@code + * (k1 + sin(atan(g) + k3)) / k2} of the grism parameter {@code g}, and the inverse the grism + * parameter {@code tan(asin(k2 * w - k1) - k3)} of the wavelength {@code w}, bad where the + * sine is outside -1 to 1. Every output is bad when a constant is bad, and the forward + * transformation's when {@code k2} is zero. An input that is not finite is bad, where C tests + * only for {@link #AST__BAD} (docs/rust-c-differences.md, "Infinite input coordinates"). + */ + @Override + void transformInto(double[][] in, int npoint, boolean forward, double[][] out) { + validateTransformInto(in, npoint, forward, out); + double[] xin = in[0]; + double[] xout = out[0]; + if (k1 == AST__BAD || k2 == AST__BAD || k3 == AST__BAD) { + for (int p = 0; p < npoint; p++) { + xout[p] = AST__BAD; + } + } else if (effectiveForward(forward)) { + for (int p = 0; p < npoint; p++) { + double v = xin[p]; + if (isBad(v) || k2 == 0.0) { + xout[p] = AST__BAD; + } else { + xout[p] = (k1 + Math.sin(Math.atan(v) + k3)) / k2; + } + } + } else { + for (int p = 0; p < npoint; p++) { + double v = xin[p]; + if (isBad(v)) { + xout[p] = AST__BAD; + } else { + double sinbeta = k2 * v - k1; + if (sinbeta < -1.0 || sinbeta > 1.0) { + xout[p] = AST__BAD; + } else { + xout[p] = Math.tan(Math.asin(sinbeta) - k3); + } + } + } + } + } + + /** + * NaN protocol: {@link #transformInto} without the per-point checks of bad input, through + * whose arithmetic NaN propagates; the inverse's range check on the sine, which a NaN fails, + * gives NaN. + */ + @Override + void transformIntoNan(double[][] in, int npoint, boolean forward, double[][] out) { + double[] xin = in[0]; + double[] xout = out[0]; + if (k1 == AST__BAD || k2 == AST__BAD || k3 == AST__BAD || (effectiveForward(forward) && k2 == 0.0)) { + for (int p = 0; p < npoint; p++) { + xout[p] = Double.NaN; + } + } else if (effectiveForward(forward)) { + for (int p = 0; p < npoint; p++) { + xout[p] = (k1 + Math.sin(Math.atan(xin[p]) + k3)) / k2; + } + } else { + for (int p = 0; p < npoint; p++) { + double sinbeta = k2 * xin[p] - k1; + xout[p] = sinbeta >= -1.0 && sinbeta <= 1.0 ? Math.tan(Math.asin(sinbeta) - k3) : Double.NaN; + } + } + } + + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + /** + * grismmap.c {@code Equal}: {@code that} is a GrismMap with the same numbers of inputs and + * outputs and the same Invert attribute, whose attributes and constants are, to within {@code + * astEQUAL}, this one's. C compares the attributes as stored, so an unset attribute differs + * from one set to its default. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof GrismMap)) { + return false; + } + GrismMap other = (GrismMap) that; + if (other.getNin() != getNin() || other.getNout() != getNout() || getInvert() != other.getInvert()) { + return false; + } + return MappingHelpers.astEqual(nr, other.nr) + && MappingHelpers.astEqual(nrp, other.nrp) + && MappingHelpers.astEqual(waver, other.waver) + && MappingHelpers.astEqual(alpha, other.alpha) + && MappingHelpers.astEqual(g, other.g) + && m == other.m + && MappingHelpers.astEqual(eps, other.eps) + && MappingHelpers.astEqual(theta, other.theta) + && MappingHelpers.astEqual(k1, other.k1) + && MappingHelpers.astEqual(k2, other.k2) + && MappingHelpers.astEqual(k3, other.k3); + } + + // ------------------------------------------------------------------ + // Simplification + // ------------------------------------------------------------------ + + /** + * grismmap.c {@code MapMerge}: in series, the GrismMap is merged with the Mapping before it + * or, failing that, the one after it, as {@link #canMerge} decides, and the merged Mapping + * replaces the pair, applied with its own Invert attribute. Nothing is merged in parallel. + */ + @Override + int mapMerge(MergeList list, int where, boolean series) { + if (!series) { + return -1; + } + Mapping merged = null; + int i1 = -1; + if (where > 0) { + i1 = where - 1; + merged = canMerge(list.map(i1), list.invert(i1), list.map(where), list.invert(where)); + } + if (merged == null && where < list.size() - 1) { + i1 = where; + merged = canMerge(list.map(i1), list.invert(i1), list.map(where + 1), list.invert(where + 1)); + } + if (merged == null) { + return -1; + } + list.replacePairWith(i1, merged, merged.getInvert()); + return i1; + } + + /** + * C's {@code CanMerge} (grismmap.c): the Mapping equivalent to {@code map1} followed by {@code + * map2}, applied with the Invert values {@code inv1} and {@code inv2}, one of which is a + * GrismMap; or null if they cannot be merged. Two GrismMaps applied in opposite directions + * whose attributes are equal to within {@code astEQUAL}, except GrismM, which must differ, + * give a UnitMap. A GrismMap applied forward followed by a ZoomMap, or a ZoomMap followed by + * a GrismMap applied inverted, give a copy of the GrismMap with its GrismG, GrismNRP and + * GrismWaveR changed to describe wavelengths scaled by the zoom factor, applied in the + * direction of the GrismMap. Classes are compared by name, as C does. + * + *

The zoom factor is the ZoomMap's Zoom attribute, or its reciprocal when the ZoomMap's own + * Invert attribute differs from the Invert value it is applied with (when it follows the + * GrismMap) or equals it (when it precedes it), as C decides; a ZoomMap whose own Invert + * attribute is set is therefore taken in the direction opposite to the one it is applied in. + */ + private static Mapping canMerge(Mapping map1, boolean inv1, Mapping map2, boolean inv2) { + GrismMap gmap = null; + boolean invertResult = false; + double z = AST__BAD; + if ("GrismMap".equals(map1.astClass())) { + gmap = (GrismMap) map1; + if ("GrismMap".equals(map2.astClass())) { + GrismMap gmap2 = (GrismMap) map2; + if (MappingHelpers.astEqual(gmap.getGrismNRValue(), gmap2.getGrismNRValue()) + && MappingHelpers.astEqual(gmap.getGrismNRPValue(), gmap2.getGrismNRPValue()) + && MappingHelpers.astEqual(gmap.getGrismWaveRValue(), gmap2.getGrismWaveRValue()) + && MappingHelpers.astEqual(gmap.getGrismAlphaValue(), gmap2.getGrismAlphaValue()) + && MappingHelpers.astEqual(gmap.getGrismGValue(), gmap2.getGrismGValue()) + && gmap.getGrismMValue() != gmap2.getGrismMValue() + && MappingHelpers.astEqual(gmap.getGrismEpsValue(), gmap2.getGrismEpsValue()) + && MappingHelpers.astEqual(gmap.getGrismThetaValue(), gmap2.getGrismThetaValue()) + && inv1 != inv2) { + return new UnitMap(1); + } + return null; + } else if (!inv1 && "ZoomMap".equals(map2.astClass())) { + z = ((ZoomMap) map2).getZoom(); + if (map2.getInvert() != inv2 && z != 0.0) { + z = 1.0 / z; + } + } + } else if ("GrismMap".equals(map2.astClass())) { + gmap = (GrismMap) map2; + if (inv2) { + invertResult = true; + if ("ZoomMap".equals(map1.astClass())) { + z = ((ZoomMap) map1).getZoom(); + if (map1.getInvert() == inv1 && z != 0.0) { + z = 1.0 / z; + } + } + } + } + if (z == AST__BAD || z == 0.0) { + return null; + } + GrismMap ret = (GrismMap) gmap.copy(); + ret.setInvert(false); + ret.setGrismGValue(ret.getGrismGValue() / z); + ret.setGrismNRPValue(ret.getGrismNRPValue() / z); + ret.setGrismWaveRValue(ret.getGrismWaveRValue() * z); + if (invertResult) { + ret.invert(); + } + return ret; + } + + // ------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------ + + /** + * Gets the GrismNR attribute: the refractive index of the grism material at the reference + * wavelength (given by GrismWaveR). Default 1. + * + * @return the refractive index + */ + public double getGrismNR() { + return getD("GrismNR"); + } + + /** + * Sets the GrismNR attribute. {@link #AST__BAD} leaves it unset. + * + * @param grismNR the refractive index at the reference wavelength + * @throws AstException with status {@code AST__IMMUT} if the GrismMap is held by another + * Object, such as a CmpMap + */ + public void setGrismNR(double grismNR) { + setD("GrismNR", grismNR); + } + + /** + * Gets the GrismNRP attribute: the rate of change of the refractive index of the grism + * material with respect to wavelength, at the reference wavelength (given by GrismWaveR). Its + * units should be consistent with those of GrismWaveR and GrismG. Default 0, the value for a + * pure grating disperser with no prism. + * + * @return the rate of change of refractive index with wavelength + */ + public double getGrismNRP() { + return getD("GrismNRP"); + } + + /** + * Sets the GrismNRP attribute. {@link #AST__BAD} leaves it unset. + * + * @param grismNRP the rate of change of refractive index with wavelength + * @throws AstException with status {@code AST__IMMUT} if the GrismMap is held by another + * Object, such as a CmpMap + */ + public void setGrismNRP(double grismNRP) { + setD("GrismNRP", grismNRP); + } + + /** + * Gets the GrismWaveR attribute: the reference wavelength. Its units should be consistent + * with those of GrismNRP and GrismG, and are those of the wavelengths the GrismMap + * transforms. Default 5000 (Angstrom). + * + * @return the reference wavelength + */ + public double getGrismWaveR() { + return getD("GrismWaveR"); + } + + /** + * Sets the GrismWaveR attribute. {@link #AST__BAD} leaves it unset. + * + * @param grismWaveR the reference wavelength + * @throws AstException with status {@code AST__IMMUT} if the GrismMap is held by another + * Object, such as a CmpMap + */ + public void setGrismWaveR(double grismWaveR) { + setD("GrismWaveR", grismWaveR); + } + + /** + * Gets the GrismAlpha attribute: the angle between the incoming light and the normal to the + * grating surface, in radians. Default 0. + * + * @return the angle of incidence + */ + public double getGrismAlpha() { + return getD("GrismAlpha"); + } + + /** + * Sets the GrismAlpha attribute. {@link #AST__BAD} leaves it unset. + * + * @param grismAlpha the angle of incidence, in radians + * @throws AstException with status {@code AST__IMMUT} if the GrismMap is held by another + * Object, such as a CmpMap + */ + public void setGrismAlpha(double grismAlpha) { + setD("GrismAlpha", grismAlpha); + } + + /** + * Gets the GrismG attribute: the grating ruling density, the number of grating rulings per + * unit length. The unit of length should be consistent with the units of GrismWaveR and + * GrismNRP. Default 0, the value for a pure prism disperser with no grating. + * + * @return the grating ruling density + */ + public double getGrismG() { + return getD("GrismG"); + } + + /** + * Sets the GrismG attribute. {@link #AST__BAD} leaves it unset. + * + * @param grismG the grating ruling density + * @throws AstException with status {@code AST__IMMUT} if the GrismMap is held by another + * Object, such as a CmpMap + */ + public void setGrismG(double grismG) { + setD("GrismG", grismG); + } + + /** + * Gets the GrismM attribute: the interference order being considered. Default 0. + * + * @return the interference order + */ + public int getGrismM() { + return getI("GrismM"); + } + + /** + * Sets the GrismM attribute. {@link Integer#MAX_VALUE} leaves it unset. + * + * @param grismM the interference order + * @throws AstException with status {@code AST__IMMUT} if the GrismMap is held by another + * Object, such as a CmpMap + */ + public void setGrismM(int grismM) { + setI("GrismM", grismM); + } + + /** + * Gets the GrismEps attribute: the angle, in radians, between the normal to the grating or + * exit prism face and the dispersion plane, the plane spanned by the incoming and outgoing + * ray. Default 0. + * + * @return the angle between the normal and the dispersion plane + */ + public double getGrismEps() { + return getD("GrismEps"); + } + + /** + * Sets the GrismEps attribute. {@link #AST__BAD} leaves it unset. + * + * @param grismEps the angle between the normal and the dispersion plane, in radians + * @throws AstException with status {@code AST__IMMUT} if the GrismMap is held by another + * Object, such as a CmpMap + */ + public void setGrismEps(double grismEps) { + setD("GrismEps", grismEps); + } + + /** + * Gets the GrismTheta attribute: the angle of incidence of light of the reference + * wavelength (given by GrismWaveR) onto the detector, the angle, in radians, between the + * normal to the detector plane and an incident ray at the reference wavelength. Default 0. + * + * @return the angle of incidence onto the detector + */ + public double getGrismTheta() { + return getD("GrismTheta"); + } + + /** + * Sets the GrismTheta attribute. {@link #AST__BAD} leaves it unset. + * + * @param grismTheta the angle of incidence onto the detector, in radians + * @throws AstException with status {@code AST__IMMUT} if the GrismMap is held by another + * Object, such as a CmpMap + */ + public void setGrismTheta(double grismTheta) { + setD("GrismTheta", grismTheta); + } + + /** GrismNR, its default when unset (C's {@code astGetGrismNR}). */ + final double getGrismNRValue() { + return nr == AST__BAD ? 1.0 : nr; + } + + /** GrismNRP, its default when unset. */ + final double getGrismNRPValue() { + return nrp == AST__BAD ? 0.0 : nrp; + } + + /** GrismWaveR, its default when unset. */ + final double getGrismWaveRValue() { + return waver == AST__BAD ? 5000.0 : waver; + } + + /** GrismAlpha, its default when unset. */ + final double getGrismAlphaValue() { + return alpha == AST__BAD ? 0.0 : alpha; + } + + /** GrismG, its default when unset. */ + final double getGrismGValue() { + return g == AST__BAD ? 0.0 : g; + } + + /** GrismM, its default when unset. */ + final int getGrismMValue() { + return m == UNSET_M ? 0 : m; + } + + /** GrismEps, its default when unset. */ + final double getGrismEpsValue() { + return eps == AST__BAD ? 0.0 : eps; + } + + /** GrismTheta, its default when unset. */ + final double getGrismThetaValue() { + return theta == AST__BAD ? 0.0 : theta; + } + + /** + * C's private {@code SetGrismNR}, from grismmap.c's {@code MAKE_SET}: a shared GrismMap + * refuses the change; a value different from the one stored (unset being {@link #AST__BAD}) + * discards the record of simplification; {@link #AST__BAD} leaves the attribute unset; the + * constants are worked out again. The other private setters do the same. + */ + final void setGrismNRValue(double value) { + checkSet1("GrismNR"); + if (value != nr) { + clearIsSimple(); + } + nr = value; + updateConstants(); + } + + final void setGrismNRPValue(double value) { + checkSet1("GrismNRP"); + if (value != nrp) { + clearIsSimple(); + } + nrp = value; + updateConstants(); + } + + final void setGrismWaveRValue(double value) { + checkSet1("GrismWaveR"); + if (value != waver) { + clearIsSimple(); + } + waver = value; + updateConstants(); + } + + final void setGrismAlphaValue(double value) { + checkSet1("GrismAlpha"); + if (value != alpha) { + clearIsSimple(); + } + alpha = value; + updateConstants(); + } + + final void setGrismGValue(double value) { + checkSet1("GrismG"); + if (value != g) { + clearIsSimple(); + } + g = value; + updateConstants(); + } + + /** {@link Integer#MAX_VALUE}, C's {@code INT_MAX}, leaves GrismM unset. */ + final void setGrismMValue(int value) { + checkSet1("GrismM"); + if (value != m) { + clearIsSimple(); + } + m = value; + updateConstants(); + } + + final void setGrismEpsValue(double value) { + checkSet1("GrismEps"); + if (value != eps) { + clearIsSimple(); + } + eps = value; + updateConstants(); + } + + final void setGrismThetaValue(double value) { + checkSet1("GrismTheta"); + if (value != theta) { + clearIsSimple(); + } + theta = value; + updateConstants(); + } + + private boolean testGrismNR() { + return nr != AST__BAD; + } + + private boolean testGrismNRP() { + return nrp != AST__BAD; + } + + private boolean testGrismWaveR() { + return waver != AST__BAD; + } + + private boolean testGrismAlpha() { + return alpha != AST__BAD; + } + + private boolean testGrismG() { + return g != AST__BAD; + } + + private boolean testGrismM() { + return m != UNSET_M; + } + + private boolean testGrismEps() { + return eps != AST__BAD; + } + + private boolean testGrismTheta() { + return theta != AST__BAD; + } + + /** + * Clears the attribute named in lower case, as grismmap.c's {@code MAKE_CLEAR} does: a shared + * GrismMap refuses; otherwise the record of simplification is discarded, the attribute unset + * and the constants worked out again. + * + * @return whether {@code attrib} is a GrismMap attribute + */ + private boolean clearGrism(String attrib) { + // MODERN-JAVA(14): switch expression + switch (attrib) { + case "grismnr": + checkClear1("GrismNR"); + clearIsSimple(); + nr = AST__BAD; + break; + case "grismnrp": + checkClear1("GrismNRP"); + clearIsSimple(); + nrp = AST__BAD; + break; + case "grismwaver": + checkClear1("GrismWaveR"); + clearIsSimple(); + waver = AST__BAD; + break; + case "grismalpha": + checkClear1("GrismAlpha"); + clearIsSimple(); + alpha = AST__BAD; + break; + case "grismg": + checkClear1("GrismG"); + clearIsSimple(); + g = AST__BAD; + break; + case "grismm": + checkClear1("GrismM"); + clearIsSimple(); + m = UNSET_M; + break; + case "grismeps": + checkClear1("GrismEps"); + clearIsSimple(); + eps = AST__BAD; + break; + case "grismtheta": + checkClear1("GrismTheta"); + clearIsSimple(); + theta = AST__BAD; + break; + default: + return false; + } + updateConstants(); + return true; + } + + /** C's {@code GetAttrib}: each attribute formatted with {@code %.17g}, GrismM as a double. */ + @Override + String getAttrib(String attrib) { + double dval; + // MODERN-JAVA(14): switch expression + switch (attrib) { + case "grismnr": + dval = getGrismNRValue(); + break; + case "grismnrp": + dval = getGrismNRPValue(); + break; + case "grismwaver": + dval = getGrismWaveRValue(); + break; + case "grismalpha": + dval = getGrismAlphaValue(); + break; + case "grismg": + dval = getGrismGValue(); + break; + case "grismm": + dval = getGrismMValue(); + break; + case "grismeps": + dval = getGrismEpsValue(); + break; + case "grismtheta": + dval = getGrismThetaValue(); + break; + default: + return super.getAttrib(attrib); + } + return CFormat.format("%.17g", dval); + } + + /** + * C's {@code SetAttrib}: every attribute's value is read as a double, GrismM's then converted + * to an integer by truncation, as C's assignment of a double to an {@code int} does. + */ + @Override + void setAttrib(String attrib, String value) { + Double dval = CScan.scanDouble(value); + if (dval == null) { + super.setAttrib(attrib, value); + return; + } + double v = dval; + // MODERN-JAVA(14): switch expression + switch (attrib) { + case "grismnr": + setGrismNRValue(v); + break; + case "grismnrp": + setGrismNRPValue(v); + break; + case "grismwaver": + setGrismWaveRValue(v); + break; + case "grismalpha": + setGrismAlphaValue(v); + break; + case "grismg": + setGrismGValue(v); + break; + case "grismm": + setGrismMValue((int) v); + break; + case "grismeps": + setGrismEpsValue(v); + break; + case "grismtheta": + setGrismThetaValue(v); + break; + default: + super.setAttrib(attrib, value); + break; + } + } + + @Override + boolean testAttrib(String attrib) { + // MODERN-JAVA(14): switch expression + switch (attrib) { + case "grismnr": + return testGrismNR(); + case "grismnrp": + return testGrismNRP(); + case "grismwaver": + return testGrismWaveR(); + case "grismalpha": + return testGrismAlpha(); + case "grismg": + return testGrismG(); + case "grismm": + return testGrismM(); + case "grismeps": + return testGrismEps(); + case "grismtheta": + return testGrismTheta(); + default: + return super.testAttrib(attrib); + } + } + + @Override + void clearAttrib(String attrib) { + if (!clearGrism(attrib)) { + super.clearAttrib(attrib); + } + } +} diff --git a/src/main/java/uk/ac/starlink/ast/IntraMap.java b/src/main/java/uk/ac/starlink/ast/IntraMap.java new file mode 100644 index 0000000..e9e7797 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/IntraMap.java @@ -0,0 +1,471 @@ +package uk.ac.starlink.ast; + +import java.io.IOException; +import java.util.Arrays; +import java.util.Objects; + +/** + * A Mapping which maps points using a private transformation function. The {@code IntraMap} + * allows you to use a custom transformation function, as implemented by a {@link Transformer} + * object, to perform the transformations used by a {@code Mapping}. This allows you to create + * {@code Mapping}s that perform any conceivable coordinate transformation. + * + *

However, an {@code IntraMap} is intended for use within a given software environment. It is + * written to a {@link Channel} with the name of its transformation function, not the function + * itself, as C's IntraMap is, and can be read back only where that name stands for a Transformer: + * in the same process, after an IntraMap was made with that Transformer and until the Transformer + * is garbage-collected, or through a Channel with which a Transformer has been registered under + * the name. + * + *

The IntraMap holds its Transformer by reference; a {@link #copy} shares it. The name of its + * transformation function (written to a dump as {@code Fname}) is the Transformer's class name + * followed by {@code #} and its identity hash code in hexadecimal, with {@code #1}, {@code #2}, + * ... added if another Transformer not yet garbage-collected has that name, and two IntraMaps with the + * same name are taken to apply the same function. Making an IntraMap registers its Transformer under + * that name, as jniast registers it with C's {@code astIntraReg}, together with the numbers of + * coordinates, the flags (whether the forward and inverse transformations exist, and whether a + * forward and inverse pair, or an inverse and forward pair, in series simplify away) and the + * purpose, author and contact strings, all read from the Transformer then. The registration holds + * the Transformer weakly: it lasts while the Transformer is reachable, and lapses once the + * Transformer is garbage-collected. Every IntraMap made with one Transformer has the same name. + * + *

The IntraFlag attribute is a string which distinguishes this IntraMap from others using the + * same function: a pair of IntraMaps that could cancel is simplified only if their IntraFlag + * values are the same (an unset value reading as an empty string), and two IntraMaps are equal + * only if both have it set to the same value. It is unset by default, and cannot be changed once + * the IntraMap is held by another Object. + * + *

The Transformer's {@code tranP} method is called without any lock, and copies of an IntraMap + * share its Transformer, so it may be called from several threads at once: the Transformer must + * be thread-safe. + * + *

Ported from Rust {@code mappings/intramap.rs}, C {@code intramap.c} and jniast's {@code + * IntraMap.java} and {@code jni/IntraMap.c}. + */ +public class IntraMap extends Mapping implements NeedsChannelizing { + + /** The Transformer which performs the transformations, shared with any copies. */ + private final Transformer trans; + + /** The name of the transformation function (C's {@code tran_data[ifun].name}). */ + private final String fname; + + /** C's flags for the function: {@link IntraRegistry#SIMPFI} and {@link IntraRegistry#SIMPIF}. */ + private final int flags; + + /** The purpose string of the function. */ + private final String purpose; + + /** The author of the function. */ + private final String author; + + /** The contact details of the author. */ + private final String contact; + + /** The IntraFlag attribute, null while unset. */ + private String intraFlag; + + /** + * Constructs an {@code IntraMap} from a given {@code Transformer} object. + * + * @param trans the Transformer which will do the actual transformations + * @param nin the number of input coordinates for the forward transformation (or output + * coordinates for the inverse transformation) + * @param nout the number of output coordinates for the forward transformation (or input + * coordinates for the inverse transformation) + * @throws IllegalArgumentException if {@code trans} is not able to transform from {@code nin} + * to {@code nout} coordinates + * @throws NullPointerException if {@code trans} is null + * @throws AstException with status {@code AST__MRITF} if an IntraMap was made earlier with + * {@code trans} and other details: other numbers of coordinates, or other flags or strings + * than {@code trans} now gives + */ + public IntraMap(Transformer trans, int nin, int nout) { + this(register(trans, nin, nout), nin, nout); + } + + /** + * Constructs a two-dimensional {@code IntraMap} from a given {@code Transformer2} object. + * + * @param trans the {@code Transformer2} which will do the actual two-coordinate to + * two-coordinate transformations + */ + public IntraMap(Transformer2 trans) { + this(trans, 2, 2); + } + + /** + * Constructs a one-dimensional {@code IntraMap} from a given {@code Transformer1} object. + * + * @param trans the {@code Transformer1} which will do the actual one-coordinate to + * one-coordinate transformations + */ + public IntraMap(Transformer1 trans) { + this(trans, 1, 1); + } + + /** Constructs an IntraMap of the function {@code entry} registers, as {@code astInitIntraMap} does. */ + private IntraMap(IntraRegistry.Entry entry, int nin, int nout) { + super(nin, nout, (entry.flags & IntraRegistry.NOFWD) == 0, (entry.flags & IntraRegistry.NOINV) == 0); + trans = entry.trans; + fname = entry.name; + flags = entry.flags; + purpose = entry.purpose; + author = entry.author; + contact = entry.contact; + } + + /** + * jniast's {@code construct} (jni/IntraMap.c) up to its call of {@code astIntraReg}: the check + * that {@code trans} can map {@code nin} to {@code nout} coordinates, then the registration of + * {@code trans} under its function name in the process-wide table, which reads its flags and + * strings. An exception the Transformer's methods throw is passed on, as jniast passes it on. + */ + private static IntraRegistry.Entry register(Transformer trans, int nin, int nout) { + Objects.requireNonNull(trans, "trans"); + if (!trans.canTransformCoords(nin, nout)) { + throw new IllegalArgumentException("Transformer will not map " + nin + " -> " + nout + " coordinates"); + } + String name = trans.getClass().getName() + "#" + Integer.toHexString(System.identityHashCode(trans)); + return IntraRegistry.registerMade(name, nin, nout, trans); + } + + /** + * Loads an IntraMap from its description, as C's {@code astLoadIntraMap} does: {@code Fname}, + * {@code Iflag} (the IntraFlag attribute), {@code Purp}, {@code Auth} and {@code Cntact}. The + * Transformer is the one registered under the function name, with the Channel reading or, if + * none is, by an IntraMap made in this process with a Transformer not yet garbage-collected + * ({@link IntraRegistry#lookup}). + * As in C, the IntraMap's numbers of coordinates as its Invert attribute leaves them must be + * those registered, so an inverted IntraMap of a function with different numbers of inputs and + * outputs cannot be read. No method of the Transformer is called. + * + * @throws AstException with status {@code AST__URITF} if no function is registered under the + * name, or {@code AST__BADNI} or {@code AST__BADNO} if the numbers of coordinates differ + * from those registered + */ + // C's loader calls the Mapping class's GetNin and GetNout, which IntraMap does not override. + @SuppressWarnings("PMD.ConstructorCallsOverridableMethod") + IntraMap(NativeNode node) { + super(node); + NativeNode part = node.section("IntraMap"); + String chan = node.channelClass; + fname = part.readString("Fname", ""); + // jniast also stored a Java-serialised Transformer here for an IntraMap at the top level of + // an Object written; this library reads an IntraMap by its function name only. + intraFlag = part.getStringIfSet("Iflag"); + String dumpPurpose = part.readString("Purp", ""); + String dumpAuthor = part.readString("Auth", ""); + String dumpContact = part.readString("Cntact", ""); + IntraRegistry.Entry entry = IntraRegistry.lookup(fname); + if (entry == null) { + throw Ast.err( + AstException.AST__URITF, + "astLoadIntraMap(" + chan + "): An IntraMap was read which uses an unknown transformation " + + "function.\nThis is a private extension to the AST library: to handle it, you must " + + "obtain the source code from its author.\nYou can then register it with AST in your " + + "software by calling astIntraReg (see SUN/211).\n \n Function name: \"" + fname + + "\".\n Purpose: \"" + dumpPurpose + "\".\n Author: \"" + + dumpAuthor + "\".\n Contact address: \"" + dumpContact + "\".\n "); + } + // C asks the parent class's GetNin and GetNout, which take account of the Invert attribute + // already loaded (intramap.c astLoadIntraMap). + int nin = getNin(); + int nout = getNout(); + if (nin != entry.nin && entry.nin != IntraRegistry.AST__ANY) { + throw Ast.err( + AstException.AST__BADNI, + "astLoadIntraMap(" + chan + "): The number of input coordinates for the IntraMap read (" + nin + + ") does not match the number used by the registered \"" + entry.name + + "\" transformation function (" + entry.nin + ")."); + } else if (nout != entry.nout && entry.nout != IntraRegistry.AST__ANY) { + throw Ast.err( + AstException.AST__BADNO, + "astLoadIntraMap(" + chan + "): The number of output coordinates for the IntraMap read (" + nout + + ") does not match the number used by the registered \"" + entry.name + + "\" transformation function (" + entry.nout + ")."); + } + trans = entry.trans; + flags = entry.flags; + purpose = entry.purpose; + author = entry.author; + contact = entry.contact; + } + + @Override + String dumpComment() { + return "Map points using a private transformation function"; + } + + /** + * Writes {@code Fname}, {@code Iflag}, {@code Purp}, {@code Auth} and {@code Cntact}, as C's + * {@code Dump} (intramap.c) does: {@code Iflag} is the IntraFlag value, written as a blank + * string when unset. + */ + @Override + void dump(NativeNode node) { + super.dump(node); + node.writeIsA("Mapping", "Mapping between coordinate systems"); + node.writeString("Fname", true, true, fname, "Name of transformation function"); + // jniast also stored a Java-serialised Transformer in IntraFlag for an IntraMap at the top + // level of an Object written; this library writes and reads an IntraMap by its function + // name only. + node.writeString( + "Iflag", + intraFlag != null, + false, + intraFlag != null ? intraFlag : "", + "IntraMap identification string"); + node.writeString("Purp", true, true, purpose, "Purpose of function"); + node.writeString("Auth", true, true, author, "Author's name"); + node.writeString("Cntact", true, true, contact, "Contact address"); + } + + // ------------------------------------------------------------------ + // Channelizing + // ------------------------------------------------------------------ + + /** + * Does nothing. It is present for jniast's API, in which it stored the serialised Transformer + * in the IntraFlag attribute before a write; an IntraMap is written with the name of its + * transformation function only, and needs no preparation. + * + * @throws IOException never + */ + @Override + public void channelize() throws IOException { + // An IntraMap is written by its function name, which needs no preparation. + } + + /** + * Does nothing. It is present for jniast's API, in which it recovered the serialised + * Transformer from the IntraFlag attribute after a read; an IntraMap read finds its + * Transformer by the name of its transformation function as it is loaded. + * + * @throws IOException never + */ + @Override + public void unChannelize() throws IOException { + // The loader has found the Transformer by its function name. + } + + // ------------------------------------------------------------------ + // Accessors + // ------------------------------------------------------------------ + + /** The name of the transformation function. */ + String getFname() { + return fname; + } + + /** The Transformer, shared with the IntraMap. */ + Transformer getTransformer() { + return trans; + } + + // ------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------ + + /** + * C's {@code SetIntraFlag}, an {@code astMAKE_SET1} attribute: a shared IntraMap refuses the + * change; setting it discards the record that the IntraMap has been simplified. + */ + private void storeIntraFlag(String value) { + checkSet1("IntraFlag"); + clearIsSimple(); + intraFlag = value; + } + + /** C's {@code ClearIntraFlag}, an {@code astMAKE_CLEAR1} attribute. */ + private void clearIntraFlag() { + checkClear1("IntraFlag"); + clearIsSimple(); + intraFlag = null; + } + + @Override + String getAttrib(String attrib) { + if ("intraflag".equals(attrib)) { + return intraFlag; + } + return super.getAttrib(attrib); + } + + @Override + void setAttrib(String attrib, String value) { + if ("intraflag".equals(attrib)) { + storeIntraFlag(value); + } else { + super.setAttrib(attrib, value); + } + } + + @Override + boolean testAttrib(String attrib) { + if ("intraflag".equals(attrib)) { + return intraFlag != null; + } + return super.testAttrib(attrib); + } + + @Override + void clearAttrib(String attrib) { + if ("intraflag".equals(attrib)) { + clearIntraFlag(); + } else { + super.clearAttrib(attrib); + } + } + + // ------------------------------------------------------------------ + // Transformation + // ------------------------------------------------------------------ + + /** + * intramap.c {@code Transform}: the Transformer is applied in the direction the Invert + * attribute makes of {@code forward}, as jniast's {@code tranWrap} (jni/IntraMap.c) calls it, + * with copies of the input coordinates. An exception from the Transformer, or a result that is + * null or holds fewer than the needed arrays or values, is AST__ITFER, whose cause is that + * exception or one describing the result. + */ + @Override + // Transformer.tranP is declared to throw any Exception; each one is the function's failure. + @SuppressWarnings("PMD.AvoidCatchingGenericException") + void transformInto(double[][] in, int npoint, boolean forward, double[][] out) { + validateTransformInto(in, npoint, forward, out); + int ncoordIn = forward ? getNin() : getNout(); + int ncoordOut = forward ? getNout() : getNin(); + double[][] jin = new double[ncoordIn][]; + for (int c = 0; c < ncoordIn; c++) { + jin[c] = Arrays.copyOf(in[c], npoint); + } + double[][] result; + try { + result = trans.tranP(npoint, ncoordIn, jin, effectiveForward(forward), ncoordOut); + } catch (Exception e) { + throw functionError(e); + } + RuntimeException bad = checkResult(result, ncoordOut, npoint); + if (bad != null) { + throw functionError(bad); + } + for (int c = 0; c < ncoordOut; c++) { + System.arraycopy(result[c], 0, out[c], 0, npoint); + } + } + + /** + * The exception jniast's {@code jniastCheckArrayLength} throws for a result that is null or + * holds fewer than {@code ncoordOut} arrays of at least {@code npoint} values, or null if the + * result is good. + */ + private static RuntimeException checkResult(double[][] result, int ncoordOut, int npoint) { + if (result == null) { + return new NullPointerException("Transformer returned null"); + } + if (result.length < ncoordOut) { + return new IllegalArgumentException( + "Transformer returned " + result.length + " coordinate arrays; " + ncoordOut + " are needed"); + } + for (int c = 0; c < ncoordOut; c++) { + if (result[c] == null) { + return new NullPointerException("Transformer returned a null coordinate array"); + } + if (result[c].length < npoint) { + return new IllegalArgumentException("Transformer returned a coordinate array of " + result[c].length + + " values; " + npoint + " are needed"); + } + } + return null; + } + + /** The error of intramap.c {@code Transform} for a failure of the function, with status AST__ITFER. */ + private AstException functionError(Exception cause) { + AstException err = Ast.err( + AstException.AST__ITFER, + "astTransform(" + astClass() + "): Error signalled by \"" + fname + "\" transformation function."); + err.initCause(cause); + return err; + } + + /** + * NaN protocol: the Transformer is given bad input values as {@link #AST__BAD}, as C gives + * them, and the bad values it returns become NaN. + */ + @Override + void transformIntoNan(double[][] in, int npoint, boolean forward, double[][] out) { + double[][] bad = new double[in.length][]; + for (int c = 0; c < in.length; c++) { + bad[c] = new double[npoint]; + for (int p = 0; p < npoint; p++) { + double v = in[c][p]; + bad[c][p] = Double.isNaN(v) ? AST__BAD : v; + } + } + super.transformIntoNan(bad, npoint, forward, out); + } + + // ------------------------------------------------------------------ + // Equality and simplification + // ------------------------------------------------------------------ + + /** + * intramap.c {@code Equal}: {@code that} is an IntraMap with the same numbers of inputs and + * outputs, the same Invert attribute and the same function, and an IntraFlag set on both and + * equal. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof IntraMap)) { + return false; + } + IntraMap other = (IntraMap) that; + return other.getNin() == getNin() + && other.getNout() == getNout() + && getInvert() == other.getInvert() + && fname.equals(other.fname) + && intraFlag != null + && intraFlag.equals(other.intraFlag); + } + + /** + * intramap.c {@code MapMerge}: in series, this IntraMap and the next Mapping, if that is an + * IntraMap of the same function with the same IntraFlag (an unset value reading as empty), + * become a UnitMap when together they keep the number of coordinates and the function's flags + * say that pair of directions is the identity: forward then inverse with SIMPFI, inverse then + * forward with SIMPIF. + */ + @Override + int mapMerge(MergeList list, int where, boolean series) { + if (!series || where + 1 >= list.size() || !(list.map(where + 1) instanceof IntraMap)) { + return -1; + } + IntraMap second = (IntraMap) list.map(where + 1); + String flag1 = intraFlag != null ? intraFlag : ""; + String flag2 = second.intraFlag != null ? second.intraFlag : ""; + if (!fname.equals(second.fname) || !flag1.equals(flag2)) { + return -1; + } + boolean invert1 = list.invert(where); + boolean invert2 = list.invert(where + 1); + int nin1 = invert1 ? createdNout() : createdNin(); + int nout2 = invert2 ? second.createdNin() : second.createdNout(); + if (nin1 != nout2) { + return -1; + } + boolean simpler; + if (!invert1 && invert2) { + simpler = (flags & IntraRegistry.SIMPFI) != 0; + } else if (invert1 && !invert2) { + simpler = (flags & IntraRegistry.SIMPIF) != 0; + } else { + simpler = false; + } + if (!simpler) { + return -1; + } + list.replacePairWith(where, new UnitMap(nin1), false); + return where; + } +} diff --git a/src/main/java/uk/ac/starlink/ast/IntraRegistry.java b/src/main/java/uk/ac/starlink/ast/IntraRegistry.java new file mode 100644 index 0000000..3013103 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/IntraRegistry.java @@ -0,0 +1,403 @@ +package uk.ac.starlink.ast; + +import java.lang.ref.Reference; +import java.lang.ref.ReferenceQueue; +import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; + +/** + * Tables of transformation functions by name, C's table of functions registered with {@code + * astIntraReg} (intramap.c {@code tran_data}, filled by {@code IntraReg}), from which an IntraMap + * read takes its Transformer. + * + *

There are two. A registry object holds the functions registered with one Channel ({@link + * Channel#registerIntra}), which the Channel lends to the IntraMap loader through a thread-local + * slot only while it reads ({@link #enter} and {@link #restore}), since the loader of an IntraMap + * nested in another Object sees only its own description. The process-wide table, like C's, holds + * the function of every IntraMap made in this process, as jniast's {@code construct} registers it, + * but holds each Transformer weakly, so that an entry lasts while its Transformer is reachable + * and lapses once it is garbage-collected. A read looks in the Channel's registry first and then in the process-wide table. + */ +final class IntraRegistry { + + /** C's {@code AST__ANY}: a function that accepts or produces any number of coordinates. */ + static final int AST__ANY = -66; + + /** C's {@code AST__NOFWD}: the function has no forward transformation. */ + static final int NOFWD = 1; + + /** C's {@code AST__NOINV}: the function has no inverse transformation. */ + static final int NOINV = 2; + + /** C's {@code AST__SIMPFI}: forward then inverse may be simplified away. */ + static final int SIMPFI = 4; + + /** C's {@code AST__SIMPIF}: inverse then forward may be simplified away. */ + static final int SIMPIF = 8; + + /** The registry of the Channel reading on this thread, while it reads. */ + private static final ThreadLocal READING = new ThreadLocal<>(); + + /** + * The process-wide table of the functions of the IntraMaps made in this process, by name: C's + * {@code tran_data} (intramap.c), which {@code astIntraReg} fills for the whole process. + */ + // Mutable static state, as intramap.c keeps its table of registered functions (tran_data) in + // static memory for the whole process. PMD's MutableStaticState rule does not flag a final + // field, so it needs no suppression. + private static final ConcurrentMap MADE = new ConcurrentHashMap<>(); + + /** + * For each name of the process-wide table that has had a suffix added ({@link #registerMade}), + * the largest suffix it has had. It only grows, so that a chain of names is searched to its + * end after an earlier name in it has been removed. + */ + private static final ConcurrentMap LONGEST = new ConcurrentHashMap<>(); + + /** The references of {@link #MADE} whose Transformers have been collected. */ + private static final ReferenceQueue CLEARED = new ReferenceQueue<>(); + + /** + * An entry of the process-wide table: a registered function with its Transformer held weakly. + */ + private static final class Made extends WeakReference { + final String name; + final int nin; + final int nout; + final int flags; + final String purpose; + final String author; + final String contact; + + Made(Entry e) { + super(e.trans, CLEARED); + name = e.name; + nin = e.nin; + nout = e.nout; + flags = e.flags; + purpose = e.purpose; + author = e.author; + contact = e.contact; + } + + /** The entry, with the Transformer {@code held}. */ + Entry entry(Transformer held) { + return new Entry(name, nin, nout, held, flags, purpose, author, contact); + } + } + + /** A registered function, as C's {@code AstIntraMapTranData} holds it. */ + static final class Entry { + final String name; + final int nin; + final int nout; + final Transformer trans; + final int flags; + final String purpose; + final String author; + final String contact; + + /** + * The entry for {@code trans}, its flags and strings read from it in the order jniast's + * {@code construct} reads them. + */ + Entry(String name, int nin, int nout, Transformer trans) { + this.name = name; + this.nin = nin; + this.nout = nout; + this.trans = trans; + this.flags = flagsOf(trans); + this.purpose = text(trans.getPurpose()); + this.contact = text(trans.getContact()); + this.author = text(trans.getAuthor()); + } + + Entry( + String name, + int nin, + int nout, + Transformer trans, + int flags, + String purpose, + String author, + String contact) { + this.name = name; + this.nin = nin; + this.nout = nout; + this.trans = trans; + this.flags = flags; + this.purpose = purpose; + this.author = author; + this.contact = contact; + } + + /** This entry under the name {@code newName}. */ + Entry renamed(String newName) { + return new Entry(newName, nin, nout, trans, flags, purpose, author, contact); + } + + /** Whether this entry registers {@code t}. */ + // The same Transformer, not an equal one. + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) + boolean sameTransformer(Transformer t) { + return trans == t; + } + + /** Whether this entry and {@code o} register the same function, as C's IntraReg compares them. */ + // C compares the function pointers: the same Transformer, not an equal one. + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) + boolean sameAs(Entry o) { + return nin == o.nin + && nout == o.nout + && trans == o.trans + && flags == o.flags + && purpose.equals(o.purpose) + && author.equals(o.author) + && contact.equals(o.contact); + } + } + + private final List entries = new ArrayList<>(); + + /** A copy of this registry, holding the same registrations. */ + IntraRegistry copy() { + IntraRegistry out = new IntraRegistry(); + out.entries.addAll(entries); + return out; + } + + /** + * The flags C's {@code astIntraReg} is given for {@code trans}, as jniast makes them from the + * Transformer (jni/IntraMap.c {@code construct}). + */ + static int flagsOf(Transformer trans) { + int flags = 0; + if (!trans.hasForward()) { + flags |= NOFWD; + } + if (!trans.hasInverse()) { + flags |= NOINV; + } + if (trans.simpFI()) { + flags |= SIMPFI; + } + if (trans.simpIF()) { + flags |= SIMPIF; + } + return flags; + } + + /** A description string of a Transformer, empty when it gives null, as jniast passes it. */ + static String text(String s) { + return s == null ? "" : s; + } + + /** + * {@code name} with all white space removed, as intramap.c {@code CleanName} makes it. + * + * @throws AstException with status {@code AST__ITFNI} if the name is entirely blank + */ + static String cleanName(String name, String caller) { + StringBuilder sb = new StringBuilder(name.length()); + for (int i = 0; i < name.length(); i++) { + char c = name.charAt(i); + if (!CScan.isCSpace(c)) { + sb.append(c); + } + } + if (sb.length() == 0) { + throw Ast.err(AstException.AST__ITFNI, caller + ": Invalid blank transformation function name given."); + } + return sb.toString(); + } + + /** + * Registers {@code trans} under {@code name}, as intramap.c {@code IntraReg} does. White space + * in the name is removed; the name is case-sensitive. Registering the same function again with + * the same details has no effect. + * + * @param nin the number of input coordinates, or {@link #AST__ANY} + * @param nout the number of output coordinates, or {@link #AST__ANY} + * @throws AstException with status {@code AST__ITFNI} if the name is blank, {@code AST__BADNI} + * or {@code AST__BADNO} if a number of coordinates is negative and not {@link #AST__ANY}, + * or {@code AST__MRITF} if the name is registered with different details + */ + void register(String name, int nin, int nout, Transformer trans) { + Objects.requireNonNull(trans, "trans"); + String clname = cleanName(name, "astIntraReg"); + if (nin < 0 && nin != AST__ANY) { + throw Ast.err( + AstException.AST__BADNI, + "astIntraReg(" + clname + "): Bad number of input coordinates (" + nin + + ").\nThis number should be zero or more (or AST__ANY)."); + } else if (nout < 0 && nout != AST__ANY) { + throw Ast.err( + AstException.AST__BADNO, + "astIntraReg(" + clname + "): Bad number of output coordinates (" + nout + + ").\nThis number should be zero or more (or AST__ANY)."); + } + Entry entry = new Entry(clname, nin, nout, trans); + Entry found = find(clname); + if (found == null) { + entries.add(entry); + } else if (!found.sameAs(entry)) { + throw Ast.err( + AstException.AST__MRITF, + "astIntraReg: Invalid attempt to register the transformation function name \"" + clname + + "\" multiple times."); + } + } + + /** The function registered under exactly {@code name}, or null. */ + Entry find(String name) { + for (Entry e : entries) { + if (e.name.equals(name)) { + return e; + } + } + return null; + } + + /** + * Makes {@code registry} the one the IntraMap loader consults on this thread, as a Channel + * does for the duration of a read. + * + * @param registry the registry, or null for none + * @return the registry it replaces, to be given to {@link #restore} + */ + static IntraRegistry enter(IntraRegistry registry) { + IntraRegistry previous = READING.get(); + READING.set(registry); + return previous; + } + + /** Restores the registry {@link #enter} replaced. */ + static void restore(IntraRegistry previous) { + if (previous == null) { + READING.remove(); + } else { + READING.set(previous); + } + } + + /** + * Registers {@code trans}, the Transformer of an IntraMap being made, in the process-wide table, + * as jniast's {@code construct} registers it with {@code astIntraReg}. The name is the one of + * {@code name}, {@code name#1}, {@code name#2}, ... that already holds {@code trans}, if any + * does, so that every IntraMap of one Transformer has one name; otherwise it is the first of + * them that is free or held by a Transformer that has been garbage-collected. Held by {@code + * trans} with other details (numbers of coordinates, flags or strings), it is AST__MRITF, as + * C's {@code IntraReg} reports a function registered again with different details. + * + *

The names come from identity hash codes, which two reachable Transformers may share; C's + * names are chosen by its callers, and its {@code IntraReg} refuses a name held by another + * function. A new name is chosen here instead, so that making an IntraMap does not fail + * because of a shared hash code. + * + * @return the entry for {@code trans}, with the name it is registered under + * @throws AstException with status {@code AST__MRITF} if {@code trans} is registered under the + * name with different details + */ + // The same Transformer, not an equal one. + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) + static Entry registerMade(String name, int nin, int nout, Transformer trans) { + purge(); + Entry first = new Entry(name, nin, nout, trans); + // A name of the chain may be free while a later one holds trans, so every name up to the + // longest the chain has had is looked at. + int longest = LONGEST.getOrDefault(name, 0); + for (int k = 0; k <= longest; k++) { + Made m = MADE.get(chainName(name, k)); + if (m != null && m.get() == trans) { + Entry e = claim(first.renamed(chainName(name, k)), trans); + if (e != null) { + return e; + } + } + } + for (int k = 0; ; k++) { + Entry e = claim(k == 0 ? first : first.renamed(chainName(name, k)), trans); + if (e != null) { + if (k > 0) { + LONGEST.merge(name, k, Math::max); + } + return e; + } + } + } + + /** Name {@code k} of the chain of names starting at {@code name}: {@code name}, {@code name#1}, ... */ + private static String chainName(String name, int k) { + return k == 0 ? name : name + "#" + k; + } + + /** + * Registers {@code trans} under {@code entry}'s name if that is free, held by a Transformer that + * has been garbage-collected, or held by {@code trans} with the same details. + * + * @return {@code entry}, or null if another reachable Transformer holds the name + * @throws AstException with status {@code AST__MRITF} if {@code trans} holds the name with other + * details + */ + private static Entry claim(Entry entry, Transformer trans) { + boolean[] other = new boolean[1]; + MADE.compute(entry.name, (key, old) -> { + Transformer held = old == null ? null : old.get(); + if (held == null) { + return new Made(entry); + } + if (!old.entry(held).sameTransformer(trans)) { + other[0] = true; + return old; + } + if (!old.entry(held).sameAs(entry)) { + throw Ast.err( + AstException.AST__MRITF, + "astIntraReg: Invalid attempt to register the transformation function name \"" + entry.name + + "\" multiple times."); + } + return old; + }); + return other[0] ? null : entry; + } + + /** + * Makes the entry of the process-wide table under {@code name} lapse, as when its Transformer is + * garbage-collected: the reference is cleared and queued for removal. + */ + static void lapse(String name) { + Made m = MADE.get(name); + if (m != null) { + m.clear(); + m.enqueue(); + } + } + + /** Removes the entries of the process-wide table whose Transformers have been collected. */ + private static void purge() { + for (Reference r = CLEARED.poll(); r != null; r = CLEARED.poll()) { + Made m = (Made) r; + MADE.remove(m.name, m); + } + } + + /** + * The function registered under {@code name} with the Channel reading on this thread, or else + * in the process-wide table by an IntraMap made with a Transformer not yet garbage-collected, + * or null. + */ + static Entry lookup(String name) { + IntraRegistry reg = READING.get(); + Entry e = reg == null ? null : reg.find(name); + if (e != null) { + return e; + } + Made m = MADE.get(name); + Transformer held = m == null ? null : m.get(); + return held == null ? null : m.entry(held); + } +} diff --git a/src/main/java/uk/ac/starlink/ast/LutMap.java b/src/main/java/uk/ac/starlink/ast/LutMap.java new file mode 100644 index 0000000..6c90a39 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/LutMap.java @@ -0,0 +1,721 @@ +package uk.ac.starlink.ast; + +/** + * A Mapping which transforms 1-dimensional coordinates by interpolating in a lookup table. + * + *

Each input coordinate value is first scaled to give the index of an entry in the table by + * subtracting a starting value (the input coordinate corresponding to the first table entry) and + * dividing by an increment (the difference in input coordinate value between adjacent table + * entries). + * + *

The resulting index will usually contain a fractional part, so the output coordinate value is + * then generated by interpolating linearly between the appropriate entries in the table. If the + * index lies outside the range of the table, linear extrapolation is used based on the two nearest + * entries (the two entries at the start or end of the table, as appropriate). If either of the + * entries used for the interpolation is bad, the interpolated value is bad. + * + *

If the lookup table entries increase or decrease monotonically (ignoring any flat sections + * and bad entries), then the inverse transformation may also be performed. It gives a bad value + * for a value within a flat section of the table, or between two entries that were both next to + * a bad entry. + * + *

The LutInterp attribute (an integer, default 0) selects the interpolation method: 0 for + * linear interpolation, anything else for the nearest table entry, which makes an input outside + * the table bad. The LutEpsilon attribute (default {@code DBL_EPSILON}) is the relative error of the + * table values, which decides whether simplification replaces a nearly linear LutMap with a + * WinMap. Both are read and changed through the generic attribute methods, such as {@link + * #setI}, and neither can be changed once the LutMap is held by another Object, such as a CmpMap. + * + *

A LutMap keeps the last input value it transformed in each direction, and the result, and + * gives that result again for the same input, even after LutInterp has changed, as C's does. + * + *

Ported from Rust {@code mappings/lutmap.rs} and C {@code lutmap.c}. + */ +public class LutMap extends Mapping { + + /** LutInterp's value for linear interpolation, C's {@code LINEAR}. */ + private static final int LINEAR = 0; + + /** LutInterp's value for the nearest table entry, C's {@code NEAR}. */ + private static final int NEAR = 1; + + /** The value C stores while LutInterp is unset, {@code -INT_MAX}. */ + private static final int UNSET_INTERP = -Integer.MAX_VALUE; + + /** C's {@code DBL_EPSILON}, LutEpsilon's default. */ + private static final double DBL_EPSILON = Math.ulp(1.0); + + /** The lookup table, a value that is not finite stored as {@link #AST__BAD}. */ + private double[] lut; + + /** The input coordinate of the first table entry. */ + private double start; + + /** The increment in input coordinate between adjacent table entries. */ + private double inc; + + /** The LutInterp attribute, {@link #UNSET_INTERP} while unset. */ + private int lutInterp; + + /** The LutEpsilon attribute, {@link #AST__BAD} while unset. */ + private double lutEpsilon = AST__BAD; + + /** + * The table the inverse transformation searches when {@link #lut} has bad entries: its good + * values in order (C's {@code luti}), or null when it has none. + */ + private double[] luti; + + /** Whether each value of {@link #luti} was next to a bad entry of {@link #lut} (C's {@code flagsi}). */ + private boolean[] flagsi; + + /** The index in {@link #lut} of each value of {@link #luti} (C's {@code indexi}). */ + private int[] indexi; + + /** The last input value transformed forward, C's {@code last_fwd_in}. */ + private double lastFwdIn = AST__BAD; + + /** The output for {@link #lastFwdIn}, C's {@code last_fwd_out}. */ + private double lastFwdOut = AST__BAD; + + /** The last input value transformed in the inverse direction, C's {@code last_inv_in}. */ + private double lastInvIn = AST__BAD; + + /** The output for {@link #lastInvIn}, C's {@code last_inv_out}. */ + private double lastInvOut = AST__BAD; + + /** + * Creates a LutMap. + * + * @param lut an array containing the lookup table entries; there must be at least two. An + * entry that is not finite is stored as {@link #AST__BAD} + * @param start the input coordinate value which corresponds to the first lookup table entry + * @param inc the lookup table spacing (the increment in input coordinate value between + * successive lookup table entries); this value may be positive or negative, but must not be + * zero + * @throws AstException with status {@code AST__LUTIN} if {@code lut} has fewer than two + * entries, or {@code AST__LUTII} if {@code inc} is zero + */ + public LutMap(double[] lut, double start, double inc) { + this(Table.checked(lut, inc), start, inc); + } + + /** C's {@code astInitLutMap}, once the arguments are checked and the table's monotonicity found. */ + private LutMap(Table table, double start, double inc) { + super(1, 1, true, table.dirn != 0); + this.lut = table.lut; + this.start = start; + this.inc = inc; + this.lutInterp = LINEAR; + this.luti = table.luti; + this.flagsi = table.flagsi; + this.indexi = table.indexi; + } + + /** + * Loads a LutMap from its description, as C's {@code astLoadLutMap} does: the number of + * entries (default 2), the start (default 0) and increment (default 1), LutInterp and + * LutEpsilon, each re-applied through its setter when set, and each entry, a missing one being + * {@link #AST__BAD}. Whether the inverse is defined is the Mapping's {@code Inv} item, not the + * table's monotonicity. + */ + LutMap(NativeNode node) { + super(node); + NativeNode part = node.section("LutMap"); + // A negative count gives an empty table, as the loaders of other classes treat a negative + // count of their items. + int nlut = Math.max(0, part.readInt("Nlut", 2)); + start = part.readDouble("Start", 0.0); + inc = part.readDouble("Incr", 1.0); + lutInterp = part.readInt("LutInt", LINEAR); + if (testLutInterp()) { + storeLutInterp(lutInterp); + } + lutEpsilon = part.readDouble("LutEps", AST__BAD); + if (testLutEpsilon()) { + storeLutEpsilon(lutEpsilon); + } + lut = new double[nlut]; + for (int ilut = 0; ilut < nlut; ilut++) { + lut[ilut] = part.readDouble("L" + (ilut + 1), AST__BAD); + } + Table table = Table.getMonotonic(lut); + luti = table.luti; + flagsi = table.flagsi; + indexi = table.indexi; + } + + /** + * A lookup table and what C's {@code GetMonotonic} finds in it: whether its good values + * increase (+1) or decrease (-1) monotonically, ignoring runs of equal values, or neither (0) + * (C's {@code dirn}), and the table the inverse transformation searches when it has bad + * entries. + */ + private static final class Table { + final double[] lut; + final int dirn; + final double[] luti; + final boolean[] flagsi; + final int[] indexi; + + private Table(double[] lut, int dirn, double[] luti, boolean[] flagsi, int[] indexi) { + this.lut = lut; + this.dirn = dirn; + this.luti = luti; + this.flagsi = flagsi; + this.indexi = indexi; + } + + /** + * The table {@code lut}, copied with each value that is not finite stored as {@link + * #AST__BAD}, after C's checks in {@code astInitLutMap}. + */ + static Table checked(double[] lut, double inc) { + int nlut = lut.length; + if (nlut < 2) { + throw Ast.err( + AstException.AST__LUTIN, + "astInitLutMap(LutMap): Invalid number of lookup table elements (" + nlut + + ").\nThis value should be at least 2."); + } else if (inc == 0.0) { + throw Ast.err( + AstException.AST__LUTII, + "astInitLutMap(LutMap): An input value increment of zero between lookup table elements" + + " is not allowed."); + } + double[] copy = new double[nlut]; + for (int ilut = 0; ilut < nlut; ilut++) { + copy[ilut] = Double.isFinite(lut[ilut]) ? lut[ilut] : AST__BAD; + } + return getMonotonic(copy); + } + + /** + * C's {@code GetMonotonic} of {@code lut}, whose bad values are {@link #AST__BAD} (C tests + * the table as supplied, with {@code astISBAD}, which takes a value that is not finite to + * be bad, so the result is the same). + */ + static Table getMonotonic(double[] lut) { + int nlut = lut.length; + int result = 0; + double lval = AST__BAD; + int nbad = 0; + for (int ilut = 0; ilut < nlut; ilut++) { + double v = lut[ilut]; + if (!isBad(v)) { + if (lval == AST__BAD) { + lval = v; + } else if (v != lval) { + if (result == 0) { + result = v > lval ? 1 : -1; + } else if (result == 1 && v < lval) { + result = 0; + break; + } else if (result == -1 && v > lval) { + result = 0; + break; + } + lval = v; + } + } else { + nbad++; + } + } + if (nbad == 0) { + return new Table(lut, result, null, null, null); + } + // C stops counting at a break, so the number of good values is counted again here. + int nluti = 0; + for (double v : lut) { + if (!isBad(v)) { + nluti++; + } + } + // C sizes its arrays from the bad values it counted before any break, so after a break + // they are longer than the good values; only the good values are ever read. + double[] luti = new double[nluti]; + boolean[] flagsi = new boolean[nluti]; + int[] indexi = new int[nluti]; + int k = 0; + for (int ilut = 0; ilut < nlut; ilut++) { + if (!isBad(lut[ilut])) { + luti[k] = lut[ilut]; + boolean below = ilut > 0 && isBad(lut[ilut - 1]); + boolean above = ilut < nlut - 1 && isBad(lut[ilut + 1]); + flagsi[k] = below || above; + indexi[k] = ilut; + k++; + } + } + return new Table(lut, result, luti, flagsi, indexi); + } + } + + @Override + String dumpComment() { + return "Map 1-d coordinates using a lookup table"; + } + + /** + * Writes the number of entries, the start and increment (written as comments at their defaults + * of 0 and 1), LutInterp (a comment when unset), LutEpsilon (only when set) and each entry that + * is not bad, as C's {@code Dump} (lutmap.c) does. + */ + @Override + void dump(NativeNode node) { + super.dump(node); + node.writeIsA("Mapping", "Mapping between coordinate systems"); + int nlut = lut.length; + node.writeInt("Nlut", true, true, nlut, "Number of lookup table elements"); + node.writeDouble("Start", start != 0.0, true, start, "Input value at first element"); + node.writeDouble("Incr", inc != 1.0, true, inc, "Input value increment between elements"); + node.writeInt("LutInt", testLutInterp(), true, getLutInterp(), "Interpolation method"); + if (testLutEpsilon()) { + node.writeDouble("LutEps", true, true, getLutEpsilon(), "Table relative error"); + } + for (int ilut = 0; ilut < nlut; ilut++) { + if (lut[ilut] != AST__BAD) { + node.writeDouble("L" + (ilut + 1), true, true, lut[ilut], ilut != 0 ? "" : "Lookup table elements..."); + } + } + } + + /** Gives the copy its own tables, as C's {@code Copy} (lutmap.c) does. */ + @Override + void deepCopy() { + super.deepCopy(); + lut = lut.clone(); + if (luti != null) { + luti = luti.clone(); + flagsi = flagsi.clone(); + indexi = indexi.clone(); + } + } + + // ------------------------------------------------------------------ + // The table, as C's astGetLutMapInfo gives it + // ------------------------------------------------------------------ + + /** A copy of the lookup table, with {@link #AST__BAD} for each bad entry. */ + double[] lutTable() { + return lut.clone(); + } + + /** The input coordinate of the first table entry. */ + double lutStart() { + return start; + } + + /** The increment in input coordinate between adjacent table entries. */ + double lutInc() { + return inc; + } + + // ------------------------------------------------------------------ + // LutInterp and LutEpsilon + // ------------------------------------------------------------------ + + /** The LutInterp attribute: 0 for linear interpolation, 1 for the nearest entry. Default 0. */ + int getLutInterp() { + return lutInterp == UNSET_INTERP ? LINEAR : lutInterp; + } + + /** + * C's private {@code SetLutInterp}, an {@code astMAKE_SET1} attribute: a shared LutMap refuses + * the change; any value but 0 is stored as 1; a value different from the one held discards the + * record that the LutMap has been simplified. + */ + private void storeLutInterp(int value) { + checkSet1("LutInterp"); + int v = value == LINEAR ? LINEAR : NEAR; + if (v != lutInterp) { + clearIsSimple(); + } + lutInterp = v; + } + + /** Whether LutInterp is set. */ + private boolean testLutInterp() { + return lutInterp != UNSET_INTERP; + } + + /** Clears LutInterp, discarding the record of simplification ({@code astMAKE_CLEAR1}). */ + private void clearLutInterp() { + checkClear1("LutInterp"); + clearIsSimple(); + lutInterp = UNSET_INTERP; + } + + /** The LutEpsilon attribute: the relative error of the table values. Default {@code DBL_EPSILON}. */ + double getLutEpsilon() { + return lutEpsilon == AST__BAD ? DBL_EPSILON : lutEpsilon; + } + + /** + * C's private {@code SetLutEpsilon}, an {@code astMAKE_SET1} attribute: a shared LutMap refuses + * the change; a value different from the one held (unset being {@link #AST__BAD}) discards the + * record that the LutMap has been simplified. {@link #AST__BAD} leaves the attribute unset. + */ + private void storeLutEpsilon(double value) { + checkSet1("LutEpsilon"); + if (value != lutEpsilon) { + clearIsSimple(); + } + lutEpsilon = value; + } + + /** Whether LutEpsilon is set. */ + private boolean testLutEpsilon() { + return lutEpsilon != AST__BAD; + } + + /** Clears LutEpsilon, discarding the record of simplification ({@code astMAKE_CLEAR1}). */ + private void clearLutEpsilon() { + checkClear1("LutEpsilon"); + clearIsSimple(); + lutEpsilon = AST__BAD; + } + + @Override + String getAttrib(String attrib) { + if ("lutinterp".equals(attrib)) { + return Integer.toString(getLutInterp()); + } else if ("lutepsilon".equals(attrib)) { + return CFormat.format("%.17g", getLutEpsilon()); + } + return super.getAttrib(attrib); + } + + @Override + void setAttrib(String attrib, String value) { + Integer ival = CScan.scanInt(value); + Double dval = CScan.scanDouble(value); + if ("lutinterp".equals(attrib) && ival != null) { + storeLutInterp(ival); + } else if ("lutepsilon".equals(attrib) && dval != null) { + storeLutEpsilon(dval); + } else { + super.setAttrib(attrib, value); + } + } + + @Override + boolean testAttrib(String attrib) { + if ("lutinterp".equals(attrib)) { + return testLutInterp(); + } else if ("lutepsilon".equals(attrib)) { + return testLutEpsilon(); + } + return super.testAttrib(attrib); + } + + @Override + void clearAttrib(String attrib) { + if ("lutinterp".equals(attrib)) { + clearLutInterp(); + } else if ("lutepsilon".equals(attrib)) { + clearLutEpsilon(); + } else { + super.clearAttrib(attrib); + } + } + + // ------------------------------------------------------------------ + // Equality and simplification + // ------------------------------------------------------------------ + + /** + * lutmap.c {@code Equal}: {@code that} is a LutMap with the same Invert attribute, start and + * increment (to within {@code astEQUAL}), number of entries and LutInterp value as stored, + * unset included, and entries equal to within {@code astEQUAL}. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof LutMap)) { + return false; + } + LutMap other = (LutMap) that; + if (other.getNin() != getNin() || other.getNout() != getNout()) { + return false; + } + // A LutMap and an inverted one are never equal. + if (getInvert() != other.getInvert()) { + return false; + } + if (!MappingHelpers.astEqual(start, other.start) + || !MappingHelpers.astEqual(inc, other.inc) + || lut.length != other.lut.length + || lutInterp != other.lutInterp) { + return false; + } + for (int i = 0; i < lut.length; i++) { + if (!MappingHelpers.astEqual(lut[i], other.lut[i])) { + return false; + } + } + return true; + } + + /** + * Whether the table is linear, C's {@code GetLinear} (lutmap.c): never for nearest-neighbour + * interpolation, because of the discontinuities at the ends of the table; always when every + * entry is the same; and otherwise when every entry lies within twice a tolerance of the + * straight line between the first and last, the tolerance being LutEpsilon times the larger of + * the range of the entries and the size of the value on the line. + */ + private boolean getLinear() { + boolean linear = false; + if (getLutInterp() != NEAR) { + int nlut = lut.length; + double lo = Double.MAX_VALUE; + double hi = -Double.MAX_VALUE; + for (int ilut = 0; ilut < nlut; ilut++) { + if (lut[ilut] > hi) { + hi = lut[ilut]; + } + if (lut[ilut] < lo) { + lo = lut[ilut]; + } + } + linear = hi == lo; + if (!linear) { + double eps = getLutEpsilon(); + double tol1 = Math.abs(hi - lo) * eps; + linear = true; + for (int ilut = 1; ilut < nlut - 1; ilut++) { + double fract = ilut / (nlut - 1.0); + double interp = lut[0] * (1.0 - fract) + lut[nlut - 1] * fract; + double tol2 = Math.abs(interp) * eps; + double tol = tol1 > tol2 ? tol1 : tol2; + linear = Math.abs(lut[ilut] - interp) <= 2.0 * tol; + if (!linear) { + break; + } + } + } + } + return linear; + } + + /** + * lutmap.c {@code MapMerge}. A linear LutMap whose first and last entries differ is replaced by + * the WinMap between the corners of its table, applied forward. A LutMap that is not linear, + * in series, cancels with the LutMap after it or, failing that, before it, when C's {@code + * astEqual} finds the nominated LutMap, with its own Invert attribute, equal to the inverse of + * the neighbour applied as the list says: the pair is replaced by a UnitMap. The index + * returned is that of the nominated LutMap, even when the pair began before it. + */ + @Override + int mapMerge(MergeList list, int where, boolean series) { + int result = -1; + LutMap map = (LutMap) list.map(where); + boolean simpler = map.getLinear(); + if (simpler) { + int nlut = map.lut.length; + double a1 = map.start; + double a2 = map.start + map.inc * (nlut - 1); + double b1 = map.lut[0]; + double b2 = map.lut[nlut - 1]; + if (b1 != b2) { + Mapping replacement; + if (!list.invert(where)) { + replacement = + new WinMap(1, new double[] {a1}, new double[] {a2}, new double[] {b1}, new double[] {b2}); + } else { + replacement = + new WinMap(1, new double[] {b1}, new double[] {b2}, new double[] {a1}, new double[] {a2}); + } + list.set(where, replacement, false); + result = where; + } + } else if (series) { + LutMap neb = null; + boolean invneb = false; + int ilo = -1; + if (where < list.size() - 1 && list.map(where + 1) instanceof LutMap) { + neb = (LutMap) list.map(where + 1); + invneb = list.invert(where + 1); + ilo = where; + } else if (where > 0 && list.map(where - 1) instanceof LutMap) { + neb = (LutMap) list.map(where - 1); + invneb = list.invert(where - 1); + ilo = where - 1; + } + if (neb != null) { + // C sets the neighbour's Invert attribute to its value in the list, inverts it, + // compares, and sets the attribute back to the value it had. + boolean oldInv = neb.getInvert(); + neb.setInvert(invneb); + neb.invert(); + boolean equal = map.astEqual(neb); + neb.setInvert(oldInv); + if (equal) { + list.replacePairWith(ilo, new UnitMap(1), false); + result = where; + } + } + } + return result; + } + + // ------------------------------------------------------------------ + // Transformation + // ------------------------------------------------------------------ + + @Override + void transformInto(double[][] in, int npoint, boolean forward, double[][] out) { + validateTransformInto(in, npoint, forward, out); + // Where C tests an input for AST__BAD, isBad also takes NaN and the infinities to be bad, + // the library's rule for values that are not finite. + if (effectiveForward(forward)) { + forwardInto(in[0], npoint, out[0]); + } else { + inverseInto(in[0], npoint, out[0]); + } + } + + /** + * The forward transformation of lutmap.c {@code Transform}: an input equal to the last one + * transformed forward gives the output kept for it; otherwise the input is scaled to a table + * index, and the output is the nearest entry (bad outside the table) or interpolated linearly, + * extrapolating from the two end entries outside the table; an interpolation using a bad entry + * is bad. + */ + private void forwardInto(double[] xin, int npoint, double[] xout) { + double[] table = lut; + int nlut = table.length; + boolean near = getLutInterp() == NEAR; + int nlutm1 = nlut - 1; + double scale = 1.0 / inc; + for (int point = 0; point < npoint; point++) { + double valueIn = xin[point]; + double valueOut; + if (valueIn == lastFwdIn) { + valueOut = lastFwdOut; + } else if (isBad(valueIn)) { + valueOut = AST__BAD; + } else if (near) { + double x = (valueIn - start) * scale; + double xi = Math.floor(x + 0.5); + int ix = (int) xi; + valueOut = ix < 0 || ix >= nlut ? AST__BAD : table[ix]; + } else { + double x = (valueIn - start) * scale; + double xi = Math.floor(x); + int ix = (int) xi; + if (ix < 0) { + if (table[0] != AST__BAD && table[1] != AST__BAD) { + valueOut = table[0] + x * (table[1] - table[0]); + } else { + valueOut = AST__BAD; + } + } else if (ix >= nlutm1) { + if (table[nlutm1] != AST__BAD && table[nlut - 2] != AST__BAD) { + valueOut = table[nlutm1] + (x - nlutm1) * (table[nlutm1] - table[nlut - 2]); + } else { + valueOut = AST__BAD; + } + } else { + if (table[ix] != AST__BAD && table[ix + 1] != AST__BAD) { + double fract = x - xi; + valueOut = table[ix] * (1.0 - fract) + table[ix + 1] * fract; + } else { + valueOut = AST__BAD; + } + } + } + xout[point] = valueOut; + lastFwdIn = valueIn; + lastFwdOut = valueOut; + } + } + + /** + * The inverse transformation of lutmap.c {@code Transform}, over the table with its bad entries + * removed when it has any: an input equal to the last one transformed in this direction gives + * the output kept for it; otherwise a bisection finds the pair of adjacent entries bracketing + * the value ({@code i1} being -1 for a value beyond the first entry). A value within a flat run + * of the table, or between two entries that were both next to a bad entry, is bad. The output + * is the input coordinate of the nearer entry (bad outside the table), or interpolated linearly + * between the pair, extrapolating from the first or last pair outside the table. + */ + private void inverseInto(double[] xin, int npoint, double[] xout) { + double[] table; + boolean[] flags; + int[] index; + if (luti != null) { + table = luti; + flags = flagsi; + index = indexi; + } else { + table = lut; + flags = null; + index = null; + } + int nlut = table.length; + boolean near = getLutInterp() == NEAR; + int nlutm1 = nlut - 1; + for (int point = 0; point < npoint; point++) { + double valueIn = xin[point]; + double valueOut; + if (valueIn == lastInvIn) { + valueOut = lastInvOut; + } else if (isBad(valueIn)) { + valueOut = AST__BAD; + } else { + boolean up = table[nlutm1] > table[0]; + int i1 = -1; + int i2 = nlutm1; + while (i2 > i1 + 1) { + int i = (i1 + i2) / 2; + if ((valueIn >= table[i]) == up) { + i1 = i; + } else { + i2 = i; + } + } + boolean ok = true; + if (i1 >= 0 && table[i1] == valueIn) { + if (i1 > 0 && table[i1 - 1] == valueIn) { + ok = false; + } + if (table[i2] == valueIn) { + ok = false; + } + } else if (table[i2] == valueIn && i2 < nlutm1 && table[i2 + 1] == valueIn) { + ok = false; + } + if (!ok) { + valueOut = AST__BAD; + } else if (flags != null && i1 >= 0 && flags[i1] && flags[i2]) { + valueOut = AST__BAD; + } else if (near) { + double d2 = table[i2] - valueIn; + double d1 = i1 >= 0 ? table[i1] - valueIn : d2; + if (i1 < 0 && d2 == 0.0) { + int istart = index != null ? index[i2] : i2; + valueOut = start + inc * istart; + } else if ((d1 > 0.0 && d2 > 0.0) || (d1 < 0.0 && d2 < 0.0)) { + valueOut = AST__BAD; + } else { + int inear = Math.abs(d1) < Math.abs(d2) ? i1 : i2; + int istart = index != null ? index[inear] : inear; + valueOut = start + inc * istart; + } + } else { + if (i1 < 0) { + i1 = 0; + } + if (i1 > nlut - 2) { + i1 = nlut - 2; + } + int istart = index != null ? index[i1] : i1; + valueOut = start + inc * (istart + ((valueIn - table[i1]) / (table[i1 + 1] - table[i1]))); + } + } + xout[point] = valueOut; + lastInvIn = valueIn; + lastInvOut = valueOut; + } + } +} diff --git a/src/main/java/uk/ac/starlink/ast/Mapping.java b/src/main/java/uk/ac/starlink/ast/Mapping.java index c80fc33..3060be8 100644 --- a/src/main/java/uk/ac/starlink/ast/Mapping.java +++ b/src/main/java/uk/ac/starlink/ast/Mapping.java @@ -399,6 +399,47 @@ boolean isLinear() { return false; } + /** + * mapping.c {@code Equal}: every concrete Mapping class compares Mappings in its own way, so + * reaching this for two Mappings of the same class, which the base Object class's {@code + * Equal} finds equivalent, is an internal error. + * + * @throws AstException with status {@code AST__INTER} if {@code that} is of this Mapping's + * class + */ + @Override + boolean equalTo(AstObject that) { + if (super.equalTo(that)) { + throw Ast.err( + AstException.AST__INTER, + "astEqual(Mapping): The " + astClass() + " class does not override the abstract astEqual method " + + "inherited from the base Mapping class (internal AST programming error)."); + } + return false; + } + + /** + * The Invert attributes of {@code a} and {@code b}, each as {@link #swapInvert} returns it, + * after setting them to {@code invertA} and {@code invertB} in that order, as C's {@code Equal} + * functions do with {@code astGetInvert} and {@code astSetInvert} before comparing two Mappings + * in given orientations; {@link #restoreInverts} puts them back in the same order. + */ + static int[] swapInverts(Mapping a, boolean invertA, Mapping b, boolean invertB) { + int savedA = a.swapInvert(invertA); + int savedB = b.swapInvert(invertB); + return new int[] {savedA, savedB}; + } + + /** + * Puts back the Invert attributes {@link #swapInverts} returned, {@code a}'s first, as C's + * {@code Equal} functions restore them, so that when {@code a} and {@code b} are the same object + * it is left with the value {@code swapInverts} gave {@code a}. + */ + static void restoreInverts(Mapping a, Mapping b, int[] saved) { + a.restoreInvert(saved[0]); + b.restoreInvert(saved[1]); + } + // ------------------------------------------------------------------ // Report // ------------------------------------------------------------------ diff --git a/src/main/java/uk/ac/starlink/ast/MathMap.java b/src/main/java/uk/ac/starlink/ast/MathMap.java new file mode 100644 index 0000000..4c0ba98 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/MathMap.java @@ -0,0 +1,840 @@ +package uk.ac.starlink.ast; + +import java.util.Arrays; + +/** + * Java interface to the AST MathMap class - transform coordinates using mathematical expressions. + * A MathMap is a Mapping which allows you to specify a set of forward and/or inverse transformation + * functions using arithmetic operations and mathematical functions similar to those available in + * C. The MathMap interprets these functions at run-time, whenever its forward or inverse + * transformation is required. Because the functions are not compiled in the normal sense (unlike + * an IntraMap), they may be used to describe coordinate transformations in a transportable manner. + * A MathMap therefore provides a flexible way of defining new types of Mapping whose descriptions + * may be stored as part of a dataset and interpreted by other programs. + * + *

Defining Transformation Functions

+ * + * A MathMap's transformation functions are supplied as a set of expressions in an array of + * character strings. Normally you would supply the same number of expressions for the forward + * transformation, via the "fwd" parameter, as there are output variables (given by the MathMap's + * Nout attribute). For instance, if Nout is 2 you might use: + * + *
    + *
  • "r = sqrt( x * x + y * y )" + *
  • "theta = atan2( y, x )" + *
+ * + *

which defines a transformation from Cartesian to polar coordinates. Here, the variables that + * appear on the left of each expression ("r" and "theta") provide names for the output variables + * and those that appear on the right ("x" and "y") are references to input variables. + * + *

To complement this, you must also supply expressions for the inverse transformation via the + * "inv" parameter. In this case, the number of expressions given would normally match the number + * of MathMap input coordinates (given by the Nin attribute). If Nin is 2, you might use: + * + *

    + *
  • "x = r * cos( theta )" + *
  • "y = r * sin( theta )" + *
+ * + *

which expresses the transformation from polar to Cartesian coordinates. Note that here the + * input variables ("x" and "y") are named on the left of each expression, and the output variables + * ("r" and "theta") are referenced on the right. + * + *

Normally, you cannot refer to a variable on the right of an expression unless it is named on + * the left of an expression in the complementary set of functions. Therefore both sets of + * functions (forward and inverse) must be formulated using the same consistent set of variable + * names. This means that if you wish to leave one of the transformations undefined, you must + * supply dummy expressions which simply name each of the output (or input) variables. For example, + * you might use "x" and "y" for the inverse transformation above, which serves to name the input + * variables but without defining an inverse transformation. + * + *

Calculating Intermediate Values

+ * + * It is sometimes useful to calculate intermediate values and then to use these in the final + * expressions for the output (or input) variables. This may be done by supplying additional + * expressions for the forward (or inverse) transformation functions. For instance, the following + * array of five expressions describes 2-dimensional pin-cushion distortion: + * + *
    + *
  • "r = sqrt( xin * xin + yin * yin )" + *
  • "rout = r * ( 1 + 0.1 * r * r )" + *
  • "theta = atan2( yin, xin )" + *
  • "xout = rout * cos( theta )" + *
  • "yout = rout * sin( theta )" + *
+ * + *

Here, we first calculate three intermediate results ("r", "rout" and "theta") and then use + * these to calculate the final results ("xout" and "yout"). The MathMap knows that only the final + * two results constitute values for the output variables because its Nout attribute is set to 2. + * You may define as many intermediate variables in this way as you choose. Having defined a + * variable, you may then refer to it on the right of any subsequent expressions. The intermediate + * variables are private to their transformation: the inverse transformation may refer only to the + * output variables, though it may define its own private intermediate variables. + * + *

Expression Syntax

+ * + * The expressions closely follow the syntax of the C programming language (with some extensions + * for compatibility with Fortran). They may contain references to variables and literal constants, + * together with arithmetic, boolean, relational and bitwise operators, and function invocations. A + * set of symbolic constants is also available. Parentheses may be used to over-ride the normal + * order of evaluation. There is no built-in limit to the length of expressions and they are + * insensitive to case or the presence of additional white space. + * + *

Variable names must begin with an alphabetic character and may contain only alphabetic + * characters, digits, and the underscore character "_". Literal constants, such as "0", "1", + * "0.007" or "2.505e-16", may appear in expressions, with the decimal point and exponent being + * optional (a "D" may also be used as an exponent character). A unary minus "-" may be used as a + * prefix. All arithmetic is floating point, performed in double precision. + * + *

Unless indicated otherwise, if any argument of a function or operator has the value {@link + * #AST__BAD} (indicating missing data), then the result of that function or operation is also + * {@link #AST__BAD}, so that such values are propagated automatically through all operations + * performed by MathMap transformations. The special value is written "<bad>" in expressions. + * A bad result is also produced in response to any numerical error (such as division by zero or + * numerical overflow), or if an invalid argument value is provided to a function or operator. + * + *

The arithmetic operators are {@code +}, {@code -}, {@code *}, {@code /} and {@code **} + * (power), with unary {@code +} and {@code -}. The boolean operators, for which zero is false, + * other values true and {@link #AST__BAD} "unknown", are {@code &&} ({@code .and.}) and {@code ||} + * ({@code .or.}), which use tri-state logic, {@code ^^} (exclusive or), {@code .eqv.}, {@code + * .neqv.} and {@code .xor.}, and {@code !} ({@code .not.}). The relational operators are {@code + * ==} ({@code .eq.}), {@code !=} ({@code .ne.}), {@code >} ({@code .gt.}), {@code >=} ({@code + * .ge.}), {@code <} ({@code .lt.}) and {@code <=} ({@code .le.}). The bitwise operators {@code + * >>}, {@code <<}, {@code &}, {@code |} and {@code ^} regard their operands as fixed-point binary + * numbers with negative values in two's complement. + * + *

The functions are {@code abs} ({@code fabs}), {@code acos}, {@code acosd}, {@code acosh}, + * {@code acoth}, {@code acsch}, {@code aint} ({@code int}), {@code asech}, {@code asin}, {@code + * asind}, {@code asinh}, {@code atan}, {@code atand}, {@code atanh}, {@code atan2}, {@code atan2d}, + * {@code ceil}, {@code cos}, {@code cosd}, {@code cosh}, {@code coth}, {@code csch}, {@code dim}, + * {@code exp}, {@code floor}, {@code fmod} ({@code mod}), {@code gauss}, {@code isbad}, {@code + * log}, {@code log10}, {@code max}, {@code min}, {@code nint}, {@code poisson}, {@code pow}, + * {@code qif}, {@code rand}, {@code sech}, {@code sign}, {@code sin}, {@code sinc}, {@code sind}, + * {@code sinh}, {@code sqr}, {@code sqrt}, {@code tan}, {@code tand} and {@code tanh}. The symbolic + * constants, whose enclosing "<>" brackets must be included, are <bad>, <dig>, + * <e>, <epsilon>, <mant_dig>, <max>, <max_10_exp>, <max_exp>, + * <min>, <min_10_exp>, <min_exp>, <pi>, <radix> and <rounds>. + * + *

Evaluation Precedence and Associativity

+ * + * Items appearing in expressions are evaluated in the following order (highest precedence first): + * constants and variables; function arguments and parenthesised expressions; function + * invocations; {@code **}; unary {@code + - ! .not.}; {@code * /}; {@code + -}; {@code << >>}; + * {@code < .lt. <= .le. > .gt. >= .ge.}; {@code == .eq. != .ne.}; {@code &}; {@code ^}; {@code |}; + * {@code && .and.}; {@code ^^}; {@code || .or.}; {@code .eqv. .neqv. .xor.}. So {@code -x**2} is + * {@code -(x**2)}, and {@code x**-2} is {@code x**(-2)}. All operators associate from + * left-to-right, except for unary {@code +}, unary {@code -}, {@code !}, {@code .not.} and {@code + * **}, which associate from right-to-left. + * + *

Notes

+ * + *
    + *
  • The sequence of numbers produced by the random number functions available within a + * MathMap is normally unpredictable and different for each MathMap. However, this behaviour + * may be controlled by means of the MathMap's Seed attribute. + *
  • Normally, compound Mappings (CmpMaps) which involve MathMaps will not be subject to + * simplification because AST cannot know how different MathMaps will interact. However, in + * the special case where a MathMap occurs in series with its own inverse, then simplification + * may be possible. Whether simplification does, in fact, occur under these circumstances is + * controlled by the MathMap's SimpFI and SimpIF attributes. + *
+ * + *

Ported from Rust {@code mappings/mathmap/mod.rs} and C {@code mathmap.c}. A MathMap keeps C's + * compiled form of its functions: for each function an array of operation codes, whose first + * element is the number that follow, and an array of the constants they consume ({@link + * MathMapParser}), evaluated by {@link MathMapEvaluator}. Its random-number functions draw on a + * context of its own ({@link MathMapRandom}), which a copy copies. + * + * @see AST MathMap + */ +public class MathMap extends Mapping { + + /** The value C stores while SimpFI or SimpIF is unset, {@code -INT_MAX}. */ + private static final int UNSET = -Integer.MAX_VALUE; + + /** The cleaned forward functions (C's {@code fwdfun}): lower case, without white space. */ + private final String[] fwdfun; + + /** The cleaned inverse functions (C's {@code invfun}). */ + private final String[] invfun; + + /** + * The compiled functions. Like the function texts, they are never changed once made, so a + * copy shares them. + */ + private final MathMapParser.Compiled compiled; + + /** The SimpFI attribute, {@link #UNSET} while unset. */ + private int simpFiFlag; + + /** The SimpIF attribute, {@link #UNSET} while unset. */ + private int simpIfFlag; + + /** The random-number context, which holds the Seed attribute (C's {@code rcontext}). */ + private MathMapRandom rcontext; + + /** + * Create a MathMap. This function creates a new MathMap and optionally initialises its + * attributes. + * + *

A MathMap is a Mapping which allows you to specify a set of forward and/or inverse + * transformation functions using arithmetic operations and mathematical functions similar to + * those available in C, as the class description explains. + * + * @param nin Number of input variables for the MathMap. This determines the value of its Nin + * attribute. + * @param nout Number of output variables for the MathMap. This determines the value of its Nout + * attribute. + * @param fwd an array of Strings describing the forward transformations. There should be at + * least {@code nout} of these, but there may be more (see the note on "Calculating + * intermediate values"). + * @param inv an array of Strings describing the inverse transformations. There should be at + * least {@code nin} of these, but there may be more (see the note on "Calculating + * intermediate values"). + * @throws AstException if an error occurred in the AST library + */ + public MathMap(int nin, int nout, String[] fwd, String[] inv) { + this(Init.of(nin, nout, fwd, inv), nin, nout); + } + + /** C's {@code astInitMathMap}, once the counts are checked and the functions compiled. */ + private MathMap(Init init, int nin, int nout) { + super(nin, nout, init.compiled.fwdcode != null, init.compiled.invcode != null); + this.fwdfun = init.fwdfun; + this.invfun = init.invfun; + this.compiled = init.compiled; + this.simpFiFlag = UNSET; + this.simpIfFlag = UNSET; + this.rcontext = new MathMapRandom(); + } + + /** The cleaned and compiled functions of a new MathMap. */ + private static final class Init { + final String[] fwdfun; + final String[] invfun; + final MathMapParser.Compiled compiled; + + private Init(String[] fwdfun, String[] invfun, MathMapParser.Compiled compiled) { + this.fwdfun = fwdfun; + this.invfun = invfun; + this.compiled = compiled; + } + + /** + * C's checks and compilation in {@code astInitMathMap}: the numbers of inputs and outputs + * must be at least 1 (C reports a bad output count with status {@code AST__BADNI}, as it + * does a bad input count), and there must be at least {@code nout} forward and {@code nin} + * inverse functions; the functions are then cleaned and compiled. + */ + static Init of(int nin, int nout, String[] fwd, String[] inv) { + String name = "MathMap"; + if (nin < 1) { + throw Ast.err( + AstException.AST__BADNI, + "astInitMathMap(" + name + "): Bad number of input coordinates (" + nin + + ").\nThis number should be one or more."); + } else if (nout < 1) { + throw Ast.err( + AstException.AST__BADNI, + "astInitMathMap(" + name + "): Bad number of output coordinates (" + nout + + ").\nThis number should be one or more."); + } + checkCounts("astInitMathMap", name, nin, nout, fwd.length, inv.length); + String[] fwdfun = MathMapParser.cleanFunctions(fwd); + String[] invfun = MathMapParser.cleanFunctions(inv); + MathMapParser.Compiled compiled = + MathMapParser.compileMapping("astInitMathMap", name, nin, nout, fwdfun, invfun); + return new Init(fwdfun, invfun, compiled); + } + } + + /** + * C's check in {@code astInitMathMap} that there are at least {@code nout} forward and {@code + * nin} inverse functions. + * + * @throws AstException {@code AST__INNTF} if there are too few + */ + private static void checkCounts(String method, String name, int nin, int nout, int nfwd, int ninv) { + if (nfwd < nout) { + throw Ast.err( + AstException.AST__INNTF, + method + "(" + name + "): Too few forward transformation functions given (" + nfwd + ").\nAt least " + + nout + " forward transformation functions must be supplied. "); + } else if (ninv < nin) { + throw Ast.err( + AstException.AST__INNTF, + method + "(" + name + "): Too few inverse transformation functions given (" + ninv + ").\nAt least " + + nin + " inverse transformation functions must be supplied. "); + } + } + + /** + * Loads a MathMap from its description, as C's {@code astLoadMathMap} does: the numbers of + * forward and inverse functions (defaults the numbers of outputs and inputs of the MathMap as + * created), each function (default empty), SimpFI and SimpIF, each re-applied through its + * setter when set, and the Seed when the {@code Seeded} item says it was set, an unpredictable + * default otherwise. The functions are then compiled. A description with fewer functions than + * the MathMap's outputs or inputs is refused as the constructor refuses it. + */ + MathMap(NativeNode node) { + super(node); + NativeNode part = node.section("MathMap"); + int nin = createdNin(); + int nout = createdNout(); + int nfwd = part.readInt("Nfwd", nout); + int ninv = part.readInt("Ninv", nin); + checkCounts("astLoadMathMap", "MathMap", nin, nout, nfwd, ninv); + fwdfun = new String[nfwd]; + for (int ifun = 0; ifun < nfwd; ifun++) { + fwdfun[ifun] = part.readString("Fwd" + (ifun + 1), ""); + } + invfun = new String[ninv]; + for (int ifun = 0; ifun < ninv; ifun++) { + invfun[ifun] = part.readString("Inv" + (ifun + 1), ""); + } + simpFiFlag = part.readInt("SimpFI", UNSET); + if (simpFiFlag != UNSET) { + storeSimpFI(simpFiFlag); + } + simpIfFlag = part.readInt("SimpIF", UNSET); + if (simpIfFlag != UNSET) { + storeSimpIF(simpIfFlag); + } + // C stores the Seed it reads and then re-applies it through its setter, which leaves the + // record of simplification alone because the value is unchanged. + if (part.readInt("Seeded", 0) != 0) { + rcontext = new MathMapRandom(true, part.readInt("Seed", 0)); + } else { + rcontext = new MathMapRandom(); + } + compiled = MathMapParser.compileMapping("astLoadMathMap", "MathMap", nin, nout, fwdfun, invfun); + } + + @Override + String dumpComment() { + return "Transformation using mathematical functions"; + } + + /** + * Writes the numbers of forward and inverse functions (set when they differ from the numbers + * of outputs and inputs of the MathMap as created), each function, SimpFI and SimpIF, and the + * Seed with a flag saying whether it is set, as C's {@code Dump} (mathmap.c) does; an + * attribute that is unset is written as a comment. + */ + @Override + void dump(NativeNode node) { + super.dump(node); + node.writeIsA("Mapping", "Mapping between coordinate systems"); + int nin = createdNin(); + int nout = createdNout(); + int nfwd = fwdfun.length; + int ninv = invfun.length; + node.writeInt("Nfwd", nfwd != nout, false, nfwd, "Number of forward transformation functions"); + for (int ifun = 0; ifun < nfwd; ifun++) { + node.writeString("Fwd" + (ifun + 1), true, true, fwdfun[ifun], "Forward function " + (ifun + 1)); + } + node.writeInt("Ninv", ninv != nin, false, ninv, "Number of inverse transformation functions"); + for (int ifun = 0; ifun < ninv; ifun++) { + node.writeString("Inv" + (ifun + 1), true, true, invfun[ifun], "Inverse function " + (ifun + 1)); + } + boolean set = testSimpFI(); + int ival = set ? simpFiFlag : (getSimpFIValue() ? 1 : 0); + node.writeInt( + "SimpFI", + set, + false, + ival, + ival != 0 ? "Forward-inverse pairs may simplify" : "Forward-inverse pairs do not simplify"); + set = testSimpIF(); + ival = set ? simpIfFlag : (getSimpIFValue() ? 1 : 0); + node.writeInt( + "SimpIF", + set, + false, + ival, + ival != 0 ? "Inverse-forward pairs may simplify" : "Inverse-forward pairs do not simplify"); + set = rcontext.testSeed(); + ival = rcontext.getSeed(); + node.writeInt( + "Seeded", + set, + false, + set ? 1 : 0, + set ? "Explicit random number seed set" : "No random number seed set"); + node.writeInt("Seed", set, false, ival, set ? "Random number seed value" : "Default random number seed used"); + } + + /** + * Gives the copy its own random-number context, a copy of this one, as C's copy of the + * MathMap structure does. The functions, which are never changed, are shared. + */ + @Override + void deepCopy() { + super.deepCopy(); + rcontext = rcontext.copy(); + } + + // ------------------------------------------------------------------ + // The functions, as C holds them + // ------------------------------------------------------------------ + + /** The cleaned forward functions. */ + String[] fwdFunctions() { + return fwdfun.clone(); + } + + /** The cleaned inverse functions. */ + String[] invFunctions() { + return invfun.clone(); + } + + /** + * The compiled forward and inverse functions. The arrays are shared with every copy of this + * MathMap, as the functions never change, so callers must not modify them. + */ + MathMapParser.Compiled compiledFunctions() { + return compiled; + } + + // ------------------------------------------------------------------ + // Equality and simplification + // ------------------------------------------------------------------ + + /** + * mathmap.c {@code Equal}: {@code that} is a MathMap with the same numbers of inputs and + * outputs whose compiled functions for the effective forward direction, and then for the + * effective inverse direction, taking each one's Invert attribute into account, match this + * MathMap's ({@link #sameFunctions}). + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof MathMap)) { + return false; + } + MathMap other = (MathMap) that; + if (other.getNout() != getNout() || other.getNin() != getNin()) { + return false; + } + boolean result = true; + for (int pass = 0; pass < 2 && result; pass++) { + // The first pass compares the effective forward functions, the second the inverse. + boolean thisFwd = (pass == 0) != getInvert(); + boolean thatFwd = (pass == 0) != other.getInvert(); + result = sameFunctions( + thisFwd ? fwdfun.length : invfun.length, + thisFwd ? compiled.fwdcode : compiled.invcode, + thisFwd ? compiled.fwdcon : compiled.invcon, + thatFwd ? other.fwdfun.length : other.invfun.length, + thatFwd ? other.compiled.fwdcode : other.compiled.invcode, + thatFwd ? other.compiled.fwdcon : other.compiled.invcon); + } + return result; + } + + /** + * The comparison of two sets of compiled functions in C's {@code Equal} (mathmap.c): the + * numbers of functions must be the same, and for each function the numbers of opcodes (none + * for a direction that is not defined); the opcodes are then compared in turn, and the constant + * consumed by each opcode that loads a constant or a variable or takes a variable number of + * arguments ({@code max}, {@code min}) is compared to within {@code astEQUAL}. + * + *

As C does, the comparison runs over the elements of the opcode array from the first, which + * holds the number of opcodes, and stops before the last opcode, so that the last opcode of a + * function is never compared ({@code x+1} matches {@code x-1}) and a number of opcodes equal to + * the value of a constant-consuming opcode is taken to consume a constant. Where that leads + * past the end of the constants, which C reads regardless, a constant that neither function has + * matches and one that only one function has does not. + */ + private static boolean sameFunctions( + int thisNfun, int[][] thisCode, double[][] thisCon, int thatNfun, int[][] thatCode, double[][] thatCon) { + if (thatNfun != thisNfun) { + return false; + } + for (int ifun = 0; ifun < thisNfun; ifun++) { + int ncode = thisCode != null ? thisCode[ifun][0] : 0; + int ncodeThat = thatCode != null ? thatCode[ifun][0] : 0; + if (ncode != ncodeThat) { + return false; + } + int icon = 0; + for (int icode = 0; icode < ncode; icode++) { + int code = thisCode[ifun][icode]; + if (thatCode[ifun][icode] != code) { + return false; + } else if (code == MathMapToken.OP_LDCON + || code == MathMapToken.OP_LDVAR + || code == MathMapToken.OP_MAX + || code == MathMapToken.OP_MIN) { + double[] a = thisCon[ifun]; + double[] b = thatCon[ifun]; + boolean inA = icon < a.length; + boolean inB = icon < b.length; + if (inA != inB || (inA && !MappingHelpers.astEqual(a[icon], b[icon]))) { + return false; + } + icon++; + } + } + } + return true; + } + + /** + * mathmap.c {@code MapMerge}. In series, a MathMap cancels with the MathMap after it in the + * list, the pair becoming a UnitMap applied forward, when each allows it and they are each + * other's inverse as text: the first's SimpFI (its SimpIF if the list applies it inverted) and + * the second's SimpIF (its SimpFI if applied inverted) must both be set non-zero; the first's + * number of inputs as applied must equal the second's number of outputs as applied; and the + * cleaned functions of the first's effective forward direction must be those of the second's + * effective inverse direction, and the other way round. The index returned is that of the + * first of the pair. + */ + @Override + int mapMerge(MergeList list, int where, boolean series) { + boolean simplify = series; + int imap1 = where; + int imap2 = imap1 + 1; + if (simplify) { + simplify = imap2 < list.size(); + } + if (simplify) { + simplify = "MathMap".equals(list.map(imap1).astClass()) + && "MathMap".equals(list.map(imap2).astClass()); + } + if (!simplify) { + return -1; + } + MathMap mathmap1 = (MathMap) list.map(imap1); + MathMap mathmap2 = (MathMap) list.map(imap2); + boolean invert1 = list.invert(imap1); + boolean invert2 = list.invert(imap2); + simplify = (invert1 ? mathmap1.getSimpIFValue() : mathmap1.getSimpFIValue()) + && (invert2 ? mathmap2.getSimpFIValue() : mathmap2.getSimpIFValue()); + int nin1 = appliedNin(mathmap1, invert1); + if (simplify) { + simplify = nin1 == appliedNout(mathmap2, invert2); + } + if (simplify) { + simplify = Arrays.equals( + invert1 ? mathmap1.invfun : mathmap1.fwdfun, invert2 ? mathmap2.fwdfun : mathmap2.invfun); + } + if (simplify) { + simplify = Arrays.equals( + invert1 ? mathmap1.fwdfun : mathmap1.invfun, invert2 ? mathmap2.invfun : mathmap2.fwdfun); + } + if (!simplify) { + return -1; + } + list.replacePairWith(imap1, new UnitMap(nin1), false); + return imap1; + } + + // ------------------------------------------------------------------ + // Seed, SimpFI and SimpIF + // ------------------------------------------------------------------ + + /** + * Get random number seed for a MathMap. This attribute, which may take any integer value, + * determines the sequence of random numbers produced by the random number functions in MathMap + * expressions. It is set to an unpredictable default value when a MathMap is created, so that + * by default each MathMap uses a different set of random numbers. + * + *

If required, you may set this Seed attribute to a value of your choosing in order to + * produce repeatable behaviour from the random number functions. You may also enquire the Seed + * value (e.g. if an initially unpredictable value has been used) and then use it to reproduce + * the resulting sequence of random numbers, either from the same MathMap or from another one. + * + *

Clearing the Seed attribute gives it a new unpredictable default value. + * + * @return this object's Seed attribute + */ + public int getSeed() { + return getI("Seed"); + } + + /** + * Set random number seed for a MathMap. This attribute, which may take any integer value, + * determines the sequence of random numbers produced by the random number functions in MathMap + * expressions. It is set to an unpredictable default value when a MathMap is created, so that + * by default each MathMap uses a different set of random numbers. + * + *

If required, you may set this Seed attribute to a value of your choosing in order to + * produce repeatable behaviour from the random number functions. You may also enquire the Seed + * value (e.g. if an initially unpredictable value has been used) and then use it to reproduce + * the resulting sequence of random numbers, either from the same MathMap or from another one. + * + *

Clearing the Seed attribute gives it a new unpredictable default value. + * + * @param seed the Seed attribute of this object + */ + public void setSeed(int seed) { + setI("Seed", seed); + } + + /** + * Get forward-inverse MathMap pairs simplify. This attribute should be set to a non-zero value + * if applying a MathMap's forward transformation, followed immediately by the matching inverse + * transformation will always restore the original set of coordinates. It indicates that AST + * may replace such a sequence of operations by an identity Mapping (a UnitMap) if it is + * encountered while simplifying a compound Mapping (e.g. using astSimplify). + * + *

By default, the SimpFI attribute is zero, so that AST will not perform this simplification + * unless you have set SimpFI to indicate that it is safe to do so. + * + *

Notes

+ * + *
    + *
  • For simplification to occur, the two MathMaps must be in series and be identical (with + * textually identical transformation functions). Functional equivalence is not + * sufficient. + *
  • The consent of both MathMaps is required before simplification can take place. If + * either has a SimpFI value of zero, then simplification will not occur. + *
  • The SimpFI attribute controls simplification only in the case where a MathMap's + * forward transformation is followed by the matching inverse transformation. It does not + * apply if an inverse transformation is followed by a forward transformation. This latter + * case is controlled by the SimpIF attribute. + *
  • The "forward" and "inverse" transformations referred to are those defined when the + * MathMap is created (corresponding to the "fwd" and "inv" parameters of its constructor + * function). If the MathMap is inverted (i.e. its Invert attribute is non-zero), then the + * role of the SimpFI and SimpIF attributes will be interchanged. + *
+ * + * @return this object's SimpFI attribute + */ + public boolean getSimpFI() { + return getB("SimpFI"); + } + + /** + * Set forward-inverse MathMap pairs simplify. This attribute should be set to a non-zero value + * if applying a MathMap's forward transformation, followed immediately by the matching inverse + * transformation will always restore the original set of coordinates, as {@link #getSimpFI} + * describes. + * + * @param simpFI the SimpFI attribute of this object + */ + public void setSimpFI(boolean simpFI) { + setB("SimpFI", simpFI); + } + + /** + * Get inverse-forward MathMap pairs simplify. This attribute should be set to a non-zero value + * if applying a MathMap's inverse transformation, followed immediately by the matching forward + * transformation will always restore the original set of coordinates. It indicates that AST + * may replace such a sequence of operations by an identity Mapping (a UnitMap) if it is + * encountered while simplifying a compound Mapping (e.g. using astSimplify). + * + *

By default, the SimpIF attribute is zero, so that AST will not perform this simplification + * unless you have set SimpIF to indicate that it is safe to do so. + * + *

Notes

+ * + *
    + *
  • For simplification to occur, the two MathMaps must be in series and be identical (with + * textually identical transformation functions). Functional equivalence is not + * sufficient. + *
  • The consent of both MathMaps is required before simplification can take place. If + * either has a SimpIF value of zero, then simplification will not occur. + *
  • The SimpIF attribute controls simplification only in the case where a MathMap's + * inverse transformation is followed by the matching forward transformation. It does not + * apply if a forward transformation is followed by an inverse transformation. This latter + * case is controlled by the SimpFI attribute. + *
  • The "forward" and "inverse" transformations referred to are those defined when the + * MathMap is created (corresponding to the "fwd" and "inv" parameters of its constructor + * function). If the MathMap is inverted (i.e. its Invert attribute is non-zero), then the + * role of the SimpFI and SimpIF attributes will be interchanged. + *
+ * + * @return this object's SimpIF attribute + */ + public boolean getSimpIF() { + return getB("SimpIF"); + } + + /** + * Set inverse-forward MathMap pairs simplify. This attribute should be set to a non-zero value + * if applying a MathMap's inverse transformation, followed immediately by the matching forward + * transformation will always restore the original set of coordinates, as {@link #getSimpIF} + * describes. + * + * @param simpIF the SimpIF attribute of this object + */ + public void setSimpIF(boolean simpIF) { + setB("SimpIF", simpIF); + } + + /** The SimpFI attribute's value, false while unset (C's private {@code GetSimpFI}). */ + boolean getSimpFIValue() { + return simpFiFlag != UNSET && simpFiFlag != 0; + } + + /** The SimpIF attribute's value, false while unset (C's private {@code GetSimpIF}). */ + boolean getSimpIFValue() { + return simpIfFlag != UNSET && simpIfFlag != 0; + } + + /** Whether SimpFI is set. */ + boolean testSimpFI() { + return simpFiFlag != UNSET; + } + + /** Whether SimpIF is set. */ + boolean testSimpIF() { + return simpIfFlag != UNSET; + } + + /** + * C's private {@code SetSimpFI}, an {@code astMAKE_SET1} attribute: a shared MathMap refuses + * the change; any non-zero value is stored as 1; a value different from the one held discards + * the record that the MathMap has been simplified. + */ + private void storeSimpFI(int value) { + checkSet1("SimpFI"); + int v = value != 0 ? 1 : 0; + if (v != simpFiFlag) { + clearIsSimple(); + } + simpFiFlag = v; + } + + /** As {@link #storeSimpFI}, for SimpIF. */ + private void storeSimpIF(int value) { + checkSet1("SimpIF"); + int v = value != 0 ? 1 : 0; + if (v != simpIfFlag) { + clearIsSimple(); + } + simpIfFlag = v; + } + + /** Clears SimpFI, discarding the record of simplification ({@code astMAKE_CLEAR1}). */ + private void clearSimpFI() { + checkClear1("SimpFI"); + clearIsSimple(); + simpFiFlag = UNSET; + } + + /** Clears SimpIF, discarding the record of simplification ({@code astMAKE_CLEAR1}). */ + private void clearSimpIF() { + checkClear1("SimpIF"); + clearIsSimple(); + simpIfFlag = UNSET; + } + + /** + * C's private {@code SetSeed}, an {@code astMAKE_SET1} attribute: a shared MathMap refuses the + * change; setting a Seed that was unset, or a different value, discards the record that the + * MathMap has been simplified; the generator restarts from the new seed when next used. + */ + private void storeSeed(int value) { + checkSet1("Seed"); + if (!rcontext.testSeed() || value != rcontext.getSeed()) { + clearIsSimple(); + } + rcontext.setSeed(value); + } + + /** + * Clears the Seed, discarding the record of simplification and giving the seed a new + * unpredictable value ({@code astMAKE_CLEAR1}). + */ + private void clearSeed() { + checkClear1("Seed"); + clearIsSimple(); + rcontext.clearSeed(); + } + + @Override + String getAttrib(String attrib) { + if ("seed".equals(attrib)) { + return Integer.toString(rcontext.getSeed()); + } else if ("simpfi".equals(attrib)) { + return getSimpFIValue() ? "1" : "0"; + } else if ("simpif".equals(attrib)) { + return getSimpIFValue() ? "1" : "0"; + } + return super.getAttrib(attrib); + } + + @Override + void setAttrib(String attrib, String value) { + Integer ival = CScan.scanInt(value); + if ("seed".equals(attrib) && ival != null) { + storeSeed(ival); + } else if ("simpfi".equals(attrib) && ival != null) { + storeSimpFI(ival); + } else if ("simpif".equals(attrib) && ival != null) { + storeSimpIF(ival); + } else { + super.setAttrib(attrib, value); + } + } + + @Override + boolean testAttrib(String attrib) { + if ("seed".equals(attrib)) { + return rcontext.testSeed(); + } else if ("simpfi".equals(attrib)) { + return testSimpFI(); + } else if ("simpif".equals(attrib)) { + return testSimpIF(); + } + return super.testAttrib(attrib); + } + + @Override + void clearAttrib(String attrib) { + if ("seed".equals(attrib)) { + clearSeed(); + } else if ("simpfi".equals(attrib)) { + clearSimpFI(); + } else if ("simpif".equals(attrib)) { + clearSimpIF(); + } else { + super.clearAttrib(attrib); + } + } + + // ------------------------------------------------------------------ + // Transformation + // ------------------------------------------------------------------ + + /** + * C's {@code Transform} (mathmap.c): each function of the direction applied is evaluated in + * turn, the intermediate ones into workspace and the last ones into the output, each having + * the inputs and the results of the functions before it to refer to. Where C tests an input + * for {@link #AST__BAD}, an input that is not finite is also bad, the library's rule for such + * values. + */ + @Override + void transformInto(double[][] in, int npoint, boolean forward, double[][] out) { + validateTransformInto(in, npoint, forward, out); + boolean fwd = effectiveForward(forward); + int ncoordIn = in.length; + int ncoordOut = forward ? getNout() : getNin(); + int[][] code = fwd ? compiled.fwdcode : compiled.invcode; + double[][] con = fwd ? compiled.fwdcon : compiled.invcon; + int stacksize = fwd ? compiled.fwdstack : compiled.invstack; + int nfun = code.length; + double[][] data = new double[ncoordIn + nfun][]; + int ndata = 0; + for (int idata = 0; idata < ncoordIn; idata++) { + double[] values = new double[npoint]; + for (int point = 0; point < npoint; point++) { + double v = in[idata][point]; + values[point] = isBad(v) ? AST__BAD : v; + } + data[ndata++] = values; + } + for (int idata = 0; idata < nfun - ncoordOut; idata++) { + data[ndata++] = new double[npoint]; + } + for (int idata = 0; idata < ncoordOut; idata++) { + data[ndata++] = out[idata]; + } + for (int ifun = 0; ifun < nfun; ifun++) { + MathMapEvaluator.evaluate(rcontext, npoint, data, code[ifun], con[ifun], stacksize, data[ifun + ncoordIn]); + } + } +} diff --git a/src/main/java/uk/ac/starlink/ast/MathMapEvaluator.java b/src/main/java/uk/ac/starlink/ast/MathMapEvaluator.java new file mode 100644 index 0000000..a68c6a7 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/MathMapEvaluator.java @@ -0,0 +1,850 @@ +package uk.ac.starlink.ast; + +import static uk.ac.starlink.ast.MathMapToken.OP_ABS; +import static uk.ac.starlink.ast.MathMapToken.OP_ACOS; +import static uk.ac.starlink.ast.MathMapToken.OP_ACOSD; +import static uk.ac.starlink.ast.MathMapToken.OP_ACOSH; +import static uk.ac.starlink.ast.MathMapToken.OP_ACOTH; +import static uk.ac.starlink.ast.MathMapToken.OP_ACSCH; +import static uk.ac.starlink.ast.MathMapToken.OP_ADD; +import static uk.ac.starlink.ast.MathMapToken.OP_AND; +import static uk.ac.starlink.ast.MathMapToken.OP_ASECH; +import static uk.ac.starlink.ast.MathMapToken.OP_ASIN; +import static uk.ac.starlink.ast.MathMapToken.OP_ASIND; +import static uk.ac.starlink.ast.MathMapToken.OP_ASINH; +import static uk.ac.starlink.ast.MathMapToken.OP_ATAN; +import static uk.ac.starlink.ast.MathMapToken.OP_ATAN2; +import static uk.ac.starlink.ast.MathMapToken.OP_ATAN2D; +import static uk.ac.starlink.ast.MathMapToken.OP_ATAND; +import static uk.ac.starlink.ast.MathMapToken.OP_ATANH; +import static uk.ac.starlink.ast.MathMapToken.OP_BITAND; +import static uk.ac.starlink.ast.MathMapToken.OP_BITOR; +import static uk.ac.starlink.ast.MathMapToken.OP_BITXOR; +import static uk.ac.starlink.ast.MathMapToken.OP_CEIL; +import static uk.ac.starlink.ast.MathMapToken.OP_COS; +import static uk.ac.starlink.ast.MathMapToken.OP_COSD; +import static uk.ac.starlink.ast.MathMapToken.OP_COSH; +import static uk.ac.starlink.ast.MathMapToken.OP_COTH; +import static uk.ac.starlink.ast.MathMapToken.OP_CSCH; +import static uk.ac.starlink.ast.MathMapToken.OP_DIM; +import static uk.ac.starlink.ast.MathMapToken.OP_DIV; +import static uk.ac.starlink.ast.MathMapToken.OP_EQ; +import static uk.ac.starlink.ast.MathMapToken.OP_EQV; +import static uk.ac.starlink.ast.MathMapToken.OP_EXP; +import static uk.ac.starlink.ast.MathMapToken.OP_FLOOR; +import static uk.ac.starlink.ast.MathMapToken.OP_GAUSS; +import static uk.ac.starlink.ast.MathMapToken.OP_GE; +import static uk.ac.starlink.ast.MathMapToken.OP_GT; +import static uk.ac.starlink.ast.MathMapToken.OP_INT; +import static uk.ac.starlink.ast.MathMapToken.OP_ISBAD; +import static uk.ac.starlink.ast.MathMapToken.OP_LDBAD; +import static uk.ac.starlink.ast.MathMapToken.OP_LDCON; +import static uk.ac.starlink.ast.MathMapToken.OP_LDDIG; +import static uk.ac.starlink.ast.MathMapToken.OP_LDE; +import static uk.ac.starlink.ast.MathMapToken.OP_LDEPS; +import static uk.ac.starlink.ast.MathMapToken.OP_LDMAX; +import static uk.ac.starlink.ast.MathMapToken.OP_LDMAX10E; +import static uk.ac.starlink.ast.MathMapToken.OP_LDMAXE; +import static uk.ac.starlink.ast.MathMapToken.OP_LDMDIG; +import static uk.ac.starlink.ast.MathMapToken.OP_LDMIN; +import static uk.ac.starlink.ast.MathMapToken.OP_LDMIN10E; +import static uk.ac.starlink.ast.MathMapToken.OP_LDMINE; +import static uk.ac.starlink.ast.MathMapToken.OP_LDPI; +import static uk.ac.starlink.ast.MathMapToken.OP_LDRAD; +import static uk.ac.starlink.ast.MathMapToken.OP_LDRND; +import static uk.ac.starlink.ast.MathMapToken.OP_LDVAR; +import static uk.ac.starlink.ast.MathMapToken.OP_LE; +import static uk.ac.starlink.ast.MathMapToken.OP_LOG; +import static uk.ac.starlink.ast.MathMapToken.OP_LOG10; +import static uk.ac.starlink.ast.MathMapToken.OP_LT; +import static uk.ac.starlink.ast.MathMapToken.OP_MAX; +import static uk.ac.starlink.ast.MathMapToken.OP_MIN; +import static uk.ac.starlink.ast.MathMapToken.OP_MOD; +import static uk.ac.starlink.ast.MathMapToken.OP_MUL; +import static uk.ac.starlink.ast.MathMapToken.OP_NE; +import static uk.ac.starlink.ast.MathMapToken.OP_NEG; +import static uk.ac.starlink.ast.MathMapToken.OP_NINT; +import static uk.ac.starlink.ast.MathMapToken.OP_NOT; +import static uk.ac.starlink.ast.MathMapToken.OP_NULL; +import static uk.ac.starlink.ast.MathMapToken.OP_OR; +import static uk.ac.starlink.ast.MathMapToken.OP_POISS; +import static uk.ac.starlink.ast.MathMapToken.OP_POW; +import static uk.ac.starlink.ast.MathMapToken.OP_QIF; +import static uk.ac.starlink.ast.MathMapToken.OP_RAND; +import static uk.ac.starlink.ast.MathMapToken.OP_SECH; +import static uk.ac.starlink.ast.MathMapToken.OP_SHFTL; +import static uk.ac.starlink.ast.MathMapToken.OP_SHFTR; +import static uk.ac.starlink.ast.MathMapToken.OP_SIGN; +import static uk.ac.starlink.ast.MathMapToken.OP_SIN; +import static uk.ac.starlink.ast.MathMapToken.OP_SINC; +import static uk.ac.starlink.ast.MathMapToken.OP_SIND; +import static uk.ac.starlink.ast.MathMapToken.OP_SINH; +import static uk.ac.starlink.ast.MathMapToken.OP_SQR; +import static uk.ac.starlink.ast.MathMapToken.OP_SQRT; +import static uk.ac.starlink.ast.MathMapToken.OP_SUB; +import static uk.ac.starlink.ast.MathMapToken.OP_TAN; +import static uk.ac.starlink.ast.MathMapToken.OP_TAND; +import static uk.ac.starlink.ast.MathMapToken.OP_TANH; +import static uk.ac.starlink.ast.MathMapToken.OP_XOR; + +/** + * The virtual machine that evaluates a compiled MathMap function, C's {@code EvaluateFunction} + * (mathmap.c): each operation code applies a vector operation to a push-down stack of vectors, one + * element per point, and the result is left in the bottom element, which is the output. + * + *

Unless an operation says otherwise, a bad argument gives a bad result, and so do numerical + * errors, such as division by zero and overflow, and arguments outside a function's domain. C + * traps the errors of some maths library functions ({@code exp}, {@code pow}, {@code ldexp} and + * others) through {@code errno}; here a finite argument whose result is not finite stands for the + * error C's library reports, as a library that sets {@code errno} (glibc) reports it. The macOS + * library does not set {@code errno}, so C built there gives the infinity or NaN instead. + * + *

Ported from Rust {@code mappings/mathmap/evaluator.rs} and C {@code mathmap.c}. + */ +final class MathMapEvaluator { + + private MathMapEvaluator() {} + + private static final double BAD = Mapping.AST__BAD; + + /** C's {@code DBL_EPSILON}. */ + private static final double DBL_EPSILON = Math.ulp(1.0); + + /** C's {@code AST__DBL_DIG}, the significant digits of a full-precision double. */ + private static final int AST_DBL_DIG = 17; + + /** The number of bits in C's {@code unsigned long}, and in a Java {@code long}. */ + private static final int BITS = 64; + + /** The number of blocks of bits a double is processed in, C's {@code nblock}. */ + private static final int NBLOCK = (8 + 8 - 1) / 8; + + /** The smallest number that may be subtracted from 2.0, C's {@code eps}. */ + private static final double EPS = 2.0 * DBL_EPSILON; + + /** 2 to the power {@link #BITS}, C's {@code scale}. */ + private static final double SCALE = Math.scalb(1.0, BITS); + + /** 2 to the power {@code BITS - 1}, C's {@code scale1}. */ + private static final double SCALE1 = SCALE * 0.5; + + private static final double RSCALE = 1.0 / SCALE; + private static final double RSCALE1 = 1.0 / SCALE1; + + /** The sign bit of a block, C's {@code signbit}. */ + private static final long SIGNBIT = 1L << (BITS - 1); + + /** C's {@code pi}, from {@code acos(-1.0)}. */ + private static final double PI = Math.acos(-1.0); + + private static final double R2D = 180.0 / PI; + private static final double D2R = PI / 180.0; + + /** The natural logarithm of 2. */ + private static final double LOG2 = Math.log(2.0); + + /** + * A value that may be squared without overflow, yet large enough that adding or subtracting 1 + * from its square makes no difference. + */ + private static final double SAFE_SQ = 0.9 * Math.sqrt(Double.MAX_VALUE); + + private static final double RSAFE_SQ = 1.0 / SAFE_SQ; + + /** + * Evaluates a compiled function for {@code npoint} points. + * + * @param rcontext the random-number context of the MathMap + * @param ptrIn the data the function's variables refer to, {@code [variable][point]} + * @param code the opcodes, the first element being the number that follow + * @param con the constants the opcodes consume + * @param stacksize the size of evaluation stack the opcodes need + * @param out receives the result for each point + */ + static void evaluate( + MathMapRandom rcontext, + int npoint, + double[][] ptrIn, + int[] code, + double[] con, + int stacksize, + double[] out) { + double[][] stack = new double[Math.max(stacksize, 1)][]; + stack[0] = out; + for (int istk = 1; istk < stacksize; istk++) { + stack[istk] = new double[npoint]; + } + int tos = -1; + int icon = 0; + int ncode = code[0]; + for (int icode = 1; icode <= ncode; icode++) { + int op = code[icode]; + switch (op) { + case OP_NULL: + break; + + // Constants and variables. + case OP_LDCON: { + double value = con[icon++]; + fill(stack[++tos], npoint, value); + break; + } + case OP_LDVAR: { + int ivar = (int) Math.round(con[icon++]); + System.arraycopy(ptrIn[ivar], 0, stack[++tos], 0, npoint); + break; + } + case OP_LDBAD: + case OP_LDDIG: + case OP_LDEPS: + case OP_LDMAX: + case OP_LDMAX10E: + case OP_LDMAXE: + case OP_LDMDIG: + case OP_LDMIN: + case OP_LDMIN10E: + case OP_LDMINE: + case OP_LDRAD: + case OP_LDRND: + case OP_LDE: + case OP_LDPI: + fill(stack[++tos], npoint, constant(op)); + break; + + // Functions of one argument, which a bad argument leaves bad. + case OP_ABS: + case OP_ACOS: + case OP_ACOSD: + case OP_ACOSH: + case OP_ACOTH: + case OP_ACSCH: + case OP_ASECH: + case OP_ASIN: + case OP_ASIND: + case OP_ASINH: + case OP_ATAN: + case OP_ATAND: + case OP_ATANH: + case OP_CEIL: + case OP_COS: + case OP_COSD: + case OP_COSH: + case OP_COTH: + case OP_CSCH: + case OP_EXP: + case OP_FLOOR: + case OP_INT: + case OP_LOG: + case OP_LOG10: + case OP_NINT: + case OP_POISS: + case OP_SECH: + case OP_SIN: + case OP_SINC: + case OP_SIND: + case OP_SINH: + case OP_SQR: + case OP_SQRT: + case OP_TAN: + case OP_TAND: + case OP_TANH: + case OP_NEG: + case OP_NOT: { + double[] xv = stack[tos]; + for (int point = 0; point < npoint; point++) { + double x = xv[point]; + if (x != BAD) { + xv[point] = function1(op, x, rcontext); + } + } + break; + } + + // The bad-value test, which takes a bad argument. + case OP_ISBAD: { + double[] xv = stack[tos]; + for (int point = 0; point < npoint; point++) { + xv[point] = xv[point] == BAD ? 1.0 : 0.0; + } + break; + } + + // Functions and operators of two arguments, which a bad argument makes bad. + case OP_ATAN2: + case OP_ATAN2D: + case OP_DIM: + case OP_GAUSS: + case OP_MOD: + case OP_POW: + case OP_RAND: + case OP_SIGN: + case OP_ADD: + case OP_SUB: + case OP_MUL: + case OP_DIV: + case OP_SHFTL: + case OP_SHFTR: + case OP_EQ: + case OP_GE: + case OP_GT: + case OP_LE: + case OP_LT: + case OP_NE: + case OP_BITOR: + case OP_BITXOR: + case OP_BITAND: + case OP_EQV: + case OP_XOR: { + double[] xv2 = stack[tos--]; + double[] xv1 = stack[tos]; + for (int point = 0; point < npoint; point++) { + double x1 = xv1[point]; + if (x1 != BAD) { + double x2 = xv2[point]; + xv1[point] = x2 != BAD ? function2(op, x1, x2, rcontext) : BAD; + } + } + break; + } + + // The tri-state boolean operators, which take bad arguments. + case OP_AND: + case OP_OR: { + double[] xv2 = stack[tos--]; + double[] xv1 = stack[tos]; + for (int point = 0; point < npoint; point++) { + xv1[point] = + op == OP_AND ? tristateAnd(xv1[point], xv2[point]) : tristateOr(xv1[point], xv2[point]); + } + break; + } + + // C's "a?b:c", which takes bad arguments. + case OP_QIF: { + double[] xv3 = stack[tos--]; + double[] xv2 = stack[tos--]; + double[] xv1 = stack[tos]; + for (int point = 0; point < npoint; point++) { + xv1[point] = xv1[point] != 0.0 ? xv2[point] : xv3[point]; + } + break; + } + + // Functions of a variable number of arguments, the number being a constant. + case OP_MAX: + case OP_MIN: { + int narg = (int) Math.round(con[icon++]); + for (int iarg = 0; iarg < narg - 1; iarg++) { + double[] xv2 = stack[tos--]; + double[] xv1 = stack[tos]; + for (int point = 0; point < npoint; point++) { + double x1 = xv1[point]; + if (x1 != BAD) { + double x2 = xv2[point]; + if (x2 == BAD) { + xv1[point] = BAD; + } else if (op == OP_MAX) { + xv1[point] = x1 >= x2 ? x1 : x2; + } else { + xv1[point] = x1 <= x2 ? x1 : x2; + } + } + } + } + break; + } + default: + throw Ast.err(AstException.AST__INTER, "EvaluateFunction(MathMap): unknown opcode " + op + "."); + } + } + } + + private static void fill(double[] y, int npoint, double value) { + for (int point = 0; point < npoint; point++) { + y[point] = value; + } + } + + /** The value a constant-loading opcode loads. */ + private static double constant(int op) { + switch (op) { + case OP_LDBAD: + return BAD; + case OP_LDDIG: + return AST_DBL_DIG; + case OP_LDEPS: + return DBL_EPSILON; + case OP_LDMAX: + return Double.MAX_VALUE; + case OP_LDMAX10E: + return 308.0; + case OP_LDMAXE: + return Double.MAX_EXPONENT + 1; + case OP_LDMDIG: + return 53.0; + case OP_LDMIN: + return Double.MIN_NORMAL; + case OP_LDMIN10E: + return -307.0; + case OP_LDMINE: + return Double.MIN_EXPONENT + 1; + case OP_LDRAD: + return 2.0; + // FLT_ROUNDS: rounding to nearest. + case OP_LDRND: + return 1.0; + case OP_LDE: + // C's exp(1.0), which C's library rounds correctly to Math.E; Java's Math.exp(1.0) + // is one unit in the last place above it. + return Math.E; + case OP_LDPI: + return PI; + default: + throw Ast.err( + AstException.AST__INTER, "EvaluateFunction(MathMap): unknown constant opcode " + op + "."); + } + } + + // ------------------------------------------------------------------ + // Functions of one argument + // ------------------------------------------------------------------ + + /** C's {@code ABS} macro, which keeps the sign of a negative zero. */ + private static double abs(double x) { + return x >= 0.0 ? x : -x; + } + + /** C's {@code INT} macro: rounding towards zero. */ + private static double trunc(double x) { + return x >= 0.0 ? Math.floor(x) : Math.ceil(x); + } + + /** + * C's {@code CATCH_MATHS_OVERFLOW}: a result that overflows from finite arguments is bad, as + * the {@code ERANGE} error a library that sets {@code errno} reports for it. + */ + private static double catchOverflow(double result, boolean finiteArgs) { + return finiteArgs && Double.isInfinite(result) ? BAD : result; + } + + /** + * C's {@code CATCH_MATHS_ERROR}: as {@link #catchOverflow}, and a result that is not a number + * from finite arguments is bad, as the {@code EDOM} error such a library reports for it. + */ + private static double catchError(double result, boolean finiteArgs) { + return finiteArgs && !Double.isFinite(result) ? BAD : result; + } + + /** The value of a one-argument function or unary operator at a good argument {@code x}. */ + private static double function1(int op, double x, MathMapRandom rcontext) { + boolean finite = Double.isFinite(x); + switch (op) { + case OP_ABS: + return abs(x); + case OP_ACOS: + return abs(x) <= 1.0 ? Math.acos(x) : BAD; + case OP_ACOSD: + return abs(x) <= 1.0 ? Math.acos(x) * R2D : BAD; + case OP_ACOSH: + if (x < 1.0) { + return BAD; + } + return x > SAFE_SQ ? Math.log(x) + LOG2 : Math.log(x + Math.sqrt(x * x - 1.0)); + case OP_ACOTH: + return abs(x) <= 1.0 ? BAD : 0.5 * Math.log((x + 1.0) / (x - 1.0)); + case OP_ACSCH: { + if (x == 0.0) { + return BAD; + } + boolean sign = x >= 0.0; + double ax = abs(x); + double v; + if (ax < RSAFE_SQ) { + v = LOG2 - Math.log(ax); + } else { + double r = 1.0 / ax; + v = Math.log(r + Math.sqrt(r * r + 1.0)); + } + return (sign ? 1.0 : -1.0) * v; + } + case OP_ASECH: { + if (x <= 0 || x > 1.0) { + return BAD; + } + if (x < RSAFE_SQ) { + return LOG2 - Math.log(x); + } + double r = 1.0 / x; + return Math.log(r + Math.sqrt(r * r - 1.0)); + } + case OP_ASIN: + return abs(x) <= 1.0 ? Math.asin(x) : BAD; + case OP_ASIND: + return abs(x) <= 1.0 ? Math.asin(x) * R2D : BAD; + case OP_ASINH: { + boolean sign = x >= 0.0; + double ax = abs(x); + double v = ax > SAFE_SQ ? Math.log(ax) + LOG2 : Math.log(ax + Math.sqrt(ax * ax + 1.0)); + return (sign ? 1.0 : -1.0) * v; + } + case OP_ATAN: + return Math.atan(x); + case OP_ATAND: + return Math.atan(x) * R2D; + case OP_ATANH: + return abs(x) >= 1.0 ? BAD : 0.5 * Math.log((1.0 + x) / (1.0 - x)); + case OP_CEIL: + return Math.ceil(x); + case OP_COS: + return Math.cos(x); + case OP_COSD: + return Math.cos(x * D2R); + case OP_COSH: + return catchOverflow(Math.cosh(x), finite); + case OP_COTH: + return safeDiv(1.0, Math.tanh(x)); + case OP_CSCH: { + double s = catchOverflow(Math.sinh(x), finite); + return s == BAD ? 0.0 : safeDiv(1.0, s); + } + case OP_EXP: + return catchOverflow(Math.exp(x), finite); + case OP_FLOOR: + return Math.floor(x); + case OP_INT: + return trunc(x); + case OP_LOG: + return x > 0.0 ? Math.log(x) : BAD; + case OP_LOG10: + return x > 0.0 ? Math.log10(x) : BAD; + case OP_NINT: + return x >= 0 ? Math.floor(x + 0.5) : Math.ceil(x - 0.5); + case OP_POISS: + return rcontext.poisson(x); + case OP_SECH: { + double c = catchOverflow(Math.cosh(x), finite); + return c == BAD ? 0.0 : 1.0 / c; + } + case OP_SIN: + return Math.sin(x); + case OP_SINC: + return x == 0.0 ? 1.0 : Math.sin(x) / x; + case OP_SIND: + return Math.sin(x * D2R); + case OP_SINH: + return catchOverflow(Math.sinh(x), finite); + case OP_SQR: + return safeMul(x, x); + case OP_SQRT: + return x >= 0.0 ? Math.sqrt(x) : BAD; + case OP_TAN: + return catchOverflow(Math.tan(x), finite); + case OP_TAND: + return Math.tan(x * D2R); + case OP_TANH: + return Math.tanh(x); + case OP_NEG: + return -x; + case OP_NOT: + return x == 0.0 ? 1.0 : 0.0; + default: + throw Ast.err( + AstException.AST__INTER, "EvaluateFunction(MathMap): unknown function opcode " + op + "."); + } + } + + // ------------------------------------------------------------------ + // Functions of two arguments + // ------------------------------------------------------------------ + + /** The value of a two-argument function or binary operator at good arguments. */ + private static double function2(int op, double x1, double x2, MathMapRandom rcontext) { + switch (op) { + case OP_ATAN2: + return Math.atan2(x1, x2); + case OP_ATAN2D: + return Math.atan2(x1, x2) * R2D; + case OP_DIM: + return x1 > x2 ? x1 - x2 : 0.0; + case OP_GAUSS: + return gauss(x1, x2, rcontext); + case OP_MOD: + // Java's remainder of doubles is C's fmod. + return x2 != 0.0 ? x1 % x2 : BAD; + case OP_POW: + return catchError(Math.pow(x1, x2), Double.isFinite(x1) && Double.isFinite(x2)); + case OP_RAND: { + double ran = rcontext.rand(); + return x1 * ran + x2 * (1.0 - ran); + } + case OP_SIGN: + return (x1 >= 0.0) == (x2 >= 0.0) ? x1 : -x1; + case OP_ADD: + return safeAdd(x1, x2); + case OP_SUB: + return safeSub(x1, x2); + case OP_MUL: + return safeMul(x1, x2); + case OP_DIV: + return safeDiv(x1, x2); + case OP_SHFTL: + return shiftBits(x1, x2); + case OP_SHFTR: + return shiftBits(x1, -x2); + case OP_EQ: + return x1 == x2 ? 1.0 : 0.0; + case OP_GE: + return x1 >= x2 ? 1.0 : 0.0; + case OP_GT: + return x1 > x2 ? 1.0 : 0.0; + case OP_LE: + return x1 <= x2 ? 1.0 : 0.0; + case OP_LT: + return x1 < x2 ? 1.0 : 0.0; + case OP_NE: + return x1 != x2 ? 1.0 : 0.0; + case OP_BITOR: + case OP_BITXOR: + case OP_BITAND: + return bitOper(op, x1, x2); + case OP_EQV: + return (x1 != 0.0) == (x2 != 0.0) ? 1.0 : 0.0; + case OP_XOR: + return (x1 != 0.0) != (x2 != 0.0) ? 1.0 : 0.0; + default: + throw Ast.err( + AstException.AST__INTER, "EvaluateFunction(MathMap): unknown function opcode " + op + "."); + } + } + + /** C's {@code TRISTATE_AND}: false if either argument is false, even when the other is bad. */ + private static double tristateAnd(double x1, double x2) { + if (x1 == BAD) { + return x2 != 0.0 ? BAD : 0.0; + } else if (x2 == BAD) { + return x1 != 0.0 ? BAD : 0.0; + } + return x1 != 0.0 && x2 != 0.0 ? 1.0 : 0.0; + } + + /** C's {@code TRISTATE_OR}: true if either argument is true, even when the other is bad. */ + private static double tristateOr(double x1, double x2) { + if (x1 == BAD) { + return x2 == 0.0 || x2 == BAD ? BAD : 1.0; + } else if (x2 == BAD) { + return x1 == 0.0 ? BAD : 1.0; + } + return x1 != 0.0 || x2 != 0.0 ? 1.0 : 0.0; + } + + /** C's {@code SAFE_ADD}: addition, bad where it would overflow. */ + private static double safeAdd(double x1, double x2) { + if (x1 >= 0.0) { + return x2 <= 0.0 || (Double.MAX_VALUE - x1) >= x2 ? x1 + x2 : BAD; + } + return x2 >= 0.0 || (Double.MAX_VALUE + x1) >= -x2 ? x1 + x2 : BAD; + } + + /** C's {@code SAFE_SUB}: subtraction, bad where it would overflow. */ + private static double safeSub(double x1, double x2) { + if (x1 >= 0.0) { + return x2 >= 0.0 || (Double.MAX_VALUE - x1) >= -x2 ? x1 - x2 : BAD; + } + return x2 <= 0.0 || (Double.MAX_VALUE + x1) >= x2 ? x1 - x2 : BAD; + } + + /** C's {@code SAFE_MUL}: multiplication, bad where it would overflow. */ + private static double safeMul(double x1, double x2) { + double abs1 = abs(x1); + if (abs1 <= 1.0) { + return x1 * x2; + } + double abs2 = abs(x2); + return abs2 <= 1.0 || (Double.MAX_VALUE / abs1) >= abs2 ? x1 * x2 : BAD; + } + + /** C's {@code SAFE_DIV}: division, bad for a zero divisor and where it would overflow. */ + private static double safeDiv(double x1, double x2) { + if (x2 == 0.0) { + return BAD; + } + double abs2 = abs(x2); + return abs2 >= 1.0 || (Double.MAX_VALUE * abs2) >= abs(x1) ? x1 / x2 : BAD; + } + + /** + * C's {@code GAUSS}: a value from a Gaussian distribution with mean {@code x1} and standard + * deviation {@code |x2|}, drawn again until it does not overflow. + */ + private static double gauss(double x1, double x2, MathMapRandom rcontext) { + double result; + do { + double ran = rcontext.gauss(); + result = abs(x2); + result = safeMul(ran, result); + if (result != BAD) { + result = safeAdd(result, x1); + } + } while (result == BAD); + return result; + } + + /** + * C's {@code SHIFT_BITS}: {@code x1} times 2 to the power of the integer part of {@code x2}, + * zero where the power is too negative to hold in an {@code int}, and bad where it is too + * large or the result overflows. + */ + private static double shiftBits(double x1, double x2) { + double frac = frexpFraction(x1); + int expon = frexpExponent(x1); + double newexp = trunc(x2) + expon; + if (newexp < -Integer.MAX_VALUE) { + return 0.0; + } else if (newexp > Integer.MAX_VALUE) { + return frac == 0.0 ? 0.0 : BAD; + } + return catchOverflow(ldexp(frac, (int) newexp), Double.isFinite(frac)); + } + + /** + * C's {@code BIT_OPER}: a bit-wise operation on two values, each read as a fixed-point binary + * number with negative values in two's complement, so that integer values give the result of + * the integer operation and fraction bits take part too. Both values are brought to the same + * power of two as fractions below 1; a negative value's fraction is subtracted from 2 (or the + * largest number below 2, if it has underflowed), and the bits are combined a block at a time. + */ + private static double bitOper(int op, double x1, double x2) { + double frac1 = frexpFraction(abs(x1)); + int expon1 = frexpExponent(abs(x1)); + double frac2 = frexpFraction(abs(x2)); + int expon2 = frexpExponent(abs(x2)); + int expon = expon1; + if (expon2 > expon1) { + expon = expon2; + frac1 = ldexp(frac1, expon1 - expon); + } else if (expon1 > expon2) { + frac2 = ldexp(frac2, expon2 - expon); + } + if (x1 < 0.0) { + frac1 = 2.0 - (frac1 > EPS ? frac1 : EPS); + } + if (x2 < 0.0) { + frac2 = 2.0 - (frac2 > EPS ? frac2 : EPS); + } + frac1 *= SCALE1; + frac2 *= SCALE1; + long b1 = toUnsignedLong(frac1); + long b2 = toUnsignedLong(frac2); + long b = combine(op, b1, b2); + long neg = b & SIGNBIT; + double unscale = RSCALE1; + double result = unsignedToDouble(b) * unscale; + for (int iblock = 1; iblock < NBLOCK; iblock++) { + frac1 = (frac1 - unsignedToDouble(b1)) * SCALE; + frac2 = (frac2 - unsignedToDouble(b2)) * SCALE; + b1 = toUnsignedLong(frac1); + b2 = toUnsignedLong(frac2); + b = combine(op, b1, b2); + unscale *= RSCALE; + result += unsignedToDouble(b) * unscale; + } + if (neg != 0L) { + result -= 2.0; + } + return ldexp(result, expon); + } + + private static long combine(int op, long b1, long b2) { + switch (op) { + case OP_BITOR: + return b1 | b2; + case OP_BITXOR: + return b1 ^ b2; + case OP_BITAND: + return b1 & b2; + default: + throw Ast.err( + AstException.AST__INTER, "EvaluateFunction(MathMap): unknown bit-wise opcode " + op + "."); + } + } + + // ------------------------------------------------------------------ + // C's conversions and frexp/ldexp + // ------------------------------------------------------------------ + + /** + * C's conversion of a double in {@code [0, 2^64)} to {@code unsigned long}, which drops the + * fraction, as the bits of a Java {@code long}. + */ + static long toUnsignedLong(double d) { + if (d < SCALE1) { + return (long) d; + } + return (long) (d - SCALE1) ^ SIGNBIT; + } + + /** C's conversion of an {@code unsigned long}, held in a Java {@code long}, to a double. */ + static double unsignedToDouble(long b) { + if (b >= 0L) { + return b; + } + // Halve with the lowest bit kept as a sticky bit, so that the one rounding is correct. + return ((b >>> 1) | (b & 1L)) * 2.0; + } + + /** + * The fraction C's {@code frexp} gives: {@code x} as a fraction of magnitude in {@code [0.5, + * 1)} with the sign of {@code x}; zero, infinities and NaN unchanged. + */ + static double frexpFraction(double x) { + if (x == 0.0 || !Double.isFinite(x)) { + return x; + } + return Math.scalb(x, -frexpExponent(x)); + } + + /** + * The power of two C's {@code frexp} gives, such that {@code x} is its fraction times 2 to + * this power; zero for zero, infinities and NaN. + */ + static int frexpExponent(double x) { + if (x == 0.0 || !Double.isFinite(x)) { + return 0; + } + int e = Math.getExponent(x); + if (e == Double.MIN_EXPONENT - 1) { + // A subnormal value: scale it into the normal range first. + return Math.getExponent(x * 0x1.0p64) - 64 + 1; + } + return e + 1; + } + + /** + * {@code x} times 2 to the power {@code n}, rounded once, as C's {@code ldexp} gives it: the + * result overflows to an infinity or underflows through the subnormal numbers to zero only + * where the exact product does. + */ + static double ldexp(double x, int n) { + double y = x; + if (n > 1023) { + y *= 0x1.0p1023; + n -= 1023; + if (n > 1023) { + y *= 0x1.0p1023; + n -= 1023; + n = Math.min(n, 1023); + } + } else if (n < -1022) { + // A step down by 2^-969 keeps 53 bits clear of the subnormal range, so that only the + // final multiplication rounds. + y *= 0x1.0p-969; + n += 1022 - 53; + if (n < -1022) { + y *= 0x1.0p-969; + n += 1022 - 53; + n = Math.max(n, -1022); + } + } + return y * Double.longBitsToDouble((long) (0x3ff + n) << 52); + } +} diff --git a/src/main/java/uk/ac/starlink/ast/MathMapParser.java b/src/main/java/uk/ac/starlink/ast/MathMapParser.java new file mode 100644 index 0000000..8fb9f3c --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/MathMapParser.java @@ -0,0 +1,692 @@ +package uk.ac.starlink.ast; + +import java.util.Arrays; + +/** + * Checks and compiles the transformation functions of a MathMap, as C's {@code CleanFunctions}, + * {@code CompileMapping}, {@code ExtractVariables}, {@code ExtractExpressions}, {@code + * CompileExpression}, {@code ValidateSymbol}, {@code ParseConstant}, {@code ParseName}, {@code + * ParseVariable} and {@code EvaluationSort} (mathmap.c) do. + * + *

Each function compiles to C's form: an array of operation codes ({@link MathMapToken}) whose + * first element is the number that follow, and an array of the constants the codes consume, in + * the order they consume them. A function is evaluated on a push-down stack by {@link + * MathMapEvaluator}. + * + *

Ported from Rust {@code mappings/mathmap/{mod,token,parser}.rs} and C {@code mathmap.c}. + * Rust reads an expression with a tokenizer and a precedence-climbing parser; this class follows + * C, which identifies each symbol with its table and sorts the symbols into evaluation order with + * an operator stack. Both give the same opcodes and constants. + */ +final class MathMapParser { + + private MathMapParser() {} + + /** + * The compiled forward and inverse functions of a MathMap. A direction whose functions have no + * right-hand sides is undefined, and has null arrays. + */ + static final class Compiled { + + /** The opcodes of each forward function (C's {@code fwdcode}), or null. */ + final int[][] fwdcode; + + /** The opcodes of each inverse function (C's {@code invcode}), or null. */ + final int[][] invcode; + + /** The constants of each forward function (C's {@code fwdcon}), or null. */ + final double[][] fwdcon; + + /** The constants of each inverse function (C's {@code invcon}), or null. */ + final double[][] invcon; + + /** The evaluation stack size the forward functions need (C's {@code fwdstack}). */ + final int fwdstack; + + /** The evaluation stack size the inverse functions need (C's {@code invstack}). */ + final int invstack; + + Compiled(int[][] fwdcode, int[][] invcode, double[][] fwdcon, double[][] invcon, int fwdstack, int invstack) { + this.fwdcode = fwdcode; + this.invcode = invcode; + this.fwdcon = fwdcon; + this.invcon = invcon; + this.fwdstack = fwdstack; + this.invstack = invstack; + } + } + + /** One compiled expression, C's {@code code}, {@code con} and {@code stacksize}. */ + private static final class Expression { + final int[] code; + final double[] con; + final int stacksize; + + Expression(int[] code, double[] con, int stacksize) { + this.code = code; + this.con = con; + this.stacksize = stacksize; + } + } + + // ------------------------------------------------------------------ + // Character classes of the C locale + // ------------------------------------------------------------------ + + private static boolean isDigit(char c) { + return c >= '0' && c <= '9'; + } + + private static boolean isAlpha(char c) { + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); + } + + private static boolean isAlnum(char c) { + return isDigit(c) || isAlpha(c); + } + + /** The character of {@code s} at {@code i}, or C's terminating nul beyond its end. */ + private static char at(String s, int i) { + return i < s.length() ? s.charAt(i) : '\0'; + } + + // ------------------------------------------------------------------ + // CleanFunctions + // ------------------------------------------------------------------ + + /** + * A copy of each function with its white space removed and its letters in lower case, as C's + * {@code CleanFunctions} makes it. + */ + static String[] cleanFunctions(String[] fun) { + String[] clean = new String[fun.length]; + for (int ifun = 0; ifun < fun.length; ifun++) { + String f = fun[ifun]; + StringBuilder sb = new StringBuilder(f.length()); + for (int i = 0; i < f.length(); i++) { + char c = f.charAt(i); + if (!CScan.isCSpace(c)) { + sb.append(CScan.toLower(c)); + } + } + clean[ifun] = sb.toString(); + } + return clean; + } + + // ------------------------------------------------------------------ + // CompileMapping + // ------------------------------------------------------------------ + + /** + * Compiles the cleaned functions of a MathMap, as C's {@code CompileMapping} does. The input + * variables of the forward functions are named by the left-hand sides of the last {@code nin} + * inverse functions, and those of the inverse functions by the last {@code nout} forward + * functions; each function may also use the variables the functions before it define. + * + * @param method the method named in error messages + * @param cls the class named in error messages + * @param fwdfun the cleaned forward functions, at least {@code nout} + * @param invfun the cleaned inverse functions, at least {@code nin} + * @throws AstException with C's status and messages if a function is invalid + */ + static Compiled compileMapping(String method, String cls, int nin, int nout, String[] fwdfun, String[] invfun) { + int nfwd = fwdfun.length; + int ninv = invfun.length; + + // The forward transformation. + String[] strings = new String[nin + nfwd]; + int nvar = 0; + for (int ifun = ninv - nin; ifun < ninv; ifun++) { + strings[nvar++] = invfun[ifun]; + } + for (int ifun = 0; ifun < nfwd; ifun++) { + strings[nvar++] = fwdfun[ifun]; + } + String[] var = extractVariables(method, cls, strings, nin, nout, nfwd, ninv, true); + String[] exprs = extractExpressions(method, cls, fwdfun, true); + int[][] fwdcode = null; + double[][] fwdcon = null; + int fwdstack = 0; + if (exprs != null) { + fwdcode = new int[nfwd][]; + fwdcon = new double[nfwd][]; + for (int ifun = 0; ifun < nfwd; ifun++) { + Expression e = compileFunction(method, cls, exprs[ifun], nin + ifun, var, "forward", ifun); + fwdcode[ifun] = e.code; + fwdcon[ifun] = e.con; + fwdstack = Math.max(fwdstack, e.stacksize); + } + } + + // The inverse transformation. + strings = new String[nout + ninv]; + nvar = 0; + for (int ifun = nfwd - nout; ifun < nfwd; ifun++) { + strings[nvar++] = fwdfun[ifun]; + } + for (int ifun = 0; ifun < ninv; ifun++) { + strings[nvar++] = invfun[ifun]; + } + var = extractVariables(method, cls, strings, nin, nout, nfwd, ninv, false); + exprs = extractExpressions(method, cls, invfun, false); + int[][] invcode = null; + double[][] invcon = null; + int invstack = 0; + if (exprs != null) { + invcode = new int[ninv][]; + invcon = new double[ninv][]; + for (int ifun = 0; ifun < ninv; ifun++) { + Expression e = compileFunction(method, cls, exprs[ifun], nout + ifun, var, "inverse", ifun); + invcode[ifun] = e.code; + invcon[ifun] = e.con; + invstack = Math.max(invstack, e.stacksize); + } + } + return new Compiled(fwdcode, invcode, fwdcon, invcon, fwdstack, invstack); + } + + /** + * {@link #compileExpression} of one function, whose errors gain C's context line naming the + * direction and the function's number. + */ + private static Expression compileFunction( + String method, String cls, String expr, int nvar, String[] var, String dir, int ifun) { + try { + return compileExpression(method, cls, expr, nvar, var); + } catch (AstException e) { + throw Ast.withContext(e, "Error in " + dir + " transformation function " + (ifun + 1) + "."); + } + } + + // ------------------------------------------------------------------ + // ExtractVariables and ExtractExpressions + // ------------------------------------------------------------------ + + /** + * The direction, as the caller knows it, of the function of entry {@code ifun} of the list + * {@link #extractVariables} checks: the list starts with the {@code nprimary} functions of the + * other direction that name its input variables. + */ + private static String userDirection(int ifun, int nprimary, boolean forward) { + return (ifun < nprimary) != forward ? "forward" : "inverse"; + } + + /** + * The number, as the caller knows it, of the function of entry {@code ifun} of the list {@link + * #extractVariables} checks: the {@code nprimary} functions of the other direction at its start + * follow {@code nextra} intermediate functions there. + */ + private static int userNumber(int ifun, int nprimary, int nextra) { + return ifun < nprimary ? ifun + 1 + nextra : ifun + 1 - nprimary; + } + + /** + * The variable names on the left-hand sides of {@code fun}, as C's {@code ExtractVariables} + * finds them: the text before each first {@code =}, or the whole function if it has none, + * which must be a name, and no two of which may be the same. + * + * @param fun the {@code nprimary} functions of the other direction that name the input + * variables, then every function of the direction being compiled + * @throws AstException {@code AST__MISVN}, {@code AST__VARIN} or {@code AST__DUVAR} + */ + private static String[] extractVariables( + String method, String cls, String[] fun, int nin, int nout, int nfwd, int ninv, boolean forward) { + int nfun = fun.length; + int nprimary = forward ? nin : nout; + int nextra = forward ? ninv - nin : nfwd - nout; + String[] var = new String[nfun]; + for (int ifun = 0; ifun < nfun; ifun++) { + String f = fun[ifun]; + int nc = f.indexOf('='); + if (nc < 0) { + nc = f.length(); + } + String message = null; + int status = 0; + if (nc == 0) { + status = AstException.AST__MISVN; + if (nc < f.length()) { + message = method + "(" + cls + "): No left hand side in expression: \"" + f + "\"."; + } else { + message = method + ": Transformation function contains no variable name."; + } + } else { + var[ifun] = f.substring(0, nc); + int iend = parseName(var[ifun], 0); + if (iend < 0 || iend + 1 < var[ifun].length()) { + status = AstException.AST__VARIN; + message = method + "(" + cls + "): Variable name is invalid: \"" + var[ifun] + "\"."; + } + } + if (message != null) { + throw Ast.err( + status, + message + "\nError in " + userDirection(ifun, nprimary, forward) + " transformation function " + + userNumber(ifun, nprimary, nextra) + "."); + } + } + for (int i1 = 1; i1 < nfun; i1++) { + for (int i2 = 0; i2 < i1; i2++) { + if (var[i1].equals(var[i2])) { + throw Ast.err( + AstException.AST__DUVAR, + method + "(" + cls + "): Duplicate definition of variable name: \"" + var[i1] + "\".\n" + + "Conflict between " + userDirection(i1, nprimary, forward) + " function " + + userNumber(i1, nprimary, nextra) + " and " + userDirection(i2, nprimary, forward) + + " function " + userNumber(i2, nprimary, nextra) + "."); + } + } + } + return var; + } + + /** + * The right-hand sides of {@code fun}, the text after each first {@code =}, as C's {@code + * ExtractExpressions} finds them; null if no function has an {@code =}, which leaves the + * transformation undefined. + * + * @throws AstException {@code AST__NORHS} if a function's {@code =} has nothing after it, or + * some but not all functions have an {@code =} + */ + private static String[] extractExpressions(String method, String cls, String[] fun, boolean forward) { + String dir = forward ? "forward" : "inverse"; + int nfun = fun.length; + String[] exprs = new String[nfun]; + int nud = 0; + int iud = 0; + for (int ifun = 0; ifun < nfun; ifun++) { + int eq = fun[ifun].indexOf('='); + if (eq >= 0) { + if (eq + 1 < fun[ifun].length()) { + exprs[ifun] = fun[ifun].substring(eq + 1); + } else { + throw Ast.err( + AstException.AST__NORHS, + method + "(" + cls + "): Missing right hand side in expression: \"" + fun[ifun] + + "\".\nError in " + dir + " transformation function " + (ifun + 1) + "."); + } + } else { + nud++; + if (nud == 1) { + iud = ifun; + } + } + } + if (nud != 0 && nud != nfun) { + throw Ast.err( + AstException.AST__NORHS, + method + "(" + cls + "): Missing right hand side in function: \"" + fun[iud] + "\".\nError in " + + dir + " transformation function " + (iud + 1) + "."); + } + return nud != 0 ? null : exprs; + } + + // ------------------------------------------------------------------ + // CompileExpression + // ------------------------------------------------------------------ + + /** The expression up to and including index {@code iend}, as C's {@code "%.*s"} quotes it. */ + private static String through(String exprs, int iend) { + return exprs.substring(0, Math.min(iend + 1, exprs.length())); + } + + /** + * The parenthesis level, the argument count at each level and the symbol that opened each + * level, which C's {@code ValidateSymbol} keeps for {@code CompileExpression}, together with the + * constants found so far. + */ + private static final class Context { + int lpar; + int[] argcount = new int[4]; + int[] opensym = new int[4]; + double[] con = new double[4]; + int ncon; + + void addConstant(double value) { + if (ncon == con.length) { + con = Arrays.copyOf(con, ncon * 2); + } + con[ncon++] = value; + } + } + + /** + * Compiles one expression, as C's {@code CompileExpression} does: each symbol is identified + * from the symbol table, looking for the longest text that may stand where it does (an + * operator or an operand, according to the symbol before it, and a unary operator only after + * a symbol that allows one), and checked against the parentheses and function arguments so + * far; text that matches no symbol is parsed as a constant and then as a variable. The symbols + * are then sorted into evaluation order. + * + * @param exprs the expression, in lower case without white space + * @param nvar the number of variables of {@code var} the expression may use + * @throws AstException with C's status and message if the expression is invalid + */ + private static Expression compileExpression(String method, String cls, String exprs, int nvar, String[] var) { + Context ctx = new Context(); + int[] symlist = new int[Math.max(1, exprs.length())]; + int nsym = 0; + boolean opernext = false; + boolean unarynext = true; + int nsymbols = MathMapToken.count(); + int iend = -1; + for (int istart = 0; istart < exprs.length(); istart = iend + 1) { + boolean found = false; + int size = 0; + int sym = 0; + for (int isym = 0; isym < nsymbols; isym++) { + MathMapToken.Symbol s = MathMapToken.symbol(isym); + if (s.size() != 0 + && s.operleft == opernext + && (!s.unaryoper || unarynext) + && exprs.startsWith(s.text, istart)) { + found = true; + if (s.size() > size) { + sym = isym; + size = s.size(); + iend = istart + size - 1; + } + } + } + if (found) { + validateSymbol(method, cls, exprs, iend, sym, ctx); + } else if (opernext) { + throw Ast.err( + AstException.AST__MIOPR, + method + "(" + cls + "): Missing or invalid operator in the expression \"" + + through(exprs, istart) + "\"."); + } else { + double[] value = new double[1]; + iend = parseConstant(method, cls, exprs, istart, value); + if (iend >= istart) { + sym = MathMapToken.SYMBOL_LDCON; + ctx.addConstant(value[0]); + } else { + int[] ivar = new int[1]; + iend = parseVariable(method, cls, exprs, istart, nvar, var, ivar); + if (ivar[0] != -1) { + sym = MathMapToken.SYMBOL_LDVAR; + ctx.addConstant(ivar[0]); + } else { + throw Ast.err( + AstException.AST__MIOPA, + method + "(" + cls + "): Missing or invalid operand in the expression \"" + + through(exprs, istart) + "\"."); + } + } + } + MathMapToken.Symbol s = MathMapToken.symbol(sym); + opernext = !s.operright; + unarynext = s.unarynext; + if (nsym == symlist.length) { + symlist = Arrays.copyOf(symlist, nsym * 2); + } + symlist[nsym++] = sym; + } + if (!opernext) { + throw Ast.err( + AstException.AST__MIOPA, + method + "(" + cls + "): Missing or invalid operand in the expression \"" + exprs + "\"."); + } else if (ctx.lpar > 0) { + throw Ast.err( + AstException.AST__MRPAR, + method + "(" + cls + "): Missing right parenthesis in the expression \"" + exprs + "\"."); + } + double[] con = Arrays.copyOf(ctx.con, ctx.ncon); + int[] stacksize = new int[1]; + int[] code = evaluationSort(con, nsym, symlist, stacksize); + return new Expression(code, con, stacksize[0]); + } + + /** + * Checks a standard symbol against the parentheses and function arguments so far, as C's + * {@code ValidateSymbol} does: a comma must separate the arguments of a function, a closing + * parenthesis needs an opening one, and a function call must close with the number of + * arguments the function takes. Closing the call of a function that takes a variable number of + * arguments adds the number given to the constants. + * + * @param iend the index in {@code exprs} of the symbol's last character + * @throws AstException {@code AST__COMIN}, {@code AST__MLPAR} or {@code AST__WRNFA} + */ + private static void validateSymbol(String method, String cls, String exprs, int iend, int sym, Context ctx) { + MathMapToken.Symbol s = MathMapToken.symbol(sym); + if (",".equals(s.text)) { + if (ctx.lpar <= 0 || ctx.argcount[ctx.lpar - 1] == 0) { + throw Ast.err( + AstException.AST__COMIN, + method + "(" + cls + "): Spurious comma encountered in the expression \"" + through(exprs, iend) + + "\"."); + } + ctx.argcount[ctx.lpar - 1]++; + } else if (s.parincrement > 0) { + if (ctx.lpar == ctx.argcount.length) { + ctx.argcount = Arrays.copyOf(ctx.argcount, ctx.lpar * 2); + ctx.opensym = Arrays.copyOf(ctx.opensym, ctx.lpar * 2); + } + ctx.argcount[++ctx.lpar - 1] = s.nargs != 0 ? 1 : 0; + ctx.opensym[ctx.lpar - 1] = sym; + } else if (s.parincrement < 0) { + if (ctx.lpar == 0) { + throw Ast.err( + AstException.AST__MLPAR, + method + "(" + cls + "): Missing left parenthesis in the expression \"" + through(exprs, iend) + + "\"."); + } + int nargs = MathMapToken.symbol(ctx.opensym[ctx.lpar - 1]).nargs; + if (nargs > 0) { + if (ctx.argcount[ctx.lpar - 1] != nargs) { + throw Ast.err( + AstException.AST__WRNFA, + method + "(" + cls + "): Wrong number of function arguments in the expression \"" + + through(exprs, iend) + "\"."); + } + ctx.lpar--; + } else if (nargs < 0) { + if (ctx.argcount[ctx.lpar - 1] < -nargs) { + throw Ast.err( + AstException.AST__WRNFA, + method + "(" + cls + "): Insufficient function arguments in the expression \"" + + through(exprs, iend) + "\"."); + } + ctx.addConstant(ctx.argcount[--ctx.lpar]); + } else { + ctx.lpar--; + } + } + } + + /** + * Parses the numeric constant that starts at {@code istart}, as C's {@code ParseConstant} does. + * Text starting with a digit or a decimal point is meant as a constant; it extends while each + * character may continue it (digits, one decimal point before any exponent, one {@code d} or + * {@code e} exponent character after a digit, and one sign directly after it), and is invalid + * if a decimal point, exponent character or sign cannot continue it, except that a sign after + * a digit ends it. Every field must hold a digit. + * + * @param con receives the value in its first element + * @return the index of the constant's last character, or -1 if the text does not start with a + * digit or a decimal point + * @throws AstException {@code AST__CONIN} if the constant is invalid + */ + private static int parseConstant(String method, String cls, String exprs, int istart, double[] con) { + con[0] = 0.0; + char c = at(exprs, istart); + boolean numeral = isDigit(c); + boolean dpoint = c == '.'; + if (!(numeral || dpoint)) { + return -1; + } + boolean expon = false; + boolean sign = false; + boolean valid = true; + int iend = istart; + boolean iscon = true; + while ((c = at(exprs, iend + 1)) != '\0' && iscon) { + iscon = false; + if (isDigit(c)) { + numeral = true; + iscon = true; + } else if (c == '.') { + if (!(dpoint || expon)) { + dpoint = true; + iscon = true; + } else { + valid = false; + } + } else if (c == 'd' || c == 'e') { + if (!expon && numeral) { + expon = true; + numeral = false; + iscon = true; + } else { + valid = false; + } + } else if (c == '+' || c == '-') { + if (expon && !sign && !numeral) { + sign = true; + iscon = true; + } else if (!numeral) { + valid = false; + } + } + if (iscon || !valid) { + iend++; + } + } + valid = valid && numeral; + if (valid) { + // C reads the constant with sscanf after changing 'd' to 'e'; every character must be + // read. + String str = exprs.substring(istart, iend + 1).replace('d', 'e'); + CScan.Num n = CScan.strtod(str, 0); + if (n == null || n.end < str.length()) { + valid = false; + } else { + con[0] = n.value; + } + } + if (!valid) { + throw Ast.err( + AstException.AST__CONIN, + method + "(" + cls + "): Invalid constant syntax in the expression \"" + through(exprs, iend) + + "\"."); + } + return iend; + } + + /** + * The index of the last character of the name starting at {@code istart}, as C's {@code + * ParseName} finds it: a letter followed by letters, digits and underscores; -1 if the text + * does not start with a letter. + */ + static int parseName(String exprs, int istart) { + int iend = -1; + if (isAlpha(at(exprs, istart))) { + iend = istart; + char c; + while ((c = at(exprs, iend + 1)) != '\0') { + if (!(isAlnum(c) || c == '_')) { + break; + } + iend++; + } + } + return iend; + } + + /** + * Parses the variable name starting at {@code istart}, as C's {@code ParseVariable} does. + * + * @param ivar receives in its first element the index of the name in {@code var}, or -1 if + * the text does not start with a name + * @return the index of the name's last character, or -1 if there is no name + * @throws AstException {@code AST__UDVOF} if the name is not one of the first {@code nvar} + * names of {@code var} + */ + private static int parseVariable( + String method, String cls, String exprs, int istart, int nvar, String[] var, int[] ivar) { + ivar[0] = -1; + int iend = parseName(exprs, istart); + if (iend >= istart) { + String name = exprs.substring(istart, iend + 1); + for (int i = 0; i < nvar; i++) { + if (name.equals(var[i])) { + ivar[0] = i; + return iend; + } + } + throw Ast.err( + AstException.AST__UDVOF, + method + "(" + cls + "): Undefined variable or function in the expression \"" + through(exprs, iend) + + "\"."); + } + return iend; + } + + // ------------------------------------------------------------------ + // EvaluationSort + // ------------------------------------------------------------------ + + /** + * Sorts the symbols into evaluation order and gives their opcodes, as C's {@code + * EvaluationSort} does: each symbol is pushed on to a sort stack when its priority seen from + * the left is greater than the stack top's seen from the right, and otherwise the stack top is + * sent to the output; a closing parenthesis cancels the opening parenthesis or function call + * it meets on the stack. The sort stack occupies the part of {@code symlist} already read. + * + * @param con the constants, which give the argument count of each function taking a variable + * number of arguments + * @param stacksize receives in its first element the evaluation stack size the opcodes need + * @return the opcodes, the first element being the number that follow + */ + private static int[] evaluationSort(double[] con, int nsym, int[] symlist, int[] stacksize) { + boolean flush = false; + int icon = 0; + int isym = 0; + int ncode = 0; + int nstack = 0; + int tos = -1; + int[] code = new int[nsym + 1]; + stacksize[0] = 0; + while (tos > -1 || isym < nsym) { + boolean push; + if (tos == -1) { + push = true; + } else if (isym >= nsym) { + push = false; + } else if (flush) { + push = false; + flush = false; + } else { + push = MathMapToken.symbol(symlist[isym]).leftpriority + > MathMapToken.symbol(symlist[tos]).rightpriority; + } + if (push) { + int sym = symlist[isym++]; + if (MathMapToken.symbol(sym).parincrement < 0) { + flush = true; + } else { + symlist[++tos] = sym; + } + } else { + int sym = symlist[tos--]; + if (sym == MathMapToken.SYMBOL_LDVAR || sym == MathMapToken.SYMBOL_LDCON) { + icon++; + } + MathMapToken.Symbol s = MathMapToken.symbol(sym); + if (s.opcode != MathMapToken.OP_NULL) { + code[++ncode] = s.opcode; + if (s.nargs >= 0) { + nstack += s.stackincrement; + } else { + nstack -= (int) Math.round(con[icon++]) - 1; + } + stacksize[0] = Math.max(nstack, stacksize[0]); + } + } + } + code[0] = ncode; + return Arrays.copyOf(code, ncode + 1); + } +} diff --git a/src/main/java/uk/ac/starlink/ast/MathMapRandom.java b/src/main/java/uk/ac/starlink/ast/MathMapRandom.java new file mode 100644 index 0000000..1138889 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/MathMapRandom.java @@ -0,0 +1,402 @@ +package uk.ac.starlink.ast; + +import java.util.concurrent.atomic.AtomicLong; + +/** + * The random-number generator context of a MathMap, C's {@code Rcontext} (mathmap.h), with C's + * {@code Rand}, {@code Gauss}, {@code Poisson}, {@code LogGamma} and {@code DefaultSeed} + * (mathmap.c). + * + *

Each MathMap has its own context, which holds the Seed attribute and the state of a pair of + * combined linear congruential generators with a Bays-Durham shuffle, so that the sequences of + * different MathMaps are independent and each is set by its own Seed. A copy of a MathMap takes a + * copy of its context, as C's copy does, and so continues the same sequence. C's {@code long} is + * 64 bits on the platforms the library is built for, which Java's {@code long} matches; the + * generator's arithmetic depends on it for a Seed below 1. + * + *

Ported from Rust {@code mappings/mathmap/rng.rs} and C {@code mathmap.c}. + */ +final class MathMapRandom implements Cloneable { + + /** The size of the shuffle table, {@code AST_MATHMAP_RAND_CONTEXT_NTAB_}. */ + private static final int NTAB = 32; + + /** The number of warm-up iterations before the shuffle table is filled. */ + private static final int NWARM = 8; + + private static final long A1 = 40014L; + private static final long A2 = 40692L; + private static final long M1 = 2147483563L; + private static final long M2 = 2147483399L; + private static final long Q1 = 53668L; + private static final long Q2 = 52774L; + private static final long R1 = 12211L; + private static final long R2 = 3791L; + + /** The number of random integers combined into each value, C's {@code nrand}. */ + private static final int NRAND; + + /** The scale decrement for successive integers, C's {@code scale0}. */ + private static final double SCALE0; + + /** The normalisation constant, C's {@code norm}. */ + private static final double NORM; + + static { + // C's local initialisation of Rand: the bits the generator produces (from m1), the bits of + // a double's mantissa, and hence how many integers make a double. + int lbits = Math.getExponent((double) M1) + 1; + int dbits = (int) Math.ceil(53.0 * Math.log(2.0) / Math.log(2.0)); + NRAND = (dbits + lbits - 1) / lbits; + SCALE0 = 1.0 / (M1 - 1L); + double sum = 0.0; + double scale = 1.0; + for (int irand = 0; irand < NRAND; irand++) { + scale *= SCALE0; + sum += scale; + } + NORM = 1.0 / (sum * (M1 - 2L)); + } + + /** The constants of the quick generator of {@link #defaultSeed}. */ + private static final long SEED_A = 8121L; + + private static final long SEED_C = 28411L; + private static final long SEED_M = 134456L; + + /** + * The quick generator {@link #defaultSeed} mixes into each seed, C's {@code static long rand} + * of {@code DefaultSeed}, which C starts from the time and the processor time on first use and + * warms up with five iterations. It is shared by every MathMap, as C's is. + */ + private static final AtomicLong SEED_RAND = new AtomicLong(initialSeedRand()); + + /** C's first-use initialisation of {@code DefaultSeed}'s generator. */ + private static long initialSeedRand() { + long bits = (System.currentTimeMillis() / 1000L) ^ clock(); + long rand = Long.remainderUnsigned(bits, SEED_M); + for (int iwarm = 0; iwarm < 5; iwarm++) { + rand = (rand * SEED_A + SEED_C) % SEED_M; + } + return rand; + } + + /** + * The stand-in for C's {@code clock()}, the processor time used: the JVM's high-resolution + * time. Each serves only as bits that are hard to predict. + */ + private static long clock() { + return System.nanoTime(); + } + + /** The state of the first generator. */ + private long rand1; + + /** The state of the second generator. */ + private long rand2; + + /** The last random integer produced. */ + private long randomInt; + + /** The shuffle table. */ + private long[] table = new long[NTAB]; + + /** Whether the generator has been initialised from the seed. */ + private boolean active; + + /** The seed used when the generator is initialised. */ + private int seed; + + /** Whether the seed was set through the Seed attribute. */ + private boolean seedSet; + + /** + * Whether {@link #gauss} has a second value saved from its last pair. C keeps this, and the + * value, in variables of {@code Gauss} shared by every MathMap; here each context keeps its + * own. + */ + private boolean ysaved; + + /** The second value of {@link #gauss}'s last pair, used when {@link #ysaved} is true. */ + private double ysave; + + /** + * A context with an unpredictable default seed, as {@code astInitMathMap} makes it: inactive, + * with no last random integer and the Seed unset. + */ + MathMapRandom() { + this(false, 0); + } + + /** + * A context as C's {@code astInitMathMap} or {@code astLoadMathMap} makes it: inactive, with no + * last random integer, and with the seed given if {@code seeded} and an unpredictable default + * otherwise. + */ + MathMapRandom(boolean seeded, int value) { + active = false; + randomInt = 0L; + seedSet = seeded; + seed = seeded ? value : defaultSeed(); + } + + /** A copy of this context, as C's copy of a MathMap copies its context. */ + MathMapRandom copy() { + try { + MathMapRandom c = (MathMapRandom) super.clone(); + c.table = table.clone(); + return c; + } catch (CloneNotSupportedException e) { + AstException err = Ast.err(AstException.AST__INTER, "astCopy(MathMap): cannot clone the random context."); + err.initCause(e); + throw err; + } + } + + // ------------------------------------------------------------------ + // The Seed attribute + // ------------------------------------------------------------------ + + /** The seed: the one set, or the unpredictable default chosen when it was last unset. */ + int getSeed() { + return seed; + } + + /** Whether the seed was set through the Seed attribute. */ + boolean testSeed() { + return seedSet; + } + + /** Sets the seed and marks the generator to be initialised from it when next used. */ + void setSeed(int value) { + seedSet = true; + active = false; + seed = value; + } + + /** + * Clears the seed, giving it a new unpredictable default value, and marks the generator to be + * initialised from it when next used. + */ + void clearSeed() { + seedSet = false; + active = false; + seed = defaultSeed(); + } + + // ------------------------------------------------------------------ + // DefaultSeed + // ------------------------------------------------------------------ + + /** + * An unpredictable seed, as C's {@code DefaultSeed} makes one: the bits of the time and the + * processor time ({@link #clock}), of the context's identity, of the last random integer the + * context produced, and of the next value of a quick generator shared by every MathMap, so + * that two seeds made in quick succession differ. C uses the context's address as its + * identity; Java has no addresses, so {@link System#identityHashCode} stands in for it. + */ + private int defaultSeed() { + long rand = SEED_RAND.updateAndGet(r -> (r * SEED_A + SEED_C) % SEED_M); + long bits = System.currentTimeMillis() / 1000L; + bits ^= clock(); + bits ^= System.identityHashCode(this); + bits ^= randomInt; + double scaled = ((double) rand / (SEED_M - 1L)) * (0x1.0p64 * (1.0 - Math.ulp(1.0))); + bits ^= MathMapEvaluator.toUnsignedLong(scaled); + return (int) bits; + } + + // ------------------------------------------------------------------ + // Rand + // ------------------------------------------------------------------ + + /** + * A random value uniformly distributed between 0 and 1 inclusive, as C's {@code Rand} gives + * it. The generator is first initialised from the seed if it is not active: a seed below 1 has + * {@code LONG_MAX} added, and is replaced by {@code LONG_MAX} if still below 1. + */ + double rand() { + if (!active) { + long s = seed; + if (s < 1) { + s = s + Long.MAX_VALUE; + } + if (s < 1) { + s = Long.MAX_VALUE; + } + rand1 = s; + rand2 = s; + for (int itab = NTAB + NWARM - 1; itab >= 0; itab--) { + long tmp = rand1 / Q1; + rand1 = A1 * (rand1 - tmp * Q1) - tmp * R1; + if (rand1 < 0L) { + rand1 += M1; + } + if (itab < NTAB) { + table[itab] = rand1; + } + } + randomInt = table[0]; + active = true; + } + double result = 0.0; + double scale = NORM; + for (int irand = 0; irand < NRAND; irand++) { + long tmp = rand1 / Q1; + rand1 = A1 * (rand1 - tmp * Q1) - tmp * R1; + if (rand1 < 0L) { + rand1 += M1; + } + tmp = rand2 / Q2; + rand2 = A2 * (rand2 - tmp * Q2) - tmp * R2; + if (rand2 < 0L) { + rand2 += M2; + } + // C converts the quotient to int, keeping its low 32 bits, and then folds a negative + // index into the table's range. + int itab = (int) (randomInt / (1L + (M1 - 1L) / NTAB)); + if (itab < 0) { + itab = -itab; + } + itab = itab % NTAB; + randomInt = table[itab]; + table[itab] = rand1; + randomInt -= rand2; + if (randomInt < 1L) { + randomInt += M1 - 1L; + } + scale *= SCALE0; + result += scale * (randomInt - 1L); + } + return result; + } + + // ------------------------------------------------------------------ + // Gauss + // ------------------------------------------------------------------ + + /** + * A random value from a standard Gaussian distribution, as C's {@code Gauss} gives it: values + * come in pairs from the Box-Muller transformation of a point drawn uniformly inside the unit + * circle, the second being kept for the next call. A context that is not active discards a + * kept value. + */ + double gauss() { + if (!active) { + ysaved = false; + } + double x; + if (ysaved) { + x = ysave; + ysaved = false; + } else { + double y; + while (true) { + double rsq; + do { + x = 2.0 * rand() - 1.0; + y = 2.0 * rand() - 1.0; + rsq = x * x + y * y; + } while (rsq >= 1.0 || rsq == 0.0); + double s = -2.0 * Math.log(rsq); + if (Double.MAX_VALUE * rsq >= s) { + s = Math.sqrt(s / rsq); + x *= s; + y *= s; + break; + } + } + ysave = y; + ysaved = true; + } + return x; + } + + // ------------------------------------------------------------------ + // Poisson and LogGamma + // ------------------------------------------------------------------ + + /** + * A random integer value from a Poisson distribution with mean {@code mean}, as C's {@code + * Poisson} gives it: {@link Mapping#AST__BAD} for a negative mean; zero for a zero mean; for a + * mean up to 9.3, the number of uniform values whose product stays above {@code exp(-mean)}; + * for a larger mean, a value drawn from a Lorentzian distribution and accepted with the ratio + * of the two distributions; and for a mean so large that the deviation is negligible, the mean + * itself. C keeps the constants it derives from the mean in static variables for the next + * call with the same mean; they are computed here for each call, giving the same values. + */ + double poisson(double mean) { + final double small = 9.3; + double result; + double pi = Math.acos(-1.0); + double sqrtPoint9 = Math.sqrt(0.9); + double huge = Math.pow(1.0e3 / Math.ulp(1.0), 2.0); + double ranmax = (Math.sqrt(Double.MAX_VALUE - 0.9) / Math.sqrt(0.9)) * (1.0 - 4.0 * Math.ulp(1.0)); + if (mean < 0.0) { + result = Mapping.AST__BAD; + } else if (mean == 0.0) { + result = 0.0; + } else if (mean <= small) { + double thresh = Math.exp(-mean); + double product = 1.0; + result = -1.0; + do { + product *= rand(); + result += 1.0; + } while (product > thresh); + } else if (mean <= huge) { + double logMean = Math.log(mean); + double root2mean = Math.sqrt(2.0 * mean); + double beta = mean * logMean - logGamma(mean + 1.0); + double ran; + double pfract; + do { + do { + // C also retries a tangent that overflows, which a finite argument does not. + do { + ran = Math.tan(pi * rand()); + } while (ran > ranmax); + result = ran * root2mean + mean; + } while (result < 0.0); + result = Math.floor(result); + ran *= sqrtPoint9; + pfract = (0.9 + ran * ran) * Math.exp(result * logMean - logGamma(result + 1.0) - beta); + } while (rand() > pfract); + } else { + result = mean; + } + return result; + } + + /** + * The natural logarithm of the gamma function, as C's {@code LogGamma} computes it with the + * six-term series of Lanczos; {@link Mapping#AST__BAD} for an argument not above zero. + */ + // The coefficients are C's literals, one of which has more digits than a double holds. + @SuppressWarnings("FloatingPointLiteralPrecision") + static double logGamma(double x) { + final double c0 = 1.000000000190015; + final double c1 = 76.18009172947146; + final double c2 = -86.50532032941677; + final double c3 = 24.01409824083091; + final double c4 = -1.231739572450155; + final double c5 = 0.1208650973866179e-2; + final double c6 = -0.5395239384953e-5; + final double g = 5.0; + if (x <= 0.0) { + return Mapping.AST__BAD; + } + double rootTwopi = Math.sqrt(2.0 * Math.acos(-1.0)); + double xx = x; + double sum = c0; + sum += c1 / ++xx; + sum += c2 / ++xx; + sum += c3 / ++xx; + sum += c4 / ++xx; + sum += c5 / ++xx; + sum += c6 / ++xx; + double result = x + g + 0.5; + result -= (x + 0.5) * Math.log(result); + return Math.log(rootTwopi * sum / x) - result; + } +} diff --git a/src/main/java/uk/ac/starlink/ast/MathMapToken.java b/src/main/java/uk/ac/starlink/ast/MathMapToken.java new file mode 100644 index 0000000..079fc12 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/MathMapToken.java @@ -0,0 +1,508 @@ +package uk.ac.starlink.ast; + +/** + * The operation codes of a compiled MathMap function and the symbols that may appear in a + * MathMap expression, as C's {@code Oper} enum and {@code symbol} array (mathmap.c) define them. + * + *

Ported from Rust {@code mappings/mathmap/{token,opcode}.rs} and C {@code mathmap.c}. Rust + * reads expressions with its own tokenizer; this class keeps C's table, which {@link + * MathMapParser} searches as C's {@code CompileExpression} does. + */ +final class MathMapToken { + + private MathMapToken() {} + + // ------------------------------------------------------------------ + // Operation codes, in the order of C's Oper enum + // ------------------------------------------------------------------ + + /** Load a constant. */ + static final int OP_LDCON = 0; + + /** Load a variable. */ + static final int OP_LDVAR = 1; + + /** Load the bad value, {@code AST__BAD}. */ + static final int OP_LDBAD = 2; + + /** Load the number of decimal digits, {@code AST__DBL_DIG}. */ + static final int OP_LDDIG = 3; + + /** Load the relative precision, {@code DBL_EPSILON}. */ + static final int OP_LDEPS = 4; + + /** Load the largest value, {@code DBL_MAX}. */ + static final int OP_LDMAX = 5; + + /** Load the largest decimal exponent, {@code DBL_MAX_10_EXP}. */ + static final int OP_LDMAX10E = 6; + + /** Load the largest exponent, {@code DBL_MAX_EXP}. */ + static final int OP_LDMAXE = 7; + + /** Load the number of mantissa digits, {@code DBL_MANT_DIG}. */ + static final int OP_LDMDIG = 8; + + /** Load the smallest normalised value, {@code DBL_MIN}. */ + static final int OP_LDMIN = 9; + + /** Load the smallest decimal exponent, {@code DBL_MIN_10_EXP}. */ + static final int OP_LDMIN10E = 10; + + /** Load the smallest exponent, {@code DBL_MIN_EXP}. */ + static final int OP_LDMINE = 11; + + /** Load the floating-point radix, {@code FLT_RADIX}. */ + static final int OP_LDRAD = 12; + + /** Load the rounding mode, {@code FLT_ROUNDS}. */ + static final int OP_LDRND = 13; + + /** Load e, the base of natural logarithms. */ + static final int OP_LDE = 14; + + /** Load pi. */ + static final int OP_LDPI = 15; + + /** Absolute value. */ + static final int OP_ABS = 16; + + /** Inverse cosine (radians). */ + static final int OP_ACOS = 17; + + /** Inverse cosine (degrees). */ + static final int OP_ACOSD = 18; + + /** Inverse hyperbolic cosine. */ + static final int OP_ACOSH = 19; + + /** Inverse hyperbolic cotangent. */ + static final int OP_ACOTH = 20; + + /** Inverse hyperbolic cosecant. */ + static final int OP_ACSCH = 21; + + /** Inverse hyperbolic secant. */ + static final int OP_ASECH = 22; + + /** Inverse sine (radians). */ + static final int OP_ASIN = 23; + + /** Inverse sine (degrees). */ + static final int OP_ASIND = 24; + + /** Inverse hyperbolic sine. */ + static final int OP_ASINH = 25; + + /** Inverse tangent (radians). */ + static final int OP_ATAN = 26; + + /** Inverse tangent (degrees). */ + static final int OP_ATAND = 27; + + /** Inverse hyperbolic tangent. */ + static final int OP_ATANH = 28; + + /** Round up. */ + static final int OP_CEIL = 29; + + /** Cosine (radians). */ + static final int OP_COS = 30; + + /** Cosine (degrees). */ + static final int OP_COSD = 31; + + /** Hyperbolic cosine. */ + static final int OP_COSH = 32; + + /** Hyperbolic cotangent. */ + static final int OP_COTH = 33; + + /** Hyperbolic cosecant. */ + static final int OP_CSCH = 34; + + /** Exponential function. */ + static final int OP_EXP = 35; + + /** Round down. */ + static final int OP_FLOOR = 36; + + /** Integer part (round towards zero). */ + static final int OP_INT = 37; + + /** Test for the bad value. */ + static final int OP_ISBAD = 38; + + /** Natural logarithm. */ + static final int OP_LOG = 39; + + /** Base 10 logarithm. */ + static final int OP_LOG10 = 40; + + /** Fortran's NINT (round to nearest). */ + static final int OP_NINT = 41; + + /** Poisson random number. */ + static final int OP_POISS = 42; + + /** Hyperbolic secant. */ + static final int OP_SECH = 43; + + /** Sine (radians). */ + static final int OP_SIN = 44; + + /** Sinc function, {@code sin(x)/x}. */ + static final int OP_SINC = 45; + + /** Sine (degrees). */ + static final int OP_SIND = 46; + + /** Hyperbolic sine. */ + static final int OP_SINH = 47; + + /** Square. */ + static final int OP_SQR = 48; + + /** Square root. */ + static final int OP_SQRT = 49; + + /** Tangent (radians). */ + static final int OP_TAN = 50; + + /** Tangent (degrees). */ + static final int OP_TAND = 51; + + /** Hyperbolic tangent. */ + static final int OP_TANH = 52; + + /** Inverse tangent of two arguments (radians). */ + static final int OP_ATAN2 = 53; + + /** Inverse tangent of two arguments (degrees). */ + static final int OP_ATAN2D = 54; + + /** Fortran's DIM (positive difference). */ + static final int OP_DIM = 55; + + /** Gaussian random number. */ + static final int OP_GAUSS = 56; + + /** Modulus function. */ + static final int OP_MOD = 57; + + /** Raise to a power. */ + static final int OP_POW = 58; + + /** Uniformly distributed random number. */ + static final int OP_RAND = 59; + + /** Transfer of sign. */ + static final int OP_SIGN = 60; + + /** C's "question mark" operator, {@code a?b:c}. */ + static final int OP_QIF = 61; + + /** Maximum of two or more values. */ + static final int OP_MAX = 62; + + /** Minimum of two or more values. */ + static final int OP_MIN = 63; + + /** Negate. */ + static final int OP_NEG = 64; + + /** Boolean NOT. */ + static final int OP_NOT = 65; + + /** Add. */ + static final int OP_ADD = 66; + + /** Divide. */ + static final int OP_DIV = 67; + + /** Multiply. */ + static final int OP_MUL = 68; + + /** Subtract. */ + static final int OP_SUB = 69; + + /** Shift bits left. */ + static final int OP_SHFTL = 70; + + /** Shift bits right. */ + static final int OP_SHFTR = 71; + + /** Relational equal. */ + static final int OP_EQ = 72; + + /** Greater than or equal. */ + static final int OP_GE = 73; + + /** Greater than. */ + static final int OP_GT = 74; + + /** Less than or equal. */ + static final int OP_LE = 75; + + /** Less than. */ + static final int OP_LT = 76; + + /** Not equal. */ + static final int OP_NE = 77; + + /** Bit-wise AND. */ + static final int OP_BITAND = 78; + + /** Bit-wise OR. */ + static final int OP_BITOR = 79; + + /** Bit-wise exclusive OR. */ + static final int OP_BITXOR = 80; + + /** Boolean AND. */ + static final int OP_AND = 81; + + /** Fortran's logical {@code .EQV.}. */ + static final int OP_EQV = 82; + + /** Boolean OR. */ + static final int OP_OR = 83; + + /** Boolean exclusive OR. */ + static final int OP_XOR = 84; + + /** Null operation. */ + static final int OP_NULL = 85; + + // ------------------------------------------------------------------ + // The symbol table + // ------------------------------------------------------------------ + + /** A symbol which may appear in an expression, C's {@code Symbol} structure. */ + static final class Symbol { + + /** The symbol's text as it appears in expressions; empty for a constant or variable. */ + final String text; + + /** Whether the symbol is an operator when seen from the left. */ + final boolean operleft; + + /** Whether the symbol is an operator when seen from the right. */ + final boolean operright; + + /** Whether the symbol may be followed by a unary {@code +} or {@code -}. */ + final boolean unarynext; + + /** Whether the symbol is a unary {@code +} or {@code -}. */ + final boolean unaryoper; + + /** The symbol's priority seen from the left. */ + final int leftpriority; + + /** The symbol's priority seen from the right. */ + final int rightpriority; + + /** The change in parenthesis level. */ + final int parincrement; + + /** The change in evaluation stack size. */ + final int stackincrement; + + /** + * The number of function arguments: 0 for a symbol that is not a function, minus the least + * number for a function taking a variable number. + */ + final int nargs; + + /** The operation code the symbol gives. */ + final int opcode; + + Symbol( + String text, + int operleft, + int operright, + int unarynext, + int unaryoper, + int leftpriority, + int rightpriority, + int parincrement, + int stackincrement, + int nargs, + int opcode) { + this.text = text; + this.operleft = operleft != 0; + this.operright = operright != 0; + this.unarynext = unarynext != 0; + this.unaryoper = unaryoper != 0; + this.leftpriority = leftpriority; + this.rightpriority = rightpriority; + this.parincrement = parincrement; + this.stackincrement = stackincrement; + this.nargs = nargs; + this.opcode = opcode; + } + + /** The length of the symbol's text, C's {@code size}. */ + int size() { + return text.length(); + } + } + + /** + * Every symbol, as C's {@code symbol} array lists them (without its end marker): a symbol's + * index here is its symbol number. + */ + private static final Symbol[] SYMBOLS = { + // User-supplied constants and variables. + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDCON), + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDVAR), + + // System constants. + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDBAD), + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDDIG), + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDEPS), + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDMDIG), + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDMAX), + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDMAX10E), + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDMAXE), + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDMIN), + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDMIN10E), + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDMINE), + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDRAD), + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDRND), + + // Mathematical constants. + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDE), + new Symbol("", 0, 0, 0, 0, 19, 19, 0, 1, 0, OP_LDPI), + + // Functions with one argument. + new Symbol("abs(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ABS), + new Symbol("acos(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ACOS), + new Symbol("acosd(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ACOSD), + new Symbol("acosh(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ACOSH), + new Symbol("acoth(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ACOTH), + new Symbol("acsch(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ACSCH), + new Symbol("aint(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_INT), + new Symbol("asech(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ASECH), + new Symbol("asin(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ASIN), + new Symbol("asind(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ASIND), + new Symbol("asinh(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ASINH), + new Symbol("atan(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ATAN), + new Symbol("atand(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ATAND), + new Symbol("atanh(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ATANH), + new Symbol("ceil(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_CEIL), + new Symbol("cos(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_COS), + new Symbol("cosd(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_COSD), + new Symbol("cosh(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_COSH), + new Symbol("coth(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_COTH), + new Symbol("csch(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_CSCH), + new Symbol("exp(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_EXP), + new Symbol("fabs(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ABS), + new Symbol("floor(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_FLOOR), + new Symbol("int(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_INT), + new Symbol("isbad(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_ISBAD), + new Symbol("log(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_LOG), + new Symbol("log10(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_LOG10), + new Symbol("nint(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_NINT), + new Symbol("poisson(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_POISS), + new Symbol("sech(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_SECH), + new Symbol("sin(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_SIN), + new Symbol("sinc(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_SINC), + new Symbol("sind(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_SIND), + new Symbol("sinh(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_SINH), + new Symbol("sqr(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_SQR), + new Symbol("sqrt(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_SQRT), + new Symbol("tan(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_TAN), + new Symbol("tand(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_TAND), + new Symbol("tanh(", 0, 1, 1, 0, 19, 1, 1, 0, 1, OP_TANH), + + // Functions with two arguments. + new Symbol("atan2(", 0, 1, 1, 0, 19, 1, 1, -1, 2, OP_ATAN2), + new Symbol("atan2d(", 0, 1, 1, 0, 19, 1, 1, -1, 2, OP_ATAN2D), + new Symbol("dim(", 0, 1, 1, 0, 19, 1, 1, -1, 2, OP_DIM), + new Symbol("fmod(", 0, 1, 1, 0, 19, 1, 1, -1, 2, OP_MOD), + new Symbol("gauss(", 0, 1, 1, 0, 19, 1, 1, -1, 2, OP_GAUSS), + new Symbol("mod(", 0, 1, 1, 0, 19, 1, 1, -1, 2, OP_MOD), + new Symbol("pow(", 0, 1, 1, 0, 19, 1, 1, -1, 2, OP_POW), + new Symbol("rand(", 0, 1, 1, 0, 19, 1, 1, -1, 2, OP_RAND), + new Symbol("sign(", 0, 1, 1, 0, 19, 1, 1, -1, 2, OP_SIGN), + + // Functions with three arguments. + new Symbol("qif(", 0, 1, 1, 0, 19, 1, 1, -2, 3, OP_QIF), + + // Functions with variable numbers of arguments. + new Symbol("max(", 0, 1, 1, 0, 19, 1, 1, -1, -2, OP_MAX), + new Symbol("min(", 0, 1, 1, 0, 19, 1, 1, -1, -2, OP_MIN), + + // Parenthesised expressions. + new Symbol(")", 1, 0, 0, 0, 2, 19, -1, 0, 0, OP_NULL), + new Symbol("(", 0, 1, 1, 0, 19, 1, 1, 0, 0, OP_NULL), + + // Unary arithmetic operators. + new Symbol("+", 0, 1, 1, 1, 17, 16, 0, 0, 0, OP_NULL), + new Symbol("-", 0, 1, 1, 1, 17, 16, 0, 0, 0, OP_NEG), + + // Unary boolean operators. + new Symbol("!", 0, 1, 1, 0, 17, 16, 0, 0, 0, OP_NOT), + new Symbol(".not.", 0, 1, 1, 0, 17, 16, 0, 0, 0, OP_NOT), + + // Binary arithmetic operators. + new Symbol("**", 1, 1, 1, 0, 18, 15, 0, -1, 0, OP_POW), + new Symbol("*", 1, 1, 1, 0, 14, 14, 0, -1, 0, OP_MUL), + new Symbol("/", 1, 1, 1, 0, 14, 14, 0, -1, 0, OP_DIV), + new Symbol("+", 1, 1, 1, 0, 13, 13, 0, -1, 0, OP_ADD), + new Symbol("-", 1, 1, 1, 0, 13, 13, 0, -1, 0, OP_SUB), + + // Bit-shift operators. + new Symbol("<<", 1, 1, 1, 0, 12, 12, 0, -1, 0, OP_SHFTL), + new Symbol(">>", 1, 1, 1, 0, 12, 12, 0, -1, 0, OP_SHFTR), + + // Relational operators. + new Symbol("<", 1, 1, 1, 0, 11, 11, 0, -1, 0, OP_LT), + new Symbol(".lt.", 1, 1, 1, 0, 11, 11, 0, -1, 0, OP_LT), + new Symbol("<=", 1, 1, 1, 0, 11, 11, 0, -1, 0, OP_LE), + new Symbol(".le.", 1, 1, 1, 0, 11, 11, 0, -1, 0, OP_LE), + new Symbol(">", 1, 1, 1, 0, 11, 11, 0, -1, 0, OP_GT), + new Symbol(".gt.", 1, 1, 1, 0, 11, 11, 0, -1, 0, OP_GT), + new Symbol(">=", 1, 1, 1, 0, 11, 11, 0, -1, 0, OP_GE), + new Symbol(".ge.", 1, 1, 1, 0, 11, 11, 0, -1, 0, OP_GE), + new Symbol("==", 1, 1, 1, 0, 10, 10, 0, -1, 0, OP_EQ), + new Symbol(".eq.", 1, 1, 1, 0, 10, 10, 0, -1, 0, OP_EQ), + new Symbol("!=", 1, 1, 1, 0, 10, 10, 0, -1, 0, OP_NE), + new Symbol(".ne.", 1, 1, 1, 0, 10, 10, 0, -1, 0, OP_NE), + + // Bit-wise operators. + new Symbol("&", 1, 1, 1, 0, 9, 9, 0, -1, 0, OP_BITAND), + new Symbol("^", 1, 1, 1, 0, 8, 8, 0, -1, 0, OP_BITXOR), + new Symbol("|", 1, 1, 1, 0, 7, 7, 0, -1, 0, OP_BITOR), + + // Binary boolean operators. + new Symbol("&&", 1, 1, 1, 0, 6, 6, 0, -1, 0, OP_AND), + new Symbol(".and.", 1, 1, 1, 0, 6, 6, 0, -1, 0, OP_AND), + new Symbol("^^", 1, 1, 1, 0, 5, 5, 0, -1, 0, OP_XOR), + new Symbol("||", 1, 1, 1, 0, 4, 4, 0, -1, 0, OP_OR), + new Symbol(".or.", 1, 1, 1, 0, 4, 4, 0, -1, 0, OP_OR), + new Symbol(".eqv.", 1, 1, 1, 0, 3, 3, 0, -1, 0, OP_EQV), + new Symbol(".neqv.", 1, 1, 1, 0, 3, 3, 0, -1, 0, OP_XOR), + new Symbol(".xor.", 1, 1, 1, 0, 3, 3, 0, -1, 0, OP_XOR), + + // Separators. + new Symbol(",", 1, 1, 1, 0, 2, 2, 0, 0, 0, OP_NULL), + }; + + /** The symbol number of "load a constant", C's {@code symbol_ldcon}. */ + static final int SYMBOL_LDCON = 0; + + /** The symbol number of "load a variable", C's {@code symbol_ldvar}. */ + static final int SYMBOL_LDVAR = 1; + + /** The number of symbols. */ + static int count() { + return SYMBOLS.length; + } + + /** The symbol with number {@code sym}. */ + static Symbol symbol(int sym) { + return SYMBOLS[sym]; + } +} diff --git a/src/main/java/uk/ac/starlink/ast/MatrixMap.java b/src/main/java/uk/ac/starlink/ast/MatrixMap.java index dc99974..e376a0d 100644 --- a/src/main/java/uk/ac/starlink/ast/MatrixMap.java +++ b/src/main/java/uk/ac/starlink/ast/MatrixMap.java @@ -303,6 +303,48 @@ boolean isLinear() { return true; } + /** + * matrixmap.c {@code Equal}: {@code that} is a MatrixMap with the same numbers of inputs and + * outputs and, with both stored in full form for the duration, the same elements, to within + * {@code astEQUAL}, in the matrices each applies forward: the inverse matrix of an inverted + * MatrixMap. If either of those matrices is missing, the matrices each applies in the inverse + * direction are compared instead, and if either of those is missing too the MatrixMaps are + * taken to be equal. Both are compressed again afterwards ({@link #compressMatrix()}), which, + * as in C, may zero negligible elements of a matrix stored in full form. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof MatrixMap)) { + return false; + } + MatrixMap other = (MatrixMap) that; + int nin = getNin(); + int nout = getNout(); + if (other.getNout() != nout || other.getNin() != nin) { + return false; + } + boolean result = true; + expandMatrix(); + other.expandMatrix(); + double[] thisMatrix = getInvert() ? iMatrix : fMatrix; + double[] thatMatrix = other.getInvert() ? other.iMatrix : other.fMatrix; + if (thisMatrix == null || thatMatrix == null) { + thisMatrix = getInvert() ? fMatrix : iMatrix; + thatMatrix = other.getInvert() ? other.fMatrix : other.iMatrix; + } + if (thisMatrix != null && thatMatrix != null) { + for (int i = 0; i < nin * nout; i++) { + if (!MappingHelpers.astEqual(thisMatrix[i], thatMatrix[i])) { + result = false; + break; + } + } + } + compressMatrix(); + other.compressMatrix(); + return result; + } + /** {@link MatrixMapMerge#matrixMapMerge}, matrixmap.c {@code MapMerge}. */ @Override int mapMerge(MergeList list, int where, boolean series) { diff --git a/src/main/java/uk/ac/starlink/ast/NeedsChannelizing.java b/src/main/java/uk/ac/starlink/ast/NeedsChannelizing.java new file mode 100644 index 0000000..6b5bb90 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/NeedsChannelizing.java @@ -0,0 +1,38 @@ +package uk.ac.starlink.ast; + +/** + * Declares that an {@code AstObject} requires object-specific preparation before writing to and/or + * after reading from a {@code Channel}. Any object implementing this interface will have the + * {@code channelize} method called on it before it is written to a sink by a Channel, and the + * {@code unChannelize} method called on it after it is read from a source by a Channel. No other + * {@code uk.ac.starlink.ast} methods will be called on it between calls to {@code channelize} and + * {@code unChannelize}, so {@code channelize} may leave the object in an unusable state, as long + * as {@code unChannelize} undoes this situation. + * + *

Only the Object given to {@link Channel#write} or returned by {@link Channel#read} is treated + * this way, not the Objects it holds. + */ +public interface NeedsChannelizing { + + /** + * Does object-specific preparation for output to a {@code Channel}. This method is called by + * the writing methods of a Channel prior to doing the actual write. + * + *

The actions of this method should be reversed by the {@code unChannelize} method. + * + * @throws Exception the implementation may cause any exception to be thrown. This will scupper + * the write. + */ + void channelize() throws Exception; + + /** + * Reverses the effects of {@code channelize}. This method is called by the reading methods of + * a Channel after doing the actual read. It is also called by the writing methods of a Channel + * after doing the actual write, to undo possible destructive effects of the {@code channelize} + * call. + * + * @throws Exception the implementation may cause any exception to be thrown. This will scupper + * the read. + */ + void unChannelize() throws Exception; +} diff --git a/src/main/java/uk/ac/starlink/ast/ObjectRegistry.java b/src/main/java/uk/ac/starlink/ast/ObjectRegistry.java index 4e9f85a..52f5914 100644 --- a/src/main/java/uk/ac/starlink/ast/ObjectRegistry.java +++ b/src/main/java/uk/ac/starlink/ast/ObjectRegistry.java @@ -36,6 +36,8 @@ static Loader loader(String className) { return CmpMap::new; case "DSBSpecFrame": return DSBSpecFrame::new; + case "DssMap": + return DssMap::new; case "FitsChan": return FitsChan::new; case "FluxFrame": @@ -44,14 +46,26 @@ static Loader loader(String className) { return Frame::new; case "FrameSet": return FrameSet::new; + case "GrismMap": + return GrismMap::new; + case "IntraMap": + return IntraMap::new; case "KeyMap": return KeyMap::new; + case "LutMap": + return LutMap::new; + case "MathMap": + return MathMap::new; case "MatrixMap": return MatrixMap::new; + case "PcdMap": + return PcdMap::new; case "PermMap": return PermMap::new; case "PolyMap": return PolyMap::new; + case "RateMap": + return RateMap::new; case "ShiftMap": return ShiftMap::new; case "SkyAxis": @@ -68,10 +82,14 @@ static Loader loader(String className) { return SpecMap::new; case "SphMap": return SphMap::new; + case "SwitchMap": + return SwitchMap::new; case "TimeFrame": return TimeFrame::new; case "TimeMap": return TimeMap::new; + case "TranMap": + return TranMap::new; case "UnitMap": return UnitMap::new; case "WcsMap": diff --git a/src/main/java/uk/ac/starlink/ast/PcdMap.java b/src/main/java/uk/ac/starlink/ast/PcdMap.java new file mode 100644 index 0000000..0c45801 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/PcdMap.java @@ -0,0 +1,776 @@ +package uk.ac.starlink.ast; + +import java.util.Arrays; +import java.util.Objects; + +/** + * A non-linear Mapping which transforms 2-dimensional positions to correct for the radial + * distortion introduced by some cameras and telescopes. This can take the form either of + * pincushion or barrel distortion, and is characterised by a single distortion coefficient. + * + *

A PcdMap is specified by giving this distortion coefficient and the coordinates of the centre + * of the radial distortion. The forward transformation of a PcdMap applies the distortion: + * + *

+ *    RD = R * ( 1 + C * R * R )
+ * 
+ * + *

where R is the undistorted radial distance from the distortion centre (specified by attribute + * PcdCen), RD is the radial distance from the same centre in the presence of distortion, and C is + * the distortion coefficient (given by attribute Disco). + * + *

The inverse transformation of a PcdMap removes the distortion produced by the forward + * transformation. The expression used to derive R from RD is an approximate inverse of the + * expression above, the one SLALIB's {@code sla_UNPCD} uses. + * + *

Disco and PcdCen(1), PcdCen(2) have defaults of zero. The constructor sets all three unless + * given {@link #AST__BAD}. Once the PcdMap is held by another Object, such as a CmpMap, none of them + * can be set or cleared. + * + *

Ported from Rust {@code mappings/pcdmap.rs} and C {@code pcdmap.c}. + */ +public class PcdMap extends Mapping { + + /** 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; + + /** Disco, {@link #AST__BAD} while unset (C's {@code disco}). */ + private double disco = AST__BAD; + + /** PcdCen for axes 1 and 2, each {@link #AST__BAD} while unset (C's {@code pcdcen}). */ + private double[] centre = {AST__BAD, AST__BAD}; + + /** + * Creates a PcdMap, as C's {@code astPcdMap} does: each value given is stored as set, so that + * only {@link #AST__BAD} leaves an attribute unset. + * + * @param disco the distortion coefficient: negative for barrel distortion, positive for + * pincushion distortion, zero for none + * @param pcdcen the coordinates of the centre of the distortion, two values + * @throws NullPointerException if {@code pcdcen} is null + * @throws IllegalArgumentException if {@code pcdcen} has fewer than two values + */ + public PcdMap(double disco, double[] pcdcen) { + super(2, 2, true, true); + Objects.requireNonNull(pcdcen, "Supplied array is null"); + if (pcdcen.length < 2) { + throw new IllegalArgumentException("Supplied array has only " + pcdcen.length + " elements (needs 2)"); + } + this.centre[0] = pcdcen[0]; + this.centre[1] = pcdcen[1]; + this.disco = disco; + } + + /** + * Loads a PcdMap from its description, as C's {@code astLoadPcdMap} does: each attribute read + * is set through its private setter, which, given the value just read, keeps the record of + * simplification the Mapping part set up. + */ + PcdMap(NativeNode node) { + super(node); + NativeNode part = node.section("PcdMap"); + centre[0] = part.readDouble("PcdCn0", AST__BAD); + if (testPcdCenValue(0)) { + setPcdCenValue(0, centre[0]); + } + centre[1] = part.readDouble("PcdCn1", AST__BAD); + if (testPcdCenValue(1)) { + setPcdCenValue(1, centre[1]); + } + disco = part.readDouble("Disco", AST__BAD); + if (testDiscoValue()) { + setDiscoValue(disco); + } + } + + /** Gives the copy its own centre, as C's byte-by-byte copy does. */ + @Override + void deepCopy() { + super.deepCopy(); + centre = centre.clone(); + } + + @Override + String dumpComment() { + return "Apply pincushion distortion"; + } + + /** + * Writes the centre and the coefficient, each as a comment holding its default when it is + * unset, as C's {@code Dump} (pcdmap.c) does. + */ + @Override + void dump(NativeNode node) { + super.dump(node); + node.writeIsA("Mapping", "Mapping between coordinate systems"); + node.writeDouble("PcdCn0", testPcdCenValue(0), true, getPcdCenValue(0), "Distortion centre on first axis"); + node.writeDouble("PcdCn1", testPcdCenValue(1), true, getPcdCenValue(1), "Distortion centre on second axis"); + node.writeDouble("Disco", testDiscoValue(), true, getDiscoValue(), "Distortion coefficient"); + } + + // ------------------------------------------------------------------ + // Transformation + // ------------------------------------------------------------------ + + /** + * C's {@code Transform} (pcdmap.c): the forward transformation moves each point along the line + * from the centre by the factor {@code 1 + C * R * R}; the inverse moves it back by the + * approximate inverse factor of SLALIB's {@code sla_UNPCD}. A point with a bad coordinate + * gives bad values on both axes; a coordinate that is not finite is bad (C tests only for + * {@link #AST__BAD}). + */ + @Override + void transformInto(double[][] in, int npoint, boolean forward, double[][] out) { + validateTransformInto(in, npoint, forward, out); + double c = getDiscoValue(); + double cen0 = getPcdCenValue(0); + double cen1 = getPcdCenValue(1); + double[] x = in[0]; + double[] y = in[1]; + double[] xo = out[0]; + double[] yo = out[1]; + if (effectiveForward(forward)) { + for (int p = 0; p < npoint; p++) { + if (!isBad(x[p]) && !isBad(y[p])) { + double dx = x[p] - cen0; + double dy = y[p] - cen1; + double f = 1.0 + c * (dx * dx + dy * dy); + xo[p] = dx * f + cen0; + yo[p] = dy * f + cen1; + } else { + xo[p] = AST__BAD; + yo[p] = AST__BAD; + } + } + } else { + for (int p = 0; p < npoint; p++) { + if (!isBad(x[p]) && !isBad(y[p])) { + double dxp = x[p] - cen0; + double dyp = y[p] - cen1; + double f = unpcdFactor(c * (dxp * dxp + dyp * dyp)); + xo[p] = dxp * f + cen0; + yo[p] = dyp * f + cen1; + } else { + xo[p] = AST__BAD; + yo[p] = AST__BAD; + } + } + } + } + + /** + * The factor C's inverse {@code Transform} (pcdmap.c), after SLALIB's {@code sla_UNPCD}, + * multiplies a distorted offset from the centre by to remove the distortion, given {@code cr2}, + * the coefficient times the square of the distorted radius. + */ + private static double unpcdFactor(double cr2) { + double a = (2.0 * cr2 + 1.0) / (3.0 * cr2 + 1.0); + double cr2a2 = cr2 * a * a; + return (2.0 * cr2a2 * a + 1.0) / (3.0 * cr2a2 + 1.0); + } + + /** + * NaN protocol: {@link #transformInto} without the per-point checks of bad input, through + * whose arithmetic NaN propagates to both outputs. + */ + @Override + void transformIntoNan(double[][] in, int npoint, boolean forward, double[][] out) { + double c = getDiscoValue(); + double cen0 = getPcdCenValue(0); + double cen1 = getPcdCenValue(1); + double[] x = in[0]; + double[] y = in[1]; + double[] xo = out[0]; + double[] yo = out[1]; + if (effectiveForward(forward)) { + for (int p = 0; p < npoint; p++) { + double dx = x[p] - cen0; + double dy = y[p] - cen1; + double f = 1.0 + c * (dx * dx + dy * dy); + xo[p] = dx * f + cen0; + yo[p] = dy * f + cen1; + } + } else { + for (int p = 0; p < npoint; p++) { + double dxp = x[p] - cen0; + double dyp = y[p] - cen1; + double f = unpcdFactor(c * (dxp * dxp + dyp * dyp)); + xo[p] = dxp * f + cen0; + yo[p] = dyp * f + cen1; + } + } + } + + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + /** + * pcdmap.c {@code Equal}: {@code that} is a PcdMap with the same Invert attribute, whose + * centre and coefficient are, to within {@code astEQUAL}, this one's. C compares the + * attributes as stored, so an unset attribute differs from one set to its default. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof PcdMap)) { + return false; + } + PcdMap other = (PcdMap) that; + return getInvert() == other.getInvert() + && MappingHelpers.astEqual(centre[0], other.centre[0]) + && MappingHelpers.astEqual(centre[1], other.centre[1]) + && MappingHelpers.astEqual(disco, other.disco); + } + + // ------------------------------------------------------------------ + // Simplification + // ------------------------------------------------------------------ + + /** + * pcdmap.c's own {@code EQUAL}: whether two values are equal to within {@code 1e5} times the + * larger of their scaled sum and {@code DBL_MIN}; two bad values are equal, and a bad value and + * a good one are not. Unlike {@code astEQUAL}, whose floor is {@code 1e-12}, it finds only + * values below about {@code 2e-303} equal to zero. + */ + private static boolean equal(double aa, double bb) { + if (aa == AST__BAD) { + return bb == AST__BAD; + } + return bb != AST__BAD + && Math.abs(aa - bb) <= 1.0e5 * Math.max((Math.abs(aa) + Math.abs(bb)) * DBL_EPSILON, DBL_MIN); + } + + /** Whether the class of {@code m} is exactly {@code cls}, as C's comparison of class names tests. */ + private static boolean isClass(Mapping m, Class cls) { + return m.getClass() == cls; + } + + /** + * pcdmap.c {@code MapMerge}. A PcdMap whose coefficient is zero (by pcdmap.c's {@link #equal}) + * is replaced by a UnitMap, in series or in parallel, and nothing else is done. Otherwise, in + * series only, the PcdMap is merged with the Mapping before it or, failing that, the one after + * it, as {@link #canMerge} decides: with a PcdMap to give a UnitMap, with a UnitMap to give the + * PcdMap itself, applied as before. Failing that, it is swapped past a neighbouring ZoomMap or + * PermMap ({@link #swap}). + */ + @Override + int mapMerge(MergeList list, int where, boolean series) { + if (equal(getDiscoValue(), 0.0)) { + list.set(where, new UnitMap(2), false); + return where; + } + if (!series) { + return -1; + } + Mapping lower = where > 0 ? list.map(where - 1) : null; + Mapping upper = where < list.size() - 1 ? list.map(where + 1) : null; + Mapping nclass; + int i1; + if (lower != null && canMerge(lower, list.map(where), list.invert(where - 1), list.invert(where))) { + nclass = lower; + i1 = where - 1; + } else if (upper != null && canMerge(list.map(where), upper, list.invert(where), list.invert(where + 1))) { + nclass = upper; + i1 = where; + } else { + return swap(list, where, lower, upper, series); + } + if (isClass(nclass, PcdMap.class)) { + list.replacePairWith(i1, new UnitMap(2), false); + } else { + list.replacePairWith(i1, list.map(where), list.invert(where)); + } + return i1; + } + + /** + * C's {@code CanMerge} (pcdmap.c): whether {@code map1} followed by {@code map2}, applied with + * the Invert values {@code inv1} and {@code inv2}, one of which is a PcdMap, can be merged: + * the other is a UnitMap, or a PcdMap applied in the other direction whose coefficient and + * centre, as their getters give them, are equal by pcdmap.c's {@link #equal}. C sets each + * Mapping's Invert attribute to the value given while it looks at them; nothing it reads + * depends on it, so here the values are compared directly. + */ + private static boolean canMerge(Mapping map1, Mapping map2, boolean inv1, boolean inv2) { + PcdMap pcd; + Mapping nopcd; + boolean pcdInv; + boolean nopcdInv; + if (isClass(map1, PcdMap.class)) { + pcd = (PcdMap) map1; + nopcd = map2; + pcdInv = inv1; + nopcdInv = inv2; + } else if (isClass(map2, PcdMap.class)) { + pcd = (PcdMap) map2; + nopcd = map1; + pcdInv = inv2; + nopcdInv = inv1; + } else { + // C's "unusable": neither is a PcdMap. + return false; + } + if (isClass(nopcd, UnitMap.class)) { + return true; + } + if (isClass(nopcd, PcdMap.class)) { + PcdMap pcd2 = (PcdMap) nopcd; + return equal(pcd.getDiscoValue(), pcd2.getDiscoValue()) + && equal(pcd.getPcdCenValue(0), pcd2.getPcdCenValue(0)) + && equal(pcd.getPcdCenValue(1), pcd2.getPcdCenValue(1)) + && pcdInv != nopcdInv; + } + return false; + } + + /** + * C's {@code CanSwap} (pcdmap.c): whether {@code map1} followed by {@code map2}, applied with + * the Invert values {@code inv1} and {@code inv2}, one of which is a PcdMap, can be swapped: + * the other is a ZoomMap, or a PermMap of two inputs and two outputs that exchanges them in + * both directions (found by C's {@code PermGet}, with each Mapping's Invert attribute set to + * the value given while it looks). + */ + private static boolean canSwap(Mapping map1, Mapping map2, boolean inv1, boolean inv2) { + int invert0 = map1.swapInvert(inv1); + int invert1 = map2.swapInvert(inv2); + try { + Mapping nopcd = isClass(map1, PcdMap.class) ? map2 : map1; + if (isClass(nopcd, ZoomMap.class)) { + return true; + } + if (isClass(nopcd, PermMap.class) && nopcd.getNin() == 2 && nopcd.getNout() == 2) { + WinMapMerge.PermParts perm = WinMapMerge.permGet((PermMap) nopcd); + int[] outperm = perm.outperm; + int[] inperm = perm.inperm; + return outperm[0] == 1 && outperm[1] == 0 && inperm[0] == 1 && inperm[1] == 0; + } + return false; + } finally { + map1.restoreInvert(invert0); + map2.restoreInvert(invert1); + } + } + + /** + * The swap part of pcdmap.c {@code MapMerge}, in series, when the PcdMap at {@code where} + * merges with neither neighbour. On each side whose neighbour it can be swapped past ({@link + * #canSwap}), the Mappings up to the nearest UnitMap or PcdMap are counted, stopping at any that + * is not a ZoomMap or PermMap. The PcdMap is swapped towards the nearer such Mapping (the upper + * one on a tie), and the list from the new neighbours on is offered to the Mapping beginning + * it, so that the PcdMap merges at once. With no such Mapping, the swap with the lower and then + * the upper neighbour is made on copies, and kept only if one of the two swapped Mappings + * simplifies to a Mapping of another class. + * + * @return the index of the first entry changed, or -1 if nothing changed + */ + private static int swap(MergeList list, int where, Mapping lower, Mapping upper, boolean series) { + int nmap = list.size(); + boolean swaphi = false; + if (where + 1 < nmap) { + swaphi = canSwap(list.map(where), list.map(where + 1), list.invert(where), list.invert(where + 1)); + } + int nstep2 = -1; + if (swaphi) { + for (int i2 = where + 1; i2 < nmap; i2++) { + Mapping m = list.map(i2); + if (isClass(m, UnitMap.class) || isClass(m, PcdMap.class)) { + nstep2 = i2 - where - 1; + break; + } + if (!isClass(m, ZoomMap.class) && !isClass(m, PermMap.class)) { + break; + } + } + } + + boolean swaplo = false; + if (where > 0) { + swaplo = canSwap(list.map(where - 1), list.map(where), list.invert(where - 1), list.invert(where)); + } + int nstep1 = -1; + if (swaplo) { + for (int i1 = where - 1; i1 >= 0; i1--) { + Mapping m = list.map(i1); + if (isClass(m, UnitMap.class) || isClass(m, PcdMap.class)) { + nstep1 = where - 1 - i1; + break; + } + if (!isClass(m, ZoomMap.class) && !isClass(m, PermMap.class)) { + break; + } + } + } + + Mapping nclass; + int i1; + if (nstep1 != -1 && (nstep2 == -1 || nstep2 > nstep1)) { + nclass = lower; + i1 = where - 1; + } else if (nstep2 != -1) { + nclass = upper; + i1 = where; + } else { + nclass = null; + i1 = -1; + } + + if (nclass != null) { + swapPair(list, i1, where - i1, nclass); + if (where == i1 && where + 1 < list.size()) { + list.mergeSubrange(where + 1, 0, series); + } else if (where - 2 >= 0) { + list.mergeSubrange(where - 2, 0, series); + } + return i1; + } + + if (swaphi || swaplo) { + for (int i = 0; i < 2; i++) { + Mapping neighbour; + int j1; + if (i == 0 && swaplo) { + neighbour = lower; + j1 = where - 1; + } else if (i == 1 && swaphi) { + neighbour = upper; + j1 = where; + } else { + continue; + } + MergeList mc = new MergeList( + Arrays.asList((Mapping) list.map(j1).copy(), (Mapping) + list.map(j1 + 1).copy()), + Arrays.asList(list.invert(j1), list.invert(j1 + 1))); + swapPair(mc, 0, where - j1, neighbour); + Mapping smc0 = mc.map(0).simplify(); + Mapping smc1 = mc.map(1).simplify(); + if (smc0.getClass() != mc.map(0).getClass() + || smc1.getClass() != mc.map(1).getClass()) { + list.set(j1, mc.map(0), mc.invert(0)); + list.set(j1 + 1, mc.map(1), mc.invert(1)); + return j1; + } + } + } + return -1; + } + + /** + * Swaps the PcdMap at {@code base + ipc} with the Mapping {@code nclass} beside it, by C's + * {@code PcdZoom} or {@code PcdPerm}. + */ + private static void swapPair(MergeList maps, int base, int ipc, Mapping nclass) { + if (isClass(nclass, ZoomMap.class)) { + pcdZoom(maps, base, ipc); + } else if (isClass(nclass, PermMap.class)) { + pcdPerm(maps, base, ipc); + } else { + throw Ast.err( + AstException.AST__INTER, + "astMapMerge(PcdMap): Cannot swap a PcdMap with a " + nclass.astClass() + + " (internal AST programming error)."); + } + } + + /** + * C's {@code PcdZoom} (pcdmap.c): swaps a PcdMap and a ZoomMap applied in series, the entries + * at {@code base} and {@code base + 1}, the PcdMap at {@code base + ipc}. The ZoomMap's factor + * is its Zoom attribute, or the reciprocal when the list applies it inverted; the new ZoomMap + * has that factor and is applied forward. The new PcdMap's centre is the old one's multiplied + * (PcdMap first) or divided (PcdMap second) by the factor, and its coefficient the old one's + * divided or multiplied by the square of the factor; it is applied with the Invert value of + * the old PcdMap, and its own Invert attribute is set when that value is. + */ + private static void pcdZoom(MergeList maps, int base, int ipc) { + PcdMap pm = (PcdMap) maps.map(base + ipc); + ZoomMap zm = (ZoomMap) maps.map(base + 1 - ipc); + boolean pinv = maps.invert(base + ipc); + boolean zinv = maps.invert(base + 1 - ipc); + int oldPinv = pm.swapInvert(pinv); + int oldZinv = zm.swapInvert(zinv); + double zoom; + double disc; + double xcen; + double ycen; + try { + zoom = zm.getZoom(); + if (zinv) { + zoom = 1.0 / zoom; + } + disc = pm.getDiscoValue(); + xcen = pm.getPcdCenValue(0); + ycen = pm.getPcdCenValue(1); + } finally { + pm.restoreInvert(oldPinv); + zm.restoreInvert(oldZinv); + } + ZoomMap zm2 = new ZoomMap(2, zoom); + double[] cen = new double[2]; + if (ipc == 0) { + cen[0] = xcen * zoom; + cen[1] = ycen * zoom; + disc = disc / (zoom * zoom); + } else { + cen[0] = xcen / zoom; + cen[1] = ycen / zoom; + disc = disc * zoom * zoom; + } + PcdMap pm2 = new PcdMap(disc, cen); + if (pinv) { + pm2.invert(); + } + maps.set(base + 1 - ipc, pm2, pinv); + maps.set(base + ipc, zm2, false); + } + + /** + * C's {@code PcdPerm} (pcdmap.c): swaps a PcdMap and a PermMap that exchanges the two axes, + * applied in series, the entries at {@code base} and {@code base + 1}, the PcdMap at {@code + * base + ipc}. The PermMap itself, shared as C clones it, moves to the PcdMap's place with the + * Invert value the list applied it with; the new PcdMap has the old one's coefficient and its + * centre with the axes exchanged, and is applied with the Invert value of the old PcdMap, its + * own Invert attribute being set when that value is. + */ + private static void pcdPerm(MergeList maps, int base, int ipc) { + PcdMap pm = (PcdMap) maps.map(base + ipc); + Mapping rm = maps.map(base + 1 - ipc); + boolean pinv = maps.invert(base + ipc); + boolean rinv = maps.invert(base + 1 - ipc); + int oldPinv = pm.swapInvert(pinv); + int oldRinv = rm.swapInvert(rinv); + double disc; + double xcen; + double ycen; + try { + disc = pm.getDiscoValue(); + xcen = pm.getPcdCenValue(0); + ycen = pm.getPcdCenValue(1); + } finally { + pm.restoreInvert(oldPinv); + rm.restoreInvert(oldRinv); + } + PcdMap pm2 = new PcdMap(disc, new double[] {ycen, xcen}); + if (pinv) { + pm2.invert(); + } + maps.set(base + ipc, rm, rinv); + maps.set(base + 1 - ipc, pm2, pinv); + } + + // ------------------------------------------------------------------ + // Attributes + // ------------------------------------------------------------------ + + /** + * Gets the Disco attribute: the pincushion/barrel distortion coefficient. Positive values give + * pincushion distortion, negative values barrel distortion. The forward transformation + * applies the distortion and the inverse removes it; if the PcdMap is inverted, the forward + * transformation removes the distortion and the inverse applies it, the distortion still being + * given by the same value. Default 0, which gives no distortion. + * + * @return the distortion coefficient + */ + public double getDisco() { + return getD("Disco"); + } + + /** + * Sets the Disco attribute. {@link #AST__BAD} leaves it unset. + * + * @param disco the distortion coefficient + * @throws AstException with status {@code AST__IMMUT} if the PcdMap is held by another Object, + * such as a CmpMap + */ + public void setDisco(double disco) { + setD("Disco", disco); + } + + /** + * Gets the PcdCen attribute for an axis: the coordinate on that axis of the centre of the + * pincushion/barrel distortion. Default 0. + * + * @param axis the axis, 1 or 2 + * @return the coordinate of the centre on the axis + * @throws IndexOutOfBoundsException if {@code axis} is not 1 or 2 + */ + public double getPcdCen(int axis) { + if (axis >= 1 && axis <= 2) { + return getD("PcdCen(" + axis + ")"); + } else { + throw new IndexOutOfBoundsException("axis value " + axis + " is not in the range 1..2"); + } + } + + /** + * Sets the PcdCen attribute for an axis. {@link #AST__BAD} leaves it unset. Through the + * generic attribute methods, a setting or clearing of {@code PcdCen} without an axis applies to + * both axes, and a value got or tested is that of axis 1. + * + * @param axis the axis, 1 or 2 + * @param pcdCen the coordinate of the centre on the axis + * @throws IndexOutOfBoundsException if {@code axis} is not 1 or 2 + * @throws AstException with status {@code AST__IMMUT} if the PcdMap is held by another Object, + * such as a CmpMap + */ + public void setPcdCen(int axis, double pcdCen) { + if (axis >= 1 && axis <= 2) { + setD("PcdCen(" + axis + ")", pcdCen); + } else { + throw new IndexOutOfBoundsException("axis value " + axis + " is not in the range 1..2"); + } + } + + /** Disco, its default when unset (C's {@code astGetDisco}). */ + final double getDiscoValue() { + return disco == AST__BAD ? 0.0 : disco; + } + + private boolean testDiscoValue() { + return disco != AST__BAD; + } + + /** + * C's private {@code SetDisco}, from {@code astMAKE_SET1}: a shared PcdMap refuses the change; + * a value different from the one stored (unset being {@link #AST__BAD}) discards the record of + * simplification; {@link #AST__BAD} leaves the attribute unset. + */ + private void setDiscoValue(double value) { + checkSet1("Disco"); + if (value != disco) { + clearIsSimple(); + } + disco = value; + } + + /** C's {@code ClearDisco}, from {@code astMAKE_CLEAR1}. */ + private void clearDiscoValue() { + checkClear1("Disco"); + clearIsSimple(); + disco = AST__BAD; + } + + /** + * The error C's {@code MAKE_GET}, {@code MAKE_SET}, {@code MAKE_TEST} and {@code MAKE_CLEAR} + * (pcdmap.c) report for an axis index, from zero, other than 0 or 1. + */ + private void checkAxis(int axis, String method) { + if (axis < 0 || axis >= 2) { + throw Ast.err( + AstException.AST__AXIIN, + method + "(" + astClass() + "): Index (" + (axis + 1) + + ") is invalid for attribute PcdCen - it should be in the range 1 to 2."); + } + } + + /** PcdCen for the axis {@code axis} (from zero), its default when unset (C's {@code GetPcdCen}). */ + final double getPcdCenValue(int axis) { + checkAxis(axis, "astGetPcdCen"); + return centre[axis] == AST__BAD ? 0.0 : centre[axis]; + } + + private boolean testPcdCenValue(int axis) { + checkAxis(axis, "astTestPcdCen"); + return centre[axis] != AST__BAD; + } + + /** + * C's private {@code SetPcdCen}, from pcdmap.c's {@code MAKE_SET}: an axis other than 0 or 1 + * is refused; then a shared PcdMap refuses the change; a value different from the one stored + * discards the record of simplification; {@link #AST__BAD} leaves the axis unset. + */ + private void setPcdCenValue(int axis, double value) { + checkAxis(axis, "astSetPcdCen"); + checkSet1("PcdCen"); + if (value != centre[axis]) { + clearIsSimple(); + } + centre[axis] = value; + } + + /** C's private {@code ClearPcdCen}, from pcdmap.c's {@code MAKE_CLEAR}. */ + private void clearPcdCenValue(int axis) { + checkAxis(axis, "astClearPcdCen"); + checkClear1("PcdCen"); + clearIsSimple(); + centre[axis] = AST__BAD; + } + + /** + * The axis number in {@code attrib} if it is {@code pcdcen(n)}, as C's {@code "pcdcen(%d)%n"} + * reads it, or null. + */ + private static Integer pcdCenAxis(String attrib) { + return Frame.axisArg(attrib, "pcdcen"); + } + + /** + * C's {@code GetAttrib}: each value formatted with {@code %.17g}; {@code PcdCen} without an + * axis gives axis 1. + */ + @Override + String getAttrib(String attrib) { + double dval; + Integer axis = pcdCenAxis(attrib); + if ("disco".equals(attrib)) { + dval = getDiscoValue(); + } else if (axis != null) { + dval = getPcdCenValue(axis - 1); + } else if ("pcdcen".equals(attrib)) { + dval = getPcdCenValue(0); + } else { + return super.getAttrib(attrib); + } + return CFormat.format("%.17g", dval); + } + + /** C's {@code SetAttrib}: a value read as a double; {@code PcdCen} without an axis sets both. */ + @Override + void setAttrib(String attrib, String value) { + Double dval = CScan.scanDouble(value); + Integer axis = pcdCenAxis(attrib); + if (dval != null && "disco".equals(attrib)) { + setDiscoValue(dval); + } else if (dval != null && axis != null) { + setPcdCenValue(axis - 1, dval); + } else if (dval != null && "pcdcen".equals(attrib)) { + setPcdCenValue(0, dval); + setPcdCenValue(1, dval); + } else { + super.setAttrib(attrib, value); + } + } + + /** C's {@code TestAttrib}: {@code PcdCen} without an axis tests axis 1. */ + @Override + boolean testAttrib(String attrib) { + Integer axis = pcdCenAxis(attrib); + if ("disco".equals(attrib)) { + return testDiscoValue(); + } else if ("pcdcen".equals(attrib)) { + return testPcdCenValue(0); + } else if (axis != null) { + return testPcdCenValue(axis - 1); + } else { + return super.testAttrib(attrib); + } + } + + /** C's {@code ClearAttrib}: {@code PcdCen} without an axis clears both. */ + @Override + void clearAttrib(String attrib) { + Integer axis = pcdCenAxis(attrib); + if (axis != null) { + clearPcdCenValue(axis - 1); + } else if ("pcdcen".equals(attrib)) { + clearPcdCenValue(0); + clearPcdCenValue(1); + } else if ("disco".equals(attrib)) { + clearDiscoValue(); + } else { + super.clearAttrib(attrib); + } + } +} diff --git a/src/main/java/uk/ac/starlink/ast/PermMap.java b/src/main/java/uk/ac/starlink/ast/PermMap.java index 3a87e50..3107837 100644 --- a/src/main/java/uk/ac/starlink/ast/PermMap.java +++ b/src/main/java/uk/ac/starlink/ast/PermMap.java @@ -409,6 +409,55 @@ MapSplit splitOff(int[] in) { return new MapSplit(result, new UnitMap(nin)); } + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + /** + * permmap.c {@code Equal}: {@code that} is a PermMap with the same numbers of inputs and + * outputs whose permutations, as each PermMap applies them, feed every input in the inverse + * transformation and every output in the forward one from the same coordinate, or, where both + * feed it a constant, from constants of the same value (two bad values being the same), whatever + * their indices. A null permutation feeds each coordinate from the one with the same number, if + * there is one, and otherwise from the first constant (C's {@code SAFE_PERMVAL}). + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof PermMap)) { + return false; + } + PermMap other = (PermMap) that; + int nin = getNin(); + int nout = getNout(); + if (other.getNout() != nout || other.getNin() != nin) { + return false; + } + boolean inv = getInvert(); + boolean thatInv = other.getInvert(); + return samePerm(inv ? outperm : inperm, other, thatInv ? other.outperm : other.inperm, nin, nout) + && samePerm(inv ? inperm : outperm, other, thatInv ? other.inperm : other.outperm, nout, nin); + } + + /** + * Whether {@code n} coordinates are fed alike by this PermMap's permutation {@code perm1} and + * {@code that}'s {@code perm2}, each of whose values is below {@code valmax}, as permmap.c + * {@code Equal} compares them. + */ + private boolean samePerm(int[] perm1, PermMap that, int[] perm2, int n, int valmax) { + for (int i = 0; i < n; i++) { + int p1 = permVal(perm1, i, valmax); + int p2 = permVal(perm2, i, valmax); + if (p1 >= 0 || p2 >= 0) { + if (p1 != p2) { + return false; + } + } else if (constantFor(p1) != that.constantFor(p2)) { + return false; + } + } + return true; + } + // ------------------------------------------------------------------ // Simplification // ------------------------------------------------------------------ diff --git a/src/main/java/uk/ac/starlink/ast/PolyMap.java b/src/main/java/uk/ac/starlink/ast/PolyMap.java index 562573d..e878a18 100644 --- a/src/main/java/uk/ac/starlink/ast/PolyMap.java +++ b/src/main/java/uk/ac/starlink/ast/PolyMap.java @@ -896,12 +896,13 @@ void clearTolInverse() { // ------------------------------------------------------------------ /** - * Whether {@code that} is a PolyMap equivalent to this one, as C's {@code Equal} (polymap.c) - * decides it: the same numbers of inputs and outputs, the same Invert attribute, and, for each - * original transformation, either no coefficients in both or the same coefficient counts, - * maximum powers and powers, and coefficients equal to within {@code astEQUAL}. + * polymap.c {@code Equal}: {@code that} is a PolyMap with the same numbers of inputs and + * outputs, the same Invert attribute, and, for each original transformation, either no + * coefficients in both or the same coefficient counts, maximum powers and powers, and + * coefficients equal to within {@code astEQUAL}. */ - boolean equalTo(Mapping that) { + @Override + boolean equalTo(AstObject that) { if (!(that instanceof PolyMap)) { return false; } @@ -1134,7 +1135,10 @@ private static boolean linearTerms(PolyMap poly, int nin, int nout, double[] off * 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. The Invert attributes set for the comparison are restored. + * 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 @@ -1142,6 +1146,7 @@ private static boolean linearTerms(PolyMap poly, int nin, int nout, double[] off 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(); @@ -1153,7 +1158,7 @@ private static int cancelWithNeighbour(MergeList list, int where, Mapping pmap0, int saved1 = pmap1.swapInvert(inv0); boolean ok; try { - ok = astEqual(pmap0, pmap1); + ok = pmap0.astEqual(pmap1); } finally { pmap1.restoreInvert(saved1); } @@ -1161,26 +1166,19 @@ private static int cancelWithNeighbour(MergeList list, int where, Mapping pmap0, 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 { - pmap0.restoreInvert(saved0); + // C annuls its pointer to a cancelled pmap0, which skips the restore. + if (!cancelled) { + pmap0.restoreInvert(saved0); + } } return result; } - /** - * C's {@code astEqual(pmap0, pmap1)} for a PolyMap {@code pmap1}: the same object, or, through - * the {@code Equal} of {@code pmap0}'s class, an equal PolyMap. The {@code Equal} of every other - * class {@code pmap0} can be here (those the linear replacement makes) finds no PolyMap equal. - */ - // C compares the pointers first (object.c astEqual_): the same object is equal. - @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) - private static boolean astEqual(Mapping pmap0, PolyMap pmap1) { - return pmap0 == pmap1 || (pmap0 instanceof PolyMap && ((PolyMap) pmap0).equalTo(pmap1)); - } - // ------------------------------------------------------------------ // Attribute strings (polymap.c GetAttrib, SetAttrib, TestAttrib, ClearAttrib) // ------------------------------------------------------------------ diff --git a/src/main/java/uk/ac/starlink/ast/RateMap.java b/src/main/java/uk/ac/starlink/ast/RateMap.java new file mode 100644 index 0000000..83e0d0a --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/RateMap.java @@ -0,0 +1,371 @@ +package uk.ac.starlink.ast; + +import java.util.Objects; + +/** + * A Mapping which represents a single element of the Jacobian matrix of another Mapping, the + * "encapsulated Mapping". The number of inputs of a RateMap is the number of inputs of the + * encapsulated Mapping, and it has one output: the rate of change of a chosen output of the + * encapsulated Mapping with respect to a chosen input, at the input position. + * + *

A RateMap that has not been inverted defines no inverse transformation; an inverted one + * defines an inverse transformation but no forward transformation. + * + *

A RateMap does not copy the Mapping it is given: it holds it, as C's holds a cloned pointer + * to it, and {@link #copy} copies it. Being shared, the Mapping's attributes that C makes + * immutable once cloned (such as a ZoomMap's Zoom) can no longer be changed. The RateMap records + * the Mapping's Invert attribute when it is made and uses the Mapping in that orientation whatever + * is later done to the Mapping it shares; its other attributes do change the RateMap, so the + * Mapping should not be changed while the RateMap is in use. + * + *

Ported from Rust {@code mappings/ratemap.rs} and C {@code ratemap.c}. + */ +public class RateMap extends Mapping { + + /** The encapsulated Mapping. */ + private Mapping map; + + /** The Invert attribute of the encapsulated Mapping when the RateMap was made (C's {@code invert}). */ + private final boolean invert; + + /** The zero-based index of the encapsulated Mapping's input that is varied (C's {@code iin}). */ + private final int iin; + + /** The zero-based index of the encapsulated Mapping's output that is differentiated (C's {@code iout}). */ + private final int iout; + + /** + * Creates a RateMap. + * + * @param map the encapsulated Mapping, which must be able to transform in the forward + * direction + * @param ax1 the index of the output of the encapsulated Mapping whose rate of change is + * wanted, the numerator of the Jacobian element; the first axis has index 1 + * @param ax2 the index of the input of the encapsulated Mapping that is varied, the + * denominator of the Jacobian element; the first axis has index 1 + * @throws AstException with status {@code AST__INTRD} if {@code map} cannot transform in the + * forward direction, or {@code AST__INNCO} if {@code ax1} is not an output of {@code map} + * or {@code ax2} not one of its inputs + */ + public RateMap(Mapping map, int ax1, int ax2) { + // astRateMapId_ (ratemap.c) gives astInitRateMap the indices from zero. + this(map, ax1 - 1, ax2 - 1, true); + } + + /** + * C's {@code astRateMap_} and {@code astInitRateMap} (ratemap.c), with zero-based indices: + * shares {@code map} and records its Invert attribute. + * + * @param zeroBased distinguishes this constructor from the public one + */ + RateMap(Mapping map, int iout, int iin, boolean zeroBased) { + super(check(map, iout, iin), 1, true, false); + map.markShared(); + this.map = map; + invert = map.getInvert(); + this.iout = iout; + this.iin = iin; + } + + /** + * The number of inputs of a RateMap of {@code map}, after the checks C's {@code + * astInitRateMap} makes, in its order: the first error found is the one reported. + */ + private static int check(Mapping map, int iout, int iin) { + Objects.requireNonNull(map, "map"); + if (!map.getTranForward()) { + throw Ast.err( + AstException.AST__INTRD, + "astInitRateMap(RateMap): The supplied Mapping is not able to transform coordinates in the " + + "forward direction."); + } + int nin = map.getNin(); + int nout = map.getNout(); + if (iout < 0 || iout >= nout) { + throw Ast.err( + AstException.AST__INNCO, + "astInitRateMap(RateMap): The output axis " + (iout + 1) + + " is out of range - it should be in the range 1 to " + nout + "."); + } + if (iin < 0 || iin >= nin) { + throw Ast.err( + AstException.AST__INNCO, + "astInitRateMap(RateMap): The input axis " + (iin + 1) + + " is out of range - it should be in the range 1 to " + nin + "."); + } + return nin; + } + + /** + * Loads a RateMap from its description, as C's {@code astLoadRateMap} does: {@code Inv}, + * {@code IIn} and {@code IOut} (zero if absent) and the encapsulated Mapping {@code Map}. + * + * @throws AstException with status {@code AST__LDERR} if the Mapping is missing or is not a + * Mapping + */ + RateMap(NativeNode node) { + super(node); + NativeNode part = node.section("RateMap"); + invert = part.readInt("Inv", 0) != 0; + iin = part.readInt("IIn", 0); + iout = part.readInt("IOut", 0); + NativeNode desc = part.readObject("Map"); + if (desc == null) { + throw Ast.err(AstException.AST__LDERR, "astLoadRateMap(RateMap): The Mapping Map is missing."); + } + AstObject obj = ObjectRegistry.loadNested(desc, "Map"); + if (!(obj instanceof Mapping)) { + throw Ast.err( + AstException.AST__LDERR, + "astLoadRateMap(RateMap): The component Map is a " + obj.astClass() + ", not a Mapping."); + } + map = (Mapping) obj; + } + + @Override + String dumpComment() { + return "Differential Mapping"; + } + + /** + * Writes {@code IIn} and {@code IOut} (set when not zero), {@code Inv}, the Invert value + * recorded when the RateMap was made (set when true), and the encapsulated Mapping, with its + * own Invert attribute as it now is, as C's {@code Dump} (ratemap.c) does. + */ + @Override + void dump(NativeNode node) { + super.dump(node); + node.writeIsA("Mapping", "Mapping between coordinate systems"); + node.writeInt("IIn", iin != 0, false, iin, "Index of Mapping input"); + node.writeInt("IOut", iout != 0, false, iout, "Index of Mapping output"); + node.writeInt( + "Inv", + invert, + false, + invert ? 1 : 0, + invert ? "Mapping used in inverse direction" : "Mapping used in forward direction"); + node.writeObject("Map", true, true, NativeNode.of(map), "Mapping to be differentiated"); + } + + /** Gives the copy a copy of the encapsulated Mapping, as C's {@code Copy} (ratemap.c) does. */ + @Override + void deepCopy() { + super.deepCopy(); + map = (Mapping) map.copy(); + } + + // ------------------------------------------------------------------ + // Components + // ------------------------------------------------------------------ + + /** The encapsulated Mapping, shared with the RateMap. */ + Mapping getMap() { + return map; + } + + /** The Invert value the RateMap applies the encapsulated Mapping with. */ + boolean getRecordedInvert() { + return invert; + } + + /** The zero-based index of the encapsulated Mapping's input that is varied. */ + int getIin() { + return iin; + } + + /** The zero-based index of the encapsulated Mapping's output that is differentiated. */ + int getIout() { + return iout; + } + + // ------------------------------------------------------------------ + // Transformation + // ------------------------------------------------------------------ + + /** + * C's {@code Transform} (ratemap.c): the one output at each point is the rate of change of the + * encapsulated Mapping's chosen output with respect to its chosen input there, found + * by {@code astRate} with the Mapping set for the duration to the Invert value recorded when the + * RateMap was made. Every point is passed to {@code astRate}, bad values included, as the rate + * of some Mappings does not depend on the position. + */ + @Override + void transformInto(double[][] in, int npoint, boolean forward, double[][] out) { + validateTransformInto(in, npoint, forward, out); + // validateTransformInto has refused the direction a RateMap does not define, which is C's + // AST__INTER report in Transform. + int ncoord = in.length; + double[] work = new double[ncoord]; + double[] pout = out[0]; + int oldInv = map.swapInvert(invert); + try { + for (int p = 0; p < npoint; p++) { + for (int c = 0; c < ncoord; c++) { + work[c] = in[c][p]; + } + pout[p] = map.rate(work, iout + 1, iin + 1); + } + } finally { + map.restoreInvert(oldInv); + } + } + + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + /** + * ratemap.c {@code Equal}: {@code that} is a RateMap with the same numbers of inputs and + * outputs and the same Invert attribute, the same indices, and an encapsulated Mapping equal + * ({@link #astEqual}) to this one's, each set for the duration to the Invert value its RateMap + * recorded. RateMaps whose Invert attributes differ are never equal. The Invert attributes of + * the Mappings are set back afterwards in C's order. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof RateMap)) { + return false; + } + RateMap other = (RateMap) that; + int nin = getNin(); + int nout = getNout(); + if (other.getNin() != nin || other.getNout() != nout || getInvert() != other.getInvert()) { + return false; + } + // C reads both Invert values before setting either. + int thisInv = map.swapInvert(map.getInvert()); + int thatInv = other.map.swapInvert(other.map.getInvert()); + try { + map.setInvert(invert); + other.map.setInvert(other.invert); + return map.astEqual(other.map) && iin == other.iin && iout == other.iout; + } finally { + map.restoreInvert(thisInv); + other.map.restoreInvert(thatInv); + } + } + + // ------------------------------------------------------------------ + // Simplification + // ------------------------------------------------------------------ + + /** + * ratemap.c {@code MapMerge}. With the encapsulated Mapping set, for the duration, to the + * Invert value recorded when the RateMap was made, it is simplified; if that gives a different + * Mapping, the RateMap is replaced by a RateMap of the simplified Mapping, the entry's Invert + * value unchanged. Otherwise, if the list is in series, a RateMap beside it (the one before it + * first) that the list applies with the other Invert value, of the same indices, whose + * encapsulated Mapping in its recorded orientation is equal ({@link #astEqual}) to this one's, + * cancels with it: both are replaced by UnitMaps applied forward, of this RateMap's number of + * outputs, as the list applies it, when the other is before it, and of its number of inputs + * when the other is after it. + */ + // C compares the pointers: whether astSimplify returned the Mapping it was given. + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) + @Override + int mapMerge(MergeList list, int where, boolean series) { + int mapInv = swapInvert(list.invert(where)); + int oldInv = map.swapInvert(invert); + try { + Mapping smap = map.simplify(); + if (smap != map) { + list.set(where, new RateMap(smap, iout, iin, true), list.invert(where)); + return where; + } + if (!series) { + return -1; + } + int cancel = -1; + int naxes = 0; + if (where > 0 && cancels(list, where, where - 1)) { + cancel = where - 1; + naxes = getNout(); + } + if (cancel == -1 && where + 1 < list.size() && cancels(list, where, where + 1)) { + cancel = where + 1; + naxes = getNin(); + } + if (cancel == -1) { + return -1; + } + list.set(where, new UnitMap(naxes), false); + list.set(cancel, new UnitMap(naxes), false); + return Math.min(cancel, where); + } finally { + map.restoreInvert(oldInv); + restoreInvert(mapInv); + } + } + + /** + * Whether the entry {@code other} of the list cancels this RateMap, the entry {@code where}: + * a RateMap the list applies with the other Invert value, of the same indices, whose + * encapsulated Mapping, set for the duration to the Invert value its RateMap recorded, is equal + * to this one's in its recorded orientation, as C's {@code MapMerge} (ratemap.c) compares them. + */ + private boolean cancels(MergeList list, int where, int other) { + if (!(list.map(other) instanceof RateMap) || list.invert(where) == list.invert(other)) { + return false; + } + RateMap rmap2 = (RateMap) list.map(other); + if (iin != rmap2.iin || iout != rmap2.iout) { + return false; + } + Mapping emap2 = rmap2.map; + int oldWinv = rmap2.swapInvert(list.invert(other)); + int oldInv2 = emap2.swapInvert(rmap2.invert); + try { + return map.astEqual(emap2); + } finally { + emap2.restoreInvert(oldInv2); + rmap2.restoreInvert(oldWinv); + } + } + + // ------------------------------------------------------------------ + // Splitting + // ------------------------------------------------------------------ + + /** + * C's {@code MapSplit} (ratemap.c): the base split ({@link MapSplit#baseSplit}) if there is + * one; otherwise, for a RateMap that is not inverted, the encapsulated Mapping, in its recorded + * orientation, is split for the chosen inputs, and if the input varied is among them and the + * output differentiated among the outputs of the split, the split is the RateMap of the split + * Mapping for those, with the one output, output 0. The Mapping's Invert attribute is set for + * the duration and set back afterwards. + */ + @Override + MapSplit splitOff(int[] in) { + MapSplit result = MapSplit.baseSplit(this, in); + if (result != null || getInvert()) { + return result; + } + int oldInv = map.swapInvert(invert); + try { + MapSplit esplit = map.mapSplit(in); + if (esplit != null) { + int ax2 = -1; + for (int i = 0; i < in.length; i++) { + if (in[i] == iin) { + ax2 = i; + break; + } + } + int ax1 = -1; + int nout = esplit.map.getNout(); + for (int i = 0; i < nout; i++) { + if (esplit.outputs[i] == iout) { + ax1 = i; + break; + } + } + if (ax1 != -1 && ax2 != -1) { + result = new MapSplit(new int[] {0}, new RateMap(esplit.map, ax1, ax2, true)); + } + } + } finally { + map.restoreInvert(oldInv); + } + return result; + } +} diff --git a/src/main/java/uk/ac/starlink/ast/ShiftMap.java b/src/main/java/uk/ac/starlink/ast/ShiftMap.java index ce724bc..397e542 100644 --- a/src/main/java/uk/ac/starlink/ast/ShiftMap.java +++ b/src/main/java/uk/ac/starlink/ast/ShiftMap.java @@ -84,11 +84,12 @@ boolean isLinear() { } /** - * Whether {@code that} is a ShiftMap equivalent to this one, as C's {@code Equal} (shiftmap.c) - * decides it: the same numbers of inputs and outputs, and, if their Invert attributes are the - * same, equal shifts, or, if not, shifts equal and opposite, each to within {@code astEQUAL}. + * shiftmap.c {@code Equal}: {@code that} is a ShiftMap with the same numbers of inputs and + * outputs and, if their Invert attributes are the same, equal shifts, or, if not, shifts equal + * and opposite, each to within {@code astEQUAL}. */ - boolean equalTo(Mapping that) { + @Override + boolean equalTo(AstObject that) { if (!(that instanceof ShiftMap)) { return false; } @@ -128,7 +129,8 @@ int mapMerge(MergeList list, int where, boolean series) { list.set(where, w1, false); int oldNmap = list.size(); int result = Simplifier.dispatchMapMerge(w1, list, where, series); - boolean revert = result == where && list.size() == oldNmap && sameAsThis(list.map(where)); + boolean revert = + result == where && list.size() == oldNmap && list.map(where).astEqual(this); if (revert || result == -1) { if (oldInv) { ShiftMap sm = (ShiftMap) copy(); @@ -145,17 +147,6 @@ int mapMerge(MergeList list, int where, boolean series) { return result; } - /** - * C's {@code astEqual(map, this)}: the same object, or, through the {@code Equal} of {@code - * map}'s class, which finds no Mapping of another class equal to a ShiftMap, an equivalent - * ShiftMap. - */ - // C compares the pointers first (object.c astEqual_): the same object is equal. - @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) - private boolean sameAsThis(Mapping map) { - return map == this || (map instanceof ShiftMap && ((ShiftMap) map).equalTo(this)); - } - /** The rate of change: one where the output is the input, zero elsewhere ({@code Rate}, shiftmap.c). */ @Override double rateAt(double[] at, int ax1, int ax2) { diff --git a/src/main/java/uk/ac/starlink/ast/Simplifier.java b/src/main/java/uk/ac/starlink/ast/Simplifier.java index c48d810..a44e16f 100644 --- a/src/main/java/uk/ac/starlink/ast/Simplifier.java +++ b/src/main/java/uk/ac/starlink/ast/Simplifier.java @@ -18,10 +18,10 @@ final class Simplifier { /** - * The Mappings this thread is simplifying further up its call stack, each with its description - * once one has been needed (C's {@code simplify_stackmaps}, cmpmap.c). + * The CmpMaps this thread is simplifying further up its call stack, the most recent first (C's + * {@code simplify_stackmaps}, cmpmap.c). */ - private static final ThreadLocal> STACK = ThreadLocal.withInitial(ArrayDeque::new); + private static final ThreadLocal> STACK = ThreadLocal.withInitial(ArrayDeque::new); /** The shortest history in which {@link #patternCheck} looks for a pattern (C's {@code PatternCheck}). */ private static final int PATTERN_MIN_HISTORY = 29; @@ -37,58 +37,17 @@ final class Simplifier { private Simplifier() {} - /** A Mapping on the recursion stack, with the description it is compared by. */ - private static final class StackEntry { - final Mapping map; - private String description; - - StackEntry(Mapping map) { - this.map = map; - } - - String key() { - if (description == null) { - description = guardKey(map); - } - return description; - } - } - /** - * The description by which the recursion guard compares two Mappings: the native text without - * the records of simplification, which change as a simplification goes on. C compares with - * {@code astEqual}, which this library does not have; equal descriptions give equal Mappings. + * Whether a Mapping equal to {@code m} ({@link AstObject#astEqual}) is being simplified further + * up this thread's stack (C's check at the start of cmpmap.c {@code Simplify}). As in C, the + * Mappings are compared from the bottom of the stack up, {@code m} first in each comparison; + * a comparison may itself simplify Mappings (that of two Frames does), which pushes them on the + * stack and pops them again. */ - private static String guardKey(Mapping m) { - StringBuilder sb = new StringBuilder(); - for (String line : Channel.text(m, false, 0).split("\n", -1)) { - if (!line.trim().startsWith("IsSimp =")) { - sb.append(line).append('\n'); - } - } - return sb.toString(); - } - - /** - * Whether a Mapping equal to {@code m} is being simplified further up this thread's stack (C's - * check at the start of cmpmap.c {@code Simplify}). - */ - // C compares the pointers: the same object, not an equal one. - @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) private static boolean onStack(Mapping m) { - Deque stack = STACK.get(); - if (stack.isEmpty()) { - return false; - } - String key = null; - for (StackEntry e : stack) { - if (e.map == m) { - return true; - } - if (key == null) { - key = guardKey(m); - } - if (key.equals(e.key())) { + Mapping[] stack = STACK.get().toArray(new Mapping[0]); + for (int i = stack.length - 1; i >= 0; i--) { + if (m.astEqual(stack[i])) { return true; } } @@ -222,8 +181,8 @@ static Mapping simplifyCmpMap(CmpMap cmp) { if (onStack(cmp)) { return cmp; } - Deque stack = STACK.get(); - stack.push(new StackEntry(cmp)); + Deque stack = STACK.get(); + stack.push(cmp); try { boolean series = cmp.isSeries(); boolean[] decomposed = new boolean[1]; diff --git a/src/main/java/uk/ac/starlink/ast/SlaMap.java b/src/main/java/uk/ac/starlink/ast/SlaMap.java index 3fbc240..d721a8d 100644 --- a/src/main/java/uk/ac/starlink/ast/SlaMap.java +++ b/src/main/java/uk/ac/starlink/ast/SlaMap.java @@ -415,6 +415,39 @@ boolean isEmpty() { // Simplification // ------------------------------------------------------------------ + /** + * slamap.c {@code Equal}: {@code that} is an SlaMap with the same numbers of inputs and + * outputs and the same Invert attribute, whose conversions are those of this SlaMap, in the + * same order, with the same arguments to within {@code astEQUAL}: the first {@code nargs} of + * each. SlaMaps with different Invert attributes are never equal. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof SlaMap)) { + return false; + } + SlaMap other = (SlaMap) that; + if (other.getNin() != getNin() || other.getNout() != getNout() || getInvert() != other.getInvert()) { + return false; + } + if (steps.size() != other.steps.size()) { + return false; + } + for (int i = 0; i < steps.size(); i++) { + Step s1 = steps.get(i); + Step s2 = other.steps.get(i); + if (s1.cvt != s2.cvt) { + return false; + } + for (int j = 0; j < s1.cvt.nargs(); j++) { + if (!MappingHelpers.astEqual(s1.args[j], s2.args[j])) { + return false; + } + } + } + return true; + } + /** * slamap.c {@code MapMerge}. In series, or alone in the list, the SlaMap and the SlaMaps * adjacent to it are condensed into one Mapping: their conversions are gathered in the order diff --git a/src/main/java/uk/ac/starlink/ast/SpecFluxFrame.java b/src/main/java/uk/ac/starlink/ast/SpecFluxFrame.java index c18e46c..01ebd73 100644 --- a/src/main/java/uk/ac/starlink/ast/SpecFluxFrame.java +++ b/src/main/java/uk/ac/starlink/ast/SpecFluxFrame.java @@ -10,13 +10,9 @@ * is the FluxFrame's Label, then {@code versus} and the SpecFrame's Label (as {@code Flux density * versus Frequency}), and that when it is aligned with another SpecFluxFrame the flux values are * converted as the spectral positions they are densities in change, as well as with the flux - * System and Unit. Where C converts between SpecFluxFrames whose SpecFrames or FluxFrames differ - * it builds Mappings this library does not have (a RateMap, a MathMap and a TranMap), and such a - * conversion throws {@link UnsupportedOperationException}. So does a conversion between a - * SpecFluxFrame and a FluxFrame or SpecFrame that do not match directly (a FluxFrame in another - * flux System, say): C then casts the CmpFrame its match gives into a SpecFluxFrame and converts - * between SpecFluxFrames. SpecFluxFrames with equal components, and those C finds no conversion - * between, behave as in C. + * System and Unit. A conversion between a SpecFluxFrame and a FluxFrame or SpecFrame that do not + * match directly (a FluxFrame in another flux System, say) is made as in C, which casts the + * CmpFrame its match gives into a SpecFluxFrame and converts between SpecFluxFrames. * *

Ported from C {@code specfluxframe.c}, with Rust {@code frames/specfluxframe.rs}. */ @@ -237,44 +233,40 @@ boolean subFrame( /** * The Mapping from {@code target} to {@code result}, ignoring their axis permutations, or null * if there is none (C's {@code MakeSFMapping}). If their SpecFrames are equal and their - * FluxFrames are equal it is a UnitMap. Otherwise C makes a chain of Mappings whose middle - * part, the conversion between the standardised Frames ({@link #makeMap3}), is a TranMap - * holding a RateMap and MathMaps; it is made only if the target's values convert to the - * standardised Frames ({@link #makeMap2}). - * - * @throws UnsupportedOperationException if the SpecFrames or FluxFrames are not equal and C - * would make that TranMap, or if comparing them needs a Mapping this library does not - * have + * FluxFrames are equal it is a UnitMap. Otherwise it is the simplified series of five + * Mappings: a PermMap giving the flux value, the spectral value and a copy of the spectral + * value; the conversion of the target's values to its standardised Frames ({@link + * #makeMap2}); the conversion between the standardised Frames, with the copy converted between + * the original SpecFrames ({@link #makeMap3}); the inverse of the result's {@link #makeMap2}; + * and the inverse of the first PermMap. There is no Mapping if any of the three conversions + * cannot be made. */ private static Mapping makeSFMapping(SpecFluxFrame target, SpecFluxFrame result) { - boolean same = astEqual(target.getSpecFrame(false), result.getSpecFrame(false)) - && astEqual(target.getFluxFrame(false), result.getFluxFrame(false)); + boolean same = target.getSpecFrame(false).astEqual(result.getSpecFrame(false)) + && target.getFluxFrame(false).astEqual(result.getFluxFrame(false)); if (same) { return new UnitMap(2); } - if (target.makeMap2() != null) { - makeMap3(target, result); - } - // makeMap3 throws where C would make its TranMap; otherwise C makes no conversion either. - return null; - } - - /** - * Whether two Frames are equal, as C's {@code astEqual} finds (object.c {@code astEqual_} and - * frame.c {@code Equal}): they are the same Frame, or of the same class with a conversion from - * {@code that} to {@code frame} that simplifies to a UnitMap. - */ - @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) // C compares the pointers. - private static boolean astEqual(Frame frame, Frame that) { - if (frame == that) { - return true; + PermMap map1 = PermMap.fromInternal(2, new int[] {2, 0}, 3, new int[] {1, 0, 0}, null); + Mapping map2 = target.makeMap2(); + Mapping map3 = map2 != null ? makeMap3(target, result) : null; + Mapping map4 = null; + if (map3 != null) { + map4 = result.makeMap2(); + if (map4 != null) { + map4.invert(); + } } - if (!frame.astClass().equals(that.astClass())) { - return false; + if (map4 == null) { + return null; } - FrameSet fs = that.convert(frame, ""); - return fs != null - && fs.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT).simplify() instanceof UnitMap; + Mapping map5 = (Mapping) map1.copy(); + map5.invert(); + Mapping tmap1 = new CmpMap(map1, map2, true); + Mapping tmap2 = new CmpMap(tmap1, map3, true); + Mapping tmap3 = new CmpMap(tmap2, map4, true); + Mapping tmap4 = new CmpMap(tmap3, map5, true); + return tmap4.simplify(); } /** @@ -294,54 +286,84 @@ private Mapping makeMap2() { return null; } Mapping ax2Map = fs.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT); - Mapping tmap = CmpMap.transientCmpMap(ax1Map, ax2Map, false); - return CmpMap.transientCmpMap(tmap, new UnitMap(1), false); + Mapping tmap = new CmpMap(ax1Map, ax2Map, false); + return new CmpMap(tmap, new UnitMap(1), false); } /** * The conversion of flux and spectral values between the standardised Frames of {@code target} - * and {@code result}, as far as this library can follow C's {@code MakeMap3}. C makes a TranMap - * of the Mappings {@link #makeMapF} and {@link #makeMapI} give, each of which throws where C - * would build its RateMap, and looks for the conversion between the SpecFrames themselves; if - * neither standardised SpecFrame converts to the other, C makes no Mapping. - * - * @throws UnsupportedOperationException if the standardised SpecFrames convert + * and {@code result}, in parallel with the conversion of the third value, a spectral value, + * between their original SpecFrames, or null if either cannot be made (C's {@code MakeMap3}). + * The first is a TranMap whose forward transformation is {@link #makeMapF}'s and whose inverse + * is {@link #makeMapI}'s. */ - private static void makeMap3(SpecFluxFrame target, SpecFluxFrame result) { + private static Mapping makeMap3(SpecFluxFrame target, SpecFluxFrame result) { // C makes the standardised FluxFrames as well, though MakeMapF and MakeMapI do not use them. target.getFluxFrame(true); SpecFrame sf1 = target.getSpecFrame(true); result.getFluxFrame(true); SpecFrame sf2 = result.getSpecFrame(true); - makeMapF(sf1, sf2); - makeMapI(sf1, sf2); - target.getSpecFrame(false).convert(result.getSpecFrame(false), ""); + Mapping fmap = makeMapF(sf1, sf2); + Mapping imap = makeMapI(sf1, sf2); + Mapping mapa = fmap != null && imap != null ? new TranMap(fmap, imap) : null; + FrameSet fs = target.getSpecFrame(false).convert(result.getSpecFrame(false), ""); + Mapping mapb = fs != null ? fs.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT) : null; + return mapa != null && mapb != null ? new CmpMap(mapa, mapb, false) : null; } /** - * The forward part of C's flux conversion ({@code MakeMapF}): if the standardised SpecFrame - * {@code x1} converts to {@code x2}, C builds a RateMap of that conversion to scale the flux, - * and a MathMap dividing by it, which this library does not have. - * - * @throws UnsupportedOperationException if {@code x1} converts to {@code x2} + * The forward part of the conversion between standardised Frames (C's {@code MakeMapF}): a + * Mapping from (v1, x1) to (v2, x2), the flux value and spectral value in the standardised + * Frames, which divides the flux value by the absolute rate of change of {@code x2} with + * respect to {@code x1} (a RateMap of the conversion between the SpecFrames), or null if + * {@code x1} does not convert to {@code x2}. */ - private static void makeMapF(SpecFrame x1, SpecFrame x2) { - if (x1.convert(x2, "") != null) { - throw new UnsupportedOperationException( - "MakeMapF(SpecFluxFrame): the conversion of flux values between SpecFluxFrames needs RateMap"); + private static Mapping makeMapF(SpecFrame x1, SpecFrame x2) { + FrameSet fs = x1.convert(x2, ""); + if (fs == null) { + return null; } + Mapping m = fs.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT); + RateMap rate = new RateMap(m, 0, 0, true); + MathMap div = new MathMap(2, 1, new String[] {"out=in0/abs(in1)"}, new String[] {"in0", "in1"}); + UnitMap unit = new UnitMap(1); + PermMap perm = PermMap.fromInternal(2, new int[] {0, 2}, 3, new int[] {0, 1, 1}, null); + // (v1, x1) to (v1, dx2/dx1), to v2; with x1 to x2 beside it; after the PermMap giving + // (v1, x1, x1) from (v1, x1). + CmpMap cmap1 = new CmpMap(unit, rate, false); + CmpMap cmap2 = new CmpMap(cmap1, div, true); + CmpMap cmap3 = new CmpMap(cmap2, m, false); + return new CmpMap(perm, cmap3, true); } /** - * The inverse part of C's flux conversion ({@code MakeMapI}): as {@link #makeMapF}, with a - * MathMap multiplying by the rate. - * - * @throws UnsupportedOperationException if {@code x1} converts to {@code x2} + * The inverse part of the conversion between standardised Frames (C's {@code MakeMapI}): a + * Mapping whose inverse transformation goes from (v2, x2) to (v1, x1), multiplying the flux + * value by the absolute rate of change of {@code x2} with respect to {@code x1}, or null if + * {@code x1} does not convert to {@code x2}. The RateMap shares the conversion between the + * SpecFrames, which is then inverted: the RateMap uses the conversion as it was when the + * RateMap was made. */ - private static void makeMapI(SpecFrame x1, SpecFrame x2) { - if (x1.convert(x2, "") != null) { - throw new UnsupportedOperationException( - "MakeMapI(SpecFluxFrame): the conversion of flux values between SpecFluxFrames needs RateMap"); + private static Mapping makeMapI(SpecFrame x1, SpecFrame x2) { + FrameSet fs = x1.convert(x2, ""); + if (fs == null) { + return null; } + Mapping m = fs.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT); + RateMap rate = new RateMap(m, 0, 0, true); + m.invert(); + MathMap mult = new MathMap(2, 1, new String[] {"out=in0*abs(in1)"}, new String[] {"in0", "in1"}); + UnitMap unit = new UnitMap(1); + PermMap perm = PermMap.fromInternal(2, new int[] {0, 2}, 3, new int[] {0, 1, 1}, null); + // (v2, x1) to (v2, dx2/dx1), to v1; with x1 copied beside it; after the PermMap giving + // (v2, x1, x1) from (v2, x1); after (v2, x2) to (v2, x1). + CmpMap cmap1 = new CmpMap(unit, rate, false); + CmpMap cmap2 = new CmpMap(cmap1, mult, true); + CmpMap cmap3 = new CmpMap(cmap2, unit, false); + CmpMap cmap4 = new CmpMap(perm, cmap3, true); + CmpMap cmap5 = new CmpMap(unit, m, false); + CmpMap ret = new CmpMap(cmap5, cmap4, true); + ret.invert(); + return ret; } } diff --git a/src/main/java/uk/ac/starlink/ast/SpecFrame.java b/src/main/java/uk/ac/starlink/ast/SpecFrame.java index 9b6a71e..8370638 100644 --- a/src/main/java/uk/ac/starlink/ast/SpecFrame.java +++ b/src/main/java/uk/ac/starlink/ast/SpecFrame.java @@ -1335,7 +1335,8 @@ public String getLabel(int axis) { result = result + " offset from " + format(1, orig); } if (testUnit(axis)) { - Units.LabelledMapping lm = Units.relabel(defUnit(system, "astGetLabel", astClass()), getUnit(axis), result); + Units.LabelledMapping lm = + Units.unitMapperLabel(defUnit(system, "astGetLabel", astClass()), getUnit(axis), result); if (lm != null && lm.label != null) { result = lm.label; } @@ -1364,7 +1365,7 @@ public String getSymbol(int axis) { } if (testUnit(axis)) { Units.LabelledMapping lm = - Units.relabel(defUnit(system, "astGetSymbol", astClass()), getUnit(axis), result); + Units.unitMapperLabel(defUnit(system, "astGetSymbol", astClass()), getUnit(axis), result); if (lm != null && lm.label != null) { result = lm.label; } diff --git a/src/main/java/uk/ac/starlink/ast/SpecMap.java b/src/main/java/uk/ac/starlink/ast/SpecMap.java index d2a2f10..6d8a500 100644 --- a/src/main/java/uk/ac/starlink/ast/SpecMap.java +++ b/src/main/java/uk/ac/starlink/ast/SpecMap.java @@ -493,6 +493,39 @@ private void addSpecCvt(Cvt type, int narg, double[] args) { // Simplification // ------------------------------------------------------------------ + /** + * specmap.c {@code Equal}: {@code that} is a SpecMap with the same numbers of inputs and + * outputs and the same Invert attribute, whose conversions are those of this SpecMap, in the + * same order, with the same arguments to within {@code astEQUAL}: the first {@code nargs} of + * each, not the frequency correction factor. SpecMaps with different Invert attributes are never equal. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof SpecMap)) { + return false; + } + SpecMap other = (SpecMap) that; + if (other.getNin() != getNin() || other.getNout() != getNout() || getInvert() != other.getInvert()) { + return false; + } + if (steps.size() != other.steps.size()) { + return false; + } + for (int i = 0; i < steps.size(); i++) { + Step s1 = steps.get(i); + Step s2 = other.steps.get(i); + if (s1.cvt != s2.cvt) { + return false; + } + for (int j = 0; j < s1.cvt.nargs; j++) { + if (!MappingHelpers.astEqual(s1.args[j], s2.args[j])) { + return false; + } + } + } + return true; + } + /** * specmap.c {@code MapMerge}. In series, or alone in the list, the SpecMap and the SpecMaps * with the same number of axes adjacent to it are condensed into one Mapping: their conversions diff --git a/src/main/java/uk/ac/starlink/ast/SphMap.java b/src/main/java/uk/ac/starlink/ast/SphMap.java index 3ed4072..dd00984 100644 --- a/src/main/java/uk/ac/starlink/ast/SphMap.java +++ b/src/main/java/uk/ac/starlink/ast/SphMap.java @@ -197,6 +197,23 @@ void clearPolarLong() { polarLong = AST__BAD; } + /** + * sphmap.c {@code Equal}: {@code that} is a SphMap with the same numbers of inputs and outputs, + * the same Invert attribute, PolarLong values as stored equal to within {@code astEQUAL}, and the + * same UnitRadius value as stored, unset values included. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof SphMap)) { + return false; + } + SphMap other = (SphMap) that; + if (other.getNin() != getNin() || other.getNout() != getNout() || getInvert() != other.getInvert()) { + return false; + } + return MappingHelpers.astEqual(polarLong, other.polarLong) && unitRadius == other.unitRadius; + } + // ------------------------------------------------------------------ // Attribute strings (sphmap.c GetAttrib, SetAttrib, TestAttrib, ClearAttrib) // ------------------------------------------------------------------ diff --git a/src/main/java/uk/ac/starlink/ast/SwitchMap.java b/src/main/java/uk/ac/starlink/ast/SwitchMap.java new file mode 100644 index 0000000..eb46001 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/SwitchMap.java @@ -0,0 +1,708 @@ +package uk.ac.starlink.ast; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** + * A Mapping which represents a set of alternate Mappings, each of which is used to transform + * positions within a particular region of the input or output coordinate system of the SwitchMap. + * + *

A SwitchMap can encapsulate any number of Mappings, but they must all have the same number of + * inputs (Nin attribute value) and the same number of outputs (Nout attribute value). The + * SwitchMap itself inherits these same values for its Nin and Nout attributes. Each of these + * Mappings represents a "route" through the switch, and is referred to as a "route" Mapping below. + * Each route Mapping transforms positions between the input and output coordinate space of the + * entire SwitchMap, but only one Mapping will be used to transform any given position. The + * selection of the appropriate route Mapping to use with any given input position is made by + * another Mapping, called the "selector" Mapping. Each SwitchMap encapsulates two selector + * Mappings in addition to its route Mappings; one for use with the SwitchMap's forward + * transformation (called the "forward selector Mapping"), and one for use with the SwitchMap's + * inverse transformation (called the "inverse selector Mapping"). The forward selector Mapping + * must have the same number of inputs as the route Mappings, but should have only one output. + * Likewise, the inverse selector Mapping must have the same number of outputs as the route + * Mappings, but should have only one input. + * + *

When the SwitchMap is used to transform a position in the forward direction (from input to + * output), each supplied input position is first transformed by the forward transformation of the + * forward selector Mapping. This produces a single output value for each input position referred + * to as the selector value. The nearest integer to the selector value is found, and is used to + * index the array of route Mappings (the first supplied route Mapping has index 1, the second + * route Mapping has index 2, etc). If the nearest integer to the selector value is less than 1 or + * greater than the number of route Mappings, then the SwitchMap output position is set to a value + * of {@link #AST__BAD} on every axis. Otherwise, the forward transformation of the selected route + * Mapping is used to transform the supplied input position to produce the SwitchMap output + * position. + * + *

When the SwitchMap is used to transform a position in the inverse direction (from "output" to + * "input"), each supplied "output" position is first transformed by the inverse transformation of + * the inverse selector Mapping. This produces a selector value for each "output" position. Again, + * the nearest integer to the selector value is found, and is used to index the array of route + * Mappings. If this selector index value is within the bounds of the array of route Mappings, then + * the inverse transformation of the selected route Mapping is used to transform the supplied + * "output" position to produce the SwitchMap "input" position. If the selector index value is + * outside the bounds of the array of route Mappings, then the SwitchMap "input" position is set to + * a value of {@link #AST__BAD} on every axis. + * + *

In practice, appropriate selector Mappings should be chosen to associate a different route + * Mapping with each region of coordinate space. Note that the SelectorMap class of Mapping is + * particularly appropriate for this purpose. + * + *

If a compound Mapping contains a SwitchMap in series with its own inverse, the combination of + * the two adjacent SwitchMaps will be replaced by a UnitMap when the compound Mapping is + * simplified using {@link #simplify}. + * + *

A SwitchMap does not copy the Mappings it is given: it holds them, as C's holds cloned + * pointers to them, and {@link #copy} copies them. Being shared, their attributes that C makes + * immutable once cloned (such as a ZoomMap's Zoom) can no longer be changed. It records the Invert + * attribute of each when it is made, and applies each in that orientation whatever is later done + * to the Mapping it shares; their other attributes do change the SwitchMap, so they should not be + * changed while the SwitchMap is in use. + * + *

Ported from Rust {@code mappings/switchmap.rs} and C {@code switchmap.c}. + */ +public class SwitchMap extends Mapping { + + /** The forward selector Mapping, or null if there is none (C's {@code fsmap}). */ + private Mapping fsmap; + + /** The inverse selector Mapping, or null if there is none (C's {@code ismap}). */ + private Mapping ismap; + + /** The route Mappings (C's {@code routemap}). */ + private Mapping[] routemap; + + /** The Invert attribute of the forward selector when the SwitchMap was made (C's {@code fsinv}). */ + private final boolean fsinv; + + /** The Invert attribute of the inverse selector when the SwitchMap was made (C's {@code isinv}). */ + private final boolean isinv; + + /** The Invert attribute of each route Mapping when the SwitchMap was made (C's {@code routeinv}). */ + private boolean[] routeinv; + + /** + * Creates a SwitchMap. + * + * @param fsmap the forward selector Mapping. This must have a defined forward transformation, + * but need not have a defined inverse transformation. It must have one output, and the + * number of inputs must match the number of inputs of each of the supplied route Mappings. + * Null may be supplied, in which case the SwitchMap will have an undefined forward + * Mapping. + * @param ismap the inverse selector Mapping. This must have a defined inverse transformation, + * but need not have a defined forward transformation. It must have one input, and the + * number of outputs must match the number of outputs of each of the supplied route + * Mappings. Null may be supplied, in which case the SwitchMap will have an undefined + * inverse Mapping. + * @param routemaps the route Mappings. All the supplied route Mappings must have common + * values for the Nin and Nout attributes, and these values define the number of inputs + * and outputs of the SwitchMap. + * @throws NullPointerException if {@code routemaps} is null + * @throws AstException with status {@code AST__BDPAR} if no route Mappings are given, {@code + * AST__OBJIN} if one is null, {@code AST__BADNI} or {@code AST__BADNO} if the numbers of + * coordinates do not match, or {@code AST__INTRD} if a selector cannot transform in the + * direction it is used in or neither selector is given + */ + public SwitchMap(Mapping fsmap, Mapping ismap, Mapping[] routemaps) { + this(fsmap, ismap, routemaps, check(fsmap, ismap, routemaps, " Bad")); + } + + /** + * C's {@code astSwitchMap_} and {@code astInitSwitchMap} (switchmap.c), as the library itself + * makes a SwitchMap: shares the Mappings and records their Invert attributes. + * + * @param library distinguishes this constructor from the public one + */ + SwitchMap(Mapping fsmap, Mapping ismap, Mapping[] routemaps, boolean library) { + this(fsmap, ismap, routemaps, check(fsmap, ismap, routemaps, "Bad")); + } + + /** Makes the SwitchMap once {@link #check} has given its numbers of inputs and outputs. */ + private SwitchMap(Mapping fsmap, Mapping ismap, Mapping[] routemaps, int[] counts) { + super(counts[0], counts[1], fsmap != null, ismap != null); + this.fsmap = fsmap; + this.ismap = ismap; + fsinv = fsmap != null && fsmap.getInvert(); + isinv = ismap != null && ismap.getInvert(); + if (fsmap != null) { + fsmap.markShared(); + } + if (ismap != null) { + ismap.markShared(); + } + routemap = routemaps.clone(); + routeinv = new boolean[routemap.length]; + for (int i = 0; i < routemap.length; i++) { + routemap[i].markShared(); + routeinv[i] = routemap[i].getInvert(); + } + } + + /** + * The numbers of inputs and outputs of a SwitchMap of these Mappings, after the checks C's + * {@code astSwitchMap} and {@code astInitSwitchMap} make, in their order: the first error + * found is the one reported. + * + * @param bad the start of the message for no route Mappings, which has an extra space when + * the public function ({@code astSwitchMapId_}) reports it + */ + private static int[] check(Mapping fsmap, Mapping ismap, Mapping[] routemaps, String bad) { + Objects.requireNonNull(routemaps, "routemaps"); + int nroute = routemaps.length; + if (nroute <= 0) { + throw Ast.err( + AstException.AST__BDPAR, + "astSwitchMap(SwitchMap): " + bad + " number of route Mappings (" + nroute + ") specified."); + } + for (Mapping m : routemaps) { + if (m == null) { + throw Ast.err(AstException.AST__OBJIN, "Invalid Object pointer given (value is zero)."); + } + } + int nin = routemaps[0].getNin(); + int nout = routemaps[0].getNout(); + for (int i = 1; i < nroute; i++) { + if (nin != routemaps[i].getNin()) { + throw Ast.err( + AstException.AST__BADNI, + "astInitSwitchMap(SwitchMap): Route Mapping number " + (i + 1) + " has " + + routemaps[i].getNin() + " input(s) but the first route Mapping has " + nin + + " input(s)."); + } else if (nout != routemaps[i].getNout()) { + // C's message gives the numbers of inputs, not outputs. + throw Ast.err( + AstException.AST__BADNO, + "astInitSwitchMap(SwitchMap): Route Mapping number " + (i + 1) + " has " + + routemaps[i].getNin() + " output(s) but the first route Mapping has " + nin + + " output(s)."); + } + } + if (fsmap != null) { + if (!fsmap.getTranForward()) { + throw Ast.err( + AstException.AST__INTRD, + "astInitSwitchMap(SwitchMap): The forward selector Mapping is not able to transform " + + "coordinates in the forward direction."); + } else if (fsmap.getNin() != nin) { + throw Ast.err( + AstException.AST__BADNI, + "astInitSwitchMap(SwitchMap): The forward selector Mapping has " + fsmap.getNin() + + " input(s) but the SwitchMap has " + nin + " input(s)."); + } else if (fsmap.getNout() != 1) { + throw Ast.err( + AstException.AST__BADNO, + "astInitSwitchMap(SwitchMap): The forward selector Mapping has " + fsmap.getNout() + + " outputs but should only have 1."); + } + } + if (ismap != null) { + if (!ismap.getTranInverse()) { + throw Ast.err( + AstException.AST__INTRD, + "astInitSwitchMap(SwitchMap): The inverse selector Mapping is not able to transform " + + "coordinates in the inverse direction."); + } else if (nout != ismap.getNout()) { + throw Ast.err( + AstException.AST__BADNO, + "astInitSwitchMap(SwitchMap): The inverse selector Mapping has " + ismap.getNout() + + " output(s) but the SwitchMap has " + nout + " output(s)."); + } else if (ismap.getNin() != 1) { + throw Ast.err( + AstException.AST__BADNI, + "astInitSwitchMap(SwitchMap): The inverse selector Mapping has " + ismap.getNin() + + " inputs but should only have 1."); + } + } + if (fsmap == null && ismap == null) { + throw Ast.err(AstException.AST__INTRD, "astInitSwitchMap(SwitchMap): No selector Mappings supplied."); + } + return new int[] {nin, nout}; + } + + /** + * Loads a SwitchMap from its description, as C's {@code astLoadSwitchMap} does: {@code FSMap} + * and {@code FSInv} (false if absent), {@code ISMap} and {@code ISInv}, then {@code RMap1}, + * {@code RInv1}, {@code RMap2} and so on until a route Mapping is missing. As in C, an absent + * {@code ISInv} takes the value of {@code FSInv}, and an absent {@code RInv} is false. + * + * @throws AstException with status {@code AST__LDERR} if a component is not a Mapping + */ + SwitchMap(NativeNode node) { + super(node); + NativeNode part = node.section("SwitchMap"); + fsmap = component(part, "FSMap"); + fsinv = part.readInt("FSInv", 0) != 0; + ismap = component(part, "ISMap"); + isinv = part.readInt("ISInv", fsinv ? 1 : 0) != 0; + List maps = new ArrayList<>(); + List invs = new ArrayList<>(); + while (true) { + Mapping rmap = component(part, "RMap" + (maps.size() + 1)); + if (rmap == null) { + break; + } + invs.add(part.readInt("RInv" + (maps.size() + 1), 0) != 0); + maps.add(rmap); + } + routemap = maps.toArray(new Mapping[0]); + routeinv = new boolean[invs.size()]; + for (int i = 0; i < routeinv.length; i++) { + routeinv[i] = invs.get(i); + } + } + + /** The Mapping {@code key} describes, or null if there is none. */ + private static Mapping component(NativeNode part, String key) { + NativeNode desc = part.readObject(key); + if (desc == null) { + return null; + } + AstObject obj = ObjectRegistry.loadNested(desc, key); + if (!(obj instanceof Mapping)) { + throw Ast.err( + AstException.AST__LDERR, + "astLoadSwitchMap(SwitchMap): The component " + key + " is a " + obj.astClass() + + ", not a Mapping."); + } + return (Mapping) obj; + } + + @Override + String dumpComment() { + return "Alternate regionalised Mapping"; + } + + /** + * Writes each selector there is with its Invert value recorded when the SwitchMap was made + * (set when true), and then each route Mapping with its recorded Invert value, as C's {@code + * Dump} (switchmap.c) does; each Mapping is written with its own Invert attribute as it now + * is. As in C, a SwitchMap whose forward selector was recorded inverted and whose inverse + * selector was not loads back with its inverse selector inverted, since {@code ISInv} is + * written only when true and the loader takes its absence as {@code FSInv}. + */ + @Override + void dump(NativeNode node) { + super.dump(node); + node.writeIsA("Mapping", "Mapping between coordinate systems"); + if (fsmap != null) { + node.writeObject("FSMap", true, true, NativeNode.of(fsmap), "Forward selector Mapping"); + node.writeInt( + "FSInv", + fsinv, + false, + fsinv ? 1 : 0, + fsinv ? "Fwd selector used in inverse direction" : "Fwd selector used in forward direction"); + } + if (ismap != null) { + node.writeObject("ISMap", true, true, NativeNode.of(ismap), "Inverse selector Mapping"); + node.writeInt( + "ISInv", + isinv, + false, + isinv ? 1 : 0, + isinv ? "Inv selector used in inverse direction" : "Inv selector used in forward direction"); + } + for (int i = 0; i < routemap.length; i++) { + node.writeObject("RMap" + (i + 1), true, true, NativeNode.of(routemap[i]), "Route Mapping"); + boolean inv = routeinv[i]; + node.writeInt( + "RInv" + (i + 1), + inv, + false, + inv ? 1 : 0, + inv ? "Route Mapping used in inverse direction" : "Route Mapping used in forward direction"); + } + } + + /** Gives the copy copies of the selectors and route Mappings, as C's {@code Copy} (switchmap.c) does. */ + @Override + void deepCopy() { + super.deepCopy(); + if (fsmap != null) { + fsmap = (Mapping) fsmap.copy(); + } + if (ismap != null) { + ismap = (Mapping) ismap.copy(); + } + Mapping[] maps = new Mapping[routemap.length]; + for (int i = 0; i < maps.length; i++) { + maps[i] = (Mapping) routemap[i].copy(); + } + routemap = maps; + routeinv = routeinv.clone(); + } + + // ------------------------------------------------------------------ + // Selectors and routes + // ------------------------------------------------------------------ + + /** + * C's {@code GetSelector} (switchmap.c): the selector Mapping a transformation in direction + * {@code fwd} of the SwitchMap as it now is uses, or null if there is none. Its Invert + * attribute is set to the value recorded when the SwitchMap was made, and inverted if the + * SwitchMap is inverted, so that applied in direction {@code fwd} it gives the selector value; + * {@code saved[0]} receives the attribute as it was, for {@link Mapping#restoreInvert}. + */ + private Mapping getSelector(boolean fwd, int[] saved) { + boolean swinv = getInvert(); + Mapping ret; + if ((!swinv && !fwd) || (swinv && fwd)) { + ret = ismap; + if (ret != null) { + saved[0] = ret.swapInvert(isinv); + } + } else { + ret = fsmap; + if (ret != null) { + saved[0] = ret.swapInvert(fsinv); + } + } + if (ret != null && swinv) { + ret.invert(); + } + return ret; + } + + /** + * C's {@code GetRoute} (switchmap.c): the route Mapping the selector value {@code sel} picks, + * or null if it is bad or picks none. Its Invert attribute is set to the value recorded when + * the SwitchMap was made, and inverted if the SwitchMap is inverted, so that it transforms in + * the direction the SwitchMap does; {@code saved[0]} receives the attribute as it was, for + * {@link Mapping#restoreInvert}. + */ + private Mapping getRoute(double sel, int[] saved) { + if (sel == AST__BAD) { + return null; + } + int rindex = routeIndex(sel); + if (rindex < 0 || rindex >= routemap.length) { + return null; + } + Mapping ret = routemap[rindex]; + saved[0] = ret.swapInvert(routeinv[rindex]); + if (getInvert()) { + ret.invert(); + } + return ret; + } + + /** + * The zero-based index of the route a good selector value picks, as C computes it: {@code + * (int) round(sel) - 1}, which may be outside the routes. C converts without a range check, so + * a value beyond the range of {@code int}, an infinity or a NaN makes the conversion undefined, + * as does the {@code - 1} after a conversion giving {@code INT_MIN}; Java's conversion is + * defined, giving 0 for a NaN and the nearest {@code int} for any other value, and {@code + * Integer.MIN_VALUE - 1} wraps to {@code Integer.MAX_VALUE}, so each of these gives an index + * outside the routes, which picks no route, as C's documentation says of an index below 1 or + * above the number of routes. + */ + private static int routeIndex(double sel) { + return (int) FitsMakeIntWorld.roundHalfAway(sel) - 1; + } + + // ------------------------------------------------------------------ + // Transformation + // ------------------------------------------------------------------ + + /** + * C's {@code Transform} (switchmap.c): the selector Mapping for the direction gives a selector + * value for each point, and each route Mapping transforms, in one call, the points whose + * selector value picks it. A point whose selector value is bad or picks no route is bad on + * every output. + */ + @Override + void transformInto(double[][] in, int npoint, boolean forward, double[][] out) { + validateTransformInto(in, npoint, forward, out); + int ncin = forward ? getNin() : getNout(); + int ncout = forward ? getNout() : getNin(); + int nroute = routemap.length; + int[] selinv = new int[1]; + Mapping selmap = getSelector(forward, selinv); + try { + double[] sel = selmap.transform(in, npoint, forward)[0]; + int[] popmap = new int[nroute]; + for (int p = 0; p < npoint; p++) { + if (sel[p] != AST__BAD) { + int rindex = routeIndex(sel[p]); + if (rindex >= 0 && rindex < nroute) { + popmap[rindex]++; + } + } + } + int totpop = 0; + for (int pop : popmap) { + totpop += pop; + } + if (totpop < npoint) { + for (int j = 0; j < ncout; j++) { + for (int p = 0; p < npoint; p++) { + out[j][p] = AST__BAD; + } + } + } + for (int iroute = 0; iroute < nroute; iroute++) { + if (popmap[iroute] > 0) { + applyRoute(iroute, popmap[iroute], sel, in, npoint, forward, ncin, ncout, out); + } + } + } finally { + selmap.restoreInvert(selinv[0]); + } + } + + /** + * Transforms with route {@code iroute} the {@code pop} points whose selector value picks it, + * gathered in order, and puts the results at those points of {@code out}. + */ + private void applyRoute( + int iroute, + int pop, + double[] sel, + double[][] in, + int npoint, + boolean forward, + int ncin, + int ncout, + double[][] out) { + int[] rinv = new int[1]; + Mapping rmap = getRoute(iroute + 1, rinv); + try { + double[][] sub = new double[ncin][pop]; + int k = 0; + for (int p = 0; p < npoint; p++) { + if (sel[p] != AST__BAD && routeIndex(sel[p]) == iroute) { + for (int j = 0; j < ncin; j++) { + sub[j][k] = in[j][p]; + } + k++; + } + } + double[][] res = rmap.transform(sub, pop, forward); + k = 0; + for (int p = 0; p < npoint; p++) { + if (sel[p] != AST__BAD && routeIndex(sel[p]) == iroute) { + for (int j = 0; j < ncout; j++) { + out[j][p] = res[j][k]; + } + k++; + } + } + } finally { + rmap.restoreInvert(rinv[0]); + } + } + + /** + * C's {@code Rate} (switchmap.c): the rate of the route Mapping the forward selector of the + * SwitchMap as it now is picks at {@code at}, in the orientation the SwitchMap applies it; bad + * if there is no forward selector or it picks no route. + */ + @Override + double rateAt(double[] at, int ax1, int ax2) { + int[] fsinvOld = new int[1]; + Mapping smap = getSelector(true, fsinvOld); + if (smap == null) { + return AST__BAD; + } + try { + int nin = smap.getNin(); + double[][] pos = new double[nin][1]; + for (int i = 0; i < nin; i++) { + pos[i][0] = at[i]; + } + double sel = smap.transform(pos, 1, true)[0][0]; + int[] rinv = new int[1]; + Mapping rmap = getRoute(sel, rinv); + if (rmap == null) { + return AST__BAD; + } + try { + return rmap.rateAt(at, ax1, ax2); + } finally { + rmap.restoreInvert(rinv[0]); + } + } finally { + smap.restoreInvert(fsinvOld[0]); + } + } + + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + /** + * switchmap.c {@code Equal}: {@code that} is a SwitchMap with the same number of route + * Mappings, whose forward selectors, inverse selectors and routes, each as the two SwitchMaps + * now apply it ({@link #getSelector}, {@link #getRoute}), are equal ({@link #astEqual}) or + * both absent. The Invert attributes are set back in C's order, the second SwitchMap's first, + * so that a Mapping both SwitchMaps share is left as it was. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof SwitchMap)) { + return false; + } + SwitchMap other = (SwitchMap) that; + int nroute = routemap.length; + if (other.routemap.length != nroute) { + return false; + } + boolean result = false; + int[] fsinv1 = new int[1]; + int[] fsinv2 = new int[1]; + Mapping fsmap1 = getSelector(true, fsinv1); + Mapping fsmap2 = other.getSelector(true, fsinv2); + try { + if (sameSelector(fsmap1, fsmap2)) { + int[] isinv1 = new int[1]; + int[] isinv2 = new int[1]; + Mapping ismap1 = getSelector(false, isinv1); + Mapping ismap2 = other.getSelector(false, isinv2); + try { + if (sameSelector(ismap1, ismap2)) { + result = true; + for (int i = 0; result && i < nroute; i++) { + int[] rinv1 = new int[1]; + int[] rinv2 = new int[1]; + Mapping rmap1 = getRoute(i + 1, rinv1); + Mapping rmap2 = other.getRoute(i + 1, rinv2); + try { + result = rmap1.astEqual(rmap2); + } finally { + rmap2.restoreInvert(rinv2[0]); + rmap1.restoreInvert(rinv1[0]); + } + } + } + } finally { + if (ismap2 != null) { + ismap2.restoreInvert(isinv2[0]); + } + if (ismap1 != null) { + ismap1.restoreInvert(isinv1[0]); + } + } + } + } finally { + if (fsmap2 != null) { + fsmap2.restoreInvert(fsinv2[0]); + } + if (fsmap1 != null) { + fsmap1.restoreInvert(fsinv1[0]); + } + } + return result; + } + + /** Whether two selectors are both absent, or both present and equal ({@link #astEqual}). */ + private static boolean sameSelector(Mapping a, Mapping b) { + return (a == null && b == null) || (a != null && b != null && a.astEqual(b)); + } + + // ------------------------------------------------------------------ + // Simplification + // ------------------------------------------------------------------ + + /** + * switchmap.c {@code MapMerge}. With the selectors and route Mappings set, for the duration, + * to the Invert values recorded when the SwitchMap was made: in series, the SwitchMap after it + * in the list, or failing that the one before it, is inverted and compared with it ({@link + * #astEqual}, each with its own Invert attribute), and if they are equal the pair is replaced + * by a UnitMap of the lower one's number of inputs. Otherwise, a SwitchMap the list applies + * inverted is replaced by the forward SwitchMap of its selectors inverted and exchanged and its + * route Mappings inverted; one it applies forward is replaced, if simplifying any of its + * Mappings gives a different Mapping, by the SwitchMap of the simplified Mappings. + * + *

As C does, the Invert attributes are set and then restored in the same order, the forward + * selector, the inverse selector, then the routes in turn, so a Mapping held twice is left with + * the value set for the first of its places rather than its own. + */ + // C compares the pointers: whether astSimplify returned the Mapping it was given. + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) + @Override + int mapMerge(MergeList list, int where, boolean series) { + int nroute = routemap.length; + int fsinvOld = fsmap != null ? fsmap.swapInvert(fsinv) : 0; + int isinvOld = ismap != null ? ismap.swapInvert(isinv) : 0; + int[] rinvOld = new int[nroute]; + for (int i = 0; i < nroute; i++) { + rinvOld[i] = routemap[i].swapInvert(routeinv[i]); + } + try { + int result = -1; + if (series) { + result = cancelWithNeighbour(list, where); + } + if (result == -1) { + if (list.invert(where)) { + if (fsmap != null) { + fsmap.setInvert(!fsinv); + } + if (ismap != null) { + ismap.setInvert(!isinv); + } + for (int i = 0; i < nroute; i++) { + routemap[i].setInvert(!routeinv[i]); + } + list.set(where, new SwitchMap(ismap, fsmap, routemap, true), false); + result = where; + } else { + Mapping sfsmap = fsmap != null ? fsmap.simplify() : null; + Mapping sismap = ismap != null ? ismap.simplify() : null; + boolean simp = sfsmap != fsmap || sismap != ismap; + Mapping[] srmap = new Mapping[nroute]; + for (int i = 0; i < nroute; i++) { + srmap[i] = routemap[i].simplify(); + simp = simp || srmap[i] != routemap[i]; + } + if (simp) { + list.set(where, new SwitchMap(sfsmap, sismap, srmap, true), list.invert(where)); + result = where; + } + } + } + return result; + } finally { + if (fsmap != null) { + fsmap.restoreInvert(fsinvOld); + } + if (ismap != null) { + ismap.restoreInvert(isinvOld); + } + for (int i = 0; i < nroute; i++) { + routemap[i].restoreInvert(rinvOld[i]); + } + } + } + + /** + * The neighbour half of {@link #mapMerge}: replaces this SwitchMap, at {@code where}, and the + * SwitchMap after it in the list, or failing that the one before it, with a UnitMap, if the + * neighbour, inverted for the duration, is equal to this one. + * + * @return {@code where} if the pair was replaced, or -1 + */ + private int cancelWithNeighbour(MergeList list, int where) { + int ilo; + if (where < list.size() - 1 && list.map(where + 1) instanceof SwitchMap) { + ilo = where; + } else if (where > 0 && list.map(where - 1) instanceof SwitchMap) { + ilo = where - 1; + } else { + return -1; + } + Mapping swneb = list.map(ilo == where ? where + 1 : where - 1); + swneb.invert(); + boolean equal; + try { + equal = astEqual(swneb); + } finally { + swneb.invert(); + } + if (!equal) { + return -1; + } + list.replacePairWith(ilo, new UnitMap(list.map(ilo).getNin()), false); + return where; + } +} diff --git a/src/main/java/uk/ac/starlink/ast/TimeFrame.java b/src/main/java/uk/ac/starlink/ast/TimeFrame.java index a935e9d..1e0a543 100644 --- a/src/main/java/uk/ac/starlink/ast/TimeFrame.java +++ b/src/main/java/uk/ac/starlink/ast/TimeFrame.java @@ -885,7 +885,7 @@ public String getLabel(int axis) { } if (testUnit(axis)) { Units.LabelledMapping lm = - Units.relabel(defUnit(system, "astGetLabel", astClass()), getUnit(axis), result); + Units.unitMapperLabel(defUnit(system, "astGetLabel", astClass()), getUnit(axis), result); if (lm != null && lm.label != null) { result = lm.label; } @@ -927,7 +927,7 @@ public String getSymbol(int axis) { } if (testUnit(axis)) { Units.LabelledMapping lm = - Units.relabel(defUnit(system, "astGetSymbol", astClass()), getUnit(axis), result); + Units.unitMapperLabel(defUnit(system, "astGetSymbol", astClass()), getUnit(axis), result); if (lm != null && lm.label != null) { result = lm.label; } diff --git a/src/main/java/uk/ac/starlink/ast/TimeMap.java b/src/main/java/uk/ac/starlink/ast/TimeMap.java index bac56f1..2af9e51 100644 --- a/src/main/java/uk/ac/starlink/ast/TimeMap.java +++ b/src/main/java/uk/ac/starlink/ast/TimeMap.java @@ -460,6 +460,39 @@ private static void addArgs(Cvt cvt, double[] a) { // Simplification // ------------------------------------------------------------------ + /** + * timemap.c {@code Equal}: {@code that} is a TimeMap with the same numbers of inputs and + * outputs and the same Invert attribute, whose conversions are those of this TimeMap, in the + * same order, with the same arguments to within {@code astEQUAL}: the first {@code nargs} of + * each, not the values derived from them. TimeMaps with different Invert attributes are never equal. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof TimeMap)) { + return false; + } + TimeMap other = (TimeMap) that; + if (other.getNin() != getNin() || other.getNout() != getNout() || getInvert() != other.getInvert()) { + return false; + } + if (steps.size() != other.steps.size()) { + return false; + } + for (int i = 0; i < steps.size(); i++) { + Step s1 = steps.get(i); + Step s2 = other.steps.get(i); + if (s1.cvt != s2.cvt) { + return false; + } + for (int j = 0; j < s1.cvt.nargs; j++) { + if (!MappingHelpers.astEqual(s1.args[j], s2.args[j])) { + return false; + } + } + } + return true; + } + /** * timemap.c {@code MapMerge}. In series, or alone in the list, the TimeMap and the TimeMaps * adjacent to it are condensed into one Mapping: their conversions are gathered in the order diff --git a/src/main/java/uk/ac/starlink/ast/TranMap.java b/src/main/java/uk/ac/starlink/ast/TranMap.java new file mode 100644 index 0000000..26fea14 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/TranMap.java @@ -0,0 +1,546 @@ +package uk.ac.starlink.ast; + +import java.util.Arrays; +import java.util.Objects; + +/** + * A Mapping which combines the forward transformation of one Mapping with the inverse + * transformation of another, ignoring the transformation of each that is not used (which need not + * exist). The forward transformation of the TranMap is the forward transformation of the first + * Mapping given when it was made, and its inverse transformation is the inverse transformation of + * the second. + * + *

A TranMap does not copy its components: it holds the Mappings it is given, as C's holds + * cloned pointers to them, and {@link #copy} copies them. Being shared, a component's attributes + * that C makes immutable once cloned (such as a ZoomMap's Zoom) can no longer be changed. It + * records each component's Invert attribute when it is made, and applies each component in that + * orientation whatever is later done to the Mapping it shares; the Invert attribute of a component + * therefore does not change the TranMap. Its other attributes do, so a component should not be + * changed while the TranMap is in use. + * + *

Ported from Rust {@code mappings/tranmap.rs} and C {@code tranmap.c}. + */ +public class TranMap extends Mapping { + + /** The Mapping whose forward transformation is the TranMap's forward transformation. */ + private Mapping map1; + + /** The Mapping whose inverse transformation is the TranMap's inverse transformation. */ + private Mapping map2; + + /** The Invert attribute of the first component when the TranMap was made (C's {@code invert1}). */ + private final boolean invert1; + + /** The Invert attribute of the second component when the TranMap was made (C's {@code invert2}). */ + private final boolean invert2; + + /** + * Creates a TranMap. + * + *

The two Mappings must have the same numbers of input and of output coordinates. Both + * directions of the TranMap are defined. + * + * @param map1 the first component Mapping, which defines the forward transformation + * @param map2 the second component Mapping, which defines the inverse transformation + * @throws AstException with status {@code AST__INTRD} if {@code map1} cannot transform in the + * forward direction or {@code map2} cannot transform in the inverse direction, or {@code + * AST__INNCO} if the numbers of coordinates do not match + */ + public TranMap(Mapping map1, Mapping map2) { + super(count(map1, map2, true), count(map1, map2, false), true, true); + map1.markShared(); + map2.markShared(); + this.map1 = map1; + this.map2 = map2; + invert1 = map1.getInvert(); + invert2 = map2.getInvert(); + } + + /** + * The number of input coordinates of a TranMap of {@code map1} and {@code map2} if {@code in}, + * otherwise of output coordinates, after the checks C's {@code astInitTranMap} makes, in its + * order: the first error found is the one reported. + */ + private static int count(Mapping map1, Mapping map2, boolean in) { + Objects.requireNonNull(map1, "map1"); + Objects.requireNonNull(map2, "map2"); + if (!map1.getTranForward()) { + throw Ast.err( + AstException.AST__INTRD, + "astInitTranMap(TranMap): The first supplied Mapping is not able to transform coordinates in the " + + "forward direction."); + } + if (!map2.getTranInverse()) { + throw Ast.err( + AstException.AST__INTRD, + "astInitTranMap(TranMap): The second supplied Mapping is not able to transform coordinates in " + + "the inverse direction."); + } + int nout = map1.getNout(); + if (map2.getNout() != nout) { + throw Ast.err( + AstException.AST__INNCO, + "astInitTranMap(TranMap): The number of output coordinates per point (" + nout + + ") for the first Mapping supplied does not match the number of output coordinates (" + + map2.getNout() + ") for the second Mapping."); + } + int nin = map1.getNin(); + if (map2.getNin() != nin) { + throw Ast.err( + AstException.AST__INNCO, + "astInitTranMap(TranMap): The number of input coordinates per point (" + nin + + ") for the first Mapping supplied does not match the number of input coordinates (" + + map2.getNin() + ") for the second Mapping."); + } + return in ? nin : nout; + } + + /** + * Loads a TranMap from its description, as C's {@code astLoadTranMap} does: {@code InvA} and + * {@code InvB} (false if absent) and the components {@code MapA} and {@code MapB}. + * + * @throws AstException with status {@code AST__LDERR} if a component is missing or is not a + * Mapping + */ + TranMap(NativeNode node) { + super(node); + NativeNode part = node.section("TranMap"); + invert1 = part.readInt("InvA", 0) != 0; + invert2 = part.readInt("InvB", 0) != 0; + map1 = component(part, "MapA"); + map2 = component(part, "MapB"); + } + + /** The component Mapping {@code key} describes. */ + private static Mapping component(NativeNode part, String key) { + NativeNode desc = part.readObject(key); + if (desc == null) { + throw Ast.err( + AstException.AST__LDERR, "astLoadTranMap(TranMap): The component Mapping " + key + " is missing."); + } + AstObject obj = ObjectRegistry.loadNested(desc, key); + if (!(obj instanceof Mapping)) { + throw Ast.err( + AstException.AST__LDERR, + "astLoadTranMap(TranMap): The component " + key + " is a " + obj.astClass() + ", not a Mapping."); + } + return (Mapping) obj; + } + + @Override + String dumpComment() { + return "Compound Transformation Mapping"; + } + + /** + * Writes {@code InvA} and {@code InvB} (set when true), the Invert values recorded when the + * TranMap was made, and the components, each with its own Invert attribute as it now is, as + * C's {@code Dump} (tranmap.c) does. + */ + @Override + void dump(NativeNode node) { + super.dump(node); + node.writeIsA("Mapping", "Mapping between coordinate systems"); + node.writeInt( + "InvA", + invert1, + false, + invert1 ? 1 : 0, + invert1 ? "First Mapping used in inverse direction" : "First Mapping used in forward direction"); + node.writeInt( + "InvB", + invert2, + false, + invert2 ? 1 : 0, + invert2 ? "Second Mapping used in inverse direction" : "Second Mapping used in forward direction"); + node.writeObject("MapA", true, true, NativeNode.of(map1), "Mapping for forward transformation"); + node.writeObject("MapB", true, true, NativeNode.of(map2), "Mapping for inverse transformation"); + } + + /** Gives the copy copies of the components, as C's {@code Copy} (tranmap.c) does. */ + @Override + void deepCopy() { + super.deepCopy(); + map1 = (Mapping) map1.copy(); + map2 = (Mapping) map2.copy(); + } + + // ------------------------------------------------------------------ + // Components + // ------------------------------------------------------------------ + + /** The first component, which gives the forward transformation, shared with the TranMap. */ + Mapping getMap1() { + return map1; + } + + /** The second component, which gives the inverse transformation, shared with the TranMap. */ + Mapping getMap2() { + return map2; + } + + /** The Invert value the TranMap applies its first component with. */ + boolean getInvert1() { + return invert1; + } + + /** The Invert value the TranMap applies its second component with. */ + boolean getInvert2() { + return invert2; + } + + /** + * The components, as C's {@code Decompose} (tranmap.c) gives them: an inverted TranMap gives + * them in reverse order with their recorded Invert values reversed. C's {@code Decompose} does + * not set the series flag, which its documentation gives as zero for a TranMap; it is false + * here. + */ + @Override + Mapping[] decomposeInto(boolean[] flags) { + flags[0] = false; + if (getInvert()) { + flags[1] = !invert2; + flags[2] = !invert1; + return new Mapping[] {map2, map1}; + } + flags[1] = invert1; + flags[2] = invert2; + return new Mapping[] {map1, map2}; + } + + // ------------------------------------------------------------------ + // Transformation + // ------------------------------------------------------------------ + + @Override + void transformInto(double[][] in, int npoint, boolean forward, double[][] out) { + validateTransformInto(in, npoint, forward, out); + apply(in, npoint, forward, out, false); + } + + /** NaN protocol: the component used transforms through its own {@link #transformIntoNan}. */ + @Override + void transformIntoNan(double[][] in, int npoint, boolean forward, double[][] out) { + apply(in, npoint, forward, out, true); + } + + /** + * Applies the component C's {@code Transform} (tranmap.c) chooses: for the forward + * transformation of the TranMap as created, the first component, forward, and for the inverse + * the second, in its inverse direction, each in the orientation recorded when the TranMap was + * made, whatever its Invert attribute now is. + */ + private void apply(double[][] in, int npoint, boolean forward, double[][] out, boolean nan) { + Mapping cmap; + boolean dir; + if (effectiveForward(forward)) { + cmap = map1; + dir = invert1 == map1.getInvert(); + } else { + cmap = map2; + dir = invert2 != map2.getInvert(); + } + if (nan) { + cmap.transformIntoNan(in, npoint, dir, out); + } else { + cmap.transformInto(in, npoint, dir, out); + } + } + + /** + * The rate of the component that gives the TranMap's forward transformation as it is now + * applied, as C's {@code Rate} (tranmap.c) asks it: the first component in its recorded + * orientation, or, for an inverted TranMap, the second inverted from its recorded orientation. + * As C does, the component's Invert attribute is set for the duration and then set back. + */ + @Override + double rateAt(double[] at, int ax1, int ax2) { + Mapping cmap; + boolean cinv; + if (getInvert()) { + cmap = map2; + cinv = !invert2; + } else { + cmap = map1; + cinv = invert1; + } + int oldInv = cmap.swapInvert(cinv); + try { + return cmap.rateAt(at, ax1, ax2); + } finally { + cmap.restoreInvert(oldInv); + } + } + + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + /** + * tranmap.c {@code Equal}: {@code that} is a TranMap with the same numbers of inputs and + * outputs whose components, each set for the duration to the Invert value its TranMap recorded, + * are equal ({@link #astEqual}) to this TranMap's: in order when the two TranMaps have the same + * Invert attribute, and otherwise each inverted and in the other order. The Invert attributes + * of the components are set back afterwards in C's order. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof TranMap)) { + return false; + } + TranMap other = (TranMap) that; + int nin = getNin(); + int nout = getNout(); + if (other.getNin() != nin || other.getNout() != nout) { + return false; + } + // C reads all four Invert values before setting any of them. + int thatInv1 = other.map1.swapInvert(other.map1.getInvert()); + int thatInv2 = other.map2.swapInvert(other.map2.getInvert()); + int thisInv1 = map1.swapInvert(map1.getInvert()); + int thisInv2 = map2.swapInvert(map2.getInvert()); + try { + map1.setInvert(invert1); + map2.setInvert(invert2); + other.map1.setInvert(other.invert1); + other.map2.setInvert(other.invert2); + if (getInvert() == other.getInvert()) { + return map1.astEqual(other.map1) && map2.astEqual(other.map2); + } + other.map1.invert(); + other.map2.invert(); + return map1.astEqual(other.map2) && map2.astEqual(other.map1); + } finally { + map1.restoreInvert(thisInv1); + map2.restoreInvert(thisInv2); + other.map1.restoreInvert(thatInv1); + other.map2.restoreInvert(thatInv2); + } + } + + // ------------------------------------------------------------------ + // Simplification + // ------------------------------------------------------------------ + + /** + * tranmap.c {@code MapMerge}. With its components set, for the duration, to the Invert values + * recorded when it was made, the TranMap is first simplified on its own: applied inverted, it + * is replaced by the forward TranMap of its components inverted and swapped; otherwise, if + * simplifying either component gives a different Mapping, it is replaced by the TranMap of the + * simplified components; otherwise, if both components are defined in both directions and the + * first in series with the inverse of the second simplifies to a UnitMap, it is replaced by a + * copy of the first component, the entry's Invert value unchanged. If none of those applies and + * the list is in series, a TranMap after it in the list merges with it: the two forward + * Mappings in series, and the two inverse Mappings in series in the same order, are each + * simplified, and if either simplifies the pair is replaced by the TranMap of the two results, + * applied forward. + * + *

As in C, the copy of the first component keeps the Invert value it was recorded with, + * while the entry it replaces is applied forward, so that a TranMap whose equal components were + * inverted when it was made is replaced by a Mapping that transforms the other way. + */ + @Override + int mapMerge(MergeList list, int where, boolean series) { + int result; + int oldInv1 = map1.swapInvert(invert1); + int oldInv2 = map2.swapInvert(invert2); + try { + if (list.invert(where)) { + map1.invert(); + map2.invert(); + TranMap swapped = new TranMap(map2, map1); + map1.invert(); + map2.invert(); + list.set(where, swapped, false); + result = where; + } else { + result = simplifyAlone(list, where); + } + if (result == -1 && series && where < list.size() - 1 && list.map(where + 1) instanceof TranMap) { + result = mergeWithHigher(list, where); + } + } finally { + map1.restoreInvert(oldInv1); + map2.restoreInvert(oldInv2); + } + return result; + } + + /** + * The part of {@link #mapMerge} that simplifies a TranMap the list applies forward on its own, + * its components set to their recorded Invert values. + * + * @return {@code where} if the entry was replaced, or -1 + */ + // C compares the pointers: whether astSimplify returned the Mapping it was given. + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) + private int simplifyAlone(MergeList list, int where) { + Mapping smapF = map1.simplify(); + Mapping smapI = map2.simplify(); + if (smapF != map1 || smapI != map2) { + list.set(where, new TranMap(smapF, smapI), list.invert(where)); + return where; + } + if (map1.getTranForward() && map1.getTranInverse() && map2.getTranForward() && map2.getTranInverse()) { + map2.invert(); + CmpMap cmap = CmpMap.transientCmpMap(map1, map2, true); + map2.invert(); + Mapping smap = cmap.simplify(); + if (smap instanceof UnitMap) { + Mapping copy = (Mapping) map1.copy(); + if (list.invert(where)) { + copy.invert(); + } + list.set(where, copy, list.invert(where)); + return where; + } + } + return -1; + } + + /** + * The part of {@link #mapMerge} that merges a TranMap with the TranMap after it in a series + * list, each applied as the list gives it. + * + * @return {@code where} if the pair was replaced, or -1 + */ + // C compares the pointers: whether astSimplify returned the Mapping it was given. + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) + private int mergeWithHigher(MergeList list, int where) { + TranMap hmap = (TranMap) list.map(where + 1); + Mapping hmap1 = hmap.map1; + int oldHinv1 = hmap1.swapInvert(hmap.invert1); + Mapping hmap2 = hmap.map2; + int oldHinv2 = hmap2.swapInvert(hmap.invert2); + TranMap merged; + try { + Mapping mapF; + Mapping mapI; + if (list.invert(where)) { + mapF = map2; + mapI = map1; + mapF.invert(); + mapI.invert(); + } else { + mapF = map1; + mapI = map2; + } + Mapping hmapF; + Mapping hmapI; + if (list.invert(where + 1)) { + hmapF = hmap2; + hmapI = hmap1; + hmapF.invert(); + hmapI.invert(); + } else { + hmapF = hmap1; + hmapI = hmap2; + } + CmpMap cmapF = CmpMap.transientCmpMap(mapF, hmapF, true); + Mapping smapF = cmapF.simplify(); + CmpMap cmapI = CmpMap.transientCmpMap(mapI, hmapI, true); + Mapping smapI = cmapI.simplify(); + if (cmapF != smapF || cmapI != smapI) { + // A CmpMap that did not simplify is kept by the new TranMap, so its components are + // shared as C's reference counts then have them. + keep(cmapF, smapF); + keep(cmapI, smapI); + merged = new TranMap(smapF, smapI); + } else { + merged = null; + } + } finally { + hmap1.restoreInvert(oldHinv1); + hmap2.restoreInvert(oldHinv2); + } + if (merged == null) { + return -1; + } + list.set(where, merged, false); + list.removeAt(where + 1); + return where; + } + + /** Marks the components of {@code cmap} shared if {@code kept} is {@code cmap} itself. */ + // C compares the pointers: whether astSimplify returned the Mapping it was given. + @SuppressWarnings({"ReferenceEquality", "PMD.CompareObjectsWithEquals"}) + private static void keep(CmpMap cmap, Mapping kept) { + if (kept == cmap) { + cmap.getMap1().markShared(); + cmap.getMap2().markShared(); + } + } + + // ------------------------------------------------------------------ + // Splitting + // ------------------------------------------------------------------ + + /** + * C's {@code MapSplit} (tranmap.c): the base split ({@link MapSplit#baseSplit}) if there is + * one; otherwise the Mapping giving the TranMap's forward transformation as it is now applied, + * in its recorded orientation, is split for the chosen inputs, and the Mapping giving its + * inverse, inverted, is split for the outputs that gives; if that leads back to exactly the + * chosen inputs, in order, the split is the TranMap of the forward split and the inverse of + * the inverse split. The components' Invert attributes are set for the duration and set back + * afterwards in C's order. + */ + @Override + MapSplit splitOff(int[] in) { + MapSplit result = MapSplit.baseSplit(this, in); + if (result != null) { + return result; + } + Mapping fmap; + boolean finv; + Mapping imap; + boolean iinv; + if (!getInvert()) { + fmap = map1; + finv = invert1; + imap = map2; + iinv = invert2; + } else { + imap = map1; + iinv = !invert1; + fmap = map2; + finv = !invert2; + } + int oldFinv = fmap.swapInvert(finv); + int oldIinv = imap.swapInvert(iinv); + try { + MapSplit fsplit = fmap.mapSplit(in); + if (fsplit != null) { + int nout = fsplit.map.getNout(); + int[] out = Arrays.copyOf(fsplit.outputs, nout); + imap.invert(); + MapSplit isplit; + try { + isplit = imap.mapSplit(out); + } finally { + imap.invert(); + } + if (isplit != null) { + Mapping rimap = isplit.map; + rimap.invert(); + if (rimap.getNin() == in.length && sameInputs(in, isplit.outputs)) { + result = new MapSplit(out, new TranMap(fsplit.map, rimap)); + } + } + } + } finally { + fmap.restoreInvert(oldFinv); + imap.restoreInvert(oldIinv); + } + return result; + } + + /** Whether the first {@code in.length} elements of {@code ires} are those of {@code in}. */ + private static boolean sameInputs(int[] in, int[] ires) { + for (int i = 0; i < in.length; i++) { + if (in[i] != ires[i]) { + return false; + } + } + return true; + } +} diff --git a/src/main/java/uk/ac/starlink/ast/Transformer.java b/src/main/java/uk/ac/starlink/ast/Transformer.java new file mode 100644 index 0000000..3974202 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/Transformer.java @@ -0,0 +1,145 @@ +package uk.ac.starlink.ast; + +/** + * Defines a custom general coordinate transformation function. Objects subclassing this abstract + * class can be used to construct a {@code Mapping} (an {@link IntraMap}) with a user-defined + * transformation function. + * + *

An {@code IntraMap} is written to a {@link Channel} with the name of its transformation + * function, not the {@code Transformer}, and is read back with the {@code Transformer} that name + * stands for (see {@link IntraMap}). + * + *

The {@code tranP} method may be called from several threads at once, since copies of an + * {@code IntraMap} share its {@code Transformer} and no lock is held while it is called: a + * {@code Transformer} must be thread-safe. + * + *

This is implemented as an abstract class (rather than an interface) so that additional flags + * along the lines of the {@code simpFI} method can be introduced in the future without breaking + * existing code. + */ +public abstract class Transformer { + + /** Constructs a Transformer. */ + public Transformer() {} + + /** + * Indicates whether this {@code Transformer} is able to transform between coordinate spaces + * with the given dimensionalities. + * + * @param nin the number of coordinates of an input point + * @param nout the number of coordinates of an output point + * @return the method should return {@code true} if this {@code Transformer}'s {@code tranP} + * method will be able to transform points with {@code nin} coordinates to points with + * {@code nout} coordinates, and {@code false} otherwise + */ + public abstract boolean canTransformCoords(int nin, int nout); + + /** + * Indicates whether this {@code Transformer} can perform a forward transformation (whether the + * transformation method may be invoked with {@code forward} set true). + * + *

The default implementation returns {@code true}; subclasses should override this if the + * forward transformation is not available. + * + * @return whether the forward transformation is available + */ + public boolean hasForward() { + return true; + } + + /** + * Indicates whether this {@code Transformer} can perform an inverse transformation (whether the + * transformation method may be invoked with {@code forward} set false). + * + *

The default implementation returns {@code true}; subclasses should override this if the + * inverse transformation is not available. + * + * @return whether the inverse transformation is available + */ + public boolean hasInverse() { + return true; + } + + /** + * Indicates whether a forward transformation followed by an inverse transformation may always + * be considered to restore the original coordinates. It is not necessary that both forward + * and inverse transformations have been implemented. + * + *

The default implementation returns {@code false}; subclasses should override this if such + * simplifications are always valid. + * + * @return whether forward followed by inverse is a unit transformation + */ + public boolean simpFI() { + return false; + } + + /** + * Indicates whether an inverse transformation followed by a forward transformation may always + * be considered to restore the original coordinates. It is not necessary that both forward + * and inverse transformations have been implemented. + * + *

The default implementation returns {@code false}; subclasses should override this if such + * simplifications are always valid. + * + * @return whether inverse followed by forward is a unit transformation + */ + public boolean simpIF() { + return false; + } + + /** + * Transforms points from input coordinates to output coordinates. This method does the work of + * the {@code Transformer}, taking an array of input coordinate arrays and returning an array + * of output coordinate arrays. + * + *

This method will only be called with {@code forward} set true if a prior call of the + * {@code hasForward} method has returned true, and will only be called with {@code forward} + * set false if a prior call of the {@code hasInverse} method has returned true. + * + *

If {@code forward} is true, then this method will only be called with values of {@code + * ncoordIn}, {@code ncoordOut} for which a prior call of {@code + * canTransformCoords(ncoordIn, ncoordOut)} has returned true. If {@code forward} is false, + * then this method will only be called with values of {@code ncoordIn}, {@code ncoordOut} for + * which a prior call of {@code canTransformCoords(ncoordOut, ncoordIn)} has returned true. + * + * @param npoint the number of points to be transformed + * @param ncoordIn the number of coordinates being supplied for each input point (the + * dimensionality of the input space) + * @param in an array of {@code ncoordIn} arrays, each containing {@code npoint} elements. + * These give the coordinates of each point to transform. + * @param forward {@code true} if the forward transformation is to be used, {@code false} if + * its inverse transformation is to be used + * @param ncoordOut the number of coordinates being generated by the transformation for each + * output point (the dimensionality of the output space). This need not be equal to {@code + * ncoordIn}. + * @return an array of {@code ncoordOut} arrays, each containing {@code npoint} elements. These + * give the coordinates of the transformed points. + * @throws Exception if an error occurs during the transformation, in which case the + * transformation is aborted + */ + public abstract double[][] tranP(int npoint, int ncoordIn, double[][] in, boolean forward, int ncoordOut) + throws Exception; + + /** + * Gives a brief indication of the purpose of this {@code Transformer}. + * + * @return a short (one-line) string describing the purpose of this transformation function + */ + public abstract String getPurpose(); + + /** + * Names the author of this {@code Transformer}. + * + * @return a string giving the name of the author of this transformation function + */ + public abstract String getAuthor(); + + /** + * Gives contact details for the author of this {@code Transformer}. + * + * @return a string giving contact details, for instance an e-mail or WWW address, for the + * author + */ + public abstract String getContact(); +} diff --git a/src/main/java/uk/ac/starlink/ast/Transformer1.java b/src/main/java/uk/ac/starlink/ast/Transformer1.java new file mode 100644 index 0000000..8ecebba --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/Transformer1.java @@ -0,0 +1,64 @@ +package uk.ac.starlink.ast; + +/** + * Defines a custom one-dimensional coordinate transformation function. This abstract subclass of + * {@code Transformer} is provided for convenience when only a 1-d transformation is required. + * Subclasses need to implement the {@code tran1} method, which is somewhat more convenient than + * {@code Transformer}'s {@code tranP} method. + */ +public abstract class Transformer1 extends Transformer { + + /** Constructs a Transformer1. */ + public Transformer1() {} + + /** + * Indicates whether this {@code Transformer} is able to transform between coordinate spaces + * with the given dimensionalities. + * + * @param nin the number of coordinates of an input point + * @param nout the number of coordinates of an output point + * @return true only if both {@code nin} and {@code nout} are equal to 1 + */ + @Override + public final boolean canTransformCoords(int nin, int nout) { + return nin == 1 && nout == 1; + } + + /** + * Implements {@code Transformer}'s {@code tranP} method in terms of this class's {@code tran1} + * method. + * + * @param npoint the number of points to be transformed + * @param ncoordIn the number of coordinates of each input point (1) + * @param in a one-element array holding the array of {@code npoint} input coordinates + * @param forward {@code true} for the forward transformation, {@code false} for the inverse + * @param ncoordOut the number of coordinates of each output point (1) + * @return a one-element array holding the result of {@code tran1} + * @throws Exception if {@code tran1} throws it + */ + @Override + public final double[][] tranP(int npoint, int ncoordIn, double[][] in, boolean forward, int ncoordOut) + throws Exception { + return new double[][] {tran1(npoint, in[0], forward)}; + } + + /** + * Transforms points from 1-d input coordinates to 1-d output coordinates. This method does the + * work of the {@code Transformer1}, taking an input coordinate array and returning an output + * coordinate array. + * + *

This method will only be called with {@code forward} set true if a prior call of the + * {@code hasForward} method has returned true, and will only be called with {@code forward} + * set false if a prior call of the {@code hasInverse} method has returned true. + * + * @param npoint the number of points to be transformed + * @param xin an array of {@code npoint} elements representing the coordinates to be + * transformed + * @param forward {@code true} if the forward transformation is to be used, {@code false} if + * its inverse transformation is to be used + * @return an array of {@code npoint} elements giving the transformed coordinates + * @throws Exception if an error occurs during the transformation, in which case the + * transformation is aborted + */ + public abstract double[] tran1(int npoint, double[] xin, boolean forward) throws Exception; +} diff --git a/src/main/java/uk/ac/starlink/ast/Transformer2.java b/src/main/java/uk/ac/starlink/ast/Transformer2.java new file mode 100644 index 0000000..584fa87 --- /dev/null +++ b/src/main/java/uk/ac/starlink/ast/Transformer2.java @@ -0,0 +1,68 @@ +package uk.ac.starlink.ast; + +/** + * Defines a custom two-dimensional coordinate transformation function. This abstract subclass of + * {@code Transformer} is provided for convenience when only a 2-d transformation is required. + * Subclasses need to implement the {@code tran2} method, which is somewhat more convenient than + * {@code Transformer}'s {@code tranP} method. + */ +public abstract class Transformer2 extends Transformer { + + /** Constructs a Transformer2. */ + public Transformer2() {} + + /** + * Indicates whether this {@code Transformer} is able to transform between coordinate spaces + * with the given dimensionalities. + * + * @param nin the number of coordinates of an input point + * @param nout the number of coordinates of an output point + * @return true only if both {@code nin} and {@code nout} are equal to 2 + */ + @Override + public final boolean canTransformCoords(int nin, int nout) { + return nin == 2 && nout == 2; + } + + /** + * Implements {@code Transformer}'s {@code tranP} method in terms of this class's {@code tran2} + * method. + * + * @param npoint the number of points to be transformed + * @param ncoordIn the number of coordinates of each input point (2) + * @param in a two-element array holding the arrays of {@code npoint} X and Y input coordinates + * @param forward {@code true} for the forward transformation, {@code false} for the inverse + * @param ncoordOut the number of coordinates of each output point (2) + * @return the result of {@code tran2} + * @throws Exception if {@code tran2} throws it + */ + @Override + public final double[][] tranP(int npoint, int ncoordIn, double[][] in, boolean forward, int ncoordOut) + throws Exception { + return tran2(npoint, in[0], in[1], forward); + } + + /** + * Transforms points from 2-d input coordinates to 2-d output coordinates. This method does the + * work of the {@code Transformer2}, taking input x and y coordinate arrays and returning a + * two-element array consisting of the x and y output coordinate arrays. + * + *

This method will only be called with {@code forward} set true if a prior call of the + * {@code hasForward} method has returned true, and will only be called with {@code forward} + * set false if a prior call of the {@code hasInverse} method has returned true. + * + * @param npoint the number of points to be transformed + * @param xin an array of {@code npoint} elements representing the X coordinates to be + * transformed + * @param yin an array of {@code npoint} elements representing the Y coordinates to be + * transformed + * @param forward {@code true} if the forward transformation is to be used, {@code false} if + * its inverse transformation is to be used + * @return a two-element array; the first element is an {@code npoint}-element array of the + * output X coordinates, and the second element is an {@code npoint}-element array of the + * output Y coordinates + * @throws Exception if an error occurs during the transformation, in which case the + * transformation is aborted + */ + public abstract double[][] tran2(int npoint, double[] xin, double[] yin, boolean forward) throws Exception; +} diff --git a/src/main/java/uk/ac/starlink/ast/UnitMap.java b/src/main/java/uk/ac/starlink/ast/UnitMap.java index 3706d84..8e0bd88 100644 --- a/src/main/java/uk/ac/starlink/ast/UnitMap.java +++ b/src/main/java/uk/ac/starlink/ast/UnitMap.java @@ -25,6 +25,15 @@ public UnitMap(int ncoord) { super(node); } + /** + * unitmap.c {@code Equal}: {@code that} is a UnitMap with the same number of inputs; the + * Invert attributes play no part. + */ + @Override + boolean equalTo(AstObject that) { + return that instanceof UnitMap && ((UnitMap) that).getNin() == getNin(); + } + /** * unitmap.c {@code MapMerge}: alone, the UnitMap is applied forward; in series it is removed * from the list; in parallel it is joined with the UnitMaps on either side of it into one, or, diff --git a/src/main/java/uk/ac/starlink/ast/Units.java b/src/main/java/uk/ac/starlink/ast/Units.java index 9e28d59..1501fb2 100644 --- a/src/main/java/uk/ac/starlink/ast/Units.java +++ b/src/main/java/uk/ac/starlink/ast/Units.java @@ -37,8 +37,6 @@ static final class LabelledMapping { * with no label). * * @throws AstException with status {@code AST__BADUN} if a units string cannot be parsed - * @throws UnsupportedOperationException if the conversion needs a MathMap, which is not - * available */ static Mapping unitMapper(String inUnit, String outUnit) { LabelledMapping lm = UnitsMapper.unitMapper(inUnit, outUnit, null); @@ -55,29 +53,11 @@ static Mapping unitMapper(String inUnit, String outUnit) { * * @throws AstException with status {@code AST__BADUN} if a units string or the label cannot * be parsed - * @throws UnsupportedOperationException if the conversion needs a MathMap, which is not - * available */ static LabelledMapping unitMapperLabel(String inUnit, String outUnit, String inLabel) { return UnitsMapper.unitMapper(inUnit, outUnit, inLabel); } - /** - * Whether values in the units {@code inUnit} can be converted to the units {@code outUnit}, - * and the label {@code inLabel} rewritten for the output units, as {@link #unitMapperLabel} - * gives them, but without making a Mapping from the conversion found, so that the result's - * {@code mapping} may be null: C's - * {@code NewUnit} (frame.c) uses only the label and whether there is a Mapping, so a conversion - * that needs a MathMap is found too. - * - * @return the label, or null if the units cannot be converted - * @throws AstException with status {@code AST__BADUN} if a units string or the label cannot - * be parsed - */ - static LabelledMapping relabel(String inUnit, String outUnit, String inLabel) { - return UnitsMapper.unitMapper(inUnit, outUnit, inLabel, false); - } - /** * The standard FITS-WCS form of the units string {@code in} (C {@code astUnitNormaliser}). A * string that is only a constant normalises to a blank string. diff --git a/src/main/java/uk/ac/starlink/ast/UnitsMapper.java b/src/main/java/uk/ac/starlink/ast/UnitsMapper.java index ee9501c..c804130 100644 --- a/src/main/java/uk/ac/starlink/ast/UnitsMapper.java +++ b/src/main/java/uk/ac/starlink/ast/UnitsMapper.java @@ -27,10 +27,8 @@ private UnitsMapper() {} * The Mapping {@code tree} describes, whose input is the input units and whose output is the * head of the tree (C {@code MakeMapping}): a UnitMap for the input units alone or a product * of them and 1, a ZoomMap for a product of them and another constant, and otherwise a - * MathMap. - * - * @throws UnsupportedOperationException where a MathMap is needed, since MathMap is not - * available + * MathMap whose forward function gives "output_units" from "input_units" and whose inverse is + * that of the inverted tree, with SimpFI and SimpIF set, so that it cancels with its inverse. */ static Mapping makeMapping(Node tree) { if (tree.opcode == Oper.LDVAR) { @@ -52,8 +50,10 @@ static Mapping makeMapping(Node tree) { + "' (internal AST programming error)."); } String invexp = UnitsToExpr.makeExp(inv, UnitsToExpr.MATHMAP, true); - throw new UnsupportedOperationException("This conversion of units (forward \"output_units=" + fwdexp - + "\", inverse \"input_units=" + invexp + "\") needs MathMap"); + MathMap result = + new MathMap(1, 1, new String[] {"output_units=" + fwdexp}, new String[] {"input_units=" + invexp}); + result.set("SimpFI=1,SimpIF=1"); + return result; } /** @@ -74,18 +74,8 @@ private static AstException context(AstException e, String context) { * if {@code inLab} is null, or where C gives none * @throws AstException with status {@code AST__BADUN} if a units string or the label cannot * be parsed - * @throws UnsupportedOperationException if the conversion needs a MathMap */ static Units.LabelledMapping unitMapper(String in, String out, String inLab) { - return unitMapper(in, out, inLab, true); - } - - /** - * {@link #unitMapper(String, String, String)}, making the Mapping from the conversion found - * only if {@code makeMap}: otherwise the result's Mapping is null, so that a conversion C makes with a MathMap is found - * and its label rewritten, as C's {@code NewUnit} (frame.c) uses them. - */ - static Units.LabelledMapping unitMapper(String in, String out, String inLab, boolean makeMap) { if (in.equals(out)) { return new Units.LabelledMapping(new UnitMap(1), inLab); } @@ -172,7 +162,7 @@ static Units.LabelledMapping unitMapper(String in, String out, String inLab, boo return null; } - Mapping result = makeMap ? makeMapping(testtree) : null; + Mapping result = makeMapping(testtree); if (inLab == null) { return new Units.LabelledMapping(result, null); } diff --git a/src/main/java/uk/ac/starlink/ast/WcsMap.java b/src/main/java/uk/ac/starlink/ast/WcsMap.java index 7a29d95..2d36798 100644 --- a/src/main/java/uk/ac/starlink/ast/WcsMap.java +++ b/src/main/java/uk/ac/starlink/ast/WcsMap.java @@ -388,6 +388,41 @@ void dump(NativeNode node) { } } + /** + * wcsmap.c {@code Equal}: {@code that} is a WcsMap with the same numbers of inputs and + * outputs, the same Invert attribute, projection and longitude and latitude axes, and, on each + * axis, projection parameters equal to within {@code astEQUAL}, an unset parameter being bad, + * so that it differs from one set to zero. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof WcsMap)) { + return false; + } + WcsMap other = (WcsMap) that; + int nout = getNout(); + if (other.getNin() != getNin() || other.getNout() != nout || getInvert() != other.getInvert()) { + return false; + } + if (proj != other.proj || axes[0] != other.axes[0] || axes[1] != other.axes[1]) { + return false; + } + for (int i = 0; i < nout; i++) { + double[] p1 = pv == null ? null : pv[i]; + double[] p2 = other.pv == null ? null : other.pv[i]; + int n1 = p1 == null ? 0 : p1.length; + int n2 = p2 == null ? 0 : p2.length; + for (int j = 0; j < n1 || j < n2; j++) { + double v1 = j < n1 ? p1[j] : AST__BAD; + double v2 = j < n2 ? p2[j] : AST__BAD; + if (!MappingHelpers.astEqual(v1, v2)) { + return false; + } + } + } + return true; + } + /** Gives the copy its own projection parameters, as C's {@code Copy} (wcsmap.c) does. */ @Override void deepCopy() { diff --git a/src/main/java/uk/ac/starlink/ast/WinMap.java b/src/main/java/uk/ac/starlink/ast/WinMap.java index 11bcd6a..14177c7 100644 --- a/src/main/java/uk/ac/starlink/ast/WinMap.java +++ b/src/main/java/uk/ac/starlink/ast/WinMap.java @@ -149,6 +149,43 @@ boolean isLinear() { return true; } + /** + * winmap.c {@code Equal}: {@code that} is a WinMap with the same number of inputs whose stored + * shift and scale terms equal this one's, to within {@code astEQUAL}, and whose Invert + * attribute is the same; or, failing that, whose Invert attribute differs and whose terms, each + * WinMap's taken as it applies them ({@link #winTerms}), are equal. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof WinMap)) { + return false; + } + WinMap other = (WinMap) that; + int nin = getNin(); + if (other.getNin() != nin) { + return false; + } + if (sameTerms(shifts, scales, other.shifts, other.scales, nin)) { + return getInvert() == other.getInvert(); + } + if (getInvert() != other.getInvert()) { + double[][] thisTerms = winTerms(); + double[][] thatTerms = other.winTerms(); + return sameTerms(thisTerms[0], thisTerms[1], thatTerms[0], thatTerms[1], nin); + } + return false; + } + + /** Whether the first {@code n} shift and scale terms of two WinMaps are equal to within {@code astEQUAL}. */ + private static boolean sameTerms(double[] a1, double[] b1, double[] a2, double[] b2, int n) { + for (int i = 0; i < n; i++) { + if (!MappingHelpers.astEqual(a1[i], a2[i]) || !MappingHelpers.astEqual(b1[i], b2[i])) { + return false; + } + } + return true; + } + /** {@link WinMapMerge#winMapMerge}, winmap.c {@code MapMerge}. */ @Override int mapMerge(MergeList list, int where, boolean series) { diff --git a/src/main/java/uk/ac/starlink/ast/ZoomMap.java b/src/main/java/uk/ac/starlink/ast/ZoomMap.java index cc9bdc5..91c2735 100644 --- a/src/main/java/uk/ac/starlink/ast/ZoomMap.java +++ b/src/main/java/uk/ac/starlink/ast/ZoomMap.java @@ -69,6 +69,27 @@ boolean isLinear() { return true; } + /** + * zoommap.c {@code Equal}: {@code that} is a ZoomMap with the same numbers of inputs and + * outputs whose stored factor is, to within {@code astEQUAL}, this one's if their Invert + * attributes are the same, and its reciprocal if not. C compares the factors as stored, zero + * for a Zoom attribute that has been cleared. + */ + @Override + boolean equalTo(AstObject that) { + if (!(that instanceof ZoomMap)) { + return false; + } + ZoomMap other = (ZoomMap) that; + if (other.getNin() != getNin() || other.getNout() != getNout()) { + return false; + } + if (getInvert() == other.getInvert()) { + return MappingHelpers.astEqual(zoom, other.zoom); + } + return MappingHelpers.astEqual(zoom, 1.0 / other.zoom); + } + /** * zoommap.c {@code MapMerge}. The run of ZoomMaps and UnitMaps around this ZoomMap is replaced * by one Mapping applied forward: in series a ZoomMap of the product of their effective diff --git a/src/test/java/uk/ac/starlink/ast/AttrTestClearOracleTest.java b/src/test/java/uk/ac/starlink/ast/AttrTestClearOracleTest.java index 507bb71..042529e 100644 --- a/src/test/java/uk/ac/starlink/ast/AttrTestClearOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/AttrTestClearOracleTest.java @@ -18,21 +18,13 @@ * 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 LutMap, PcdMap, GrismMap, - * SplineMap and MathMap are skipped (out of scope). + *

{@link #build} makes each object as the probe does. The cases of SplineMap are skipped (class + * not yet ported). */ class AttrTestClearOracleTest { /** The cases whose classes are out of scope. */ - private static final List OUT_OF_SCOPE = Arrays.asList( - "lutmap_default", - "lutmap_cleared", - "pcdmap_cleared", - "grismmap_cleared", - "splinemap_default", - "splinemap_cleared", - "mathmap_default", - "mathmap_cleared"); + 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); @@ -45,6 +37,13 @@ private static PolyMap poly() { return m; } + private static LutMap lut() { + LutMap m = new LutMap(new double[] {0.0, 1.0, 4.0, 9.0, 16.0}, 0.0, 1.0); + m.setI("LutInterp", 0); + m.setD("LutEpsilon", 1e-10); + return m; + } + private static SphMap sph() { SphMap m = new SphMap(); m.set("UnitRadius=0,PolarLong=1.0"); @@ -55,6 +54,13 @@ private static SphMap sph() { * The object a case builds, and C's {@code astTest} route for each attribute: PermSplit is * protected in C, so the probe tests it through {@code astTestPermSplit}. */ + private static MathMap math() { + MathMap m = new MathMap(1, 1, new String[] {"y=x"}, new String[] {"x=y"}); + m.setSimpFI(false); + m.setSimpIF(false); + return m; + } + private static Mapping build(String name) { switch (name) { case "permmap_split_default": { @@ -74,6 +80,16 @@ private static Mapping build(String name) { assertEquals(1.0, m.getZoom()); return m; } + case "lutmap_default": + return lut(); + case "lutmap_cleared": { + LutMap m = lut(); + m.clear("LutInterp,LutEpsilon"); + // C's defaults (lutmap.c astMAKE_GET of LutInterp and LutEpsilon). + assertEquals(0, m.getI("LutInterp")); + assertEquals(Math.ulp(1.0), m.getD("LutEpsilon")); + return m; + } case "polymap_default": return poly(); case "polymap_cleared": { @@ -97,6 +113,13 @@ private static Mapping build(String name) { m.clear("UnitRadius,PolarLong"); return m; } + case "mathmap_default": + return math(); + case "mathmap_cleared": { + MathMap m = math(); + m.clear("SimpFI,SimpIF"); + return m; + } case "invert_set_zero": { ZoomMap m = new ZoomMap(1, 2.0); m.set("Invert=0"); @@ -114,6 +137,20 @@ private static Mapping build(String name) { m.invert(); return m; } + case "grismmap_cleared": { + GrismMap m = new GrismMap(); + m.setGrismNR(1.5); + m.setGrismM(2); + m.clear("GrismNR"); + m.clear("GrismM"); + return m; + } + case "pcdmap_cleared": { + PcdMap m = new PcdMap(1.0e-5, new double[] {1.0, 2.0}); + m.clear("Disco"); + m.clear("PcdCen(1)"); + return m; + } case "invert_cleared": { ZoomMap m = new ZoomMap(1, 2.0); m.set("Invert=1"); @@ -156,7 +193,7 @@ void testAndDumpMatchTheCLibrary() { failures.add(name + ": dump\n" + written + "C:\n" + c.get(2).asText()); } } - assertEquals(12, run, "the in-scope cases the C probe recorded"); + assertEquals(18, run, "the in-scope cases the C probe recorded"); assertTrue(failures.isEmpty(), String.join("\n", failures)); } diff --git a/src/test/java/uk/ac/starlink/ast/ChannelText.java b/src/test/java/uk/ac/starlink/ast/ChannelText.java index 8c80604..30a77c0 100644 --- a/src/test/java/uk/ac/starlink/ast/ChannelText.java +++ b/src/test/java/uk/ac/starlink/ast/ChannelText.java @@ -25,9 +25,14 @@ static String dump(AstObject obj) { return new String(out.toByteArray(), StandardCharsets.UTF_8); } - /** A Channel reading {@code text}. */ + /** + * A Channel reading {@code text}, with the transformation functions the C test programs + * register for the IntraMap fixtures ({@link FixtureIntraTransformers}). + */ static Channel reader(String text) { - return new Channel(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)), null); + Channel ch = new Channel(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)), null); + FixtureIntraTransformers.register(ch); + return ch; } /** diff --git a/src/test/java/uk/ac/starlink/ast/ClearOnSetTest.java b/src/test/java/uk/ac/starlink/ast/ClearOnSetTest.java index b1127e7..42935fa 100644 --- a/src/test/java/uk/ac/starlink/ast/ClearOnSetTest.java +++ b/src/test/java/uk/ac/starlink/ast/ClearOnSetTest.java @@ -19,9 +19,12 @@ * 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 LutMap, MathMap, SplineMap, PcdMap and GrismMap are listed in {@code - * deferred/rust-tests.txt} (out of scope), and the same classes are left out of {@link - * #loadPreservesTheRecordForEveryClearOnSetClass}. + *

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. */ class ClearOnSetTest { @@ -41,6 +44,28 @@ private static PermMap permMap() { return new PermMap(2, new int[] {1, 2}, 2, new int[] {1, 2}, null); } + private static LutMap lutMap() { + return new LutMap(new double[] {0.0, 1.0, 4.0, 9.0}, 0.0, 1.0); + } + + private static MathMap mathMap() { + return new MathMap(1, 1, new String[] {"y=2*x"}, new String[] {"x=0.5*y"}); + } + + /** A GrismMap with every attribute set, as Rust's {@code GrismMap::new} makes it. */ + private static GrismMap grismMap(double nr, double nrp, double waveR, double alpha, double g, int m) { + GrismMap map = new GrismMap(); + map.setGrismNR(nr); + map.setGrismNRP(nrp); + map.setGrismWaveR(waveR); + map.setGrismAlpha(alpha); + map.setGrismG(g); + map.setGrismM(m); + map.setGrismEps(0.0); + map.setGrismTheta(0.0); + return map; + } + private static WcsMap wcsMap() { return new WcsMap(2, WcsMap.AST__TAN, 1, 2); } @@ -95,6 +120,160 @@ void clearingPermSplitDiscardsTheRecord() { assertDiscards(permMap(), "PermMap.clearPermSplit", PermMap::clearPermSplit); } + @Test + void lutInterpDiscardsTheRecord() { + assertDiscards(lutMap(), "LutMap LutInterp", m -> m.setI("LutInterp", 1)); + } + + @Test + void lutEpsilonDiscardsTheRecord() { + assertDiscards(lutMap(), "LutMap LutEpsilon", m -> m.setD("LutEpsilon", 1e-7)); + } + + @Test + void mathSimpFiDiscardsTheRecord() { + assertDiscards(mathMap(), "MathMap.setSimpFI", m -> m.setSimpFI(true)); + } + + @Test + void mathSimpIfDiscardsTheRecord() { + assertDiscards(mathMap(), "MathMap.setSimpIF", m -> m.setSimpIF(true)); + } + + @Test + void mathSeedDiscardsTheRecord() { + assertDiscards(mathMap(), "MathMap.setSeed", m -> m.setSeed(1234)); + } + + @Test + void clearingMathSeedDiscardsTheRecord() { + assertDiscards(mathMap(), "MathMap Seed cleared", m -> m.clear("Seed")); + } + + /** + * Seed carries a separate set flag, so setting an unset Seed to the value it already holds is + * still a change (mathmap.c {@code SetSeed} tests {@code seed_set} before comparing values). + */ + @Test + void settingAnUnsetSeedToItsOwnDefaultDiscardsTheRecord() { + MathMap m = mathMap(); + assertFalse(m.test("Seed"), "a new MathMap must not report Seed as set, or the case proves nothing"); + int defaultSeed = m.getSeed(); + m.setIsSimple(); + m.setSeed(defaultSeed); + assertTrue(m.test("Seed"), "setting the default Seed did not make it set"); + assertFalse(m.getIsSimple(), "setting an unset Seed to its own default kept the simplified record"); + } + + /** Setting a set Seed to the value it already holds is not a change. */ + @Test + void reSettingAnExplicitSeedToTheSameValueKeepsTheRecord() { + MathMap m = mathMap(); + m.setSeed(4242); + m.setIsSimple(); + m.setSeed(4242); + assertTrue(m.getIsSimple(), "re-setting Seed to the value it already held discarded the record"); + } + + /* + * GrismMap's eight setters come from grismmap.c's own MAKE_SET, which discards both records + * when the value changes and recalculates the constants the transformation uses. + */ + + @Test + void grismNrDiscardsTheRecord() { + assertDiscards(new GrismMap(), "GrismMap.setGrismNR", m -> m.setGrismNR(1.5)); + } + + @Test + void grismNrpDiscardsTheRecord() { + assertDiscards(new GrismMap(), "GrismMap.setGrismNRP", m -> m.setGrismNRP(1e-5)); + } + + @Test + void grismWaveRDiscardsTheRecord() { + assertDiscards(new GrismMap(), "GrismMap.setGrismWaveR", m -> m.setGrismWaveR(6000.0)); + } + + @Test + void grismAlphaDiscardsTheRecord() { + assertDiscards(new GrismMap(), "GrismMap.setGrismAlpha", m -> m.setGrismAlpha(0.1)); + } + + @Test + void grismGDiscardsTheRecord() { + assertDiscards(new GrismMap(), "GrismMap.setGrismG", m -> m.setGrismG(1000.0)); + } + + @Test + void grismMDiscardsTheRecord() { + assertDiscards(new GrismMap(), "GrismMap.setGrismM", m -> m.setGrismM(1)); + } + + @Test + void grismEpsDiscardsTheRecord() { + assertDiscards(new GrismMap(), "GrismMap.setGrismEps", m -> m.setGrismEps(0.01)); + } + + @Test + void grismThetaDiscardsTheRecord() { + assertDiscards(new GrismMap(), "GrismMap.setGrismTheta", m -> m.setGrismTheta(0.02)); + } + + /** + * The setters recompute the derived constants, as C's {@code MAKE_SET} does ({@code + * UpdateConstants}): a GrismMap made with no attribute set, whose forward transformation is + * bad everywhere, has every attribute set afterwards and must then transform as C's GrismMap + * with the same attributes (probe {@code probes/grismmap_probe.c}, case {@code + * transformations}). Constants left from construction would give bad values. + */ + @Test + void grismSettersRecomputeTheConstants() { + GrismMap set = new GrismMap(); + set.setGrismNR(1.5); + set.setGrismNRP(-1e-6); + set.setGrismWaveR(5000.0); + set.setGrismAlpha(0.1); + set.setGrismG(2e-4); + set.setGrismM(1); + set.setGrismEps(0.02); + set.setGrismTheta(0.03); + String c = uk.ac.starlink.ast.testsupport.ProbeOutput.load("grismmap_probe") + .get("transformations"); + double[] pts = {0.0, 0.01, -0.01, 0.05}; + double[] got = set.tran1(pts.length, pts, true); + for (int i = 0; i < pts.length; i++) { + String head = "fwd " + CFormat.format("%.17g", pts[i]) + " -> "; + int at = c.indexOf(head); + assertTrue(at >= 0, "the probe has no line " + head); + double want = Double.parseDouble(c.substring(at + head.length(), c.indexOf('\n', at))); + assertTrue( + uk.ac.starlink.ast.testsupport.CValues.withinLibmRounding(got[i], want), + "point " + i + ": got " + got[i] + ", C gives " + want + "; the setters left stale constants"); + } + } + + /** + * C stores a GrismMap attribute as given and reads it back through a getter that gives the + * default for the {@code AST__BAD} unset value, so setting {@code AST__BAD} restores the + * default and leaves the attribute unset, which the dump shows by writing it commented out. + */ + @Test + void grismSentinelRestoresTheDefaultAndUntestsTheAttribute() { + GrismMap m = grismMap(1.5, 0.0, 6000.0, 0.0, 1000.0, 1); + assertTrue(ChannelText.dump(m).contains("GrmNR = 1.5"), "a GrismMap with GrismNR set should write it"); + m.setGrismNR(AstObject.AST__BAD); + assertEquals(1.0, m.getGrismNR(), "the sentinel should restore the default"); + String dump = ChannelText.dump(m); + assertTrue(dump.contains("# GrmNR = 1 "), "the sentinel should leave GrmNR unset; got:\n" + dump); + } + + /** PcdMap's Disco setter comes from {@code astMAKE_SET1}, which discards both records when the value changes. */ + @Test + void pcdDiscoDiscardsTheRecord() { + assertDiscards(new PcdMap(1e-6, new double[] {0.0, 0.0}), "PcdMap.setDisco", m -> m.setDisco(2e-6)); + } + @Test void zoomDiscardsTheRecord() { assertDiscards(new ZoomMap(2, 3.0), "ZoomMap.setZoom", m -> m.setZoom(4.0)); @@ -159,6 +338,12 @@ void loadPreservesTheRecordForEveryClearOnSetClass() { zoom.setIsSimple(); assertLoadPreserves(zoom, "ZoomMap Zoom"); + MathMap math = mathMap(); + math.setSimpFI(true); + math.setSimpIF(true); + math.setSeed(77); + assertLoadPreserves(math, "MathMap SimpFI"); + PolyMap poly = polyMap(); poly.setIterInverse(true); poly.setNiterInverse(7); @@ -178,5 +363,23 @@ void loadPreservesTheRecordForEveryClearOnSetClass() { PermMap perm = permMap(); perm.setPermSplit(true); assertLoadPreserves(perm, "PermMap PermSplit"); + + PcdMap pcd = new PcdMap(0.01, new double[] {1.0, 2.0}); + pcd.setDisco(0.02); + assertLoadPreserves(pcd, "PcdMap Disco"); + + PcdMap pcdCen = new PcdMap(0.01, new double[] {1.0, 2.0}); + pcdCen.setPcdCen(1, 3.0); + assertLoadPreserves(pcdCen, "PcdMap PcdCen"); + + LutMap lut = lutMap(); + lut.setI("LutInterp", 1); + assertLoadPreserves(lut, "LutMap LutInterp"); + + LutMap lutEps = lutMap(); + lutEps.setD("LutEpsilon", 1e-10); + assertLoadPreserves(lutEps, "LutMap LutEpsilon"); + + assertLoadPreserves(grismMap(1.5, -1e-6, 5000.0, 0.1, 2e-4, 1), "GrismMap GrismNR"); } } diff --git a/src/test/java/uk/ac/starlink/ast/CmpMapSeriesMemoryChild.java b/src/test/java/uk/ac/starlink/ast/CmpMapSeriesMemoryChild.java new file mode 100644 index 0000000..e8a0aef --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/CmpMapSeriesMemoryChild.java @@ -0,0 +1,84 @@ +package uk.ac.starlink.ast; + +/** + * The program {@code CmpMapTest} runs in a child JVM whose heap holds the points given and their + * result with little to spare: it transforms the points through eight ZoomMaps in nested series + * CmpMaps in the way its argument names, checks the result, prints "passed" and exits with status + * 0, or prints the failure and exits with status 1. A series CmpMap that held every point between + * its two components would hold one full-size intermediate per level and run out of heap. + */ +final class CmpMapSeriesMemoryChild { + + /** The number of points: two axes of them take 32 MiB. */ + static final int NPOINT = 1 << 21; + + private CmpMapSeriesMemoryChild() {} + + private static void check(boolean ok, String what) { + if (!ok) { + throw new IllegalStateException(what); + } + } + + /** + * Runs one mode. + * + * @param args the mode: {@code transform}, {@code transformInto} or {@code transformIntoNan} + */ + // The parent process reads the result from standard output, and any failure, running out of + // heap among them, is reported there. + @SuppressWarnings({"PMD.SystemPrintln", "PMD.AvoidCatchingGenericException"}) + public static void main(String[] args) { + try { + run(args[0]); + System.out.println("passed"); + } catch (RuntimeException | OutOfMemoryError e) { + System.out.println("failed: " + e); + System.exit(1); + } + } + + /** The points (i, -i). */ + private static double[][] points() { + double[][] pts = new double[2][NPOINT]; + for (int i = 0; i < NPOINT; i++) { + pts[0][i] = i; + pts[1][i] = -i; + } + return pts; + } + + /** Eight ZoomMaps of factor 2 in series, nested as {@code z, (z, (z, ...))} or the other way. */ + static Mapping chain(boolean right) { + Mapping map = new ZoomMap(2, 2.0); + for (int i = 1; i < 8; i++) { + map = right ? new CmpMap(new ZoomMap(2, 2.0), map, true) : new CmpMap(map, new ZoomMap(2, 2.0), true); + } + return map; + } + + private static void run(String mode) { + double[][] pts = points(); + if ("transform".equals(mode)) { + for (boolean right : new boolean[] {true, false}) { + Mapping map = chain(right); + for (boolean forward : new boolean[] {true, false}) { + double[][] out = map.transform(pts, NPOINT, forward); + double want = forward ? 256.0 : 1.0 / 256.0; + check(out[0][1] == want, "right " + right + " forward " + forward + ": " + out[0][1]); + } + } + } else if ("transformInto".equals(mode) || "transformIntoNan".equals(mode)) { + Mapping map = chain(true); + double[][] out = new double[2][NPOINT]; + if ("transformInto".equals(mode)) { + map.transformInto(pts, NPOINT, true, out); + } else { + map.transformIntoNan(pts, NPOINT, true, out); + } + check(out[0][1] == 256.0, mode + ": " + out[0][1]); + } else { + throw new IllegalArgumentException("unknown mode " + mode); + } + } +} diff --git a/src/test/java/uk/ac/starlink/ast/CmpMapTest.java b/src/test/java/uk/ac/starlink/ast/CmpMapTest.java index 739b228..8c29202 100644 --- a/src/test/java/uk/ac/starlink/ast/CmpMapTest.java +++ b/src/test/java/uk/ac/starlink/ast/CmpMapTest.java @@ -11,6 +11,11 @@ import static uk.ac.starlink.ast.MappingTestData.point; import static uk.ac.starlink.ast.MappingTestData.transformRows; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Paths; import org.junit.jupiter.api.Test; /** @@ -18,11 +23,10 @@ * gives, which Rust, copying its components, has no counterpart for. Rust's {@code then} and * {@code alongside} are the constructor with {@code series} true and false. * - *

{@code - * series_inverse_pair_of_mathmaps_cancels_to_unitmap} and {@code - * parallel_with_inverted_cmpmap_child_canonicalises_for_serialisation} need a MathMap, and {@code - * cmpmap_equality_compares_components_as_applied} tests {@code astEqual}: all are outside the first - * phase. {@code cmpmap_simplified_two_unitmaps_series} and {@code + *

Also the translation of the three nested-series tests of Rust {@code + * tests/test_transform_memory.rs}, which a child JVM runs ({@link CmpMapSeriesMemoryChild}). + * + *

{@code cmpmap_simplified_two_unitmaps_series} and {@code * cmpmap_simplified_two_unitmaps_parallel} check only how the simplified Mapping transforms, which * holds of a Mapping that is not restructured. */ @@ -297,4 +301,141 @@ void aFramesetComponentBecomesItsMapping() { " End CmpMap"); assertEquals(want, ChannelText.dump(cmp)); } + + @Test + void seriesInversePairOfMathmapsCancelsToUnitmap() { + MathMap mFwd = new MathMap(1, 1, new String[] {"y=2*x"}, new String[] {"x=0.5*y"}); + mFwd.setSimpFI(true); + mFwd.setSimpIF(true); + MathMap mInv = (MathMap) mFwd.copy(); + mInv.invert(); + Mapping simp = new CmpMap(mFwd, mInv, true).simplify(); + assertInstanceOf(UnitMap.class, simp); + } + + /** + * A simplified parallel CmpMap whose first component is an inverted series CmpMap is written + * with the inversion in the inner CmpMap's InvA and InvB, not as an InvA of the outer one or an + * Invert of the inner one ({@code MathMapTest.aParallelCmpMapWithAnInvertedSeriesSimplifiesAsC} + * compares the whole dump with C's). + */ + @Test + void parallelWithInvertedCmpmapChildCanonicalisesForSerialisation() { + CmpMap first = makeInnerSeries(); + first.invert(); + CmpMap second = makeInnerSeries(); + Mapping simp = new CmpMap(first, second, false).simplify(); + assertInstanceOf(CmpMap.class, simp); + String s = ChannelText.dump(simp); + String[] lines = s.split("\n", -1); + int outerIndent = -1; + for (String l : lines) { + if (l.contains("Begin CmpMap")) { + outerIndent = l.length() - l.trim().length(); + break; + } + } + boolean outerInva = false; + int innerInva = 0; + int innerInvb = 0; + for (String l : lines) { + int ind = l.length() - l.replaceAll("^\\s+", "").length(); + if (ind == outerIndent + 3 && l.trim().startsWith("InvA = 1")) { + outerInva = true; + } + if (l.contains("InvA = 1")) { + innerInva++; + } + if (l.contains("InvB = 1")) { + innerInvb++; + } + assertFalse(l.contains("Invert = 1"), "no CmpMap should carry Invert = 1:\n" + s); + } + assertFalse(outerInva, "outer parallel must not have InvA:\n" + s); + assertTrue(innerInva >= 1 && innerInvb >= 1, "inner CmpMap must carry InvA = 1 and InvB = 1:\n" + s); + } + + private static CmpMap makeInnerSeries() { + MathMap a = new MathMap(1, 1, new String[] {"y=2*x"}, new String[] {"x=0.5*y"}); + a.setSimpFI(true); + a.setSimpIF(true); + return new CmpMap(a, (Mapping) a.copy(), true); + } + + /** cmpmap.c {@code Equal} compares the components as the CmpMaps apply them. */ + @Test + void cmpmapEqualityComparesComponentsAsApplied() { + UnitMap u = new UnitMap(1); + u.invert(); + assertTrue(new CmpMap(u, new ZoomMap(1, 2.0), true) + .astEqual(new CmpMap(new UnitMap(1), new ZoomMap(1, 2.0), true))); + ZoomMap z = new ZoomMap(1, 2.0); + z.invert(); + assertTrue(new CmpMap(z, new ShiftMap(new double[] {1.0}), true) + .astEqual(new CmpMap(new ZoomMap(1, 0.5), new ShiftMap(new double[] {1.0}), true))); + assertFalse(new CmpMap(new ZoomMap(1, 2.0), new ShiftMap(new double[] {1.0}), true) + .astEqual(new CmpMap(new ZoomMap(1, 0.5), new ShiftMap(new double[] {1.0}), true))); + } + + // ------------------------------------------------------------------ + // tests/test_transform_memory.rs: nested series hold no full-size intermediates + // ------------------------------------------------------------------ + + /** + * The heap {@link CmpMapSeriesMemoryChild} runs in: the points given and their result, each 32 + * MiB, and beyond them half of that and 8 MiB for the JVM's own use. A series CmpMap passes the + * points between its components 8192 at a time (cmpmap.c {@code Transform}), so eight ZoomMaps + * in nested series need a few batches of 8192 points beyond the result, whatever the number of + * points; holding the points between the components would need a full-size intermediate per + * level, seven in all, and one alone does not fit. Rust bounds the peak beyond the input by the + * size of the result and 2 MiB of batches. + */ + private static final String HEAP_MIB = Integer.toString(2 * 32 + 16 + 8); + + private static String readAll(InputStream in) throws IOException { + ByteArrayOutputStream buf = new ByteArrayOutputStream(); + byte[] chunk = new byte[4096]; + for (int n = in.read(chunk); n >= 0; n = in.read(chunk)) { + buf.write(chunk, 0, n); + } + return new String(buf.toByteArray(), StandardCharsets.UTF_8); + } + + /** + * Runs {@link CmpMapSeriesMemoryChild} with {@code mode} in a JVM of the heap {@link #HEAP_MIB} + * describes, with the serial collector and a small young generation, so that the old + * generation, which holds the large arrays, has nearly all of it. + */ + private static void assertFitsTheHeap(String mode) throws IOException, InterruptedException { + String java = Paths.get(System.getProperty("java.home"), "bin", "java").toString(); + ProcessBuilder pb = new ProcessBuilder( + java, + "-XX:+UseSerialGC", + "-Xmn4m", + "-Xmx" + HEAP_MIB + "m", + "-cp", + System.getProperty("java.class.path"), + CmpMapSeriesMemoryChild.class.getName(), + mode); + pb.redirectErrorStream(true); + Process p = pb.start(); + String out = readAll(p.getInputStream()); + assertEquals(0, p.waitFor(), mode + ": " + out); + assertTrue(out.contains("passed"), mode + ": " + out); + } + + @Test + void nestedSeriesHoldsNoFullSizeIntermediates() throws IOException, InterruptedException { + assertFitsTheHeap("transform"); + } + + @Test + void nestedSeriesTransformIntoHoldsNoFullSizeIntermediates() throws IOException, InterruptedException { + assertFitsTheHeap("transformInto"); + } + + @Test + void nestedSeriesTransformIntoNanHoldsNoFullSizeIntermediates() throws IOException, InterruptedException { + assertFitsTheHeap("transformIntoNan"); + } } diff --git a/src/test/java/uk/ac/starlink/ast/ConstructorChecksTest.java b/src/test/java/uk/ac/starlink/ast/ConstructorChecksTest.java index fd4bf88..c60291b 100644 --- a/src/test/java/uk/ac/starlink/ast/ConstructorChecksTest.java +++ b/src/test/java/uk/ac/starlink/ast/ConstructorChecksTest.java @@ -2,6 +2,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -9,10 +10,52 @@ * 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 outside the first phase. + *

The other tests need classes not yet ported. */ class ConstructorChecksTest { + /** A Mapping with an inverse but no forward transformation: an inverted RateMap. */ + private static Mapping inverseOnly() { + RateMap rate = new RateMap(new ZoomMap(1, 2.0), 1, 1); + rate.invert(); + assertTrue(!rate.getTranForward() && rate.getTranInverse()); + return rate; + } + + /** A Mapping with a forward but no inverse transformation: a RateMap. */ + private static Mapping forwardOnly() { + RateMap rate = new RateMap(new ZoomMap(1, 2.0), 1, 1); + assertTrue(rate.getTranForward() && !rate.getTranInverse()); + return rate; + } + + /** + * tranmap.c astInitTranMap: the first Mapping supplies the forward transformation and the + * second the inverse. + */ + @Test + void aTranmapNeedsItsTwoDirections() { + AstException e = assertThrows(AstException.class, () -> new TranMap(inverseOnly(), new UnitMap(1))); + assertEquals(AstException.AST__INTRD, e.getStatus()); + e = assertThrows(AstException.class, () -> new TranMap(new UnitMap(1), forwardOnly())); + assertEquals(AstException.AST__INTRD, e.getStatus()); + new TranMap(forwardOnly(), inverseOnly()); + } + + /** + * switchmap.c astInitSwitchMap: the forward selector needs a forward transformation and the + * inverse selector an inverse one. + */ + @Test + void aSwitchmapSelectorNeedsItsDirection() { + AstException e = assertThrows( + AstException.class, () -> new SwitchMap(inverseOnly(), null, new Mapping[] {new ZoomMap(1, 2.0)})); + assertEquals(AstException.AST__INTRD, e.getStatus()); + e = assertThrows( + AstException.class, () -> new SwitchMap(null, forwardOnly(), new Mapping[] {new ZoomMap(1, 2.0)})); + assertEquals(AstException.AST__INTRD, e.getStatus()); + } + /** wcsmap.c SetPV: an axis out of range, or one that is not celestial, is AST__AXIIN. */ @Test void aWcsmapPvNeedsACelestialAxis() { @@ -23,6 +66,16 @@ void aWcsmapPvNeedsACelestialAxis() { } } + /** mathmap.c astInitMathMap: too few forward or inverse functions is AST__INNTF. */ + @Test + void aMathmapNeedsAFunctionPerOutput() { + AstException e = + assertThrows(AstException.class, () -> new MathMap(1, 2, new String[] {"y=x"}, new String[] {"x=y"})); + assertEquals(AstException.AST__INNTF, e.getStatus()); + e = assertThrows(AstException.class, () -> new MathMap(2, 1, new String[] {"y=x1"}, new String[] {"x1=y"})); + assertEquals(AstException.AST__INNTF, e.getStatus()); + } + /** polymap.c StoreArrays: a term for an output that does not exist is AST__BADCI. */ @Test void aPolymapTermNeedsARealOutput() { diff --git a/src/test/java/uk/ac/starlink/ast/DssMapTest.java b/src/test/java/uk/ac/starlink/ast/DssMapTest.java new file mode 100644 index 0000000..643e33b --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/DssMapTest.java @@ -0,0 +1,612 @@ +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 static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Arrays; +import java.util.Map; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.CValues; +import uk.ac.starlink.ast.testsupport.Fixtures; +import uk.ac.starlink.ast.testsupport.ProbeOutput; + +/** + * Translation of the unit tests of Rust {@code mappings/dssmap.rs}, with expected values from the + * C probe {@code probes/dssmap_probe.c}. C has no public DssMap constructor, so every DssMap here + * is read from the C fixture {@code serialisation/c_dssmap.ast} (the plate solution of Rust's + * {@code make_test_dssmap}), some with one item removed or its value replaced. + * + *

The plate solution uses {@code sin}, {@code cos}, {@code tan}, {@code atan} and {@code + * atan2}, whose last bit can differ from C's maths library ({@code Math.tan} of the plate + * declination does here), so transformed values are compared with C's to within libm rounding + * ({@link CValues#withinLibmRounding}), each given the inputs C was given; every other part of the + * text must match exactly. + */ +class DssMapTest { + + private static final double BAD = AstObject.AST__BAD; + + private static final Map PROBE_CASES = ProbeOutput.load("dssmap_probe"); + + /** The pixel positions the probe transforms forward. */ + private static final double[] XS = {1000.0, 1.0, 500.0, 4000.0, 2000.0, BAD, 100.0}; + + private static final double[] YS = {2000.0, 1.0, 500.0, 4000.0, 3000.0, 100.0, BAD}; + + /** The sky positions (radians) the probe transforms in the inverse direction. */ + private static final double[] RAS = {2.83, 2.8, 5.97, 1.25, BAD, 2.85}; + + private static final double[] DECS = {-1.05, -1.0, 1.05, 0.0, -1.0, BAD}; + + private static final String FIXTURE = Fixtures.read("serialisation/c_dssmap.ast"); + + /** + * The size of the plate pixel coordinates of the image pixels here (CNPix of the fixture), to + * which {@link #pixelEq} applies {@link CValues#LIBM_RTOL}. + */ + private static final double PLATE_PIXELS = 4201.0; + + private static String probe(String name) { + String text = PROBE_CASES.get(name); + if (text == null) { + throw new IllegalStateException("no probe case " + name); + } + return text; + } + + private static String g(double v) { + return CFormat.format("%.17g", v); + } + + /** Whether the fixture line {@code line} holds the item {@code key}, as the probe's {@code has_key}. */ + private static boolean hasKey(String line, String key) { + return line.trim().startsWith(key + " ="); + } + + /** + * The probe's {@code dss}: the DssMap the fixture describes, with the item {@code drop} left + * out and the value of item {@code key} replaced by {@code value} (either may be null). + */ + static Mapping dss(String drop, String key, String value) { + StringBuilder sb = new StringBuilder(); + for (String line : FIXTURE.split("\n", -1)) { + if (line.isEmpty() || (drop != null && hasKey(line, drop))) { + continue; + } + if (key != null && hasKey(line, key)) { + sb.append(" ") + .append(key) + .append(" = ") + .append(value) + .append(" \t") + .append(line.substring(line.indexOf('#'))) + .append('\n'); + } else { + sb.append(line).append('\n'); + } + } + return (Mapping) ChannelText.read(sb.toString()); + } + + static Mapping dss() { + return dss(null, null, null); + } + + /** The fixture with both CNPix items 4200, so that the probe's WinMaps give whole CNPix values. */ + private static Mapping dss4200() { + String text = FIXTURE.replace("CNPix1 = 4201", "CNPix1 = 4200").replace("CNPix2 = 4201", "CNPix2 = 4200"); + return (Mapping) ChannelText.read(text); + } + + private static T inv(T m) { + m.invert(); + return m; + } + + private static CmpMap series(Mapping a, Mapping b) { + return new CmpMap(a, b, true); + } + + /** The WinMap x -> 2x - 0.5 on both axes. */ + private static WinMap win() { + return new WinMap( + 2, new double[] {0.0, 0.0}, new double[] {1.0, 1.0}, new double[] {-0.5, -0.5}, new double[] {1.5, 1.5 + }); + } + + /** The WinMap x -> 2x on both axes. */ + private static WinMap winNoShift() { + return new WinMap( + 2, new double[] {0.0, 0.0}, new double[] {1.0, 1.0}, new double[] {0.0, 0.0}, new double[] {2.0, 2.0}); + } + + /** + * Whether the image pixel coordinate {@code got} matches C's {@code want}. {@code platepix} + * gives the plate pixel coordinate, about 4200 here, less the corner offset (CNPix), so the + * image pixel coordinate is compared to within libm rounding of the plate pixel coordinate: the + * tolerance is {@link CValues#LIBM_RTOL} applied to the plate coordinate, about 4e-10 pixels. + * That is too coarse to see an error the size of the one a wrong value of two pi makes, so + * {@link #rightAscensionWrapsAsInC} checks the wrapped right ascensions to two units in the last + * place. + */ + private static boolean pixelEq(double got, double want) { + if (got == BAD || want == BAD) { + return got == want; + } + return Math.abs(got - want) <= CValues.LIBM_ATOL + CValues.LIBM_RTOL * (Math.abs(want) + PLATE_PIXELS); + } + + /** + * Requires each line {@code

x y -> a b} of the probe case {@code name} to be what {@code + * m} gives: ({@code x}, {@code y}) transformed forward ({@code fwd}) or in the inverse + * direction ({@code inv}) is ({@code a}, {@code b}), sky coordinates to within libm rounding + * and pixel coordinates as {@link #pixelEq} compares them. + */ + private static void assertTransformsAsC(String name, Mapping m) { + StringBuilder failures = new StringBuilder(); + int n = 0; + for (String line : probe(name).split("\n", -1)) { + if (line.isEmpty()) { + continue; + } + String[] f = line.split(" ", -1); + assertEquals(6, f.length, line); + assertEquals("->", f[3], line); + boolean forward = "fwd".equals(f[0]); + double[][] out = m.tran2( + 1, new double[] {Double.parseDouble(f[1])}, new double[] {Double.parseDouble(f[2])}, forward); + double want0 = Double.parseDouble(f[4]); + double want1 = Double.parseDouble(f[5]); + boolean ok = forward != m.getInvert() + ? CValues.cValueEq(out[0][0], want0) && CValues.cValueEq(out[1][0], want1) + : pixelEq(out[0][0], want0) && pixelEq(out[1][0], want1); + if (!ok) { + failures.append(line) + .append(": got ") + .append(g(out[0][0])) + .append(' ') + .append(g(out[1][0])) + .append('\n'); + } + n++; + } + assertEquals(XS.length * 2 + RAS.length, n, name); + assertEquals("", failures.toString(), name); + } + + /** Requires {@code got} to be the probe case {@code name}, numbers to within libm rounding. */ + private static void assertProbe(String name, String got) { + String want = probe(name); + assertTrue(CValues.nativeStringsWithinLibmRounding(got, want), name + ": got\n" + got + "C gives\n" + want); + } + + /** + * The probe's {@code simp}: the class of the simplified Mapping, its dump, and, for a Mapping + * of two inputs, the transformations of the pixel positions in direction {@code fwd} by the + * Mapping and by the simplified Mapping. + */ + private static String simp(Mapping m, boolean fwd) { + Mapping s = m.simplify(); + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(s.astClass()).append('\n').append(ChannelText.dump(s)); + if (m.getNin() != 2) { + return sb.toString(); + } + String[] heads = {"-- transformations\n", "-- transformations simplified\n"}; + Mapping[] maps = {m, s}; + for (int k = 0; k < 2; k++) { + sb.append(heads[k]); + double[][] out = maps[k].tran2(XS.length, XS, YS, fwd); + for (int i = 0; i < XS.length; i++) { + sb.append(g(out[0][i])).append(' ').append(g(out[1][i])).append('\n'); + } + } + return sb.toString(); + } + + private static String report(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 case without the lines naming the C source of an error. */ + private static String withoutSource(String text) { + StringBuilder sb = new StringBuilder(); + for (String line : text.split("\n", -1)) { + if (!line.contains("AST: Error in routine") && !line.isEmpty()) { + sb.append(line).append('\n'); + } + } + return sb.toString(); + } + + // ------------------------------------------------------------------ + // Construction + // ------------------------------------------------------------------ + + /** dssmap_basic_properties: two inputs and outputs, not inverted, the plate centre as read. */ + @Test + void dssmapBasicProperties() { + Mapping dm = dss(); + assertEquals("DssMap", dm.astClass()); + assertEquals(2, dm.getNin()); + assertEquals(2, dm.getNout()); + assertFalse(dm.getInvert()); + assertTrue(dm.getTranForward()); + assertTrue(dm.getTranInverse()); + String dump = ChannelText.dump(dm); + assertTrue(dump.contains("PltRA = 2.8272374655684112 \t"), dump); + assertTrue(dump.contains("PltDec = -1.0518122540502668 \t"), dump); + assertTrue(dump.contains("PltScl = 67.200000000000003 \t"), dump); + } + + // ------------------------------------------------------------------ + // Transformations + // ------------------------------------------------------------------ + + /** + * dssmap_forward_plate_centre, dssmap_forward_bad_propagation, dssmap_inverse_bad_propagation + * and dssmap_reads_c_written_native_dump: pixel positions to the sky and back, and sky + * positions to pixels, as C gives them; a bad coordinate gives bad values on both axes. + */ + @Test + void transformationsMatchC() { + assertTransformsAsC("tran", dss()); + assertTransformsAsC("tran_cnpix_4200", dss(null, "CNPix1", "4200")); + } + + /** dssmap_roundtrip_inverted: an inverted DssMap exchanges the two directions. */ + @Test + void invertedTransformationsMatchC() { + assertTransformsAsC("tran_inverted", inv(dss())); + } + + /** + * A plate centre just east of RA zero: pixel positions to its west have a negative right + * ascension, to which C's {@code platepos} adds its own value of two pi, 6.28318530717959, a + * little more than the double nearest to two pi: about four units in the last place of the + * result. So the wrapped right ascensions, which C gives here to within libm rounding, must also + * be within two units in the last place of C's (one for the {@code atan2} of the plate offset + * and one for the rounding of the conversions). + */ + @Test + void rightAscensionWrapsAsInC() { + Mapping wrapped = dss(null, "PltRA", "0.0001"); + assertTransformsAsC("tran_pltra_small", wrapped); + int n = 0; + for (String line : probe("tran_pltra_small").split("\n", -1)) { + String[] f = line.split(" ", -1); + if (!line.startsWith("fwd") || Double.parseDouble(f[1]) == BAD || Double.parseDouble(f[2]) == BAD) { + continue; + } + double want = Double.parseDouble(f[4]); + double[][] out = wrapped.tran2( + 1, new double[] {Double.parseDouble(f[1])}, new double[] {Double.parseDouble(f[2])}, true); + assertTrue(want > 6.2 && want < 2.0 * Math.PI, line); + assertTrue(CValues.ulpClose(out[0][0], want, 2), line + ": got " + g(out[0][0])); + n++; + } + assertEquals(5, n); + } + + /** + * Plate solution coefficients 14 to 19 are read and dumped but take no part in the + * transformations: C's {@code platepos} and {@code platepix} leave out the magnitude and colour + * terms. + */ + @Test + void magnitudeTermsAreIgnored() { + assertTransformsAsC("load_amdx14_nonzero", dss(null, "AMDX14", "5")); + } + + /** dssmap_roundtrip: pixel positions come back from the sky to well within a pixel. */ + @Test + void dssmapRoundtrip() { + Mapping dm = dss(); + double[] x = {500.0, 1000.0, 2000.0, 4000.0}; + double[] y = {500.0, 1000.0, 3000.0, 4000.0}; + double[][] sky = dm.tran2(4, x, y, true); + double[][] back = dm.tran2(4, sky[0], sky[1], false); + for (int i = 0; i < 4; i++) { + assertTrue(Math.abs(x[i] - back[0][i]) < 1e-6, "x " + i); + assertTrue(Math.abs(y[i] - back[1][i]) < 1e-6, "y " + i); + } + } + + /** dssmap_roundtrip_inverted. */ + @Test + void dssmapRoundtripInverted() { + Mapping dm = inv(dss()); + double[] x = {1500.0, 3000.0}; + double[] y = {2500.0, 3500.0}; + double[][] sky = dm.tran2(2, x, y, false); + double[][] back = dm.tran2(2, sky[0], sky[1], true); + for (int i = 0; i < 2; i++) { + assertTrue(Math.abs(x[i] - back[0][i]) < 1e-6, "x " + i); + assertTrue(Math.abs(y[i] - back[1][i]) < 1e-6, "y " + i); + } + } + + /** The numerical rates of the forward transformation, as mapping.c {@code Rate} gives them. */ + @Test + void ratesMatchC() { + Mapping dm = dss(); + StringBuilder sb = new StringBuilder(); + for (int ax1 = 1; ax1 <= 2; ax1++) { + for (int ax2 = 1; ax2 <= 2; ax2++) { + sb.append("rate ") + .append(ax1) + .append(' ') + .append(ax2) + .append(' ') + .append(g(dm.rate(new double[] {1000.0, 2000.0}, ax1, ax2))) + .append('\n'); + } + } + assertProbe("rate", sb.toString()); + } + + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + /** + * dssmap_equal_same, dssmap_equal_different_ppo and dssmap_equal_different_invert: C's {@code + * Equal} (dssmap.c) compares, with {@code astEQUAL}, the plate centre, the pixel offsets and + * sizes, PPO3, PPO6 and the first 13 coefficients on each axis, and requires the same Invert + * attribute; the plate scale and the other coefficients are not compared. + */ + @Test + void equalityMatchesC() { + Mapping m = dss(); + String[] keys = { + "PltRA", "PltRA", "PltDec", "PltScl", "CNPix1", "CNPix2", "XPixSz", "YPixSz", "PPO1", "PPO2", "PPO3", + "PPO4", "PPO5", "PPO6", "AMDX1", "AMDX13", "AMDX14", "AMDX19", "AMDY1", "AMDY13", "AMDY14", "AMDY19" + }; + String[] values = { + "2.8272374655684120", + "2.8272374655685", + "-1.05", + "60", + "4200", + "4200", + "25.3", + "25.3", + "1", + "1", + "105990", + "1", + "1", + "105990", + "67.15", + "1.5e-12", + "1", + "1", + "67.15", + "1.4e-12", + "1", + "1" + }; + StringBuilder sb = new StringBuilder() + .append("same ") + .append(m.astEqual(dss()) ? 1 : 0) + .append("\ncopy ") + .append(m.astEqual(m.copy()) ? 1 : 0) + .append("\ninverted ") + .append(m.astEqual(inv(dss())) ? 1 : 0) + .append("\nboth_inverted ") + .append(inv((Mapping) m.copy()).astEqual(inv(dss())) ? 1 : 0) + .append("\nwinmap ") + .append(m.astEqual(win()) ? 1 : 0) + .append('\n'); + for (int i = 0; i < keys.length; i++) { + boolean eq = m.astEqual(dss(null, keys[i], values[i])); + sb.append(keys[i]) + .append(' ') + .append(values[i]) + .append(' ') + .append(eq ? 1 : 0) + .append('\n'); + } + assertEquals(probe("equal"), sb.toString()); + } + + // ------------------------------------------------------------------ + // Serialisation + // ------------------------------------------------------------------ + + /** + * dssmap_serialization_roundtrip, dssmap_serialization_inverted and + * dssmap_serialization_transform_preserved: a DssMap read back from its dump is equal to it, + * with the same dump and transformations. + */ + @Test + void dssmapSerializationRoundtrip() { + for (boolean inverted : new boolean[] {false, true}) { + Mapping dm = dss(); + if (inverted) { + dm.invert(); + } + String text = ChannelText.dump(dm); + Mapping back = (Mapping) ChannelText.read(text); + assertEquals("DssMap", back.astClass()); + assertEquals(inverted, back.getInvert()); + assertTrue(dm.astEqual(back)); + assertEquals(text, ChannelText.dump(back)); + for (boolean forward : new boolean[] {true, false}) { + double[][] want = dm.tran2(RAS.length, RAS, DECS, forward); + double[][] got = back.tran2(RAS.length, RAS, DECS, forward); + assertTrue(Arrays.deepEquals(want, got), "inverted " + inverted + " forward " + forward); + } + } + } + + /** C's dump of a DssMap is written back byte for byte, as C writes it. */ + @Test + void cDumpIsWrittenBackAsC() { + assertEquals(FIXTURE, ChannelText.dump(dss())); + } + + /** + * A copy holds its own plate solution: it is equal to the original, and the simplification of + * a CmpMap holding the original leaves the original as it was. + */ + @Test + void aCopyIsEqual() { + Mapping dm = dss4200(); + Mapping copy = (Mapping) dm.copy(); + assertTrue(copy.astEqual(dm)); + series(win(), dm).simplify(); + assertEquals(ChannelText.dump(copy), ChannelText.dump(dm)); + } + + /** + * Rust {@code tests/test_mapping_load.rs} {@code a_dssmap_dump_needs_its_plate_solution}, with + * C's messages: a dump missing a plate parameter, PPO3, PPO6 or one of the first 13 + * coefficients on an axis is AST__RDERR (dssmap.c {@code astLoadDssMap}); the other items + * default to zero. + */ + @Test + void loadsWithAnItemMissingMatchC() { + String[] keys = { + "PltRA", "PltDec", "PltScl", "CNPix1", "CNPix2", "XPixSz", "YPixSz", "PPO1", "PPO2", "PPO3", "PPO4", + "PPO5", "PPO6", "AMDX1", "AMDX2", "AMDX13", "AMDX14", "AMDX19", "AMDY1", "AMDY12", "AMDY13", "AMDY14", + "AMDY19" + }; + StringBuilder sb = new StringBuilder(); + for (String key : keys) { + String result; + try { + result = "class " + dss(key, null, null).astClass() + "\n"; + } catch (AstException e) { + result = report(e); + } + sb.append("-- ").append(key).append('\n').append(result); + } + assertEquals(withoutSource(probe("load_missing")), sb.toString()); + } + + // ------------------------------------------------------------------ + // Simplification + // ------------------------------------------------------------------ + + /** dssmap_simplified_returns_clone: a DssMap alone simplifies to itself. */ + @Test + void dssmapSimplifiedAlone() { + Mapping dm = dss(); + assertProbe("alone", simp(dm, true)); + } + + /** + * dssmap_absorbs_preceding_winmap: a WinMap before a DssMap folds into its pixel offsets and + * sizes when the new offsets are whole to within 0.01 of a pixel; also with the WinMap + * inverted. + */ + @Test + void dssmapAbsorbsPrecedingWinmap() { + assertProbe("winmap_then_dssmap_4200", simp(series(win(), dss4200()), true)); + assertProbe("inverted_winmap_then_dssmap_4200", simp(series(inv(win()), dss4200()), true)); + } + + /** + * dssmap_inverted_absorbs_following_winmap: an inverted DssMap absorbs a WinMap after it, and + * stays inverted. + */ + @Test + void dssmapInvertedAbsorbsFollowingWinmap() { + assertProbe("inverted_dssmap_then_winmap", simp(series(inv(dss4200()), win()), false)); + } + + /** + * dssmap_fractional_cnpix_not_merged: no merge when either new pixel offset is not whole to + * within 0.01 of a pixel. + */ + @Test + void dssmapFractionalCnpixNotMerged() { + assertProbe("winmap_then_dssmap_fractional", simp(series(win(), dss()), true)); + assertProbe("winmap_then_dssmap_fractional_cnpix2", simp(series(win(), dss(null, "CNPix1", "4200")), true)); + Mapping dm = dss(); + MergeList list = new MergeList(Arrays.asList(winNoShift(), dm), Arrays.asList(false, false)); + assertEquals(-1, dm.mapMerge(list, 1, true)); + } + + /** + * dssmap_non_winmap_neighbour_not_merged: a ZoomMap, which a WinMap of zero shifts simplifies + * to, is not absorbed; nor is a WinMap on the side the DssMap's own direction does not take. + */ + @Test + void dssmapNonWinmapNeighbourNotMerged() { + assertProbe("winmap_no_shift_then_dssmap_4200", simp(series(winNoShift(), dss4200()), true)); + assertProbe("zoommap_then_dssmap", simp(series(new ZoomMap(2, 2.0), dss4200()), true)); + assertProbe("dssmap_then_winmap_4200", simp(series(dss4200(), win()), true)); + assertProbe("winmap_then_inverted_dssmap", simp(series(win(), inv(dss4200())), false)); + Mapping dm = dss4200(); + MergeList list = new MergeList(Arrays.asList(new ZoomMap(2, 2.0), dm), Arrays.asList(false, false)); + assertEquals(-1, dm.mapMerge(list, 1, true)); + } + + /** dssmap_parallel_not_merged: nothing merges in parallel. */ + @Test + void dssmapParallelNotMerged() { + assertProbe("parallel", simp(new CmpMap(win(), dss4200(), false), true)); + Mapping dm = dss4200(); + MergeList list = new MergeList(Arrays.asList(win(), dm), Arrays.asList(false, false)); + assertEquals(-1, dm.mapMerge(list, 1, false)); + } + + /** + * dssmap_zero_scale_winmap_not_merged: a WinMap with a zero scale is not absorbed (C's {@code + * MapMerge} requires both scales to be non-zero and neither term bad). + */ + @Test + void dssmapZeroScaleWinmapNotMerged() { + Mapping dm = dss4200(); + WinMap zero = new WinMap(new double[] {-0.5, -0.5}, new double[] {0.0, 2.0}); + MergeList list = new MergeList(Arrays.asList(zero, dm), Arrays.asList(false, false)); + assertEquals(-1, dm.mapMerge(list, 1, true)); + assertEquals(2, list.size()); + } + + /** + * The inverse of a series CmpMap of an inverted DssMap and an inverted WinMap applies the WinMap + * forward and then the DssMap forward, so the two merge as C merges them. As in C, the WinMap, + * which the CmpMap shares, is left with Invert 0, the value the list applied it with + * (dssmap.c {@code MapMerge} annuls its pointer before the restore; docs/rust-c-differences.md, + * "A DssMap merge leaves the WinMap's Invert attribute changed"). + */ + @Test + void aMergeLeavesTheWinmapWithTheListsInvertValue() { + WinMap w = inv(win()); + CmpMap c = series(inv(dss4200()), w); + c.invert(); + int before = w.getI("Invert"); + Mapping s = c.simplify(); + String got = "before " + before + "\nclass " + s.astClass() + "\nafter " + w.getI("Invert") + "\n"; + assertEquals(probe("invert_attr_both_inverted"), got); + assertProbe("inverted_dssmap_then_winmap_both_inverted", simp(c, true)); + } + + /** When the merge fails C restores the WinMap's Invert attribute, as this library does. */ + @Test + void aFailedMergeRestoresTheWinmapInvertAttribute() { + WinMap w = inv(win()); + CmpMap c = series(inv(dss()), w); + c.invert(); + int before = w.getI("Invert"); + Mapping s = c.simplify(); + String got = "before " + before + "\nclass " + s.astClass() + "\nafter " + w.getI("Invert") + "\n"; + assertEquals(probe("invert_attr_no_merge"), got); + } + + /** A DssMap has no constructor but the loader and the one its merge uses. */ + @Test + void noPublicConstructor() { + assertEquals(0, dss().getClass().getConstructors().length); + assertThrows(AstException.class, () -> dss("PltRA", null, null)); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/DssMergeOracleTest.java b/src/test/java/uk/ac/starlink/ast/DssMergeOracleTest.java new file mode 100644 index 0000000..dd66e26 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/DssMergeOracleTest.java @@ -0,0 +1,62 @@ +package uk.ac.starlink.ast; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +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_dss_merge_oracle.rs}: the plate centre of the DssMap a + * DssMap and a preceding WinMap merge into, bit for bit against C's. C rebuilds the merged DssMap + * from the FITS cards {@code astDssFits} writes (dssmap.c {@code MapMerge}), which hold the plate + * centre as sexagesimal hours or degrees, minutes and seconds, so the merged centre is the original + * after that round trip: a PltRA of 0.1 comes back as 0.09999999999999999. + * + *

The cases come from {@code oracle/dss_merge.json} (from {@code + * tools/oracle_fixtures/dss_merge_probe.c}), applied to the C fixture {@code + * simplify/dssmap_winmap_absorb.map} with its PltRA and PltDec replaced. + */ +class DssMergeOracleTest { + + /** {@code text} with the value of {@code key} (up to the tab before its comment) replaced by {@code value}. */ + private static String setValue(String text, String key, String value) { + int start = text.indexOf(key) + key.length(); + int end = text.indexOf('\t', start); + return text.substring(0, start) + value + " " + text.substring(end); + } + + private static double getValue(String dump, String key) { + int start = dump.indexOf(key) + key.length(); + int end = dump.indexOf(' ', start); + return Double.parseDouble(dump.substring(start, end)); + } + + @Test + void mergedPlateCentreMatchesTheCLibrary() { + String base = Fixtures.read("simplify/dssmap_winmap_absorb.map"); + for (JsonNode c : ProbeData.load("dss_merge").get("CASES")) { + String ra = c.get(0).asText(); + String dec = c.get(1).asText(); + String text = setValue(setValue(base, "PltRA = ", ra), "PltDec = ", dec); + Mapping map = (Mapping) ChannelText.read(text); + assertEquals("CmpMap", map.astClass()); + Mapping simp = map.simplify(); + assertEquals("DssMap", simp.astClass(), ra + " " + dec + " did not merge"); + String dump = ChannelText.dump(simp); + double gotRa = getValue(dump, "PltRA = "); + double gotDec = getValue(dump, "PltDec = "); + double wantRa = ProbeData.toDouble(c.get(2)); + double wantDec = ProbeData.toDouble(c.get(3)); + assertEquals( + Double.doubleToLongBits(wantRa), + Double.doubleToLongBits(gotRa), + ra + ": PltRA " + gotRa + ", C " + wantRa); + assertEquals( + Double.doubleToLongBits(wantDec), + Double.doubleToLongBits(gotDec), + dec + ": PltDec " + gotDec + ", C " + wantDec); + } + } +} diff --git a/src/test/java/uk/ac/starlink/ast/EqualTest.java b/src/test/java/uk/ac/starlink/ast/EqualTest.java new file mode 100644 index 0000000..df91634 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/EqualTest.java @@ -0,0 +1,956 @@ +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.assertNotEquals; +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.Fixtures; +import uk.ac.starlink.ast.testsupport.ProbeData; +import uk.ac.starlink.ast.testsupport.ProbeOutput; + +/** + * Translation of Rust {@code tests/test_equal.rs} and {@code tests/test_equal_oracle.rs} (C's + * {@code astEqual}, {@link AstObject#astEqual}), with the cases of the C probe {@code + * probes/equal_probe.c}, which also gives C's answer for every comparison the Rust tests make: each + * translated test compares its results with the probe's case of the Rust test's name. The probe's + * own cases are comparisons where C's {@code Equal} and a comparison of native text disagree, a CmpMap comparison + * 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}. The SelectorMap cases of {@code oracle/equal.json} are + * skipped: they need SelectorMap and Regions. + */ +class EqualTest { + + private static final double BAD = AstObject.AST__BAD; + + private static final Map PROBE_CASES = ProbeOutput.load("equal_probe"); + + private static String probe(String name) { + String text = PROBE_CASES.get(name); + if (text == null) { + throw new IllegalStateException("no probe case " + name); + } + return text; + } + + /** + * Asserts that the results of a sequence of comparisons are C's, as the probe's case {@code + * name} records them; a translated Rust test of that name makes the same comparisons. + */ + static void assertAsC(String name, boolean... results) { + assertEquals(probe(name), equalLines(results), name); + } + + /** The probe's lines for a sequence of comparisons. */ + private static String equalLines(boolean... results) { + StringBuilder sb = new StringBuilder(); + for (boolean r : results) { + sb.append("equal ").append(r ? 1 : 0).append('\n'); + } + return sb.toString(); + } + + private static T inv(T m) { + m.invert(); + return m; + } + + private static ZoomMap zoom(int n, double f) { + return new ZoomMap(n, f); + } + + private static ShiftMap shift(double... s) { + return new ShiftMap(s); + } + + private static PermMap perm1(int in, int out, double... con) { + return new PermMap(1, new int[] {in}, 1, new int[] {out}, con.length == 0 ? null : con); + } + + private static Frame frame(int naxes, String settings) { + Frame f = new Frame(naxes); + if (!settings.isEmpty()) { + f.set(settings); + } + return f; + } + + private static SkyFrame sky(String settings) { + SkyFrame f = new SkyFrame(); + f.set(settings); + return f; + } + + // ------------------------------------------------------------------ + // ast_equal tolerance behaviour (via ZoomMap as a vehicle) + // ------------------------------------------------------------------ + + @Test + void floatToleranceWithin() { + assertAsC("float_tolerance_within", zoom(2, 1.0).astEqual(zoom(2, 1.0 + 1.0e-14))); + } + + @Test + void floatToleranceOutside() { + assertAsC("float_tolerance_outside", zoom(2, 1.0).astEqual(zoom(2, 1.1))); + } + + @Test + void badValueComparison() { + assertAsC("bad_value_comparison", perm1(-1, -1, BAD).astEqual(perm1(-1, -1, BAD))); + } + + @Test + void badVsNonBadSameIndexIsNotEqual() { + assertAsC("bad_vs_non_bad_same_index_is_not_equal", perm1(-1, -1, BAD).astEqual(perm1(-1, -1, 42.0))); + } + + @Test + void badVsNonBadDifferentIndexIsNotEqual() { + assertAsC( + "bad_vs_non_bad_different_index_is_not_equal", + perm1(-1, -1, BAD, 0.0).astEqual(perm1(-2, -2, 0.0, 42.0))); + } + + // ------------------------------------------------------------------ + // UnitMap + // ------------------------------------------------------------------ + + @Test + void unitmapIdentity() { + UnitMap a = new UnitMap(3); + assertAsC("unitmap_identity", a.astEqual(a)); + } + + @Test + void unitmapSameNcoord() { + assertAsC("unitmap_same_ncoord", new UnitMap(3).astEqual(new UnitMap(3))); + } + + @Test + void unitmapDifferentNcoord() { + assertAsC("unitmap_different_ncoord", new UnitMap(3).astEqual(new UnitMap(2))); + } + + // ------------------------------------------------------------------ + // ZoomMap + // ------------------------------------------------------------------ + + @Test + void zoommapIdentity() { + ZoomMap a = zoom(2, 3.5); + assertAsC("zoommap_identity", a.astEqual(a)); + } + + @Test + void zoommapSameValues() { + assertAsC("zoommap_same_values", zoom(2, 3.5).astEqual(zoom(2, 3.5))); + } + + @Test + void zoommapDifferentFactor() { + assertAsC("zoommap_different_factor", zoom(2, 3.5).astEqual(zoom(2, 4.0))); + } + + @Test + void zoommapDifferentNcoord() { + assertAsC("zoommap_different_ncoord", zoom(2, 3.5).astEqual(zoom(3, 3.5))); + } + + @Test + void zoommapInvertAware() { + assertAsC("zoommap_invert_aware", inv(zoom(2, 2.0)).astEqual(zoom(2, 0.5))); + } + + @Test + void zoommapInvertAwareMismatch() { + assertAsC("zoommap_invert_aware_mismatch", inv(zoom(2, 3.0)).astEqual(zoom(2, 0.5))); + } + + // ------------------------------------------------------------------ + // ShiftMap + // ------------------------------------------------------------------ + + @Test + void shiftmapIdentity() { + ShiftMap a = shift(1.0, 2.0, 3.0); + assertAsC("shiftmap_identity", a.astEqual(a)); + } + + @Test + void shiftmapSameValues() { + assertAsC("shiftmap_same_values", shift(1.0, 2.0).astEqual(shift(1.0, 2.0))); + } + + @Test + void shiftmapDifferentShifts() { + assertAsC("shiftmap_different_shifts", shift(1.0, 2.0).astEqual(shift(1.0, 3.0))); + } + + @Test + void shiftmapDifferentLength() { + assertAsC("shiftmap_different_length", shift(1.0, 2.0).astEqual(shift(1.0, 2.0, 3.0))); + } + + @Test + void shiftmapInvertAware() { + assertAsC("shiftmap_invert_aware", inv(shift(1.0, 2.0)).astEqual(shift(-1.0, -2.0))); + } + + @Test + void shiftmapInvertAwareMismatch() { + assertAsC("shiftmap_invert_aware_mismatch", inv(shift(1.0, 2.0)).astEqual(shift(1.0, 2.0))); + } + + // ------------------------------------------------------------------ + // MatrixMap + // ------------------------------------------------------------------ + + /** A MatrixMap of the full matrix given as rows. */ + private static MatrixMap full(double[]... rows) { + return new MatrixMap(rows[0].length, rows.length, rows); + } + + @Test + void matrixmapSame() { + assertAsC( + "matrixmap_same", + full(new double[] {2.0, 0.0}, new double[] {0.0, 3.0}) + .astEqual(full(new double[] {2.0, 0.0}, new double[] {0.0, 3.0}))); + } + + @Test + void matrixmapDifferentElement() { + assertAsC( + "matrixmap_different_element", + full(new double[] {2.0, 0.0}, new double[] {0.0, 3.0}) + .astEqual(full(new double[] {2.0, 0.0}, new double[] {0.0, 4.0}))); + } + + @Test + void matrixmapInvertedNotEqual() { + MatrixMap a = inv(full(new double[] {2.0, 0.0}, new double[] {0.0, 3.0})); + assertAsC("matrixmap_inverted_not_equal", a.astEqual(full(new double[] {2.0, 0.0}, new double[] {0.0, 3.0}))); + } + + // ------------------------------------------------------------------ + // PermMap + // ------------------------------------------------------------------ + + @Test + void permmapSame() { + PermMap a = new PermMap(2, new int[] {1, 2}, 2, new int[] {2, 1}, null); + PermMap b = new PermMap(2, new int[] {1, 2}, 2, new int[] {2, 1}, null); + assertAsC("permmap_same", a.astEqual(b)); + } + + @Test + void permmapDifferentPerm() { + PermMap a = new PermMap(2, new int[] {1, 2}, 2, new int[] {2, 1}, null); + PermMap b = new PermMap(2, new int[] {1, 2}, 2, new int[] {1, 2}, null); + assertAsC("permmap_different_perm", a.astEqual(b)); + } + + @Test + void permmapEqualCrossInversion() { + PermMap pm1 = new PermMap(2, new int[] {2, 1}, 2, new int[] {2, 1}, null); + PermMap pm2 = inv(new PermMap(2, new int[] {2, 1}, 2, new int[] {2, 1}, null)); + boolean r1 = pm1.astEqual(pm2); + PermMap pm3 = new PermMap(3, new int[] {2, 3, 1}, 3, new int[] {3, 1, 2}, null); + PermMap pm3Inv = inv((PermMap) pm3.copy()); + PermMap pm4 = new PermMap(3, new int[] {3, 1, 2}, 3, new int[] {2, 3, 1}, null); + boolean r2 = pm3Inv.astEqual(pm4); + assertAsC("permmap_equal_cross_inversion", r1, r2); + } + + // ------------------------------------------------------------------ + // WinMap + // ------------------------------------------------------------------ + + private static WinMap win(double[] shifts, double[] scales) { + return new WinMap(shifts, scales); + } + + @Test + void winmapSame() { + assertAsC( + "winmap_same", + win(new double[] {1.0, 2.0}, new double[] {3.0, 4.0}) + .astEqual(win(new double[] {1.0, 2.0}, new double[] {3.0, 4.0}))); + } + + @Test + void winmapDifferentScale() { + assertAsC( + "winmap_different_scale", + win(new double[] {1.0, 2.0}, new double[] {3.0, 4.0}) + .astEqual(win(new double[] {1.0, 2.0}, new double[] {3.0, 5.0}))); + } + + @Test + void winmapInvertedNotEqual() { + WinMap a = inv(win(new double[] {1.0, 2.0}, new double[] {3.0, 4.0})); + assertAsC("winmap_inverted_not_equal", a.astEqual(win(new double[] {1.0, 2.0}, new double[] {3.0, 4.0}))); + } + + @Test + void winmapEqualCrossInversion() { + WinMap wm1Inv = inv(win(new double[] {2.0}, new double[] {3.0})); + WinMap wm2 = win(new double[] {-2.0 / 3.0}, new double[] {1.0 / 3.0}); + assertAsC("winmap_equal_cross_inversion", wm1Inv.astEqual(wm2)); + } + + // ------------------------------------------------------------------ + // CmpMap (recursive) + // ------------------------------------------------------------------ + + @Test + void cmpmapSeriesSame() { + CmpMap a = new CmpMap(zoom(2, 3.0), shift(1.0, 2.0), true); + CmpMap b = new CmpMap(zoom(2, 3.0), shift(1.0, 2.0), true); + assertAsC("cmpmap_series_same", a.astEqual(b)); + } + + @Test + void cmpmapDifferentComponent() { + CmpMap a = new CmpMap(zoom(2, 3.0), shift(1.0, 2.0), true); + CmpMap b = new CmpMap(zoom(2, 4.0), shift(1.0, 2.0), true); + assertAsC("cmpmap_different_component", a.astEqual(b)); + } + + @Test + void cmpmapDifferentKind() { + CmpMap a = new CmpMap(new UnitMap(2), new UnitMap(2), true); + CmpMap b = new CmpMap(new UnitMap(2), new UnitMap(2), false); + assertAsC("cmpmap_different_kind", a.astEqual(b)); + } + + // ------------------------------------------------------------------ + // PolyMap + // ------------------------------------------------------------------ + + @Test + void polymapSame() { + double[] coeffs = {2.0, 1.0, 1.0, 0.0, 3.0, 2.0, 0.0, 1.0}; + PolyMap a = new PolyMap(2, 2, 2, coeffs, 0, null); + PolyMap b = new PolyMap(2, 2, 2, coeffs, 0, null); + assertAsC("polymap_same", a.astEqual(b)); + } + + @Test + void polymapDifferentCoeff() { + PolyMap a = new PolyMap(1, 1, 1, new double[] {2.0, 1.0, 1.0}, 0, null); + PolyMap b = new PolyMap(1, 1, 1, new double[] {3.0, 1.0, 1.0}, 0, null); + assertAsC("polymap_different_coeff", a.astEqual(b)); + } + + // ------------------------------------------------------------------ + // LutMap + // ------------------------------------------------------------------ + + @Test + void lutmapSame() { + LutMap a = new LutMap(new double[] {0.0, 1.0, 4.0, 9.0}, 0.0, 1.0); + LutMap b = new LutMap(new double[] {0.0, 1.0, 4.0, 9.0}, 0.0, 1.0); + assertAsC("lutmap_same", a.astEqual(b)); + } + + @Test + void lutmapDifferentValues() { + LutMap a = new LutMap(new double[] {0.0, 1.0, 4.0, 9.0}, 0.0, 1.0); + LutMap b = new LutMap(new double[] {0.0, 1.0, 4.0, 16.0}, 0.0, 1.0); + assertAsC("lutmap_different_values", a.astEqual(b)); + } + + @Test + void lutmapDifferentStart() { + LutMap a = new LutMap(new double[] {0.0, 1.0}, 0.0, 1.0); + LutMap b = new LutMap(new double[] {0.0, 1.0}, 1.0, 1.0); + assertAsC("lutmap_different_start", a.astEqual(b)); + } + + // ------------------------------------------------------------------ + // WcsMap + // ------------------------------------------------------------------ + + @Test + void wcsmapSame() { + assertAsC("wcsmap_same", new WcsMap(2, WcsMap.AST__TAN, 1, 2).astEqual(new WcsMap(2, WcsMap.AST__TAN, 1, 2))); + } + + @Test + void wcsmapDifferentProj() { + assertAsC( + "wcsmap_different_proj", + new WcsMap(2, WcsMap.AST__TAN, 1, 2).astEqual(new WcsMap(2, WcsMap.AST__SIN, 1, 2))); + } + + @Test + void wcsmapDifferentAxes() { + assertAsC( + "wcsmap_different_axes", + new WcsMap(3, WcsMap.AST__TAN, 1, 2).astEqual(new WcsMap(3, WcsMap.AST__TAN, 1, 3))); + } + + // ------------------------------------------------------------------ + // SlaMap + // ------------------------------------------------------------------ + + private static SlaMap sla(String cvt, double... args) { + SlaMap m = new SlaMap(); + m.add(cvt, args); + return m; + } + + @Test + void slamapSame() { + assertAsC("slamap_same", sla("EQGAL").astEqual(sla("EQGAL"))); + } + + @Test + void slamapDifferentType() { + assertAsC("slamap_different_type", sla("EQGAL").astEqual(sla("GALEQ"))); + } + + @Test + void slamapDifferentArgs() { + assertAsC("slamap_different_args", sla("PREC", 50000.0, 51000.0).astEqual(sla("PREC", 50000.0, 52000.0))); + } + + // ------------------------------------------------------------------ + // SphMap + // ------------------------------------------------------------------ + + @Test + void sphmapSame() { + assertAsC("sphmap_same", new SphMap().astEqual(new SphMap())); + } + + @Test + void sphmapDifferentPolarLong() { + SphMap a = new SphMap(); + a.setPolarLong(1.5); + assertAsC("sphmap_different_polar_long", a.astEqual(new SphMap())); + } + + @Test + void sphmapDifferentUnitRadius() { + SphMap a = new SphMap(); + a.setUnitRadius(true); + assertAsC("sphmap_different_unit_radius", a.astEqual(new SphMap())); + } + + @Test + void sphmapInverted() { + assertAsC("sphmap_inverted", inv(new SphMap()).astEqual(new SphMap())); + } + + @Test + void cmpmapEqualDifferentTreeStructure() { + ShiftMap a = shift(1.0, 2.0); + ZoomMap b = zoom(2, 3.0); + ShiftMap c = shift(4.0, 5.0); + CmpMap bc = new CmpMap((Mapping) b.copy(), (Mapping) c.copy(), true); + CmpMap abc1 = new CmpMap((Mapping) a.copy(), bc, true); + CmpMap ab = new CmpMap((Mapping) a.copy(), (Mapping) b.copy(), true); + CmpMap abc2 = new CmpMap(ab, (Mapping) c.copy(), true); + assertAsC("cmpmap_equal_different_tree_structure", abc1.astEqual(abc2)); + } + + // ------------------------------------------------------------------ + // Cross-type rejection + // ------------------------------------------------------------------ + + @Test + void crossTypeZoomVsShift() { + assertAsC("cross_type_zoom_vs_shift", zoom(2, 1.0).astEqual(shift(0.0, 0.0))); + } + + @Test + void crossTypeUnitVsZoom() { + assertAsC("cross_type_unit_vs_zoom", new UnitMap(2).astEqual(zoom(2, 1.0))); + } + + @Test + void crossTypeWinmapVsShiftmap() { + assertAsC( + "cross_type_winmap_vs_shiftmap", + win(new double[] {0.0}, new double[] {1.0}).astEqual(shift(0.0))); + } + + // ------------------------------------------------------------------ + // Frame + // ------------------------------------------------------------------ + + @Test + void basicframeSame() { + assertAsC("basicframe_same", frame(2, "Title=test,Domain=PIXEL").astEqual(frame(2, "Title=test,Domain=PIXEL"))); + } + + @Test + void basicframeDifferentNaxes() { + assertAsC("basicframe_different_naxes", frame(2, "").astEqual(frame(3, ""))); + } + + @Test + void basicframeDifferentTitleIsEqual() { + assertAsC("basicframe_different_title_is_equal", frame(2, "Title=A").astEqual(frame(2, "Title=B"))); + } + + @Test + void basicframeDifferentDomain() { + assertAsC("basicframe_different_domain", frame(2, "Domain=X").astEqual(frame(2, "Domain=Y"))); + } + + @Test + void basicframeDifferentEpochIsEqual() { + assertAsC( + "basicframe_different_epoch_is_equal", + frame(2, "Epoch=MJD 50000").astEqual(frame(2, "Epoch=MJD 51000"))); + } + + @Test + void basicframeEpochSetVsUnsetIsEqual() { + assertAsC( + "basicframe_epoch_set_vs_unset_is_equal", + frame(2, "Epoch=MJD 50000").astEqual(frame(2, ""))); + } + + @Test + void basicframeDifferentLabelsIsEqual() { + assertAsC("basicframe_different_labels_is_equal", frame(2, "Label(1)=X").astEqual(frame(2, "Label(1)=Y"))); + } + + // ------------------------------------------------------------------ + // CmpFrame + // ------------------------------------------------------------------ + + @Test + void cmpframeSame() { + CmpFrame a = new CmpFrame(frame(1, ""), frame(1, "")); + CmpFrame b = new CmpFrame(frame(1, ""), frame(1, "")); + assertAsC("cmpframe_same", a.astEqual(b)); + } + + @Test + void cmpframeDifferentChild() { + CmpFrame a = new CmpFrame(frame(1, "Domain=A"), frame(1, "")); + CmpFrame b = new CmpFrame(frame(1, "Domain=B"), frame(1, "")); + assertAsC("cmpframe_different_child", a.astEqual(b)); + } + + // ------------------------------------------------------------------ + // SkyFrame + // ------------------------------------------------------------------ + + @Test + void skyframeSame() { + assertAsC("skyframe_same", sky("System=FK5").astEqual(sky("System=FK5"))); + } + + @Test + void skyframeDifferentSystem() { + assertAsC("skyframe_different_system", sky("System=FK5").astEqual(sky("System=Galactic"))); + } + + @Test + void skyframeDifferentEquinox() { + assertAsC( + "skyframe_different_equinox", + sky("System=FK5,Equinox=MJD 50000").astEqual(sky("System=FK5,Equinox=MJD 51000"))); + } + + @Test + void skyframeEquinoxSetVsUnsetDefaultIsEqual() { + assertAsC( + "skyframe_equinox_set_vs_unset_default_is_equal", + sky("System=FK5,Equinox=MJD 51544.5").astEqual(sky("System=FK5"))); + } + + @Test + void skyframeDifferentEpoch() { + assertAsC( + "skyframe_different_epoch", + sky("System=FK5,Epoch=MJD 50000").astEqual(sky("System=FK5,Epoch=MJD 51000"))); + } + + @Test + void skyframeSkyRefIsOriginWithoutSkyRefIsEqual() { + assertAsC( + "skyframe_sky_ref_is_origin_without_sky_ref_is_equal", + sky("System=FK5,SkyRefIs=Origin").astEqual(sky("System=FK5"))); + } + + @Test + void skyframeOffsetOriginWithSkyRefIsNotEqual() { + SkyFrame a = sky("System=FK5,SkyRefIs=Origin"); + a.setD("SkyRef(1)", 1.0); + a.setD("SkyRef(2)", 0.5); + assertAsC("skyframe_offset_origin_with_sky_ref_is_not_equal", a.astEqual(sky("System=FK5"))); + } + + @Test + void skyframeSkyRefWithoutSkyRefIsIsEqual() { + SkyFrame a = sky("System=FK5"); + a.setD("SkyRef(1)", 1.0); + a.setD("SkyRef(2)", 0.5); + assertAsC("skyframe_sky_ref_without_sky_ref_is_is_equal", a.astEqual(sky("System=FK5"))); + } + + @Test + void skyframeDifferentNeglonIsEqual() { + assertAsC( + "skyframe_different_neglon_is_equal", sky("System=FK5,NegLon=1").astEqual(sky("System=FK5"))); + } + + @Test + void skyframeDifferentTitleIsEqual() { + assertAsC("skyframe_different_title_is_equal", sky("System=FK5,Title=A").astEqual(sky("System=FK5,Title=B"))); + } + + @Test + void crossTypeSkyframeVsBasicframe() { + assertAsC("cross_type_skyframe_vs_basicframe", sky("System=FK5").astEqual(frame(2, ""))); + } + + @Test + void crossTypeBasicframeVsSkyframe() { + assertAsC("cross_type_basicframe_vs_skyframe", frame(2, "").astEqual(sky("System=FK5"))); + } + + // ------------------------------------------------------------------ + // FrameSet + // ------------------------------------------------------------------ + + private static FrameSet frameSet(double zoom, String currentSettings) { + FrameSet fs = new FrameSet(frame(2, "")); + fs.addFrame(FrameSet.AST__BASE, zoom(2, zoom), frame(2, currentSettings)); + return fs; + } + + /** Rust compares the FrameSets as Frames and as Mappings; C has one {@code astEqual}. */ + @Test + void framesetSame() { + assertAsC("frameset_same", frameSet(2.0, "Title=current").astEqual(frameSet(2.0, "Title=current"))); + } + + @Test + void framesetDifferentMapping() { + assertAsC("frameset_different_mapping", frameSet(2.0, "").astEqual(frameSet(3.0, ""))); + } + + // ------------------------------------------------------------------ + // Serialisation round trip preserves equality + // ------------------------------------------------------------------ + + private static AstObject roundTrip(AstObject obj) { + return ChannelText.read(ChannelText.dump(obj)); + } + + @Test + void serialiseRoundTripZoommap() { + ZoomMap original = zoom(2, 3.14159); + assertAsC("serialise_round_trip_zoommap", original.astEqual(roundTrip(original))); + } + + @Test + void serialiseRoundTripShiftmap() { + ShiftMap original = shift(1.5, -2.7, 0.001); + assertAsC("serialise_round_trip_shiftmap", original.astEqual(roundTrip(original))); + } + + @Test + void serialiseRoundTripSkyframe() { + SkyFrame original = sky("System=FK5,Epoch=MJD 52000,Equinox=MJD 51544.5,NegLon=1,Title=Test Sky"); + assertAsC("serialise_round_trip_skyframe", original.astEqual(roundTrip(original))); + } + + // ------------------------------------------------------------------ + // MatrixMap equality with inversion and storage normalisation + // ------------------------------------------------------------------ + + @Test + void matrixmapEqualCrossInversion() { + MatrixMap mmInv = inv(full(new double[] {1.0, 2.0}, new double[] {3.0, 4.0})); + MatrixMap mmDirect = full(new double[] {-2.0, 1.0}, new double[] {1.5, -0.5}); + boolean r1 = mmInv.astEqual(mmDirect); + MatrixMap mmFwd = full(new double[] {1.0, 2.0}, new double[] {3.0, 4.0}); + boolean r2 = mmFwd.astEqual(mmInv); + assertAsC("matrixmap_equal_cross_inversion", r1, r2); + } + + // ------------------------------------------------------------------ + // tests/test_equal_oracle.rs + // ------------------------------------------------------------------ + + private static WinMap winCorners(double ina, double inb, double outa, double outb) { + return new WinMap(1, new double[] {ina}, new double[] {inb}, new double[] {outa}, new double[] {outb}); + } + + private static WcsMap sinPv(double... pv) { + WcsMap w = new WcsMap(2, WcsMap.AST__SIN, 1, 2); + for (int i = 0; i < pv.length; i++) { + w.setD("PV2_" + (i + 1), pv[i]); + } + return w; + } + + /** The two Mappings an oracle case compares, or null for a case that needs SelectorMap. */ + private static Mapping[] pair(String name) { + switch (name) { + case "winmap_self_inverse_vs_inverted_copy": { + WinMap a = winCorners(0.0, 1.0, 0.0, -1.0); + return new Mapping[] {a, inv((WinMap) a.copy())}; + } + case "winmap_inverse_of_its_inverse": + return new Mapping[] {winCorners(0.0, 1.0, 1.0, 3.0), inv(winCorners(0.0, 2.0, -0.5, 0.5))}; + case "selectormap_one_region_vs_two": + case "selectormap_vs_inverted_copy": + case "selectormap_1d_vs_inverted_copy": + return null; + case "tranmap_vs_reread_without_component_invert": { + TranMap tm = new TranMap(inv(zoom(1, 2.0)), zoom(1, 0.5)); + String dump = ChannelText.dump(tm); + assertTrue(dump.contains("InvA = 1")); + StringBuilder edited = new StringBuilder(); + boolean dropped = false; + for (String line : dump.split("\n", -1)) { + if (!dropped && line.contains(" Invert = 1")) { + dropped = true; + continue; + } + edited.append(line).append('\n'); + } + return new Mapping[] {tm, (Mapping) ChannelText.read(edited.toString())}; + } + case "wcsmap_pv_vs_none": + return new Mapping[] {sinPv(0.5), sinPv()}; + case "wcsmap_zero_pv_vs_none": + return new Mapping[] {sinPv(0.0), sinPv()}; + case "wcsmap_pv_vs_pv_with_one_cleared": { + WcsMap b = sinPv(0.5, 1.0); + b.clear("PV2_2"); + return new Mapping[] {sinPv(0.5), b}; + } + case "wcsmap_same_pv": + return new Mapping[] {sinPv(0.5), sinPv(0.5)}; + default: + throw new IllegalStateException("no construction for case " + name); + } + } + + @Test + void equalityMatchesTheCLibrary() { + List failures = new ArrayList<>(); + int run = 0; + for (JsonNode c : ProbeData.load("equal").get("CASES")) { + String name = c.get(0).asText(); + Mapping[] p = pair(name); + if (p == null) { + continue; + } + boolean got = p[0].astEqual(p[1]); + if (got != c.get(1).asBoolean()) { + failures.add(name + ": " + got + ", C " + c.get(1).asBoolean()); + } + run++; + } + assertEquals(7, run, "the in-scope cases the C probe recorded"); + assertTrue(failures.isEmpty(), String.join("\n", failures)); + } + + /** testmapping.c {@code testwcsmapequal} asserts cases 1 and 3 in both directions. */ + @Test + void wcsmapEqualityIsSymmetricWhereCChecksIt() { + for (String name : new String[] {"wcsmap_pv_vs_none", "wcsmap_pv_vs_pv_with_one_cleared"}) { + boolean want = false; + for (JsonNode c : ProbeData.load("equal").get("CASES")) { + if (c.get(0).asText().equals(name)) { + want = c.get(1).asBoolean(); + } + } + Mapping[] p = pair(name); + assertEquals(want, p[1].astEqual(p[0]), name + ", reversed"); + } + } + + // ------------------------------------------------------------------ + // The C probe: where C's Equal and a comparison of text disagree + // ------------------------------------------------------------------ + + /** An inverted ZoomMap equals one of the reciprocal factor, though they are written differently. */ + @Test + void anInvertedZoommapEqualsTheReciprocalAsC() { + ZoomMap a = inv(zoom(1, 2.0)); + ZoomMap b = zoom(1, 0.5); + assertNotEquals(a, b); + assertEquals(probe("zoommap_inverted_vs_reciprocal"), equalLines(a.astEqual(b))); + } + + /** ID and Ident play no part in a comparison. */ + @Test + void identifiersAreIgnoredAsC() { + ZoomMap a = zoom(1, 2.0); + ZoomMap b = zoom(1, 2.0); + a.setID("a"); + b.setID("b"); + assertNotEquals(a, b); + assertEquals(probe("differing_id"), equalLines(a.astEqual(b))); + a = zoom(1, 2.0); + b = zoom(1, 2.0); + a.setIdent("a"); + b.setIdent("b"); + assertNotEquals(a, b); + assertEquals(probe("differing_ident"), equalLines(a.astEqual(b))); + } + + private static MathMap mathmap(String f, String i) { + return new MathMap(1, 1, new String[] {f}, new String[] {i}); + } + + /** C's MathMap comparison never compares the last opcode of a function. */ + @Test + void mathmapsDifferingInTheirLastOpcodeAreEqualAsC() { + assertEquals( + probe("mathmap_last_opcode"), + equalLines( + mathmap("y = x + 1", "x = y - 1").astEqual(mathmap("y = x - 1", "x = y + 1")), + mathmap("y = x * 2", "x = y / 2").astEqual(mathmap("y = x / 2", "x = y * 2")), + mathmap("y = x + 1", "x = y - 1").astEqual(mathmap("y = x + 2", "x = y - 2")))); + } + + /** + * Comparing two CmpMaps that share a component, recorded with different Invert values, leaves + * the component with the Invert value of the first CmpMap's record (cmpmap.c {@code Equal}). + */ + @Test + void comparingCmpmapsWithASharedComponentSetsItsInvertAsC() { + ZoomMap z = zoom(1, 2.0); + UnitMap u = new UnitMap(1); + CmpMap a = new CmpMap(z, u, true); + z.invert(); + CmpMap b = new CmpMap(z, u, true); + String before = invertLine("invert before", z); + String first = equalLines(a.astEqual(b)); + String after = invertLine("invert after", z); + String second = equalLines(b.astEqual(a)); + String afterReverse = invertLine("invert after reverse", z); + assertEquals(probe("cmpmap_shared_component"), before + first + after + second + afterReverse); + } + + private static String invertLine(String what, Mapping m) { + return what + " " + (m.getInvert() ? 1 : 0) + " set " + (m.testInvert() ? 1 : 0) + "\n"; + } + + /** + * Simplifying {@code simplify/brad.map} compares CmpMaps that share its WcsMap, recorded not + * inverted, whose Invert attribute is 1; the comparison leaves the WcsMap with the recorded + * value, so the Mapping read and its simplification both hold it not inverted, as in C (probe + * {@code probes/simplify_input_probe.c}). + */ + @Test + void simplifyingBradChangesItsSharedWcsmapAsC() { + Map c = ProbeOutput.load("simplify_input_probe"); + Mapping m = (Mapping) ChannelText.read(Fixtures.read("simplify/brad.map")); + assertEquals(c.get("brad/input_before"), ChannelText.dump(m)); + Mapping s = m.simplify(); + assertEquals(c.get("brad/simplified"), ChannelText.dump(s)); + assertEquals(c.get("brad/input_after"), ChannelText.dump(m)); + } + + /** CmpMaps with Ident set are compared through copies of their components. */ + @Test + void cmpmapsWithIdentAreComparedAsC() { + UnitMap u = new UnitMap(1); + StringBuilder sb = new StringBuilder(); + sb.append(equalLines( + ident(new CmpMap(zoom(1, 2.0), u, true), "a").astEqual(ident(new CmpMap(zoom(1, 2.0), u, true), "b")), + ident(new CmpMap(zoom(1, 2.0), u, true), "a").astEqual(ident(new CmpMap(zoom(1, 3.0), u, true), "b")), + ident(new CmpMap(zoom(1, 2.0), u, true), "a").astEqual(new CmpMap(zoom(1, 2.0), u, true)))); + ZoomMap z = zoom(1, 2.0); + CmpMap a = ident(new CmpMap(z, u, true), "a"); + z.invert(); + CmpMap b = ident(new CmpMap(z, u, true), "b"); + sb.append(equalLines(a.astEqual(b))) + .append(invertLine("invert after", z)) + .append(equalLines(inv(ident(new CmpMap(zoom(1, 2.0), zoom(1, 3.0), true), "a")) + .astEqual(ident(new CmpMap(zoom(1, 1.0 / 3.0), zoom(1, 0.5), true), "b")))); + assertEquals(probe("cmpmap_ident"), sb.toString()); + } + + private static CmpMap ident(CmpMap m, String ident) { + m.setIdent(ident); + return m; + } + + /** FrameSets compare their Frames by conversion, so Titles play no part. */ + @Test + void framesetsWhoseFramesDifferInTitleAreEqualAsC() { + FrameSet a = new FrameSet(frame(2, "Title=A")); + a.addFrame(FrameSet.AST__BASE, zoom(2, 2.0), frame(2, "Title=B")); + FrameSet b = new FrameSet(frame(2, "Title=C")); + b.addFrame(FrameSet.AST__BASE, zoom(2, 2.0), frame(2, "Title=D")); + String first = equalLines(a.astEqual(b)); + b.setCurrent(1); + assertEquals( + probe("frameset_frames_differ_in_title"), + first + + equalLines( + a.astEqual(b), + a.astEqual(frame(2, "")), + frame(2, "").astEqual(a))); + } + + /** + * C compares ZoomMaps' factors as stored, zero once the Zoom attribute is cleared, so a ZoomMap + * whose Zoom is cleared, though its factor is 1, does not equal a ZoomMap of factor 1; against + * an inverted ZoomMap the reciprocal of zero is infinite, which {@code astEQUAL} finds equal to + * anything. + */ + @Test + void zoommapsCompareTheirStoredFactorsAsC() { + ZoomMap a = zoom(1, 2.0); + a.clear("Zoom"); + ZoomMap b = zoom(1, 2.0); + b.clear("Zoom"); + assertEquals( + probe("zoommap_cleared_zoom"), + equalLines( + a.astEqual(zoom(1, 1.0)), + zoom(1, 1.0).astEqual(a), + a.astEqual(inv(b)), + zoom(1, 3.0).astEqual(inv((ZoomMap) a.copy())))); + } + + /** frameset.c {@code Equal} does not compare the FrameSets' Invert attributes. */ + @Test + void anInvertedFramesetEqualsItsOriginalAsC() { + FrameSet a = frameSet(2.0, ""); + assertEquals(probe("frameset_inverted"), equalLines(a.astEqual(inv((FrameSet) a.copy())))); + } + + /** Objects of a class without its own {@code Equal} are equal when they are of the same class. */ + @Test + void objectsOfTheSameClassAreEqualAsC() { + KeyMap k1 = new KeyMap(); + KeyMap k2 = new KeyMap(); + String first = equalLines(new KeyMap().astEqual(new KeyMap())); + k1.mapPut0I("A", 1, null); + k2.mapPut0I("B", 2, null); + assertEquals(probe("object_classes"), first + equalLines(k1.astEqual(k2), k1.astEqual(zoom(1, 1.0)))); + } + + /** A Mapping is not equal to a missing Object (object.c {@code astEqual_}). */ + @Test + void nothingIsEqualToNull() { + assertFalse(zoom(1, 1.0).astEqual(null)); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/FitsChanAltEpochOracleTest.java b/src/test/java/uk/ac/starlink/ast/FitsChanAltEpochOracleTest.java index 6b7a12c..7ba0cbc 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsChanAltEpochOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsChanAltEpochOracleTest.java @@ -23,14 +23,9 @@ * write returns and the cards written. The cases are those of {@code * oracle/fitschan_alt_epoch.json}, made by {@code tools/oracle_fixtures/fitschan_alt_epoch_probe.c}. * - *

The cases that remap the alternate Frame with a MathMap, which this library does not have, - * do not run; their number is pinned. */ class FitsChanAltEpochOracleTest { - /** The number of cases that remap the alternate Frame with a MathMap. */ - private static final int NEED_MATHMAP = 3; - private static final String[] HEADER = { "NAXIS = 2", "NAXIS1 = 100", @@ -59,7 +54,7 @@ class FitsChanAltEpochOracleTest { * The value the write returns and the cards written. {@code prim} and {@code alt} are the MJD * epochs set on the primary and alternate Frames, or 0 for none. */ - private static List written(String mjdobs, double prim, double alt) { + private static List written(String mjdobs, double prim, double alt, boolean fail) { FitsChan fc = new FitsChan(); for (String card : HEADER) { fc.putFits(card, false); @@ -77,6 +72,10 @@ private static List written(String mjdobs, double prim, double alt) { if (alt != 0.0) { fs.setEpoch(String.format(java.util.Locale.ROOT, "MJD %.1f", alt)); } + if (fail) { + fs.remapFrame( + 3, new MathMap(2, 2, new String[] {"x=a+100*b*b", "y=b"}, new String[] {"a=x-100*y*y", "b=y"})); + } fs.setCurrent(2); FitsChan out = new FitsChan(); out.setEncoding("FITS-WCS"); @@ -96,23 +95,23 @@ private static FitsChan rewound(FitsChan fc) { @Test void datesMatchC() { List failed = new ArrayList<>(); - int needMathMap = 0; + int remapped = 0; for (JsonNode c : ProbeData.load("fitschan_alt_epoch").get("CASES")) { String name = c.get(0).asText(); - if (c.get(4).asBoolean()) { - needMathMap++; - continue; + boolean fail = c.get(4).asBoolean(); + if (fail) { + remapped++; } List want = new ArrayList<>(); want.add("wrote " + c.get(5).asInt()); want.addAll(FitsHeaders.strings(c.get(6))); List got = - written(c.get(1).asText(), c.get(2).asDouble(), c.get(3).asDouble()); + written(c.get(1).asText(), c.get(2).asDouble(), c.get(3).asDouble(), fail); if (!FitsHeaders.cardsMatchC(got, want)) { failed.add(name + ":\n--- Java\n" + String.join("\n", got) + "\n--- C\n" + String.join("\n", want)); } } assertTrue(failed.isEmpty(), String.join("\n", failed)); - assertEquals(NEED_MATHMAP, needMathMap, "cases that need MathMap"); + assertEquals(3, remapped, "cases that remap the alternate Frame with a MathMap"); } } diff --git a/src/test/java/uk/ac/starlink/ast/FitsChanAxisCountOracleTest.java b/src/test/java/uk/ac/starlink/ast/FitsChanAxisCountOracleTest.java index acc0eb4..e375c8c 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsChanAxisCountOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsChanAxisCountOracleTest.java @@ -7,8 +7,8 @@ import com.fasterxml.jackson.databind.JsonNode; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -29,19 +29,13 @@ * gives a FrameSet, nothing or an error, Ncard after the read, the names of the cards left, the * number of axes of each Frame, and the current Frame's position for pixel (2, 3, 4, ...). * - *

The case in {@link #EXCLUDED} has a {@code -LOG} spectral axis, which C maps with a MathMap; - * it must still stop there. + *

A case that needs a class this library lacks would be listed in {@link #EXCLUDED}, and must + * still stop there; none does. */ class FitsChanAxisCountOracleTest { /** The cases that cannot be read, with the reason the read gives. */ - private static final Map EXCLUDED = exclusions(); - - private static Map exclusions() { - Map m = new LinkedHashMap<>(); - m.put("spec_log", "needs MathMap"); - return m; - } + private static final Map EXCLUDED = Collections.emptyMap(); /** What the port gives for {@code header}, in the form C's transcript is compared in. */ private static String read(String[] header) { diff --git a/src/test/java/uk/ac/starlink/ast/FitsChanCInlineTest.java b/src/test/java/uk/ac/starlink/ast/FitsChanCInlineTest.java index e84a6e4..5f0b952 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsChanCInlineTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsChanCInlineTest.java @@ -27,8 +27,7 @@ * C probe of the pinned library gives ({@code c1.c} beside the task report): where C's test accepts * either of two outcomes, the one C gives. * - *

Listed in {@code deferred/rust-tests.txt}: {@code log_spectral_axis_writes_freq_log}, whose - * FrameSet is built with a MathMap, and {@code show_fits_succeeds} (jniast has no {@code + *

Listed in {@code deferred/rust-tests.txt}: {@code show_fits_succeeds} (jniast has no {@code * showFits}). */ class FitsChanCInlineTest { @@ -618,6 +617,38 @@ void skySystemsThroughFiveEncodings() { } } + /** + * 680-683: a frequency axis exponential in the pixel axis, made with a MathMap, writes as + * {@code FREQ-LOG} and reads back to a FrameSet that transforms as the original. + */ + @Test + void logSpectralAxisWritesFreqLog() { + MathMap logmap = new MathMap( + 1, 1, new String[] {"s = 1.4204e9 * exp( p * 1.0e-4 )"}, new String[] {"p = 1.0e4 * log( s / 1.4204e9 )" + }); + SpecFrame spec = new SpecFrame(); + spec.setC("System", "FREQ"); + spec.setUnit(1, "Hz"); + spec.setC("StdOfRest", "Barycentric"); + spec.setD("RestFreq", 1.4204e9); + Frame pixel = new Frame(1); + pixel.setDomain("GRID"); + FrameSet fs = new FrameSet(pixel); + fs.addFrame(FrameSet.AST__BASE, logmap, spec); + + FitsChan fc = new FitsChan(); + fc.setEncoding("FITS-WCS"); + put(fc, "NAXIS = 1", "NAXIS1 = 1024"); + assertEquals(1, fc.write(fs), "Error 680"); + fc.clear("Card"); + assertEquals("FREQ-LOG", fc.getFitsS("CTYPE1"), "Error 681-682"); + fc.clear("Card"); + FrameSet fs2 = FitsHeaders.readFrameSet(fc); + double a = fs.tran1(1, new double[] {512.0}, true)[0]; + double b = fs2.tran1(1, new double[] {512.0}, true)[0]; + assertTrue(Math.abs(a - b) <= Math.abs(1e-6 * a), "Error 683: " + a + " vs " + b); + } + /** * 650-659 (DATE-OBS block): an FK5 header with MJD-OBS and OBSGEO writes them back as FITS-WCS * within 1e-3 days and 1 m, as the cards C writes. diff --git a/src/test/java/uk/ac/starlink/ast/FitsChanCursorOracleTest.java b/src/test/java/uk/ac/starlink/ast/FitsChanCursorOracleTest.java index 6d3a302..1827b3b 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsChanCursorOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsChanCursorOracleTest.java @@ -38,7 +38,7 @@ *

Cases whose scripts read from the FitsChan ({@code R}, {@code RN}, {@code PW}, and {@code * RW}, {@code RCIW} and {@code RSW}, which write what they read back into it) run when their reads * and writes need only the classes of this library. A read or write that stops at an out-of-scope - * class (such as {@code needs MathMap}) must be in {@link #EXCLUDED} with that reason, measured + * class (such as {@code needs FitsTable}) must be in {@link #EXCLUDED} with that reason, measured * from the exception. Cases whose scripts write an Object they make ({@code W}, * {@code WF}, {@code WFT}, {@code WC} and {@code WCF}) run; {@code native_full_1}, whose Object * parts C writes with counts this library does not keep, is excluded and compared without them. @@ -67,10 +67,6 @@ class FitsChanCursorOracleTest { private static Map excludedCases() { Map m = new LinkedHashMap<>(); - // The absolute description of the offset SkyFrame passes C's LogAxis test on its first - // axis, so C builds the -LOG Mapping, which holds a MathMap; the description then fails - // MakeIntWorld and is not written (lldb probe s2 of the final review fixes). - m.put("alt_axes_alt_offset", "needs MathMap"); // The Mapping C's FitLine fits for the offset coordinates, written without a projection, // is the same as this library's (probe s1, dumps equal); of the 101 points of each grid // axis, 81 and 67 differ, each first at a SphMap, SphMap inverse or TAN WcsMap inverse @@ -86,6 +82,21 @@ private static Map excludedCases() { // compares them. m.put("alt_axes_offset", RUNTIME_MATH + " SphMap and TAN WcsMap transforms 1 ULP from C's libm"); m.put("alt_axes_offset_none", RUNTIME_MATH + " SphMap and TAN WcsMap transforms 1 ULP from C's libm"); + // The absolute description of the offset SkyFrame of alternate description B passes C's + // LogAxis test on its first axis and fails MakeIntWorld with the -LOG Mapping, so C writes + // the offset description SKY_POLE, fitted to the Mapping from pixel coordinates to the + // offset SkyFrame. Probe probes/alt_offset_probe.c: the simplified Mapping (a WinMap, an + // inverse TAN WcsMap, SphMaps and a MatrixMap) dumps as C's does; at its 101 x 11 grid + // over the image, 484 of the 1111 first outputs and 493 of the second differ from C's, + // by at most 2.2e-16 rad, 1 ULP of a unit-vector component, the SphMap and WcsMap + // evaluation difference traced for alt_axes_offset. Plane fits through the two sets of + // values differ by about 1e-20 rad per pixel in each slope: 4e-16 of the diagonal slope + // (CDELT1B differs from C's by 1.5e-15 of its value) and 5e-10 of the cross slope + // (-2.6e-11), whose ratio to the diagonal is PC2_1B (-1.5e-6; the card differs by + // 2.3e-15, 1.5e-9 of its value). PC2_1B passes withinLibmRounding only because a PC + // element is compared relative to 1. runtimeMathCasesMatchCButForLicensedCards compares + // the cards. + m.put("alt_axes_alt_offset", RUNTIME_MATH + " SphMap and TAN WcsMap transforms 1 ULP from C's libm"); // Its transcript shows the FrameSet read. The rotation of the alternate description // (fitschan.c WcsNative, three astMtrRot calls) takes the sine of 2 deg - pi/2, for which // java.lang.Math gives -0x1.ffb0278bf0566p-1 and C's libm -0x1.ffb0278bf0567p-1 (measured @@ -638,6 +649,7 @@ private static Map> runtimeMathCards() { Map> m = new LinkedHashMap<>(); m.put("alt_axes_offset", Arrays.asList("CDELT2", "CDELT2A")); m.put("alt_axes_offset_none", Arrays.asList("CDELT2")); + m.put("alt_axes_alt_offset", Arrays.asList("CDELT1B", "PC2_1B")); m.put("sky_offset_system_rw", Arrays.asList("CDELT1", "CDELT2", "PC1_2", "PC2_1")); return Collections.unmodifiableMap(m); } diff --git a/src/test/java/uk/ac/starlink/ast/FitsChanEncodingsTest.java b/src/test/java/uk/ac/starlink/ast/FitsChanEncodingsTest.java index 2cc4184..93eb060 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsChanEncodingsTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsChanEncodingsTest.java @@ -11,10 +11,7 @@ * fixture line is given to {@code putFits}, and the values expected are those C gives (probe * {@code c2.c} beside the task report). * - *

{@code read_dss_produces_frameset} is translated in {@link FitsEncDssTest}. Listed in {@code - * deferred/rust-tests.txt}: {@code - * freq_log_builds_log_mapping} (a {@code -LOG} spectral axis, which C maps with a MathMap) and - * {@code grism_builds_grism_mapping} (a {@code -GRI} axis, which C maps with a GrismMap). + *

{@code read_dss_produces_frameset} is translated in {@link FitsEncDssTest}. */ class FitsChanEncodingsTest { @@ -112,4 +109,90 @@ void readAipsSpectral() { assertEquals(1, fs.getFrame(FrameSet.AST__CURRENT).getNaxes()); assertInstanceOf(SpecFrame.class, fs.getFrame(FrameSet.AST__CURRENT)); } + + /** + * A {@code FREQ-LOG} header read with FITS-WCS maps pixel to frequency through C's {@code + * LogWcs} MathMap: the inverse transformation gives the pixel coordinates C gives for the same + * frequencies (the oracle {@code headers.oracle}, section {@code freq-log.head}). + */ + @Test + void freqLogBuildsLogMapping() { + FrameSet fs = FitsHeaders.readFrameSet(FitsHeaders.fixture("wcsconv/inputs/freq-log.head")); + double[] sInputs = { + 1420399999.4884999, + 1420400000.5115, + 1420399999.4884999, + 1420400000.0, + 1420400000.0, + 1420399999.74425, + 1420400000.25575, + 1420399999.616375, + 1420400000.127875, + 1420399999.8721251, + 1420400000.383625, + 1420399999.5524375, + 1420400000.0639377, + 1420399999.8081875, + 1420400000.3196874, + 1420399999.6803126, + 1420400000.1918123, + 1420399999.9360623, + 1420400000.4475627, + 1420399999.5204687, + 1420400000.0319688, + 1420399999.7762187, + 1420400000.2877188, + 1420399999.6483438, + }; + double[] expectedPixels = { + 0.9998384814760453, + 1023.999845942171, + 0.9998384814760453, + 512.5, + 512.5, + 256.75007695984095, + 768.24992299411, + 128.87495772641466, + 640.3751191988895, + 384.62519618175503, + 896.125042169975, + 64.9375558014628, + 576.4375596008838, + 320.6874788761586, + 832.1874825834816, + 192.8126750406453, + 704.3123634018605, + 448.5622827001597, + 960.0626017535905, + 32.968775989868405, + 544.4687798008017, + 288.7186990703203, + 800.2187027891555, + 160.84373753585044, + }; + double[] got = fs.tran1(sInputs.length, sInputs, false); + for (int i = 0; i < sInputs.length; i++) { + double tol = 1e-9 + 1e-9 * Math.abs(expectedPixels[i]); + assertEquals(expectedPixels[i], got[i], tol, "point " + i + ": S=" + sInputs[i]); + } + } + + /** + * The {@code -GRI} axis of {@code wcsconv/inputs/grism.head} is read with a GrismMap, and the + * FrameSet's inverse gives C's pixel coordinates for C's wavelengths, every row of the section + * {@code [grism.head nin=1 nout=1 dir=inverse]} of {@code headers.oracle}. + */ + @Test + void grismBuildsGrismMapping() { + String rel = "wcsconv/inputs/grism.head"; + FrameSet fs = FitsHeaders.readFrameSet(FitsHeaders.fixture(rel)); + uk.ac.starlink.ast.testsupport.OracleSection inv = FitsHeaders.headersOracle(rel, false); + for (int row = 1; row <= inv.npoint(); row++) { + double s = FitsHeaders.oracleIn(inv, row)[0]; + double expected = FitsHeaders.oracleOut(inv, row)[0]; + double got = fs.tran1(1, new double[] {s}, false)[0]; + double tol = 1e-9 + 1e-9 * Math.abs(expected); + assertEquals(expected, got, tol, "row " + row + ": S=" + s); + } + } } diff --git a/src/test/java/uk/ac/starlink/ast/FitsChanNativeKeywordTest.java b/src/test/java/uk/ac/starlink/ast/FitsChanNativeKeywordTest.java index 7608ea3..19ae840 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsChanNativeKeywordTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsChanNativeKeywordTest.java @@ -12,9 +12,7 @@ * keyword-card form of the NATIVE encoding ({@code BEGAST_xx}, {@code ENDAST_xx} and data-keyword * cards). * - *

{@code polco.head} and {@code polco2.head} hold a MathMap, a class out of scope, so {@code - * polco_loads} and {@code polco2_loads} are listed in {@code deferred/rust-tests.txt}, and {@code - * native_read_consumes_its_cards} is translated for {@code specflux.head} and {@code + *

{@code native_read_consumes_its_cards} is translated for {@code specflux.head} and {@code * timeplot.head}. */ class FitsChanNativeKeywordTest { @@ -29,6 +27,16 @@ void specfluxLoads() { assertNotNull(obj, "specflux.head: read returned null"); } + @Test + void polcoLoads() { + assertNotNull(header("polco.head").read(), "polco.head: read returned null"); + } + + @Test + void polco2Loads() { + assertNotNull(header("polco2.head").read(), "polco2.head: read returned null"); + } + @Test void timeplotLoads() { AstObject obj = header("timeplot.head").read(); diff --git a/src/test/java/uk/ac/starlink/ast/FitsChanReadChainOracleTest.java b/src/test/java/uk/ac/starlink/ast/FitsChanReadChainOracleTest.java index 11b3cd8..fefe957 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsChanReadChainOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsChanReadChainOracleTest.java @@ -5,8 +5,8 @@ import com.fasterxml.jackson.databind.JsonNode; import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -25,20 +25,13 @@ * Mapping C simplified ({@code WcsMapFrm} returns {@code astSimplify} of it). Each case is compared * with C's whole dump. * - *

The cases in {@link #EXCLUDED} have a {@code -LOG} axis (which C maps with a MathMap); each - * must still stop there. + *

A case that needs a class this library lacks would be listed in {@link #EXCLUDED}, and must + * still stop there; none does. */ class FitsChanReadChainOracleTest { /** The cases that cannot be read, with the reason the read gives. */ - private static final Map EXCLUDED = exclusions(); - - private static Map exclusions() { - Map m = new LinkedHashMap<>(); - m.put("other_log", "needs MathMap"); - m.put("other_log_and_linear", "needs MathMap"); - return m; - } + private static final Map EXCLUDED = Collections.emptyMap(); /** The first mismatch between the port's read of {@code header} and C's dump {@code want}, or null. */ private static String compare(String[] header, String want) { diff --git a/src/test/java/uk/ac/starlink/ast/FitsChanReadTest.java b/src/test/java/uk/ac/starlink/ast/FitsChanReadTest.java index f097a96..59e5933 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsChanReadTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsChanReadTest.java @@ -14,9 +14,8 @@ * FITS-WCS read sets, each test isolating one decision of C's {@code WcsSkyFrame} or {@code * WcsOthers}. * - *

Listed in {@code deferred/rust-tests.txt}: {@code log_suffix_is_stripped_from_the_domain_and_symbol} - * (a {@code -LOG} axis, which C maps with a MathMap) and {@code - * unset_system_still_leaves_system_unset} (a constructor of the Rust port's own). + *

Listed in {@code deferred/rust-tests.txt}: {@code unset_system_still_leaves_system_unset} (a + * constructor of the Rust port's own). */ class FitsChanReadTest { @@ -136,6 +135,16 @@ void unclassifiedAxisDomainComesFromCtype() { assertTrue(f.test("Domain"), "Domain is set"); } + @Test + void logSuffixIsStrippedFromTheDomainAndSymbol() { + // C's WcsOthers removes a trailing "-LOG" from the CTYPE before using it as the Domain + // and the Symbol (fitschan.c:39352-39358). + Frame f = currentFrame(oneAxisHeader("CTYPE1 = 'ZZZZ-LOG'\n")); + assertEquals("ZZZZ", f.getDomain()); + assertEquals(Frame.class, f.getClass(), "a linear axis gives a plain Frame"); + assertEquals("ZZZZ", f.getSymbol(1)); + } + @Test void absentCtypeFallsBackToTheAxisNumber() { // An absent CTYPE is replaced by "AXIS" (fitschan.c:39345-39349). diff --git a/src/test/java/uk/ac/starlink/ast/FitsChanSpecUnitOracleTest.java b/src/test/java/uk/ac/starlink/ast/FitsChanSpecUnitOracleTest.java index c6d277b..718ea6c 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsChanSpecUnitOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsChanSpecUnitOracleTest.java @@ -25,10 +25,10 @@ * to a FitsChan holding the case's NAXIS cards; the value the write returns and the cards written * are compared with C's. * - *

The read of the cube is checked for every case. A case can stop at something not available: - * a logarithmic Unit set through the FrameSet needs the MathMap that converts to it ({@code needs - * MathMap}). Such cases are listed with their reason in {@link #UNAVAILABLE}, and the list is checked both ways: a listed case must stop with the reason - * listed, and every other case must match C. + *

The read of the cube is checked for every case. A case that stops at something not available + * ({@code needs }) is listed with its reason in {@link #UNAVAILABLE}, and the list is + * checked both ways: a listed case must stop with the reason listed, and every other case must + * match C. */ class FitsChanSpecUnitOracleTest { @@ -59,8 +59,6 @@ class FitsChanSpecUnitOracleTest { private static Map unavailableCases() { Map m = new TreeMap<>(); - m.put("unit_log", "needs MathMap"); - m.put("unit_log_no_dims", "needs MathMap"); return Collections.unmodifiableMap(m); } diff --git a/src/test/java/uk/ac/starlink/ast/FitsChanWcsWriteTest.java b/src/test/java/uk/ac/starlink/ast/FitsChanWcsWriteTest.java index 1f804e3..ed94968 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsChanWcsWriteTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsChanWcsWriteTest.java @@ -14,11 +14,12 @@ * header written FITS-WCS into a new FitsChan, and read back. The cards and coordinates expected * are those C gives (probe {@code c1.c} beside the task report). * - *

Listed in {@code deferred/rust-tests.txt}: {@code grism_interference_order_survives_a_round_trip} - * and {@code a_non_linear_grism_axis_writes_a_header_that_reads_back} (GrismMap, which the read of - * their {@code WAVE-GRI} headers builds), - * the four tests of the {@code lsst2.ast} FrameSet (SplineMap), and {@code - * a_sip_description_is_rejected_when_it_is_not_linear_over_the_image} (MathMap). + *

Grism axes are also checked against the C probe {@code probes/grismmap_probe.c}: headers + * 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). */ class FitsChanWcsWriteTest { @@ -52,6 +53,53 @@ private static FitsChan written(FrameSet fs) { return fc; } + /** + * A SIP-shaped PolyMap followed by a MathMap that is not linear over the image is not written + * as a SIP description; the plain linear approximation is good enough, so the write succeeds. + */ + @Test + void aSipDescriptionIsRejectedWhenItIsNotLinearOverTheImage() { + FrameSet tan = FitsHeaders.readFrameSet(FitsHeaders.chan( + "CTYPE1 = 'RA---TAN'", + "CTYPE2 = 'DEC--TAN'", + "CRPIX1 = 0.0", + "CRPIX2 = 0.0", + "CRVAL1 = 180.0", + "CRVAL2 = 0.0", + "CD1_1 = -5.5E-05", + "CD1_2 = 0.0", + "CD2_1 = 0.0", + "CD2_2 = 5.5E-05", + "RADESYS = 'ICRS'")); + // A unit linear term per axis plus one quadratic term, as the SIP conventions require. + PolyMap poly = new PolyMap( + 2, 2, 4, new double[] {1.0, 1, 1, 0, 1.0e-9, 1, 2, 0, 1.0, 2, 0, 1, 1.0e-9, 2, 0, 2}, 4, new double[] { + 1.0, 1, 1, 0, -1.0e-9, 1, 2, 0, 1.0, 2, 0, 1, -1.0e-9, 2, 0, 2 + }); + // The cubic term sits between the PolyMap and the CD matrix, so it is part of the Mapping + // whose linearity the SIP test judges. + MathMap cubic = new MathMap( + 2, 2, new String[] {"u = x + 1.0E-15*x*x*x", "v = y"}, new String[] {"x = u - 1.0E-15*u*u*u", "y = v"}); + Mapping total = new CmpMap( + new CmpMap(new CmpMap(new ShiftMap(new double[] {20000.0, 20000.0}), poly, true), cubic, true), + tan.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT), + true); + Frame grid = new Frame(2); + grid.setDomain("GRID"); + FrameSet fs = new FrameSet(grid); + fs.addFrame(FrameSet.AST__BASE, total, (Frame) + tan.getFrame(FrameSet.AST__CURRENT).copy()); + FitsChan fc = new FitsChan(); + fc.setEncoding("FITS-WCS"); + fc.setCDMatrix(true); + fc.putFits("NAXIS1 = 4000", false); + fc.putFits("NAXIS2 = 4000", false); + assertEquals(1, fc.write(fs), "the plain linear approximation is good enough"); + assertFalse( + FitsHeaders.keywords(fc).contains("A_ORDER"), + "a SIP description must not be accepted when the Mapping after the SIP polynomial is not linear"); + } + @Test void writeProducesFitsCards() { FitsChan fc = written(readMinimalTan()); @@ -177,4 +225,420 @@ void writeSpectralRoundTrip() { assertArrayEquals(want, fs1.tran1(3, pix, true), 0.0); assertArrayEquals(want, fs2.tran1(3, pix, true), 0.0); } + + // ------------------------------------------------------------------ + // tests/test_fitschan_wcs_write.rs: grism axes + // ------------------------------------------------------------------ + + /** + * A FITS grism header keeps its interference order, which is commonly negative, through a + * read and write, with its reference pixel and pixel size (C's {@code testgrismorder}, + * testfitschan.c). + */ + @Test + void grismInterferenceOrderSurvivesARoundTrip() { + for (double morder : new double[] {1.0, -1.0, -2.0}) { + FitsChan in = FitsHeaders.chan( + "CTYPE1 = 'WAVE-GRI'", + "CRVAL1 = 5.0E-7", + "CRPIX1 = 1.0", + "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", + "PV1_0 = 9.0E5", + String.format(java.util.Locale.ROOT, "PV1_1 = %20.1f", morder), + "PV1_2 = 0.0", + "PV1_3 = 1.0", + "PV1_4 = 0.0", + "PV1_5 = 0.0", + "PV1_6 = 0.0"); + FitsChan out = written(FitsHeaders.readFrameSet(in)); + out.clear("Card"); + assertEquals(morder, out.getFitsF("PV1_1"), "grism interference order not preserved"); + out.clear("Card"); + assertEquals(1.0, out.getFitsF("CRPIX1"), "grism output must carry a reference pixel"); + out.clear("Card"); + assertEquals(1.0e-9, out.getFitsF("CDELT1"), 1.0e-12, "grism output CDELT1"); + } + } + + /** + * A grism axis whose non-linearity over 10000 pixels is within the linearity tolerance is + * written as a linear {@code WAVE} axis, with the cards C writes (an oracle probe), and the + * header read back transforms as the original. + */ + @Test + void aNonLinearGrismAxisWritesAHeaderThatReadsBack() { + FrameSet obj = FitsHeaders.readFrameSet(FitsHeaders.chan( + "NAXIS = 1", + "NAXIS1 = 10000", + "CTYPE1 = 'WAVE-GRI'", + "CRVAL1 = 5.000E-07", + "CRPIX1 = 5000.0", + "CDELT1 = 1.000E-10", + "CUNIT1 = 'm'", + "RESTFRQ = 5.996E+14", + "SPECSYS = 'BARYCENT'", + "PV1_0 = 3.000E-06", + "PV1_1 = 1", + "PV1_2 = 0.0")); + FitsChan fc = new FitsChan(); + fc.setEncoding("FITS-WCS"); + fc.putFits("NAXIS = 1", false); + fc.putFits("NAXIS1 = 10000", false); + assertEquals(1, fc.write(obj), "a grism FrameSet should write one description"); + List want = FitsHeaders.padded( + "NAXIS = 1", + "NAXIS1 = 10000", + "CRPIX1 = 5001.0 / Reference pixel on axis 1", + "CRVAL1 = 5.001E-7 / Value at ref. pixel on axis 1", + "CTYPE1 = 'WAVE ' / Type of co-ordinate on axis 1", // codespell:ignore + "CDELT1 = 1.0E-10 / Pixel size on axis 1", + "CUNIT1 = 'm ' / Units for axis 1", + "SPECSYS = 'BARYCENT' / Standard of rest for spectral axis", + "VELOSYS = 29327.576999871173 / [m/s] Topo. apparent velocity of rest frame", + "RESTWAV = 4.9998742161440962E-7 / [m] Rest wavelength"); + List got = FitsHeaders.foundCards(fc); + assertTrue(FitsHeaders.cardsMatchC(got, want), got.toString()); + fc.clear("Card"); + FrameSet obj2 = FitsHeaders.readFrameSet(fc); + double x1 = obj.tran1(1, new double[] {5000.0}, true)[0]; + double x2 = obj2.tran1(1, new double[] {5000.0}, true)[0]; + assertTrue(Math.abs(x1 - x2) <= 1.0e-6 * Math.abs(x1), x1 + " vs " + x2); + } + + // ------------------------------------------------------------------ + // Grism axes against the C probe probes/grismmap_probe.c + // ------------------------------------------------------------------ + + private static final java.util.Map GRISM_PROBE = + uk.ac.starlink.ast.testsupport.ProbeOutput.load("grismmap_probe"); + + private static String g(double v) { + return CFormat.format("%.17g", v); + } + + /** The probe's {@code pixels}: pixels 1, 50 and 100 transformed forward, and back. */ + private static void pixels(List out, FrameSet fs) { + double[] pix = {1.0, 50.0, 100.0}; + double[] w = fs.tran1(3, pix, true); + double[] back = fs.tran1(3, w, false); + for (int i = 0; i < 3; i++) { + out.add("pixel " + g(pix[i]) + " -> " + g(w[i]) + " -> " + g(back[i])); + } + } + + /** The probe's report of an error, without the line naming the C source. */ + private static void error(List out, AstException e) { + for (String line : uk.ac.starlink.ast.testsupport.ProbeOutput.trimLines(e.getMsgText()) + .split("\n", -1)) { + out.add("! " + line); + } + out.add("status " + e.getStatus()); + } + + /** {@code text}'s lines, trailing white space removed, without the last newline. */ + private static void addText(List out, String text) { + String t = uk.ac.starlink.ast.testsupport.ProbeOutput.trimLines(text); + out.add(t.endsWith("\n") ? t.substring(0, t.length() - 1) : t); + } + + /** The cards of {@code fc}, as the probe lists them. */ + private static void cards(List out, FitsChan fc) { + for (String card : FitsHeaders.foundCards(fc)) { + out.add(uk.ac.starlink.ast.testsupport.ProbeOutput.trimLines(card)); + } + } + + /** 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<>(); + FitsChan fc = FitsHeaders.chan(header); + fc.setEncoding(encoding); + fc.clear("Card"); + AstObject obj; + try { + obj = fc.read(); + } catch (AstException e) { + error(out, e); + return String.join("\n", out) + "\n"; + } + if (obj == null) { + return "read nothing\n"; + } + FrameSet fs = (FrameSet) obj; + out.add("read " + fs.astClass()); + pixels(out, fs); + addText( + out, + ChannelText.dump( + fs.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT).simplify())); + FitsChan wfc = new FitsChan(); + wfc.setEncoding(encoding); + int n = wfc.write(fs); + out.add("-- written " + n); + cards(out, wfc); + if (n != 0) { + wfc.clear("Card"); + try { + AstObject back = wfc.read(); + if (back == null) { + out.add("-- read back nothing"); + } else { + out.add("-- read back " + back.astClass()); + pixels(out, (FrameSet) back); + } + } catch (AstException e) { + error(out, e); + } + } + return String.join("\n", out) + "\n"; + } + + /** 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<>(); + Frame grid = new Frame(1); + grid.setDomain("GRID"); + FrameSet fs = new FrameSet(grid); + SpecFrame sf = new SpecFrame(); + sf.set(specattrs); + fs.addFrame(FrameSet.AST__BASE, map, sf); + FitsChan wfc = new FitsChan(); + wfc.setEncoding("FITS-WCS"); + int n = wfc.write(fs); + out.add("written " + n); + cards(out, wfc); + pixels(out, fs); + if (n != 0) { + wfc.clear("Card"); + out.add("-- read back"); + pixels(out, (FrameSet) wfc.read()); + } + return String.join("\n", out) + "\n"; + } + + /** + * The relative difference from C's allowed the values that depend on the rate of change of the + * grism parameter at CRVAL: the WinMap's scale and shift in a read Mapping, the world + * coordinates and the pixel coordinates transformed back, and CDELT. C's {@code astRate} + * estimates the rate numerically from the Mapping's values at points about CRVAL, and + * java.lang.Math's {@code asin} and {@code tan} give some of those values 1 ULP, and near + * CRVAL, where the grism parameter is the difference of two nearly equal angles, up to 32 ULP + * from C's libm (measured against the pinned C library for the {@code AWAV-GRA} and nm cases). + * The rates then differ from C's by 1.7e-10 and 8e-10 of their values in those cases. + */ + private static final double GRISM_RTOL = 1.0e-8; + + /** + * Whether a line holds values that depend on the rate (see {@link #GRISM_RTOL}): a {@code + * pixel} line, the WinMap's {@code Sft1} or {@code Scl1}, or a CDELT card. + */ + private static boolean rateDerived(String line) { + String t = line.trim(); + return t.startsWith("pixel ") || t.startsWith("Sft1 =") || t.startsWith("Scl1 =") || line.startsWith("CDELT"); + } + + /** + * Whether {@code got} is C's {@code want} without the lines naming the C source of an error: + * each line the same, but for the numbers of a line holding rate-derived values ({@link + * #rateDerived}), which need be within {@link #GRISM_RTOL} of C's, and the numbers of other + * lines, which need be within libm rounding; a number on a card may be written to a width the + * white space beside it absorbs. + */ + static boolean grismMatchesC(String got, String want) { + List g = CValues.lines(got); + List w = new java.util.ArrayList<>(); + for (String line : CValues.lines(want)) { + if (!line.contains("AST: Error in routine")) { + w.add(line); + } + } + if (g.size() != w.size()) { + return false; + } + for (int i = 0; i < g.size(); i++) { + String gl = g.get(i) + "\n"; + String wl = w.get(i) + "\n"; + boolean ok = rateDerived(w.get(i)) + ? CValues.nativeStringsWithinRelative(gl, wl, GRISM_RTOL) + : CValues.nativeStringsWithinLibmRounding(gl, wl); + if (!ok) { + return false; + } + } + return true; + } + + private static void assertGrismProbe(String name, String got) { + String want = GRISM_PROBE.get(name); + if (want == null || !grismMatchesC(got, want)) { + assertEquals(want, got, name); + } + } + + private static final String[] GRI_HEADER = { + "CTYPE1 = 'WAVE-GRI'", + "CRVAL1 = 5.0E-7", + "CRPIX1 = 1.0", + "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", + "PV1_0 = 9.0E5", + "PV1_1 = 1.0", + "PV1_2 = 0.0", + "PV1_3 = 1.0", + "PV1_4 = 0.0", + "PV1_5 = 0.0", + "PV1_6 = 0.0" + }; + + private static final String[] GRA_HEADER = { + "CTYPE1 = 'AWAV-GRA'", + "CRVAL1 = 5.0E-7", + "CRPIX1 = 10.0", + "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", + "PV1_0 = 6.0E5", + "PV1_1 = -2.0", + "PV1_2 = 10.0", + "PV1_3 = 1.5", + "PV1_4 = -100.0", + "PV1_5 = 2.0", + "PV1_6 = 3.0" + }; + + /** + * {@code -GRI} and {@code -GRA} headers read with each encoding, and written back with it, as + * C reads and writes them: FITS-WCS writes the grism axis with each parameter that differs + * from its default; FITS-PC and FITS-IRAF write the CTYPE without the parameters, so the + * header does not read back; FITS-AIPS and FITS-AIPS++ write nothing; FITS-CLASS and DSS + * refuse the header, and NATIVE finds nothing in it. + */ + @Test + void grismHeadersReadAndWriteAsC() { + for (String enc : new String[] { + "FITS-WCS", "FITS-PC", "FITS-IRAF", "FITS-AIPS", "FITS-AIPS++", "FITS-CLASS", "NATIVE", "DSS" + }) { + assertGrismProbe("fits_gri_" + enc, fitsrw(enc, GRI_HEADER)); + assertGrismProbe("fits_gra_" + enc, fitsrw(enc, GRA_HEADER)); + } + } + + /** + * Grism axes in vacuum wavelength dispersed in air, in frequency, and in nm read and written + * as C does; a fractional order is rounded, and a radio velocity axis, which does not convert + * to wavelength, and an order whose rounding puts the reference ray outside the grism, are + * refused. + */ + @Test + void otherGrismHeadersReadAndWriteAsC() { + assertGrismProbe( + "fits_wave_gra", + fitsrw( + "FITS-WCS", + "CTYPE1 = 'WAVE-GRA'", + "CRVAL1 = 5.0E-7", + "CRPIX1 = 1.0", + "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", + "PV1_0 = 9.0E5", + "PV1_1 = 1.0")); + assertGrismProbe( + "fits_freq_gri", + fitsrw( + "FITS-WCS", + "CTYPE1 = 'FREQ-GRI'", + "CRVAL1 = 6.0E14", + "CRPIX1 = 1.0", + "CDELT1 = 1.0E12", + "CUNIT1 = 'Hz '", + "PV1_0 = 9.0E5", + "PV1_1 = 1.0")); + assertGrismProbe( + "fits_gri_nm", + fitsrw( + "FITS-WCS", + "CTYPE1 = 'WAVE-GRI'", + "CRVAL1 = 500.0", + "CRPIX1 = 1.0", + "CDELT1 = 1.0", + "CUNIT1 = 'nm '", + "PV1_0 = 9.0E5", + "PV1_1 = 1.0")); + assertGrismProbe( + "fits_vrad_gri", + fitsrw( + "FITS-WCS", + "CTYPE1 = 'VRAD-GRI'", + "CRVAL1 = 100.0", + "CRPIX1 = 1.0", + "CDELT1 = 1.0", + "PV1_0 = 9.0E5", + "PV1_1 = 1.0")); + assertGrismProbe( + "fits_gri_half_order", + fitsrw( + "FITS-WCS", + "CTYPE1 = 'WAVE-GRI'", + "CRVAL1 = 5.0E-7", + "CRPIX1 = 1.0", + "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", + "PV1_0 = 9.0E5", + "PV1_1 = 1.5")); + assertGrismProbe( + "fits_gri_negative_half_order", + fitsrw( + "FITS-WCS", + "CTYPE1 = 'WAVE-GRI'", + "CRVAL1 = 5.0E-7", + "CRPIX1 = 1.0", + "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", + "PV1_0 = 9.0E5", + "PV1_1 = -2.5")); + } + + private static Mapping pixelToGrism() { + return new CmpMap(new ShiftMap(new double[] {-50.0}), new ZoomMap(1, 0.002), true); + } + + private static GrismMap grism() { + GrismMap g = new GrismMap(); + g.set("GrismG=9.0E5,GrismM=1,GrismWaveR=5.0E-7"); + return g; + } + + /** + * FrameSets whose Mapping ends in a GrismMap are written as {@code -GRI} axes, as C writes + * them: in wavelength, and in frequency, whose Mapping ends in a GrismMap once the SpecFrame + * is set to wavelength; a GrismMap inverted twice is still not inverted. A GrismMap followed + * by a ShiftMap is not at the end of the Mapping, and one followed by a ZoomMap to nm is not + * written either. + */ + @Test + void grismFrameSetsWriteAsC() { + assertGrismProbe( + "write_shift_zoom_grism", fitswrite(new CmpMap(pixelToGrism(), grism(), true), "System=WAVE,Unit=m")); + assertGrismProbe( + "write_grism_then_zoom_nm", + fitswrite( + new CmpMap(pixelToGrism(), new CmpMap(grism(), new ZoomMap(1, 1.0e9), true), true), + "System=WAVE,Unit=nm")); + SpecMap w2f = new SpecMap(1, 0); + w2f.specAdd("WVTOFR", new double[0]); + assertGrismProbe( + "write_grism_freq", + fitswrite(new CmpMap(pixelToGrism(), new CmpMap(grism(), w2f, true), true), "System=FREQ,Unit=Hz")); + assertGrismProbe( + "write_grism_then_shift", + fitswrite( + new CmpMap( + new CmpMap(pixelToGrism(), grism(), true), new ShiftMap(new double[] {1.0e-9}), true), + "System=WAVE,Unit=m")); + GrismMap twice = grism(); + twice.invert(); + twice.invert(); + assertGrismProbe( + "write_grism_inverted", fitswrite(new CmpMap(pixelToGrism(), twice, true), "System=WAVE,Unit=m")); + } } diff --git a/src/test/java/uk/ac/starlink/ast/FitsChanWriteTest.java b/src/test/java/uk/ac/starlink/ast/FitsChanWriteTest.java index 1cdf09b..26b54a1 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsChanWriteTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsChanWriteTest.java @@ -276,7 +276,11 @@ void cardsGoInFrontOfAConsumedCurrentCard() { * linearly in frequency or wavelength, C writes with the {@code -X2P} algorithm, the reference * at pixel 1 and a CDELT from the numerical rate of the conversion there, so that the cards * read back give velocities up to 1e-3 m/s from those of the header, the same values as C's - * read of C's cards: C probe {@code roundtrip_probe} of Task 8), or C's read of the cards written fails (skyref, whose alternate description, + * read of C's cards: C probe {@code roundtrip_probe} of Task 8; and freq-log, whose axis + * spans so narrow a range (1 Hz at 1.42e9 Hz) that it is linear, and C's IsMapLinear rejects + * the conversion from Hz to GHz over it, so that C writes the axis in GHz and the cards read + * back give GHz where the header gives Hz: case {@code freq_log_head} of {@code + * probes/fitslog_probe.c}), or C's read of the cards written fails (skyref, whose alternate description, * CTYPE1A {@code RA} and CTYPE2A {@code Dec}, C's read rejects as a longitude axis without a * latitude axis). */ @@ -308,6 +312,7 @@ private static Map notRoundTripped() { "programs/joye_car_headers/cmap_3years_GP_D2.head", "wcsconv/inputs/car1.head", "wcsconv/inputs/car2.head", + "wcsconv/inputs/freq-log.head", "wcsconv/inputs/offset-sky-pole.head", "wcsconv/inputs/offset-sky.head", "wcsconv/inputs/offset-sref.head", diff --git a/src/test/java/uk/ac/starlink/ast/FitsLogAxesTest.java b/src/test/java/uk/ac/starlink/ast/FitsLogAxesTest.java new file mode 100644 index 0000000..233037b --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/FitsLogAxesTest.java @@ -0,0 +1,361 @@ +package uk.ac.starlink.ast; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.CValues; +import uk.ac.starlink.ast.testsupport.ProbeOutput; + +/** + * FITS-WCS {@code -LOG} axes, spectral and not, read and written as C reads and writes them + * (fitschan.c {@code LogWcs} and {@code LogAxis}): each case of the probe {@code + * probes/fitslog_probe.c} made here and its text compared with C's, the numbers within libm + * rounding (the transformations go through {@code exp} and {@code log}). + * + *

A header is read, its FrameSet dumped and transformed, and written back in each FITS encoding + * (C writes a {@code -LOG} axis that is not spectral with FITS-WCS, FITS-PC, FITS-IRAF, FITS-AIPS + * and FITS-AIPS++, a spectral one only with the first three); each header written is read back + * and transformed, so that the FrameSet read back transforms as the original. FrameSets whose world + * axis is exponential in the pixel axis are written with FITS-WCS as {@code -LOG} axes. + */ +class FitsLogAxesTest { + + private static final Map PROBE = ProbeOutput.load("fitslog_probe"); + + private static final String[] ENCODINGS = { + "FITS-WCS", "FITS-PC", "FITS-IRAF", "FITS-AIPS", "FITS-AIPS++", "FITS-CLASS" + }; + + private static final String[] NAXIS1 = {"NAXIS = 1", "NAXIS1 = 100"}; + + private static final String[] NAXIS1K = {"NAXIS = 1", "NAXIS1 = 1024"}; + + private static final String[] NAXIS2 = {"NAXIS = 2", "NAXIS1 = 100", "NAXIS2 = 100"}; + + private static String g(double v) { + return CFormat.format("%.17g", v); + } + + /** The probe's {@code trans}: pixel positions along the first axis, the others at 1. */ + private static void trans(List out, FrameSet fs, boolean big) { + double[] pix = {1.0, 50.0, 100.0, 512.0, 1024.0}; + int np = big ? 5 : 3; + int nin = fs.getNin(); + double[][] in = new double[nin][np]; + for (int i = 0; i < np; i++) { + in[0][i] = pix[i]; + for (int j = 1; j < nin; j++) { + in[j][i] = 1.0; + } + } + double[][] wcs = fs.transform(in, np, true); + double[][] back = fs.transform(wcs, np, false); + for (int i = 0; i < np; i++) { + out.add("pix" + coords(in, i) + " -> wcs" + coords(wcs, i) + " -> pix" + coords(back, i)); + } + } + + /** Point {@code i} of {@code cols}, each coordinate after a space. */ + private static String coords(double[][] cols, int i) { + StringBuilder sb = new StringBuilder(); + for (double[] col : cols) { + sb.append(' ').append(g(col[i])); + } + return sb.toString(); + } + + /** The probe's {@code writeback}. */ + private static void writeback(List out, FrameSet fs, String enc, String[] naxis, boolean big) { + out.add("-- write " + enc); + FitsChan fc = new FitsChan(); + fc.setEncoding(enc); + for (String card : naxis) { + fc.putFits(card, false); + } + int n = fc.write(fs); + out.add("wrote " + n); + for (String card : FitsHeaders.foundCards(fc)) { + out.add(ProbeOutput.trimLines(card)); + } + if (n != 0) { + fc.clear("Card"); + AstObject back = fc.read(); + out.add("-- read back " + (back != null ? back.astClass() : "nothing")); + if (back != null) { + FrameSet bfs = (FrameSet) back; + out.add("domain " + bfs.getDomain()); + trans(out, bfs, big); + } + } + } + + /** {@code lines}, each ending with a newline. */ + private static String text(List lines) { + return String.join("\n", lines) + "\n"; + } + + /** The probe's {@code readhead}. */ + private static String readHead(String[] header, String[] naxis, boolean big) { + List out = new ArrayList<>(); + FitsChan fc = new FitsChan(); + for (String card : header) { + fc.putFits(card, false); + } + fc.clear("Card"); + out.add("encoding " + fc.getEncoding()); + FrameSet fs = (FrameSet) fc.read(); + out.add("-- read"); + String dump = ProbeOutput.trimLines(ChannelText.dump(fs)); + out.add(dump.substring(0, dump.length() - 1)); + out.add("domain " + fs.getDomain()); + for (int i = 1; i <= fs.getNaxes(); i++) { + out.add("symbol(" + i + ") " + fs.getSymbol(i)); + } + trans(out, fs, big); + for (String enc : ENCODINGS) { + writeback(out, fs, enc, naxis, big); + } + return text(out); + } + + private static String written(FrameSet fs, String[] naxis, boolean big) { + List out = new ArrayList<>(); + writeback(out, fs, "FITS-WCS", naxis, big); + return text(out); + } + + /** + * The largest difference from C's of a pixel coordinate transformed back from world + * coordinates. The CDELT1 written for a spectral {@code -LOG} axis is the slope fitted through + * the axis's {@code exp} and {@code log} values, of which java.lang.Math gives a few in the + * last bit unlike C's libm, and is up to 3 ULP (5e-16 of its value) from C's. Read back, + * the inverse divides an intermediate world coordinate up to about 500 CDELT from the + * reference pixel by that CDELT, which moves the pixel coordinate by up to about 3e-13; the + * forward transformation moves the world value by less than an ULP of it. With C's CDELT1 + * card the pixel coordinates are C's. + */ + private static final double PIXEL_ATOL = 1e-12; + + /** + * Whether {@code got} matches C's {@code want}: every line within libm rounding, but for the + * pixel coordinates a {@code pix} line ends with, which need only be within {@link + * #PIXEL_ATOL}. + */ + private static boolean matchesC(String got, String want) { + List g = CValues.lines(got); + List w = CValues.lines(want); + if (g.size() != w.size()) { + return false; + } + for (int i = 0; i < g.size(); i++) { + String gl = g.get(i); + String wl = w.get(i); + int gi = gl.lastIndexOf(" -> pix"); + int wi = wl.lastIndexOf(" -> pix"); + boolean ok; + if (gl.startsWith("pix") && gi >= 0 && wi >= 0) { + ok = CValues.nativeStringsWithinLibmRounding(gl.substring(0, gi), wl.substring(0, wi)) + && CValues.nativeStringsWithin(gl.substring(gi), wl.substring(wi), PIXEL_ATOL); + } else { + ok = CValues.nativeStringsWithinLibmRounding(gl, wl); + } + if (!ok) { + return false; + } + } + return true; + } + + private static void assertProbe(String name, String got) { + String want = PROBE.get(name); + if (want == null || !matchesC(got, want)) { + assertEquals(want, got, name); + } + } + + /** The PolyMap of the Taylor series to degree 20 of {@code sr exp(slope p)}. */ + private static PolyMap exponential(double sr, double slope) { + double[] coeffs = new double[21 * 3]; + double term = sr; + for (int k = 0; k <= 20; k++) { + coeffs[3 * k] = term; + coeffs[3 * k + 1] = 1; + coeffs[3 * k + 2] = k; + term = term * slope / (k + 1); + } + PolyMap pm = new PolyMap(1, 1, 21, coeffs, 0, new double[0]); + pm.set("IterInverse=1"); + return pm; + } + + private static FrameSet frameSet(int nin, Mapping map, Frame wcs) { + Frame pix = new Frame(nin); + pix.setDomain("GRID"); + FrameSet fs = new FrameSet(pix); + fs.addFrame(FrameSet.AST__BASE, map, wcs); + return fs; + } + + @Test + void otherLogAxis() { + assertProbe( + "other_log", + readHead( + new String[] { + "NAXIS = 1", + "NAXIS1 = 100", + "CTYPE1 = 'ZZZZ-LOG'", + "CRPIX1 = 1", + "CRVAL1 = 10.0", + "CDELT1 = 0.1" + }, + NAXIS1, + false)); + } + + @Test + void otherLogAxisBesideALinearAxis() { + assertProbe( + "other_log_2d", + readHead( + new String[] { + "NAXIS = 2", + "NAXIS1 = 100", + "NAXIS2 = 100", + "CTYPE1 = 'XPOS'", + "CTYPE2 = 'YPOS-LOG'", + "CUNIT2 = 'V'", + "CRPIX1 = 1", + "CRPIX2 = 50", + "CRVAL1 = 3.0", + "CRVAL2 = 250.0", + "CDELT1 = 2.0", + "CDELT2 = 5.0" + }, + NAXIS2, + false)); + } + + @Test + void spectralLogAxis() { + assertProbe( + "freq_log", + readHead( + new String[] { + "NAXIS = 1", + "NAXIS1 = 1024", + "CTYPE1 = 'FREQ-LOG'", + "CUNIT1 = 'Hz'", + "CRPIX1 = 512", + "CRVAL1 = 1.4204E9", + "CDELT1 = 1.0E5", + "SPECSYS = 'BARYCENT'", + "RESTFRQ = 1.4204E9" + }, + NAXIS1K, + true)); + } + + @Test + void velocityLogAxis() { + assertProbe( + "vrad_log", + readHead( + new String[] { + "NAXIS = 1", + "NAXIS1 = 100", + "CTYPE1 = 'VRAD-LOG'", + "CUNIT1 = 'km/s'", + "CRPIX1 = 50", + "CRVAL1 = 1000.0", + "CDELT1 = 2.0", + "SPECSYS = 'LSRK'", + "RESTFRQ = 1.4204E9" + }, + NAXIS1, + false)); + } + + /** + * The fixture {@code wcsconv/inputs/freq-log.head}: its logarithmic increment is so small that + * the axis is linear, and C writes it back as a linear FREQ axis in GHz, since over its range + * of 1 Hz at 1.42e9 Hz IsMapLinear does not find the conversion from Hz to GHz linear. + */ + @Test + void freqLogFixtureIsWrittenAsLinear() { + FitsChan fc = FitsHeaders.fixture("wcsconv/inputs/freq-log.head"); + FrameSet fs = FitsHeaders.readFrameSet(fc); + List out = new ArrayList<>(); + trans(out, fs, true); + writeback(out, fs, "FITS-WCS", NAXIS1K, true); + assertProbe("freq_log_head", text(out)); + } + + /** + * The write leaves the Unit of the FrameSet given as it was: C's {@code SpectralAxes} clears + * the Unit of the FrameSet it describes, which is not the caller's. + */ + @Test + void writingLeavesTheUnitOfTheFrameSet() { + FrameSet fs = FitsHeaders.readFrameSet(FitsHeaders.fixture("wcsconv/inputs/freq-log.head")); + List out = new ArrayList<>(); + out.add("unit before " + fs.getC("Unit(1)") + " test " + (fs.test("Unit(1)") ? 1 : 0)); + FitsChan fc = new FitsChan(); + fc.setEncoding("FITS-WCS"); + for (String card : NAXIS1K) { + fc.putFits(card, false); + } + out.add("wrote " + fc.write(fs)); + out.add("unit after " + fs.getC("Unit(1)") + " test " + (fs.test("Unit(1)") ? 1 : 0)); + assertProbe("freq_log_head_unit", text(out)); + } + + /** {@code FitsSpectralAxesTest.nonlinearUnitIsCleared}'s FrameSet, written with FITS-WCS. */ + @Test + void logUnitAxisOfAUnitMapIsWrittenAsLog() { + SpecFrame sf = new SpecFrame(); + sf.set("System=FREQ,Unit(1)=log(Hz)"); + FrameSet fs = frameSet(2, new UnitMap(2), new CmpFrame(new Frame(1), sf)); + List out = new ArrayList<>(); + writeback(out, fs, "FITS-WCS", NAXIS2, false); + out.add("unit after " + fs.getC("Unit(2)")); + assertProbe("write_log_unit_unitmap", text(out)); + } + + @Test + void exponentialAxisIsWrittenAsLog() { + Frame world = new Frame(1); + world.setDomain("WORLD"); + assertProbe("write_other_exp", written(frameSet(1, exponential(10.0, 0.01), world), NAXIS1, false)); + } + + @Test + void exponentialFrequencyAxisIsWrittenAsLog() { + SpecFrame sf = new SpecFrame(); + sf.set("System=FREQ"); + assertProbe("write_freq_exp", written(frameSet(1, exponential(1.4, 0.001), sf), NAXIS1, false)); + } + + @Test + void mathMapFrequencyAxisIsWrittenAsLog() { + MathMap mm = new MathMap( + 1, 1, new String[] {"s = 1.4204e9 * exp( p * 1.0e-4 )"}, new String[] {"p = 1.0e4 * log( s / 1.4204e9 )" + }); + SpecFrame sf = new SpecFrame(); + sf.set("System=FREQ,Unit=Hz,StdOfRest=Bary,RestFreq=1.4204e9 Hz"); + assertProbe("write_mathmap_freq", written(frameSet(1, mm, sf), NAXIS1K, true)); + } + + @Test + void logUnitFrequencyAxisIsWrittenAsLog() { + SpecFrame sf = new SpecFrame(); + sf.set("System=FREQ,Unit=log(Hz)"); + CmpFrame cf = new CmpFrame(new Frame(1), sf); + Mapping map = new CmpMap( + new MatrixMap(2, 2, new double[] {1.0, 0.001}), new ShiftMap(new double[] {0.0, 8.95}), true); + assertProbe("write_log_unit", written(frameSet(2, map, cf), NAXIS2, false)); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/FitsLogMapTest.java b/src/test/java/uk/ac/starlink/ast/FitsLogMapTest.java deleted file mode 100644 index 500bc54..0000000 --- a/src/test/java/uk/ac/starlink/ast/FitsLogMapTest.java +++ /dev/null @@ -1,66 +0,0 @@ -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.assertTrue; - -import org.junit.jupiter.api.Test; - -/** - * {@link FitsLogMap} transforms as the MathMap {@code logs=log(s)}, {@code s=exp(logs)} of C's - * {@code LogAxis} (fitschan.c) does. The values expected are those of that MathMap in the pinned C - * library (C probe {@code mm.c} of the final review fixes), to within one unit in the last place, - * by which {@link Math#log} and {@link Math#exp} may differ from the C library's. - */ -class FitsLogMapTest { - - private static final double BAD = AstObject.AST__BAD; - - @Test - void forwardIsTheNaturalLogarithmAndBadForNoPositiveValue() { - double[] in = {0.0, -1.0, BAD, 1.0, 1e308, Double.NaN, 1000.0, -1000.0, 709.8}; - double[] want = {BAD, BAD, BAD, 0.0, 709.1962086421661, BAD, 6.907755278982137, BAD, 6.564983240212396}; - double[] got = new FitsLogMap().tran1(in.length, in, true); - for (int i = 0; i < in.length; i++) { - assertEquals(want[i], got[i], Math.ulp(want[i]), "log(" + in[i] + ")"); - } - } - - @Test - void inverseIsTheExponentialAndBadOnOverflow() { - // C's evaluator gives AST__BAD for an exponential that overflows, where the C library - // reports the overflow in errno; the pinned build on macOS, whose libm does not set errno, - // gives an infinity for 1000 and 709.8. - double[] in = {0.0, -1.0, BAD, 1.0, 1e308, Double.NaN, 1000.0, -1000.0, 709.8}; - double[] want = {1.0, 0.36787944117144233, BAD, 2.718281828459045, BAD, BAD, BAD, 0.0, BAD}; - double[] got = new FitsLogMap().tran1(in.length, in, false); - for (int i = 0; i < in.length; i++) { - assertEquals(want[i], got[i], Math.ulp(want[i]), "exp(" + in[i] + ")"); - } - } - - @Test - void invertingSwapsTheDirections() { - FitsLogMap m = new FitsLogMap(); - m.invert(); - assertEquals(2.718281828459045, m.tran1(1, new double[] {1.0}, true)[0], Math.ulp(2.718281828459045)); - assertEquals(6.907755278982137, m.tran1(1, new double[] {1000.0}, false)[0], Math.ulp(6.907755278982137)); - } - - @Test - void neverMergesWithItsNeighbours() { - // A MathMap merges only with another MathMap (mathmap.c MapMerge), and no FrameSet of this - // library holds one, so the Mapping is left in place whatever its neighbours. - FitsLogMap log = new FitsLogMap(); - Mapping s = new CmpMap(new ZoomMap(1, 2.0), new CmpMap(log, new UnitMap(1), true), true).simplify(); - assertInstanceOf(CmpMap.class, s); - Mapping[] parts = s.decompose(null, null); - assertInstanceOf(ZoomMap.class, parts[0]); - assertInstanceOf(FitsLogMap.class, parts[1]); - assertFalse(log.isLinear()); - assertTrue(log.getTranForward() && log.getTranInverse()); - assertEquals(1, log.getNin()); - assertEquals(1, log.getNout()); - } -} diff --git a/src/test/java/uk/ac/starlink/ast/FitsMapTabTest.java b/src/test/java/uk/ac/starlink/ast/FitsMapTabTest.java index 1f71b7a..68206c7 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsMapTabTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsMapTabTest.java @@ -51,6 +51,31 @@ void aSeparableAxisWithAnUnknownDimensionIsNotTabulated() { assertFalse(win.getInvert()); } + /** + * A grid to WCS Mapping holding a LutMap applied forward: C takes the table from the LutMap, + * and its interpolation method, whether or not the grid dimension is known, and makes a + * FitsTable for it, which needs FitsTable. An inverted LutMap is not used, so with the + * dimension unknown the axis is not tabulated. + */ + @Test + void aLutMapIsTabulatedWithoutTheGridDimension() { + LutMap lut = new LutMap(new double[] {0.0, 1.0, 4.0, 9.0}, 1.0, 1.0); + lut.setI("LutInterp", 1); + CmpMap map = new CmpMap(new ZoomMap(1, 2.0), lut, true); + int[] interp = {5}; + UnsupportedOperationException e = assertThrows( + UnsupportedOperationException.class, + () -> FitsMapTab.isMapTab1D( + map, 1.0, null, new Frame(1), new double[] {BAD}, 0, 0, new int[1], new int[1], interp)); + assertTrue(e.getMessage().endsWith("needs FitsTable"), e.getMessage()); + assertEquals(1, interp[0]); + assertFalse(map.getInvert()); + + LutMap inv = new LutMap(new double[] {0.0, 1.0, 4.0, 9.0}, 1.0, 1.0); + inv.invert(); + assertNull(isMapTab1D(new CmpMap(new ZoomMap(1, 2.0), inv, true), new double[] {BAD}, 0)); + } + /** An output that depends on two grid axes cannot be split off, so is not tabulated. */ @Test void aNonSeparableAxisIsNotTabulated() { diff --git a/src/test/java/uk/ac/starlink/ast/FitsOtherAxesTest.java b/src/test/java/uk/ac/starlink/ast/FitsOtherAxesTest.java index f2cf581..b55cb0e 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsOtherAxesTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsOtherAxesTest.java @@ -4,6 +4,7 @@ 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.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -16,10 +17,7 @@ * fitschan.c) that need no class this library lacks, and tests of the branches that reach one. * Expectations not from a Rust test are worked from C's code. * - *

{@code log_axis.rs} {@code detects_log_axis_and_returns_inverse_mapping} builds its - * logarithmic axis with a MathMap; here it is a PolyMap, and where C goes on to build the {@code - * -LOG} Mapping, which holds a MathMap, the translation expects the throw {@code needs MathMap}. Not - * translated: {@code out_of_range_axis_returns_none}, a check C does not make. + *

Not translated: {@code out_of_range_axis_returns_none}, a check C does not make. */ class FitsOtherAxesTest { @@ -223,18 +221,22 @@ void slightlyNonLinearAxisIsDescribedAsLinear() { } @Test - void logarithmicAxisNeedsMathMap() { - // C probe loglin.c: 10 exp(0.01 p) is written as WORL-LOG, whose Mapping holds a MathMap. - UnsupportedOperationException e = assertThrows( - UnsupportedOperationException.class, - () -> otherAxes( - new FitsChan(), - frameSet(exponential(10, 0.01), new Frame(1)), - new double[] {100}, - new FitsStore(1), - null, - new boolean[1])); - assertTrue(e.getMessage().endsWith("needs MathMap"), e.getMessage()); + void logarithmicAxisIsDescribedWithLog() { + // C probe fitslog_probe case write_other_exp: 10 exp(0.01 p) is written as WORL-LOG with + // CRVAL1 the world value at the centre pixel, 50. + Frame world = new Frame(1); + world.setDomain("WORLD"); + FitsStore store = new FitsStore(1); + boolean[] axisDone = new boolean[1]; + Mapping map = otherAxes( + new FitsChan(), frameSet(exponential(10, 0.01), world), new double[] {100}, store, null, axisDone); + assertTrue(axisDone[0]); + assertEquals("WORL-LOG", store.ctype[0]); + assertEquals(16.48721270700128, store.crval[0], 1e-12); + // LogAxis's Mapping w = Sr log(S/Sr), Sr the CRVAL. + double sr = store.crval[0]; + assertEquals(0.0, map.tran1(1, new double[] {sr}, true)[0], 1e-14); + assertEquals(sr * 0.1, map.tran1(1, new double[] {sr * Math.exp(0.1)}, true)[0], 1e-13); } /** Rust {@code log_axis.rs} {@code linear_axis_is_not_log}. */ @@ -245,17 +247,24 @@ void linearAxisIsNotLog() { } /** - * Rust {@code log_axis.rs} {@code detects_log_axis_and_returns_inverse_mapping}, with axis 1 - * {@code 2 exp(0.1 p)} from a PolyMap: the axis passes C's test, and the Mapping C then - * returns holds a MathMap. + * Rust {@code log_axis.rs} {@code detects_log_axis_and_returns_inverse_mapping}: axis 1 is + * {@code 2 exp(0.1 p)}, and the Mapping returned is {@code w = 2 log(S/2)} on it, a UnitMap on + * axis 0. */ @Test - void detectsLogAxis() { - Mapping map = new CmpMap(new UnitMap(1), exponential(2.0, 0.1), false); - UnsupportedOperationException e = assertThrows( - UnsupportedOperationException.class, - () -> FitsOtherAxes.logAxis(map, 1, 2, new double[] {1, 1}, new double[] {10, 10}, 2.0)); - assertTrue(e.getMessage().endsWith("needs MathMap"), e.getMessage()); + void detectsLogAxisAndReturnsInverseMapping() { + double sr = 2.0; + double slope = 0.1; + MathMap m = new MathMap(2, 2, new String[] {"s0=x1", "s1=" + sr + "*exp(" + slope + "*x2)"}, new String[] { + "x1=s0", "x2=log(s1/" + sr + ")/" + slope + }); + Mapping mapping = FitsOtherAxes.logAxis(m, 1, 2, new double[] {1, 1}, new double[] {10, 10}, sr); + assertNotNull(mapping); + assertEquals(2, mapping.getNin()); + assertEquals(2, mapping.getNout()); + double[][] out = mapping.transform(new double[][] {{3.0}, {sr * Math.exp(slope * 10.0)}}, 1, true); + assertEquals(3.0, out[0][0], 1e-9); + assertEquals(2.0, out[1][0], 1e-6); } @Test diff --git a/src/test/java/uk/ac/starlink/ast/FitsSpectralAxesTest.java b/src/test/java/uk/ac/starlink/ast/FitsSpectralAxesTest.java index 756bb8f..6242cc0 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsSpectralAxesTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsSpectralAxesTest.java @@ -5,6 +5,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -25,10 +26,11 @@ * *

The Rust tests' expectations are checked against the cards C writes for the same FrameSets. * {@code x2p_cascade_picks_freq_for_wavelength_axis} builds its axis with a MathMap; here the - * frequency axis is set to wavelength through the FrameSet, as {@code testfitschan.c} does. {@code - * nonlinear_unit_is_cleared} sets the Unit {@code log(Hz)}, whose conversion to the default Unit is - * the MathMap C builds, so it expects {@code needs MathMap}. Listed in {@code - * deferred/rust-tests.txt}: {@code try_grism_cascade_emits_gri_pv_and_chain} (GrismMap). + * frequency axis is set to wavelength through the FrameSet, as {@code testfitschan.c} does. Rust's + * {@code try_grism_cascade_emits_gri_pv_and_chain} calls a helper this library does not have; + * here the whole of {@code SpectralAxes} describes its axis, through a grism non-linear enough + * that the linear, {@code -X2P} and {@code -LOG} algorithms fail first. The unit tests of Rust + * {@code fitschan/fset_to_store/grism.rs} test {@link FitsSpectralAxes#extractGrismMap}. */ class FitsSpectralAxesTest { @@ -597,19 +599,46 @@ void linearUnitMhzPreservesUserCunit() { } @Test - void nonlinearUnitNeedsMathMap() { - // The conversion from log(Hz) to the default Unit is the MathMap C builds. - UnsupportedOperationException e = assertThrows( - UnsupportedOperationException.class, - () -> spectralAxes( - twoAxis(spec("System=FREQ,Unit(1)=log(Hz)"), null), - new double[] {100, 100}, - new FitsStore(2), - new double[] {BAD, 9.0}, - new boolean[2])); - assertTrue(e.getMessage().endsWith("needs MathMap"), e.getMessage()); + void nonlinearUnitIsCleared() { + // The conversion from log(Hz) to the default Unit is not linear, so C clears the Unit: + // CUNIT is the default, GHz, and the CRVAL of 9 (log10 of 1 GHz in Hz) is converted to it. + // The axis, linear in log(Hz), is exponential in GHz, and C writes it with -LOG (C probe + // fitslog_probe, case write_log_unit_unitmap, writes this FrameSet: C_LOG_UNIT). + FitsStore store = new FitsStore(2); + spectralAxes( + twoAxis(spec("System=FREQ,Unit(1)=log(Hz)"), null), + new double[] {100, 100}, + store, + new double[] {BAD, 9.0}, + new boolean[2]); + assertEquals("GHz", store.cunit[1]); + assertEquals(1.0, store.crval[1], 1e-9); + assertEquals("FREQ-LOG", store.ctype[1]); + assertWritesAsC(C_LOG_UNIT, twoAxis(spec("System=FREQ,Unit(1)=log(Hz)"), null), "", 100, 100); } + /** + * C's cards for a FREQ axis in log(Hz) that is the second pixel axis (C probe {@code + * fitslog_probe}, case {@code write_log_unit_unitmap}). + */ + private static final String[] C_LOG_UNIT = { + "wrote 1", + "NAXIS = 2", + "NAXIS1 = 100", + "NAXIS2 = 100", + "CRPIX1 = 50.0 / Reference pixel on axis 1", + "CRPIX2 = 100.0 / Reference pixel on axis 2", + "CRVAL1 = 50.0 / Value at ref. pixel on axis 1", + "CRVAL2 = 1.0E+91 / Value at ref. pixel on axis 2", + "CTYPE1 = 'x1 ' / Type of co-ordinate on axis 1", // codespell:ignore + "CTYPE2 = 'FREQ-LOG' / Type of co-ordinate on axis 2", // codespell:ignore + "CDELT1 = 1.0 / Pixel size on axis 1", + "CDELT2 = 2.3025850929940716E+91 / Pixel size on axis 2", + "CUNIT2 = 'GHz ' / Units for axis 2", + "SPECSYS = 'HELIOCEN' / Standard of rest for spectral axis", + "VELOSYS = 29336.889452278185 / [m/s] Topo. apparent velocity of rest frame", + }; + @Test void x2pCascadePicksFreqForWavelengthAxis() { // Pixel axis 2 linear in frequency, 1e9 + 1e6 p Hz, the SpecFrame then set to wavelength @@ -740,13 +769,23 @@ void sourceVelocityKeepsItsRestFrame() { assertEquals(-200.0, sf.getSourceVel(), 1e-9); } + /** C's cards for an exponential frequency axis (C probe {@code fitslog_probe}, case {@code write_freq_exp}). */ + private static final String[] C_LOG = { + "wrote 1", + "NAXIS = 1", + "NAXIS1 = 100", + "CRPIX1 = 52.0 / Reference pixel on axis 1", + "CRVAL1 = 1.4747260395187105 / Value at ref. pixel on axis 1", + "CTYPE1 = 'FREQ-LOG' / Type of co-ordinate on axis 1", // codespell:ignore + "CDELT1 = 0.0014747260395187112 / Pixel size on axis 1", + "CUNIT1 = 'GHz ' / Units for axis 1", + "SPECSYS = 'HELIOCEN' / Standard of rest for spectral axis", + "VELOSYS = 29336.889452278185 / [m/s] Topo. apparent velocity of rest frame", + }; + @Test - void logarithmicAxisNeedsMathMap() { - // C probe case log: C writes FREQ-LOG, whose Mapping holds a MathMap. - UnsupportedOperationException e = assertThrows( - UnsupportedOperationException.class, - () -> written(oneAxis(spec("System=FREQ"), exponential(1.4, 0.001)), "", 100, 0)); - assertTrue(e.getMessage().endsWith("needs MathMap"), e.getMessage()); + void logarithmicAxisIsWrittenAsLog() { + assertWritesAsC(C_LOG, oneAxis(spec("System=FREQ"), exponential(1.4, 0.001)), "", 100, 0); } @Test @@ -797,4 +836,125 @@ void getFitsSorNamesEachStandardOfRest() { } assertNull(FitsSpectralAxes.getFitsSor("lsrk")); } + + // ------------------------------------------------------------------ + // spectral_axes.rs: try_grism_cascade_emits_gri_pv_and_chain + // ------------------------------------------------------------------ + + /** A GrismMap of a grating of 9e5 rulings per metre, first order, about 5e-7 m. */ + private static GrismMap grating() { + GrismMap g = new GrismMap(); + g.set("GrismG=9.0E5,GrismM=1,GrismWaveR=5.0E-7"); + return g; + } + + /** + * A wavelength axis whose Mapping from pixels ends in a GrismMap is described with the {@code + * -GRI} algorithm: CRVAL is the GrismMap's reference wavelength and PVi_0 and PVi_1 its + * GrismG and GrismM, as C writes them for the same axis alone (probe {@code + * probes/grismmap_probe.c}, case {@code write_shift_zoom_grism}). + */ + @Test + void tryGrismCascadeEmitsGriPvAndChain() { + GrismMap g = grating(); + Mapping chain1d = + new CmpMap(new CmpMap(new ShiftMap(new double[] {-50.0}), new ZoomMap(1, 0.002), true), g, true); + Mapping chain2d = new CmpMap(new UnitMap(1), chain1d, false); + FitsStore store = new FitsStore(2); + boolean[] axisDone = new boolean[2]; + Mapping axmap = spectralAxes( + twoAxis(spec("System=WAVE,Unit=m"), chain2d), new double[] {100, 100}, store, null, axisDone); + assertTrue(axisDone[1]); + assertEquals("WAVE-GRI", store.ctype[1]); + assertEquals(2, axmap.getNin()); + assertEquals(2, axmap.getNout()); + // C's CRVAL1, the GrismMap's reference wavelength (case write_shift_zoom_grism). + assertEquals(5.0e-7, store.crval[1]); + assertEquals(9.0e5, store.pv[1][0]); + assertEquals(1.0, store.pv[1][1]); + for (int m = 2; m < store.pv[1].length; m++) { + assertNull(store.pv[1][m], "PV2_" + m + " is the default and is not stored"); + } + } + + // ------------------------------------------------------------------ + // fitschan/fset_to_store/grism.rs: ExtractGrismMap + // ------------------------------------------------------------------ + + @Test + void leafGrismExtracted() { + GrismMap g = new GrismMap(); + Mapping[] replacement = new Mapping[1]; + GrismMap extracted = FitsSpectralAxes.extractGrismMap(g, 0, replacement); + assertInstanceOf(UnitMap.class, replacement[0]); + assertEquals(1, replacement[0].getNin()); + assertEquals(1, replacement[0].getNout()); + // C clones the GrismMap: the one extracted is the one given. + assertSame(g, extracted, "the GrismMap is shared, as C clones it"); + } + + @Test + void invertedGrismNotExtracted() { + GrismMap g = new GrismMap(); + g.invert(); + Mapping[] replacement = new Mapping[1]; + assertNull(FitsSpectralAxes.extractGrismMap(g, 0, replacement)); + assertNull(replacement[0]); + } + + @Test + void shiftThenGrismInSeriesExtracts() { + GrismMap g = new GrismMap(); + CmpMap chain = new CmpMap(new ShiftMap(new double[] {3.5}), g, true); + Mapping[] replacement = new Mapping[1]; + GrismMap extracted = FitsSpectralAxes.extractGrismMap(chain, 0, replacement); + assertSame(g, extracted, "the GrismMap at the end is extracted"); + assertEquals(1, replacement[0].getNin()); + assertEquals(1, replacement[0].getNout()); + assertEquals(4.5, replacement[0].tran1(1, new double[] {1.0}, true)[0]); + } + + /** The output of a GrismMap followed by a ShiftMap is changed after it, so it is not extracted. */ + @Test + void grismThenShiftInSeriesDoesNotExtract() { + CmpMap chain = new CmpMap(new GrismMap(), new ShiftMap(new double[] {3.5}), true); + assertNull(FitsSpectralAxes.extractGrismMap(chain, 0, new Mapping[1])); + } + + @Test + void parallelGrismOnAxisOneExtracts() { + GrismMap g = new GrismMap(); + CmpMap chain = new CmpMap(new UnitMap(1), g, false); + Mapping[] replacement = new Mapping[1]; + GrismMap extracted = FitsSpectralAxes.extractGrismMap(chain, 1, replacement); + assertSame(g, extracted, "the GrismMap producing output 1 is extracted"); + assertEquals(2, replacement[0].getNin()); + assertEquals(2, replacement[0].getNout()); + } + + @Test + void parallelGrismWrongAxisDoesNotExtract() { + CmpMap chain = new CmpMap(new UnitMap(1), new GrismMap(), false); + assertNull(FitsSpectralAxes.extractGrismMap(chain, 0, new Mapping[1])); + } + + @Test + void noGrismAnywhereReturnsNone() { + CmpMap chain = new CmpMap(new ShiftMap(new double[] {1.0}), new UnitMap(1), true); + assertNull(FitsSpectralAxes.extractGrismMap(chain, 0, new Mapping[1])); + } + + /** + * Each component is set, for the search, to the Invert value it had when the CmpMap was made, + * as C sets it: a GrismMap inverted after it was combined is still found, and is left with the + * Invert value it had. + */ + @Test + void aComponentIsSearchedAsItWasCombined() { + GrismMap g = new GrismMap(); + CmpMap chain = new CmpMap(new ShiftMap(new double[] {1.0}), g, true); + g.invert(); + assertSame(g, FitsSpectralAxes.extractGrismMap(chain, 0, new Mapping[1])); + assertTrue(g.getInvert()); + } } diff --git a/src/test/java/uk/ac/starlink/ast/FitsWcsReadTest.java b/src/test/java/uk/ac/starlink/ast/FitsWcsReadTest.java index 785a762..405f83a 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsWcsReadTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsWcsReadTest.java @@ -9,7 +9,10 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.List; +import java.util.Map; import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.ProbeOutput; /** * Translates the unit tests of Rust {@code fitschan/wcs_read.rs} ({@code mod tests}), which build @@ -36,7 +39,15 @@ private static FitsStore celestial2dStore() { /** Rust's test helper {@code decode_wcs}: the primary description of {@code store} alone. */ private static FrameSet decodeWcs(FitsStore store) { return FitsWcsRead.decodeWcsInner( - store, store.naxis, false, false, new FitsCardList(), ' ', 0, new FitsWarnings(), new ArrayList<>()); + store, + store.naxis, + false, + false, + new FitsCardList(), + ' ', + new FitsChan(), + new FitsWarnings(), + new ArrayList<>()); } @Test @@ -56,15 +67,119 @@ void decodeCrpixMapsToCrval() { assertEquals(Math.toRadians(45.0), out[1][0], 1e-4); } + /** + * With TabOK above zero C's {@code TabMapping} needs the name of the table holding a {@code + * -TAB} axis's coordinates, PS{@code i}_0, and reports AST__NOFTS without it. + */ @Test - void tabAxisNeedsLutMapWhenTabOkIsPositive() { + void tabAxisNeedsItsTableName() { FitsStore store = new FitsStore(1); store.ctype[0] = "WAVE-TAB"; - UnsupportedOperationException e = assertThrows( - UnsupportedOperationException.class, + FitsChan fc = new FitsChan(); + fc.setI("TabOK", 1); + AstException e = assertThrows( + AstException.class, () -> FitsWcsRead.decodeWcsInner( - store, 1, false, false, new FitsCardList(), ' ', 1, new FitsWarnings(), new ArrayList<>())); - assertTrue(e.getMessage().endsWith(" needs LutMap"), e.getMessage()); + store, 1, false, false, new FitsCardList(), ' ', fc, new FitsWarnings(), new ArrayList<>())); + assertEquals(AstException.AST__NOFTS, e.getStatus()); + assertEquals("astRead(FitsChan): No value can be found for PS1_0 .", e.getMsgText()); + } + + /** + * With TabOK above zero and the table named, C's {@code GetNamedTable} looks for the table in + * the FitsChan, which holds none, and reports AST__NOTAB with the extension version and level + * of PV{@code i}_1 and PV{@code i}_2 (default 1). + */ + @Test + void tabAxisNeedsItsTable() { + FitsStore store = new FitsStore(1); + store.ctype[0] = "WAVE-TAB"; + store.ps[0][0] = "WCS-TAB"; + store.pv[0][1] = 3.0; + FitsChan fc = new FitsChan(); + fc.setI("TabOK", 1); + AstException e = assertThrows( + AstException.class, + () -> FitsWcsRead.decodeWcsInner( + store, 1, false, false, new FitsCardList(), ' ', fc, new FitsWarnings(), new ArrayList<>())); + assertEquals(AstException.AST__NOTAB, e.getStatus()); + assertEquals( + "astRead(FitsChan): Failed to read FITS binary table from extension 'WCS-TAB' (extver=3," + + " extlevel=1).", + e.getMsgText()); + } + + /** + * The reads of {@code -TAB} headers in the probe {@code probes/lutmap_probe.c}: with TabOK set + * and no tables C's read fails, with the status and message the probe prints, for a spectral + * axis, an axis of another kind, and an alternate description (IgnoreBadAlt being unset); with + * TabOK unset an axis of another kind is read as linear. + */ + @Test + void tabHeadersReadAsC() { + Map probe = ProbeOutput.load("lutmap_probe"); + String[] common = { + "NAXIS = 1", "NAXIS1 = 10", "CRPIX1 = 1", "CDELT1 = 1.0E6", "CTYPE1 = 'WAVE-TAB'", "CRVAL1 = 1.4E9" + }; + String[][] h1 = {common, {"PS1_0 = 'WCS-TAB'"}}; + String[] other = { + "NAXIS = 2", + "NAXIS1 = 10", + "NAXIS2 = 10", + "CRPIX1 = 1", + "CRPIX2 = 1", + "CDELT1 = 1.0", + "CDELT2 = 1.0", + "CTYPE1 = 'XPOS'", + "CTYPE2 = 'YPOS-TAB'", + "CRVAL1 = 0.0", + "CRVAL2 = 0.0", + "PS2_0 = 'TABLE2'", + "PV2_1 = 3", + "PV2_2 = 2" + }; + String[] alternate = { + "NAXIS = 1", + "NAXIS1 = 10", + "CRPIX1 = 1", + "CDELT1 = 1.0", + "CTYPE1 = 'XPOS'", + "CRVAL1 = 0.0", + "CRPIX1A = 1", + "CDELT1A = 1.0E6", + "CTYPE1A = 'WAVE-TAB'", + "CRVAL1A = 1.4E9", + "PS1_0A = 'WCS-TAB'" + }; + assertEquals(probe.get("tab_spectral"), tabRead(concat(h1), 1)); + assertEquals(probe.get("tab_no_extname"), tabRead(common, 1)); + assertEquals(probe.get("tab_other_extver"), tabRead(other, 1)); + assertEquals(probe.get("tab_other_tabok0"), tabRead(other, 0)); + assertEquals(probe.get("tab_alternate"), tabRead(alternate, 1)); + } + + private static String[] concat(String[][] parts) { + List all = new ArrayList<>(); + for (String[] p : parts) { + all.addAll(Arrays.asList(p)); + } + return all.toArray(new String[0]); + } + + /** What the probe's {@code tabread} prints for a read of {@code cards} with TabOK {@code tabOk}. */ + private static String tabRead(String[] cards, int tabOk) { + FitsChan fc = FitsHeaders.chan(cards); + if (tabOk != 0) { + fc.setI("TabOK", tabOk); + } + AstObject obj; + try { + obj = fc.read(); + } catch (AstException e) { + return "! AST: Error in routine tabread at line 75 in file lutmap_probe.c.\n! " + e.getMsgText() + + "\nread status " + e.getStatus() + "\n"; + } + return "nframe " + ((FrameSet) obj).getNframe() + "\n"; } @Test @@ -130,13 +245,20 @@ void buildPixelToWorldHandlesNonAdjacentCelestialAxes() { assertEquals(83.6, Math.toDegrees(out[2]), 1e-9); } + /** + * fitschan.c WcsOthers maps an axis whose CTYPE ends in "-LOG" with LogWcs's MathMap {@code + * s=Sr*exp(w/Sr)}, Sr the CRVAL; with CRPIX 0 and CDELT 1 the intermediate world coordinate is + * the pixel coordinate. + */ @Test - void logAxisNeedsMathMap() { + void logAxisIsExponentialInTheIntermediateWorldCoordinate() { FitsStore store = new FitsStore(1); store.ctype[0] = "X-LOG"; store.crval[0] = 2.0; - UnsupportedOperationException e = assertThrows(UnsupportedOperationException.class, () -> decodeWcs(store)); - assertTrue(e.getMessage().endsWith(" needs MathMap"), e.getMessage()); + FrameSet fs = decodeWcs(store); + double[] out = FitsHeaders.tran(fs, new double[] {3.0}, true); + assertEquals(2.0 * Math.exp(1.5), out[0], 1e-15); + assertEquals(3.0, FitsHeaders.tran(fs, out, false)[0], 1e-14); } @Test diff --git a/src/test/java/uk/ac/starlink/ast/FitsWcsSpectralTest.java b/src/test/java/uk/ac/starlink/ast/FitsWcsSpectralTest.java index e2d18e4..4ef04e1 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsWcsSpectralTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsWcsSpectralTest.java @@ -15,9 +15,9 @@ * fitschan/wcs_spectral.rs} ({@code mod tests}), which build FitsStores directly, and reads of * spectral headers through a FitsChan compared with what C's {@code astRead} gives for the same * cards (the SpecFrame's attributes as {@code astGetC} formats them, the pixel to world transform, - * and the error status and messages), including the read half of the plan's Review Focus 5: a - * spectral axis whose Mapping needs a class that is not available ({@code -LOG} through MathMap, - * {@code -GRI} through GrismMap, {@code -TAB} through LutMap) fails with {@code needs }. + * and the error status and messages). Grism axes ({@code -GRI} and {@code -GRA}) are read as the + * C probe {@code probes/grismmap_probe.c} reads them. A {@code -TAB} axis with TabOK set fails as + * in C, since the FitsChan holds no table. */ class FitsWcsSpectralTest { @@ -452,39 +452,171 @@ void unknownSsyssrcIsAnError() { // Review Focus 5, read half: spectral axes needing absent classes // ------------------------------------------------------------------ - /** C maps a {@code -LOG} spectral axis with a non-zero CRVAL with a MathMap (C's LogWcs). */ + /** + * C maps a {@code -LOG} spectral axis with a non-zero CRVAL with LogWcs's MathMap {@code + * s=Sr*exp(w/Sr)}, Sr the CRVAL, written with C's {@code %.17g}. + */ @Test - void logSpectralAxisNeedsMathMap() { - UnsupportedOperationException e = assertThrows( - UnsupportedOperationException.class, - () -> oneAxis("CTYPE1 = 'FREQ-LOG'", "CRVAL1 = 1.4E9").read()); - assertTrue(e.getMessage().endsWith(" needs MathMap"), e.getMessage()); + void logSpectralAxisIsAMathMap() { + FrameSet fs = + (FrameSet) oneAxis("CTYPE1 = 'FREQ-LOG'", "CRVAL1 = 1.4E9").read(); + String dump = ChannelText.dump(fs.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT)); + assertTrue(dump.contains("Fwd1 = \"s=1400000000*exp(w/1400000000)\""), dump); + assertTrue(dump.contains("Inv1 = \"w=1400000000*log(s/1400000000)\""), dump); + assertTrue(dump.contains("SimpFI = 1") && dump.contains("SimpIF = 1"), dump); + } + + /** The cases of the C probe {@code probes/grismmap_probe.c}. */ + private static final java.util.Map GRISM_PROBE = + uk.ac.starlink.ast.testsupport.ProbeOutput.load("grismmap_probe"); + + /** + * What the probe's {@code fitsrw} prints for the read of {@code cards} with FITS-WCS: the + * class read, pixels 1, 50 and 100 transformed forward and back, and the simplified Mapping. + */ + private static String grismRead(String... cards) { + FitsChan fc = FitsHeaders.chan(cards); + fc.setEncoding("FITS-WCS"); + FrameSet fs = (FrameSet) fc.read(); + double[] pix = {1.0, 50.0, 100.0}; + double[] w = fs.tran1(3, pix, true); + double[] back = fs.tran1(3, w, false); + StringBuilder sb = new StringBuilder("read ").append(fs.astClass()).append('\n'); + for (int i = 0; i < 3; i++) { + sb.append("pixel ") + .append(CFormat.format("%.17g", pix[i])) + .append(" -> ") + .append(CFormat.format("%.17g", w[i])) + .append(" -> ") + .append(CFormat.format("%.17g", back[i])) + .append('\n'); + } + return sb.append(ChannelText.dump( + fs.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT).simplify())) + .toString(); + } + + /** The read part of the probe case {@code name}, up to what the write gives. */ + private static String grismProbeRead(String name) { + String text = GRISM_PROBE.get(name); + return text.substring(0, text.indexOf("-- written")); } - /** C maps a {@code -GRI} axis with a GrismMap once the SpecFrame converts to wavelength. */ + private static void assertGrismRead(String name, String got) { + String want = grismProbeRead(name); + if (!FitsChanWcsWriteTest.grismMatchesC(got, want)) { + assertEquals(want, got, name); + } + } + + /** + * C maps a {@code -GRI} or {@code -GRA} axis with an inverted GrismMap, whose attributes come + * from PVi_0 to PVi_6, following a WinMap from the intermediate world coordinate to the grism + * parameter; the transformations are C's (probe {@code probes/grismmap_probe.c}, within the + * tolerance {@link FitsChanWcsWriteTest#grismMatchesC} explains). + */ @Test - void grismAxisNeedsGrismMap() { - for (String ctype : new String[] {"WAVE-GRI", "WAVE-GRA"}) { - UnsupportedOperationException e = assertThrows( - UnsupportedOperationException.class, - () -> oneAxis( - "CTYPE1 = '" + ctype + "'", - "CRVAL1 = 5.0E-7", - "CDELT1 = 1.0E-10", - "PV1_0 = 3.0E5", - "PV1_1 = 1") - .read()); - assertTrue(e.getMessage().endsWith(" needs GrismMap"), e.getMessage()); + void grismAxesAreReadAsC() { + assertGrismRead( + "fits_gri_FITS-WCS", + grismRead( + "CTYPE1 = 'WAVE-GRI'", + "CRVAL1 = 5.0E-7", + "CRPIX1 = 1.0", + "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", + "PV1_0 = 9.0E5", + "PV1_1 = 1.0", + "PV1_2 = 0.0", + "PV1_3 = 1.0", + "PV1_4 = 0.0", + "PV1_5 = 0.0", + "PV1_6 = 0.0")); + assertGrismRead( + "fits_gra_FITS-WCS", + grismRead( + "CTYPE1 = 'AWAV-GRA'", + "CRVAL1 = 5.0E-7", + "CRPIX1 = 10.0", + "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", + "PV1_0 = 6.0E5", + "PV1_1 = -2.0", + "PV1_2 = 10.0", + "PV1_3 = 1.5", + "PV1_4 = -100.0", + "PV1_5 = 2.0", + "PV1_6 = 3.0")); + assertGrismRead( + "fits_gri_half_order", + grismRead( + "CTYPE1 = 'WAVE-GRI'", + "CRVAL1 = 5.0E-7", + "CRPIX1 = 1.0", + "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", + "PV1_0 = 9.0E5", + "PV1_1 = 1.5")); + } + + /** + * C cannot implement a grism axis whose SpecFrame does not convert to wavelength, or whose + * order, rounded half away from zero, puts the reference ray outside the grism, so the rate at + * the reference point is bad. + */ + @Test + void unusableGrismAxesAreRefusedAsC() { + String[][] cases = { + { + "fits_vrad_gri", + "CTYPE1 = 'VRAD-GRI'", + "CRVAL1 = 100.0", + "CRPIX1 = 1.0", + "CDELT1 = 1.0", + "PV1_0 = 9.0E5", + "PV1_1 = 1.0" + }, + { + "fits_gri_negative_half_order", + "CTYPE1 = 'WAVE-GRI'", + "CRVAL1 = 5.0E-7", + "CRPIX1 = 1.0", + "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", + "PV1_0 = 9.0E5", + "PV1_1 = -2.5" + } + }; + for (String[] c : cases) { + FitsChan fc = FitsHeaders.chan(Arrays.copyOfRange(c, 1, c.length)); + fc.setEncoding("FITS-WCS"); + fc.clear("Card"); + AstException e = assertThrows(AstException.class, fc::read, c[0]); + StringBuilder sb = new StringBuilder(); + for (String line : e.getMsgText().split("\n", -1)) { + sb.append("! ").append(line).append('\n'); + } + sb.append("status ").append(e.getStatus()).append('\n'); + String want = GRISM_PROBE.get(c[0]).replaceAll("(?m)^.*AST: Error in routine.*\n", ""); + assertEquals(want, sb.toString(), c[0]); } } - /** With TabOK above zero C reads a {@code -TAB} spectral axis through a LutMap. */ + /** + * With TabOK above zero C reads a {@code -TAB} spectral axis through a LutMap made from the + * table the FitsChan holds; it holds none, so the read fails as C's does (probe {@code + * probes/lutmap_probe.c}, case {@code tab_spectral}). + */ @Test - void tabSpectralAxisNeedsLutMapWithTabOk() { + void tabSpectralAxisWithTabOkNeedsItsTable() { FitsChan fc = oneAxis("CTYPE1 = 'WAVE-TAB'", "CRVAL1 = 1.4E9", "PS1_0 = 'WCS-TAB'"); fc.setI("TabOK", 1); - UnsupportedOperationException e = assertThrows(UnsupportedOperationException.class, fc::read); - assertTrue(e.getMessage().endsWith(" needs LutMap"), e.getMessage()); + AstException e = assertThrows(AstException.class, fc::read); + assertEquals(AstException.AST__NOTAB, e.getStatus()); + assertEquals( + "astRead(FitsChan): Failed to read FITS binary table from extension 'WCS-TAB' (extver=1," + + " extlevel=1).", + e.getMsgText()); } /** diff --git a/src/test/java/uk/ac/starlink/ast/FitsWriteUnsupportedTest.java b/src/test/java/uk/ac/starlink/ast/FitsWriteUnsupportedTest.java index 4246488..94146a1 100644 --- a/src/test/java/uk/ac/starlink/ast/FitsWriteUnsupportedTest.java +++ b/src/test/java/uk/ac/starlink/ast/FitsWriteUnsupportedTest.java @@ -43,34 +43,6 @@ private static void assertNeeds(String cls, FitsChan fc, FrameSet fs) { assertEquals(before, fc.toHeader()); } - /** A 1-D FrameSet whose world axis is the Taylor series to degree 20 of {@code 10 exp(0.01 p)}. */ - private static FrameSet exponential() { - double[] coeffs = new double[21 * 3]; - double term = 10.0; - for (int k = 0; k <= 20; k++) { - coeffs[3 * k] = term; - coeffs[3 * k + 1] = 1; - coeffs[3 * k + 2] = k; - term = term * 0.01 / (k + 1); - } - PolyMap pm = new PolyMap(1, 1, 21, coeffs, 0, new double[0]); - pm.set("IterInverse=1"); - Frame pixel = new Frame(1); - pixel.setDomain("GRID"); - Frame wcs = new Frame(1); - wcs.setDomain("WORLD"); - FrameSet fs = new FrameSet(pixel); - fs.addFrame(FrameSet.AST__BASE, pm, wcs); - return fs; - } - - @Test - void aLogarithmicAxisIsUnsupported() { - // C's LogAxis finds the logarithm of the axis linear and describes it with the -LOG - // algorithm, whose Mapping holds a MathMap (C probe loglin.c: written as WORL-LOG). - assertNeeds("MathMap", chan(""), exponential()); - } - @Test void aNonLinearAxisThatIsNotLogarithmicIsNotWritten() { // C's LogAxis finds the logarithm of this quadratic not linear, and the axis described as diff --git a/src/test/java/uk/ac/starlink/ast/FixtureIntraTransformers.java b/src/test/java/uk/ac/starlink/ast/FixtureIntraTransformers.java new file mode 100644 index 0000000..c015be1 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/FixtureIntraTransformers.java @@ -0,0 +1,83 @@ +package uk.ac.starlink.ast; + +/** + * The four transformation functions the C test programs ({@code simplify.c}, {@code roundtrip.c}, + * {@code ast_astequal.c}, {@code transform_oracle_util.c}) register with {@code astIntraReg} for + * the IntraMap fixtures, with the same names, numbers of coordinates, flags and descriptions. + */ +final class FixtureIntraTransformers { + + private FixtureIntraTransformers() {} + + /** + * C's {@code TestIntraTran}: each output coordinate is the input coordinate of the same index, + * or bad beyond the input coordinates, in either direction. + */ + static final class Identity extends Transformer { + private final boolean fiFlag; + private final boolean ifFlag; + private final String purpose; + + Identity(boolean fiFlag, boolean ifFlag, String purpose) { + this.fiFlag = fiFlag; + this.ifFlag = ifFlag; + this.purpose = purpose; + } + + @Override + public boolean canTransformCoords(int nin, int nout) { + return nin == 1 && nout == 1; + } + + @Override + public boolean simpFI() { + return fiFlag; + } + + @Override + public boolean simpIF() { + return ifFlag; + } + + @Override + public double[][] tranP(int npoint, int ncoordIn, double[][] in, boolean forward, int ncoordOut) { + double[][] out = new double[ncoordOut][npoint]; + for (int ic = 0; ic < ncoordOut; ic++) { + for (int ip = 0; ip < npoint; ip++) { + out[ic][ip] = ic < ncoordIn ? in[ic][ip] : AstObject.AST__BAD; + } + } + return out; + } + + @Override + public String getPurpose() { + return purpose; + } + + @Override + public String getAuthor() { + return "AST test suite"; + } + + @Override + public String getContact() { + return "starlink-ast"; + } + } + + private static final Identity SIMPLIFY_IDENTITY = + new Identity(true, true, "Identity IntraMap for simplify fixtures"); + private static final Identity SIMPLIFY_IDENTITY2 = + new Identity(true, true, "Second identity IntraMap for simplify fixtures"); + private static final Identity NOSIMPFI = new Identity(false, true, "IntraMap without SIMPFI for simplify fixtures"); + private static final Identity NOSIMPIF = new Identity(true, false, "IntraMap without SIMPIF for simplify fixtures"); + + /** Registers the four functions with {@code ch}, as the C test programs register them. */ + static void register(Channel ch) { + ch.registerIntra("simplifyidentity", 1, 1, SIMPLIFY_IDENTITY); + ch.registerIntra("simplifyidentity2", 1, 1, SIMPLIFY_IDENTITY2); + ch.registerIntra("nosimpfi", 1, 1, NOSIMPFI); + ch.registerIntra("nosimpif", 1, 1, NOSIMPIF); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/FixtureReadWarningsOracleTest.java b/src/test/java/uk/ac/starlink/ast/FixtureReadWarningsOracleTest.java index 6396dc9..c8d6ae2 100644 --- a/src/test/java/uk/ac/starlink/ast/FixtureReadWarningsOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/FixtureReadWarningsOracleTest.java @@ -3,8 +3,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import com.fasterxml.jackson.databind.JsonNode; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; @@ -83,9 +85,13 @@ private static Map>> cReads() { return out; } - /** Each read of {@code fixture}, up to the end or an error, listing only reads that fail or warn. */ + /** + * Each read of {@code fixture}, up to the end or an error, listing only reads that fail or warn. + * The Channel has no transformation functions registered, as the probe's C Channel has none. + */ private static List> reads(String fixture) { - Channel ch = ChannelText.reader(Fixtures.read(fixture.substring(2))); + Channel ch = new Channel( + new ByteArrayInputStream(Fixtures.read(fixture.substring(2)).getBytes(StandardCharsets.UTF_8)), null); List> out = new ArrayList<>(); for (int i = 0; i < 10; i++) { int status = 0; diff --git a/src/test/java/uk/ac/starlink/ast/FluxFrameTest.java b/src/test/java/uk/ac/starlink/ast/FluxFrameTest.java index f9f747d..43609fc 100644 --- a/src/test/java/uk/ac/starlink/ast/FluxFrameTest.java +++ b/src/test/java/uk/ac/starlink/ast/FluxFrameTest.java @@ -9,6 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.ProbeOutput; /** * Translation of the FluxFrame tests of Rust {@code tests/test_fluxframe.rs}, of Rust {@code @@ -28,9 +29,8 @@ * the constructor. * *

{@code test_fluxframe_equal_same}, {@code test_fluxframe_equal_different_system} and {@code - * test_fluxframe_equal_different_specval_is_equal} test {@code astEqual}, which this library does - * not have, and are listed in {@code deferred/rust-tests.txt}. The SpecFluxFrame tests of {@code - * test_fluxframe.rs} are in {@link SpecFluxFrameTest}, and {@code + * test_fluxframe_equal_different_specval_is_equal} call {@link AstObject#astEqual}. The + * SpecFluxFrame tests of {@code test_fluxframe.rs} are in {@link SpecFluxFrameTest}, and {@code * system_from_unit_matches_the_c_library} is in {@link FluxUnitSystemOracleTest}. */ class FluxFrameTest { @@ -543,13 +543,38 @@ void alignSystemIsNotUsed() { assertInstanceOf(UnitMap.class, map); } - /** A logarithmic Unit is converted by a MathMap, which this library does not have. */ + /** + * A logarithmic Unit is converted by the MathMap of the units conversion, after the ZoomMap + * to the default Unit, as C's is (probe {@code mathmap_simplify_probe.c}, case {@code + * flux_log_conversion}); the values agree with C's to within the last bits of the maths + * library. + */ @Test - void logarithmicConversionNeedsMathMap() { + void logarithmicConversionUsesAMathMap() { FluxFrame jy = flux(AstObject.AST__BAD, "Unit=Jy"); FluxFrame log = flux(AstObject.AST__BAD, "Unit=log(W/m^2/Hz)"); - UnsupportedOperationException e = assertThrows(UnsupportedOperationException.class, () -> jy.convert(log, "")); - assertTrue(e.getMessage().endsWith("needs MathMap"), e.getMessage()); + FrameSet fs = jy.convert(log, ""); + assertNotNull(fs); + Mapping map = fs.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT).simplify(); + String[] want = ProbeOutput.load("mathmap_simplify_probe") + .get("flux_log_conversion") + .split("\n", -1); + String dump = ChannelText.dump(map); + int ndump = dump.split("\n", -1).length - 1; + StringBuilder wantDump = new StringBuilder(); + for (int i = 1; i <= ndump; i++) { + wantDump.append(want[i]).append('\n'); + } + assertEquals(want[0], map.astClass()); + assertEquals(wantDump.toString(), dump); + double[] vals = {1.0, 1000.0, 0.5}; + double[] fwd = fs.tran1(vals.length, vals, true); + double[] inv = fs.tran1(vals.length, fwd, false); + for (int i = 0; i < vals.length; i++) { + String[] parts = want[ndump + 1 + i].split(" -> ", -1); + assertEquals(Double.parseDouble(parts[1]), fwd[i], 1e-14 * Math.abs(fwd[i]), "forward " + vals[i]); + assertEquals(Double.parseDouble(parts[2]), inv[i], 1e-14 * Math.abs(inv[i]), "inverse " + vals[i]); + } } // ------------------------------------------------------------------ @@ -1000,4 +1025,27 @@ void jniastAccessors() { ff.setSpecVal(5.0); assertEquals(5.0, ff.getSpecVal()); } + + // ------------------------------------------------------------------ + // Equality (frame.c Equal: the conversion simplifies to a UnitMap) + // ------------------------------------------------------------------ + + @Test + void testFluxframeEqualSame() { + assertTrue(new FluxFrame().astEqual(new FluxFrame())); + } + + @Test + void testFluxframeEqualDifferentSystem() { + assertFalse(new FluxFrame().astEqual(flux(AstObject.AST__BAD, "System=FLXDNW"))); + } + + @Test + void testFluxframeEqualDifferentSpecvalIsEqual() { + FluxFrame ff1 = new FluxFrame(); + FluxFrame ff2 = new FluxFrame(); + ff1.setSpecVal(1.0e9); + ff2.setSpecVal(2.0e9); + assertTrue(ff1.astEqual(ff2)); + } } diff --git a/src/test/java/uk/ac/starlink/ast/FrameAxisAttrsTest.java b/src/test/java/uk/ac/starlink/ast/FrameAxisAttrsTest.java index a23946a..5367146 100644 --- a/src/test/java/uk/ac/starlink/ast/FrameAxisAttrsTest.java +++ b/src/test/java/uk/ac/starlink/ast/FrameAxisAttrsTest.java @@ -21,8 +21,8 @@ *

The cases for a plain Frame, a SkyFrame, a SpecFrame, a DSBSpecFrame, a TimeFrame, a FluxFrame, * a FrameSet holding a SkyFrame (with those of its current Frame, "inner1"), the probe's CmpFrame of a SkyFrame and a * SpecFrame, and PlainCmpFrame, a CmpFrame of a one-axis and a two-axis plain Frame (each with - * those of its components, "inner1" and "inner2"), run here. Those of SpecFluxFrame (not yet - * ported) and Circle (out of scope) do not. + * those of its components, "inner1" and "inner2"), and a SpecFluxFrame of a SpecFrame and a + * FluxFrame (with those of its components) run here. Those of Circle (out of scope) do not. * *

Digits of an axis is set, read and tested through the attribute string ({@code * "Digits(n)"}), as the probe does: for a CmpFrame that goes to the component holding the axis @@ -38,6 +38,7 @@ class FrameAxisAttrsTest { "DSBSpecFrame", "TimeFrame", "FluxFrame", + "SpecFluxFrame", "FrameSet", "CmpFrame", "PlainCmpFrame"); @@ -62,6 +63,8 @@ private static Frame make(String cls) { return new TimeFrame(); case "FluxFrame": return new FluxFrame(AstObject.AST__BAD, null); + case "SpecFluxFrame": + return new SpecFluxFrame(new SpecFrame(), new FluxFrame(AstObject.AST__BAD, null)); case "FrameSet": return new FrameSet(icrs()); case "CmpFrame": @@ -208,7 +211,7 @@ void everyClassMatchesTheCLibrary() { failures.add(cls + " \"" + setting + "\" " + whose + " " + attr + ": got " + got + ", C gives " + want); } } - assertEquals(2096 + 80 + 80 + 80 + 864, run, "the cases of the in-scope classes the C probe recorded"); + assertEquals(2096 + 80 + 80 + 80 + 864 + 576, run, "the cases of the in-scope classes the C probe recorded"); assertTrue(failures.isEmpty(), failures.size() + " cases differ:\n" + String.join("\n", failures)); } diff --git a/src/test/java/uk/ac/starlink/ast/FrameClassAttrsTest.java b/src/test/java/uk/ac/starlink/ast/FrameClassAttrsTest.java index 5bea8a5..79770ae 100644 --- a/src/test/java/uk/ac/starlink/ast/FrameClassAttrsTest.java +++ b/src/test/java/uk/ac/starlink/ast/FrameClassAttrsTest.java @@ -18,14 +18,21 @@ * astGetC}, {@code astGetI} or {@code astGetD} and its {@code astTest} result; for a FrameSet it * also reads the current Frame ("inner"). {@link #make} and {@link #mismatch} do the same. * - *

The probe's SpecFluxFrame cases are skipped (that class is not yet ported), as are its - * Circle cases (Region, out of scope). + *

The probe's Circle cases are skipped (Region, out of scope). */ class FrameClassAttrsTest { /** The probe's classes this library provides. */ private static final List IN_SCOPE = Arrays.asList( - "Frame", "SkyFrame", "SpecFrame", "DSBSpecFrame", "TimeFrame", "FluxFrame", "CmpFrame", "FrameSet"); + "Frame", + "SkyFrame", + "SpecFrame", + "DSBSpecFrame", + "TimeFrame", + "FluxFrame", + "SpecFluxFrame", + "CmpFrame", + "FrameSet"); /** The object the probe builds for {@code cls}. */ private static Frame make(String cls) { @@ -42,6 +49,8 @@ private static Frame make(String cls) { return new TimeFrame(); case "FluxFrame": return new FluxFrame(AstObject.AST__BAD, null); + case "SpecFluxFrame": + return new SpecFluxFrame(new SpecFrame(), new FluxFrame(AstObject.AST__BAD, null)); case "CmpFrame": return new CmpFrame(new SkyFrame(), new SpecFrame()); case "FrameSet": @@ -53,14 +62,15 @@ private static Frame make(String cls) { /** * The Frame whose attributes show the effect of a setting on {@code f}: a FrameSet's current - * Frame, or a CmpFrame's first component (its SkyFrame, the primary Frame of axis 1). + * Frame, or a CmpFrame's first component (for the probe's CmpFrame its SkyFrame, the primary + * Frame of axis 1; for a SpecFluxFrame its SpecFrame). */ private static Frame inner(String cls, Frame f) { if ("FrameSet".equals(cls)) { return ((FrameSet) f).getFrame(FrameSet.AST__CURRENT); } - if ("CmpFrame".equals(cls)) { - return f.primaryFrame(1, new int[1]); + if ("CmpFrame".equals(cls) || "SpecFluxFrame".equals(cls)) { + return ((CmpFrame) f).decompose()[0]; } return null; } @@ -143,7 +153,7 @@ void everyClassMatchesTheCLibrary() { failures.add(what + ": " + e.getMessage()); } } - assertEquals(6 * 256 + 2 * 512, run, "the in-scope cases the C probe recorded"); + assertEquals(6 * 256 + 3 * 512, run, "the in-scope cases the C probe recorded"); assertTrue( failures.isEmpty(), failures.size() + " of " + run + " cases differ:\n" + String.join("\n", failures)); } diff --git a/src/test/java/uk/ac/starlink/ast/FrameEqualityTest.java b/src/test/java/uk/ac/starlink/ast/FrameEqualityTest.java new file mode 100644 index 0000000..0a70cdd --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/FrameEqualityTest.java @@ -0,0 +1,59 @@ +package uk.ac.starlink.ast; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.junit.jupiter.api.Test; + +/** + * Translation of Rust {@code tests/test_frame_equality.rs}: Frames are equal when the conversion + * between them simplifies to a UnitMap (frame.c {@code Equal}), so attributes that only describe + * the axes play no part. C's answers are in the probe {@code probes/equal_probe.c}. + */ +class FrameEqualityTest { + + private static SkyFrame icrs() { + SkyFrame f = new SkyFrame(); + f.setSystem("ICRS"); + return f; + } + + @Test + void basicFramesDifferingOnlyInCosmeticsAreEqual() { + Frame f1 = new Frame(2); + f1.set("Title=First frame,Label(1)=X,Symbol(1)=x,Format(1)=3"); + Frame f2 = new Frame(2); + f2.set("Title=Second frame,Label(1)=Different label,Symbol(1)=q,Format(1)=7"); + assertTrue(f1.astEqual(f2)); + } + + @Test + void basicFramesDifferingInDomainAreNotEqual() { + Frame f1 = new Frame(2); + f1.setDomain("PIXEL"); + Frame f2 = new Frame(2); + f2.setDomain("GRID"); + assertFalse(f1.astEqual(f2)); + } + + @Test + void skyframesDifferingOnlyInTitleAreEqual() { + SkyFrame sf2 = icrs(); + sf2.setTitle("A different description"); + assertTrue(icrs().astEqual(sf2)); + } + + @Test + void skyframeExplicitDefaultDomainEqualsUnsetDomain() { + SkyFrame sf2 = icrs(); + sf2.setDomain("SKY"); + assertTrue(icrs().astEqual(sf2)); + } + + @Test + void skyframesDifferingInSystemAreNotEqual() { + SkyFrame sf2 = new SkyFrame(); + sf2.setSystem("Galactic"); + assertFalse(icrs().astEqual(sf2)); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/FrameSetIntegrityTest.java b/src/test/java/uk/ac/starlink/ast/FrameSetIntegrityTest.java index a9335ae..2c2fac9 100644 --- a/src/test/java/uk/ac/starlink/ast/FrameSetIntegrityTest.java +++ b/src/test/java/uk/ac/starlink/ast/FrameSetIntegrityTest.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.CValues; @@ -23,9 +22,10 @@ * RestoreIntegrity}): it converts the recorded state of the current Frame to its new state with * {@code astConvert}, and reports {@code AST__ILOST} when no conversion exists. * - *

The probe's SpecFluxFrame cases need a class this version does not have yet and are skipped. - * Every value is compared within libm rounding, which is no wider than the Rust test's comparison. - * {@code unit_change_leaves_mappings_alone} reads a FrameSet holding a LutMap and is deferred. + *

Every value is compared within libm rounding, which is no wider than the Rust test's comparison. + * {@code unit_change_leaves_mappings_alone} runs Rust's integrity routine with no change; here the + * change sets an attribute of the current Frame to the value it already has, which marks the + * integrity as lost, as any setting through the FrameSet does. */ class FrameSetIntegrityTest { @@ -37,18 +37,6 @@ class FrameSetIntegrityTest { /** RefDec of the probe's SpecFrames ({@code integrity_probe.c REF_DEC}). */ private static final double REF_DEC = 0.5235987755982988; - /** The prefixes of the cases that need a class this version does not have. */ - private static final List SKIPPED_PREFIXES = Arrays.asList("specflux_"); - - private static boolean skipped(String name) { - for (String p : SKIPPED_PREFIXES) { - if (name.startsWith(p)) { - return true; - } - } - return false; - } - private static SkyFrame sky(String settings) { SkyFrame f = new SkyFrame(); f.set(settings); @@ -109,6 +97,12 @@ private static Frame current(String name) { DSBSpecFrame d = new DSBSpecFrame(); d.set("System=FREQ,Unit=GHz,DSBCentre=230.0,IF=4.0,SideBand=LSB"); return d; + case "specflux_unit2_jy": + case "specflux_unit1_mhz": { + FluxFrame ff = new FluxFrame(AstObject.AST__BAD, null); + ff.set("System=FLXDN"); + return new SpecFluxFrame(spec("System=FREQ,Unit=GHz"), ff); + } case "flux_unit_jy": case "flux_system_sfcbr": { FluxFrame ff = new FluxFrame(1.4e9, null); @@ -167,6 +161,10 @@ private static String[][] settings(String name) { return new String[][] {{"Unit(1)", "Jy"}}; case "flux_system_sfcbr": return new String[][] {{"System", "SFCBR"}}; + case "specflux_unit2_jy": + return new String[][] {{"Unit(2)", "Jy"}}; + case "specflux_unit1_mhz": + return new String[][] {{"Unit(1)", "MHz"}}; default: throw new IllegalArgumentException("no case " + name); } @@ -186,6 +184,9 @@ private static double[][] points(String name) { if (name.startsWith("spec_") || name.startsWith("dsb_")) { return new double[][] {{230.0, 345.0}}; } + if (name.startsWith("specflux_")) { + return new double[][] {{1.0, 2.0}, {1.0e-26, 3.0e-26}}; + } if (name.startsWith("cmp_")) { return new double[][] {{1.0, 4.2}, {0.5, -0.9}, {1.0, 2.0}}; } @@ -247,16 +248,13 @@ void integrityMatchesTheCLibrary() { int checked = 0; for (JsonNode c : PROBE.get("CASES")) { String name = c.get(0).asText(); - if (skipped(name)) { - continue; - } checked++; String failure = compare(name, c.get(1)); if (failure != null) { failures.add(failure); } } - assertEquals(21, checked, "the cases with classes this version has"); + assertEquals(23, checked, "the cases"); assertTrue( failures.isEmpty(), failures.size() + " of " + checked + " cases differ from C:\n" + String.join("\n", failures)); @@ -325,4 +323,17 @@ void settingAFrameAttributeKeepsTheFrameSetsSize() { assertEquals(nodeCount(first), nodeCount(last), "nodes after the first and last settings"); assertEquals(first.replace("\"x0\"", "\"x199\""), last); } + /** + * A change to the current Frame that leaves the conversion from its old state a UnitMap does + * not remap the Frame, as C's {@code RestoreIntegrity} does not, so the FrameSet's Mappings, + * one of which holds a LutMap and simplifies further than it stands in {@code + * programs/testfitschan/sparse.ast}, are left as they are rather than re-simplified. + */ + @Test + void unitChangeLeavesMappingsAlone() { + FrameSet fs = (FrameSet) ChannelText.read(Fixtures.read("programs/testfitschan/sparse.ast")); + String before = ChannelText.dump(fs); + fs.setC("System(1)", "FK5"); + assertEquals(before, ChannelText.dump(fs)); + } } diff --git a/src/test/java/uk/ac/starlink/ast/FrameSetTest.java b/src/test/java/uk/ac/starlink/ast/FrameSetTest.java index 0fb3be8..806db37 100644 --- a/src/test/java/uk/ac/starlink/ast/FrameSetTest.java +++ b/src/test/java/uk/ac/starlink/ast/FrameSetTest.java @@ -835,6 +835,36 @@ void convertSetsTheBaseOfAFramesetArgumentToTheFrameUsed() { } } + /** A FrameSet X -> A (a MathMap with no inverse), X -> B (zoom 3), and one A -> B (unit). */ + private static FrameSet[] firstDomainPair() { + FrameSet from = new FrameSet(named(1, "X")); + from.addFrame(1, new MathMap(1, 1, new String[] {"y=2*x"}, new String[] {"x"}), named(1, "A")); + from.addFrame(1, new ZoomMap(1, 3.0), named(1, "B")); + from.setCurrent(1); + FrameSet to = new FrameSet(named(1, "A")); + to.addFrame(1, new UnitMap(1), named(1, "B")); + to.setCurrent(1); + return new FrameSet[] {from, to}; + } + + /** + * The conversion is found through the first domain of the list that gives one, and leaves each + * FrameSet's Base at the Frame used. + */ + @Test + void convertStopsAtTheFirstDomainThatGivesAConversion() { + FrameSet[] pair = firstDomainPair(); + FrameSet cvt = pair[0].convert(pair[1], "A,B"); + assertArrayEquals(new int[] {2, 1}, new int[] {pair[0].getBase(), pair[1].getBase()}); + assertTrue(cvt.getTranForward() && !cvt.getTranInverse()); + assertEquals(2.0, tranOne(cvt), 1e-15); + + pair = firstDomainPair(); + cvt = pair[0].convert(pair[1], "B,A"); + assertArrayEquals(new int[] {3, 2}, new int[] {pair[0].getBase(), pair[1].getBase()}); + assertEquals(3.0, tranOne(cvt), 1e-15); + } + @Test void failedConvertLeavesTheBaseAlone() { FrameSet fs = fourDomains(); diff --git a/src/test/java/uk/ac/starlink/ast/FrameSetVariantLinkOracleTest.java b/src/test/java/uk/ac/starlink/ast/FrameSetVariantLinkOracleTest.java index e2b3b1c..5c21f92 100644 --- a/src/test/java/uk/ac/starlink/ast/FrameSetVariantLinkOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/FrameSetVariantLinkOracleTest.java @@ -21,8 +21,7 @@ * followed by the change of variant, simplified; the link then records the Invert of the result. * Each case adds a variant to Frame A or B and selects the Frame's own variant again. * - *

The cases whose A -> B link is a MathMap need a class outside the first phase and are skipped. - * {@code selecting_a_variant_matches_c} compares the transformations after adding the variant and + *

The A -> B link is a ShiftMap or a MathMap. {@code selecting_a_variant_matches_c} compares the transformations after adding the variant and * after selecting the Frame's own variant again. Its comparisons of the dumps are left out, as they * need simplification: C's {@code AddVariant} (frameset.c:1824) and {@code SetVariant} * (frameset.c:10075) store the Mappings {@code astSimplify} makes. The C dumps are each read back @@ -61,11 +60,23 @@ private static Mapping variantMap(String variant) { } } + /** The A -> B link of a case. */ + private static Mapping link(String link) { + switch (link) { + case "shift": + return new ShiftMap(new double[] {10.0}); + case "mathmap": + return new MathMap(1, 1, new String[] {"y=x+10"}, new String[] {"x=y-10"}); + default: + throw new IllegalArgumentException("link " + link); + } + } + /** The outer FrameSet of a case, with the variant added. */ - private static FrameSet build(int current, String variant) { + private static FrameSet build(int current, String link, String variant) { FrameSet outer = new FrameSet(frame("GRID")); FrameSet inner = new FrameSet(frame("A")); - inner.addFrame(FrameSet.AST__BASE, new ShiftMap(new double[] {10.0}), frame("B")); + inner.addFrame(FrameSet.AST__BASE, link(link), frame("B")); outer.addFrame(FrameSet.AST__BASE, new ZoomMap(1, 2.0), inner); outer.setCurrent(current); outer.addVariant(variantMap(variant), "V2"); @@ -80,30 +91,21 @@ private static double[] doubles(JsonNode arr) { return out; } - /** The cases whose A -> B link is a ShiftMap, those the first phase can build. */ - private static List shiftCases() { + /** The cases, six with each link. */ + private static List allCases() { List out = new ArrayList<>(); - int skipped = 0; for (JsonNode c : CASES) { - String link = c.get(2).asText(); - if ("shift".equals(link)) { - out.add(c); - } else if ("mathmap".equals(link)) { - skipped++; - } else { - throw new IllegalStateException("link " + link); - } + out.add(c); } - assertEquals(6, out.size()); - assertEquals(6, skipped); + assertEquals(12, out.size()); return out; } @Test void selectingAVariantMatchesC() { - for (JsonNode c : shiftCases()) { + for (JsonNode c : allCases()) { String name = c.get(0).asText(); - FrameSet outer = build(c.get(1).asInt(), c.get(3).asText()); + FrameSet outer = build(c.get(1).asInt(), c.get(2).asText(), c.get(3).asText()); assertArrayEquals(doubles(c.get(5)), transforms(outer), name + ": added"); outer.setVariant(outer.getDomain()); @@ -113,7 +115,7 @@ void selectingAVariantMatchesC() { @Test void cDumpsReadBackUnchanged() { - for (JsonNode c : shiftCases()) { + for (JsonNode c : allCases()) { String name = c.get(0).asText(); for (int i : new int[] {4, 6}) { String text = c.get(i).asText(); diff --git a/src/test/java/uk/ac/starlink/ast/GrismMapTest.java b/src/test/java/uk/ac/starlink/ast/GrismMapTest.java new file mode 100644 index 0000000..fa90666 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/GrismMapTest.java @@ -0,0 +1,725 @@ +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.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static uk.ac.starlink.ast.MappingTestData.transformRows; + +import java.util.Map; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.CValues; +import uk.ac.starlink.ast.testsupport.ProbeOutput; + +/** + * Translation of Rust {@code tests/test_grismmap.rs} (after the GrismMap sections of C's {@code + * ast_tester}), with the cases of the C probe {@code probes/grismmap_probe.c}: attribute values, + * tests, clears and settings, a GrismMap held by a CmpMap, native dumps with each attribute set and + * unset read back, transformations, a rate, equality, a split, and simplification beside ZoomMaps, + * WinMaps, a ShiftMap and other GrismMaps. + * + *

Rust's {@code GrismMap::new}, which sets all eight attributes, is {@link #typical} and {@link + * #grism}, which set them through the jniast setters, as the probe sets them with {@code + * astGrismMap}; Rust's {@code default_map} is the jniast constructor. The five Rust tests that call + * {@code try_merge}, which this library does not have, simplify the series or parallel CmpMap they + * describe instead. + */ +class GrismMapTest { + + private static final double BAD = AstObject.AST__BAD; + + private static final Map PROBE_CASES = ProbeOutput.load("grismmap_probe"); + + private static final String[] ATTRS = { + "GrismNR", "GrismNRP", "GrismWaveR", "GrismAlpha", "GrismG", "GrismM", "GrismEps", "GrismTheta" + }; + + private static String probe(String name) { + String text = PROBE_CASES.get(name); + if (text == null) { + throw new IllegalStateException("no probe case " + name); + } + return text; + } + + /** Requires {@code got} to be C's text for {@code name}, its numbers within libm rounding. */ + private static void assertProbe(String name, String got) { + String want = probe(name); + if (!want.equals(got) && !CValues.nativeStringsWithinLibmRounding(got, want)) { + assertEquals(want, got, name); + } + } + + /** A GrismMap with every attribute set, as Rust's {@code GrismMap::new} makes it. */ + private static GrismMap grism( + double nr, double nrp, double waveR, double alpha, double g, int m, double eps, double theta) { + GrismMap map = new GrismMap(); + map.setGrismNR(nr); + map.setGrismNRP(nrp); + map.setGrismWaveR(waveR); + map.setGrismAlpha(alpha); + map.setGrismG(g); + map.setGrismM(m); + map.setGrismEps(eps); + map.setGrismTheta(theta); + return map; + } + + /** The probe's {@code typical}: a GrismMap with every attribute set, wavelengths in Angstrom. */ + private static GrismMap typical() { + return grism(1.5, -1e-6, 5000.0, 0.1, 2e-4, 1, 0.02, 0.03); + } + + private static GrismMap typicalM(int m) { + GrismMap g = typical(); + g.setGrismM(m); + return g; + } + + private static T inv(T m) { + m.invert(); + return m; + } + + private static ZoomMap zoom(double f) { + return new ZoomMap(1, f); + } + + private static WinMap win(double scale, double shift) { + return new WinMap( + 1, new double[] {0.0}, new double[] {1.0}, new double[] {shift}, new double[] {shift + scale}); + } + + private static CmpMap series(Mapping a, Mapping b) { + return new CmpMap(a, b, true); + } + + private static String g(double v) { + return CFormat.format("%.17g", v); + } + + // ------------------------------------------------------------------ + // tests/test_grismmap.rs: construction and attributes + // ------------------------------------------------------------------ + + @Test + void defaultGrismmapAttributes() { + GrismMap gm = new GrismMap(); + assertEquals(1, gm.getNin()); + assertEquals(1, gm.getNout()); + assertEquals(1.0, gm.getGrismNR()); + assertEquals(0.0, gm.getGrismNRP()); + assertEquals(5000.0, gm.getGrismWaveR()); + assertEquals(0.0, gm.getGrismAlpha()); + assertEquals(0.0, gm.getGrismG()); + assertEquals(0, gm.getGrismM()); + assertEquals(0.0, gm.getGrismEps()); + assertEquals(0.0, gm.getGrismTheta()); + assertFalse(gm.getInvert()); + } + + @Test + void customGrismmapAttributes() { + GrismMap gm = typical(); + assertEquals(1.5, gm.getGrismNR()); + assertEquals(-1e-6, gm.getGrismNRP()); + assertEquals(5000.0, gm.getGrismWaveR()); + assertEquals(0.1, gm.getGrismAlpha()); + assertEquals(2e-4, gm.getGrismG()); + assertEquals(1, gm.getGrismM()); + assertEquals(0.02, gm.getGrismEps()); + assertEquals(0.03, gm.getGrismTheta()); + } + + // ------------------------------------------------------------------ + // tests/test_grismmap.rs: transformations, with C's values (probe case transformations) + // ------------------------------------------------------------------ + + /** C's value for {@code value} in the probe's {@code transformations} line {@code prefix value ->}. */ + private static double cValue(String prefix, double value) { + String head = prefix + " " + g(value) + " -> "; + for (String line : probe("transformations").split("\n", -1)) { + if (line.startsWith(head)) { + return Double.parseDouble(line.substring(head.length())); + } + } + throw new IllegalStateException("no line " + head); + } + + private static void assertC(double want, double got, String what) { + assertTrue(CValues.withinLibmRounding(got, want), what + ": got " + got + ", C gives " + want); + } + + @Test + void forwardTransformTypicalGrism() { + double wavelength = typical().tran1(1, new double[] {0.0}, true)[0]; + assertNotEquals(BAD, wavelength); + assertTrue(wavelength > 0.0, "wavelength should be positive"); + assertC(cValue("fwd", 0.0), wavelength, "forward of 0"); + } + + @Test + void forwardInverseRoundtrip() { + GrismMap gm = typical(); + double[] params = {0.0, 0.01, -0.01, 0.05}; + double[] wavelengths = gm.tran1(4, params, true); + double[] recovered = gm.tran1(4, wavelengths, false); + for (int i = 0; i < 4; i++) { + assertC(cValue("fwd", params[i]), wavelengths[i], "forward of " + params[i]); + assertNotEquals(BAD, recovered[i], "point " + i + ": inverse returned BAD"); + assertTrue(Math.abs(params[i] - recovered[i]) < 1e-12, "point " + i + ": round trip error"); + } + } + + @Test + void inverseForwardRoundtrip() { + GrismMap gm = typical(); + double[] wavelengths = {4900.0, 5000.0, 5100.0, 5200.0}; + double[] params = gm.tran1(4, wavelengths, false); + double[] recovered = gm.tran1(4, params, true); + for (int i = 0; i < 4; i++) { + assertC(cValue("inv", wavelengths[i]), params[i], "inverse of " + wavelengths[i]); + assertNotEquals(BAD, recovered[i], "point " + i + ": forward returned BAD"); + assertTrue(Math.abs(wavelengths[i] - recovered[i]) < 1e-10, "point " + i + ": round trip error"); + } + } + + @Test + void badValuePropagation() { + double[] out = typical().tran1(2, new double[] {BAD, 0.0}, true); + assertEquals(BAD, out[0]); + assertNotEquals(BAD, out[1]); + } + + /** + * An infinite input is bad in either direction (docs/rust-c-differences.md, "Infinite input + * coordinates"); forward, C would give the finite wavelength of {@code atan(±inf)}. + */ + @Test + void infiniteInputIsBad() { + double[] in = {Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0}; + double[] fwd = typical().tran1(3, in, true); + assertEquals(BAD, fwd[0]); + assertEquals(BAD, fwd[1]); + assertNotEquals(BAD, fwd[2]); + double[] inv = typical().tran1(2, in, false); + assertEquals(BAD, inv[0]); + assertEquals(BAD, inv[1]); + } + + /** A GrismMap with no attribute set has {@code k2} zero, so its forward transformation is bad. */ + @Test + void degenerateParamsProduceBad() { + double[] out = new GrismMap().tran1(2, new double[] {0.0, 0.5}, true); + assertEquals(BAD, out[0]); + assertEquals(BAD, out[1]); + } + + @Test + void invertedGrismmapSwapsDirections() { + GrismMap gm = typical(); + double[] input = {0.0}; + double fwd = gm.tran1(1, input, true)[0]; + gm.invert(); + assertTrue(gm.getInvert()); + double invFwd = gm.tran1(1, input, true)[0]; + double invInv = gm.tran1(1, input, false)[0]; + assertTrue(Math.abs(fwd - invInv) < 1e-15, "inverted inverse should match forward"); + double recovered = gm.tran1(1, new double[] {invFwd}, false)[0]; + assertTrue(Math.abs(input[0] - recovered) < 1e-12, "round trip through inverted map failed"); + } + + // ------------------------------------------------------------------ + // tests/test_grismmap.rs: equality + // ------------------------------------------------------------------ + + @Test + void equalSameParams() { + assertTrue(typical().astEqual(typical())); + } + + @Test + void notEqualDifferentNr() { + GrismMap other = typical(); + other.setGrismNR(1.6); + assertFalse(typical().astEqual(other)); + } + + @Test + void notEqualDifferentM() { + assertFalse(typical().astEqual(typicalM(-1))); + } + + @Test + void notEqualDifferentInversion() { + assertFalse(typical().astEqual(inv(typical()))); + } + + // ------------------------------------------------------------------ + // tests/test_grismmap.rs: native serialisation + // ------------------------------------------------------------------ + + private static Mapping readBack(Mapping m) { + return (Mapping) ChannelText.read(ChannelText.dump(m)); + } + + @Test + void nativeSerializationRoundtrip() { + GrismMap gm = typical(); + Mapping parsed = readBack(gm); + assertTrue(gm.astEqual(parsed)); + double[] input = {0.0, 0.01, -0.01}; + double[] orig = gm.tran1(3, input, true); + double[] back = parsed.tran1(3, input, true); + for (int i = 0; i < 3; i++) { + assertTrue(Math.abs(orig[i] - back[i]) < 1e-15, "transform mismatch after round trip at point " + i); + } + } + + @Test + void nativeSerializationRoundtripInverted() { + GrismMap gm = inv(typical()); + assertTrue(gm.astEqual(readBack(gm))); + } + + @Test + void nativeSerializationRoundtripDefaults() { + GrismMap gm = new GrismMap(); + assertTrue(gm.astEqual(readBack(gm))); + } + + // ------------------------------------------------------------------ + // tests/test_grismmap.rs: simplification + // ------------------------------------------------------------------ + + /** + * Rust's {@code inverse_cancellation}: a GrismMap followed by the inverse of one whose + * attributes equal its own but for GrismM, which must differ, simplifies to a UnitMap. + */ + @Test + void inverseCancellation() { + Mapping merged = series(typical(), inv(typicalM(-1))).simplify(); + assertInstanceOf(UnitMap.class, merged); + assertEquals(1, merged.getNin()); + assertEquals(1, merged.getNout()); + assertEquals(42.0, merged.tran1(1, new double[] {42.0}, true)[0]); + } + + @Test + void noCancelSameDirection() { + Mapping s = series(new GrismMap(), new GrismMap()).simplify(); + assertInstanceOf(CmpMap.class, s, "same direction should not cancel"); + } + + /** C's {@code CanMerge} cancels GrismMaps only when their GrismM attributes differ. */ + @Test + void noCancelSameMOppositeDirection() { + Mapping s = series(typical(), inv(typical())).simplify(); + assertInstanceOf(CmpMap.class, s, "same M opposite direction should not cancel per C library"); + } + + @Test + void noCancelDifferentAttrs() { + GrismMap other = typicalM(-1); + other.setGrismNR(1.6); + Mapping s = series(typical(), inv(other)).simplify(); + assertInstanceOf(CmpMap.class, s, "different attrs should not cancel"); + } + + @Test + void noMergeParallel() { + Mapping s = new CmpMap(typical(), inv(typicalM(-1)), false).simplify(); + assertInstanceOf(CmpMap.class, s, "parallel merge should not be supported"); + } + + // ------------------------------------------------------------------ + // tests/test_grismmap.rs: rate and dump + // ------------------------------------------------------------------ + + @Test + void rateAtZero() { + double rate = typical().rate(new double[] {0.0}, 1, 1); + assertTrue(Double.isFinite(rate)); + assertNotEquals(0.0, rate); + } + + /** A GrismMap made with no attribute values writes the defaults commented out, as C does. */ + @Test + void defaultGrismmapDumpsAsCDoes() { + String want = String.join( + "\n", + " Begin GrismMap \t# Map 1-d coordinates using a spectral disperser", + " Nin = 1 \t# Number of input coordinates", + " IsA Mapping \t# Mapping between coordinate systems", + "# GrmNR = 1 \t# Refractive index at the ref. wavelength", + "# GrmNRP = 0 \t# Rate of change of refractive index", + "# GrmWR = 5000 \t# Ref. wavelength", + "# GrmAlp = 0 \t# Angle of incidence of incoming light", + "# GrmG = 0 \t# Grating ruling density", + "# GrmM = 0 \t# The interference order", + "# GrmEps = 0 \t# Angle between grating normal and dispersion plane", + "# GrmTh = 0 \t# Angle between detector normal and reference ray", + " End GrismMap") + + "\n"; + assertEquals(want, ChannelText.dump(new GrismMap())); + } + + // ------------------------------------------------------------------ + // Probe: attributes + // ------------------------------------------------------------------ + + /** The probe's {@code attributes}: each attribute, whether it is set, and its value. */ + private static String attributes(Mapping m) { + StringBuilder sb = new StringBuilder(); + for (String a : ATTRS) { + sb.append(a) + .append(' ') + .append(m.test(a) ? 1 : 0) + .append(' ') + .append(m.getC(a)) + .append('\n'); + } + return sb.toString(); + } + + /** + * The attributes of a GrismMap made with none set, with all set, with all set then cleared, + * and with each set to its default, as C gives them. + */ + @Test + void attributesMatchC() { + assertEquals(probe("attributes_default"), attributes(new GrismMap())); + assertEquals(probe("attributes_set"), attributes(typical())); + GrismMap cleared = typical(); + cleared.clear("GrismNR,GrismNRP,GrismWaveR,GrismAlpha,GrismG,GrismM,GrismEps,GrismTheta"); + assertEquals(probe("attributes_cleared"), attributes(cleared)); + GrismMap defaults = new GrismMap(); + defaults.set("GrismNR=1,GrismNRP=0,GrismWaveR=5000,GrismAlpha=0,GrismG=0,GrismM=0,GrismEps=0,GrismTheta=0"); + assertEquals(probe("attributes_set_to_defaults"), attributes(defaults)); + } + + /** GrismM is set from a double, truncated toward zero, as C's {@code SetAttrib} sets it. */ + @Test + void aFractionalOrderIsTruncated() { + GrismMap gm = new GrismMap(); + gm.set("GrismM=2.7"); + String m27 = gm.getC("GrismM"); + gm.set("GrismM=-2.7"); + String mMinus27 = gm.getC("GrismM"); + gm.setD("GrismM", 3.5); + String got = "2.7 -> " + m27 + "\n-2.7 -> " + mMinus27 + "\nsetd 3.5 -> " + gm.getC("GrismM") + "\ngetd " + + g(gm.getD("GrismM")) + "\n"; + assertEquals(probe("set_m_fraction"), got); + } + + /** C's unset values, {@code AST__BAD} and {@code INT_MAX}, set as values, leave an attribute unset. */ + @Test + void theUnsetValuesUnsetTheAttribute() { + GrismMap gm = typical(); + gm.setGrismNR(BAD); + gm.setD("GrismTheta", BAD); + assertEquals(probe("set_bad_unsets"), attributes(gm)); + GrismMap gm2 = typical(); + gm2.setGrismM(Integer.MAX_VALUE); + assertEquals(probe("set_m_int_max_unsets"), attributes(gm2)); + } + + private static String report(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 case without the lines naming the C source of an error. */ + private static String withoutSource(String text) { + StringBuilder sb = new StringBuilder(); + for (String line : text.split("\n", -1)) { + if (!line.contains("AST: Error in routine") && !line.isEmpty()) { + sb.append(line).append('\n'); + } + } + return sb.toString(); + } + + @Test + void aSettingThatIsNotANumberIsRefused() { + AstException e = assertThrows(AstException.class, () -> new GrismMap().set("GrismNR=abc")); + assertEquals(withoutSource(probe("set_not_a_number")), report(e)); + } + + /** + * A GrismMap held by a CmpMap cannot have an attribute set or cleared, as C's cannot once + * cloned, but can be inverted; a copy of it can be changed. + */ + @Test + void aSharedGrismMapIsImmutable() { + GrismMap gm = typical(); + CmpMap c = series(gm, zoom(2.0)); + String errors = report(assertThrows(AstException.class, () -> gm.setD("GrismNR", 2.0))) + + report(assertThrows(AstException.class, () -> gm.clear("GrismM"))); + String nr = gm.getC("GrismNR"); + gm.invert(); + GrismMap copy = (GrismMap) gm.copy(); + copy.setD("GrismNR", 2.0); + String got = errors + "GrismNR " + nr + "\nInvert " + gm.getI("Invert") + "\ncopy GrismNR " + + copy.getC("GrismNR") + "\n"; + assertEquals(withoutSource(probe("shared_set")), got); + assertTrue(gm.isShared(), "the CmpMap " + c.astClass() + " holds the GrismMap"); + assertThrows(AstException.class, () -> gm.setGrismG(1.0)); + } + + // ------------------------------------------------------------------ + // Probe: native dumps + // ------------------------------------------------------------------ + + /** The probe's {@code tran}: the forward transformation of {@code xf}, the inverse of {@code xi}. */ + private static String tran(Mapping m, double xf, double xi) { + return tranLine("fwd", m, xf, true) + tranLine("inv", m, xi, false); + } + + private static String tranLine(String label, Mapping m, double x, boolean forward) { + int n = m.getNin(); + double[] in = new double[n]; + java.util.Arrays.fill(in, x); + double[] out = m.tranN(1, n, in, forward, n); + StringBuilder sb = new StringBuilder(label); + for (double v : in) { + sb.append(' ').append(g(v)); + } + sb.append(" ->"); + for (double v : out) { + sb.append(' ').append(g(v)); + } + return sb.append('\n').toString(); + } + + private static void assertRoundTrips(String name, Mapping m, double xf, double xi) { + String dump = ChannelText.dump(m); + Mapping back = (Mapping) ChannelText.read(dump); + String got = dump + "-- read back\n" + ChannelText.dump(back) + "-- equal " + (m.astEqual(back) ? 1 : 0) + "\n" + + "-- transformations\n" + tran(m, xf, xi) + "-- transformations read back\n" + tran(back, xf, xi); + assertProbe(name, got); + } + + /** + * Dumps of GrismMaps with no attribute set, all set, inverted, each set alone, each cleared + * from a GrismMap with all set, a negative order, and a simplified one, each read back, + * as C writes and reads them. + */ + @Test + void nativeDumpsMatchC() { + assertRoundTrips("dump_default", new GrismMap(), 0.01, 5100.0); + assertRoundTrips("dump_all_set", typical(), 0.01, 5100.0); + assertRoundTrips("dump_inverted", inv(typical()), 5100.0, 0.01); + String[] one = { + "GrismNR=1.5", + "GrismNRP=-1.0E-6", + "GrismWaveR=5000", + "GrismAlpha=0.1", + "GrismG=2.0E-4", + "GrismM=1", + "GrismEps=0.02", + "GrismTheta=0.03" + }; + for (int i = 0; i < ATTRS.length; i++) { + GrismMap gm = new GrismMap(); + gm.set(one[i]); + assertRoundTrips("dump_only_" + ATTRS[i], gm, 0.01, 5100.0); + } + for (String a : ATTRS) { + GrismMap gm = typical(); + gm.clear(a); + assertRoundTrips("dump_without_" + a, gm, 0.01, 5100.0); + } + assertRoundTrips("dump_negative_order", typicalM(-2), 0.01, 5100.0); + assertRoundTrips("dump_simplified", typical().simplify(), 0.01, 5100.0); + } + + /** A GrismMap splits off whole, keeping its Invert attribute, as C's base {@code MapSplit} does. */ + @Test + void aSplitIsTheGrismMap() { + int[] out = new int[1]; + Mapping s = inv(typical()).mapSplit(new int[] {1}, out); + assertEquals(probe("split"), "output " + out[0] + "\n" + ChannelText.dump(s)); + } + + // ------------------------------------------------------------------ + // Probe: transformations, rate and equality + // ------------------------------------------------------------------ + + @Test + void transformationsMatchC() { + StringBuilder sb = new StringBuilder(); + GrismMap gm = typical(); + double[] gp = {0.0, 0.01, -0.01, 0.05, BAD}; + double[] wl = {4900.0, 5000.0, 5100.0, 5200.0, BAD}; + lines(sb, "fwd", gp, gm.tran1(5, gp, true)); + lines(sb, "inv", wl, gm.tran1(5, wl, false)); + double[] far = {1.0e6, -1.0e6}; + lines(sb, "inv", far, gm.tran1(2, far, false)); + GrismMap d = new GrismMap(); + double[] dp = {0.0, 0.5}; + lines(sb, "default fwd", dp, d.tran1(2, dp, true)); + double[] wl2 = {4900.0, 5000.0}; + lines(sb, "default inv", wl2, d.tran1(2, wl2, false)); + GrismMap e = typical(); + e.setD("GrismEps", 1.5707963267948966); + lines(sb, "eps 90 fwd", dp, e.tran1(2, dp, true)); + GrismMap b = typical(); + b.setD("GrismG", 1.0); + lines(sb, "sinbeta_r over 1 fwd", dp, b.tran1(2, dp, true)); + assertProbe("transformations", sb.toString()); + } + + private static void lines(StringBuilder sb, String label, double[] in, double[] out) { + for (int i = 0; i < in.length; i++) { + sb.append(label) + .append(' ') + .append(g(in[i])) + .append(" -> ") + .append(g(out[i])) + .append('\n'); + } + } + + /** C's GrismMap has no rate of its own: the base class's numerical estimate is used. */ + @Test + void ratesMatchC() { + GrismMap gm = typical(); + String got = "fwd " + g(gm.rate(new double[] {0.0}, 1, 1)) + "\n" + "inv " + + g(inv(gm).rate(new double[] {5100.0}, 1, 1)) + "\n"; + assertProbe("rate", got); + } + + /** + * C compares the attributes as stored, so a GrismMap with no attribute set differs from one + * with each set to its default; GrismMaps with different Invert attributes are never equal. + */ + @Test + void equalityMatchesC() { + GrismMap a = typical(); + GrismMap b = typical(); + b.setD("GrismNR", 1.6); + GrismMap defaults = new GrismMap(); + defaults.set("GrismNR=1,GrismNRP=0,GrismWaveR=5000,GrismAlpha=0,GrismG=0,GrismM=0,GrismEps=0,GrismTheta=0"); + String got = "same " + eq(a, typical()) + "\n" + + "copy " + eq(a, a.copy()) + "\n" + + "different_nr " + eq(a, b) + "\n" + + "different_m " + eq(a, typicalM(-1)) + "\n" + + "inverted " + eq(a, inv(typical())) + "\n" + + "both_inverted " + eq(inv(typical()), inv(typical())) + "\n" + + "default " + eq(new GrismMap(), new GrismMap()) + "\n" + + "default_vs_set_to_defaults " + eq(new GrismMap(), defaults) + "\n" + + "not_a_grismmap " + eq(a, zoom(2.0)) + "\n"; + assertEquals(probe("equal"), got); + } + + private static int eq(AstObject a, AstObject b) { + return a.astEqual(b) ? 1 : 0; + } + + // ------------------------------------------------------------------ + // Probe: simplification + // ------------------------------------------------------------------ + + private static void assertSimplifies(String name, Mapping map, double xf, double xi) { + Mapping s = map.simplify(); + String got = "class " + s.astClass() + "\n" + ChannelText.dump(s) + "-- transformations\n" + tran(map, xf, xi) + + "-- transformations simplified\n" + tran(s, xf, xi); + assertProbe(name, got); + } + + /** + * A GrismMap applied forward followed by a ZoomMap, or a ZoomMap followed by a GrismMap + * applied inverted, merge into a GrismMap whose GrismG, GrismNRP and GrismWaveR describe the + * scaled wavelengths; the other orders do not merge. + */ + @Test + void zoomMapNeighboursMergeAsC() { + assertSimplifies("zoom_after_forward", series(typical(), zoom(2.0)), 0.01, 10200.0); + assertSimplifies("zoom_before_inverted", series(zoom(0.5), inv(typical())), 10200.0, 0.01); + assertSimplifies("inverted_zoom_before_inverted", series(inv(zoom(2.0)), inv(typical())), 10200.0, 0.01); + assertSimplifies("zoom_before_forward", series(zoom(2.0), typical()), 0.01, 5100.0); + assertSimplifies("zoom_after_inverted", series(inv(typical()), zoom(2.0)), 5100.0, 0.01); + assertSimplifies("zooms_both_sides", series(series(zoom(0.5), inv(typical())), zoom(3.0)), 10200.0, 0.03); + assertSimplifies("zoom_forward_zoom", series(series(zoom(3.0), typical()), zoom(2.0)), 0.01, 10200.0); + GrismMap gm = typical(); + CmpMap c = series(gm, zoom(2.0)); + gm.invert(); + assertSimplifies("grism_inverted_after_combining", c, 0.01, 10200.0); + assertSimplifies("zoom_after_default", series(new GrismMap(), zoom(2.0)), 0.01, 10200.0); + assertSimplifies("zoom_after_two_grisms", series(series(typical(), inv(typicalM(2))), zoom(2.0)), 0.01, 0.02); + } + + /** + * C takes the factor of a ZoomMap whose own Invert attribute is set in the direction opposite + * to the one it is applied in, so the merged GrismMap does not transform as the pair did: a + * ZoomMap inverted before it is combined, after a GrismMap, and a ZoomMap inverted after it is + * combined, on either side. The port merges as C does. + */ + @Test + void anInvertedZoomMapMergesAsCMergesIt() { + assertSimplifies("inverted_zoom_after_forward", series(typical(), inv(zoom(2.0))), 0.01, 2550.0); + ZoomMap z = zoom(2.0); + CmpMap c = series(typical(), z); + z.invert(); + assertSimplifies("zoom_inverted_after_combining", c, 0.01, 10200.0); + ZoomMap z2 = zoom(2.0); + CmpMap c2 = series(z2, inv(typical())); + z2.invert(); + assertSimplifies("zoom_inverted_after_combining_before", c2, 10200.0, 0.01); + } + + /** + * A GrismMap does not merge with a WinMap or a ShiftMap; a WinMap that only scales becomes a + * ZoomMap, with which the GrismMap then merges. + */ + @Test + void winMapAndShiftMapNeighboursSimplifyAsC() { + assertSimplifies("winmap_scale_after_forward", series(typical(), win(2.0, 0.0)), 0.01, 10200.0); + assertSimplifies("winmap_after_forward", series(typical(), win(2.0, 10.0)), 0.01, 10210.0); + assertSimplifies("winmap_scale_before_inverted", series(win(0.5, 0.0), inv(typical())), 10200.0, 0.01); + assertSimplifies("winmap_before_inverted", series(win(0.5, -5.0), inv(typical())), 10210.0, 0.01); + assertSimplifies("shiftmap_after_forward", series(typical(), new ShiftMap(new double[] {10.0})), 0.01, 5110.0); + } + + /** + * GrismMaps applied in opposite directions whose attributes are equal but for GrismM, which + * must differ, cancel to a UnitMap, as C's {@code CanMerge} decides, though they are not + * inverses of each other; others, and GrismMaps in parallel or alone, are left as they are. + */ + @Test + void grismMapNeighboursSimplifyAsC() { + assertSimplifies("inverse_cancel", series(typical(), inv(typicalM(-1))), 0.01, 0.01); + assertSimplifies("inverse_cancel_lower", series(inv(typicalM(-1)), typical()), 5100.0, 5100.0); + assertSimplifies("inverse_same_order", series(typical(), inv(typical())), 0.01, 0.01); + GrismMap other = typicalM(-1); + other.setD("GrismNR", 1.6); + assertSimplifies("inverse_different_nr", series(typical(), inv(other)), 0.01, 0.01); + assertSimplifies("same_direction", series(typical(), typicalM(-1)), 0.0, 0.0); + assertSimplifies("parallel", new CmpMap(typical(), inv(typicalM(-1)), false), 0.01, 0.01); + assertSimplifies("parallel_zoom", new CmpMap(typical(), zoom(2.0), false), 0.01, 0.01); + assertSimplifies("alone", typical(), 0.01, 5100.0); + assertSimplifies("alone_inverted", inv(typical()), 5100.0, 0.01); + GrismMap gm = typical(); + assertSimplifies("shared_pair", series(gm, inv((GrismMap) gm.copy())), 0.01, 0.01); + } + + /** The transformations of the probe's merged pairs are those of the pairs. */ + @Test + void aMergedGrismMapTransformsAsThePair() { + CmpMap pair = series(typical(), zoom(2.0)); + Mapping merged = pair.simplify(); + assertInstanceOf(GrismMap.class, merged); + double[][] in = {{0.0}, {0.02}}; + double[][] a = transformRows(pair, true, in); + double[][] b = transformRows(merged, true, in); + for (int i = 0; i < 2; i++) { + assertTrue(CValues.withinLibmRounding(b[0][i], a[0][i])); + } + } +} diff --git a/src/test/java/uk/ac/starlink/ast/IntraMapOracleTest.java b/src/test/java/uk/ac/starlink/ast/IntraMapOracleTest.java new file mode 100644 index 0000000..86ed4da --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/IntraMapOracleTest.java @@ -0,0 +1,114 @@ +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.assertInstanceOf; + +import com.fasterxml.jackson.databind.JsonNode; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.ProbeData; + +/** + * The IntraMap tests of Rust {@code tests/test_intramap.rs} that compare with the C library, from + * {@code oracle/intramap.json} (C probe {@code intramap_probe.c}, which registers a doubling + * function "double" with SIMPFI and SIMPIF set and one without a forward transformation, "nofwd"). + * + *

An IntraMap made here is named after its Transformer's class, so its dump is compared with + * C's with the function name replaced; an IntraMap read from C's dump through a Channel that has + * the function registered under C's name keeps that name, and is written back byte for byte. + */ +class IntraMapOracleTest { + + private static final JsonNode CONSTS = ProbeData.load("intramap"); + + private static String want(String table, String name) { + for (JsonNode c : CONSTS.get(table)) { + if (c.get(0).textValue().equals(name)) { + return c.get(1).textValue(); + } + } + throw new IllegalStateException("no case " + name + " in " + table); + } + + private static double[] doubles(String name) { + JsonNode n = CONSTS.get(name); + double[] out = new double[n.size()]; + for (int i = 0; i < out.length; i++) { + out[i] = ProbeData.toDouble(n.get(i)); + } + return out; + } + + /** The text a Channel with Full set to {@code full} writes for {@code obj}. */ + private static String dump(AstObject obj, int full) throws IOException { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + Channel ch = new Channel(null, out); + ch.setFull(full); + ch.write(obj); + return new String(out.toByteArray(), StandardCharsets.UTF_8); + } + + /** {@code text} with the function name of {@code map} replaced by C's {@code name}. */ + private static String renamed(String text, IntraMap map, String name) { + return text.replace("Fname = \"" + map.getFname() + "\"", "Fname = \"" + name + "\""); + } + + /** The IntraMap C's dump {@code text} describes, read with {@code t} registered as {@code name}. */ + private static IntraMap read(String text, String name, Transformer t) throws IOException { + Channel ch = new Channel(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)), null); + ch.registerIntra(name, 1, 1, t); + return assertInstanceOf(IntraMap.class, ch.read()); + } + + /** + * The dumps of the probe's IntraMaps: the IntraFlag, an inverted IntraMap, and the {@code Fwd = + * 0} C writes for a function without a forward transformation. + */ + @Test + void dumpsMatchTheCLibrary() throws IOException { + for (int full : new int[] {0, 1}) { + String table = full == 0 ? "DUMPS" : "FULL_DUMPS"; + IntraMap dbl = new IntraMap(new IntraMapTest.Doubler()); + dbl.setC("IntraFlag", "v1"); + assertEquals(want(table, "double_with_flag"), renamed(dump(dbl, full), dbl, "double")); + dbl.invert(); + assertEquals(want(table, "double_inverted"), renamed(dump(dbl, full), dbl, "double")); + IntraMap nofwd = new IntraMap(new IntraMapTest.NoFwd()); + assertEquals(want(table, "nofwd"), renamed(dump(nofwd, full), nofwd, "nofwd")); + } + } + + /** C's dumps read back through a Channel that knows their functions, and are written again. */ + @Test + void cDumpsReadBack() throws IOException { + for (int full : new int[] {0, 1}) { + String table = full == 0 ? "DUMPS" : "FULL_DUMPS"; + IntraMap dbl = read(want(table, "double_with_flag"), "double", new IntraMapTest.Doubler()); + assertEquals("double", dbl.getFname()); + assertEquals("v1", dbl.getC("IntraFlag")); + assertEquals(want(table, "double_with_flag"), dump(dbl, full)); + dbl.invert(); + assertEquals(want(table, "double_inverted"), dump(dbl, full)); + IntraMap inverted = read(want(table, "double_inverted"), "double", new IntraMapTest.Doubler()); + assertEquals(want(table, "double_inverted"), dump(inverted, full)); + IntraMap nofwd = read(want(table, "nofwd"), "nofwd", new IntraMapTest.NoFwd()); + assertEquals(want(table, "nofwd"), dump(nofwd, full)); + } + } + + /** The transformation is applied in the direction the Invert flag makes of the one asked for. */ + @Test + void transformsMatchTheCLibrary() { + double[] input = doubles("INPUT"); + IntraMap dbl = new IntraMap(new IntraMapTest.Doubler()); + assertArrayEquals(doubles("FORWARD"), dbl.tran1(input.length, input, true)); + assertArrayEquals(doubles("INVERSE"), dbl.tran1(input.length, input, false)); + IntraMap inverted = (IntraMap) dbl.copy(); + inverted.invert(); + assertArrayEquals(doubles("FORWARD"), inverted.tran1(input.length, input, false)); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/IntraMapTest.java b/src/test/java/uk/ac/starlink/ast/IntraMapTest.java new file mode 100644 index 0000000..a28404b --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/IntraMapTest.java @@ -0,0 +1,845 @@ +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.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.Serializable; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import java.util.function.Supplier; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.ProbeOutput; + +/** + * Translation of Rust {@code tests/test_intramap.rs} (intramap.c), less the three tests that + * compare with the C probe, which {@link IntraMapOracleTest} translates, and of jniast's IntraMap + * tests (AstTest {@code testMapping}, ThreadTest {@code testIntraMap}), with the Java API: the + * Transformer classes; IntraMaps written by name and read back with the Transformer of an IntraMap + * made in the same process, or one registered with the Channel, through a Channel and a FitsChan, + * at the top level and inside a CmpMap, and AST__URITF where the name stands for no Transformer; + * the numbers of coordinates C's loader checks (probe {@code intramap_load_probe.c}); the errors of + * a Transformer that throws or returns arrays of the wrong shape; the registration of functions, + * C's {@code astIntraReg}; and simplification of IntraMaps in series (intramap.c {@code MapMerge}). + */ +class IntraMapTest { + + private static final double BAD = AstObject.AST__BAD; + + private static final Map LOAD_PROBE = ProbeOutput.load("intramap_load_probe"); + + /** A doubling transformation, as the probe registers "double": forward 2x, inverse x/2. */ + static final class Doubler extends Transformer1 { + @Override + public boolean simpFI() { + return true; + } + + @Override + public boolean simpIF() { + return true; + } + + @Override + public double[] tran1(int npoint, double[] xin, boolean forward) { + double[] out = new double[npoint]; + for (int i = 0; i < npoint; i++) { + double x = xin[i]; + out[i] = x == BAD ? BAD : forward ? 2.0 * x : 0.5 * x; + } + return out; + } + + @Override + public String getPurpose() { + return "Double the value"; + } + + @Override + public String getAuthor() { + return "AST test suite"; + } + + @Override + public String getContact() { + return "starlink-ast"; + } + } + + /** The probe's "nofwd": the doubling transformation without a forward direction. */ + static final class NoFwd extends Transformer1 { + @Override + public boolean hasForward() { + return false; + } + + @Override + public double[] tran1(int npoint, double[] xin, boolean forward) { + double[] out = new double[npoint]; + for (int i = 0; i < npoint; i++) { + out[i] = xin[i] == BAD ? BAD : 0.5 * xin[i]; + } + return out; + } + + @Override + public String getPurpose() { + return "No forward transformation"; + } + + @Override + public String getAuthor() { + return "AST test suite"; + } + + @Override + public String getContact() { + return "starlink-ast"; + } + } + + /** jniast's {@code TestTransformer2} (AstTest.java): a two-dimensional stretch, Serializable as there. */ + static final class Stretch extends Transformer2 implements Serializable { + private static final long serialVersionUID = 1L; + private final double xfactor; + private final double yfactor; + + Stretch(double x, double y) { + xfactor = x; + yfactor = y; + } + + @Override + public double[][] tran2(int npoint, double[] xin, double[] yin, boolean forward) { + double[] xout = new double[npoint]; + double[] yout = new double[npoint]; + double xf = forward ? xfactor : 1.0 / xfactor; + double yf = forward ? yfactor : 1.0 / yfactor; + for (int i = 0; i < npoint; i++) { + xout[i] = xf * xin[i]; + yout[i] = yf * yin[i]; + } + return new double[][] {xout, yout}; + } + + @Override + public boolean simpFI() { + return true; + } + + @Override + public boolean simpIF() { + return true; + } + + @Override + public boolean hasInverse() { + return xfactor != 0 && yfactor != 0; + } + + @Override + public String getAuthor() { + return "Mark Taylor (Starlink)"; + } + + @Override + public String getContact() { + return "Desolation Row"; + } + + @Override + public String getPurpose() { + return "Two-dimensional stretch"; + } + } + + /** A Transformer of any numbers of coordinates whose transformation is {@code body}. */ + private static class Failing extends Transformer { + private final Supplier body; + private final Exception thrown; + + Failing(Supplier body) { + this.body = body; + this.thrown = null; + } + + Failing(Exception thrown) { + this.body = null; + this.thrown = thrown; + } + + @Override + public boolean canTransformCoords(int nin, int nout) { + return true; + } + + @Override + public double[][] tranP(int npoint, int ncoordIn, double[][] in, boolean forward, int ncoordOut) + throws Exception { + if (thrown != null) { + throw thrown; + } + return body.get(); + } + + @Override + public String getPurpose() { + return ""; + } + + @Override + public String getAuthor() { + return ""; + } + + @Override + public String getContact() { + return ""; + } + } + + /** + * C's {@code Sum2} of {@code probes/intramap_load_probe.c}: two inputs and one output; forward + * the sum of the inputs, inverse half the input on each output. + */ + static final class Sum2 extends Transformer { + @Override + public boolean canTransformCoords(int nin, int nout) { + return nin == 2 && nout == 1; + } + + @Override + public double[][] tranP(int npoint, int ncoordIn, double[][] in, boolean forward, int ncoordOut) { + double[][] out = new double[ncoordOut][npoint]; + for (int i = 0; i < npoint; i++) { + if (forward) { + out[0][i] = in[0][i] + in[1][i]; + } else { + out[0][i] = 0.5 * in[0][i]; + out[1][i] = 0.5 * in[0][i]; + } + } + return out; + } + + @Override + public String getPurpose() { + return "Sum of two inputs"; + } + + @Override + public String getAuthor() { + return "AST test suite"; + } + + @Override + public String getContact() { + return "starlink-ast"; + } + } + + /** The text a default Channel writes for {@code obj}. */ + private static String dump(AstObject obj) { + return ChannelText.dump(obj); + } + + private static Channel reader(String text) { + return new Channel(new ByteArrayInputStream(text.getBytes(StandardCharsets.UTF_8)), null); + } + + private static AstObject readBack(String text) throws IOException { + return reader(text).read(); + } + + /** + * {@code text} with the function name of {@code map} replaced by {@code name}, as a dump of + * {@code map} reads in another process, where its name stands for no Transformer. + */ + private static String renamed(String text, IntraMap map, String name) { + return text.replace("Fname = \"" + map.getFname() + "\"", "Fname = \"" + name + "\""); + } + + // ------------------------------------------------------------------ + // Translations of test_intramap.rs + // ------------------------------------------------------------------ + + /** NOFWD and NOINV decide which directions are defined, relative to the Invert flag. */ + @Test + void flagsDecideTheDefinedDirections() { + IntraMap m = new IntraMap(new NoFwd()); + assertFalse(m.getTranForward()); + assertTrue(m.getTranInverse()); + AstException e = assertThrows(AstException.class, () -> m.tran1(1, new double[] {1.0}, true)); + assertEquals(AstException.AST__TRNND, e.getStatus()); + m.invert(); + assertTrue(m.getTranForward()); + assertFalse(m.getTranInverse()); + IntraMap noinv = new IntraMap(new Stretch(0.0, 2.0)); + assertTrue(noinv.getTranForward()); + assertFalse(noinv.getTranInverse()); + } + + /** + * jniast's construction checks (jni/IntraMap.c {@code construct}): a Transformer that cannot + * map the numbers of coordinates given is an IllegalArgumentException, and the registration of + * one Transformer with other numbers of coordinates than an IntraMap in use made with it is + * AST__MRITF, as C's {@code astIntraReg} reports it. C's {@code astInitIntraMap} checks + * (AST__BADNI, AST__BADNO) cannot fail, since the function is registered with the IntraMap's + * numbers. + */ + @Test + void constructionChecksAsJniastDoes() { + IllegalArgumentException e = + assertThrows(IllegalArgumentException.class, () -> new IntraMap(new Doubler(), 2, 1)); + assertEquals("Transformer will not map 2 -> 1 coordinates", e.getMessage()); + assertThrows(IllegalArgumentException.class, () -> new IntraMap(new Stretch(1, 1), 1, 1)); + assertThrows(NullPointerException.class, () -> new IntraMap((Transformer) null, 1, 1)); + Failing any = new Failing(() -> null); + IntraMap m = new IntraMap(any, 3, 2); + assertEquals(3, m.getNin()); + assertEquals(2, m.getNout()); + IntraMap again = new IntraMap(any, 3, 2); + assertEquals(m.getFname(), again.getFname()); + AstException mritf = assertThrows(AstException.class, () -> new IntraMap(any, 2, 2)); + assertEquals(AstException.AST__MRITF, mritf.getStatus()); + } + + /** + * intramap.c {@code IntraReg} and {@code CleanName}, as a Channel registers a function: a blank + * name is AST__ITFNI, negative numbers of coordinates other than AST__ANY are AST__BADNI and + * AST__BADNO, a name already registered is AST__MRITF unless the registration is the same, and + * white space in a name is ignored. The process-wide table refuses a name held by another + * Transformer in use in the same way. + */ + @Test + void registryChecksAsCDoes() { + Channel ch = reader(""); + Doubler t = new Doubler(); + AstException e = assertThrows(AstException.class, () -> ch.registerIntra(" \t ", 1, 1, t)); + assertEquals(AstException.AST__ITFNI, e.getStatus()); + e = assertThrows(AstException.class, () -> ch.registerIntra("double", -2, 1, t)); + assertEquals(AstException.AST__BADNI, e.getStatus()); + e = assertThrows(AstException.class, () -> ch.registerIntra("double", 1, -3, t)); + assertEquals(AstException.AST__BADNO, e.getStatus()); + ch.registerIntra("any", IntraRegistry.AST__ANY, IntraRegistry.AST__ANY, t); + ch.registerIntra("double", 1, 1, t); + ch.registerIntra("double", 1, 1, t); + e = assertThrows(AstException.class, () -> ch.registerIntra("double", 1, 1, new Doubler())); + assertEquals(AstException.AST__MRITF, e.getStatus()); + e = assertThrows(AstException.class, () -> ch.registerIntra("double", 1, 2, t)); + assertEquals(AstException.AST__MRITF, e.getStatus()); + e = assertThrows(AstException.class, () -> ch.registerIntra(" dou ble ", 1, 1, new NoFwd())); + assertEquals(AstException.AST__MRITF, e.getStatus()); + + String name = IntraMapTest.class.getName() + "#collision"; + assertEquals(name, IntraRegistry.registerMade(name, 1, 1, t).name); + assertEquals(name, IntraRegistry.registerMade(name, 1, 1, t).name); + e = assertThrows(AstException.class, () -> IntraRegistry.registerMade(name, 2, 2, t)); + assertEquals(AstException.AST__MRITF, e.getStatus()); + } + + /** + * An IntraMap is written as C writes it, by name, and reads back in the same process with the + * Transformer of the IntraMap that was written, while that is in use. + */ + @Test + void aSameProcessReadFindsTheTransformer() throws IOException { + Doubler t = new Doubler(); + IntraMap dbl = new IntraMap(t); + dbl.setC("IntraFlag", "v1"); + String text = dump(dbl); + assertTrue(text.contains("Iflag = \"v1\""), text); + IntraMap back = assertInstanceOf(IntraMap.class, readBack(text)); + assertSame(t, back.getTransformer()); + assertTrue(back.astEqual(dbl)); + assertEquals(text, dump(back)); + assertArrayEquals(new double[] {3.0}, back.tran1(1, new double[] {1.5}, true)); + } + + /** + * An IntraMap read where its function name stands for no Transformer, as in another process + * (here a name no IntraMap was made with), is AST__URITF, as C's loader reports an + * unregistered function, unless the Channel reading has a Transformer registered under it. + */ + @Test + void aReadInANewProcessNeedsTheTransformationRegistered() throws IOException { + Doubler t = new Doubler(); + IntraMap dbl = new IntraMap(t); + String gone = "org.example.Gone#1f2e3d4c"; + String text = renamed(dump(dbl), dbl, gone); + AstException e = assertThrows(AstException.class, () -> readBack(text)); + assertEquals(AstException.AST__URITF, e.getStatus()); + assertEquals( + "astLoadIntraMap(Channel): An IntraMap was read which uses an unknown transformation function.\n" + + "This is a private extension to the AST library: to handle it, you must obtain the source " + + "code from its author.\n" + + "You can then register it with AST in your software by calling astIntraReg (see SUN/211).\n" + + " \n" + + " Function name: \"" + gone + "\".\n" + + " Purpose: \"Double the value\".\n" + + " Author: \"AST test suite\".\n" + + " Contact address: \"starlink-ast\".\n" + + " \n" + + "Error while reading a IntraMap from a Channel.", + e.getMsgText()); + + Channel ch = reader(text); + ch.registerIntra(gone, 1, 1, t); + IntraMap back = assertInstanceOf(IntraMap.class, ch.read()); + assertEquals(gone, back.getFname()); + assertEquals(text, dump(back)); + } + + /** + * A registration made with a Channel serves IntraMaps nested inside other Mappings, and one + * without the function needed is AST__URITF. + */ + @Test + void aNestedIntraMapReadsByName() throws IOException { + Doubler t = new Doubler(); + IntraMap im = new IntraMap(t); + CmpMap cmp = new CmpMap(new ZoomMap(1, 3.0), im, true); + String text = renamed(dump(cmp), im, "double"); + + Channel ch = reader(text); + ch.registerIntra("nofwd", 1, 1, new NoFwd()); + AstException e = assertThrows(AstException.class, ch::read); + assertEquals(AstException.AST__URITF, e.getStatus()); + + ch = reader(text); + ch.registerIntra("double", 1, 1, t); + Mapping back = (Mapping) ch.read(); + assertArrayEquals(new double[] {9.0}, back.tran1(1, new double[] {1.5}, true)); + assertEquals(text, dump(back)); + } + + /** + * intramap.c {@code Equal}: the same function and an IntraFlag set on both and equal, so two + * IntraMaps without one are not equal. + */ + @Test + void equalityNeedsAnIntraFlagOnBoth() { + IntraMap a = new IntraMap(new Doubler()); + IntraMap b = (IntraMap) a.copy(); + assertFalse(a.astEqual(b)); + a.setC("IntraFlag", "x"); + assertFalse(a.astEqual(b)); + b.setC("IntraFlag", "x"); + assertTrue(a.astEqual(b)); + b.invert(); + assertFalse(a.astEqual(b)); + IntraMap c = new IntraMap(new Doubler()); + c.setC("IntraFlag", "x"); + assertFalse(a.astEqual(c)); + } + + /** IntraFlag get, set, test and clear (intramap.c); a shared IntraMap refuses a change. */ + @Test + void intraFlagSetTestClear() { + IntraMap m = new IntraMap(new Doubler()); + assertFalse(m.test("IntraFlag")); + assertEquals("", m.getC("IntraFlag")); + m.set("IntraFlag=abc"); + assertTrue(m.test("IntraFlag")); + assertEquals("abc", m.getC("IntraFlag")); + m.clear("IntraFlag"); + assertFalse(m.test("IntraFlag")); + new CmpMap(m, new UnitMap(1), true); + AstException e = assertThrows(AstException.class, () -> m.setC("IntraFlag", "x")); + assertEquals(AstException.AST__IMMUT, e.getStatus()); + e = assertThrows(AstException.class, () -> m.clear("IntraFlag")); + assertEquals(AstException.AST__IMMUT, e.getStatus()); + } + + /** + * An error from the transformation is reported as one signalled by the named function, with + * jniast's status AST__ITFER (jni/IntraMap.c {@code tranWrap}) and the Transformer's exception + * as its cause. + */ + @Test + void transformationErrorsNameTheFunction() { + IllegalStateException failure = new IllegalStateException("it failed"); + IntraMap m = new IntraMap(new Failing(failure), 2, 2); + AstException e = + assertThrows(AstException.class, () -> m.tran2(1, new double[] {1.0}, new double[] {2.0}, true)); + assertEquals(AstException.AST__ITFER, e.getStatus()); + assertEquals( + "astTransform(IntraMap): Error signalled by \"" + m.getFname() + "\" transformation function.", + e.getMsgText()); + assertSame(failure, e.getCause()); + } + + // ------------------------------------------------------------------ + // Review Focus 3: a Transformer that fails + // ------------------------------------------------------------------ + + /** + * A Transformer that throws, or returns null, too few arrays, a null array or an array too + * short, gives AST__ITFER, whether the IntraMap is applied alone or inside a CmpMap; arrays + * longer than needed are accepted, as jniast's {@code jniastCheckArrayLength} accepts them. + */ + @Test + void failingTransformersGiveItfer() { + Transformer[] failing = { + new Failing(new IllegalArgumentException("bad")), + new Failing(new Exception("checked")), + new Failing(new IOException("io")), + new Failing(() -> null), + new Failing(() -> new double[][] {{1, 2}}), + new Failing(() -> new double[][] {{1, 2}, null}), + new Failing(() -> new double[][] {{1, 2}, {3}}), + }; + double[] x = {1, 2}; + double[] y = {3, 4}; + for (Transformer t : failing) { + IntraMap m = new IntraMap(t, 2, 2); + AstException e = assertThrows(AstException.class, () -> m.tran2(2, x, y, true)); + assertEquals(AstException.AST__ITFER, e.getStatus()); + assertNotNull(e.getCause()); + CmpMap cmp = new CmpMap(new ShiftMap(new double[] {1, 1}), m, true); + e = assertThrows(AstException.class, () -> cmp.tran2(2, x, y, true)); + assertEquals(AstException.AST__ITFER, e.getStatus()); + } + IntraMap longer = new IntraMap(new Failing(() -> new double[][] {{5, 6, 7}, {8, 9, 10}, {0}}), 2, 2); + double[][] out = longer.tran2(2, x, y, true); + assertArrayEquals(new double[] {5, 6}, out[0]); + assertArrayEquals(new double[] {8, 9}, out[1]); + } + + /** + * A read calls no method of the Transformer: its flags and strings are those registered, so a + * Transformer whose methods throw once the IntraMap is made does not make the read throw. + */ + @Test + void aReadCallsNoTransformerMethod() throws IOException { + int[] calls = new int[1]; + Failing touchy = new Failing(() -> null) { + @Override + public boolean hasForward() { + if (calls[0]++ > 0) { + throw new IllegalStateException("called again"); + } + return true; + } + + @Override + public boolean canTransformCoords(int nin, int nout) { + if (calls[0] > 0) { + throw new IllegalStateException("called again"); + } + return true; + } + }; + IntraMap m = new IntraMap(touchy, 1, 1); + Mapping back = (Mapping) readBack(dump(new CmpMap(new UnitMap(1), m, true))); + assertEquals(1, back.getNin()); + assertEquals(1, calls[0]); + } + + /** + * Under the NaN protocol a bad input reaches the Transformer as AST__BAD, as C passes it, never + * as NaN. + */ + @Test + void badInputsReachTheTransformerAsBad() { + Failing marksBad = new Failing(() -> null) { + @Override + public double[][] tranP(int npoint, int ncoordIn, double[][] in, boolean forward, int ncoordOut) { + double[] out = new double[npoint]; + for (int i = 0; i < npoint; i++) { + out[i] = in[0][i] == BAD ? 7.0 : in[0][i]; + } + return new double[][] {out}; + } + }; + IntraMap m = new IntraMap(marksBad, 1, 1); + CmpMap cmp = new CmpMap(new ZoomMap(1, 1.0), m, true); + double[][] out = cmp.transformNanProtocol(new double[][] {{BAD, 2.0}}, 2, true); + assertArrayEquals(new double[] {7.0, 2.0}, out[0]); + } + + // ------------------------------------------------------------------ + // jniast's tests + // ------------------------------------------------------------------ + + /** + * jniast's AstTest {@code testMapping} (AstTest.java:595-626), less the XmlChan part, a class + * this library lacks: an IntraMap written to a Channel and to a FitsChan reads back and + * transforms as before, and so does the original. + */ + @Test + void jniastRoundTrip() throws IOException { + Mapping imap = new IntraMap(new Stretch(2.0, 4.0)); + double[] xina = {1, 2, 3}; + double[] yina = {100, 200, 300}; + double[][] resulta = imap.tran2(3, xina, yina, true); + assertArrayEquals(new double[] {2, 4, 6}, resulta[0]); + assertArrayEquals(new double[] {400, 800, 1200}, resulta[1]); + + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + assertEquals(1, new Channel(null, bout).write(imap)); + Mapping jmap = (Mapping) readBack(new String(bout.toByteArray(), StandardCharsets.UTF_8)); + double[][] resultb = jmap.tran2(3, xina, yina, true); + assertArrayEquals(resulta[0], resultb[0]); + assertArrayEquals(resulta[1], resultb[1]); + + FitsChan fc = new FitsChan(); + assertEquals(1, fc.write(jmap)); + fc.setCard(1); + Mapping kmap = (Mapping) fc.read(); + double[][] resultc = kmap.tran2(3, xina, yina, true); + assertArrayEquals(resulta[0], resultc[0]); + assertArrayEquals(resulta[1], resultc[1]); + + double[][] resulte = imap.tran2(3, xina, yina, true); + assertArrayEquals(resulta[0], resulte[0]); + assertArrayEquals(resulta[1], resulte[1]); + } + + /** + * jniast's ThreadTest {@code testIntraMap} (ThreadTest.java:29-48): an IntraMap made on one + * thread transforms on another. + */ + @Test + void jniastIntraMapOnAnotherThread() throws InterruptedException { + double z = 3.0; + IntraMap map = new IntraMap(new Stretch(z, z)); + int np = 2; + double[] xin = {1, 4}; + double[] yin = {8, 2}; + double[] xout = new double[np]; + double[] yout = new double[np]; + Thread thread = new Thread( + () -> { + double[][] out = map.tran2(np, xin, yin, true); + System.arraycopy(out[0], 0, xout, 0, np); + System.arraycopy(out[1], 0, yout, 0, np); + }, + "IntraThread"); + thread.start(); + thread.join(); + assertArrayEquals(new double[] {xin[0] * z, xin[1] * z}, xout); + assertArrayEquals(new double[] {yin[0] * z, yin[1] * z}, yout); + } + + // ------------------------------------------------------------------ + // Writing and reading by name + // ------------------------------------------------------------------ + + /** + * An IntraMap inside a CmpMap reads back in the same process, and two IntraMaps of one + * Transformer still simplify to a UnitMap after the round trip. + */ + @Test + void aRoundTripInsideACmpMap() throws IOException { + IntraMap im = new IntraMap(new Stretch(2.0, 4.0)); + IntraMap inv = (IntraMap) im.copy(); + inv.invert(); + CmpMap cmp = new CmpMap(new CmpMap(new ZoomMap(2, 3.0), im, true), inv, true); + String text = dump(cmp); + assertFalse(text.contains("Iflag"), text); + Mapping back = (Mapping) readBack(text); + double[][] out = back.tran2(1, new double[] {1}, new double[] {2}, true); + assertArrayEquals(new double[] {3}, out[0]); + assertArrayEquals(new double[] {6}, out[1]); + assertEquals(text, dump(back)); + assertInstanceOf(ZoomMap.class, back.simplify()); + } + + /** + * Channel and FitsChan writes call {@code channelize} and {@code unChannelize}, which do + * nothing for an IntraMap, so an IntraMap whose Transformer is not Serializable is written. + */ + @Test + void writingNeedsNoSerializableTransformer() throws IOException { + IntraMap m = new IntraMap(new Doubler()); + String before = dump(m); + m.channelize(); + m.unChannelize(); + assertEquals(before, dump(m)); + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + assertEquals(1, new Channel(null, bout).write(m)); + assertEquals(before, new String(bout.toByteArray(), StandardCharsets.UTF_8)); + FitsChan fc = new FitsChan(); + assertEquals(1, fc.write(m)); + fc.setCard(1); + assertArrayEquals(new double[] {3.0}, ((Mapping) fc.read()).tran1(1, new double[] {1.5}, true)); + } + + /** + * An IntraFlag value is read as the string it is, never as a serialised object: a dump that + * jniast wrote with a serialised Transformer in IntraFlag reads back, by name, with that text + * as its IntraFlag, or is AST__URITF where the name stands for no Transformer. + */ + @Test + void anIntraFlagIsOnlyAString() throws IOException { + Doubler t = new Doubler(); + IntraMap m = new IntraMap(t); + String blob = "s2OAFAAAAAAAAAA+/AAA"; + m.setC("IntraFlag", blob); + String text = dump(m); + IntraMap back = assertInstanceOf(IntraMap.class, readBack(text)); + assertEquals(blob, back.getC("IntraFlag")); + assertSame(t, back.getTransformer()); + AstException e = assertThrows(AstException.class, () -> readBack(renamed(text, m, "unknown"))); + assertEquals(AstException.AST__URITF, e.getStatus()); + } + + /** + * C's {@code astLoadIntraMap} compares the numbers of coordinates of the IntraMap read, as its + * Invert attribute leaves them, with those registered (probe {@code intramap_load_probe.c}): an + * IntraMap of a function with two inputs and one output reads back as made, and inverted is + * AST__BADNI, whether the function is registered with the Channel or by the IntraMap made in + * this process. + */ + @Test + void anInvertedNonSquareIntraMapCannotBeRead() throws IOException { + Sum2 t = new Sum2(); + IntraMap m = new IntraMap(t, 2, 1); + for (String name : new String[] {"as_made", "inverted"}) { + String[] parts = LOAD_PROBE.get(name).split("-- read\n", -1); + String cdump = parts[0]; + assertEquals(cdump, renamed(dump(m), m, "sum2"), name); + Channel ch = reader(cdump); + ch.registerIntra("sum2", 2, 1, t); + String result; + try { + Mapping back = (Mapping) ch.read(); + double[] out = back.tranP(1, 2, new double[][] {{1.5}, {2.25}}, true, 1)[0]; + result = + "Nin " + back.getNin() + " forward of (1.5, 2.25): " + CFormat.format("%.17g", out[0]) + " 0\n"; + } catch (AstException e) { + StringBuilder sb = new StringBuilder(); + for (String line : ProbeOutput.trimLines(e.getMsgText()).split("\n", -1)) { + sb.append("! ").append(line).append('\n'); + } + result = sb + "status " + e.getStatus() + "\n"; + } + StringBuilder want = new StringBuilder(); + for (String line : parts[1].split("\n", -1)) { + if (!line.isEmpty() && !line.startsWith("!! ")) { + want.append(line).append('\n'); + } + } + assertEquals(want.toString(), result, name); + AstException same = null; + try { + readBack(dump(m)); + } catch (AstException e) { + same = e; + } + assertEquals("inverted".equals(name), same != null, name); + if (same != null) { + assertEquals(AstException.AST__BADNI, same.getStatus()); + } + m.invert(); + } + } + + /** + * When the name made from a Transformer's identity hash code is held by another Transformer in + * use, as two Transformers' hash codes may coincide, the IntraMap takes the next free name, + * with {@code #1}, {@code #2}, ... added, and is written and read back under it. + */ + @Test + void aSharedIdentityHashGivesAnotherName() throws IOException { + Doubler t = new Doubler(); + String base = Doubler.class.getName() + "#" + Integer.toHexString(System.identityHashCode(t)); + Doubler other1 = new Doubler(); + Doubler other2 = new Doubler(); + IntraRegistry.registerMade(base, 1, 1, other1); + IntraRegistry.registerMade(base + "#1", 1, 1, other2); + IntraMap m = new IntraMap(t); + assertEquals(base + "#2", m.getFname()); + IntraMap again = new IntraMap(t); + assertEquals(base + "#2", again.getFname()); + IntraMap back = assertInstanceOf(IntraMap.class, readBack(dump(m))); + assertSame(t, back.getTransformer()); + assertEquals(base + "#2", back.getFname()); + assertSame(other1, IntraRegistry.lookup(base).trans); + assertSame(other2, IntraRegistry.lookup(base + "#1").trans); + } + + /** + * Every IntraMap of one Transformer has one name: after a collision has given it {@code #1}, + * and the Transformer holding the base name has been garbage-collected, a new IntraMap of it + * still takes {@code #1}, not the free base name. + */ + @Test + void oneTransformerKeepsItsNameAfterACollisionLapses() { + Doubler t = new Doubler(); + String base = Doubler.class.getName() + "#" + Integer.toHexString(System.identityHashCode(t)); + Doubler other = new Doubler(); + IntraRegistry.registerMade(base, 1, 1, other); + IntraMap m = new IntraMap(t); + assertEquals(base + "#1", m.getFname()); + IntraRegistry.lapse(base); + assertNull(IntraRegistry.lookup(base)); + IntraMap again = new IntraMap(t); + assertEquals(base + "#1", again.getFname()); + assertSame(t, IntraRegistry.lookup(base + "#1").trans); + } + + /** jniast's {@code copy}: a copy shares the Transformer and the function name. */ + @Test + void aCopySharesTheTransformer() { + IntraMap m = new IntraMap(new Stretch(2.0, 4.0)); + AstObject c = m.copy(); + IntraMap copy = assertInstanceOf(IntraMap.class, c); + assertNotSame(m, copy); + assertSame(m.getTransformer(), copy.getTransformer()); + assertEquals(m.getFname(), copy.getFname()); + String fname = Stretch.class.getName() + "#" + Integer.toHexString(System.identityHashCode(m.getTransformer())); + assertEquals(fname, m.getFname()); + } + + // ------------------------------------------------------------------ + // Simplification (intramap.c MapMerge) + // ------------------------------------------------------------------ + + /** + * IntraMaps of one function in series cancel to a UnitMap when they keep the number of + * coordinates and the function's SIMPFI (forward then inverse) or SIMPIF (inverse then + * forward) flag is set and their IntraFlag values agree (unset reading as empty); not in + * parallel, not in the same direction, not for different functions. + */ + @Test + void intraMapsInSeriesMergeAsCDoes() { + Doubler t = new Doubler(); + IntraMap a = new IntraMap(t); + IntraMap b = new IntraMap(t); + b.invert(); + assertInstanceOf(UnitMap.class, new CmpMap(a, b, true).simplify()); + assertInstanceOf(UnitMap.class, new CmpMap(b, a, true).simplify()); + assertInstanceOf(CmpMap.class, new CmpMap(a, a, true).simplify()); + assertInstanceOf(CmpMap.class, new CmpMap(a, b, false).simplify()); + + IntraMap other = new IntraMap(new Doubler()); + other.invert(); + assertInstanceOf(CmpMap.class, new CmpMap(a, other, true).simplify()); + + IntraMap flagged = new IntraMap(t); + flagged.invert(); + flagged.setC("IntraFlag", "f"); + assertInstanceOf(CmpMap.class, new CmpMap(a, flagged, true).simplify()); + IntraMap flagged2 = new IntraMap(t); + flagged2.setC("IntraFlag", "f"); + assertInstanceOf(UnitMap.class, new CmpMap(flagged2, flagged, true).simplify()); + + Failing none = new Failing(() -> null); + IntraMap n1 = new IntraMap(none, 1, 1); + IntraMap n2 = new IntraMap(none, 1, 1); + n2.invert(); + assertInstanceOf(CmpMap.class, new CmpMap(n1, n2, 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 f0d121a..7d53b52 100644 --- a/src/test/java/uk/ac/starlink/ast/JniastApiTest.java +++ b/src/test/java/uk/ac/starlink/ast/JniastApiTest.java @@ -44,15 +44,23 @@ class JniastApiTest { "CmpFrame", "CmpMap", "DSBSpecFrame", + "DssMap", "FitsChan", "FluxFrame", "Frame", "FrameSet", + "GrismMap", + "IntraMap", "KeyMap", + "LutMap", "Mapping", + "MathMap", "MatrixMap", + "NeedsChannelizing", + "PcdMap", "PermMap", "PolyMap", + "RateMap", "ResampleFlags", "ShiftMap", "SkyAxis", @@ -62,8 +70,13 @@ class JniastApiTest { "SpecFrame", "SpecMap", "SphMap", + "SwitchMap", "TimeFrame", "TimeMap", + "TranMap", + "Transformer", + "Transformer1", + "Transformer2", "UinterpCalculator", "Ukern1Calculator", "UnitMap", diff --git a/src/test/java/uk/ac/starlink/ast/LinearApproxTest.java b/src/test/java/uk/ac/starlink/ast/LinearApproxTest.java index ca6ee69..ded35c0 100644 --- a/src/test/java/uk/ac/starlink/ast/LinearApproxTest.java +++ b/src/test/java/uk/ac/starlink/ast/LinearApproxTest.java @@ -13,9 +13,7 @@ * the tolerance of 1e-12 is the Rust tests' own. A fit is {@code Nout} constant terms followed by * the gradients, row by row. * - *

{@code returns_correct_type} tests a Rust type. In - * {@code transform_error_is_reported}, a Mapping with no inverse, inverted, stands in for the - * inverted RateMap, which is outside the first phase. + *

{@code returns_correct_type} tests a Rust type. */ class LinearApproxTest { @@ -84,7 +82,7 @@ void dimensionMismatchIsAnError() { @Test void transformErrorIsReported() { - NoInverseMap rm = new NoInverseMap(); + RateMap rm = new RateMap(new ZoomMap(1, 2.0), 1, 1); rm.invert(); AstException e = assertThrows(AstException.class, () -> rm.linearApprox(new double[] {0.0}, new double[] {1.0}, 1e-3)); diff --git a/src/test/java/uk/ac/starlink/ast/LutMapForwardOracleTest.java b/src/test/java/uk/ac/starlink/ast/LutMapForwardOracleTest.java new file mode 100644 index 0000000..729f296 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/LutMapForwardOracleTest.java @@ -0,0 +1,50 @@ +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.List; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.ProbeData; + +/** + * Translation of Rust {@code tests/test_lutmap_forward_oracle.rs}: a LutMap's forward + * transformation against C's, bit for bit, between nodes with an increment that is not a power of + * two, beyond either end, on the last node beside a bad entry, and at half increments for + * nearest-neighbour interpolation (lutmap.c {@code Transform}), from {@code + * oracle/lutmap_forward.json} (C probe {@code tools/oracle_fixtures/lutmap_forward_probe.c}). + */ +class LutMapForwardOracleTest { + + 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; + } + + @Test + void forwardMatchesTheCLibraryBitForBit() { + JsonNode cases = ProbeData.load("lutmap_forward").get("CASES"); + List failures = new ArrayList<>(); + for (JsonNode c : cases) { + String name = c.get(0).asText(); + LutMap lm = + new LutMap(doubles(c.get(1)), c.get(2).asDouble(), c.get(3).asDouble()); + lm.setI("LutInterp", c.get(4).asBoolean() ? 1 : 0); + double[] input = doubles(c.get(5)); + double[] want = doubles(c.get(6)); + double[] got = lm.tran1(input.length, input, true); + for (int i = 0; i < input.length; i++) { + if (Double.doubleToRawLongBits(got[i]) != Double.doubleToRawLongBits(want[i])) { + failures.add(name + " at " + input[i] + ": " + got[i] + ", C " + want[i]); + } + } + } + assertEquals(6, cases.size()); + assertTrue(failures.isEmpty(), String.join("\n", failures)); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/LutMapTest.java b/src/test/java/uk/ac/starlink/ast/LutMapTest.java new file mode 100644 index 0000000..233e572 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/LutMapTest.java @@ -0,0 +1,836 @@ +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 com.fasterxml.jackson.databind.JsonNode; +import java.util.ArrayList; +import java.util.Arrays; +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_lutmap.rs} and {@code tests/test_lutmap_inverse.rs}, and of + * C's {@code testlutmap.c}. + * + *

The Rust tests read the monotonicity of the table, which C keeps to itself; here they read + * what C makes of it, whether the inverse transformation is defined. Rust's {@code + * lutmap_interp_change_applies_to_a_repeated_value} expects the result of the new interpolation + * method, where C returns the result it kept for the same input; the test here expects C's value, + * from the probe {@code probes/lutmap_probe.c}. + * + *

The cases of {@code probes/lutmap_probe.out} pin what no fixture or oracle holds: the + * simplification of a LutMap beside a WinMap, a ZoomMap and its own inverse, its dumps through a + * Channel and a FitsChan with LutInterp and LutEpsilon set and unset, its attribute strings, and + * the input and output it keeps from its last transformation. + */ +class LutMapTest { + + private static final double BAD = AstObject.AST__BAD; + + /** A table that is not linear, so the WinMap replacement cannot hide the cancellation. */ + private static final double[] CURVED = {0.0, 1.0, 4.0, 9.0, 16.0}; + + private static final double[] LINEAR = {1.0, 3.0, 5.0, 7.0, 9.0}; + + private static final Map PROBE_CASES = ProbeOutput.load("lutmap_probe"); + + private static double at(Mapping m, double x, boolean forward) { + return m.tran1(1, new double[] {x}, forward)[0]; + } + + private static LutMap inverted(LutMap m) { + LutMap c = (LutMap) m.copy(); + c.invert(); + return c; + } + + private static String probe(String name) { + String text = PROBE_CASES.get(name); + if (text == null) { + throw new IllegalStateException("no probe case " + name); + } + return text; + } + + // ------------------------------------------------------------------ + // Construction + // ------------------------------------------------------------------ + + @Test + void lutmapDimensions() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + assertEquals(1, m.getNin()); + assertEquals(1, m.getNout()); + } + + @Test + void lutmapEmptyTableRejected() { + AstException e = assertThrows(AstException.class, () -> new LutMap(new double[0], 0.0, 1.0)); + assertEquals(AstException.AST__LUTIN, e.getStatus()); + } + + @Test + void lutmapZeroIncRejected() { + AstException e = assertThrows(AstException.class, () -> new LutMap(new double[] {1.0, 2.0}, 0.0, 0.0)); + assertEquals(AstException.AST__LUTII, e.getStatus()); + } + + /** The table is stored as C's {@code astGetLutMapInfo} gives it, an entry that is not finite being bad. */ + @Test + void theTableIsStoredWithBadValues() { + LutMap m = new LutMap(new double[] {1.0, Double.NaN, Double.POSITIVE_INFINITY, 4.0}, 2.5, -0.5); + assertArrayEquals(new double[] {1.0, BAD, BAD, 4.0}, m.lutTable()); + assertEquals(2.5, m.lutStart()); + assertEquals(-0.5, m.lutInc()); + } + + @Test + void lutmapDefaultInterp() { + LutMap m = new LutMap(new double[] {0.0, 10.0}, 0.0, 1.0); + assertEquals(0, m.getI("LutInterp")); + } + + // ------------------------------------------------------------------ + // Monotonicity, which decides whether the inverse is defined + // ------------------------------------------------------------------ + + @Test + void lutmapMonotonicIncreasing() { + assertTrue(new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0).getTranInverse()); + } + + @Test + void lutmapMonotonicDecreasing() { + assertTrue(new LutMap(new double[] {30.0, 20.0, 10.0, 0.0}, 0.0, 1.0).getTranInverse()); + } + + @Test + void lutmapNonMonotonic() { + assertFalse(new LutMap(new double[] {0.0, 10.0, 5.0, 30.0}, 0.0, 1.0).getTranInverse()); + } + + @Test + void lutmapFlatSectionsMonotonic() { + assertTrue(new LutMap(new double[] {0.0, 10.0, 10.0, 20.0}, 0.0, 1.0).getTranInverse()); + } + + @Test + void lutmapAllEqualUndetermined() { + assertFalse(new LutMap(new double[] {5.0, 5.0, 5.0}, 0.0, 1.0).getTranInverse()); + } + + @Test + void lutmapBadEntriesIgnoredForMonotonicity() { + assertTrue(new LutMap(new double[] {0.0, BAD, 20.0, 30.0}, 0.0, 1.0).getTranInverse()); + } + + // ------------------------------------------------------------------ + // Linear forward transform + // ------------------------------------------------------------------ + + @Test + void lutmapLinearInterpolation() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + assertEquals(15.0, at(m, 1.5, true), 1e-10); + } + + @Test + void lutmapLinearAtExactEntry() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + assertEquals(20.0, at(m, 2.0, true), 1e-10); + } + + @Test + void lutmapLinearAtFirstEntry() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + assertEquals(0.0, at(m, 0.0, true), 1e-10); + } + + @Test + void lutmapLinearAtLastEntry() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + assertEquals(30.0, at(m, 3.0, true), 1e-10); + } + + @Test + void lutmapLinearExtrapolationBelow() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + assertEquals(-5.0, at(m, -0.5, true), 1e-10); + } + + @Test + void lutmapLinearExtrapolationAbove() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + assertEquals(35.0, at(m, 3.5, true), 1e-10); + } + + @Test + void lutmapLinearWithNonzeroStartAndInc() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 10.0, 5.0); + assertEquals(5.0, at(m, 12.5, true), 1e-10); + } + + // ------------------------------------------------------------------ + // Nearest-neighbour forward transform + // ------------------------------------------------------------------ + + @Test + void lutmapNearestInBounds() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + m.setI("LutInterp", 1); + assertEquals(10.0, at(m, 1.3, true), 1e-10); + assertEquals(20.0, at(m, 1.7, true), 1e-10); + } + + @Test + void lutmapNearestOutsideBounds() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + m.setI("LutInterp", 1); + assertEquals(BAD, at(m, -1.0, true)); + assertEquals(BAD, at(m, 4.0, true)); + } + + // ------------------------------------------------------------------ + // Bad values + // ------------------------------------------------------------------ + + @Test + void lutmapBadInputPropagation() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + assertEquals(BAD, at(m, BAD, true)); + assertEquals(BAD, at(m, Double.NaN, true)); + } + + @Test + void lutmapBadInTableBrackets() { + LutMap m = new LutMap(new double[] {0.0, BAD, 20.0, 30.0}, 0.0, 1.0); + assertEquals(BAD, at(m, 0.5, true)); + } + + @Test + void lutmapBadAtBoundaryExtrapolation() { + LutMap m = new LutMap(new double[] {BAD, 10.0, 20.0, 30.0}, 0.0, 1.0); + assertEquals(BAD, at(m, -0.5, true)); + } + + // ------------------------------------------------------------------ + // Inverse transform + // ------------------------------------------------------------------ + + @Test + void lutmapInverseMonotonicIncreasing() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + assertEquals(1.5, at(m, 15.0, false), 1e-10); + } + + @Test + void lutmapInverseMonotonicDecreasing() { + LutMap m = new LutMap(new double[] {30.0, 20.0, 10.0, 0.0}, 0.0, 1.0); + assertEquals(15.0, at(m, 1.5, true), 1e-10); + assertEquals(1.5, at(m, 15.0, false), 1e-10); + } + + @Test + void lutmapInverseNonMonotonicIsAnError() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 5.0, 30.0}, 0.0, 1.0); + assertFalse(m.getTranInverse()); + AstException e = assertThrows(AstException.class, () -> at(m, 15.0, false)); + assertEquals(AstException.AST__TRNND, e.getStatus()); + } + + @Test + void lutmapFlatSectionInverseReturnsBad() { + LutMap m = new LutMap(new double[] {0.0, 1.0, 1.0, 1.0, 2.0}, 0.0, 1.0); + assertEquals(BAD, at(m, 1.0, false)); + } + + @Test + void lutmapInverseRoundTrip() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + for (double x : new double[] {0.5, 1.0, 1.5, 2.0, 2.5}) { + double y = at(m, x, true); + assertEquals(x, at(m, y, false), 1e-10, "round trip of " + x); + } + } + + @Test + void lutmapInverseExtrapolation() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + assertEquals(-0.5, at(m, -5.0, false), 1e-10); + assertEquals(3.5, at(m, 35.0, false), 1e-10); + } + + @Test + void lutmapInverseBadInput() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + assertEquals(BAD, at(m, BAD, false)); + } + + @Test + void lutmapSingleElementIsAnError() { + AstException e = assertThrows(AstException.class, () -> new LutMap(new double[] {42.0}, 0.0, 1.0)); + assertEquals(AstException.AST__LUTIN, e.getStatus()); + assertEquals( + "astInitLutMap(LutMap): Invalid number of lookup table elements (1).\n" + + "This value should be at least 2.", + e.getMsgText()); + e = assertThrows(AstException.class, () -> new LutMap(new double[] {1.0, 2.0}, 0.0, 0.0)); + assertEquals(AstException.AST__LUTII, e.getStatus()); + assertEquals( + "astInitLutMap(LutMap): An input value increment of zero between lookup table elements is" + + " not allowed.", + e.getMsgText()); + } + + @Test + void lutmapInvertFlag() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + assertFalse(m.getInvert()); + m.invert(); + assertTrue(m.getInvert()); + assertEquals(1.5, at(m, 15.0, true), 1e-10); + } + + @Test + void lutmapMultiplePoints() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + double[] out = m.tran1(4, new double[] {0.0, 1.0, 1.5, 3.0}, true); + assertArrayEquals(new double[] {0.0, 10.0, 15.0, 30.0}, out, 1e-10); + } + + @Test + void lutmapRate() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + // The rate of a linear table is about 10 everywhere (the Rust test's tolerance). + assertEquals(10.0, m.rate(new double[] {1.5}, 1, 1), 1e-3); + } + + // ------------------------------------------------------------------ + // Serialisation + // ------------------------------------------------------------------ + + @Test + void lutmapSerialisationRoundTrip() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 5.0, 2.0); + Mapping m2 = (Mapping) ChannelText.read(ChannelText.dump(m)); + assertEquals(at(m, 6.0, true), at(m2, 6.0, true), 1e-10); + } + + @Test + void lutmapSerialisationTextContent() { + String text = ChannelText.dump(new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 5.0, 2.0)); + for (String s : new String[] {"Begin LutMap", "Nlut", "Start", "Incr", "L1", "L4", "End LutMap"}) { + assertTrue(text.contains(s), "missing " + s); + } + } + + @Test + void lutmapSerialisationDefaultCommented() { + String text = ChannelText.dump(new LutMap(new double[] {0.0, 10.0, 20.0}, 0.0, 1.0)); + assertTrue(text.contains("# Start = 0"), text); + assertTrue(text.contains("# Incr = 1"), text); + } + + @Test + void lutmapSerialisationNearestInterp() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0}, 0.0, 1.0); + m.setI("LutInterp", 1); + String text = ChannelText.dump(m); + assertTrue(text.contains("LutInt"), text); + LutMap m2 = assertInstanceOf(LutMap.class, ChannelText.read(text)); + assertEquals(1, m2.getI("LutInterp")); + } + + @Test + void lutmapSerialisationBadEntries() { + LutMap m = new LutMap(new double[] {0.0, BAD, 20.0}, 0.0, 1.0); + String text = ChannelText.dump(m); + assertTrue(text.contains("L1"), text); + assertFalse(text.contains("L2"), text); + assertTrue(text.contains("L3"), text); + Mapping m2 = (Mapping) ChannelText.read(text); + assertEquals(BAD, at(m2, 0.5, true)); + } + + @Test + void lutmapSerialisationInverted() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0}, 0.0, 1.0); + m.invert(); + String text = ChannelText.dump(m); + assertTrue(text.contains("Invert"), text); + assertTrue(((Mapping) ChannelText.read(text)).getInvert()); + } + + // ------------------------------------------------------------------ + // Cancellation against an adjacent inverse LutMap + // ------------------------------------------------------------------ + + @Test + void lutmapCancelsWithInverse() { + LutMap lm = new LutMap(CURVED, 0.0, 1.0); + assertInstanceOf(UnitMap.class, new CmpMap(lm, inverted(lm), true).simplify()); + } + + @Test + void lutmapNoCancelDifferentLut() { + LutMap lm1 = new LutMap(CURVED, 0.0, 1.0); + LutMap lm2 = new LutMap(new double[] {0.0, 2.0, 3.0, 9.0, 8.0}, 0.0, 1.0); + lm2.invert(); + assertFalse(new CmpMap(lm1, lm2, true).simplify() instanceof UnitMap); + } + + @Test + void lutmapNoCancelSameDirection() { + LutMap lm = new LutMap(CURVED, 0.0, 1.0); + assertFalse(new CmpMap(lm, (LutMap) lm.copy(), true).simplify() instanceof UnitMap); + } + + @Test + void lutmapNoCancelParallel() { + LutMap lm = new LutMap(CURVED, 0.0, 1.0); + assertFalse(new CmpMap(lm, inverted(lm), false).simplify() instanceof UnitMap); + } + + // ------------------------------------------------------------------ + // Simplification: a linear table becomes a WinMap + // ------------------------------------------------------------------ + + @Test + void lutmapLinearSimplifiesToWinmap() { + LutMap lm = new LutMap(LINEAR, 0.0, 1.0); + Mapping s = lm.simplify(); + assertInstanceOf(WinMap.class, s); + assertEquals(1, s.getNin()); + assertEquals(1, s.getNout()); + assertEquals(at(lm, 2.5, true), at(s, 2.5, true), 1e-10); + } + + @Test + void lutmapNearestLinearDoesNotSimplify() { + LutMap lm = new LutMap(LINEAR, 0.0, 1.0); + lm.setI("LutInterp", 1); + assertFalse(lm.simplify() instanceof WinMap); + } + + @Test + void lutmapLinearWithStartAndIncSimplifies() { + LutMap lm = new LutMap(new double[] {100.0, 200.0, 300.0}, 10.0, 5.0); + Mapping s = lm.simplify(); + assertInstanceOf(WinMap.class, s); + for (double x : new double[] {10.0, 12.5, 15.0, 17.5, 20.0}) { + assertEquals(at(lm, x, true), at(s, x, true), 1e-10, "x = " + x); + } + } + + @Test + void lutmapLinearInvertedSimplifies() { + LutMap lm = new LutMap(LINEAR, 0.0, 1.0); + lm.invert(); + Mapping s = lm.simplify(); + assertInstanceOf(WinMap.class, s); + // C builds the WinMap from the corners swapped, so it is applied forward. + assertFalse(s.getInvert()); + assertEquals(at(lm, 5.0, true), at(s, 5.0, true), 1e-10); + } + + @Test + void lutmapNonlinearStaysLutmap() { + assertInstanceOf(LutMap.class, new LutMap(CURVED, 0.0, 1.0).simplify()); + } + + @Test + void lutmapHasBeenSimplifiedRespected() { + LutMap lm = new LutMap(LINEAR, 0.0, 1.0); + lm.setIsSimple(); + assertInstanceOf(LutMap.class, lm.simplify()); + } + + // ------------------------------------------------------------------ + // Values that are not finite + // ------------------------------------------------------------------ + + @Test + void lutmapTreatsInfAsBad() { + LutMap lm = new LutMap(new double[] {0.0, 1.0, 2.0, 3.0}, 0.0, 1.0); + assertEquals(BAD, at(lm, Double.POSITIVE_INFINITY, true)); + assertEquals(BAD, at(lm, Double.NEGATIVE_INFINITY, true)); + } + + /** + * Infinite and NaN entries are stored as bad values, so a table holding one is not linear and + * stays a LutMap; a linear table of the same length simplifies to a UnitMap. The classes are + * those C gives for the same four tables. + */ + @Test + void lutmapNonFiniteEntriesNotLinear() { + double inf = Double.NEGATIVE_INFINITY; + Object[][] tables = { + {"interior -inf", new double[] {1.0, 2.0, 3.0, inf, inf}, true}, + {"last -inf", new double[] {1.0, 2.0, 3.0, 4.0, inf}, true}, + {"interior nan", new double[] {1.0, 2.0, Double.NaN, 4.0, 5.0}, true}, + {"linear", new double[] {1.0, 2.0, 3.0, 4.0, 5.0}, false}, + }; + for (Object[] t : tables) { + Mapping s = new LutMap((double[]) t[1], 1.0, 1.0).simplify(); + if ((Boolean) t[2]) { + assertInstanceOf(LutMap.class, s, (String) t[0]); + } else { + assertInstanceOf(UnitMap.class, s, (String) t[0]); + } + } + } + + // ------------------------------------------------------------------ + // testlutmap.c + // ------------------------------------------------------------------ + + /** testlutmap.c Errors 1 and 2: a table equal to its input round-trips. */ + @Test + void identityTableRoundTrips() { + double[] lut = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8}; + double[] x = {-2.0, -1.0, -0.5, 3.0, 7.5, 8.0, 8.5}; + LutMap lm = new LutMap(lut, -1.0, 1.0); + double[] y = lm.tran1(7, x, true); + assertArrayEquals(x, y, "Error 1"); + assertArrayEquals(y, lm.tran1(7, y, false), "Error 2"); + } + + /** + * testlutmap.c Errors 3-12. The table starts with two equal values, so anything at or below the + * start maps to that value and its inverse is bad, while values beyond the flat run round-trip; + * a bad table value makes its node and the value it would have held bad in both directions. + */ + @Test + void flatStartAndBadValueTables() { + double[] lut = {0.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}; + double[] x = {-2.0, -1.0, -0.5, 0.5, 3.0, 8.0, 8.5}; + + LutMap lm = new LutMap(lut, -1.0, 1.0); + double[] y = lm.tran1(7, x, true); + assertArrayEquals(new double[3], Arrays.copyOfRange(y, 0, 3), "Error 3"); + assertArrayEquals(Arrays.copyOfRange(x, 3, 7), Arrays.copyOfRange(y, 3, 7), "Error 4"); + double[] back = lm.tran1(7, y, false); + assertArrayEquals(new double[] {BAD, BAD, BAD}, Arrays.copyOfRange(back, 0, 3), "Error 5"); + assertArrayEquals(Arrays.copyOfRange(y, 3, 7), Arrays.copyOfRange(back, 3, 7), "Error 6"); + + lut[4] = BAD; + lm = new LutMap(lut, -1.0, 1.0); + y = lm.tran1(7, x, true); + assertArrayEquals(new double[3], Arrays.copyOfRange(y, 0, 3), "Error 7"); + assertEquals(BAD, y[4], "Error 8"); + y[4] = x[4]; + assertArrayEquals(Arrays.copyOfRange(x, 3, 7), Arrays.copyOfRange(y, 3, 7), "Error 9"); + back = lm.tran1(7, y, false); + assertArrayEquals(new double[] {BAD, BAD, BAD}, Arrays.copyOfRange(back, 0, 3), "Error 10"); + assertEquals(BAD, back[4], "Error 11"); + back[4] = y[4]; + assertArrayEquals(Arrays.copyOfRange(y, 3, 7), Arrays.copyOfRange(back, 3, 7), "Error 12"); + } + + /** + * testlutmap.c Errors 13-16: the inverse of values beyond the first table value, which has no + * lower table value to compare with. + */ + @Test + void inverseBeyondTheFirstValue() { + LutMap lm = new LutMap(new double[] {1.0, BAD, 3.0}, 1.0, 1.0); + assertEquals(0.25, at(lm, -0.5, false), "Error 13"); + lm = new LutMap(new double[] {1.0, 2.0, 4.0, 8.0}, 1.0, 1.0); + lm.set("LutInterp=1"); + assertEquals(BAD, at(lm, -0.5, false), "Error 14"); + lm = new LutMap(new double[] {8.0, 4.0, 2.0, 1.0}, 1.0, 1.0); + lm.set("LutInterp=1"); + double[] out = lm.tran1(2, new double[] {8.0, 10.0}, false); + assertEquals(1.0, out[0], "Error 15"); + assertEquals(BAD, out[1], "Error 16"); + } + + /** + * A long inverse array, with bad values, flat runs and values beyond both ends of a table with a + * bad entry, gives each point the result it gets alone. + */ + @Test + void lutmapInverseOfALongArrayMatchesEachPointAlone() { + double[] lut = {-3.0, 0.0, 0.0, 2.0, BAD, 5.0, 7.5, 7.5, 7.5, 9.0, 12.0, 20.0}; + for (int interp = 0; interp < 2; interp++) { + LutMap m = new LutMap(lut, 1.0, 0.5); + m.setI("LutInterp", interp); + double[] ys = new double[1000]; + for (int i = 0; i < ys.length; i++) { + ys[i] = i % 37 == 0 ? BAD : -5.0 + (i % 101) * 0.27; + } + double[] all = m.tran1(ys.length, ys, false); + for (int i = 0; i < ys.length; i++) { + assertEquals( + Double.doubleToRawLongBits(all[i]), + Double.doubleToRawLongBits(at(m, ys[i], false)), + "LutInterp " + interp + " point " + i + ", y = " + ys[i]); + } + } + } + + /** + * Changing LutInterp between transforms leaves the result for the last value transformed in + * each direction as it was: C keeps the last input and output of each direction and returns + * the kept output for the same input, whatever LutInterp now says (lutmap.c {@code + * Transform}). The probe's {@code cache} case gives C's values; Rust expects those of the new + * method. + */ + @Test + void lutmapInterpChangeKeepsTheLastResult() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0}, 1.0, 1.0); + StringBuilder sb = new StringBuilder(); + tranLine(sb, m, 1.4, true); + m.setI("LutInterp", 1); + tranLine(sb, m, 1.4, true); + tranLine(sb, m, 1.6, true); + tranLine(sb, m, 1.4, true); + tranLine(sb, m, 4.0, false); + m.clear("LutInterp"); + tranLine(sb, m, 4.0, false); + tranLine(sb, m, 5.0, false); + tranLine(sb, m, 4.0, false); + assertEquals(probe("cache"), sb.toString()); + } + + /** A copy keeps the last input and output of the LutMap it copies, as C's copy does. */ + @Test + void aCopyKeepsTheLastResult() { + LutMap c = new LutMap(new double[] {0.0, 10.0, 20.0}, 1.0, 1.0); + StringBuilder sb = new StringBuilder(); + tranLine(sb, c, 1.4, true); + LutMap cc = (LutMap) c.copy(); + cc.setI("LutInterp", 1); + tranLine(sb, cc, 1.4, true); + cc.invert(); + tranLine(sb, cc, 1.4, false); + tranLine(sb, cc, 1.6, false); + assertEquals(probe("cache_copy"), sb.toString()); + } + + private static void tranLine(StringBuilder sb, Mapping m, double x, boolean forward) { + double y = at(m, x, forward); + sb.append(forward ? "fwd " : "inv ") + .append(CFormat.format("%.17g", x)) + .append(" -> ") + .append(CFormat.format("%.17g", y)) + .append('\n'); + } + + // ------------------------------------------------------------------ + // test_lutmap_inverse.rs: the inverse against C + // ------------------------------------------------------------------ + + 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; + } + + /** + * The inverse transformation matches C's (lutmap.c {@code Transform}) bit for bit, for tables + * with bad entries, flat runs, either direction and both interpolation methods, at the table + * values, between them and beyond both ends ({@code oracle/lutmap_inverse.json}, from {@code + * tools/oracle_fixtures/lutmap_inverse_probe.c}). + */ + @Test + void inverseMatchesTheCLibrary() { + List failures = new ArrayList<>(); + JsonNode cases = ProbeData.load("lutmap_inverse").get("CASES"); + for (JsonNode c : cases) { + String name = c.get(0).asText(); + LutMap map = + new LutMap(doubles(c.get(1)), c.get(2).asDouble(), c.get(3).asDouble()); + if (c.get(4).asBoolean()) { + map.setI("LutInterp", 1); + } + JsonNode pairs = c.get(5); + double[] ys = new double[pairs.size()]; + for (int i = 0; i < ys.length; i++) { + ys[i] = ProbeData.toDouble(pairs.get(i).get(0)); + } + double[] out = map.tran1(ys.length, ys, false); + for (int i = 0; i < ys.length; i++) { + double want = ProbeData.toDouble(pairs.get(i).get(1)); + if (Double.doubleToRawLongBits(out[i]) != Double.doubleToRawLongBits(want)) { + failures.add(name + ": inverse of " + ys[i] + " is " + out[i] + ", C gives " + want); + } + } + } + assertTrue(cases.size() > 0); + assertTrue(failures.isEmpty(), String.join("\n", failures)); + } + + // ------------------------------------------------------------------ + // The probe: simplification + // ------------------------------------------------------------------ + + private static void assertSimplifies(String name, Mapping map) { + Mapping s = map.simplify(); + String got = "class " + s.astClass() + "\n" + ChannelText.dump(s); + assertEquals(probe(name), got, name); + } + + /** A LutMap that is not linear stays beside a WinMap or a ZoomMap, either side. */ + @Test + void besideAWinMapOrZoomMap() { + LutMap lc = new LutMap(CURVED, 0.0, 1.0); + WinMap wm = new WinMap(1, new double[] {0.0}, new double[] {1.0}, new double[] {1.0}, new double[] {3.0}); + ZoomMap zm = new ZoomMap(1, 2.0); + assertSimplifies("win_lut", new CmpMap(wm, lc, true)); + assertSimplifies("lut_win", new CmpMap(lc, wm, true)); + assertSimplifies("zoom_lut", new CmpMap(zm, lc, true)); + assertSimplifies("lut_zoom", new CmpMap(lc, zm, true)); + } + + /** A linear LutMap becomes a WinMap, which merges with a WinMap or a ZoomMap beside it. */ + @Test + void aLinearLutMapMergesWithItsNeighbour() { + LutMap ll = new LutMap(LINEAR, 0.0, 1.0); + WinMap wm = new WinMap(1, new double[] {0.0}, new double[] {1.0}, new double[] {1.0}, new double[] {3.0}); + assertSimplifies("zoom_linlut", new CmpMap(new ZoomMap(1, 2.0), ll, true)); + assertSimplifies("linlut_win", new CmpMap(ll, wm, true)); + assertSimplifies("linlut_alone", ll); + assertSimplifies("linlut_inverted", inverted(ll)); + } + + /** + * A LutMap and its inverse in series cancel when C's comparison finds them equal: C compares + * the nominated LutMap with its own Invert attribute, not the one it is applied with, so in an + * inverted CmpMap a LutMap followed by its inverse is kept, and a LutMap followed by itself + * cancels (lutmap.c {@code MapMerge}). + */ + @Test + void besideItsOwnInverse() { + LutMap lc = new LutMap(CURVED, 0.0, 1.0); + assertSimplifies("lut_lutinv", new CmpMap(lc, inverted(lc), true)); + assertSimplifies("lutinv_lut", new CmpMap(inverted(lc), lc, true)); + CmpMap cm = new CmpMap(lc, inverted(lc), true); + cm.invert(); + assertSimplifies("inverted_cmp_lut_lutinv", cm); + CmpMap same = new CmpMap(lc, (LutMap) lc.copy(), true); + same.invert(); + assertSimplifies("inverted_cmp_lut_lut", same); + CmpMap inner = new CmpMap(new ZoomMap(1, 2.0), lc, true); + inner.invert(); + assertSimplifies("inverted_inner_then_lut", new CmpMap(inner, lc, true)); + assertSimplifies("lut_lut", new CmpMap(lc, (LutMap) lc.copy(), true)); + assertSimplifies("lut_lutinv_parallel", new CmpMap(lc, inverted(lc), false)); + LutMap ln = (LutMap) lc.copy(); + ln.setI("LutInterp", 1); + assertSimplifies("lut_nearestinv", new CmpMap(lc, inverted(ln), true)); + } + + /** + * A table C takes to be linear but whose ends are equal is neither replaced nor cancelled + * against its inverse: C's {@code MapMerge} tries the cancellation only for a table that is not + * linear. + */ + @Test + void aLinearTableWithEqualEndsIsKept() { + LutMap lf = new LutMap(new double[] {1.0, 1.0 + Math.ulp(1.0), 1.0}, 0.0, 1.0); + assertSimplifies("flat_linear_lutinv", new CmpMap(lf, inverted(lf), true)); + LutMap lk = new LutMap(new double[] {5.0, 5.0, 5.0}, 0.0, 1.0); + assertSimplifies("constant_lutinv", new CmpMap(lk, inverted(lk), true)); + } + + /** LutEpsilon decides whether a nearly linear table becomes a WinMap. */ + @Test + void lutEpsilonDecidesLinearity() { + double[] near = {1.0, 3.0 + 1.0E-9, 5.0, 7.0, 9.0}; + assertSimplifies("near_linear_default_eps", new LutMap(near, 0.0, 1.0)); + LutMap le = new LutMap(near, 0.0, 1.0); + le.set("LutEpsilon=1.0E-7"); + assertSimplifies("near_linear_eps", le); + } + + // ------------------------------------------------------------------ + // The probe: attributes and dumps + // ------------------------------------------------------------------ + + private static String attrs(LutMap m) { + return "LutInterp " + m.getC("LutInterp") + " test " + (m.test("LutInterp") ? 1 : 0) + "\n" + "LutEpsilon " + + m.getC("LutEpsilon") + " test " + (m.test("LutEpsilon") ? 1 : 0) + "\n"; + } + + /** + * The dump through a Channel, the cards of a native FitsChan write, and the dump of the Object + * read back from them, as the probe's {@code dumps} gives them. + */ + private static void assertDumps(String name, AstObject obj) { + StringBuilder sb = new StringBuilder(); + String dump = ChannelText.dump(obj); + sb.append(dump); + FitsChan fc = new FitsChan(); + fc.setC("Encoding", "NATIVE"); + fc.write(obj); + sb.append("-- fits\n"); + fc.clear("Card"); + String card; + while ((card = fc.findFits("%f", true)) != null) { + assertEquals(80, card.length(), card); + sb.append(ProbeOutput.trimLines(card)).append('\n'); + } + fc.clear("Card"); + AstObject back = fc.read(); + sb.append("-- read back from fits\n").append(ChannelText.dump(back)); + assertEquals(probe(name), sb.toString(), name); + } + + @Test + void attributesAndDumps() { + LutMap m = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 5.0, 2.0); + assertEquals(probe("attrs_default"), attrs(m)); + assertDumps("dump_default", m); + m.set("LutInterp=1"); + assertEquals(probe("attrs_interp1"), attrs(m)); + assertDumps("dump_interp1", m); + m.set("LutEpsilon=1.0E-7"); + assertEquals(probe("attrs_both"), attrs(m)); + assertDumps("dump_both", m); + m.clear("LutInterp"); + m.clear("LutEpsilon"); + assertEquals(probe("attrs_cleared"), attrs(m)); + assertDumps("dump_cleared", m); + m.set("LutInterp=5"); + assertEquals(probe("attrs_interp5"), attrs(m)); + m.set("LutInterp=0"); + m.set("LutEpsilon=0.25"); + assertEquals(probe("attrs_interp0_eps"), attrs(m)); + assertDumps("dump_interp0_eps", m); + } + + @Test + void dumpsOfBadEntriesInversionAndACmpMap() { + assertDumps("dump_bad_first", new LutMap(new double[] {BAD, 1.0, 2.0, 4.0}, 0.0, 1.0)); + LutMap n = new LutMap(new double[] {0.0, 1.0, 0.5, 4.0}, 0.0, 1.0); + n.invert(); + assertDumps("dump_nonmonotonic_inverted", n); + LutMap k = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + k.set("LutInterp=1,LutEpsilon=1.0E-7"); + assertDumps("dump_in_cmpmap", new CmpMap(new ZoomMap(1, 2.0), k, true)); + } + + /** LutInterp and LutEpsilon cannot be changed on a LutMap a CmpMap holds (astMAKE_SET1). */ + @Test + void aSharedLutMapRefusesItsAttributes() { + LutMap k = new LutMap(new double[] {0.0, 10.0, 20.0, 30.0}, 0.0, 1.0); + new CmpMap(new ZoomMap(1, 2.0), k, true); + for (String setting : new String[] {"LutInterp=1", "LutEpsilon=1.0E-7"}) { + AstException e = assertThrows(AstException.class, () -> k.set(setting)); + assertEquals(AstException.AST__IMMUT, e.getStatus(), setting); + } + AstException e = assertThrows(AstException.class, () -> k.clear("LutInterp")); + assertEquals(AstException.AST__IMMUT, e.getStatus()); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/MapSplitOracleTest.java b/src/test/java/uk/ac/starlink/ast/MapSplitOracleTest.java index a8034f0..5e577e0 100644 --- a/src/test/java/uk/ac/starlink/ast/MapSplitOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/MapSplitOracleTest.java @@ -1,6 +1,8 @@ package uk.ac.starlink.ast; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import com.fasterxml.jackson.databind.JsonNode; @@ -18,11 +20,38 @@ * range with {@code AST__AXIIN}; the others give no split. A split is compared by its outputs and * its dump, byte for byte. * - *

The WcsMap cases are run; the NormMap, RateMap and TranMap cases, and with them {@code - * issimp_component_exclusions_still_differ}, need classes outside the first phase. + *

The NormMap cases need a class not yet ported. 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 + * issimpComponentExclusionsStillDiffer} fails when it matches; their dumps match C's whole, so + * the list is empty. */ class MapSplitOracleTest { + /** The cases compared without their {@code IsSimp} cards, with the reason. */ + private static final String[][] ISSIMP_COMPONENT_EXCLUDED = {}; + + private static boolean excluded(String name) { + for (String[] e : ISSIMP_COMPONENT_EXCLUDED) { + if (e[0].equals(name)) { + return true; + } + } + return false; + } + + /** {@code dump} without its {@code IsSimp} lines. */ + private static String withoutIsSimp(String dump) { + StringBuilder sb = new StringBuilder(); + for (String line : dump.split("\n", -1)) { + if (!line.trim().startsWith("IsSimp")) { + sb.append(line).append('\n'); + } + } + return sb.toString(); + } + private static Mapping inverted(Mapping m) { m.invert(); return m; @@ -49,7 +78,11 @@ private static Mapping mapping(String name) { return new CmpMap(new ZoomMap(1, 2.0), new ShiftMap(new double[] {1.0, 2.0}), false); } else if (name.startsWith("wcsmap_")) { return new WcsMap(3, WcsMap.AST__TAN, 1, 2); - } else if (name.startsWith("normmap_") || name.startsWith("ratemap_") || name.startsWith("tranmap_")) { + } else if (name.startsWith("tranmap_")) { + return new TranMap(new ZoomMap(3, 2.0), new ZoomMap(3, 2.0)); + } else if (name.startsWith("ratemap_")) { + return new RateMap(new ZoomMap(2, 2.0), 1, 1); + } else if (name.startsWith("normmap_")) { return null; } throw new IllegalArgumentException("no Java construction for case " + name); @@ -107,12 +140,36 @@ void mapSplitMatchesTheCLibrary() { int[] inputs = ints(c.get(1)); String got = outcome(map, inputs); String want = want(c.get(2)); - if (!got.equals(want)) { + boolean differs = excluded(name) ? !withoutIsSimp(got).equals(withoutIsSimp(want)) : !got.equals(want); + if (differs) { failures.add(name + " " + Arrays.toString(inputs) + ":\n" + got + "\nC:\n" + want); } ran++; } assertTrue(failures.isEmpty(), String.join("\n", failures)); - assertEquals(48, ran, "cases run"); + assertEquals(60, ran, "cases run"); + } + + /** + * Rust's {@code issimp_component_exclusions_still_differ}: every case in {@link + * #ISSIMP_COMPONENT_EXCLUDED} is a split in C whose dump still differs from C's; one that + * matches has to leave the list. + */ + @Test + void issimpComponentExclusionsStillDiffer() { + for (String[] e : ISSIMP_COMPONENT_EXCLUDED) { + JsonNode found = null; + for (JsonNode c : ProbeData.load("map_split").get("CASES")) { + if (c.get(0).asText().equals(e[0])) { + found = c; + } + } + assertNotNull(found, "no case " + e[0]); + assertEquals("Split", found.get(2).get("variant").asText(), e[0] + " is not a split in C"); + assertNotEquals( + want(found.get(2)), + outcome(mapping(e[0]), ints(found.get(1))), + e[0] + " now matches C; remove it from ISSIMP_COMPONENT_EXCLUDED (" + e[1] + ")"); + } } } diff --git a/src/test/java/uk/ac/starlink/ast/MapSplitTest.java b/src/test/java/uk/ac/starlink/ast/MapSplitTest.java index ee9b760..7ea714e 100644 --- a/src/test/java/uk/ac/starlink/ast/MapSplitTest.java +++ b/src/test/java/uk/ac/starlink/ast/MapSplitTest.java @@ -11,15 +11,14 @@ import static uk.ac.starlink.ast.MappingTestData.transformRows; import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.Fixtures; /** * 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_*}, {@code tranmap_*} and {@code ratemap_*} tests need classes - * outside the first phase, as does {@code testcmpmap_split_of_splittest1}, whose Mapping holds - * LutMaps. + *

The {@code normmap_*} tests need a class not yet ported. */ class MapSplitTest { @@ -690,4 +689,79 @@ void framesetSplitsItsBaseToCurrentMapping() { assertArrayEquals(new int[] {1}, s.outputs); assertArrayEquals(new double[] {1.0}, fwdPoint(s.map, 6.0)); } + /** + * testcmpmap.c Errors 7-13 on {@code programs/testcmpmap/splittest1.ast}, a Mapping holding + * LutMaps: input 1 alone cannot be split off, and inputs (1, 4, 2) can, the split Mapping + * taking (1, 8, 2) to outputs 1, 2 and 4 of the full Mapping at (1, 2, 4, 8). + */ + @Test + void testcmpmapSplitOfSplittest1() { + Mapping m1 = (Mapping) ChannelText.read(Fixtures.read("programs/testcmpmap/splittest1.ast")); + assertNull(m1.mapSplit(new int[] {1}, new int[m1.getNout()]), "Error 7"); + Mapping m2 = m1.mapSplit(new int[] {1, 4, 2}, new int[m1.getNout()]); + assertNotNull(m2, "Error 8"); + assertEquals(3, m2.getNin(), "Error 9"); + assertEquals(3, m2.getNout(), "Error 10"); + double[] y = fwdPoint(m1, 1.0, 2.0, 4.0, 8.0); + double[] y2 = fwdPoint(m2, 1.0, 8.0, 2.0); + assertEquals(y[0], y2[0], "Error 11"); + assertEquals(y[1], y2[1], "Error 12"); + assertEquals(y[3], y2[2], "Error 13"); + } + + // ------------------------------------------------------------------ + // TranMap: mirrors tranmap.c MapSplit + // ------------------------------------------------------------------ + + /** + * A TranMap of two ShiftMaps, the second inverted, splits on input 1 into the shift of that + * axis for both directions. + */ + @Test + void tranmapSplitPicksPerAxis() { + ShiftMap fwd = new ShiftMap(new double[] {10.0, 20.0, 30.0}); + ShiftMap inv = new ShiftMap(new double[] {-10.0, -20.0, -30.0}); + inv.invert(); + TranMap tm = new TranMap(fwd, inv); + MapSplit s = split(tm, 1); + assertNotNull(s); + assertArrayEquals(new int[] {1}, s.outputs); + assertEquals(1, s.map.getNin()); + assertEquals(25.0, fwdPoint(s.map, 5.0)[0], 1e-12); + } + + // ------------------------------------------------------------------ + // RateMap (ratemap.c MapSplit) + // ------------------------------------------------------------------ + + /** + * A RateMap of output 2 with respect to input 1: the split of its ShiftMap for input 1 lacks + * output 2, so there is no split. + */ + @Test + void ratemapSplitDiffOutputDroppedReturnsNone() { + RateMap rm = new RateMap(new ShiftMap(new double[] {10.0, 20.0, 30.0}), 2, 1); + assertEquals(3, rm.getNin()); + assertEquals(1, rm.getNout()); + assertNull(split(rm, 0)); + } + + /** + * A RateMap of output 1 with respect to input 1 splits for input 1, the varied input, into a + * RateMap of the split ShiftMap, and not for input 2 alone. (The Rust test's name refers to + * the inverted RateMap, which C splits only as the base class does; the probe case {@code + * split_inverted} of {@code RateMapTest} shows it.) + */ + @Test + void ratemapSplitRejectsWhenInverted() { + RateMap rm = new RateMap(new ShiftMap(new double[] {10.0, 20.0, 30.0}), 1, 1); + assertEquals(3, rm.getNin()); + assertEquals(1, rm.getNout()); + MapSplit s = split(rm, 0); + assertNotNull(s); + assertArrayEquals(new int[] {0}, s.outputs); + assertEquals(1, s.map.getNin()); + assertEquals(1, s.map.getNout()); + assertNull(split(rm, 1)); + } } diff --git a/src/test/java/uk/ac/starlink/ast/MappingLoadTest.java b/src/test/java/uk/ac/starlink/ast/MappingLoadTest.java index 2d36318..b4c4eb7 100644 --- a/src/test/java/uk/ac/starlink/ast/MappingLoadTest.java +++ b/src/test/java/uk/ac/starlink/ast/MappingLoadTest.java @@ -1,6 +1,7 @@ package uk.ac.starlink.ast; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; import com.fasterxml.jackson.databind.JsonNode; @@ -21,7 +22,8 @@ * tools/oracle_fixtures/mapping_load_probe.c}). * *

{@code loads_match_the_c_library} runs every case: PermMap, MatrixMap and WcsMap. {@code - * a_dssmap_dump_needs_its_plate_solution} needs a DssMap, which is outside the first phase. + * a_dssmap_dump_needs_its_plate_solution} reads the C fixture {@code serialisation/c_dssmap.ast} + * with one item removed; {@code DssMapTest} compares every such load with C's messages. */ class MappingLoadTest { @@ -117,4 +119,21 @@ void permmapDumpsMatchTheCLibrary() { } assertTrue(failures.isEmpty(), String.join("\n", failures)); } + + /** + * A DssMap dump missing a plate parameter, PPO3, PPO6 or one of the first 13 plate solution + * coefficients on an axis is AST__RDERR; the other items default to zero (dssmap.c {@code + * astLoadDssMap}). + */ + @Test + void aDssmapDumpNeedsItsPlateSolution() { + assertEquals("DssMap", DssMapTest.dss().astClass()); + for (String key : new String[] {"PltRA", "YPixSz", "PPO3", "PPO6", "AMDX1", "AMDY13"}) { + AstException e = assertThrows(AstException.class, () -> DssMapTest.dss(key, null, null), key); + assertEquals(AstException.AST__RDERR, e.getStatus(), key); + } + for (String key : new String[] {"PPO1", "AMDX14", "AMDY19"}) { + assertEquals("DssMap", DssMapTest.dss(key, null, null).astClass(), key); + } + } } diff --git a/src/test/java/uk/ac/starlink/ast/MathMapTest.java b/src/test/java/uk/ac/starlink/ast/MathMapTest.java new file mode 100644 index 0000000..ae3416b --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/MathMapTest.java @@ -0,0 +1,1388 @@ +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.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.CountDownLatch; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.Fixtures; +import uk.ac.starlink.ast.testsupport.ProbeOutput; + +/** + * Translation of the Rust tests {@code tests/test_mathmap.rs}, and tests against the C probes + * {@code probes/mathmap_probe.c} and, for simplification and equality, {@code + * probes/mathmap_simplify_probe.c}. + * + *

The first probe pins what no fixture or oracle holds: the value of every operator, function and + * constant of C's symbol table at a set of arguments, bad and out-of-domain ones included; the + * status and messages of each malformed function; the random-number functions for a given Seed; + * the attribute strings; and the dumps through a Channel and a FitsChan. + * + *

Two kinds of probe value differ from Java's by ruling. C traps the errors of {@code exp}, + * {@code cosh}, {@code sinh} and {@code pow} through {@code errno}, which the macOS library the + * probe was built with does not set, so the probe gives an infinity or a NaN where a library that + * sets {@code errno} gives the bad value, as Java does ({@link #ERRNO_TRAPPED}). And C keeps the + * second value of each Gaussian pair in variables shared by every MathMap, where Java keeps it in + * each MathMap's random-number context, so that a copy, or another MathMap, does not take it. + */ +class MathMapTest { + + private static final double BAD = Mapping.AST__BAD; + + private static final Map PROBE_CASES = ProbeOutput.load("mathmap_probe"); + + /** The arguments of the probe's "evaluate" case. */ + private static final double[] XS = {-2.5, -1.0, -0.5, 0.0, 0.25, 1.0, 2.0, 1000.0, 1.0e300, -1.0e300, BAD}; + + /** + * The expressions whose maths library errors C traps through {@code errno}: where the probe, + * built with a library that does not set it, gives an infinity or a NaN, Java gives the bad + * value. + */ + private static final Set ERRNO_TRAPPED = new HashSet<>(Arrays.asList( + "cosh(x)", + "exp(x)", + "sinh(x)", + "pow(x,0.5)", + "pow(x,2)", + "pow(x,-1)", + "pow(2,x)", + "x**2", + "x**0.5", + "x**-1", + "-x**2")); + + /** + * The values, by "expression @ argument" as the probe prints them, that depend on an error C + * traps through {@code errno} in a part of the expression: the value a library that sets + * {@code errno} gives, which Java gives. These values are derived from mathmap.c's {@code + * CATCH_MATHS_OVERFLOW} and {@code CATCH_MATHS_ERROR} traps, not observed: the probe ran + * against the macOS maths library (named in the probe's header), which does not set {@code + * errno}, and its infinities and NaNs for these cases are what this list overrides. + */ + private static final Map ERRNO_CASES = new LinkedHashMap<>(); + + static { + // sinh overflows, so csch is 0; the probe's library gives 1/-infinity, -0. + ERRNO_CASES.put("csch(x) @ -1.0000000000000001e+300", 0.0); + // x**2 overflows and is bad, which ! and the outer ** keep; the probe's library gives an + // infinity, which they turn into 0. + ERRNO_CASES.put("!x**2 @ 1.0000000000000001e+300", BAD); + ERRNO_CASES.put("!x**2 @ -1.0000000000000001e+300", BAD); + ERRNO_CASES.put("2**-x**2 @ 1.0000000000000001e+300", BAD); + ERRNO_CASES.put("2**-x**2 @ -1.0000000000000001e+300", BAD); + } + + private static String probe(String name) { + String text = PROBE_CASES.get(name); + if (text == null) { + throw new IllegalStateException("no probe case " + name); + } + return text; + } + + /** The parts of a probe case, each starting with a line {@code -- }, by name. */ + private static Map parts(String text) { + Map out = new LinkedHashMap<>(); + String name = null; + StringBuilder sb = new StringBuilder(); + for (String line : text.split("\n", -1)) { + if (line.startsWith("-- ")) { + if (name != null) { + out.put(name, sb.toString()); + } + name = line.substring(3); + sb.setLength(0); + } else if (name != null && !line.isEmpty()) { + sb.append(line).append('\n'); + } + } + if (name != null) { + out.put(name, sb.toString()); + } + return out; + } + + /** + * The probe's text with the lines naming the C source line of an error removed, which leaves + * C's messages, each starting with {@code "! "}, and the {@code status} lines. + */ + private static String withoutErrorOrigin(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 error report as the probe prints it, without the line naming the C source. */ + private static String report(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(); + } + + private static MathMap map1(String expr) { + return new MathMap(1, 1, new String[] {"y = " + expr}, new String[] {"x"}); + } + + private static double at(Mapping map, double x, boolean forward) { + return map.tran1(1, new double[] {x}, forward)[0]; + } + + private static double evalAt(String expr, double x) { + return at(map1(expr), x, true); + } + + private static double[] at2(Mapping map, double x1, double x2, boolean forward) { + double[][] out = map.tran2(1, new double[] {x1}, new double[] {x2}, forward); + return new double[] {out[0][0], out[1][0]}; + } + + // ------------------------------------------------------------------ + // test_mathmap.rs + // ------------------------------------------------------------------ + + @Test + void basicArithmetic() { + MathMap map = new MathMap(1, 1, new String[] {"y = x + 1"}, new String[] {"x = y - 1"}); + assertEquals(1, map.getNin()); + assertEquals(1, map.getNout()); + assertEquals(6.0, at(map, 5.0, true), 1e-10); + assertEquals(5.0, at(map, 6.0, false), 1e-10); + } + + @Test + void multiplication() { + MathMap map = new MathMap(1, 1, new String[] {"y = x * 3"}, new String[] {"x = y / 3"}); + assertEquals(12.0, at(map, 4.0, true), 1e-10); + assertEquals(4.0, at(map, 12.0, false), 1e-10); + } + + @Test + void powerOperator() { + MathMap map = new MathMap(1, 1, new String[] {"y = x ** 2"}, new String[] {"x = sqrt(y)"}); + assertEquals(25.0, at(map, 5.0, true), 1e-10); + assertEquals(5.0, at(map, 25.0, false), 1e-10); + } + + @Test + void trigFunctions() { + MathMap map = new MathMap(1, 1, new String[] {"y = sin(x)"}, new String[] {"x = asin(y)"}); + assertEquals(Math.sin(0.5), at(map, 0.5, true), 1e-10); + assertEquals(0.5, at(map, Math.sin(0.5), false), 1e-10); + } + + @Test + void trigDegrees() { + MathMap map = new MathMap(1, 1, new String[] {"y = sind(x)"}, new String[] {"x = asind(y)"}); + assertEquals(0.5, at(map, 30.0, true), 1e-10); + assertEquals(30.0, at(map, 0.5, false), 1e-10); + } + + @Test + void systemConstants() { + MathMap map = new MathMap(1, 1, new String[] {"y = "}, new String[] {"x = "}); + assertEquals(Math.PI, at(map, 0.0, true), 1e-14); + } + + @Test + void badValuePropagation() { + MathMap map = new MathMap(1, 1, new String[] {"y = x + 1"}, new String[] {"x = y - 1"}); + assertEquals(BAD, at(map, BAD, true)); + } + + @Test + void isbadFunction() { + MathMap map = new MathMap(1, 1, new String[] {"y = isbad(x)"}, new String[] {"x = y"}); + assertEquals(0.0, at(map, 42.0, true), 1e-10); + assertEquals(1.0, at(map, BAD, true), 1e-10); + } + + @Test + void twoDimensional() { + MathMap map = new MathMap( + 2, 2, new String[] {"yout1 = xin2", "yout2 = xin1"}, new String[] {"xin1 = yout2", "xin2 = yout1"}); + assertArrayEquals(new double[] {7.0, 3.0}, at2(map, 3.0, 7.0, true), 1e-10); + assertArrayEquals(new double[] {3.0, 7.0}, at2(map, 7.0, 3.0, false), 1e-10); + } + + @Test + void intermediateVariables() { + MathMap map = new MathMap( + 2, + 2, + new String[] { + "r = sqrt(xin1*xin1 + xin2*xin2)", "theta = atan2(xin2, xin1)", "yout1 = r", "yout2 = theta" + }, + new String[] {"xin1 = yout1 * cos(yout2)", "xin2 = yout1 * sin(yout2)"}); + double[] out = at2(map, 3.0, 4.0, true); + assertEquals(5.0, out[0], 1e-10); + assertEquals(Math.atan2(4.0, 3.0), out[1], 1e-10); + } + + @Test + void comparisonOperators() { + MathMap map = new MathMap(1, 1, new String[] {"y = x > 0"}, new String[] {"x = y"}); + assertEquals(1.0, at(map, 5.0, true), 1e-10); + assertEquals(0.0, at(map, -5.0, true), 1e-10); + } + + @Test + void maxMinFunctions() { + MathMap map = new MathMap(1, 1, new String[] {"y = max(x, 0, 10)"}, new String[] {"x = y"}); + assertEquals(10.0, at(map, -5.0, true), 1e-10); + assertEquals(10.0, at(map, 5.0, true), 1e-10); + assertEquals(15.0, at(map, 15.0, true), 1e-10); + } + + @Test + void expLog() { + MathMap map = new MathMap(1, 1, new String[] {"y = exp(x)"}, new String[] {"x = log(y)"}); + assertEquals(Math.E, at(map, 1.0, true), 1e-10); + assertEquals(1.0, at(map, Math.E, false), 1e-10); + } + + @Test + void absFunction() { + MathMap map = new MathMap(1, 1, new String[] {"y = abs(x)"}, new String[] {"x = y"}); + assertEquals(3.0, at(map, -3.0, true), 1e-10); + assertEquals(3.0, at(map, 3.0, true), 1e-10); + } + + @Test + void qifTernary() { + MathMap map = new MathMap(1, 1, new String[] {"y = qif(x > 0, x, -x)"}, new String[] {"x = y"}); + assertEquals(5.0, at(map, 5.0, true), 1e-10); + assertEquals(5.0, at(map, -5.0, true), 1e-10); + } + + @Test + void invert() { + MathMap map = new MathMap(1, 1, new String[] {"y = x + 10"}, new String[] {"x = y - 10"}); + assertEquals(15.0, at(map, 5.0, true), 1e-10); + map.invert(); + assertEquals(5.0, at(map, 15.0, true), 1e-10); + } + + @Test + void multipointTransform() { + MathMap map = new MathMap(1, 1, new String[] {"y = x * x"}, new String[] {"x = sqrt(y)"}); + double[] out = map.tran1(5, new double[] {1.0, 2.0, 3.0, 4.0, 5.0}, true); + assertArrayEquals(new double[] {1.0, 4.0, 9.0, 16.0, 25.0}, out, 1e-10); + } + + @Test + void divisionByZero() { + MathMap map = new MathMap(1, 1, new String[] {"y = 1.0 / x"}, new String[] {"x = 1.0 / y"}); + assertEquals(BAD, at(map, 0.0, true)); + } + + @Test + void sqrtNegative() { + MathMap map = new MathMap(1, 1, new String[] {"y = sqrt(x)"}, new String[] {"x = y * y"}); + assertEquals(BAD, at(map, -1.0, true)); + } + + @Test + void modFunction() { + MathMap map = new MathMap(1, 1, new String[] {"y = mod(x, 3)"}, new String[] {"x = y"}); + assertEquals(1.0, at(map, 7.0, true), 1e-10); + assertEquals(-1.0, at(map, -7.0, true), 1e-10); + } + + @Test + void floorCeilNint() { + assertEquals(2.0, evalAt("floor(x)", 2.7), 1e-10); + assertEquals(-3.0, evalAt("floor(x)", -2.7), 1e-10); + assertEquals(3.0, evalAt("ceil(x)", 2.3), 1e-10); + assertEquals(-2.0, evalAt("ceil(x)", -2.3), 1e-10); + assertEquals(2.0, evalAt("nint(x)", 2.3), 1e-10); + assertEquals(3.0, evalAt("nint(x)", 2.7), 1e-10); + } + + @Test + void booleanAndTristate() { + assertEquals(0.0, evalAt("x && 0", BAD), 1e-10); + assertEquals(1.0, evalAt("x || 1", BAD), 1e-10); + } + + /** + * The binary operators bind with the priorities of C's operator table: {@code .neqv.} and + * {@code .xor.} compute what {@code ^^} computes but bind as loosely as {@code .eqv.}. Expected + * values are from the C library at x = 2 and x = 1. + */ + @Test + void binaryOperatorPrioritiesMatchC() { + Object[][] cases = { + {"x .or. x .xor. x", 0.0, 0.0}, + {"x .or. x .neqv. x", 0.0, 0.0}, + {"x || x ^^ x", 1.0, 1.0}, + {"x ^^ x .eqv. x", 0.0, 0.0}, + {"x .and. x .xor. x", 0.0, 0.0}, + {"x .xor. x .eqv. 0", 1.0, 1.0}, + {"x < 3 == 1", 1.0, 1.0}, + {"x << 1 < 3", 0.0, 1.0}, + {"-x * 3", -6.0, -3.0}, + }; + for (Object[] c : cases) { + String expr = (String) c[0]; + assertEquals((double) c[1], evalAt(expr, 2.0), expr + " at x = 2"); + assertEquals((double) c[2], evalAt(expr, 1.0), expr + " at x = 1"); + } + } + + /** + * A prefix operator binds less tightly than a {@code **} on its right, as in C's operator + * table: {@code -x**2} is {@code -(x**2)}. Expected values are from the C library. + */ + @Test + void prefixOperatorsBindBelowPower() { + Object[][] cases = { + {"-x**2", -4.0, -1.0}, + {"+x**2", 4.0, 1.0}, + {".not. x**2", 0.0, 0.0}, + {"!x**2", 0.0, 0.0}, + {"-x**2**2", -16.0, -1.0}, + {"x**-2", 0.25, 1.0}, + {"2**-x**2", 0.0625, 0.5}, + {"!x == 0", 1.0, 1.0}, + {"-x < -1", 1.0, 0.0}, + }; + for (Object[] c : cases) { + String expr = (String) c[0]; + assertEquals((double) c[1], evalAt(expr, 2.0), expr + " at x = 2"); + assertEquals((double) c[2], evalAt(expr, 1.0), expr + " at x = 1"); + } + } + + private static int expressionError(String expr) { + try { + map1(expr); + } catch (AstException e) { + return e.getStatus(); + } + throw new AssertionError("\"" + expr + "\" compiled"); + } + + /** + * Each symbol is read as an operator or as an operand according to what precedes it, as in C. + * Expected codes are from the C library. + */ + @Test + void malformedExpressionsReportCErrorCodes() { + Object[][] cases = { + {"1.or.0", AstException.AST__MIOPR}, + {"1 .and. 1", AstException.AST__MIOPR}, + {"x .not. 1", AstException.AST__MIOPR}, + {"2x", AstException.AST__MIOPR}, + {"x(1)", AstException.AST__MIOPR}, + {"x!", AstException.AST__MIOPR}, + {"(x)(x)", AstException.AST__MIOPR}, + {"2.eq.2", AstException.AST__CONIN}, + {".eq.x", AstException.AST__CONIN}, + {"1.e", AstException.AST__CONIN}, + {"1.0.5", AstException.AST__CONIN}, + {"x", AstException.AST__UDVOF}, + {"sin", AstException.AST__UDVOF}, + {"q", AstException.AST__UDVOF}, + {"*x", AstException.AST__MIOPA}, + {"max(1,)", AstException.AST__MIOPA}, + {"x·2", AstException.AST__MIOPR}, + }; + for (Object[] c : cases) { + assertEquals((int) c[1], expressionError((String) c[0]), (String) c[0]); + } + assertEquals(1.0, evalAt("x.or.1", 0.0)); + assertEquals(45.05, evalAt("1.e1 + 1.d1 + .5e-1 + 2.5d+1", 0.0)); + } + + /** + * Parentheses and commas are checked as each is read, as in C. Expected codes are from the C + * library. + */ + @Test + void parenthesesAndArgumentsReportCErrorCodes() { + Object[][] cases = { + {"x,1", AstException.AST__COMIN}, + {"(x,1)", AstException.AST__COMIN}, + {"sin((x,1))", AstException.AST__COMIN}, + {"max(x,(1,2))", AstException.AST__COMIN}, + {"x,1)+(", AstException.AST__COMIN}, + {"x)", AstException.AST__MLPAR}, + {"x)+(", AstException.AST__MLPAR}, + {"sin(x,1)", AstException.AST__WRNFA}, + {"atan2(x)", AstException.AST__WRNFA}, + {"atan2(x,1,2)", AstException.AST__WRNFA}, + {"qif(1,2)", AstException.AST__WRNFA}, + {"max(x)", AstException.AST__WRNFA}, + {"max(x)+(", AstException.AST__WRNFA}, + {"min(x,)", AstException.AST__MIOPA}, + {"x+", AstException.AST__MIOPA}, + {"x+)", AstException.AST__MIOPA}, + {"(,x)", AstException.AST__MIOPA}, + {")", AstException.AST__MIOPA}, + {"(x", AstException.AST__MRPAR}, + {"sin(x", AstException.AST__MRPAR}, + }; + for (Object[] c : cases) { + assertEquals((int) c[1], expressionError((String) c[0]), (String) c[0]); + } + assertEquals(3.0, evalAt("max(1,2,3)", 0.0)); + } + + /** + * The bit-wise operators read each value as a fixed-point binary number with negative values + * in two's complement, as C does. Expected values are from the C library. + */ + @Test + void bitwiseOperatorsActOnFixedPointValues() { + Object[][] cases = { + {"2^3", 1.0}, + {"2|1", 3.0}, + {"1&3", 1.0}, + {"-1&3", 3.0}, + {"-2|1", -1.0}, + {"-1^-1", 0.0}, + {"0.5|0.25", 0.75}, + {"1.5^0.75", 1.25}, + {"-0.5&1", 1.0}, + {"3&-1e300", 0.0}, + {"|0", Double.MAX_VALUE}, + {"1e-310|1", 1.0}, + {"1e-320|1e-310", Double.parseDouble("1.00000000002213e-310")}, + {"1e308&1e308", 1e308}, + {"-|1", -Double.MAX_VALUE}, + {"0&0", 0.0}, + {"-0^1", 1.0}, + {"3.75&-2.5", 1.5}, + {"1e20|1", 1e20}, + {"1e-20^-1", -1.0}, + {"|-", -Double.MIN_NORMAL}, + {"x|2", 2.0}, + {"-1&-1", -1.0}, + }; + for (Object[] c : cases) { + assertEquals((double) c[1], evalAt((String) c[0], 0.0), (String) c[0]); + } + } + + /** + * The shift operators scale by a power of two with a single rounding. Expected values are + * from the C library; an overflowing result is bad, as C gives it where {@code ldexp} sets + * {@code errno}. + */ + @Test + void shiftOperatorsScaleExactly() { + Object[][] cases = { + {"1e-310<<1", 2e-310}, + {">>1<<1", Double.MAX_VALUE}, + {"1<<-1074", Double.MIN_VALUE}, + {"1<<-1075", 0.0}, + {"1.5<<-1074", 2 * Double.MIN_VALUE}, + {">>3", Double.parseDouble("2.781342323134e-309")}, + {"0.75<<1024", 1.348269851146737e308}, + {"<<1", BAD}, + {"1<<2000", BAD}, + }; + for (Object[] c : cases) { + assertEquals((double) c[1], evalAt((String) c[0], 0.0), (String) c[0]); + } + } + + private static int constructionError(String[] fwd, String[] inv) { + try { + new MathMap(1, 1, fwd, inv); + } catch (AstException e) { + return e.getStatus(); + } + throw new AssertionError(Arrays.toString(fwd) + " / " + Arrays.toString(inv) + " compiled"); + } + + /** + * The left-hand side of every function, or the whole of one with no {@code =}, must be a + * variable name, no name may be defined twice, and every function of a direction must have a + * right-hand side, or none may. Expected codes are from the C library. + */ + @Test + void variableNamesAreValidated() { + Object[][] cases = { + {new String[] {"y = x1 + 1"}, new String[] {"x + 1"}, AstException.AST__VARIN}, + {new String[] {"y = x"}, new String[] {"x <= y"}, AstException.AST__VARIN}, + {new String[] {"y = x"}, new String[] {"x + 1 = y"}, AstException.AST__VARIN}, + {new String[] {"y = x"}, new String[] {"_x"}, AstException.AST__VARIN}, + {new String[] {"y = x"}, new String[] {"1x"}, AstException.AST__VARIN}, + {new String[] {"y = x + 1"}, new String[] {"x = y - 1", "x = 2"}, AstException.AST__DUVAR}, + {new String[] {"y = x"}, new String[] {"y"}, AstException.AST__DUVAR}, + {new String[] {"y = x + 1"}, new String[] {"= y - 1"}, AstException.AST__MISVN}, + {new String[] {"y = x + 1"}, new String[] {""}, AstException.AST__MISVN}, + {new String[] {"y = x + 1"}, new String[] {" "}, AstException.AST__MISVN}, + {new String[] {"y =="}, new String[] {"x"}, AstException.AST__MIOPA}, + {new String[] {"y = = x"}, new String[] {"x"}, AstException.AST__MIOPA}, + {new String[] {"y ="}, new String[] {"x"}, AstException.AST__NORHS}, + {new String[] {"t", "y = x"}, new String[] {"x"}, AstException.AST__NORHS}, + }; + for (Object[] c : cases) { + String[] fwd = (String[]) c[0]; + String[] inv = (String[]) c[1]; + assertEquals((int) c[2], constructionError(fwd, inv), Arrays.toString(fwd) + " / " + Arrays.toString(inv)); + } + MathMap map = new MathMap(1, 1, new String[] {"t = x * 2", "y = t + 1"}, new String[] {"x"}); + assertEquals(1.0, at(map, 0.0, true)); + map = new MathMap(1, 1, new String[] {"y = 1"}, new String[] {"a = y", "x = a"}); + assertEquals(1.0, at(map, 0.0, true)); + assertEquals(3.0, at(map, 3.0, false)); + } + + // ------------------------------------------------------------------ + // The probe: every operator, function and constant + // ------------------------------------------------------------------ + + private static double parseC(String s) { + switch (s) { + case "inf": + return Double.POSITIVE_INFINITY; + case "-inf": + return Double.NEGATIVE_INFINITY; + case "nan": + case "-nan": + return Double.NaN; + default: + return Double.parseDouble(s); + } + } + + /** The number a token of probe text holds, or null if it is not a number. */ + private static Double number(String token) { + try { + return parseC(token); + } catch (NumberFormatException e) { + return null; + } + } + + /** + * Asserts that two texts are the same but for the last bits of their numbers, which may + * differ where C's maths library and Java's round differently: every token but the numbers is + * the same, and each number is within four units in the last place of C's, a bad value or a + * value that is not finite being the same. + */ + private static void assertSameNumbers(String expected, String actual, String what) { + String[] el = expected.split("\n", -1); + String[] al = actual.split("\n", -1); + assertEquals(el.length, al.length, what + ": lines\n" + actual); + for (int i = 0; i < el.length; i++) { + String[] et = el[i].split(" ", -1); + String[] at = al[i].split(" ", -1); + assertEquals(et.length, at.length, what + ": " + al[i]); + for (int j = 0; j < et.length; j++) { + Double e = number(et[j]); + Double a = number(at[j]); + if (e == null || a == null || e == BAD || a == BAD || !Double.isFinite(e)) { + assertEquals(et[j], at[j], what + ": " + al[i]); + } else { + assertEquals(e, a, 4 * Math.ulp(e), what + ": " + al[i]); + } + } + } + } + + /** + * Each expression of the probe's "evaluate" case at each argument gives C's value. Values of + * the maths library functions may differ from C's in the last bits, as the two libraries + * round differently; every other value, and every bad value, is C's exactly. + */ + @Test + void everySymbolGivesCsValue() { + Map results = new LinkedHashMap<>(); + List failures = new ArrayList<>(); + int checked = 0; + for (String line : probe("evaluate").split("\n", -1)) { + if (line.isEmpty()) { + continue; + } + int atSign = line.indexOf(" @ "); + int eq = line.lastIndexOf(" = "); + String expr = line.substring(0, atSign); + String key = line.substring(0, eq); + double x = parseC(line.substring(atSign + 3, eq)); + double expected = parseC(line.substring(eq + 3)); + double[] out = results.computeIfAbsent(expr, e -> map1(e).tran1(XS.length, XS, true)); + double got = out[indexOf(x)]; + boolean ok; + if (ERRNO_CASES.containsKey(key)) { + ok = Double.compare(ERRNO_CASES.get(key), got) == 0; + } else if (!Double.isFinite(expected) && ERRNO_TRAPPED.contains(expr)) { + ok = got == BAD; + } else if (expected == BAD || got == BAD || !Double.isFinite(expected) || expected == 0.0) { + ok = Double.compare(expected, got) == 0; + } else { + ok = Math.abs(expected - got) <= 2 * Math.ulp(expected); + } + if (!ok) { + failures.add(key + " = " + CFormat.format("%.17g", got) + " (C: " + line.substring(eq + 3) + ")"); + } + checked++; + } + assertEquals(Collections.emptyList(), failures); + assertEquals(XS.length * results.size(), checked); + assertEquals(138, results.size()); + } + + private static int indexOf(double x) { + for (int i = 0; i < XS.length; i++) { + if (Double.compare(XS[i], x) == 0) { + return i; + } + } + throw new IllegalStateException("no argument " + x); + } + + /** The constants of C's symbol table, exactly. */ + @Test + void symbolicConstantsAreCs() { + assertEquals(17.0, evalAt("", 0.0)); + assertEquals(Math.ulp(1.0), evalAt("", 0.0)); + assertEquals(53.0, evalAt("", 0.0)); + assertEquals(Double.MAX_VALUE, evalAt("", 0.0)); + assertEquals(308.0, evalAt("", 0.0)); + assertEquals(1024.0, evalAt("", 0.0)); + assertEquals(Double.MIN_NORMAL, evalAt("", 0.0)); + assertEquals(-307.0, evalAt("", 0.0)); + assertEquals(-1021.0, evalAt("", 0.0)); + assertEquals(2.0, evalAt("", 0.0)); + assertEquals(1.0, evalAt("", 0.0)); + // C's exp(1.0), which a correctly rounded library gives as Math.E. + assertEquals(Math.E, evalAt("", 0.0)); + assertEquals(Math.PI, evalAt("", 0.0)); + assertEquals(BAD, evalAt("", 0.0)); + } + + /** An input that is not finite is bad, the library's rule for such values. */ + @Test + void inputsThatAreNotFiniteAreBad() { + assertEquals(1.0, evalAt("isbad(x)", Double.NaN)); + assertEquals(1.0, evalAt("isbad(x)", Double.POSITIVE_INFINITY)); + assertEquals(BAD, evalAt("x + 1", Double.NEGATIVE_INFINITY)); + assertEquals(1.0, evalAt("x || 1", Double.NaN)); + } + + // ------------------------------------------------------------------ + // The probe: errors + // ------------------------------------------------------------------ + + /** The probe's text for a MathMap made with these functions: "made", or the error. */ + private static String made(int nin, int nout, String[] fwd, String[] inv) { + try { + new MathMap(nin, nout, fwd, inv); + return "made\n"; + } catch (AstException e) { + return report(e); + } + } + + /** Each malformed expression gives C's status and messages. */ + @Test + void expressionErrorsGiveCsMessages() { + Map parts = parts(probe("expression_errors")); + assertEquals(50, parts.size()); + for (Map.Entry p : parts.entrySet()) { + String expr = p.getKey(); + String got = made(1, 1, new String[] {"y = " + expr}, new String[] {"x"}); + assertEquals(withoutErrorOrigin(p.getValue()), got, expr); + } + } + + /** A unary operator may follow another operator. */ + @Test + void unarySequencesGiveCsValues() { + Map parts = parts(probe("unary_sequences")); + assertEquals(10, parts.size()); + for (Map.Entry p : parts.entrySet()) { + double y = evalAt(p.getKey(), 2.0); + assertEquals(p.getValue(), CFormat.format("%.17g", y) + "\n", p.getKey()); + } + } + + /** Errors in the functions as a whole give C's status and messages, naming the function. */ + @Test + void functionErrorsGiveCsMessages() { + Map parts = parts(probe("function_errors")); + Map cases = new LinkedHashMap<>(); + String[] y = {"y = x"}; + String[] yp1 = {"y = x + 1"}; + String[] x = {"x"}; + cases.put("varin_expression", new String[][] {{"y = x1 + 1"}, {"x + 1"}}); + cases.put("varin_relational", new String[][] {y, {"x <= y"}}); + cases.put("varin_lhs", new String[][] {y, {"x + 1 = y"}}); + cases.put("varin_underscore", new String[][] {y, {"_x"}}); + cases.put("varin_digit", new String[][] {y, {"1x"}}); + cases.put("duvar_inverse", new String[][] {yp1, {"x = y - 1", "x = 2"}}); + cases.put("duvar_input_output", new String[][] {y, {"y"}}); + cases.put("misvn_no_lhs", new String[][] {yp1, {"= y - 1"}}); + cases.put("misvn_empty", new String[][] {yp1, {""}}); + cases.put("misvn_blank", new String[][] {yp1, {" "}}); + cases.put("miopa_double_equals", new String[][] {{"y =="}, x}); + cases.put("miopa_equals_equals", new String[][] {{"y = = x"}, x}); + cases.put("norhs_empty", new String[][] {{"y ="}, x}); + cases.put("norhs_mixed", new String[][] {{"t", "y = x"}, x}); + cases.put("udvof_third_function", new String[][] {{"a = x", "b = a", "y = b + c"}, x}); + cases.put("inverse_second_function", new String[][] {y, {"t = y", "x = t + c : cases.entrySet()) { + String got = made(1, 1, c.getValue()[0], c.getValue()[1]); + assertEquals(withoutErrorOrigin(parts.get(c.getKey())), got, c.getKey()); + } + } + + /** + * The numbers of inputs, outputs and functions are checked as C checks them; a bad number of + * outputs is reported with C's status for a bad number of inputs, AST__BADNI. + */ + @Test + void countErrorsGiveCsMessages() { + Map parts = parts(probe("count_errors")); + String[] f = {"y = x"}; + String[] i = {"x = y"}; + assertEquals(withoutErrorOrigin(parts.get("nin_zero")), made(0, 1, f, i)); + assertEquals(withoutErrorOrigin(parts.get("nout_zero")), made(1, 0, f, i)); + assertEquals(withoutErrorOrigin(parts.get("nin_negative")), made(-1, 1, f, i)); + assertEquals(withoutErrorOrigin(parts.get("too_few_forward")), made(1, 2, f, new String[] {"x = y", "w = y"})); + assertEquals(withoutErrorOrigin(parts.get("too_few_inverse")), made(2, 1, new String[] {"y = x", "z = x"}, i)); + } + + // ------------------------------------------------------------------ + // The probe: transformations + // ------------------------------------------------------------------ + + private static void tran2Line(StringBuilder sb, Mapping m, double x, double y, boolean forward) { + try { + double[] out = at2(m, x, y, forward); + sb.append(forward ? "fwd " : "inv ") + .append(CFormat.format("%.17g", x)) + .append(' ') + .append(CFormat.format("%.17g", y)) + .append(" -> ") + .append(CFormat.format("%.17g", out[0])) + .append(' ') + .append(CFormat.format("%.17g", out[1])) + .append('\n'); + } catch (AstException e) { + sb.append(report(e)); + } + } + + private static String tranFlags(Mapping m) { + return "TranForward " + (m.getTranForward() ? 1 : 0) + " TranInverse " + (m.getTranInverse() ? 1 : 0) + "\n"; + } + + /** Intermediate variables, an undefined direction and inversion, as C transforms them. */ + @Test + void transformationsAsC() { + StringBuilder sb = new StringBuilder(); + MathMap m = new MathMap( + 2, + 2, + new String[] { + "r = sqrt( x * x + y * y )", + "rout = r * ( 1 + 0.1 * r * r )", + "theta = atan2( y, x )", + "xout = rout * cos( theta )", + "yout = rout * sin( theta )" + }, + new String[] {"x", "y"}); + sb.append("made\n").append(tranFlags(m)); + tran2Line(sb, m, 3.0, 4.0, true); + tran2Line(sb, m, -1.0, 0.5, true); + tran2Line(sb, m, BAD, 0.5, true); + tran2Line(sb, m, 3.0, 4.0, false); + m.invert(); + sb.append(tranFlags(m)); + tran2Line(sb, m, 3.0, 4.0, false); + MathMap p = + new MathMap(2, 2, new String[] {"r = sqrt( x * x + y * y )", "theta = atan2( y, x )"}, new String[] { + "x = r * cos( theta )", "y = r * sin( theta )" + }); + sb.append("made\n"); + tran2Line(sb, p, 3.0, 4.0, true); + tran2Line(sb, p, 5.0, 0.9272952180016122, false); + p.invert(); + tran2Line(sb, p, 5.0, 0.9272952180016122, true); + MathMap u = new MathMap(1, 1, new String[] {"y"}, new String[] {"x = 2 * y"}); + sb.append("made\n").append(tranFlags(u)); + try { + at(u, 3.0, true); + } catch (AstException e) { + sb.append(report(e)); + } + sb.append("inv ").append(CFormat.format("%.17g", at(u, 3.0, false))).append('\n'); + assertSameNumbers(withoutErrorOrigin(probe("transformations")), sb.toString(), "transformations"); + } + + // ------------------------------------------------------------------ + // The probe: random numbers + // ------------------------------------------------------------------ + + private static MathMap random1(String expr, int seed) { + MathMap m = map1(expr); + m.setSeed(seed); + return m; + } + + private static String draws(Mapping m, int npoint, double x) { + double[] in = new double[npoint]; + Arrays.fill(in, x); + double[] out = m.tran1(npoint, in, true); + StringBuilder sb = new StringBuilder(); + for (double v : out) { + sb.append(CFormat.format("%.17g", v)).append('\n'); + } + return sb.toString(); + } + + /** + * The values of {@code rand}, {@code gauss} and {@code poisson} for a given Seed are C's, a + * Seed below 1 included, for which C's generator gives values outside the range 0 to 1. + */ + @Test + void randomFunctionsGiveCsSequences() { + Map parts = parts(probe("random_seeds")); + int[] seeds = {1, 12345, -7, 0, Integer.MAX_VALUE, Integer.MIN_VALUE}; + for (int seed : seeds) { + assertEquals(parts.get("rand seed " + seed), draws(random1("rand(0,1)", seed), 6, 0.0), "rand " + seed); + } + for (int is = 0; is < 3; is++) { + assertEquals( + parts.get("gauss seed " + seeds[is]), + draws(random1("gauss(x,1)", seeds[is]), 7, 0.0), + "gauss " + seeds[is]); + } + assertEquals(parts.get("rand range"), draws(random1("rand(x,-3)", 99), 5, 10.0)); + assertEquals(parts.get("gauss mean sd"), draws(random1("gauss(x,-2)", 99), 5, 10.0)); + assertEquals(parts.get("poisson small"), draws(random1("poisson(x)", 3), 10, 3.5)); + assertEquals(parts.get("poisson large"), draws(random1("poisson(x)", 3), 10, 20.0)); + assertEquals(parts.get("poisson huge mean"), draws(random1("poisson(x)", 3), 2, 1.0e40)); + assertEquals(parts.get("poisson zero"), draws(random1("poisson(x)", 3), 2, 0.0)); + assertEquals(parts.get("poisson negative"), draws(random1("poisson(x)", 3), 2, -1.0)); + assertEquals(parts.get("poisson bad"), draws(random1("poisson(x)", 3), 2, BAD)); + assertEquals(parts.get("rand bad"), draws(random1("rand(x,1)", 3), 2, BAD)); + assertEquals(parts.get("gauss pair"), draws(random1("gauss(0,1)", 1), 2, 0.0)); + assertSameNumbers(parts.get("mixed"), draws(random1("rand(0,1)+gauss(0,1)*poisson(5)", 8), 6, 0.0), "mixed"); + } + + /** + * A copy continues its original's sequence, independently of it, and setting the Seed again + * restarts it. C keeps a Gaussian pair's second value in variables shared by every MathMap, + * so in C the original takes it and the copy draws a new pair; Java keeps it in the context a + * copy copies, so the copy gives the original's sequence. + */ + @Test + void copiesContinueTheSequence() { + Map parts = parts(probe("random_copies")); + MathMap m = random1("rand(0,1)", 42); + assertEquals(parts.get("first"), draws(m, 3, 0.0)); + MathMap c = (MathMap) m.copy(); + assertEquals(parts.get("copy"), draws(c, 3, 0.0)); + assertEquals(parts.get("original"), draws(m, 3, 0.0)); + m.setSeed(42); + assertEquals(parts.get("reseeded"), draws(m, 3, 0.0)); + + MathMap g = random1("gauss(0,1)", 42); + assertEquals(parts.get("gauss first"), draws(g, 1, 0.0)); + MathMap gc = (MathMap) g.copy(); + String original = parts.get("gauss original"); + assertEquals(original, draws(g, 3, 0.0)); + assertEquals(original, draws(gc, 3, 0.0)); + } + + /** + * Two MathMaps used in turn each give the sequence they give alone. In C each takes the + * Gaussian value the other kept: the probe's second value for "a" is the second value "b" + * gives alone. + */ + @Test + void gaussianPairsBelongToTheirMathMap() { + String[] lines = probe("gauss_two_mathmaps").split("\n", -1); + assertEquals("-- a", lines[0]); + assertEquals("-- a alone", lines[8]); + assertEquals("-- b alone", lines[11]); + String a1 = lines[9]; + String a2 = lines[10]; + String b1 = lines[12]; + String b2 = lines[13]; + assertEquals(Arrays.asList(a1, b1, b2), Arrays.asList(lines[1], lines[3], lines[5])); + MathMap a = random1("gauss(0,1)", 5); + MathMap b = random1("gauss(0,1)", 6); + assertEquals(a1 + "\n", draws(a, 1, 0.0)); + assertEquals(b1 + "\n", draws(b, 1, 0.0)); + assertEquals(a2 + "\n", draws(a, 1, 0.0)); + assertEquals(b2 + "\n", draws(b, 1, 0.0)); + } + + /** Two threads transforming two copies of a seeded MathMap at once give the same values. */ + @Test + void twoThreadsTransformingCopiesAgree() throws InterruptedException { + MathMap m = random1("rand(0,1) + gauss(x, 2) * poisson(4.5) + poisson(30)", 2024); + int npoint = 20000; + double[] in = new double[npoint]; + for (int i = 0; i < npoint; i++) { + in[i] = i * 0.001; + } + double[] alone = ((MathMap) m.copy()).tran1(npoint, in, true); + MathMap c1 = (MathMap) m.copy(); + MathMap c2 = (MathMap) m.copy(); + double[][] results = new double[2][]; + CountDownLatch start = new CountDownLatch(1); + Thread t1 = new Thread(() -> results[0] = transformAfter(start, c1, in)); + Thread t2 = new Thread(() -> results[1] = transformAfter(start, c2, in)); + t1.start(); + t2.start(); + start.countDown(); + t1.join(); + t2.join(); + assertArrayEquals(alone, results[0]); + assertArrayEquals(alone, results[1]); + assertArrayEquals(alone, m.tran1(npoint, in, true)); + } + + private static double[] transformAfter(CountDownLatch start, MathMap m, double[] in) { + try { + start.await(); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + return new double[0]; + } + return m.tran1(in.length, in, true); + } + + /** + * An unset Seed has an unpredictable default, different for each MathMap, which clearing the + * Seed replaces; a default Seed, read and set on another MathMap, reproduces its sequence. + */ + @Test + void defaultSeedsDiffer() { + MathMap a = map1("rand(0,1)"); + MathMap b = map1("rand(0,1)"); + assertFalse(a.test("Seed")); + assertNotEquals(a.getSeed(), b.getSeed()); + int before = a.getSeed(); + a.clear("Seed"); + assertFalse(a.test("Seed")); + assertNotEquals(before, a.getSeed()); + b.setSeed(a.getSeed()); + assertTrue(b.test("Seed")); + assertEquals(draws(a, 4, 0.0), draws(b, 4, 0.0)); + } + + // ------------------------------------------------------------------ + // The probe: attributes and dumps + // ------------------------------------------------------------------ + + private static String attrs(MathMap m) { + String s = "SimpFI " + m.getC("SimpFI") + " test " + (m.test("SimpFI") ? 1 : 0) + "\n" + "SimpIF " + + m.getC("SimpIF") + " test " + (m.test("SimpIF") ? 1 : 0) + "\n"; + if (m.test("Seed")) { + return s + "Seed " + m.getC("Seed") + " test 1\n"; + } + return s + "Seed test 0\n"; + } + + /** The attribute strings are C's, and a shared MathMap refuses changes to them. */ + @Test + void attributesAsC() { + StringBuilder sb = new StringBuilder(); + MathMap m = new MathMap(1, 1, new String[] {"y = x"}, new String[] {"x = y"}); + sb.append(attrs(m)); + m.set("SimpFI=5, SimpIF=0, Seed=-12"); + sb.append(attrs(m)); + m.set("SimpFI=0, SimpIF=-3"); + sb.append(attrs(m)); + m.clear("SimpFI"); + m.clear("SimpIF"); + m.clear("Seed"); + sb.append(attrs(m)); + CmpMap cm = new CmpMap(m, new ZoomMap(1, 2.0), true); + assertEquals(1, cm.getNin()); + sb.append("-- shared\n"); + try { + m.setI("Seed", 3); + fail("Seed set on a shared MathMap"); + } catch (AstException e) { + sb.append(report(e)); + } + try { + m.setI("SimpFI", 1); + fail("SimpFI set on a shared MathMap"); + } catch (AstException e) { + sb.append(report(e)); + } + try { + m.clear("SimpIF"); + fail("SimpIF cleared on a shared MathMap"); + } catch (AstException e) { + sb.append(report(e)); + } + assertEquals(withoutErrorOrigin(probe("attributes")), sb.toString()); + } + + /** The public accessors read and write the attributes. */ + @Test + void publicAccessors() { + MathMap m = map1("x"); + assertFalse(m.getSimpFI()); + assertFalse(m.getSimpIF()); + m.setSimpFI(true); + m.setSimpIF(true); + assertTrue(m.getSimpFI()); + assertTrue(m.getSimpIF()); + m.setSeed(-99); + assertEquals(-99, m.getSeed()); + assertThrows(AstException.class, () -> m.set("Seed=x")); + } + + /** + * The dump through a Channel, the cards of a native FitsChan write, and the dump of the Object + * read back from them, as the probe's {@code dumps} gives them. + */ + private static void assertDumps(String name, AstObject obj) { + StringBuilder sb = new StringBuilder(); + sb.append(ChannelText.dump(obj)); + FitsChan fc = new FitsChan(); + fc.setC("Encoding", "NATIVE"); + fc.write(obj); + sb.append("-- fits\n"); + fc.clear("Card"); + String card; + while ((card = fc.findFits("%f", true)) != null) { + assertEquals(80, card.length(), card); + sb.append(ProbeOutput.trimLines(card)).append('\n'); + } + fc.clear("Card"); + AstObject back = fc.read(); + sb.append("-- read back from fits\n").append(ChannelText.dump(back)); + assertEquals(probe(name), sb.toString(), name); + } + + /** + * A MathMap with intermediate variables and random functions, with each attribute set and + * unset, inverted, without a forward transformation and inside a CmpMap, dumps and reads back + * as C's does. + */ + @Test + void dumpsAsC() { + MathMap m = new MathMap( + 2, + 2, + new String[] { + "R = sqrt( X*X + Y*Y )", + "Theta = atan2( Y, X )", + "Rout = R * ( 1 + 0.1 * R*R ) + gauss( 0, 0.001 )", + "Tout = Theta + rand( -1.0E-6, 1.0E-6 )" + }, + new String[] {"X = Rout * cos( Tout )", "Y = Rout * sin( Tout )"}); + assertDumps("dump_default", m); + m.set("SimpFI=1"); + assertDumps("dump_simpfi", m); + m.set("SimpIF=0, Seed=1234"); + assertDumps("dump_all_set", m); + m.clear("SimpFI"); + m.clear("SimpIF"); + m.clear("Seed"); + assertDumps("dump_cleared", m); + MathMap mi = (MathMap) m.copy(); + mi.set("Seed=-5, SimpIF=1"); + mi.invert(); + assertDumps("dump_inverted", mi); + MathMap u = new MathMap(1, 1, new String[] {"y"}, new String[] {"t = y * 2", "x = t + 1"}); + assertDumps("dump_no_forward", u); + CmpMap cm = new CmpMap(new ZoomMap(2, 3.0), mi, true); + assertDumps("dump_in_cmpmap", cm); + } + + /** A MathMap read back with its Seed gives the original's sequence. */ + @Test + void seedSurvivesReadBack() { + MathMap m = random1("rand(0,1)", 77); + FitsChan fc = new FitsChan(); + fc.setC("Encoding", "NATIVE"); + fc.write(m); + fc.clear("Card"); + Mapping back = (Mapping) fc.read(); + String got = "Seed " + back.getC("Seed") + " test " + (back.test("Seed") ? 1 : 0) + "\n" + draws(back, 3, 0.0) + + draws(m, 3, 0.0); + assertEquals(probe("seed_read_back"), got); + } + + /** + * Simplifying a CmpMap clears the flag allowing a restricted simplification on the components + * it joins into a new CmpMap, which it shares with the input, as C's does. + */ + @Test + void simplifyClearsAllowSimplifyOnSharedComponents() { + Mapping m = (Mapping) ChannelText.read(Fixtures.read("simplify/cap_restricted_component_flags.map")); + m.simplify(); + assertEquals(probe("simplify_input_after"), ChannelText.dump(m)); + } + + /** A dump through a Channel reads back as an equivalent MathMap, through text. */ + @Test + void channelRoundTripTransformsTheSame() { + MathMap m = new MathMap( + 2, + 2, + new String[] {"r = sqrt(x*x + y*y)", "t = atan2(y, x)", "u = r * 2", "v = t + rand(0, 1)"}, + new String[] {"a = u / 2", "x = a * cos(v)", "y = a * sin(v)"}); + m.setSeed(11); + String text = ChannelText.dump(m); + MathMap back = (MathMap) ChannelText.read(text); + assertEquals(text, ChannelText.dump(back)); + assertArrayEquals(at2(m, 3.0, 4.0, true), at2(back, 3.0, 4.0, true)); + assertArrayEquals(at2(m, 5.0, 0.5, false), at2(back, 5.0, 0.5, false)); + } + + // ------------------------------------------------------------------ + // Simplification and equality (probe mathmap_simplify_probe.c) + // ------------------------------------------------------------------ + + private static final Map SIMPLIFY_CASES = ProbeOutput.load("mathmap_simplify_probe"); + + /** The text of a case of the simplification probe. */ + private static String simplifyProbe(String name) { + String text = SIMPLIFY_CASES.get(name); + if (text == null) { + throw new IllegalStateException("no probe case " + name); + } + return text; + } + + /** A MathMap of the functions given with the attribute settings given. */ + private static MathMap make(int nin, int nout, String[] fwd, String[] inv, String settings) { + MathMap m = new MathMap(nin, nout, fwd, inv); + if (!settings.isEmpty()) { + m.set(settings); + } + return m; + } + + /** The probe's text for the simplified {@code map}: class, input and output counts, and dump. */ + private static String simplified(Mapping map) { + Mapping s = map.simplify(); + return s.astClass() + " " + s.getNin() + " " + s.getNout() + "\n" + ChannelText.dump(s); + } + + /** Asserts that {@code map} simplifies as the probe case {@code name} says C's does. */ + private static void assertSimplified(String name, Mapping map) { + assertEquals(simplifyProbe(name), simplified(map), name); + } + + /** + * Rust {@code test_simplification_simpfi}: a MathMap followed by an identical MathMap applied + * inversely simplifies when both have SimpFI set. + */ + @Test + void simplificationSimpfi() { + MathMap map1 = new MathMap(1, 1, new String[] {"y = x * 2"}, new String[] {"x = y / 2"}); + map1.setSimpFI(true); + MathMap map2 = new MathMap(1, 1, new String[] {"y = x * 2"}, new String[] {"x = y / 2"}); + map2.setSimpFI(true); + map2.invert(); + Mapping s = new CmpMap(map1, map2, true).simplify(); + assertInstanceOf(UnitMap.class, s); + } + + /** + * A MathMap in series with an inverted copy of itself, each way round, cancels to a UnitMap + * exactly where C's does for each setting (unset, 0, 1) of SimpFI and SimpIF: forward then + * inverse needs SimpFI, inverse then forward SimpIF. + */ + @Test + void anInversePairCancelsAsSimpFIAndSimpIFAllow() { + String[] settings = {"", "=0", "=1"}; + String[] names = {"unset", "0", "1"}; + for (int fi = 0; fi < 3; fi++) { + for (int jf = 0; jf < 3; jf++) { + StringBuilder set = new StringBuilder(); + if (fi > 0) { + set.append("SimpFI").append(settings[fi]); + } + if (fi > 0 && jf > 0) { + set.append(','); + } + if (jf > 0) { + set.append("SimpIF").append(settings[jf]); + } + MathMap m = make(1, 1, new String[] {"y = 2 * x"}, new String[] {"x = y / 2"}, set.toString()); + MathMap mi = (MathMap) m.copy(); + mi.invert(); + String suffix = "_simpfi_" + names[fi] + "_simpif_" + names[jf]; + assertSimplified("fwd_inv" + suffix, new CmpMap(m, mi, true)); + assertSimplified("inv_fwd" + suffix, new CmpMap(mi, m, true)); + } + } + } + + /** Both MathMaps of the pair must allow the cancellation. */ + @Test + void bothMathMapsMustConsent() { + MathMap m = make(1, 1, new String[] {"y = 2 * x"}, new String[] {"x = y / 2"}, "SimpFI=1,SimpIF=1"); + MathMap mi = (MathMap) m.copy(); + mi.clear("SimpFI"); + mi.invert(); + assertSimplified("consent_of_both", new CmpMap(m, mi, true)); + } + + /** + * Two MathMaps made separately cancel when their functions are the same once cleaned of case + * and white space, and not when they are equivalent but written differently. + */ + @Test + void separateMathMapsCancelOnlyWithTheSameFunctions() { + MathMap a = make(1, 1, new String[] {"Y = 2 * X"}, new String[] {"X = Y / 2"}, "SimpFI=1,SimpIF=1"); + MathMap b = make(1, 1, new String[] {"y=2*x"}, new String[] {"x=y/2"}, "SimpFI=1,SimpIF=1"); + MathMap c = make(1, 1, new String[] {"y = x * 2"}, new String[] {"x = y / 2"}, "SimpFI=1,SimpIF=1"); + b.invert(); + c.invert(); + assertSimplified("equal_functions", new CmpMap(a, b, true)); + assertSimplified("unequal_functions", new CmpMap(a, c, true)); + } + + /** + * The UnitMap a pair cancels to has the effective number of inputs of the first; intermediate + * functions are compared too; the pair cancels within a longer series but not in parallel; a + * MathMap followed by itself does not cancel. + */ + @Test + void pairsCancelWithTheirCountsAndNeighbours() { + MathMap m = make( + 2, 1, new String[] {"r = sqrt( x * x + y * y )"}, new String[] {"x = r", "y = 0"}, "SimpFI=1,SimpIF=1"); + MathMap mi = (MathMap) m.copy(); + mi.invert(); + assertSimplified("nin_nout_fwd_inv", new CmpMap(m, mi, true)); + assertSimplified("nin_nout_inv_fwd", new CmpMap(mi, m, true)); + + MathMap n = make( + 2, + 2, + new String[] {"t = x + 1", "u = y * t", "v = x - y"}, + new String[] {"x = u + v", "y = u - v"}, + "SimpFI=1,SimpIF=1"); + MathMap ni = (MathMap) n.copy(); + ni.invert(); + assertSimplified("intermediate_functions", new CmpMap(n, ni, true)); + CmpMap pair = new CmpMap(n, ni, true); + assertSimplified("pair_then_zoommap", new CmpMap(pair, new ZoomMap(2, 3.0), true)); + assertSimplified("pair_in_parallel", new CmpMap(n, ni, false)); + assertSimplified("same_twice", new CmpMap(n, n, true)); + } + + /** + * A parallel CmpMap whose first component is an inverted series CmpMap of two identical + * MathMaps simplifies as C's does: the inner CmpMap carries the inversion in InvA and InvB. + */ + @Test + void aParallelCmpMapWithAnInvertedSeriesSimplifiesAsC() { + MathMap a = make(1, 1, new String[] {"y=2*x"}, new String[] {"x=0.5*y"}, "SimpFI=1,SimpIF=1"); + CmpMap first = new CmpMap(a, (Mapping) a.copy(), true); + first.invert(); + MathMap c = make(1, 1, new String[] {"y=2*x"}, new String[] {"x=0.5*y"}, "SimpFI=1,SimpIF=1"); + CmpMap second = new CmpMap(c, (Mapping) c.copy(), true); + assertSimplified("parallel_with_inverted_series", new CmpMap(first, second, false)); + } + + /** + * C's {@code astEqual} on pairs of MathMaps, which compares the compiled functions of the + * effective directions; C leaves the last operation of each function out of the comparison, + * so {@code x+1} equals {@code x-1}. + */ + @Test + void equalToAsC() { + String[] ia = {"x = y / 2"}; + String[] iu = {"x"}; + String[] fu = {"y"}; + String[] i23 = {"x = z", "y = z"}; + MathMap a = make(1, 1, new String[] {"y = 2 * x"}, ia, ""); + MathMap a2 = make(1, 1, new String[] {"y = 2 * x"}, ia, "SimpFI=1"); + MathMap ainv = (MathMap) a.copy(); + ainv.invert(); + MathMap ainv2 = (MathMap) a.copy(); + ainv2.invert(); + MathMap b = make(1, 1, new String[] {"y = 3 * x"}, new String[] {"x = y / 3"}, ""); + MathMap c = make(1, 1, new String[] {"y = x + 1"}, new String[] {"x = y - 1"}, ""); + MathMap d = make(1, 1, new String[] {"y = x - 1"}, new String[] {"x = y + 1"}, ""); + MathMap e = make(1, 1, new String[] {"y = x"}, new String[] {"x = y"}, ""); + MathMap f = make(1, 1, new String[] {"b = a"}, new String[] {"a = b"}, ""); + MathMap g = make(1, 1, new String[] {"y = max( x, 1 )"}, iu, ""); + MathMap h = make(1, 1, new String[] {"y = min( x, 1 )"}, iu, ""); + MathMap i = make(1, 1, new String[] {"y = max( x, 1, 2 )"}, iu, ""); + MathMap j = make(1, 1, new String[] {"y = max( x, 1, 3 )"}, iu, ""); + MathMap u1 = make(1, 1, fu, ia, ""); + MathMap u2 = make(1, 1, fu, ia, ""); + MathMap k = make(1, 1, new String[] {"y = x * 2"}, ia, ""); + MathMap m2 = make(2, 1, new String[] {"z = x"}, i23, ""); + MathMap m3 = make(2, 1, new String[] {"z = y"}, i23, ""); + MathMap m4 = make(1, 1, new String[] {"y = 2 * x", "w = y"}, new String[] {"x = w / 2"}, ""); + MathMap m5 = make(1, 1, new String[] {"y = x * x"}, new String[] {"x = sqrt( y )"}, ""); + MathMap m6 = make(1, 1, new String[] {"y = x * x * x"}, new String[] {"x = sqrt( y )"}, ""); + ZoomMap z = new ZoomMap(1, 2.0); + MathMap u3 = make(1, 1, fu, iu, ""); + MathMap u4 = make(1, 1, fu, iu, ""); + + StringBuilder sb = new StringBuilder(); + equalLine(sb, "same_object", a, a); + equalLine(sb, "same_functions", a, a2); + equalLine(sb, "different_constant", a, b); + equalLine(sb, "last_opcode_differs", c, d); + equalLine(sb, "inverted_copy", a, ainv); + equalLine(sb, "both_inverted", ainv, ainv2); + equalLine(sb, "renamed_variables", e, f); + equalLine(sb, "max_min", g, h); + equalLine(sb, "max_constant", i, j); + equalLine(sb, "max_argument_count", g, i); + equalLine(sb, "no_forward_both", u1, u2); + equalLine(sb, "no_forward_one", u1, a); + equalLine(sb, "forward_one", a, u1); + equalLine(sb, "neither_direction", u3, u4); + equalLine(sb, "operand_order", a, k); + equalLine(sb, "variable_index", m2, m3); + equalLine(sb, "nin_differs", a, m2); + equalLine(sb, "function_count_differs", a, m4); + equalLine(sb, "opcode_count_differs", m5, m6); + equalLine(sb, "zoommap", a, z); + assertEquals(simplifyProbe("equal"), sb.toString()); + } + + private static void equalLine(StringBuilder sb, String name, MathMap a, Mapping b) { + sb.append(name).append(' ').append(a.astEqual(b) ? 1 : 0).append('\n'); + } + + /** A loaded description with fewer functions than outputs is refused. */ + @Test + void loadingTooFewFunctionsIsRefused() { + String text = " Begin MathMap\n Nin = 1\n IsA Mapping\n Nfwd = 0\n Inv1 = \"x\"\n End MathMap\n"; + AstException e = assertThrows(AstException.class, () -> ChannelText.read(text)); + assertEquals(AstException.AST__INNTF, e.getStatus()); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/MatrixMapTest.java b/src/test/java/uk/ac/starlink/ast/MatrixMapTest.java index ba5e232..22f7588 100644 --- a/src/test/java/uk/ac/starlink/ast/MatrixMapTest.java +++ b/src/test/java/uk/ac/starlink/ast/MatrixMapTest.java @@ -559,4 +559,16 @@ void mergingWithAnInvertedSingularMatrixIsAnError() { assertEquals(AstException.AST__MTRML, e.getStatus()); } } + + /** An inverted MatrixMap without an inverse matrix compares its forward matrices (C {@code Equal}). */ + @Test + void anInvertedNonSquareMatrixmapEqualsItsCopy() { + MatrixMap m = full(new double[] {1.0, 2.0, 3.0}, new double[] {4.0, 5.0, 6.0}); + m.invert(); + assertFalse(m.getTranForward()); + assertTrue(m.astEqual(m.copy())); + MatrixMap other = full(new double[] {1.0, 2.0, 3.0}, new double[] {4.0, 5.0, 7.0}); + other.invert(); + assertFalse(m.astEqual(other)); + } } diff --git a/src/test/java/uk/ac/starlink/ast/NanOutputsTest.java b/src/test/java/uk/ac/starlink/ast/NanOutputsTest.java index ada543a..0757acd 100644 --- a/src/test/java/uk/ac/starlink/ast/NanOutputsTest.java +++ b/src/test/java/uk/ac/starlink/ast/NanOutputsTest.java @@ -14,8 +14,8 @@ * 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 LutMap, MathMap, UnitNormMap, PcdMap and TranMap are outside the first - * phase. + *

The Rust test's UnitNormMap is a class not yet ported. 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 { @@ -39,7 +39,16 @@ private static Map mappings() { TimeMap time = new TimeMap(); time.timeAdd("MJDTOJD", new double[] {0.0, 0.0}); m.put("TimeMap", time); + m.put("PcdMap", new PcdMap(1.0e-3, new double[] {0.5, 0.5})); + GrismMap grism = new GrismMap(); + grism.set("GrismNR=1.5,GrismNRP=-1.0E-6,GrismWaveR=5000,GrismAlpha=0.1,GrismG=2.0E-4,GrismM=1," + + "GrismEps=0.02,GrismTheta=0.03"); + m.put("GrismMap", grism); + m.put("DssMap", DssMapTest.dss()); m.put("WcsMap", new WcsMap(2, WcsMap.AST__TAN, 1, 2)); + m.put("LutMap", new LutMap(new double[] {1.0, 2.0, 4.0}, 0.0, 1.0)); + 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)); 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 1ab19c5..e4d25d2 100644 --- a/src/test/java/uk/ac/starlink/ast/NanProtocolTest.java +++ b/src/test/java/uk/ac/starlink/ast/NanProtocolTest.java @@ -1,6 +1,7 @@ package uk.ac.starlink.ast; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; import static uk.ac.starlink.ast.MappingTestData.fromRows; @@ -15,7 +16,7 @@ *

{@code nan_protocol_forward_matches_transform}, {@code * nan_protocol_inverse_matches_transform} and {@code nan_protocol_propagates_bad_and_nan_inputs} * run through the simplified FrameSet read from {@code wcsconv/inputs/lsst.ast}. The tests of - * classes outside the first phase are deferred. + * classes not yet ported are deferred. */ class NanProtocolTest { @@ -184,6 +185,37 @@ void nanProtocolSpecmap() { assertNanProtocolMatchesTransform(map, fromRows(rows), 32, true, 1e-14); } + @Test + void nanProtocolLutmap() { + // A 5-entry table covering x in [0, 4]. + LutMap map = new LutMap(new double[] {10.0, 12.0, 14.0, 16.0, 18.0}, 0.0, 1.0); + map.setI("LutInterp", 0); + double[][] rows = new double[32][]; + for (int i = 0; i < 32; i++) { + rows[i] = new double[] {i * 0.1}; + } + rows[3][0] = BAD; + rows[10][0] = Double.NaN; + assertNanProtocolMatchesTransform(map, fromRows(rows), 32, true, 1e-14); + } + + @Test + void nanProtocolGrismmap() { + // The probe's typical grism (probes/grismmap_probe.c), whose forward transformation is + // good over these inputs. + GrismMap map = new GrismMap(); + map.set("GrismNR=1.5,GrismNRP=-1.0E-6,GrismWaveR=5000,GrismAlpha=0.1,GrismG=2.0E-4,GrismM=1," + + "GrismEps=0.02,GrismTheta=0.03"); + assertNotEquals(BAD, map.tran1(1, new double[] {0.031}, true)[0], "the inputs must transform to good values"); + double[][] rows = new double[32][]; + for (int i = 0; i < 32; i++) { + rows[i] = new double[] {i * 0.001}; + } + rows[5][0] = BAD; + rows[12][0] = Double.NaN; + assertNanProtocolMatchesTransform(map, fromRows(rows), 32, true, 1e-14); + } + /** 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 ee1c0b7..4fffab8 100644 --- a/src/test/java/uk/ac/starlink/ast/NativeRoundTripTest.java +++ b/src/test/java/uk/ac/starlink/ast/NativeRoundTripTest.java @@ -102,6 +102,62 @@ void roundTripMatrixmapDiagonalAndUnit() { assertDoubleRoundTrip(new MatrixMap(2, 3), "MatrixMap unit"); } + @Test + void roundTripLutmap() { + double[] lut = new double[20]; + for (int i = 0; i < lut.length; i++) { + lut[i] = i + 0.1 * Math.pow(i, 1.3); + } + LutMap m = new LutMap(lut, 0.0, 1.0); + m.setI("LutInterp", 0); + assertDoubleRoundTrip(m, "LutMap"); + } + + @Test + void roundTripMathmap() { + MathMap m = new MathMap( + 2, 2, new String[] {"u = x + y", "v = x - y"}, new String[] {"x = 0.5 * (u + v)", "y = 0.5 * (u - v)"}); + assertDoubleRoundTrip(m, "MathMap"); + } + + @Test + void roundTripTranmap() { + TranMap m = new TranMap(new ZoomMap(2, 2.0), new ShiftMap(new double[] {0.5, 0.5})); + assertDoubleRoundTrip(m, "TranMap"); + } + + @Test + void roundTripPcdmap() { + assertDoubleRoundTrip(new PcdMap(1.0e-3, new double[] {0.1, -0.2}), "PcdMap"); + } + + @Test + void roundTripDssmap() { + Mapping m = DssMapTest.dss(); + m.invert(); + m.setIdent("plate"); + Mapping r = (Mapping) assertDoubleRoundTrip(m, "DssMap"); + assertTrue(r.getInvert()); + assertEquals("plate", r.getIdent()); + assertArrayEquals( + m.tranN(1, 2, new double[] {2.8, -1.0}, true, 2), r.tranN(1, 2, new double[] {2.8, -1.0}, true, 2)); + } + + @Test + void roundTripGrismmap() { + GrismMap m = new GrismMap(); + m.set("GrismNR=1.5,GrismNRP=0.0,GrismWaveR=5.0E-7,GrismAlpha=0.1,GrismG=1.0E7,GrismM=1,GrismEps=1.0," + + "GrismTheta=0.0"); + assertDoubleRoundTrip(m, "GrismMap"); + } + + @Test + void roundTripRatemap() { + double[] cofs = {1.0, 1.0, 1.0, 0.0, 0.1, 1.0, 0.0, 1.0, 0.1, 2.0, 1.0, 0.0, 1.0, 2.0, 0.0, 1.0}; + PolyMap inner = new PolyMap(2, 2, 4, cofs, 0, null); + assertDoubleRoundTrip(new RateMap(inner, 1, 1), "RateMap"); + } + @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/NoInverseMap.java b/src/test/java/uk/ac/starlink/ast/NoInverseMap.java index 8b7654e..06de1c6 100644 --- a/src/test/java/uk/ac/starlink/ast/NoInverseMap.java +++ b/src/test/java/uk/ac/starlink/ast/NoInverseMap.java @@ -2,8 +2,7 @@ /** * A 1-dimensional Mapping whose inverse transformation is not defined and whose forward - * transformation doubles each value, standing in for the RateMap the Rust tests use (RateMap is - * outside the first phase): C's ratemap.c creates its Mapping with the inverse undefined. + * transformation doubles each value, for tests that need a Mapping defined in one direction only. */ final class NoInverseMap extends Mapping { diff --git a/src/test/java/uk/ac/starlink/ast/NumericRateTest.java b/src/test/java/uk/ac/starlink/ast/NumericRateTest.java index 6663cdc..b4920a1 100644 --- a/src/test/java/uk/ac/starlink/ast/NumericRateTest.java +++ b/src/test/java/uk/ac/starlink/ast/NumericRateTest.java @@ -13,8 +13,7 @@ * *

{@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. {@code numeric_rate_tan_at_zero} needs a MathMap, and the {@code numeric_rate_chebymap_*} tests a - * ChebyMap, which are outside the first phase. + * relative. The {@code numeric_rate_chebymap_*} tests need a ChebyMap, which is not yet ported. */ class NumericRateTest { @@ -26,6 +25,17 @@ void numericRateLinearMapping() { assertEquals(3.0, zoom.rate(new double[] {1.0, 2.0}, 2, 2), 1e-6, "zoom rate d(out2)/d(in2)"); } + /** + * The rate of {@code tan} at 0 is 1, and at 1 is {@code 1/cos^2(1)}; C's numerical rate + * converges to both (oracle: {@code astRate} of the MathMap {@code y=tan(x)} at 0 is 1.0). + */ + @Test + void numericRateTanAtZero() { + MathMap m = new MathMap(1, 1, new String[] {"y = tan(x)"}, new String[] {"x = atan(y)"}); + assertEquals(1.0, m.rate(new double[] {0.0}, 1, 1), 1e-6, "rate at x = 0"); + assertEquals(3.4255188224, m.rate(new double[] {1.0}, 1, 1), 1e-6, "rate at x = 1"); + } + @Test void numericRateAtZero() { ZoomMap zoom = new ZoomMap(1, 5.0); diff --git a/src/test/java/uk/ac/starlink/ast/ObjectIdOracleTest.java b/src/test/java/uk/ac/starlink/ast/ObjectIdOracleTest.java index 7101c34..dcb4ac7 100644 --- a/src/test/java/uk/ac/starlink/ast/ObjectIdOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/ObjectIdOracleTest.java @@ -24,12 +24,13 @@ * zoommap_blank}, {@code keymap}, {@code channel}, {@code zoommap_copy}, {@code * zoommap_simplified}, {@code cmpmap}, {@code cmpmap_copy}, {@code cmpmap_simplified}, {@code * frame}, {@code skyframe}, {@code frameset}, {@code frameset_frame_id}, {@code - * frameset_part_ids}, {@code cmpframe} and {@code fitschan}. {@code simplify} returns the ZoomMap - * itself, as C's {@code astSimplify} returns a Mapping it cannot simplify, recording it as + * frameset_part_ids}, {@code cmpframe}, {@code fitschan}, {@code cmpmap_unsimplifiable}, {@code + * tranmap} and {@code ratemap}. + * {@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. {@code cmpmap_unsimplifiable} - * needs a LutMap, and the remaining cases other classes outside the first phase. + * and {@code excluded_cases_still_differ} fails when it matches. The remaining cases need classes + * not yet ported. */ class ObjectIdOracleTest { @@ -44,13 +45,16 @@ class ObjectIdOracleTest { "cmpmap", "cmpmap_copy", "cmpmap_simplified", + "cmpmap_unsimplifiable", "frame", "skyframe", "frameset", "frameset_frame_id", "frameset_part_ids", "cmpframe", - "fitschan"); + "fitschan", + "tranmap", + "ratemap"); /** The cases whose dump differs from C's, with the reason. */ private static final String[][] EXCLUDED = {}; @@ -123,6 +127,23 @@ private static AstObject object(String name) { return cmpmap().copy(); case "cmpmap_simplified": return cmpmap().simplify(); + case "cmpmap_unsimplifiable": { + LutMap lut = new LutMap(new double[] {0.0, 1.0, 4.0}, 1.0, 1.0); + lut.setID("l"); + CmpMap m = new CmpMap(zoom(2.0, "a"), lut, true); + m.setID("c"); + return m.simplify(); + } + case "tranmap": { + TranMap t = new TranMap(zoom(2.0, "a"), zoom(3.0, "b")); + t.setID("t"); + return t; + } + case "ratemap": { + RateMap r = new RateMap(zoom(2.0, "rz"), 1, 1); + r.setID("r"); + return r; + } case "frame": Frame f = new Frame(2); f.setID("fid"); diff --git a/src/test/java/uk/ac/starlink/ast/PcdMapTest.java b/src/test/java/uk/ac/starlink/ast/PcdMapTest.java new file mode 100644 index 0000000..d31e691 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/PcdMapTest.java @@ -0,0 +1,806 @@ +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 java.util.Map; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.Fixtures; +import uk.ac.starlink.ast.testsupport.ProbeOutput; + +/** + * Translation of Rust {@code tests/test_pcdmap.rs}, with the cases of the C probe {@code + * probes/pcdmap_probe.c}: attribute values, tests, clears and settings, an axis out of range, a + * PcdMap held by a CmpMap, native dumps with each attribute set and unset read back, + * transformations, rates, a split, equality, and simplification of a PcdMap alone, beside a + * UnitMap, its own inverse, ZoomMaps and PermMaps (C's {@code PcdZoom} and {@code PcdPerm}), and + * in parallel. + * + *

Rust's {@code PcdMap::new} is the jniast constructor. The four Rust tests that call {@code + * try_merge}, which this library does not have, simplify the series CmpMap they describe instead. + */ +class PcdMapTest { + + private static final double BAD = AstObject.AST__BAD; + + private static final Map PROBE_CASES = ProbeOutput.load("pcdmap_probe"); + + private static final String[] ATTRS = {"Disco", "PcdCen", "PcdCen(1)", "PcdCen(2)"}; + + /** The points the probe transforms. */ + private static final double[] XS = {0.1, 0.35, -0.25, 1.5, 0.3, BAD}; + + private static final double[] YS = {0.2, -0.45, 0.05, -2.0, -0.2, 0.7}; + + private static String probe(String name) { + String text = PROBE_CASES.get(name); + if (text == null) { + throw new IllegalStateException("no probe case " + name); + } + return text; + } + + /** + * Requires {@code got} to be C's text for {@code name}, exactly: a PcdMap's arithmetic, and + * that of the Mappings beside it here, uses no elementary function whose last bit could differ + * from C's. + */ + private static void assertProbe(String name, String got) { + assertEquals(probe(name), got, name); + } + + private static PcdMap pcd(double disco, double x, double y) { + return new PcdMap(disco, new double[] {x, y}); + } + + /** The probe's {@code typical}: the PcdMap most cases use. */ + private static PcdMap typical() { + return pcd(0.01, 0.3, -0.2); + } + + private static T inv(T m) { + m.invert(); + return m; + } + + private static ZoomMap zoom(double f) { + return new ZoomMap(2, f); + } + + /** A PermMap exchanging the two axes. */ + private static PermMap swap() { + return new PermMap(2, new int[] {2, 1}, 2, new int[] {2, 1}, null); + } + + private static CmpMap series(Mapping a, Mapping b) { + return new CmpMap(a, b, true); + } + + private static CmpMap series3(Mapping a, Mapping b, Mapping c) { + return series(series(a, b), c); + } + + private static CmpMap parallel(Mapping a, Mapping b) { + return new CmpMap(a, b, false); + } + + private static String g(double v) { + return CFormat.format("%.17g", v); + } + + // ------------------------------------------------------------------ + // tests/test_pcdmap.rs: construction + // ------------------------------------------------------------------ + + @Test + void pcdmapNewBasic() { + PcdMap pm = pcd(0.001, 100.0, 200.0); + assertEquals(2, pm.getNin()); + assertEquals(2, pm.getNout()); + assertFalse(pm.getInvert()); + assertTrue(Math.abs(pm.getDisco() - 0.001) < 1e-15); + assertTrue(Math.abs(pm.getPcdCen(1) - 100.0) < 1e-15); + assertTrue(Math.abs(pm.getPcdCen(2) - 200.0) < 1e-15); + } + + @Test + void pcdmapZeroDisc() { + assertEquals(0.0, pcd(0.0, 0.0, 0.0).getDisco()); + } + + // ------------------------------------------------------------------ + // tests/test_pcdmap.rs: transformations + // ------------------------------------------------------------------ + + private static double[] fwd(Mapping m, double x, double y) { + double[][] out = m.tran2(1, new double[] {x}, new double[] {y}, true); + return new double[] {out[0][0], out[1][0]}; + } + + private static double[] invTran(Mapping m, double x, double y) { + double[][] out = m.tran2(1, new double[] {x}, new double[] {y}, false); + return new double[] {out[0][0], out[1][0]}; + } + + @Test + void pcdmapForwardAtCentre() { + double[] out = fwd(pcd(0.5, 10.0, 20.0), 10.0, 20.0); + assertTrue(Math.abs(out[0] - 10.0) < 1e-12); + assertTrue(Math.abs(out[1] - 20.0) < 1e-12); + } + + @Test + void pcdmapForwardKnownPoint() { + // dx = 10, dy = 0, r^2 = 100, f = 1 + 0.001 * 100 = 1.1. + double[] out = fwd(pcd(0.001, 0.0, 0.0), 10.0, 0.0); + assertTrue(Math.abs(out[0] - 11.0) < 1e-12); + assertTrue(Math.abs(out[1]) < 1e-12); + } + + @Test + void pcdmapForwardWithCentre() { + // dx = 3, dy = 0, r^2 = 9, f = 1 + 0.01 * 9 = 1.09. + double[] out = fwd(pcd(0.01, 5.0, 5.0), 8.0, 5.0); + assertTrue(Math.abs(out[0] - 8.27) < 1e-12); + assertTrue(Math.abs(out[1] - 5.0) < 1e-12); + } + + @Test + void pcdmapForwardBadValue() { + double[] out = fwd(pcd(0.001, 0.0, 0.0), BAD, 5.0); + assertEquals(BAD, out[0]); + assertEquals(BAD, out[1]); + } + + @Test + void pcdmapInverseRoundtrip() { + PcdMap pm = pcd(0.001, 1.0, -2.0); + double[] xs = {5.0, 10.0, 0.5}; + double[] ys = {3.0, -7.0, 0.5}; + double[][] f = pm.tran2(3, xs, ys, true); + double[][] back = pm.tran2(3, f[0], f[1], false); + for (int i = 0; i < 3; i++) { + // The SLA_UNPCD approximation is not exact: for this coefficient and points up to 12 + // from the centre the error is up to about 1e-5. + assertTrue(Math.abs(back[0][i] - xs[i]) < 1e-4, "axis 0, point " + i); + assertTrue(Math.abs(back[1][i] - ys[i]) < 1e-4, "axis 1, point " + i); + } + } + + @Test + void pcdmapInverseBadValue() { + double[] out = invTran(pcd(0.001, 0.0, 0.0), 5.0, BAD); + assertEquals(BAD, out[0]); + assertEquals(BAD, out[1]); + } + + @Test + void pcdmapInvertSwapsDirection() { + PcdMap pm = pcd(0.001, 0.0, 0.0); + assertTrue(Math.abs(fwd(pm, 10.0, 0.0)[0] - 11.0) < 1e-12); + pm.invert(); + assertTrue(pm.getInvert()); + assertTrue(Math.abs(fwd(pm, 10.0, 0.0)[0] - 11.0) > 1e-4); + } + + @Test + void pcdmapMultiplePoints() { + PcdMap pm = pcd(0.001, 0.0, 0.0); + double[][] out = pm.tran2(4, new double[] {0.0, 10.0, 0.0, 10.0}, new double[] {0.0, 0.0, 10.0, 10.0}, true); + double[][] want = {{0.0, 11.0, 0.0, 12.0}, {0.0, 0.0, 11.0, 12.0}}; + for (int i = 0; i < 4; i++) { + assertTrue(Math.abs(out[0][i] - want[0][i]) < 1e-12, "point " + i); + assertTrue(Math.abs(out[1][i] - want[1][i]) < 1e-12, "point " + i); + } + } + + // ------------------------------------------------------------------ + // tests/test_pcdmap.rs: equality + // ------------------------------------------------------------------ + + @Test + void pcdmapEqualSame() { + assertTrue(pcd(0.001, 1.0, 2.0).astEqual(pcd(0.001, 1.0, 2.0))); + } + + @Test + void pcdmapEqualDifferentDisc() { + assertFalse(pcd(0.001, 1.0, 2.0).astEqual(pcd(0.002, 1.0, 2.0))); + } + + @Test + void pcdmapEqualDifferentCentre() { + assertFalse(pcd(0.001, 1.0, 2.0).astEqual(pcd(0.001, 1.0, 3.0))); + } + + @Test + void pcdmapEqualDifferentInversion() { + assertFalse(pcd(0.001, 1.0, 2.0).astEqual(inv(pcd(0.001, 1.0, 2.0)))); + } + + @Test + void pcdmapNotEqualToUnitmap() { + assertFalse(pcd(0.001, 0.0, 0.0).astEqual(new UnitMap(2))); + } + + // ------------------------------------------------------------------ + // tests/test_pcdmap.rs: simplification + // ------------------------------------------------------------------ + + @Test + void pcdmapDiscZeroSimplifiesToUnitmap() { + Mapping simp = pcd(0.0, 5.0, 3.0).simplify(); + assertInstanceOf(UnitMap.class, simp); + assertEquals(2, simp.getNin()); + } + + @Test + void pcdmapNonzeroDiscStaysPcdmap() { + assertInstanceOf(PcdMap.class, pcd(0.001, 0.0, 0.0).simplify()); + } + + @Test + void pcdmapMergeWithInverseCancels() { + PcdMap pm = pcd(0.001, 1.25, -0.75); + assertInstanceOf(UnitMap.class, series(pm, inv((PcdMap) pm.copy())).simplify()); + } + + @Test + void pcdmapMergeSameDirectionNoCancel() { + PcdMap pm = pcd(0.001, 1.0, 2.0); + assertInstanceOf(CmpMap.class, series(pm, (Mapping) pm.copy()).simplify()); + } + + @Test + void pcdmapMergeDifferentDiscNoCancel() { + assertInstanceOf( + CmpMap.class, + series(pcd(0.001, 0.0, 0.0), inv(pcd(0.002, 0.0, 0.0))).simplify()); + } + + @Test + void pcdmapMergeWithUnitmap() { + Mapping merged = series(pcd(0.001, 100.0, 100.0), new UnitMap(2)).simplify(); + PcdMap pm = assertInstanceOf(PcdMap.class, merged); + assertTrue(Math.abs(pm.getDisco() - 0.001) < 1e-15); + } + + // ------------------------------------------------------------------ + // tests/test_pcdmap.rs: serialisation + // ------------------------------------------------------------------ + + private static PcdMap readBack(PcdMap pm) { + return assertInstanceOf(PcdMap.class, ChannelText.read(ChannelText.dump(pm))); + } + + @Test + void pcdmapSerializationRoundtrip() { + PcdMap pm = pcd(0.001, 1.25, -0.75); + assertTrue(pm.astEqual(readBack(pm))); + } + + @Test + void pcdmapSerializationInverted() { + PcdMap pm = inv(pcd(0.005, 10.0, 20.0)); + PcdMap back = readBack(pm); + assertTrue(pm.astEqual(back)); + assertTrue(back.getInvert()); + } + + @Test + void pcdmapSerializationZeroDisc() { + PcdMap pm = pcd(0.0, 0.0, 0.0); + assertTrue(pm.astEqual(readBack(pm))); + } + + @Test + void pcdmapDeserializeFixture() { + PcdMap pm = assertInstanceOf(PcdMap.class, ChannelText.read(Fixtures.read("simplify/pcd_zero_to_unit.map"))); + assertTrue(Math.abs(pm.getDisco()) < 1e-15); + assertTrue(Math.abs(pm.getPcdCen(1)) < 1e-15); + assertTrue(Math.abs(pm.getPcdCen(2)) < 1e-15); + } + + /** + * Rust {@code pcdmap_swap_past_an_inverted_zoommap_preserves_the_transformation}, from C's + * {@code testpcdzoominverted} ({@code ast_tester/testmapping.c}): a PcdMap swapped past a + * ZoomMap applied in either direction, towards an inverted PcdMap it merges with, leaves the + * transformation as it was. + */ + @Test + void pcdmapSwapPastAnInvertedZoommapPreservesTheTransformation() { + double[] xs = {0.1, -0.25}; + double[] ys = {0.2, 0.05}; + for (double z : new double[] {2.0, 0.5}) { + for (boolean inverted : new boolean[] {false, true}) { + PcdMap pm1 = pcd(0.01, 0.3, -0.2); + PcdMap pm2 = inv(pcd(0.01, 0.3, -0.2)); + ZoomMap zm = zoom(z); + if (inverted) { + zm.invert(); + } + CmpMap outer = series(pm1, series(zm, pm2)); + Mapping simp = outer.simplify(); + double[][] before = outer.tran2(2, xs, ys, true); + double[][] after = simp.tran2(2, xs, ys, true); + for (int i = 0; i < 2; i++) { + double mag = Math.abs(before[0][i]) + Math.abs(before[1][i]); + double dev = Math.abs(after[0][i] - before[0][i]) + Math.abs(after[1][i] - before[1][i]); + assertTrue( + mag == 0.0 || dev <= 1.0e-9 * mag, + "zoom " + z + (inverted ? " inverted" : " forward") + ": point " + i + " gave (" + + before[0][i] + ", " + before[1][i] + ") before simplification and (" + + after[0][i] + ", " + after[1][i] + ") after"); + } + } + } + } + + /** + * Rust {@code tests/test_mapping.rs} {@code a_simplified_mapping_set_to_unit_simplifies_again} + * (C's {@code ast_tester/testmapping.c} selfsimp-2): a PcdMap simplified from a series with a + * UnitMap, its Disco then set to zero, simplifies again, to a UnitMap. + */ + @Test + void aSimplifiedPcdMapSetToZeroDiscoSimplifiesAgain() { + PcdMap pm = assertInstanceOf( + PcdMap.class, series(pcd(0.01, 0.0, 0.0), new UnitMap(2)).simplify()); + assertTrue(pm.getIsSimple()); + pm.setDisco(0.0); + assertInstanceOf(UnitMap.class, pm.simplify()); + } + + // ------------------------------------------------------------------ + // jniast API + // ------------------------------------------------------------------ + + /** jniast checks the axis before it reaches C, and the centre array's length. */ + @Test + void jniastChecksTheAxisAndTheCentreArray() { + PcdMap pm = typical(); + assertThrows(IndexOutOfBoundsException.class, () -> pm.getPcdCen(3)); + assertThrows(IndexOutOfBoundsException.class, () -> pm.getPcdCen(0)); + assertThrows(IndexOutOfBoundsException.class, () -> pm.setPcdCen(3, 1.0)); + IllegalArgumentException e = + assertThrows(IllegalArgumentException.class, () -> new PcdMap(0.01, new double[] {1.0})); + assertEquals("Supplied array has only 1 elements (needs 2)", e.getMessage()); + assertThrows(NullPointerException.class, () -> new PcdMap(0.01, null)); + pm.setDisco(-2.5e-3); + pm.setPcdCen(2, 4.0); + assertEquals(-2.5e-3, pm.getDisco()); + assertEquals(0.3, pm.getPcdCen(1)); + assertEquals(4.0, pm.getPcdCen(2)); + } + + // ------------------------------------------------------------------ + // Probe: attributes + // ------------------------------------------------------------------ + + /** Each attribute: whether it is set and its value as {@code getC} gives it. */ + private static String attributes(Mapping m) { + StringBuilder sb = new StringBuilder(); + for (String a : ATTRS) { + sb.append(a) + .append(' ') + .append(m.test(a) ? 1 : 0) + .append(' ') + .append(m.getC(a)) + .append('\n'); + } + return sb.toString(); + } + + @Test + void attributesMatchC() { + assertEquals(probe("attributes_constructed"), attributes(typical())); + assertEquals(probe("attributes_constructed_bad"), attributes(pcd(BAD, BAD, 5.0))); + PcdMap cleared = typical(); + cleared.clear("Disco,PcdCen"); + assertEquals(probe("attributes_cleared"), attributes(cleared)); + PcdMap cleared2 = typical(); + cleared2.clear("PcdCen(2)"); + assertEquals(probe("attributes_cleared_axis_2"), attributes(cleared2)); + PcdMap set = pcd(BAD, BAD, BAD); + set.set("Disco=-2.5E-3,PcdCen(1)=1.25,PcdCen(2)= -7 "); + assertEquals(probe("attributes_set"), attributes(set)); + PcdMap both = typical(); + both.set("PcdCen=3.5"); + assertEquals(probe("attributes_set_both_axes"), attributes(both)); + PcdMap bad = typical(); + bad.setD("Disco", BAD); + bad.setD("PcdCen(1)", BAD); + assertEquals(probe("set_bad_unsets"), attributes(bad)); + } + + private static String report(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 case without the lines naming the C source of an error. */ + private static String withoutSource(String text) { + StringBuilder sb = new StringBuilder(); + for (String line : text.split("\n", -1)) { + if (!line.contains("AST: Error in routine") && !line.isEmpty()) { + sb.append(line).append('\n'); + } + } + return sb.toString(); + } + + /** An axis of PcdCen other than 1 or 2 is refused by every attribute method, as in C. */ + @Test + void anAxisOutOfRangeIsRefused() { + PcdMap pm = typical(); + String got = "get 3\n" + + report(assertThrows(AstException.class, () -> pm.getD("PcdCen(3)"))) + + "get 0\n" + + report(assertThrows(AstException.class, () -> pm.getD("PcdCen(0)"))) + + "set 3\n" + + report(assertThrows(AstException.class, () -> pm.setD("PcdCen(3)", 1.0))) + + "set 0\n" + + report(assertThrows(AstException.class, () -> pm.set("PcdCen(0)=1.0"))) + + "test 3\n" + + report(assertThrows(AstException.class, () -> pm.test("PcdCen(3)"))) + + "clear 3\n" + + report(assertThrows(AstException.class, () -> pm.clear("PcdCen(3)"))) + + attributes(pm); + assertEquals(withoutSource(probe("axis_out_of_range")), got); + } + + @Test + void aSettingThatIsNotANumberIsRefused() { + PcdMap pm = typical(); + String got = report(assertThrows(AstException.class, () -> pm.set("Disco=abc"))) + + report(assertThrows(AstException.class, () -> pm.set("PcdCen(1)=abc"))) + + attributes(pm); + assertEquals(withoutSource(probe("set_not_a_number")), got); + } + + /** + * A PcdMap held by a CmpMap cannot have an attribute set or cleared, as C's cannot once + * cloned (an axis out of range is reported first), but can be inverted; a copy of it can be + * changed. + */ + @Test + void aSharedPcdMapIsImmutable() { + PcdMap pm = typical(); + CmpMap c = series(pm, zoom(2.0)); + String errors = report(assertThrows(AstException.class, () -> pm.setD("Disco", 2.0))) + + report(assertThrows(AstException.class, () -> pm.setD("PcdCen(2)", 2.0))) + + report(assertThrows(AstException.class, () -> pm.set("PcdCen=2.0"))) + + report(assertThrows(AstException.class, () -> pm.clear("Disco"))) + + report(assertThrows(AstException.class, () -> pm.clear("PcdCen(1)"))) + + report(assertThrows(AstException.class, () -> pm.clear("PcdCen"))) + + "set 3\n" + + report(assertThrows(AstException.class, () -> pm.setD("PcdCen(3)", 2.0))); + String attrs = attributes(pm); + pm.invert(); + PcdMap copy = (PcdMap) pm.copy(); + copy.setD("Disco", 2.0); + copy.clear("PcdCen(1)"); + String got = errors + attrs + "Invert " + pm.getI("Invert") + "\n-- copy\n" + attributes(copy); + assertEquals(withoutSource(probe("shared_set")), got); + assertTrue(pm.isShared(), "the CmpMap " + c.astClass() + " holds the PcdMap"); + assertThrows(AstException.class, () -> pm.setDisco(1.0)); + assertThrows(AstException.class, () -> pm.setPcdCen(1, 1.0)); + } + + // ------------------------------------------------------------------ + // Probe: native dumps, transformations, rates, split, equality + // ------------------------------------------------------------------ + + /** + * The probe's {@code tran}: the forward and inverse transformations of the points, given to + * every pair of coordinates. + */ + private static String tran(Mapping m) { + int n = m.getNin(); + int np = XS.length; + double[] in = new double[n * np]; + for (int k = 0; k < n; k++) { + for (int i = 0; i < np; i++) { + in[k * np + i] = k % 2 == 1 ? YS[i] : XS[i]; + } + } + StringBuilder sb = new StringBuilder(); + for (boolean forward : new boolean[] {true, false}) { + double[] out = m.tranN(np, n, in, forward, n); + for (int i = 0; i < np; i++) { + sb.append(forward ? "fwd" : "inv"); + for (int k = 0; k < n; k++) { + sb.append(' ').append(g(in[k * np + i])); + } + sb.append(" ->"); + for (int k = 0; k < n; k++) { + sb.append(' ').append(g(out[k * np + i])); + } + sb.append('\n'); + } + } + return sb.toString(); + } + + private static void assertRoundTrips(String name, Mapping m) { + String dump = ChannelText.dump(m); + Mapping back = (Mapping) ChannelText.read(dump); + String got = dump + "-- read back\n" + ChannelText.dump(back) + "-- equal " + (m.astEqual(back) ? 1 : 0) + "\n" + + "-- transformations\n" + tran(m) + "-- transformations read back\n" + tran(back); + assertProbe(name, got); + } + + /** + * Dumps of PcdMaps with every attribute set, inverted, none set, set to zero, each cleared in + * turn, and simplified, each read back, as C writes and reads them. + */ + @Test + void nativeDumpsMatchC() { + assertRoundTrips("dump_set", typical()); + assertRoundTrips("dump_inverted", inv(typical())); + assertRoundTrips("dump_unset", pcd(BAD, BAD, BAD)); + assertRoundTrips("dump_zero", pcd(0.0, 0.0, 0.0)); + String[] clr = {"Disco", "PcdCen(1)", "PcdCen(2)"}; + String[] names = {"dump_without_Disco", "dump_without_PcdCen1", "dump_without_PcdCen2"}; + for (int i = 0; i < clr.length; i++) { + PcdMap pm = typical(); + pm.clear(clr[i]); + assertRoundTrips(names[i], pm); + } + assertRoundTrips("dump_simplified", typical().simplify()); + } + + @Test + void transformationsMatchC() { + assertProbe("transformations", tran(typical())); + assertProbe("transformations_inverted", tran(inv(typical()))); + assertProbe("transformations_barrel", tran(pcd(-0.3, 0.1, 0.1))); + PcdMap pm = pcd(5.0, 0.0, 0.0); + double[] x = {1.0, 10.0, 100.0}; + double[] y = {0.0, 10.0, -100.0}; + double[][] out = pm.tran2(3, x, y, true); + double[][] back = pm.tran2(3, out[0], out[1], false); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < 3; i++) { + sb.append(g(x[i])) + .append(' ') + .append(g(y[i])) + .append(" -> ") + .append(g(out[0][i])) + .append(' ') + .append(g(out[1][i])) + .append(" -> ") + .append(g(back[0][i])) + .append(' ') + .append(g(back[1][i])) + .append('\n'); + } + assertProbe("transformations_large", sb.toString()); + } + + /** C's PcdMap has no rate of its own: the base class's numerical estimate is used. */ + @Test + void ratesMatchC() { + PcdMap pm = typical(); + double[] at = {0.1, 0.2}; + StringBuilder sb = new StringBuilder(); + for (int i = 1; i <= 2; i++) { + for (int j = 1; j <= 2; j++) { + sb.append("fwd ") + .append(i) + .append(' ') + .append(j) + .append(' ') + .append(g(pm.rate(at, i, j))) + .append('\n'); + } + } + pm.invert(); + for (int i = 1; i <= 2; i++) { + for (int j = 1; j <= 2; j++) { + sb.append("inv ") + .append(i) + .append(' ') + .append(j) + .append(' ') + .append(g(pm.rate(at, i, j))) + .append('\n'); + } + } + assertProbe("rate", sb.toString()); + } + + /** + * C's PcdMap has no {@code MapSplit} of its own: one input of the two does not split off, and + * both, in either order, give the PcdMap behind a PermMap, as the base class's does. + */ + @Test + void aSplitIsTheWholePcdMap() { + int[] out = new int[2]; + Mapping one = inv(typical()).mapSplit(new int[] {1}, out); + Mapping two = inv(typical()).mapSplit(new int[] {2, 1}, out); + String got = "one input " + (one == null ? "null" : one.astClass()) + "\n" + "outputs " + out[0] + " " + out[1] + + "\n" + ChannelText.dump(two); + assertEquals(probe("split"), got); + } + + private static int eq(AstObject a, AstObject b) { + return a.astEqual(b) ? 1 : 0; + } + + /** + * C compares the attributes as stored, so a centre set to zero differs from an unset one; a + * coefficient of 1e-13 equals zero to within {@code astEQUAL}, though not an unset one. + */ + @Test + void equalityMatchesC() { + PcdMap a = typical(); + PcdMap cleared = pcd(0.01, 0.0, 0.0); + cleared.clear("PcdCen"); + String got = "same " + eq(a, typical()) + "\n" + + "copy " + eq(a, a.copy()) + "\n" + + "different_disco " + eq(a, pcd(0.02, 0.3, -0.2)) + "\n" + + "different_centre " + eq(a, pcd(0.01, 0.3, -0.3)) + "\n" + + "near_disco " + eq(a, pcd(0.01 * (1.0 + 1.0e-12), 0.3, -0.2)) + "\n" + + "inverted " + eq(a, inv(typical())) + "\n" + + "both_inverted " + eq(inv(typical()), inv(typical())) + "\n" + + "zero_vs_unset " + eq(pcd(0.01, 0.0, 0.0), cleared) + "\n" + + "small_vs_unset_disco " + eq(pcd(1.0e-13, 0.0, 0.0), pcd(BAD, 0.0, 0.0)) + "\n" + + "small_vs_zero_disco " + eq(pcd(1.0e-13, 0.0, 0.0), pcd(0.0, 0.0, 0.0)) + "\n" + + "not_a_pcdmap " + eq(a, zoom(2.0)) + "\n"; + assertEquals(probe("equal"), got); + } + + // ------------------------------------------------------------------ + // Probe: simplification + // ------------------------------------------------------------------ + + private static void assertSimplifies(String name, Mapping map) { + Mapping s = map.simplify(); + String got = "class " + s.astClass() + "\n" + ChannelText.dump(s) + "-- transformations\n" + tran(map) + + "-- transformations simplified\n" + tran(s); + assertProbe(name, got); + } + + /** + * A PcdMap whose coefficient is zero by pcdmap.c's own {@code EQUAL}, whose floor is {@code + * DBL_MIN}, becomes a UnitMap, alone, inverted, in series or in parallel; a coefficient of + * 1e-13 is not zero by that test. + */ + @Test + void aPcdMapWithoutDistortionBecomesAUnitMap() { + assertSimplifies("alone", typical()); + assertSimplifies("alone_inverted", inv(typical())); + assertSimplifies("zero_disco", pcd(0.0, 0.3, -0.2)); + assertSimplifies("unset_disco", pcd(BAD, 0.3, -0.2)); + assertSimplifies("zero_disco_inverted", inv(pcd(0.0, 0.3, -0.2))); + assertSimplifies("small_disco", pcd(1.0e-13, 0.3, -0.2)); + assertSimplifies("tiny_disco", pcd(1.0e-310, 0.3, -0.2)); + assertSimplifies("zero_disco_parallel", parallel(pcd(0.0, 0.3, -0.2), zoom(2.0))); + assertSimplifies("zero_disco_series", series3(zoom(2.0), pcd(0.0, 0.3, -0.2), zoom(3.0))); + } + + /** + * A PcdMap merges with a UnitMap, and with a PcdMap applied the other way whose coefficient + * and centre, as their getters give them, are equal by pcdmap.c's {@code EQUAL}; not with + * others, nor in parallel. + */ + @Test + void unitMapAndInverseNeighboursMergeAsC() { + assertSimplifies("unit_after", series(typical(), new UnitMap(2))); + assertSimplifies("unit_before_inverted", series(new UnitMap(2), inv(typical()))); + assertSimplifies("inverse_after", series(typical(), inv(typical()))); + assertSimplifies("inverse_before", series(inv(typical()), typical())); + PcdMap unsetCentre = pcd(0.01, 0.0, 0.0); + unsetCentre.clear("PcdCen"); + assertSimplifies("inverse_unset_centre", series(pcd(0.01, 0.0, 0.0), inv(unsetCentre))); + assertSimplifies("inverse_near_disco", series(typical(), inv(pcd(0.01 * (1.0 + 1.0e-12), 0.3, -0.2)))); + assertSimplifies("inverse_different_disco", series(typical(), inv(pcd(0.01 * (1.0 + 1.0e-9), 0.3, -0.2)))); + assertSimplifies("inverse_different_centre", series(typical(), inv(pcd(0.01, 0.3, -0.3)))); + assertSimplifies("inverse_small_centre_offset", series(pcd(0.01, 0.0, 0.0), inv(pcd(0.01, 1.0e-13, 0.0)))); + assertSimplifies("same_direction", series(typical(), typical())); + PcdMap p = typical(); + assertSimplifies("shared_pair", series(p, inv((PcdMap) p.copy()))); + assertSimplifies("parallel_inverse", parallel(typical(), inv(typical()))); + } + + /** + * C's {@code PcdZoom}: a PcdMap swaps past a ZoomMap, applied in either direction, towards a + * PcdMap it then merges with, its centre and coefficient scaled by the factor the list applies. + * Inverting a component after the CmpMap is made does not change the CmpMap. + */ + @Test + void zoomMapSwapsMatchC() { + assertSimplifies("zoom_then_inverse", series3(typical(), zoom(2.0), inv(pcd(0.0025, 0.6, -0.4)))); + assertSimplifies("inverted_zoom_then_inverse", series3(typical(), inv(zoom(2.0)), inv(pcd(0.04, 0.15, -0.1)))); + assertSimplifies("inverted_pcd_zoom_then_pcd", series3(inv(typical()), zoom(2.0), pcd(0.0025, 0.6, -0.4))); + assertSimplifies( + "inverted_pcd_inverted_zoom_then_pcd", series3(inv(typical()), inv(zoom(0.5)), pcd(0.0025, 0.6, -0.4))); + assertSimplifies("zoom_then_inverse_not_matching", series3(typical(), zoom(2.0), inv(typical()))); + ZoomMap z = zoom(2.0); + CmpMap c = series3(typical(), z, inv(pcd(0.04, 0.15, -0.1))); + z.invert(); + assertSimplifies("zoom_inverted_after_combining", c); + PcdMap p = typical(); + CmpMap c2 = series3(p, zoom(2.0), pcd(0.0025, 0.6, -0.4)); + p.invert(); + assertSimplifies("pcd_inverted_after_combining", c2); + assertSimplifies( + "two_zooms_then_inverse", + series(series3(typical(), zoom(2.0), zoom(3.0)), inv(pcd(0.01 / 36.0, 1.8, -1.2)))); + assertSimplifies( + "zoom_inverse_both_sides", + series( + series3(inv(pcd(0.04, 0.15, -0.1)), zoom(2.0), typical()), + series(zoom(2.0), inv(pcd(0.0025, 0.6, -0.4))))); + } + + /** + * C's {@code PcdPerm}: a PcdMap swaps past a PermMap that exchanges the two axes, applied in + * either direction, its centre exchanged; not past a PermMap that does anything else. + */ + @Test + void permMapSwapsMatchC() { + assertSimplifies("perm_then_inverse", series3(typical(), swap(), inv(pcd(0.01, -0.2, 0.3)))); + assertSimplifies("inverted_pcd_perm_then_pcd", series3(inv(typical()), swap(), pcd(0.01, -0.2, 0.3))); + assertSimplifies("inverted_perm_then_inverse", series3(typical(), inv(swap()), inv(pcd(0.01, -0.2, 0.3)))); + assertSimplifies( + "perm_zoom_then_inverse", series(series3(typical(), swap(), zoom(2.0)), inv(pcd(0.0025, -0.4, 0.6)))); + PermMap notSwap = new PermMap(2, new int[] {1, 2}, 2, new int[] {1, -1}, new double[] {4.0}); + assertSimplifies("perm_not_a_swap", series3(typical(), notSwap, inv(typical()))); + assertSimplifies("perm_alone_after", series(typical(), swap())); + } + + /** + * With no PcdMap to merge with, a swap is kept only when one of the swapped Mappings then + * simplifies: past a ZoomMap of factor 1, not past one of factor 2; a ShiftMap is not swapped. + */ + @Test + void swapsWithoutATargetMatchC() { + assertSimplifies("zoom_after_no_target", series(typical(), zoom(2.0))); + assertSimplifies("zoom_before_no_target", series(zoom(2.0), typical())); + assertSimplifies("unit_zoom_after", series(typical(), zoom(1.0))); + assertSimplifies("shift_between", series3(typical(), new ShiftMap(new double[] {0.3, -0.2}), inv(typical()))); + } + + // ------------------------------------------------------------------ + // NaN protocol + // ------------------------------------------------------------------ + + /** The NaN protocol gives what the transformation gives, bad where it is bad. */ + @Test + void nanProtocolMatchesTheTransformation() { + double[][] rows = new double[32][]; + for (int i = 0; i < 32; i++) { + rows[i] = new double[] {i * 0.1 - 1.5, 0.7 - i * 0.05}; + } + rows[5][0] = BAD; + rows[12][1] = Double.NaN; + double[][] pts = fromRows(rows); + for (Mapping m : new Mapping[] {typical(), inv(typical())}) { + for (boolean forward : new boolean[] {true, false}) { + double[][] regular = m.transform(pts, 32, forward); + double[][] viaNan = m.transformNanProtocol(pts, 32, forward); + for (int axis = 0; axis < 2; axis++) { + for (int i = 0; i < 32; i++) { + double r = regular[axis][i]; + double n = viaNan[axis][i]; + if (r == BAD || Double.isNaN(r) || n == BAD || Double.isNaN(n)) { + assertTrue( + (r == BAD || Double.isNaN(r)) && (n == BAD || Double.isNaN(n)), + "point " + i + " axis " + axis + ": " + r + " and " + n); + } else { + assertEquals(r, n, "point " + i + " axis " + axis); + } + } + } + } + } + } +} diff --git a/src/test/java/uk/ac/starlink/ast/PermMapTest.java b/src/test/java/uk/ac/starlink/ast/PermMapTest.java index 24b4ac2..273ff00 100644 --- a/src/test/java/uk/ac/starlink/ast/PermMapTest.java +++ b/src/test/java/uk/ac/starlink/ast/PermMapTest.java @@ -388,4 +388,35 @@ void nullPermutationConstructorChecksArrayLengths() { assertThrows(AstException.class, () -> new PermMap(2, null, 2, new int[] {1}, null)) .getStatus()); } + + // ------------------------------------------------------------------ + // Equality (permmap.c Equal compares the constants each permutation selects) + // ------------------------------------------------------------------ + + @Test + void permEqualSameConstantIndexDifferingValues() { + assertFalse(perm(new int[] {-1}, new int[] {1}, 5.0).astEqual(perm(new int[] {-1}, new int[] {1}, 7.0))); + } + + @Test + void permEqualSameConstantIndexSameValue() { + assertTrue(perm(new int[] {-1}, new int[] {1}, 5.0).astEqual(perm(new int[] {-1}, new int[] {1}, 5.0))); + } + + @Test + void permEqualDifferentIndexSameReferencedValue() { + assertTrue( + perm(new int[] {-1}, new int[] {1}, 9.0, 0.0).astEqual(perm(new int[] {-2}, new int[] {1}, 0.0, 9.0))); + } + + @Test + void permEqualDifferentIndexDifferentReferencedValue() { + assertFalse( + perm(new int[] {-1}, new int[] {1}, 9.0, 0.0).astEqual(perm(new int[] {-2}, new int[] {1}, 0.0, 4.0))); + } + + @Test + void permEqualIgnoresUnreferencedSurplusConstants() { + assertTrue(perm(new int[] {1}, new int[] {1}, 1.0).astEqual(perm(new int[] {1}, new int[] {1}, 2.0))); + } } diff --git a/src/test/java/uk/ac/starlink/ast/PolyMapTest.java b/src/test/java/uk/ac/starlink/ast/PolyMapTest.java index 4aba21f..743b10f 100644 --- a/src/test/java/uk/ac/starlink/ast/PolyMapTest.java +++ b/src/test/java/uk/ac/starlink/ast/PolyMapTest.java @@ -19,7 +19,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.ProbeOutput; /** * Translation of Rust {@code tests/test_polymap.rs}, which ports C's {@code testpolymap.c}: @@ -39,6 +41,8 @@ class PolyMapTest { private static final double BAD = AstObject.AST__BAD; + private static final Map POLYMAP_CANCEL_PROBE = ProbeOutput.load("polymap_cancel_probe"); + private static void assertClose(double want, double got, double tol, String what) { assertTrue(Math.abs(got - want) < tol, what + ": got " + got + ", want " + want); } @@ -601,7 +605,7 @@ void cSimplify() { PolyMap pm = cPoly(2, C_COEFF2); Mapping simp = pm.simplify(); assertInstanceOf(PolyMap.class, simp, "Error 3002"); - assertTrue(((PolyMap) simp).equalTo(pm), "Error 3003"); + assertTrue(simp.astEqual(pm), "Error 3003"); } /** @@ -619,24 +623,43 @@ void polymapAffineGeneralMergesWithANeighbour() { } /** - * A PolyMap that cancels against its neighbour is left with the Invert attribute it had. The - * inverted series CmpMap applies the second PolyMap forward, so the merge sets that PolyMap's - * Invert attribute while it compares the pair; C does not restore it when the pair cancels - * (polymap.c {@code MapMerge} restores only a PolyMap that was not replaced), which the merge - * here does. + * The series CmpMap of a PolyMap and an inverted copy of it, itself inverted if {@code + * invertCmp}, simplified, with the Invert attributes of the two PolyMaps, which the CmpMap + * shares, before and after, as probe {@code polymap_cancel_probe.c} writes them. */ - @Test - void aCancelledPolymapKeepsItsInvert() { - double[][] fwd = {term(1.0, 1, 2), term(3.0, 1, 1)}; - double[][] inv = {term(0.5, 1, 1)}; - PolyMap p = poly(1, 1, fwd, inv); + private static String cancel(boolean invertCmp) { + PolyMap p = poly(1, 1, new double[][] {term(1.0, 1, 2), term(3.0, 1, 1)}, new double[][] {term(0.5, 1, 1)}); PolyMap q = (PolyMap) p.copy(); q.invert(); CmpMap c = new CmpMap(p, q, true); - c.invert(); - assertInstanceOf(UnitMap.class, c.simplify()); - assertFalse(p.getInvert()); - assertTrue(q.getInvert()); + if (invertCmp) { + c.invert(); + } + String before = invertAttrs("before", p, q); + Mapping s = c.simplify(); + return before + "class " + s.astClass() + "\n" + invertAttrs("after", p, q); + } + + 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"; + } + + /** + * 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. + */ + @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)); } @Test @@ -873,4 +896,45 @@ void polymapWithoutAnInverseRefusesItOnTheNanPathToo() { assertEquals(plain.getStatus(), nan.getStatus()); assertArrayEquals(new double[2], nanOut[0], "no outputs written"); } + + // ------------------------------------------------------------------ + // Equality (polymap.c Equal) + // ------------------------------------------------------------------ + + @Test + void polymapEqualComparesTheInverseCoefficients() { + double[][] fwd = {term(1.0, 1, 2)}; + double[][] half = {term(0.5, 1, 1)}; + double[][] seven = {term(0.7, 1, 1)}; + PolyMap a = poly(1, 1, fwd, half); + PolyMap same = poly(1, 1, fwd, half); + assertTrue(a.astEqual(same), "identical PolyMaps compare equal"); + assertTrue(same.astEqual(a), "equality is symmetric"); + PolyMap differ = poly(1, 1, fwd, seven); + assertFalse(a.astEqual(differ), "the inverse coefficient values differ, so the two are not equal"); + assertFalse(differ.astEqual(a), "in either direction"); + differ.invert(); + Mapping s = new CmpMap(poly(1, 1, fwd, half), differ, true).simplify(); + assertFalse(s instanceof UnitMap, "the inverse transformations differ, so the pair stands"); + PolyMap sameInv = poly(1, 1, fwd, half); + sameInv.invert(); + s = new CmpMap(poly(1, 1, fwd, half), sameInv, true).simplify(); + assertInstanceOf(UnitMap.class, s, "identical PolyMaps in opposite directions cancel"); + } + + @Test + void polymapWithMoreOutputsThanInputsEqualsItsCopy() { + int nwide = 8; + double[][] fwd = new double[nwide][]; + for (int io = 1; io <= nwide; io++) { + fwd[io - 1] = term(io, io, 1); + } + int[] ones = new int[nwide]; + Arrays.fill(ones, 1); + double[][] inv = {term(1.0, 1, ones)}; + PolyMap wide = poly(1, nwide, fwd, inv); + PolyMap copy = (PolyMap) wide.copy(); + assertTrue(wide.astEqual(copy), "a PolyMap equals its own copy"); + assertTrue(copy.astEqual(wide), "in either direction"); + } } diff --git a/src/test/java/uk/ac/starlink/ast/RateMapTest.java b/src/test/java/uk/ac/starlink/ast/RateMapTest.java new file mode 100644 index 0000000..dd5e31c --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/RateMapTest.java @@ -0,0 +1,680 @@ +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.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertSame; +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.Map; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.Fixtures; +import uk.ac.starlink.ast.testsupport.ProbeOutput; + +/** + * Translation of Rust {@code tests/test_ratemap.rs} (after C's {@code ast_tester/testratemap.c}), + * with the cases of the C probe {@code probes/ratemap_probe.c}: native dumps of RateMaps of + * ZoomMaps (the encapsulated Mapping inverted when the RateMap is made or afterwards, the RateMap + * inverted) and of a LutMap, a MathMap and a TranMap, each read back; simplification of a RateMap + * alone and of RateMaps cancelling against their inverses in series; rates; equality; splits; and + * the constructor's errors. + * + *

Rust's {@code ax1()} and {@code ax2()}, numbered from 1, are here the zero-based {@code + * getIout()} and {@code getIin()}, C's {@code iout} and {@code iin}. The five Rust tests that call + * {@code try_merge}, which this library does not have, simplify the series or parallel CmpMap they + * describe instead. + */ +class RateMapTest { + + private static final double BAD = AstObject.AST__BAD; + + private static final Map PROBE_CASES = ProbeOutput.load("ratemap_probe"); + + private static String probe(String name) { + String text = PROBE_CASES.get(name); + if (text == null) { + throw new IllegalStateException("no probe case " + name); + } + return text; + } + + private static ZoomMap zoom(int n, double f) { + return new ZoomMap(n, f); + } + + private static T inv(T m) { + m.invert(); + return m; + } + + private static RateMap rate(Mapping m, int ax1, int ax2) { + return new RateMap(m, ax1, ax2); + } + + /** The forward transformation of the points, given one row per point. */ + private static double[][] fwd(Mapping m, double[]... rows) { + return transformRows(m, true, rows); + } + + private static int code(org.junit.jupiter.api.function.Executable e) { + return assertThrows(AstException.class, e).getStatus(); + } + + // ------------------------------------------------------------------ + // Construction + // ------------------------------------------------------------------ + + @Test + void constructionBasic() { + RateMap rm = rate(zoom(1, 3.0), 1, 1); + assertEquals(1, rm.getNin()); + assertEquals(1, rm.getNout()); + assertEquals(0, rm.getIout()); + assertEquals(0, rm.getIin()); + assertFalse(rm.getInvert()); + assertTrue(rm.getTranForward()); + assertFalse(rm.getTranInverse()); + } + + @Test + void constructionMultiAxis() { + RateMap rm = rate(zoom(3, 2.0), 2, 3); + assertEquals(3, rm.getNin()); + assertEquals(1, rm.getNout()); + assertEquals(1, rm.getIout()); + assertEquals(2, rm.getIin()); + } + + @Test + void constructionInvalidAxes() { + ZoomMap zm = zoom(2, 3.0); + assertEquals(AstException.AST__INNCO, code(() -> rate(zm, 3, 1))); + assertEquals(AstException.AST__INNCO, code(() -> rate(zm, 1, 3))); + assertEquals(AstException.AST__INNCO, code(() -> rate(zm, 0, 1))); + assertEquals(AstException.AST__INNCO, code(() -> rate(zm, 1, 0))); + } + + // ------------------------------------------------------------------ + // Forward transformation + // ------------------------------------------------------------------ + + @Test + void zoommapRate() { + RateMap rm = rate(zoom(1, 3.0), 1, 1); + double[][] out = fwd(rm, new double[] {1.0}, new double[] {2.0}, new double[] {5.0}, new double[] {-10.0}); + assertEquals(1, out.length); + for (int i = 0; i < 4; i++) { + assertEquals(3.0, out[0][i], 1e-6, "point " + i); + } + } + + @Test + void shiftmapRate() { + RateMap rm = rate(new ShiftMap(new double[] {5.0, 10.0}), 1, 1); + double[][] out = fwd(rm, new double[] {1.0, 3.0}, new double[] {2.0, 4.0}); + assertEquals(1, out.length); + for (int i = 0; i < 2; i++) { + assertEquals(1.0, out[0][i], 1e-6, "point " + i); + } + } + + @Test + void offDiagonalZero() { + RateMap rm = rate(zoom(2, 3.0), 1, 2); + double[][] out = fwd(rm, new double[] {1.0, 3.0}, new double[] {2.0, 4.0}); + for (int i = 0; i < 2; i++) { + assertEquals(0.0, out[0][i], 1e-6, "point " + i); + } + } + + /** + * A RateMap asks its Mapping's rate at a bad input too, as ratemap.c Transform does, and a + * ZoomMap's rate does not depend on the position, so C gives 3.0 there (oracle {@code rate.json}, + * {@code ratemap_zoommap_bad_input}). + */ + @Test + void badInputAsksTheMapping() { + RateMap rm = rate(zoom(1, 3.0), 1, 1); + double[][] out = fwd(rm, new double[] {1.0}, new double[] {BAD}, new double[] {3.0}); + assertEquals(3.0, out[0][0], 1e-6); + assertEquals(3.0, out[0][1]); + assertEquals(3.0, out[0][2], 1e-6); + } + + /** Requesting the inverse is AST__TRNND, as C's base Transform reports. */ + @Test + void inverseUndefined() { + RateMap rm = rate(zoom(1, 3.0), 1, 1); + assertFalse(rm.getTranInverse()); + assertEquals(AstException.AST__TRNND, code(() -> transformRows(rm, false, new double[] {1.0}))); + } + + @Test + void inverted() { + RateMap rm = inv(rate(zoom(1, 3.0), 1, 1)); + assertEquals(1, rm.getNin()); + assertEquals(1, rm.getNout()); + assertFalse(rm.getTranForward()); + assertTrue(rm.getTranInverse()); + assertTrue(rm.getInvert()); + assertEquals(AstException.AST__TRNND, code(() -> fwd(rm, new double[] {1.0}))); + assertEquals(3.0, transformRows(rm, false, new double[] {1.0})[0][0], 1e-6); + } + + @Test + void invertedMultiAxis() { + RateMap rm = rate(zoom(2, 5.0), 1, 1); + assertEquals(2, rm.getNin()); + assertEquals(1, rm.getNout()); + rm.invert(); + assertEquals(1, rm.getNin()); + assertEquals(2, rm.getNout()); + } + + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + @Test + void equalSame() { + assertTrue(rate(zoom(2, 3.0), 1, 2).astEqual(rate(zoom(2, 3.0), 1, 2))); + } + + @Test + void equalDifferentAxes() { + assertFalse(rate(zoom(2, 3.0), 1, 1).astEqual(rate(zoom(2, 3.0), 1, 2))); + } + + @Test + void equalDifferentMapping() { + assertFalse(rate(zoom(1, 3.0), 1, 1).astEqual(rate(zoom(1, 5.0), 1, 1))); + } + + /** RateMaps whose Invert attributes differ are never equal (ratemap.c Equal). */ + @Test + void equalDifferentInvert() { + assertFalse(rate(zoom(1, 3.0), 1, 1).astEqual(inv(rate(zoom(1, 3.0), 1, 1)))); + } + + /** Every comparison of the probe's {@code equal} case gives C's {@code astEqual}. */ + @Test + void equalityMatchesC() { + RateMap a = rate(zoom(2, 2.0), 1, 2); + RateMap b = rate(zoom(2, 2.0), 1, 2); + RateMap c = rate(zoom(2, 2.0), 1, 1); + RateMap d = rate(zoom(2, 3.0), 1, 2); + RateMap e = rate(inv(zoom(2, 0.5)), 1, 2); + RateMap ainv = inv((RateMap) a.copy()); + RateMap binv = inv((RateMap) b.copy()); + ZoomMap z = zoom(2, 2.0); + RateMap f = rate(z, 1, 2); + z.invert(); + String got = "same " + flag(a.astEqual(b)) + "\n" + + "different_axes " + flag(a.astEqual(c)) + "\n" + + "different_mappings " + flag(a.astEqual(d)) + "\n" + + "equivalent_mappings " + flag(a.astEqual(e)) + "\n" + + "inverted_vs_plain " + flag(ainv.astEqual(a)) + "\n" + + "both_inverted " + flag(ainv.astEqual(binv)) + "\n" + + "mapping_inverted_after " + flag(f.astEqual(a)) + "\n" + + "not_a_ratemap " + flag(a.astEqual(zoom(2, 2.0))) + "\n" + + "mapping_still_inverted " + flag(z.getInvert()) + "\n"; + assertEquals(probe("equal"), got); + } + + private static int flag(boolean b) { + return b ? 1 : 0; + } + + // ------------------------------------------------------------------ + // Simplification + // ------------------------------------------------------------------ + + /** A RateMap of a series CmpMap of ZoomMaps becomes a RateMap of their product. */ + @Test + void simplifyInterior() { + RateMap rm = rate(new CmpMap(zoom(2, 2.0), zoom(2, 3.0), true), 1, 1); + Mapping simp = rm.simplify(); + assertInstanceOf(RateMap.class, simp); + assertEquals(6.0, fwd(simp, new double[] {1.0, 1.0})[0][0], 1e-6); + } + + /** A RateMap in series with its own inverse cancels (Rust {@code inverse_cancel_merge}). */ + @Test + void inverseCancelMerge() { + Mapping simp = new CmpMap(rate(zoom(1, 2.0), 1, 1), inv(rate(zoom(1, 2.0), 1, 1)), true).simplify(); + assertInstanceOf(UnitMap.class, simp); + assertEquals(1, simp.getNin()); + assertEquals(1, simp.getNout()); + } + + /** RateMaps with the same Invert attribute do not cancel (Rust {@code no_cancel_same_invert}). */ + @Test + void noCancelSameInvert() { + Mapping simp = new CmpMap(rate(zoom(1, 2.0), 1, 1), rate(zoom(1, 2.0), 1, 1), true).simplify(); + assertInstanceOf(CmpMap.class, simp); + } + + /** RateMaps of different axes do not cancel (Rust {@code no_cancel_different_axes}). */ + @Test + void noCancelDifferentAxes() { + Mapping simp = new CmpMap(rate(zoom(2, 2.0), 1, 1), inv(rate(zoom(2, 2.0), 1, 2)), true).simplify(); + assertInstanceOf(CmpMap.class, simp); + } + + /** RateMaps of different Mappings do not cancel (Rust {@code no_cancel_different_mapping}). */ + @Test + void noCancelDifferentMapping() { + Mapping simp = new CmpMap(rate(zoom(1, 2.0), 1, 1), inv(rate(zoom(1, 3.0), 1, 1)), true).simplify(); + assertInstanceOf(CmpMap.class, simp); + } + + /** RateMaps in parallel do not cancel (Rust {@code no_cancel_parallel}). */ + @Test + void noCancelParallel() { + Mapping simp = new CmpMap(rate(zoom(1, 2.0), 1, 1), inv(rate(zoom(1, 2.0), 1, 1)), false).simplify(); + assertInstanceOf(CmpMap.class, simp); + } + + /** The error simplifying the encapsulated Mapping is passed up, as in C (probe {@code simp_error}). */ + @Test + void anErrorSimplifyingTheEncapsulatedMappingIsPassedUp() { + CmpMap inner = new CmpMap( + new PermMap(2, new int[] {0, 0}, 2, new int[] {-1, -2}, new double[] {0.1, 0.2}), + new WcsMap(2, WcsMap.AST__COE, 1, 2), + true); + RateMap map = rate(inner, 1, 1); + assertEquals(AstException.AST__WCSPA, code(map::simplify)); + assertTrue(probe("simp_error").endsWith("status " + AstException.AST__WCSPA + "\n")); + } + + // ------------------------------------------------------------------ + // Simplification against the probe + // ------------------------------------------------------------------ + + private static String trans(Mapping m, double x) { + StringBuilder sb = new StringBuilder(); + int nin = m.getNin(); + int nout = m.getNout(); + if (m.getTranForward()) { + sb.append(tranLine("fwd", m, x, nin, nout, true)); + } + if (m.getTranInverse()) { + sb.append(tranLine("inv", m, x, nout, nin, false)); + } + return sb.toString(); + } + + private static String tranLine(String label, Mapping m, double x, int nin, int nout, boolean forward) { + double[] in = new double[nin]; + for (int i = 0; i < nin; i++) { + in[i] = x + i; + } + double[] out = m.tranN(1, nin, in, forward, nout); + StringBuilder sb = new StringBuilder(label); + for (double v : in) { + sb.append(' ').append(CFormat.format("%.17g", v)); + } + sb.append(" ->"); + for (double v : out) { + sb.append(' ').append(CFormat.format("%.17g", v)); + } + return sb.append('\n').toString(); + } + + private static void assertSimplifies(String name, Mapping map, double x) { + Mapping s = map.simplify(); + String got = "class " + s.astClass() + "\n" + ChannelText.dump(s) + "-- transformations\n" + trans(map, x) + + "-- transformations simplified\n" + trans(s, x); + assertEquals(probe(name), got, name); + } + + private static CmpMap zooms(int n, double f1, double f2) { + return new CmpMap(zoom(n, f1), zoom(n, f2), true); + } + + /** + * A RateMap alone is replaced by a RateMap of its simplified Mapping, simplified in the + * orientation it had when the RateMap was made; one whose Mapping does not simplify, such as a + * UnitMap, is left as it is. + */ + @Test + void aRateMapAloneSimplifiesAsC() { + assertSimplifies("simp_plain", rate(zoom(1, 2.0), 1, 1), 1.5); + assertSimplifies("simp_unitmap", rate(new UnitMap(2), 1, 2), 1.5); + assertSimplifies("simp_interior", rate(zooms(2, 2.0, 3.0), 1, 1), 1.5); + assertSimplifies("simp_interior_inverted_mapping", rate(inv(zooms(1, 2.0, 4.0)), 1, 1), 1.5); + CmpMap c = zooms(1, 2.0, 4.0); + RateMap r = rate(c, 1, 1); + c.invert(); + assertSimplifies("simp_interior_mapping_inverted_after", r, 1.5); + assertSimplifies("simp_interior_ratemap_inverted", inv(rate(zooms(1, 2.0, 4.0), 1, 1)), 1.5); + assertSimplifies( + "simp_interior_in_series", new CmpMap(zoom(1, 5.0), rate(zooms(1, 2.0, 4.0), 1, 1), true), 1.5); + } + + /** + * A RateMap in series beside its inverse, a RateMap of the same axes of an equal Mapping, is + * replaced, with it, by UnitMaps, as C does. + */ + @Test + void cancellationsMatchC() { + assertSimplifies( + "cancel_upper", new CmpMap(rate(zoom(1, 2.0), 1, 1), inv(rate(zoom(1, 2.0), 1, 1)), true), 1.5); + assertSimplifies( + "cancel_lower", new CmpMap(inv(rate(zoom(1, 2.0), 1, 1)), rate(zoom(1, 2.0), 1, 1), true), 1.5); + assertSimplifies( + "cancel_two_inputs_upper", + new CmpMap(rate(zoom(2, 2.0), 1, 1), inv(rate(zoom(2, 2.0), 1, 1)), true), + 1.5); + assertSimplifies( + "cancel_two_inputs_lower", + new CmpMap(inv(rate(zoom(2, 2.0), 1, 1)), rate(zoom(2, 2.0), 1, 1), true), + 1.5); + assertSimplifies( + "cancel_equivalent_mappings", + new CmpMap(rate(zoom(1, 2.0), 1, 1), inv(rate(inv(zoom(1, 0.5)), 1, 1)), true), + 1.5); + ZoomMap z = zoom(1, 2.0); + RateMap r = rate(z, 1, 1); + z.invert(); + assertSimplifies("cancel_mapping_inverted_after", new CmpMap(r, inv(rate(zoom(1, 2.0), 1, 1)), true), 1.5); + } + + /** RateMaps that are not inverses of each other, or not in series, are left as they are. */ + @Test + void nonCancellationsMatchC() { + assertSimplifies( + "no_cancel_axes", new CmpMap(rate(zoom(2, 2.0), 1, 1), inv(rate(zoom(2, 2.0), 1, 2)), true), 1.5); + assertSimplifies( + "no_cancel_mappings", new CmpMap(rate(zoom(1, 2.0), 1, 1), inv(rate(zoom(1, 3.0), 1, 1)), true), 1.5); + assertSimplifies( + "no_cancel_same_invert", new CmpMap(rate(zoom(1, 2.0), 1, 1), rate(zoom(1, 2.0), 1, 1), true), 1.5); + assertSimplifies( + "no_cancel_parallel", new CmpMap(rate(zoom(1, 2.0), 1, 1), inv(rate(zoom(1, 2.0), 1, 1)), false), 1.5); + RateMap r = rate(zoom(1, 2.0), 1, 1); + assertSimplifies("no_cancel_shared", new CmpMap(r, r, true), 1.5); + } + + // ------------------------------------------------------------------ + // Native dumps + // ------------------------------------------------------------------ + + private static void assertRoundTrips(String name, Mapping m, double x) { + String dump = ChannelText.dump(m); + Mapping back = (Mapping) ChannelText.read(dump); + String got = dump + "-- read back\n" + ChannelText.dump(back) + "-- transformations\n" + trans(m, x) + + "-- transformations read back\n" + trans(back, x); + assertEquals(probe(name), got, name); + } + + private static final double[] TABLE = {0.0, 1.0, 4.0, 9.0, 16.0}; + + private static MathMap square() { + return new MathMap(1, 1, new String[] {"y = x * x"}, new String[] {"x = sqrt( y )"}); + } + + /** RateMaps of ZoomMaps, inverted in each way, dump and read back as in C. */ + @Test + void nativeDumpsMatchC() { + assertRoundTrips("dump_plain", rate(zoom(2, 3.0), 2, 1), 1.5); + assertRoundTrips("dump_first_axes", rate(zoom(1, 2.0), 1, 1), 1.5); + assertRoundTrips("dump_inverted_mapping", rate(inv(zoom(1, 2.0)), 1, 1), 1.5); + ZoomMap z = zoom(1, 2.0); + RateMap r = rate(z, 1, 1); + z.invert(); + assertRoundTrips("dump_mapping_inverted_after", r, 1.5); + assertRoundTrips("dump_ratemap_inverted", inv(rate(zoom(2, 3.0), 1, 2)), 1.5); + } + + /** RateMaps of a LutMap, a MathMap and a TranMap dump and read back as in C. */ + @Test + void nativeDumpsOfOtherMappingsMatchC() { + assertRoundTrips("dump_lutmap", rate(new LutMap(TABLE, 1.0, 1.0), 1, 1), 2.5); + MathMap mm = new MathMap(2, 2, new String[] {"r = x * y", "s = x + y * y"}, new String[] {"x", "y"}); + assertRoundTrips("dump_mathmap", rate(mm, 2, 2), 1.5); + assertRoundTrips("dump_tranmap", rate(new TranMap(square(), zoom(1, 3.0)), 1, 1), 1.5); + assertRoundTrips("dump_inverted_tranmap", rate(inv(new TranMap(zoom(1, 3.0), square())), 1, 1), 1.5); + } + + @Test + void serializationRoundtrip() { + RateMap rm = rate(zoom(2, 3.0), 2, 1); + RateMap back = (RateMap) ChannelText.read(ChannelText.dump(rm)); + assertEquals(2, back.getNin()); + assertEquals(1, back.getNout()); + assertEquals(1, back.getIout()); + assertEquals(0, back.getIin()); + assertFalse(back.getInvert()); + double[][] out = fwd(back, new double[] {1.0, 3.0}, new double[] {2.0, 4.0}); + for (int i = 0; i < 2; i++) { + assertEquals(0.0, out[0][i], 1e-6, "point " + i); + } + } + + @Test + void serializationRoundtripDiagonal() { + Mapping back = (Mapping) ChannelText.read(ChannelText.dump(rate(zoom(2, 3.0), 1, 1))); + double[][] out = fwd(back, new double[] {1.0, 3.0}, new double[] {2.0, 4.0}); + for (int i = 0; i < 2; i++) { + assertEquals(3.0, out[0][i], 1e-6, "point " + i); + } + } + + /** IIn and IOut of zero are not written, and read back as zero. */ + @Test + void serializationDefaultAxes() { + String text = ChannelText.dump(rate(zoom(1, 2.0), 1, 1)); + assertFalse(text.contains("IIn")); + assertFalse(text.contains("IOut")); + RateMap back = (RateMap) ChannelText.read(text); + assertEquals(0, back.getIout()); + assertEquals(0, back.getIin()); + } + + // ------------------------------------------------------------------ + // Fixtures + // ------------------------------------------------------------------ + + @Test + void readFixtureInverseCancel() { + Mapping m = (Mapping) ChannelText.read(Fixtures.read("simplify/ratemap_inverse_cancel.map")); + assertEquals(1, m.getNin()); + } + + @Test + void readFixtureSimplifyInterior() { + Mapping m = (Mapping) ChannelText.read(Fixtures.read("simplify/ratemap_simplify_interior.map")); + assertEquals(2, m.getNin()); + assertEquals(1, m.getNout()); + } + + @Test + void simplifyInverseCancelFixture() { + Mapping m = (Mapping) ChannelText.read(Fixtures.read("simplify/ratemap_inverse_cancel.map")); + Mapping simp = m.simplify(); + assertInstanceOf(UnitMap.class, simp); + assertEquals(1, simp.getNin()); + assertEquals(1, simp.getNout()); + } + + @Test + void simplifyInteriorFixture() { + Mapping m = (Mapping) ChannelText.read(Fixtures.read("simplify/ratemap_simplify_interior.map")); + Mapping simp = m.simplify(); + assertInstanceOf(RateMap.class, simp); + assertEquals(6.0, fwd(simp, new double[] {1.0, 1.0})[0][0], 1e-6); + } + + @Test + void negNonRatemapNeighbour() { + Mapping m = (Mapping) ChannelText.read(Fixtures.read("simplify/neg_ratemap_nonratemap_neighbour.map")); + assertFalse(m.simplify() instanceof UnitMap); + } + + @Test + void negDifferentInner() { + Mapping m = (Mapping) ChannelText.read(Fixtures.read("simplify/neg_ratemap_different_inner.map")); + assertFalse(m.simplify() instanceof UnitMap); + } + + @Test + void negParallel() { + Mapping m = (Mapping) ChannelText.read(Fixtures.read("simplify/neg_ratemap_parallel.map")); + assertFalse(m.simplify() instanceof UnitMap); + } + + // ------------------------------------------------------------------ + // testratemap.c + // ------------------------------------------------------------------ + + /** + * {@code testratemap.c}: a RateMap of each Jacobian element of the compound Mapping {@code + * testrate.c} uses, forward and inverted, transforming (1,2,3,4) to the rate itself, with C's + * error numbers in the messages. Only the forward direction of a RateMap exists. + */ + @Test + void rateMapsOfACompoundMapping() { + double[] at = {1.0, 2.0, 3.0, 4.0}; + Mapping m = RateTest.compoundMap(); + double[][][] tables = {RateTest.COMPOUND_FORWARD, RateTest.COMPOUND_INVERSE}; + int[] firstErr = {1, 11}; + for (int t = 0; t < 2; t++) { + double[][] table = tables[t]; + for (int k = 0; k < table.length; k++) { + int ax1 = (int) table[k][0]; + int ax2 = (int) table[k][1]; + double want = table[k][2]; + boolean exact = table[k][3] != 0.0; + RateMap rm = rate(m, ax1, ax2); + if (k == 0 && t == 0) { + assertTrue(rm.getTranForward(), "Error 2"); + assertFalse(rm.getTranInverse(), "Error 3"); + } + double r = point(fwd(rm, at), 0)[0]; + int err = t == 0 && k > 0 ? 3 + k : firstErr[t] + k; + if (exact) { + assertEquals(want, r, "Error " + err + ": RateMap(" + ax1 + "," + ax2 + ")"); + } else { + assertTrue( + Math.abs(r - want) <= 1.0e-6, + "Error " + err + ": RateMap(" + ax1 + "," + ax2 + ") = " + r + ", want " + want); + } + } + m.invert(); + } + } + + // ------------------------------------------------------------------ + // Rates, splits and errors against the probe + // ------------------------------------------------------------------ + + /** The numerical rate of a RateMap, and its outputs at a good and a bad input, as in C. */ + @Test + void ratesMatchC() { + MathMap cube = new MathMap(1, 1, new String[] {"y = x * x * x"}, new String[] {"x"}); + RateMap r = rate(cube, 1, 1); + double[] at = {2.0}; + String got = "rate of ratemap " + CFormat.format("%.17g", r.rate(at, 1, 1)) + "\n" + + "ratemap of cube at 2 " + CFormat.format("%.17g", r.tran1(1, at, true)[0]) + "\n" + + "ratemap of cube at bad " + CFormat.format("%.17g", r.tran1(1, new double[] {BAD}, true)[0]) + + "\n"; + assertEquals(probe("rates"), got); + } + + private static String split(Mapping m, int[] in) { + int[] out = new int[m.getNout()]; + Mapping s = m.mapSplit(in, out); + if (s == null) { + return "split none\n"; + } + StringBuilder sb = new StringBuilder("outputs"); + for (int i = 0; i < s.getNout(); i++) { + sb.append(' ').append(out[i]); + } + return sb.append('\n').append(ChannelText.dump(s)).toString(); + } + + private static ShiftMap shift3() { + return new ShiftMap(new double[] {10.0, 20.0, 30.0}); + } + + /** + * Splits of a RateMap: the encapsulated Mapping is split, and the split is a RateMap if it + * keeps both the varied input and the differentiated output; an inverted RateMap is split only + * as the base class splits it. + */ + @Test + void splitsMatchC() { + assertEquals(probe("split_output_dropped"), split(rate(shift3(), 2, 1), new int[] {1})); + assertEquals(probe("split_picks_varied_input"), split(rate(shift3(), 1, 1), new int[] {1})); + assertEquals(probe("split_other_input"), split(rate(shift3(), 1, 1), new int[] {2})); + assertEquals(probe("split_two_inputs"), split(rate(shift3(), 1, 1), new int[] {3, 1})); + assertEquals(probe("split_inverted"), split(inv(rate(shift3(), 1, 1)), new int[] {1})); + assertEquals(probe("split_inverted_mapping"), split(rate(inv(shift3()), 1, 1), new int[] {1})); + } + + /** A split RateMap shares nothing with the RateMap it came from. */ + @Test + void aSplitIsIndependent() { + ShiftMap s = shift3(); + RateMap r = rate(s, 1, 1); + MapSplit split = r.mapSplit(new int[] {0}); + assertInstanceOf(RateMap.class, split.map); + assertNotSame(s, ((RateMap) split.map).getMap()); + } + + private static String report(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 case without the line naming the C source of the error. */ + private static String errorCase(String name) { + StringBuilder sb = new StringBuilder(); + for (String line : probe(name).split("\n", -1)) { + if (!line.startsWith("!! ") && !line.isEmpty()) { + sb.append(line).append('\n'); + } + } + return sb.toString(); + } + + private static void assertError(String name, org.junit.jupiter.api.function.Executable e) { + assertEquals(errorCase(name), report(assertThrows(AstException.class, e)), name); + } + + /** The constructor's checks, and the directions a RateMap does not define, as in C. */ + @Test + void errorsMatchC() { + assertError("error_no_forward", () -> rate(inv(rate(zoom(1, 2.0), 1, 1)), 1, 1)); + assertError("error_output_axis", () -> rate(zoom(2, 2.0), 3, 1)); + assertError("error_input_axis", () -> rate(zoom(2, 2.0), 1, 3)); + assertError("error_output_axis_zero", () -> rate(zoom(2, 2.0), 0, 1)); + assertError("error_input_axis_zero", () -> rate(zoom(2, 2.0), 1, 0)); + assertError("error_inverse", () -> rate(zoom(1, 2.0), 1, 1).tran1(1, new double[] {1.0}, false)); + assertError( + "error_inverted_forward", () -> inv(rate(zoom(1, 2.0), 1, 1)).tran1(1, new double[] {1.0}, true)); + } + + // ------------------------------------------------------------------ + // Sharing and copying + // ------------------------------------------------------------------ + + /** A RateMap holds the Mapping it is given, as C clones it, and a copy holds a copy. */ + @Test + void theMappingIsSharedAndCopied() { + ZoomMap z = zoom(1, 2.0); + RateMap r = rate(z, 1, 1); + assertSame(z, r.getMap()); + RateMap c = (RateMap) r.copy(); + assertNotSame(z, c.getMap()); + assertTrue(c.getMap().astEqual(z)); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/RateOracleTest.java b/src/test/java/uk/ac/starlink/ast/RateOracleTest.java new file mode 100644 index 0000000..2d1db8f --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/RateOracleTest.java @@ -0,0 +1,90 @@ +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.List; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.ProbeData; + +/** + * Translation of Rust {@code tests/test_rate_oracle.rs}: rates of change from classes that + * delegate to a component's rate, against C's {@code astRate}, from {@code oracle/rate.json} + * ({@code tools/oracle_fixtures/rate_probe.c}): a RateMap asks its Mapping's rate at every point, + * bad inputs included (ratemap.c Transform); a TranMap its forward component's, in the orientation + * it records (tranmap.c Rate). A RateMap read from a dump whose recorded orientation ({@code Inv}) + * differs from its Mapping's Invert asks the rate in the recorded orientation. + * + *

The SwitchMap cases select their routes with a SelectorMap of Box Regions, classes not yet + * ported, so {@code rates_match_the_c_library} runs the others. + */ +class RateOracleTest { + + private static final double BAD = AstObject.AST__BAD; + + /** The output of a RateMap of {@code map} (output 1 with respect to input 1) at {@code at}. */ + private static double ratemapAt(Mapping map, double... at) { + return new RateMap(map, 1, 1).tranN(1, at.length, at, true, 1)[0]; + } + + /** Java's rate for a case, or null for a case whose classes are not yet ported. */ + private static Double rate(String name) { + switch (name) { + case "ratemap_zoommap_bad_input": + return ratemapAt(new ZoomMap(1, 3.0), BAD); + case "ratemap_unitmap_bad_other_axis": + return ratemapAt(new UnitMap(2), 1.0, BAD); + case "tranmap_forward": + case "tranmap_inverted": { + TranMap tm = new TranMap(new ZoomMap(1, 2.0), new ZoomMap(1, 3.0)); + if ("tranmap_inverted".equals(name)) { + tm.invert(); + } + return tm.rate(new double[] {1.0}, 1, 1); + } + case "ratemap_recorded_orientation": { + ZoomMap zm = new ZoomMap(1, 2.0); + zm.invert(); + String dump = ChannelText.dump(new RateMap(zm, 1, 1)); + assertTrue(dump.contains("Inv = 1")); + // The encapsulated ZoomMap loses its Invert card, as in the probe. + StringBuilder edited = new StringBuilder(); + for (String line : dump.split("\n", -1)) { + if (!line.isEmpty() && !line.contains(" Invert = 1")) { + edited.append(line).append('\n'); + } + } + RateMap rm = (RateMap) ChannelText.read(edited.toString()); + return rm.tran1(1, new double[] {1.0}, true)[0]; + } + case "switchmap_forward": + case "switchmap_inverted_no_selector": + case "switchmap_inverted_route": + return null; + default: + throw new IllegalArgumentException("no Java construction for case " + name); + } + } + + @Test + void ratesMatchTheCLibrary() { + List failures = new ArrayList<>(); + int ran = 0; + for (JsonNode c : ProbeData.load("rate").get("CASES")) { + String name = c.get(0).asText(); + Double got = rate(name); + if (got == null) { + continue; + } + double want = ProbeData.toDouble(c.get(1)); + if (Double.compare(got, want) != 0) { + failures.add(name + ": " + got + ", C " + want); + } + ran++; + } + assertTrue(failures.isEmpty(), String.join("\n", failures)); + assertEquals(5, ran, "cases run"); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/RateTest.java b/src/test/java/uk/ac/starlink/ast/RateTest.java index 14212b5..d9b0fbb 100644 --- a/src/test/java/uk/ac/starlink/ast/RateTest.java +++ b/src/test/java/uk/ac/starlink/ast/RateTest.java @@ -10,7 +10,7 @@ * a compound Mapping, after C's {@code ast_tester/testrate.c}, with its error numbers in the * assertion messages. The tolerance of 1e-6 is the program's own, for the rates C compares to it. * - *

{@code tran_map} needs a TranMap, which is outside the first phase. As in C, the unit + *

As in C, the unit * MatrixMap is made in its unit form. The Rust test builds the CmpMap's components in the * orientation they had when C composed them; here, as in C, the components are inverted after the * CmpMap is made, which, as the CmpMap records each component's Invert value when it is made, @@ -171,6 +171,17 @@ void permMap() { assertEquals(0.0, m.rate(AT, 1, 2), "Error 44"); } + @Test + void tranMap() { + TranMap m = new TranMap(winMap(), fullMatrix()); + assertEquals(2.0, m.rate(AT, 1, 1), "Error 46"); + assertEquals(0.0, m.rate(AT, 2, 1), "Error 47"); + assertEquals(2.0, m.rate(AT, 2, 2), "Error 48"); + assertEquals(0.0, m.rate(AT, 1, 2), "Error 49"); + m.invert(); + assertInverseFullMatrixRates(m, new int[] {51, 52, 53, 54}); + } + @Test void cmpMap() { double[] at = {1.0, 2.0, 3.0, 4.0}; diff --git a/src/test/java/uk/ac/starlink/ast/SimplifyRegressionTest.java b/src/test/java/uk/ac/starlink/ast/SimplifyRegressionTest.java index 7eff61b..b891a49 100644 --- a/src/test/java/uk/ac/starlink/ast/SimplifyRegressionTest.java +++ b/src/test/java/uk/ac/starlink/ast/SimplifyRegressionTest.java @@ -1,6 +1,7 @@ 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.assertTrue; import java.util.ArrayList; @@ -15,6 +16,7 @@ import uk.ac.starlink.ast.testsupport.NativeClasses; import uk.ac.starlink.ast.testsupport.OracleFile; import uk.ac.starlink.ast.testsupport.OracleSection; +import uk.ac.starlink.ast.testsupport.ProbeOutput; /** * Translation of Rust {@code tests/test_simplify_regression.rs::simplify_regression}: the rows of @@ -23,8 +25,10 @@ * *

For each row the input is read and simplified, after reducing a FrameSet to its base-to-current * Mapping unless the reference is itself a FrameSet (the reference was then made by simplifying the - * FrameSet). The simplified Mapping's native dump is compared with the reference by the row's - * fourth field: + * FrameSet). The simplified Mapping, read back from its native dump, must be equal to the + * reference by {@code astEqual}, as C's harness finds it ({@code ast_tester/test_simplify.tap} + * runs {@code ast_astequal} on every row). The simplified Mapping's native dump is compared with + * the reference by the row's fourth field: * *

    *
  • blank: numbers within 4 units in the last place, every other byte equal; @@ -38,7 +42,10 @@ * *

    Simplifying must leave the input as C leaves it: its dump, apart from the records of * simplification C also writes on it ({@code IsSimp}, {@code ReSimp}), and what it computes for the - * inputs of its oracle sections, are unchanged. + * inputs of its oracle sections, are unchanged. Where the probe {@code + * probes/simplify_input_probe.c} records C's dump of a row's input after simplification, the + * input's dump, apart from those records, must be that instead: C's comparisons of CmpMaps can + * change the Invert attribute of a component shared with the input (row {@code brad}). * *

    The simplified Mapping must also transform the inputs of the input file's sections of {@code * oracle/simplify_fixtures.oracle} to C's recorded outputs, within the file's tolerances, as the @@ -110,6 +117,12 @@ private static Map> oracleSections() { /** The reason of a row whose Mappings are all in scope but whose simplification differs from C's. */ static final String SIMPLIFY = "needs simplification"; + /** + * C's dumps of rows' inputs after simplification, as {@code /input_after} cases of the + * probe {@code probes/simplify_input_probe.c}. + */ + private static final Map INPUT_AFTER = ProbeOutput.load("simplify_input_probe"); + /** * The reason a failing row is listed with: the out-of-scope classes its input or reference * names, or {@value #SIMPLIFY} if there are none, since the row then fails in a part of the @@ -136,6 +149,7 @@ static String failure(Row r, Map> oracle, TransformO Mapping simplified; Mapping input; String dump; + boolean equal; try { AstObject inObj = ChannelText.read(Fixtures.read(r.input)); AstObject refObj = ChannelText.read(refText); @@ -143,9 +157,15 @@ static String failure(Row r, Map> oracle, TransformO if (input == null) { return "input is a " + inObj.getClass().getSimpleName() + ", not a Mapping"; } - String inputBefore = withoutRecords(ChannelText.dump(input)); + List inputBefore = withoutRecords(ChannelText.dump(input)); simplified = input.simplify(); - if (!inputBefore.equals(withoutRecords(ChannelText.dump(input)))) { + List inputAfter = withoutRecords(ChannelText.dump(input)); + String cAfter = INPUT_AFTER.get(r.name + "/input_after"); + if (cAfter != null) { + if (!withoutRecords(cAfter).equals(inputAfter)) { + return "simplify() left the input's dump other than C leaves it"; + } + } else if (!sameButForClearedAlSimp(inputBefore, inputAfter)) { return "simplify() changed the input's dump"; } // Both dumps are taken before anything is transformed, since a transformation can @@ -153,6 +173,7 @@ static String failure(Row r, Map> oracle, TransformO // correction factor it works out, as C's does (specmap.c FrameChange). What the input // computed before it was simplified is found from a second reading of it. dump = ChannelText.dump(simplified); + equal = equalToReference(refObj, dump); List transformsBefore = inputTransforms( inputMapping(ChannelText.read(Fixtures.read(r.input)), refObj), oracle.get(r.input)); List transformsAfter = inputTransforms(input, oracle.get(r.input)); @@ -165,6 +186,9 @@ static String failure(Row r, Map> oracle, TransformO return "read or simplify: " + e.getMessage(); } + if (!equal) { + return "astEqual finds the simplified Mapping, read from its dump, unequal to C's"; + } boolean sameFile = r.input.equals(r.reference); if (sameFile) { boolean frame = simplified instanceof Frame; @@ -199,6 +223,16 @@ static String failure(Row r, Map> oracle, TransformO return problem; } + /** + * Whether astEqual finds the reference {@code refObj} equal to the simplified Mapping read + * from its dump {@code dump}. C's harness compares the two, both read from their dumps, with + * astEqual (ast_tester/test_simplify.tap, ast_astequal.c), the reference first: a dump does not + * carry everything astEqual looks at, such as a base Frame written only through Frm. + */ + static boolean equalToReference(AstObject refObj, String dump) { + return refObj.astEqual(ChannelText.read(dump)); + } + /** * The Mapping a row simplifies: the input itself, or a FrameSet's base-to-current Mapping when * the reference is not a FrameSet; null if the input is not a Mapping. @@ -214,18 +248,37 @@ private static Mapping inputMapping(AstObject inObj, AstObject refObj) { } /** - * A dump without its records of simplification, {@code IsSimp} and {@code ReSimp}, which C's - * {@code astSimplify} also writes on the Mapping it is given and on its shared components. + * The lines of a dump without its records of simplification, {@code IsSimp} and {@code + * ReSimp}, which C's {@code astSimplify} also writes on the Mapping it is given and on its + * shared components. */ - private static String withoutRecords(String dump) { - StringBuilder sb = new StringBuilder(); + private static List withoutRecords(String dump) { + List out = new ArrayList<>(); for (String line : CValues.lines(dump)) { String t = line.trim(); if (!t.startsWith("IsSimp =") && !t.startsWith("ReSimp =")) { - sb.append(line).append('\n'); + out.add(line); } } - return sb.toString(); + return out; + } + + /** + * Whether the dump {@code after} is the dump {@code before} with no change but {@code AlSimp} + * lines removed: cmpmap.c {@code Simplify} clears AllowSimplify on each component it joins + * into a new CmpMap, among them components it shares with the input (probe {@code + * mathmap_probe.c}, case {@code simplify_input_after}), but sets it on none of them. + */ + private static boolean sameButForClearedAlSimp(List before, List after) { + int j = 0; + for (String line : before) { + if (j < after.size() && line.equals(after.get(j))) { + j++; + } else if (!line.trim().startsWith("AlSimp =")) { + return false; + } + } + return j == after.size(); } /** @@ -322,6 +375,20 @@ private static String transformFailure( return null; } + /** + * The astEqual check accepts a row's own simplification and rejects a wrong one: row {@code + * zoom_series_merge} simplifies two ZoomMaps in series to C's ZoomMap of factor 6, and a ZoomMap + * of factor 5 or the unsimplified CmpMap is not that. + */ + @Test + void theAstEqualCheckRejectsAWrongSimplification() { + AstObject ref = ChannelText.read(Fixtures.read("simplify/zoom_series_merge.simp")); + Mapping input = (Mapping) ChannelText.read(Fixtures.read("simplify/zoom_series_merge.map")); + assertTrue(equalToReference(ref, ChannelText.dump(input.simplify()))); + assertFalse(equalToReference(ref, ChannelText.dump(new ZoomMap(2, 5.0)))); + assertFalse(equalToReference(ref, ChannelText.dump(input))); + } + @Test void rowCountIsTheManifests() { assertEquals(MANIFEST_ROWS, rows().size()); diff --git a/src/test/java/uk/ac/starlink/ast/SpecFluxFrameTest.java b/src/test/java/uk/ac/starlink/ast/SpecFluxFrameTest.java index f82d026..8e25d37 100644 --- a/src/test/java/uk/ac/starlink/ast/SpecFluxFrameTest.java +++ b/src/test/java/uk/ac/starlink/ast/SpecFluxFrameTest.java @@ -11,7 +11,10 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; +import java.util.Arrays; +import java.util.Map; import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.ProbeOutput; /** * Translation of Rust {@code tests/test_specflux.rs} (ported from C's {@code @@ -20,21 +23,20 @@ * defaults, conversions, matching and dumps. * *

    A conversion between two SpecFluxFrames whose SpecFrames and FluxFrames are not each equal - * (C's {@code astEqual}) is built by C's {@code MakeSFMapping} with a RateMap, a MathMap and a - * TranMap ({@code MakeMapF} and {@code MakeMapI}, specfluxframe.c), classes this library does not - * have; such a conversion throws, naming the first absent class C builds. That is RateMap, built - * by {@code MakeMapF}, unless the comparison of the FluxFrames first needs a MathMap for - * logarithmic units ({@code astUnitMapper} in fluxframe.c {@code MakeFluxMapping}). Each such test - * gives C's converted value in its Javadoc. Equal components convert through a UnitMap, and - * SpecFluxFrames whose SpecFrames do not convert do not convert at all; both work here as in C. + * (C's {@code astEqual}) is built by C's {@code MakeSFMapping} with a RateMap, MathMaps and a + * TranMap ({@code MakeMapF} and {@code MakeMapI}, specfluxframe.c). Each such conversion is + * checked against the C probe {@code probes/specflux_probe.c}: the class and dump of the + * simplified Mapping {@code astConvert} gives, and the transformation of a point forwards and of + * the result back. Equal components convert through a UnitMap, and SpecFluxFrames whose + * SpecFrames do not convert do not convert at all. * - *

    The expected values are C's: testspecflux.c's, and those of a probe built against the pinned - * C library that makes SpecFluxFrames with {@code astSpecFluxFrame( astSpecFrame( ... ), + *

    The other expected values are C's: testspecflux.c's, and those of a probe built against the + * pinned C library that makes SpecFluxFrames with {@code astSpecFluxFrame( astSpecFrame( ... ), * astFluxFrame( specval, NULL, ... ), "" )} and prints {@code astGetC}, {@code astFormat}, {@code * astUnformat}, {@code astDistance}, the class of the simplified Mapping {@code astConvert}, {@code * astFindFrame} or {@code astPickAxes} gives with the values it transforms, and {@code astShow}. - * C's {@code astEqual} is not part of this library: where C or Rust compare SpecFluxFrames, the - * test checks the conversion C's {@code Equal} (frame.c) makes, which must simplify to a UnitMap. + * Where Rust compares SpecFluxFrames for equality the test checks the conversion C's {@code Equal} + * (frame.c) makes, which must simplify to a UnitMap, or calls {@link AstObject#astEqual}. * Rust tests that call {@code match_template} and {@code sub_frame} call the package-private * {@link Frame#match} and {@link Frame#subFrame}; Rust's {@code pick_axes_snapshot} is {@link * Frame#pickAxes} here, whose classes are C's. @@ -83,11 +85,50 @@ private static double[] tran2(Mapping map, double x, double y, boolean forward) return new double[] {out[0][0], out[1][0]}; } - /** Asserts that converting {@code from} to {@code to} throws, naming {@code cls} as needed. */ - private static void assertNeeds(String cls, Frame from, Frame to, String what) { - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> from.convert(to, ""), what); - assertTrue(e.getMessage().endsWith("needs " + cls), what + ": " + e.getMessage()); + private static final Map PROBE = ProbeOutput.load("specflux_probe"); + + /** + * What the probe prints for the conversion from {@code from} to {@code to}, searching {@code + * domains}: the class and dump of the simplified Mapping, then the transformation of the point + * (x, y), or (x) for a one-dimensional {@code from}, forwards by the FrameSet {@code convert} + * gives, and of the result back. + */ + private static String converted(Frame from, Frame to, String domains, double x, double y) { + FrameSet fs = from.convert(to, domains); + if (fs == null) { + return "no conversion\n"; + } + Mapping s = fs.getMapping(FrameSet.AST__BASE, FrameSet.AST__CURRENT).simplify(); + int nin = fs.getNin(); + int nout = fs.getNout(); + double[] in = Arrays.copyOf(new double[] {x, y}, nin); + double[] out = fs.tranN(1, nin, in, true, nout); + double[] back = fs.tranN(1, nout, out, false, nin); + return "class " + s.astClass() + "\n" + ChannelText.dump(s) + "-- transformations\n" + tranLine("fwd", in, out) + + tranLine("inv", out, back); + } + + private static String tranLine(String label, double[] in, double[] out) { + StringBuilder sb = new StringBuilder(label); + for (double v : in) { + sb.append(' ').append(CFormat.format("%.17g", v)); + } + sb.append(" ->"); + for (double v : out) { + sb.append(' ').append(CFormat.format("%.17g", v)); + } + return sb.append('\n').toString(); + } + + /** Asserts that the conversion from {@code from} to {@code to} is the probe's case {@code name}. */ + private static void assertConverts(String name, Frame from, Frame to, double x, double y) { + assertConverts(name, from, to, "", x, y); + } + + private static void assertConverts(String name, Frame from, Frame to, String domains, double x, double y) { + String want = PROBE.get(name); + assertNotNull(want, "no probe case " + name); + assertEquals(want, converted(from, to, domains, x, y), name); } // ------------------------------------------------------------------ @@ -119,11 +160,11 @@ void specValDefaultsToTheFluxFrameValue() { } /** - * testspecflux.c Errors 6B, 6C, 7 and 8 ({@code flux_density_converts_to_per_wavelength}). C - * converts (2, 1) to (2, 1.33425638e-26) within 1e-32 (Errors 9 and 10). + * testspecflux.c Errors 6B to 10 ({@code flux_density_converts_to_per_wavelength}): (2, 1) + * converts to (2, 1.33425638e-26). */ @Test - void fluxDensityToPerWavelengthNeedsRateMap() { + void fluxDensityConvertsToPerWavelength() { SpecFrame sf = ghz(); SpecFluxFrame sff = jansky(sf); FluxFrame ff2 = flux(123.1, sf, "System=flxdnw"); @@ -131,46 +172,44 @@ void fluxDensityToPerWavelengthNeedsRateMap() { assertEquals("FLXDNW", ff2.getC("System"), "Error 6C"); SpecFluxFrame sff2 = new SpecFluxFrame(sf, ff2); assertEquals("SpecFluxFrame", sff2.getC("Class"), "Error 7"); - assertNeeds("RateMap", sff, sff2, "Error 8"); + assertConverts("error8", sff, sff2, 2.0, 1.0); } /** - * testspecflux.c Errors 11 and 14 ({@code conversion_follows_permuted_axes}). C converts with - * the flux on the first result axis (Errors 12, 13), and then from permuted axes too (Errors - * 15, 16). + * testspecflux.c Errors 11 to 16 ({@code conversion_follows_permuted_axes}): the flux is on the + * first result axis, and then on the first axis of both. */ @Test - void permutedAxesNeedRateMap() { + void conversionFollowsPermutedAxes() { SpecFrame sf = ghz(); SpecFluxFrame sff = jansky(sf); SpecFluxFrame sff2 = new SpecFluxFrame(sf, flux(123.1, sf, "System=flxdnw")); sff2.permAxes(new int[] {2, 1}); - assertNeeds("RateMap", sff, sff2, "Error 11"); + assertConverts("error11", sff, sff2, 2.0, 1.0); sff.permAxes(new int[] {2, 1}); - assertNeeds("RateMap", sff, sff2, "Error 14"); + assertConverts("error14", sff, sff2, 1.0, 2.0); } /** - * testspecflux.c Errors 17 and 18 ({@code logarithmic_flux_units_convert}). C converts (2, 1) - * to (2, -24.8747607) and back (Errors 19 to 22). Comparing the FluxFrames converts Jy to - * {@code log(W/m2/nm)}, which needs a MathMap before {@code MakeMapF} is reached. + * testspecflux.c Errors 17 to 22 ({@code logarithmic_flux_units_convert}): (2, 1) converts to + * (2, -24.8747607) and back. */ @Test - void logarithmicFluxUnitsNeedMathMap() { + void logarithmicFluxUnitsConvert() { SpecFrame sf = ghz(); SpecFluxFrame csff = (SpecFluxFrame) jansky(sf).copy(); FluxFrame ff2 = flux(AstObject.AST__BAD, null, "Unit=log(W/m2/nm)"); assertEquals("FLXDNW", ff2.getC("System"), "Error 17"); SpecFluxFrame sff2 = new SpecFluxFrame(sf, ff2); - assertNeeds("MathMap", csff, sff2, "Error 18"); + assertConverts("error18", csff, sff2, 2.0, 1.0); } /** - * testspecflux.c Errors 23 to 25 ({@code surface_brightness_converts}). C converts (2, 1) to - * (2, -21.3585154) and back (Errors 26 to 29). + * testspecflux.c Errors 23 to 29 ({@code surface_brightness_converts}): (2, 1) converts to (2, + * -21.3585154) and back. */ @Test - void surfaceBrightnessNeedsMathMap() { + void surfaceBrightnessConverts() { FluxFrame ff2 = flux(AstObject.AST__BAD, null, "Unit=log(W/m2/nm/sr)"); assertEquals("SFCBRW", ff2.getC("System"), "Error 23"); SpecFluxFrame sff2 = new SpecFluxFrame(ghz(), ff2); @@ -178,14 +217,14 @@ void surfaceBrightnessNeedsMathMap() { FluxFrame ff = flux(123.0, sf, "Unit=Jy/deg**2"); assertEquals("SFCBR", ff.getC("System"), "Error 24"); SpecFluxFrame sff = new SpecFluxFrame(sf, ff); - assertNeeds("MathMap", sff, sff2, "Error 25"); + assertConverts("error25", sff, sff2, 2.0, 1.0); } /** * testspecflux.c Errors 30 to 32 ({@code equal_when_and_only_when_the_components_are}): C's * {@code Equal} converts the second Frame to the first. SpecFluxFrames sharing equal * components, and a copy, convert through a UnitMap ({@code astEqual} 1); with a FLXDNW - * FluxFrame C's conversion is a CmpMap ({@code astEqual} 0), which needs a RateMap here. + * FluxFrame the conversion is a CmpMap ({@code astEqual} 0). */ @Test void equalWhenAndOnlyWhenTheComponentsAre() { @@ -199,7 +238,10 @@ void equalWhenAndOnlyWhenTheComponentsAre() { SpecFluxFrame ed = new SpecFluxFrame(esf, eff2); assertInstanceOf(UnitMap.class, conversion(eb, ea), "Error 30"); assertInstanceOf(UnitMap.class, conversion(ec, ea), "Error 31"); - assertNeeds("RateMap", ed, ea, "Error 32"); + String equal = + (ea.astEqual(eb) ? 1 : 0) + " " + (ea.astEqual(ec) ? 1 : 0) + " " + (ea.astEqual(ed) ? 1 : 0) + "\n"; + assertEquals(PROBE.get("equal"), equal, "Errors 30 to 32"); + assertConverts("error32", ed, ea, 1.4e9, 1.0e-26); } // ------------------------------------------------------------------ @@ -305,12 +347,14 @@ void equalComponentsConvertThroughAUnitMap() { /** * Rust's {@code test_specfluxframe_not_equal_different_spec} and {@code - * test_specfluxframe_convert_different_spec_system_converts}: C converts a frequency to a - * wavelength SpecFluxFrame through a CmpMap, (1.4e9, 1e-26) to (2.1413747000000005, 1e-26). + * test_specfluxframe_convert_different_spec_system_converts}: a frequency SpecFluxFrame + * converts to a wavelength one through a CmpMap, (1.4e9, 1e-26) to (2.1413747000000005, 1e-26). */ @Test - void differentSpectralSystemsNeedRateMap() { - assertNeeds("RateMap", plain(), sff("System=WAVE", AstObject.AST__BAD, "System=FLXDN"), "FREQ to WAVE"); + void differentSpectralSystemsConvert() { + SpecFluxFrame wave = sff("System=WAVE", AstObject.AST__BAD, "System=FLXDN"); + assertFalse(plain().astEqual(wave)); + assertConverts("freq_to_wave", plain(), wave, 1.4e9, 1.0e-26); } /** Rust's {@code test_specfluxframe_convert_same}. */ @@ -389,32 +433,32 @@ void serialisationWithAttributes() { * testspecflux.c Errors 8 to 10, with the SpecVal set rather than defaulted. */ @Test - void jyToFluxDenWNeedsRateMap() { + void jyToFluxDenW() { SpecFrame sf = ghz(); FluxFrame ff = flux(AstObject.AST__BAD, sf, "System=FLXDN,Unit=Jy,SpecVal=123.0"); SpecFluxFrame sff = new SpecFluxFrame(sf, ff); FluxFrame ff2 = flux(AstObject.AST__BAD, sf, "System=FLXDNW,SpecVal=123.1"); SpecFluxFrame sff2 = new SpecFluxFrame(sf, ff2); - assertNeeds("RateMap", sff, sff2, "Jy to FLXDNW"); + assertConverts("jy_to_fluxdenw", sff, sff2, 2.0, 1.0); } /** Rust's {@code test_specflux_log_units}: as testspecflux.c Errors 18 to 20. */ @Test - void logUnitsNeedMathMap() { + void logUnits() { SpecFrame sf = ghz(); SpecFluxFrame sff = new SpecFluxFrame(sf, flux(AstObject.AST__BAD, sf, "System=FLXDN,Unit=Jy,SpecVal=123.0")); SpecFluxFrame sff2 = new SpecFluxFrame(sf, flux(AstObject.AST__BAD, sf, "System=FLXDNW,Unit=log(W/m2/nm)")); - assertNeeds("MathMap", sff, sff2, "Jy to log(W/m2/nm)"); + assertConverts("log_units", sff, sff2, 2.0, 1.0); } /** Rust's {@code test_specflux_surface_brightness}: as testspecflux.c Errors 25 to 27. */ @Test - void surfaceBrightnessLogUnitsNeedMathMap() { + void surfaceBrightnessLogUnits() { SpecFrame sf = ghz(); SpecFluxFrame sff = new SpecFluxFrame(sf, flux(AstObject.AST__BAD, sf, "System=SFCBR,Unit=Jy/deg**2,SpecVal=123.0")); SpecFluxFrame sff2 = new SpecFluxFrame(sf, flux(AstObject.AST__BAD, sf, "System=SFCBRW,Unit=log(W/m2/nm/sr)")); - assertNeeds("MathMap", sff, sff2, "Jy/deg**2 to log(W/m2/nm/sr)"); + assertConverts("surface_brightness", sff, sff2, 2.0, 1.0); } // ------------------------------------------------------------------ @@ -649,7 +693,7 @@ void swappedEqualComponents() { /** * SpecFluxFrames whose SpecFrames have different Domains do not convert: C's {@code MakeMapF} - * finds no conversion between the standardised SpecFrames, so no RateMap is needed. + * finds no conversion between the standardised SpecFrames. */ @Test void spectralDomainsThatDifferDoNotConvert() { @@ -661,32 +705,62 @@ void spectralDomainsThatDifferDoNotConvert() { } /** - * Every other change goes through C's {@code MakeMapF}. C's values: Jy to mJy gives (2, - * 1000.0000000000001), GHz to MHz (1999.9999999999998, 1), and FluxFrames in different - * Domains (1.4e9, 1e-26), each through a CmpMap. + * Every other change goes through C's {@code MakeMapF} and {@code MakeMapI}, at one spectral + * system: Jy to mJy gives (2, 1000.0000000000001), GHz to MHz (1999.9999999999998, 1), and + * FluxFrames in different Domains (1.4e9, 1e-26), each through a CmpMap. */ @Test - void otherChangesNeedRateMap() { + void otherChangesConvert() { SpecFluxFrame s = sff("System=FREQ,Unit=GHz", 1.4e9, "System=FLXDN,Unit=Jy"); - assertNeeds("RateMap", s, sff("System=FREQ,Unit=GHz", 1.4e9, "System=FLXDN,Unit=mJy"), "Jy to mJy"); - assertNeeds("RateMap", s, sff("System=FREQ,Unit=MHz", 1.4e9, "System=FLXDN,Unit=Jy"), "GHz to MHz"); - assertNeeds( - "RateMap", + assertConverts("jy_to_mjy", s, sff("System=FREQ,Unit=GHz", 1.4e9, "System=FLXDN,Unit=mJy"), 2.0, 1.0); + assertConverts("ghz_to_mhz", s, sff("System=FREQ,Unit=MHz", 1.4e9, "System=FLXDN,Unit=Jy"), 2.0, 1.0); + assertConverts( + "flux_domains", sff("System=FREQ", AstObject.AST__BAD, "System=FLXDN,Domain=A"), sff("System=FREQ", AstObject.AST__BAD, "System=FLXDN,Domain=B"), - "flux Domains"); + 1.4e9, + 1.0e-26); } - /** - * Comparing FluxFrames in logarithmic units needs a MathMap. C converts (2, 1) Jy to (2, 0) - * {@code log(Jy)}, and (2, 0) back to (2, 1). - */ + /** Flux values in logarithmic units: (2, 1) Jy converts to (2, 0) {@code log(Jy)}, and back. */ @Test - void logarithmicUnitsNeedMathMap() { + void logarithmicUnitsConvert() { SpecFluxFrame s = sff("System=FREQ,Unit=GHz", 1.4e9, "System=FLXDN,Unit=Jy"); SpecFluxFrame t = sff("System=FREQ,Unit=GHz", 1.4e9, "System=FLXDN,Unit=log(Jy)"); - assertNeeds("MathMap", s, t, "Jy to log(Jy)"); - assertNeeds("MathMap", t, s, "log(Jy) to Jy"); + assertConverts("jy_to_log_jy", s, t, 2.0, 1.0); + assertConverts("log_jy_to_jy", t, s, 2.0, 0.0); + } + + /** A spectrum as SPLAT holds it: a FrameSet of a GRID Frame and a SpecFluxFrame. */ + private static FrameSet spectrum(SpecFluxFrame s) { + Frame grid = new Frame(2); + grid.setDomain("GRID"); + FrameSet fs = new FrameSet(grid); + fs.addFrame(FrameSet.AST__BASE, new UnitMap(2), s); + return fs; + } + + /** + * Spectra whose SpecFluxFrames differ in both components convert in both directions, between + * frequency in GHz with flux density in Jy, wavelength in nm with flux density in mJy, radio + * velocity with flux density in W/m^2/Hz, and wavelength in nm with flux density per unit + * wavelength in W/m^2/nm, searching the SPECTRUM-FLUX Domain (the GRID Frames would otherwise + * match first). + */ + @Test + void spectraConvertBothWays() { + String settings = ",RestFreq=1.4GHz"; + FrameSet a = spectrum(sff("System=FREQ,Unit=GHz" + settings, AstObject.AST__BAD, "System=FLXDN,Unit=Jy")); + FrameSet b = spectrum(sff("System=WAVE,Unit=nm" + settings, AstObject.AST__BAD, "System=FLXDN,Unit=mJy")); + FrameSet c = spectrum(sff("System=VRAD" + settings, AstObject.AST__BAD, "System=FLXDN,Unit=W/m^2/Hz")); + FrameSet d = spectrum(sff("System=WAVE,Unit=nm" + settings, AstObject.AST__BAD, "System=FLXDNW,Unit=W/m^2/nm")); + String domain = "SPECTRUM-FLUX"; + assertConverts("splat_freq_jy_to_wave_mjy", a, b, domain, 1.3, 2.0); + assertConverts("splat_wave_mjy_to_freq_jy", b, a, domain, 2.3e8, 2000.0); + assertConverts("splat_freq_jy_to_vrad", a, c, domain, 1.3, 2.0); + assertConverts("splat_vrad_to_freq_jy", c, a, domain, 1500.0, 2.0e-26); + assertConverts("splat_freq_jy_to_wave_flxdnw", a, d, domain, 1.3, 2.0); + assertConverts("splat_wave_flxdnw_to_freq_jy", d, a, domain, 2.3e8, 1.0e-30); } /** jniast's constructor. */ @@ -758,15 +832,16 @@ void unmatchedCmpFramesDoNotConvert() { /** * A FluxFrame whose System differs from a SpecFluxFrame's: the CmpFrame C's {@code PartMatch} - * gives is cast into a SpecFluxFrame, whose conversion {@code MakeSFMapping} builds with a - * RateMap. C converts both ways; from the SpecFluxFrame, (5000, 2) gives 239833965686.78632. + * gives is cast into a SpecFluxFrame, whose conversion {@code MakeSFMapping} builds. It + * converts both ways; from the SpecFluxFrame, (5000, 2) gives 239833965686.78632, and from the + * FluxFrame, whose spectral position is unknown, bad values. */ @Test - void fluxFrameToSpecFluxFrameNeedsRateMap() { + void fluxFrameAndSpecFluxFrameConvert() { FluxFrame fw = flux(AstObject.AST__BAD, new SpecFrame(), "System=FLXDNW"); SpecFluxFrame s = new SpecFluxFrame(new SpecFrame(), flux(AstObject.AST__BAD, new SpecFrame(), "")); - assertNeeds("RateMap", fw, s, "FluxFrame to SpecFluxFrame"); - assertNeeds("RateMap", s, fw, "SpecFluxFrame to FluxFrame"); + assertConverts("fluxframe_to_specfluxframe", fw, s, 2.0, 0.0); + assertConverts("specfluxframe_to_fluxframe", s, fw, 5000.0, 2.0); } /** diff --git a/src/test/java/uk/ac/starlink/ast/SpecFrameTest.java b/src/test/java/uk/ac/starlink/ast/SpecFrameTest.java index 931c010..0e54f68 100644 --- a/src/test/java/uk/ac/starlink/ast/SpecFrameTest.java +++ b/src/test/java/uk/ac/starlink/ast/SpecFrameTest.java @@ -1305,4 +1305,27 @@ void twoThreadsConvertingCopiesGetIdenticalMappings() throws Exception { assertTrue(pool.awaitTermination(1, TimeUnit.MINUTES), "threads finished"); } } + + // ------------------------------------------------------------------ + // Equality (frame.c Equal: the conversion simplifies to a UnitMap) + // ------------------------------------------------------------------ + + @Test + void testEqualSame() { + assertTrue(frame("FREQ").astEqual(frame("FREQ"))); + } + + @Test + void testNotEqualDifferentSystem() { + assertFalse(frame("FREQ").astEqual(frame("WAVE"))); + } + + @Test + void testNotEqualDifferentSor() { + SpecFrame sf1 = frame("FREQ"); + sf1.setStdOfRest("Heliocentric"); + SpecFrame sf2 = frame("FREQ"); + sf2.setStdOfRest("LSRK"); + assertFalse(sf1.astEqual(sf2)); + } } diff --git a/src/test/java/uk/ac/starlink/ast/SpecMapTest.java b/src/test/java/uk/ac/starlink/ast/SpecMapTest.java index 4286716..937b811 100644 --- a/src/test/java/uk/ac/starlink/ast/SpecMapTest.java +++ b/src/test/java/uk/ac/starlink/ast/SpecMapTest.java @@ -479,4 +479,17 @@ void aLoadNeedsKnownConversions() { () -> ChannelText.read(head + ChannelText.text(" Spec2 = \"XXTOYY\"", " End SpecMap"))); assertEquals(AstException.AST__BADIN, e.getStatus()); } + + /** specmap.c {@code Equal} compares the conversions and their arguments. */ + @Test + void equality() { + SpecMap spec1 = spec("FRTOWV"); + spec1.specAdd("LKF2HL", new double[] {1.0, 0.5}); + SpecMap spec2 = spec("FRTOWV"); + spec2.specAdd("LKF2HL", new double[] {1.0, 0.5}); + assertTrue(spec1.astEqual(spec2)); + SpecMap spec3 = spec("FRTOWV"); + spec3.specAdd("LKF2HL", new double[] {2.0, 0.5}); + assertFalse(spec1.astEqual(spec3)); + } } diff --git a/src/test/java/uk/ac/starlink/ast/SwitchMapTest.java b/src/test/java/uk/ac/starlink/ast/SwitchMapTest.java new file mode 100644 index 0000000..58883f6 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/SwitchMapTest.java @@ -0,0 +1,784 @@ +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.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Map; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.Fixtures; +import uk.ac.starlink.ast.testsupport.ProbeOutput; + +/** + * Translation of Rust {@code tests/test_switchmap.rs} (from {@code testswitchmap.c}), with the + * cases of the C probe {@code probes/switchmap_probe.c}: the route a selector value picks, at the + * halfway points and beyond the range of {@code int}; transformations and rates of the SwitchMaps + * of testswitchmap.c at full precision; native dumps with selectors and routes inverted when the + * SwitchMap is made and afterwards, one Mapping as both selectors, LutMap, MathMap and PcdMap + * components, a SwitchMap inside a CmpMap, a TranMap and a SwitchMap, and a dump without {@code + * ISInv}, each read back; equality; simplification of a SwitchMap alone, inverted, with route and + * selector Mappings that simplify, beside its own inverse and other Mappings; and the + * constructor's errors. + * + *

    The Rust tests whose forward selector is a SelectorMap of Box Regions, classes not yet ported, + * are listed in {@code deferred/rust-tests.txt}. + */ +class SwitchMapTest { + + private static final double BAD = AstObject.AST__BAD; + + private static final Map PROBE_CASES = ProbeOutput.load("switchmap_probe"); + + private static String probe(String name) { + String text = PROBE_CASES.get(name); + if (text == null) { + throw new IllegalStateException("no probe case " + name); + } + return text; + } + + /** The probe case without the lines naming the C source of an error. */ + private static String probeWithoutSource(String name) { + StringBuilder sb = new StringBuilder(); + for (String line : probe(name).split("\n", -1)) { + if (!line.startsWith("!! ") && !line.isEmpty()) { + sb.append(line).append('\n'); + } + } + return sb.toString(); + } + + private static String g(double v) { + return CFormat.format("%.17g", v); + } + + private static T inv(T m) { + m.invert(); + return m; + } + + private static WinMap win(double x1, double x2, double l1, double l2) { + return new WinMap(1, new double[] {x1}, new double[] {x2}, new double[] {l1}, new double[] {l2}); + } + + private static MathMap mathmap(String f, String i) { + return new MathMap(1, 1, new String[] {f}, new String[] {i}); + } + + /** The MathMap of testswitchmap.c section 2, which picks a half by pixel or by wavelength. */ + private static MathMap halves() { + return mathmap("y=qif(x>101.5,2,1)", "x=qif(y>1800,2,1)"); + } + + private static SwitchMap switch2(Mapping fs, Mapping is, Mapping r1, Mapping r2) { + return new SwitchMap(fs, is, new Mapping[] {r1, r2}); + } + + /** The plain 1-D SwitchMap of the probe. */ + private static SwitchMap plain() { + return switch2(halves(), halves(), win(1.0, 101.0, 1000.0, 2000.0), win(102.0, 202.0, 1600.0, 2700.0)); + } + + /** + * testswitchmap.c section 1: two rows of a 2-D grid, each a spectrum; a PermMap forward + * selector reading the row number and a MathMap inverse selector choosing a row by wavelength. + */ + private static SwitchMap section1() { + int[] outperm = {1}; + int[] inperm = {1, -1}; + Mapping r1 = new CmpMap( + new PermMap(2, inperm, 1, outperm, new double[] {1.0}), win(1.0, 101.0, 1000.0, 2000.0), true); + Mapping r2 = new CmpMap( + new PermMap(2, inperm, 1, outperm, new double[] {2.0}), win(1.0, 101.0, 1600.0, 2700.0), true); + PermMap fs = new PermMap(2, new int[] {0, 1}, 1, new int[] {2}, new double[] {0.0}); + return new SwitchMap(fs, mathmap("y", "x=qif(y>1800,2,1)"), new Mapping[] {r1, r2}); + } + + /** testswitchmap.c section 2: two halves of a 1-D grid, with one MathMap as both selectors. */ + private static SwitchMap section2(MathMap sm) { + return switch2(sm, sm, win(1.0, 101.0, 1000.0, 2000.0), win(102.0, 202.0, 1600.0, 2700.0)); + } + + // ------------------------------------------------------------------ + // The probe's formatting + // ------------------------------------------------------------------ + + private static final double[] PTS1 = {1.0, 37.5, 101.0, 140.0, BAD}; + private static final double[] PTS2 = {1.0, 2.0, 2.0, 1.0, 1.0}; + private static final double[] WAVE = {1000.0, 1700.0, 1900.0, 2700.0, BAD}; + + /** + * The forward and inverse transformations of the probe's points: positions with one + * coordinate are given the pixel values forward and the wavelengths inverse, positions with + * two the pixel values and row numbers. + */ + private static String tran(Mapping m) { + StringBuilder sb = new StringBuilder(); + for (boolean dir : new boolean[] {true, false}) { + String label = dir ? "fwd" : "inv"; + if (!(dir ? m.getTranForward() : m.getTranInverse())) { + sb.append(label).append(" undefined\n"); + continue; + } + int nin = dir ? m.getNin() : m.getNout(); + int nout = dir ? m.getNout() : m.getNin(); + int npt = PTS1.length; + double[][] in = new double[nin][npt]; + for (int i = 0; i < npt; i++) { + if (nin == 1) { + in[0][i] = dir ? PTS1[i] : WAVE[i]; + } else { + in[0][i] = PTS1[i]; + in[1][i] = PTS2[i]; + } + } + double[][] out = m.tranP(npt, nin, in, dir, nout); + for (int i = 0; i < npt; i++) { + sb.append(label); + for (int k = 0; k < nin; k++) { + sb.append(' ').append(g(in[k][i])); + } + sb.append(" ->"); + for (int k = 0; k < nout; k++) { + sb.append(' ').append(g(out[k][i])); + } + sb.append('\n'); + } + } + return sb.toString(); + } + + private static String rate(String label, Mapping m, double[] at, int ax1, int ax2) { + return label + ": " + g(m.rate(at, ax1, ax2)) + "\n"; + } + + private static String report(AstException e) { + StringBuilder sb = new StringBuilder(); + for (String line : ProbeOutput.trimLines(e.getMsgText()).split("\n", -1)) { + sb.append("! ").append(line).append('\n'); + } + return sb.toString(); + } + + private static String invertState(Mapping m) { + return "Invert shared after " + (m.getInvert() ? 1 : 0) + " test " + (m.testInvert() ? 1 : 0) + "\n"; + } + + // ------------------------------------------------------------------ + // test_switchmap.rs: construction + // ------------------------------------------------------------------ + + @Test + void switchmapNoRoutesRejected() { + AstException e = assertThrows(AstException.class, () -> new SwitchMap(new UnitMap(1), null, new Mapping[0])); + assertEquals(AstException.AST__BDPAR, e.getStatus()); + } + + @Test + void switchmapNoSelectorsRejected() { + AstException e = + assertThrows(AstException.class, () -> new SwitchMap(null, null, new Mapping[] {new UnitMap(2)})); + assertEquals(AstException.AST__INTRD, e.getStatus()); + } + + @Test + void switchmapMismatchedRoutesRejected() { + AstException e = assertThrows( + AstException.class, + () -> new SwitchMap(new ZoomMap(2, 1.0), null, new Mapping[] {new UnitMap(2), new UnitMap(3)})); + assertEquals(AstException.AST__BADNI, e.getStatus()); + } + + /** The constructor's errors give C's statuses and messages, in C's order of checks. */ + @Test + void constructorErrorsMatchC() { + Mapping[] zoom = {new ZoomMap(1, 2.0)}; + assertError("error_no_routes", () -> new SwitchMap(halves(), halves(), new Mapping[0])); + assertError( + "error_route_nin", + () -> new SwitchMap(halves(), null, new Mapping[] {new ZoomMap(1, 2.0), new ZoomMap(2, 2.0)})); + PermMap oneToTwo = new PermMap(1, new int[] {1}, 2, new int[] {1, 1}, null); + assertError( + "error_route_nout", () -> new SwitchMap(halves(), null, new Mapping[] {new ZoomMap(1, 2.0), oneToTwo})); + assertError("error_fsmap_no_forward", () -> new SwitchMap(inv(fwdOnlyPolymap()), null, zoom)); + assertError("error_ismap_no_inverse", () -> new SwitchMap(null, fwdOnlyPolymap(), zoom)); + assertError("error_fsmap_nin", () -> new SwitchMap(new ZoomMap(2, 1.0), null, zoom)); + PermMap fsOneToTwo = new PermMap(1, new int[] {1}, 2, new int[] {1, 1}, null); + assertError("error_fsmap_nout", () -> new SwitchMap(fsOneToTwo, null, zoom)); + assertError("error_ismap_nout", () -> new SwitchMap(null, new ZoomMap(2, 1.0), zoom)); + PermMap twoToOne = new PermMap(2, new int[] {1, 1}, 1, new int[] {1}, null); + assertError("error_ismap_nin", () -> new SwitchMap(null, twoToOne, zoom)); + assertError("error_no_selectors", () -> new SwitchMap(null, null, zoom)); + } + + private static void assertError(String name, org.junit.jupiter.api.function.Executable make) { + AstException e = assertThrows(AstException.class, make, name); + assertEquals(probeWithoutSource(name), report(e) + "status " + e.getStatus() + "\n", name); + } + + private static PolyMap fwdOnlyPolymap() { + PolyMap pm = new PolyMap(1, 1, 1, new double[] {1.0, 1.0, 1.0}, 0, null); + pm.setIterInverse(false); + return pm; + } + + /** jniast's arguments: a null array is refused, null selectors are not. */ + @Test + void jniastArguments() { + assertThrows(NullPointerException.class, () -> new SwitchMap(halves(), null, null)); + AstException e = assertThrows( + AstException.class, () -> new SwitchMap(halves(), null, new Mapping[] {new ZoomMap(1, 2.0), null})); + assertEquals(AstException.AST__OBJIN, e.getStatus()); + SwitchMap fwdOnly = new SwitchMap(halves(), null, new Mapping[] {new ZoomMap(1, 2.0)}); + assertTrue(fwdOnly.getTranForward()); + assertFalse(fwdOnly.getTranInverse()); + SwitchMap invOnly = new SwitchMap(null, halves(), new Mapping[] {new ZoomMap(1, 2.0)}); + assertFalse(invOnly.getTranForward()); + assertTrue(invOnly.getTranInverse()); + } + + /** The route Mappings are shared, so C's immutable attributes cannot be changed. */ + @Test + void routeMappingsAreShared() { + ZoomMap z = new ZoomMap(1, 2.0); + new SwitchMap(halves(), null, new Mapping[] {z}); + AstException e = assertThrows(AstException.class, () -> z.setZoom(3.0)); + assertEquals(AstException.AST__IMMUT, e.getStatus()); + } + + // ------------------------------------------------------------------ + // test_switchmap.rs: the selector value + // ------------------------------------------------------------------ + + /** + * Rust's {@code a_selector_value_beyond_any_integer_selects_no_route}: C takes {@code + * round(sel) - 1} as the route index and ignores one out of range. + */ + @Test + void aSelectorValueBeyondAnyIntegerSelectsNoRoute() { + SwitchMap m = new SwitchMap(new UnitMap(1), null, new Mapping[] {new ZoomMap(1, 2.0), new ZoomMap(1, 3.0)}); + double[] inp = {-1.0e30, 0.49, 0.5, 2.25, 2.5, 1.0e30, -Double.MAX_VALUE}; + double[] want = {BAD, BAD, 1.0, 6.75, BAD, BAD, BAD}; + assertArrayEquals(want, m.tran1(inp.length, inp, true)); + assertEquals(BAD, m.rate(new double[] {-1.0e30}, 1, 1)); + assertEquals(BAD, m.rate(new double[] {1.0e30}, 1, 1)); + } + + /** + * The route each selector value picks, in both directions and in the rate, as C picks it, + * including values beyond the range of {@code int}, which C converts without a range check + * and which pick no route, as C's documented contract says of an index below 1 or above the + * number of routes, and the halfway points, which C's {@code round} takes away from zero. + */ + @Test + void selectorValuesPickTheRoutesCPicks() { + SwitchMap sw = + new SwitchMap(new UnitMap(1), new UnitMap(1), new Mapping[] {new ZoomMap(1, 2.0), new ZoomMap(1, 3.0)}); + double[] v = { + -1.0e30, + -2147483649.0, + -0.5, + 0.0, + 0.49, + 0.49999999999999994, + 0.5, + 1.4999999999999998, + 1.5, + 2.25, + 2.4999999999999996, + 2.5, + 3.0, + 2147483647.0, + 2147483648.5, + 4294967297.0, + 4294967298.0, + 1.0e30, + -Double.MAX_VALUE, + Double.MAX_VALUE, + BAD + }; + double[] f = sw.tran1(v.length, v, true); + double[] i = sw.tran1(v.length, v, false); + StringBuilder sb = new StringBuilder(); + for (int k = 0; k < v.length; k++) { + double r = sw.rate(new double[] {v[k]}, 1, 1); + sb.append(g(v[k])) + .append(" fwd ") + .append(g(f[k])) + .append(" inv ") + .append(g(i[k])) + .append(" rate ") + .append(g(r)) + .append('\n'); + } + assertEquals(probe("selector_values"), sb.toString()); + } + + /** A selector value that is not finite picks no route. */ + @Test + void aSelectorValueThatIsNotFinitePicksNoRoute() { + PermMap sel = new PermMap(1, new int[] {1}, 1, new int[] {1}, null); + SwitchMap sw = new SwitchMap(sel, null, new Mapping[] {new ZoomMap(1, 2.0)}); + double[] in = {Double.NaN, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 1.0}; + assertArrayEquals(new double[] {BAD, BAD, BAD, 2.0}, sw.tran1(in.length, in, true)); + } + + // ------------------------------------------------------------------ + // testswitchmap.c, through test_switchmap.rs + // ------------------------------------------------------------------ + + private static double[][] tranRows(Mapping m, double[][] rows, boolean forward) { + int nin = rows[0].length; + double[][] in = new double[nin][rows.length]; + for (int i = 0; i < rows.length; i++) { + for (int k = 0; k < nin; k++) { + in[k][i] = rows[i][k]; + } + } + int nout = forward ? m.getNout() : m.getNin(); + double[][] out = m.tranP(rows.length, nin, in, forward, nout); + double[][] res = new double[rows.length][nout]; + for (int i = 0; i < rows.length; i++) { + for (int k = 0; k < nout; k++) { + res[i][k] = out[k][i]; + } + } + return res; + } + + private static void assertClose(double got, double want, double tol, int err) { + assertNotEquals(BAD, got, "Error " + err + ": BAD"); + assertTrue(Math.abs(got - want) <= tol, "Error " + err + ": " + got + ", want " + want); + } + + /** + * The checks C makes of every section after its transforms: simplifying the SwitchMap + * changes nothing, an inverted one simplifies to a non-inverted one, it cancels against its + * inverse on either side, and it survives a dump. + */ + private static void assertSimplificationAndDump(SwitchMap swm, int[] errs, String label) { + Mapping s = swm.simplify(); + assertSame(swm, s, label); + assertEquals(ChannelText.dump(swm), ChannelText.dump(s), label); + + SwitchMap invm = (SwitchMap) swm.copy(); + invm.invert(); + assertFalse(invm.simplify().getInvert(), "Error " + errs[0]); + + SwitchMap swm2 = (SwitchMap) invm.copy(); + swm2.invert(); + assertInstanceOf(UnitMap.class, new CmpMap(invm, swm2, true).simplify(), "Error " + errs[1]); + assertInstanceOf(UnitMap.class, new CmpMap(swm2, invm, true).simplify(), "Error " + errs[2]); + + String plain = ChannelText.dump(invm); + AstObject back = ChannelText.read(plain); + assertEquals("SwitchMap", back.astClass(), label); + assertEquals(plain, ChannelText.dump(back), label + ": dump round trip"); + } + + /** testswitchmap.c section 1. */ + @Test + void section1TwoRows() { + SwitchMap swm = section1(); + swm.invert(); + double[][] input = {{1.0, 1.0}, {101.0, 2.0}, {1.0, 2.0}, {101.0, 1.0}}; + double[][] out = tranRows(swm, input, false); + double[] wantOut = {1000.0, 2700.0, 1600.0, 2000.0}; + for (int i = 0; i < 4; i++) { + assertClose(out[i][0], wantOut[i], 1.0e-5, 5 + i); + } + double[][] back = tranRows(swm, out, true); + double[][] want = {{1.0, 1.0}, {101.0, 2.0}, {61.0, 1.0}, {37.3636364, 2.0}}; + for (int i = 0; i < 4; i++) { + assertClose(back[i][0], want[i][0], 1.0e-5, 17 + 2 * i); + assertClose(back[i][1], want[i][1], 1.0e-5, 18 + 2 * i); + } + + swm.invert(); + assertSimplificationAndDump(swm, new int[] {25, 26, 27}, "ast_equal 1"); + + assertClose(swm.rate(new double[] {20.0, 1.0}, 1, 1), 10.0, 1.0e-6, 28); + assertClose(swm.rate(new double[] {20.0, 2.0}, 1, 1), 11.0, 1.0e-6, 29); + swm.invert(); + assertClose(swm.rate(new double[] {1700.0}, 1, 1), 0.1, 1.0e-6, 30); + assertClose(swm.rate(new double[] {1900.0}, 1, 1), 1.0 / 11.0, 1.0e-6, 31); + } + + /** testswitchmap.c section 2; inverting the shared selector afterwards changes nothing. */ + @Test + void section2TwoHalves() { + MathMap sm = mathmap("y=qif(x>101.5,2,1)", "x=qif(y>1800,2,1)"); + SwitchMap swm = section2(sm); + swm.invert(); + sm.invert(); + double[][] input = {{1.0}, {202.0}, {102.0}, {101.0}}; + double[][] out = tranRows(swm, input, false); + double[] wantOut = {1000.0, 2700.0, 1600.0, 2000.0}; + for (int i = 0; i < 4; i++) { + assertClose(out[i][0], wantOut[i], 1.0e-5, 105 + i); + } + double[][] back = tranRows(swm, out, true); + double[] want = {1.0, 202.0, 61.0, 138.3636364}; + for (int i = 0; i < 4; i++) { + assertClose(back[i][0], want[i], 1.0e-5, 117 + 2 * i); + } + + swm.invert(); + assertSimplificationAndDump(swm, new int[] {125, 126, 127}, "ast_equal 2"); + + assertClose(swm.rate(new double[] {20.0}, 1, 1), 10.0, 1.0e-6, 128); + assertClose(swm.rate(new double[] {120.0}, 1, 1), 11.0, 1.0e-6, 129); + swm.invert(); + assertClose(swm.rate(new double[] {1700.0}, 1, 1), 0.1, 1.0e-6, 130); + assertClose(swm.rate(new double[] {1900.0}, 1, 1), 1.0 / 11.0, 1.0e-6, 131); + } + + /** The SwitchMaps of testswitchmap.c, at full precision, against the probe. */ + @Test + void sectionsMatchCExactly() { + SwitchMap s1 = section1(); + StringBuilder sb = new StringBuilder(tran(s1)); + s1.invert(); + sb.append("-- inverted\n").append(tran(s1)); + s1.invert(); + sb.append(rate("rate 20 1", s1, new double[] {20.0, 1.0}, 1, 1)) + .append(rate("rate 20 2", s1, new double[] {20.0, 2.0}, 1, 1)) + .append(rate("rate 20 2 axis 2", s1, new double[] {20.0, 2.0}, 1, 2)); + s1.invert(); + sb.append(rate("rate inverted 1700", s1, new double[] {1700.0}, 1, 1)); + AstException e = assertThrows(AstException.class, () -> s1.rate(new double[] {1900.0}, 1, 2)); + sb.append(report(e)) + .append("rate inverted 1900: ") + .append(g(BAD)) + .append("\nstatus ") + .append(e.getStatus()) + .append('\n'); + assertEquals(probeWithoutSource("section1"), sb.toString()); + + MathMap sm = halves(); + SwitchMap s2 = section2(sm); + sm.invert(); + sb = new StringBuilder(tran(s2)); + s2.invert(); + sb.append("-- inverted\n").append(tran(s2)); + s2.invert(); + sb.append(rate("rate 20", s2, new double[] {20.0}, 1, 1)) + .append(rate("rate 120", s2, new double[] {120.0}, 1, 1)) + .append(rate("rate 300", s2, new double[] {300.0}, 1, 1)); + s2.invert(); + sb.append(rate("rate inverted 1700", s2, new double[] {1700.0}, 1, 1)) + .append(rate("rate inverted 1900", s2, new double[] {1900.0}, 1, 1)); + assertEquals(probe("section2"), sb.toString()); + } + + /** A SwitchMap with no inverse selector, and its rate when inverted, which is bad. */ + @Test + void aForwardOnlySwitchMapMatchesC() { + SwitchMap sw = switch2(halves(), null, win(1.0, 101.0, 1000.0, 2000.0), win(102.0, 202.0, 1600.0, 2700.0)); + StringBuilder sb = new StringBuilder(); + sb.append("TranForward ") + .append(sw.getTranForward() ? 1 : 0) + .append(" TranInverse ") + .append(sw.getTranInverse() ? 1 : 0) + .append('\n') + .append(tran(sw)) + .append(rate("rate 20", sw, new double[] {20.0}, 1, 1)); + sw.invert(); + sb.append("inverted TranForward ") + .append(sw.getTranForward() ? 1 : 0) + .append(" TranInverse ") + .append(sw.getTranInverse() ? 1 : 0) + .append('\n') + .append(rate("rate inverted 1700", sw, new double[] {1700.0}, 1, 1)); + assertEquals(probe("forward_only"), sb.toString()); + } + + /** Routes inverted when the SwitchMap is made are applied inverted, rates included. */ + @Test + void invertedRoutesMatchC() { + SwitchMap sw = switch2( + halves(), halves(), inv(win(1000.0, 2000.0, 1.0, 101.0)), inv(win(1600.0, 2700.0, 102.0, 202.0))); + StringBuilder sb = new StringBuilder(tran(sw)); + sb.append(rate("rate 20", sw, new double[] {20.0}, 1, 1)); + sw.invert(); + sb.append(rate("rate inverted 1900", sw, new double[] {1900.0}, 1, 1)); + assertEquals(probe("inverted_routes"), sb.toString()); + } + + /** Inverting the Mappings after the SwitchMap is made does not change it. */ + @Test + void componentsInvertedAfterwardsChangeNothing() { + MathMap fs = halves(); + MathMap is = halves(); + WinMap r1 = win(1.0, 101.0, 1000.0, 2000.0); + WinMap r2 = win(102.0, 202.0, 1600.0, 2700.0); + SwitchMap sw = switch2(fs, is, r1, r2); + fs.invert(); + is.invert(); + r1.invert(); + String got = tran(sw) + "Invert fs " + (fs.getInvert() ? 1 : 0) + " is " + (is.getInvert() ? 1 : 0) + " r1 " + + (r1.getInvert() ? 1 : 0) + " r2 " + (r2.getInvert() ? 1 : 0) + "\n"; + assertEquals(probe("components_inverted_after"), got); + } + + // ------------------------------------------------------------------ + // Native dumps + // ------------------------------------------------------------------ + + private static void assertRoundTrips(String name, Mapping m) { + String dump = ChannelText.dump(m); + Mapping back = (Mapping) ChannelText.read(dump); + String got = dump + "-- read back\n" + ChannelText.dump(back) + "-- equal " + (m.astEqual(back) ? 1 : 0) + + "\n-- transformations\n" + tran(m) + "-- transformations read back\n" + tran(back); + assertEquals(probe(name), got, name); + } + + /** Native dumps, read back, give C's cards and C's transformations. */ + @Test + void nativeDumpsMatchC() { + assertRoundTrips("dump_section1", section1()); + MathMap sm = halves(); + SwitchMap s2 = section2(sm); + sm.invert(); + assertRoundTrips("dump_section2", s2); + assertRoundTrips("dump_inverted", inv(plain())); + assertRoundTrips( + "dump_forward_only", + switch2(halves(), null, win(1.0, 101.0, 1000.0, 2000.0), win(102.0, 202.0, 1600.0, 2700.0))); + assertRoundTrips( + "dump_inverse_only", + switch2(null, halves(), win(1.0, 101.0, 1000.0, 2000.0), win(102.0, 202.0, 1600.0, 2700.0))); + assertRoundTrips( + "dump_inverted_at_construction", + switch2( + inv(halves()), + inv(halves()), + inv(win(1000.0, 2000.0, 1.0, 101.0)), + win(102.0, 202.0, 1600.0, 2700.0))); + MathMap fs = halves(); + WinMap r2 = win(102.0, 202.0, 1600.0, 2700.0); + SwitchMap after = switch2(fs, halves(), win(1.0, 101.0, 1000.0, 2000.0), r2); + fs.invert(); + r2.invert(); + assertRoundTrips("dump_inverted_after", after); + } + + /** Mappings of this phase inside a SwitchMap, and a SwitchMap inside other Mappings. */ + @Test + void nestedNativeDumpsMatchC() { + LutMap lut = new LutMap(new double[] {1000.0, 1100.0, 1300.0, 1600.0, 2000.0}, 1.0, 25.0); + MathMap mm = mathmap("y = x * 10 + 990", "x = ( y - 990 ) / 10"); + assertRoundTrips("dump_lutmap_mathmap", switch2(halves(), halves(), lut, mm)); + PermMap fs = new PermMap(2, new int[] {0, 1}, 1, new int[] {2}, new double[] {0.0}); + PcdMap pcd = new PcdMap(1.0e-3, new double[] {1.0, 1.5}); + assertRoundTrips("dump_pcdmap", switch2(fs, null, pcd, new ZoomMap(2, 2.0))); + assertRoundTrips("dump_in_cmpmap", new CmpMap(new ZoomMap(1, 2.0), plain(), true)); + assertRoundTrips("dump_in_tranmap", new TranMap(plain(), inv(plain()))); + assertRoundTrips("dump_in_switchmap", new SwitchMap(new UnitMap(1), null, new Mapping[] {plain()})); + } + + /** + * A SwitchMap whose forward selector was inverted when it was made and whose inverse selector + * was not does not survive a native round trip, as in C: the dump writes {@code ISInv} only + * when it is set, and the loader takes an absent {@code ISInv} to be {@code FSInv}, so the + * SwitchMap read back applies its inverse selector inverted and its inverse transformation + * changes. + */ + @Test + void aRoundTripInvertsAnInverseSelectorAsC() { + SwitchMap sw = + switch2(inv(halves()), halves(), win(1.0, 101.0, 1000.0, 2000.0), win(102.0, 202.0, 1600.0, 2700.0)); + String dump = ChannelText.dump(sw); + assertFalse(dump.contains("ISInv")); + assertRoundTrips("dump_fsinv_set_isinv_unset", sw); + Mapping back = (Mapping) ChannelText.read(dump); + assertFalse(sw.astEqual(back)); + double[] wave = {1000.0, 1700.0}; + assertArrayEquals(new double[] {1.0, 71.0}, sw.tran1(2, wave, false)); + assertArrayEquals(new double[] {47.45454545454545, 111.09090909090911}, back.tran1(2, wave, false)); + } + + /** + * A copy holds copies of the Mappings, as C's {@code Copy} makes them, so inverting the + * original's Mappings changes the original's dump and not the copy's. + */ + @Test + void aCopyHoldsCopies() { + MathMap fs = halves(); + WinMap r1 = win(1.0, 101.0, 1000.0, 2000.0); + SwitchMap sw = switch2(fs, fs, r1, win(102.0, 202.0, 1600.0, 2700.0)); + String before = ChannelText.dump(sw); + SwitchMap copy = (SwitchMap) sw.copy(); + fs.invert(); + r1.invert(); + assertNotEquals(before, ChannelText.dump(sw)); + assertEquals(before, ChannelText.dump(copy)); + assertEquals(tran(sw), tran(copy)); + } + + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + private static String eq(String label, Mapping a, AstObject b) { + return label + " " + (a.astEqual(b) ? 1 : 0) + "\n"; + } + + /** Every comparison of the probe's {@code equal} case gives C's {@code astEqual}. */ + @Test + void equalityMatchesC() { + SwitchMap a = plain(); + SwitchMap c = switch2(halves(), halves(), win(1.0, 101.0, 1000.0, 2000.0), win(102.0, 202.0, 1600.0, 2800.0)); + SwitchMap d = switch2(halves(), null, win(1.0, 101.0, 1000.0, 2000.0), win(102.0, 202.0, 1600.0, 2700.0)); + SwitchMap e = switch2(halves(), null, win(1.0, 101.0, 1000.0, 2000.0), win(102.0, 202.0, 1600.0, 2700.0)); + SwitchMap f = new SwitchMap(halves(), halves(), new Mapping[] { + win(1.0, 101.0, 1000.0, 2000.0), win(102.0, 202.0, 1600.0, 2700.0), win(102.0, 202.0, 1600.0, 2700.0) + }); + SwitchMap ainv = (SwitchMap) a.copy(); + ainv.invert(); + String before = eq("same_contents", a, plain()) + + eq("different_route", a, c) + + eq("missing_inverse_selector", a, d) + + eq("missing_inverse_selector_reversed", d, a) + + eq("both_forward_only", d, e) + + eq("three_routes", a, f) + + eq("inverted_vs_plain", ainv, a); + Mapping n = ainv.simplify(); + SwitchMap gm = + switch2(halves(), halves(), inv(win(1000.0, 2000.0, 1.0, 101.0)), win(102.0, 202.0, 1600.0, 2700.0)); + MathMap fs = halves(); + SwitchMap h = switch2(fs, halves(), win(1.0, 101.0, 1000.0, 2000.0), win(102.0, 202.0, 1600.0, 2700.0)); + fs.invert(); + String after = eq("inverted_vs_normalised", ainv, n) + + eq("normalised_vs_inverted", n, ainv) + + eq("route_inverted_equivalent", a, gm) + + eq("selector_inverted_after", a, h) + + "Invert fs after " + (fs.getInvert() ? 1 : 0) + "\n"; + MathMap sm = halves(); + SwitchMap s2a = section2(sm); + SwitchMap s2b = section2(halves()); + sm.invert(); + String got = before + + after + + eq("shared_selectors", s2a, s2b) + + invertState(sm) + + eq("not_a_switchmap", a, new ZoomMap(1, 2.0)); + assertEquals(probe("equal"), got); + } + + // ------------------------------------------------------------------ + // Simplification + // ------------------------------------------------------------------ + + private static String simp(Mapping m) { + Mapping s = m.simplify(); + return "class " + s.astClass() + "\n" + ChannelText.dump(s) + "-- transformations\n" + tran(m) + + "-- transformations simplified\n" + tran(s); + } + + private static void assertSimplifies(String name, Mapping m) { + assertEquals(probe(name), simp(m), name); + } + + /** A SwitchMap alone: unchanged, inverted, and with route and selector Mappings that simplify. */ + @Test + void aSwitchMapAloneSimplifiesAsC() { + assertSimplifies("simp_plain", plain()); + assertSimplifies("simp_inverted", inv(plain())); + assertSimplifies( + "simp_routes_simplify", + switch2( + halves(), + halves(), + new CmpMap(new ZoomMap(1, 2.0), new ZoomMap(1, 5.0), true), + new CmpMap(win(102.0, 202.0, 1600.0, 2700.0), new UnitMap(1), true))); + assertSimplifies( + "simp_inverted_route_simplifies", + switch2(halves(), halves(), inv(new ZoomMap(1, 0.1)), win(102.0, 202.0, 1600.0, 2700.0))); + assertSimplifies( + "simp_selector_simplifies", + switch2( + new CmpMap(new ZoomMap(1, 2.0), new ZoomMap(1, 0.5), true), + null, + win(0.0, 1.0, 0.0, 10.0), + win(0.0, 1.0, 0.0, 20.0))); + assertSimplifies( + "simp_inverted_routes_simplify", + inv(switch2( + halves(), + halves(), + new CmpMap(new ZoomMap(1, 2.0), new ZoomMap(1, 5.0), true), + win(102.0, 202.0, 1600.0, 2700.0)))); + assertSimplifies("simp_section1_inverted", inv(section1())); + } + + /** A SwitchMap beside its own inverse, an equal SwitchMap, an unequal one and a ZoomMap. */ + @Test + void aSwitchMapBesideOtherMappingsSimplifiesAsC() { + SwitchMap sw = plain(); + SwitchMap swi = (SwitchMap) sw.copy(); + swi.invert(); + assertSimplifies("simp_beside_inverse", new CmpMap(sw, swi, true)); + assertSimplifies("simp_inverse_beside", new CmpMap(swi, sw, true)); + assertSimplifies("simp_beside_inverse_parallel", new CmpMap(sw, swi, false)); + assertSimplifies("simp_beside_inverse_inverted_cmpmap", inv(new CmpMap(sw, swi, true))); + assertSimplifies( + "simp_beside_inverse_between", + new CmpMap( + new CmpMap(new ZoomMap(1, 2.0), sw, true), new CmpMap(swi, new ZoomMap(1, 0.5), true), true)); + assertSimplifies("simp_beside_equal", new CmpMap(sw, plain(), true)); + SwitchMap swc = switch2(halves(), halves(), win(1.0, 101.0, 1000.0, 2000.0), win(102.0, 202.0, 1600.0, 2800.0)); + swc.invert(); + assertSimplifies("simp_beside_unequal_inverse", new CmpMap(sw, swc, true)); + assertSimplifies("simp_beside_zoommap", new CmpMap(new ZoomMap(1, 2.0), sw, true)); + SwitchMap s1 = section1(); + SwitchMap s1i = (SwitchMap) s1.copy(); + s1i.invert(); + assertSimplifies("simp_section1_beside_inverse", new CmpMap(s1, s1i, true)); + assertSimplifies("simp_section1_inverse_beside", new CmpMap(s1i, s1, true)); + } + + /** + * C sets the Invert attribute of each Mapping it holds while it simplifies, and sets them back + * in the same order, so a Mapping held twice is left with the value recorded for its first + * place rather than its own. + */ + @Test + void aMappingHeldTwiceIsLeftAsC() { + MathMap sm = halves(); + SwitchMap sw = section2(sm); + sm.invert(); + assertEquals(probe("simp_section2_shared_selector"), simp(sw) + "-- " + invertState(sm)); + MathMap sm2 = halves(); + SwitchMap swb = section2(sm2); + sm2.invert(); + assertEquals(probe("simp_section2_shared_selector_inverted"), simp(inv(swb)) + "-- " + invertState(sm2)); + WinMap r = win(1.0, 101.0, 1000.0, 2000.0); + SwitchMap shared = switch2(halves(), halves(), r, r); + r.invert(); + assertEquals(probe("simp_shared_route"), simp(shared) + "-- " + invertState(r)); + } + + /** The C fixtures test_switchmap.rs reads. */ + @Test + void switchmapSimplifyFixtures() { + Mapping cancel = (Mapping) ChannelText.read(Fixtures.read("simplify/switchmap_inverse_cancel.map")); + Mapping s = cancel.simplify(); + assertInstanceOf(UnitMap.class, s); + assertEquals(1, s.getNin()); + assertEquals(1, s.getNout()); + for (String name : new String[] {"switchmap_internal_simplify", "switchmap_invert_normalize"}) { + Mapping original = (Mapping) ChannelText.read(Fixtures.read("simplify/" + name + ".map")); + int nin = original.getNin(); + int nout = original.getNout(); + Mapping simplified = original.simplify(); + assertEquals(nin, simplified.getNin(), name); + assertEquals(nout, simplified.getNout(), name); + } + } +} diff --git a/src/test/java/uk/ac/starlink/ast/TimeFrameTest.java b/src/test/java/uk/ac/starlink/ast/TimeFrameTest.java index a1674dc..dec4e45 100644 --- a/src/test/java/uk/ac/starlink/ast/TimeFrameTest.java +++ b/src/test/java/uk/ac/starlink/ast/TimeFrameTest.java @@ -678,4 +678,14 @@ void testSetSystemReexpressesTimeOrigin() { tf.setSystem("MJD"); assertClose(53370.75, tf.getTimeOriginValue(), 1.0e-6, "TimeOrigin in MJD"); } + + /** frame.c {@code Equal}: the conversion simplifies to a UnitMap. */ + @Test + void testEqual() { + TimeFrame tf1 = frame("MJD"); + TimeFrame tf2 = frame("MJD"); + TimeFrame tf3 = frame("JD"); + assertTrue(tf1.astEqual(tf2)); + assertFalse(tf1.astEqual(tf3)); + } } diff --git a/src/test/java/uk/ac/starlink/ast/TimeMapTest.java b/src/test/java/uk/ac/starlink/ast/TimeMapTest.java index 42e0d25..410e8db 100644 --- a/src/test/java/uk/ac/starlink/ast/TimeMapTest.java +++ b/src/test/java/uk/ac/starlink/ast/TimeMapTest.java @@ -2,6 +2,7 @@ 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; @@ -396,4 +397,17 @@ void aTdbTcbPairMadeAdjacentByEarlierRemovalsCancels() { tm.timeAdd("TCBTOTDB", new double[] {2000.0}); assertInstanceOf(UnitMap.class, tm.simplify()); } + + /** timemap.c {@code Equal} compares the conversions and their arguments. */ + @Test + void equality() { + TimeMap tm1 = time("MJDTOJD", 0.0, 0.0); + tm1.timeAdd("UTCTOTAI", new double[] {0.0, 32.0}); + TimeMap tm2 = time("MJDTOJD", 0.0, 0.0); + tm2.timeAdd("UTCTOTAI", new double[] {0.0, 32.0}); + assertTrue(tm1.astEqual(tm2)); + TimeMap tm3 = time("MJDTOJD", 0.0, 0.0); + tm3.timeAdd("UTCTOTAI", new double[] {0.0, 33.0}); + assertFalse(tm1.astEqual(tm3)); + } } diff --git a/src/test/java/uk/ac/starlink/ast/Tran1Tran2Test.java b/src/test/java/uk/ac/starlink/ast/Tran1Tran2Test.java index c852a09..ad3f6b7 100644 --- a/src/test/java/uk/ac/starlink/ast/Tran1Tran2Test.java +++ b/src/test/java/uk/ac/starlink/ast/Tran1Tran2Test.java @@ -12,8 +12,7 @@ * Translation of Rust {@code tests/test_tran1_tran2.rs}: {@code tran1} and {@code tran2}, with the * checks of C's {@code ValidateMapping} (mapping.c) they make. * - *

    {@code tran_rejects_an_undefined_direction} uses a RateMap, which is outside the first phase; here a - * Mapping whose inverse is undefined, as a RateMap's is, stands in for it. The Java methods take + *

    The Java methods take * the number of points as jniast's do, so the arrays may be longer than it; one shorter than it is * C's {@code AST__DIMIN} (mapping.c {@code TranN}), where the Rust test of arrays of different * lengths expects its own {@code AST__NPTIN}. @@ -132,9 +131,9 @@ void tran2RejectsAMappingOfTheWrongArity() { @Test void tranRejectsAnUndefinedDirection() { - Mapping rate = new NoInverseMap(); + Mapping rate = new RateMap(new ZoomMap(1, 2.0), 1, 1); assertTrue(rate.getTranForward()); - assertFalse(rate.getTranInverse(), "the stand-in has no inverse transform"); + assertFalse(rate.getTranInverse(), "a RateMap has no inverse transform"); AstException e = assertThrows(AstException.class, () -> rate.tran1(1, new double[] {1.0}, false)); assertEquals(AstException.AST__TRNND, e.getStatus()); diff --git a/src/test/java/uk/ac/starlink/ast/TranDefinednessOracleTest.java b/src/test/java/uk/ac/starlink/ast/TranDefinednessOracleTest.java index 5a0c0b6..2f24e6f 100644 --- a/src/test/java/uk/ac/starlink/ast/TranDefinednessOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/TranDefinednessOracleTest.java @@ -16,11 +16,11 @@ * oracle/tran_definedness.json}, for Mappings whose definedness depends on more than their * coefficients, here a MatrixMap holding a bad element (matrixmap.c {@code InvertMatrix}) and its * control, and an NCP WcsMap, which defines both directions but cannot transform in either - * (wcsmap.c {@code Map}), and its SIN control, and a PolyMap with unequal numbers of inputs and + * (wcsmap.c {@code Map}), and its SIN control, a PolyMap with unequal numbers of inputs and * outputs (polymap.c {@code GetIterInverse}, {@code SetIterInverse}), with whether setting - * IterInverse fails. The MatrixMaps are also built from the matrices C was given. - * - *

    The SwitchMap cases need a class outside the first phase. + * IterInverse fails, and a SwitchMap with only a forward selector, inverted and not, whose + * directions swap under Invert (switchmap.c {@code astInitSwitchMap}). The MatrixMaps are also + * built from the matrices C was given. */ class TranDefinednessOracleTest { @@ -53,7 +53,10 @@ private static List want(JsonNode c) { } private static boolean inScope(String name) { - return name.startsWith("matrixmap_") || name.startsWith("wcsmap_") || name.startsWith("polymap_"); + return name.startsWith("matrixmap_") + || name.startsWith("wcsmap_") + || name.startsWith("polymap_") + || name.startsWith("switchmap_"); } @Test @@ -91,7 +94,7 @@ void definednessMatchesTheCLibrary() { ran++; } assertTrue(failures.isEmpty(), String.join("\n", failures)); - assertEquals(7, ran, "cases run"); + assertEquals(9, ran, "cases run"); } @Test diff --git a/src/test/java/uk/ac/starlink/ast/TranDefinednessTest.java b/src/test/java/uk/ac/starlink/ast/TranDefinednessTest.java index f8a0104..aaee6ce 100644 --- a/src/test/java/uk/ac/starlink/ast/TranDefinednessTest.java +++ b/src/test/java/uk/ac/starlink/ast/TranDefinednessTest.java @@ -1,6 +1,8 @@ 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 static org.junit.jupiter.api.Assertions.assertTrue; import org.junit.jupiter.api.Test; @@ -10,8 +12,7 @@ * its TranForward and TranInverse attributes, in its current orientation, a CmpMap combining its * components'. * - *

    {@code chebymap_forward_only_has_no_inverse} and {@code tranmap_needs_both_directions} need - * classes outside the first phase. + *

    {@code chebymap_forward_only_has_no_inverse} needs a class not yet ported. */ class TranDefinednessTest { @@ -121,4 +122,15 @@ void cmpmapOfTwoWayComponentsHasBothDirections() { assertTrue(cmp.getTranForward()); assertTrue(cmp.getTranInverse()); } + + /** + * A TranMap's forward transformation is its first Mapping's forward one and its inverse its + * second Mapping's inverse one, so C refuses a second Mapping with no inverse (tranmap.c {@code + * astInitTranMap}, AST__INTRD) rather than making a TranMap without one. + */ + @Test + void tranmapNeedsBothDirections() { + AstException e = assertThrows(AstException.class, () -> new TranMap(new ZoomMap(1, 2.0), fwdOnlyPolymap())); + assertEquals(AstException.AST__INTRD, e.getStatus()); + } } diff --git a/src/test/java/uk/ac/starlink/ast/TranGridTest.java b/src/test/java/uk/ac/starlink/ast/TranGridTest.java index 560b010..8612ec1 100644 --- a/src/test/java/uk/ac/starlink/ast/TranGridTest.java +++ b/src/test/java/uk/ac/starlink/ast/TranGridTest.java @@ -13,8 +13,7 @@ * with initial scale sizes of 100 and 4. The results are transformed back with {@code tranP} * rather than C's {@code astTranN}, and, as in C, the unit MatrixMap is made in its unit form. * - *

    {@code tranmap} needs a TranMap and {@code nonlinear_mathmap_1d} a MathMap, which are outside - * the first phase. {@code fits_wcs_pixel_to_sky} reads a header with a {@code CROTA1} card, which + *

    {@code fits_wcs_pixel_to_sky} reads a header with a {@code CROTA1} card, which * C's FitsChan guesses to be FITS-AIPS (fitschan.c:12880). */ class TranGridTest { @@ -107,6 +106,20 @@ void permmap() { assertGridsRoundTrip(new PermMap(2, new int[] {2, 1}, 2, new int[] {2, 1}, new double[] {0.0}), 4, 0.5); } + @Test + void nonlinearMathmap1d() { + assertGridsRoundTrip( + new MathMap(1, 1, new String[] {"y=x**3"}, new String[] {"x=sign((abs(y)**(1/3)),y)"}), 7, 0.0001); + } + + @Test + void tranmap() { + WinMap c1 = new WinMap( + 2, new double[] {0.0, 0.0}, new double[] {1.0, 1.0}, new double[] {0.5, 0.5}, new double[] {2.5, 2.5}); + WinMap c2 = (WinMap) c1.copy(); + assertGridsRoundTrip(new TranMap(c1, c2), 5, 0.5); + } + @Test void cmpmap3d() { CmpMap c3 = new CmpMap( diff --git a/src/test/java/uk/ac/starlink/ast/TranMapTest.java b/src/test/java/uk/ac/starlink/ast/TranMapTest.java new file mode 100644 index 0000000..5a84bb0 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/TranMapTest.java @@ -0,0 +1,634 @@ +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.assertSame; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.Map; +import org.junit.jupiter.api.Test; +import uk.ac.starlink.ast.testsupport.Fixtures; +import uk.ac.starlink.ast.testsupport.ProbeOutput; + +/** + * Translation of Rust {@code tests/test_tranmap.rs}, with the cases of the C probe {@code + * probes/tranmap_probe.c}: native dumps with each component inverted, when the TranMap is made and + * afterwards, and with a LutMap and a MathMap inside, each read back; simplification of a TranMap + * alone and beside other Mappings; rates; equality; decomposition; splits; and the constructor's + * errors. + * + *

    Rust's {@code no_merge_parallel_tranmaps} and {@code no_merge_with_non_tranmap} call {@code + * try_merge}, which this library does not have; here they simplify the parallel CmpMap and the + * series CmpMap they describe, against C. Rust's {@code clone_produces_independent_copy} uses + * {@link AstObject#copy}. + */ +class TranMapTest { + + private static final double BAD = AstObject.AST__BAD; + + private static final Map PROBE_CASES = ProbeOutput.load("tranmap_probe"); + + private static String probe(String name) { + String text = PROBE_CASES.get(name); + if (text == null) { + throw new IllegalStateException("no probe case " + name); + } + return text; + } + + private static ZoomMap zoom(int n, double f) { + return new ZoomMap(n, f); + } + + private static T inv(T m) { + m.invert(); + return m; + } + + private static TranMap tz(double f1, double f2) { + return new TranMap(zoom(1, f1), zoom(1, f2)); + } + + private static double at(Mapping m, double x, boolean forward) { + return m.tran1(1, new double[] {x}, forward)[0]; + } + + private static final double[] TABLE = {0.0, 1.0, 4.0, 9.0, 16.0}; + + private static LutMap lut() { + return new LutMap(TABLE, 1.0, 1.0); + } + + private static MathMap square(boolean simp) { + MathMap m = new MathMap(1, 1, new String[] {"y = x * x"}, new String[] {"x = sqrt( y )"}); + if (simp) { + m.setSimpFI(true); + m.setSimpIF(true); + } + return m; + } + + // ------------------------------------------------------------------ + // Construction and basic properties + // ------------------------------------------------------------------ + + @Test + void basicConstruction() { + TranMap tm = tz(2.0, 3.0); + assertEquals(1, tm.getNin()); + assertEquals(1, tm.getNout()); + assertFalse(tm.getInvert()); + } + + @Test + void constructionDimensionMismatchNin() { + AstException e = assertThrows(AstException.class, () -> new TranMap(zoom(1, 2.0), zoom(2, 3.0))); + assertEquals(AstException.AST__INNCO, e.getStatus()); + } + + @Test + void constructionDimensionMismatchNout() { + AstException e = assertThrows(AstException.class, () -> new TranMap(zoom(1, 2.0), zoom(2, 3.0))); + assertEquals(AstException.AST__INNCO, e.getStatus()); + } + + // ------------------------------------------------------------------ + // Forward and inverse transforms + // ------------------------------------------------------------------ + + @Test + void forwardUsesMap1() { + assertEquals(10.0, at(tz(2.0, 3.0), 5.0, true), 1e-14); + } + + @Test + void inverseUsesMap2() { + assertEquals(3.0, at(tz(2.0, 3.0), 9.0, false), 1e-14); + } + + @Test + void forwardAndInverseAreDifferent() { + TranMap tm = tz(2.0, 3.0); + double fwd = at(tm, 5.0, true); + assertEquals(10.0 / 3.0, at(tm, fwd, false), 1e-14); + } + + @Test + void inversionSwapsTransforms() { + TranMap tm = tz(2.0, 3.0); + tm.invert(); + assertTrue(tm.getInvert()); + assertEquals(3.0, at(tm, 9.0, true), 1e-14); + assertEquals(10.0, at(tm, 5.0, false), 1e-14); + } + + @Test + void badInputForward() { + assertEquals(BAD, at(tz(2.0, 3.0), BAD, true)); + } + + @Test + void badInputInverse() { + assertEquals(BAD, at(tz(2.0, 3.0), BAD, false)); + } + + @Test + void multidimTransform() { + TranMap tm = new TranMap(zoom(2, 2.0), zoom(2, 5.0)); + assertEquals(2, tm.getNin()); + assertEquals(2, tm.getNout()); + double[][] fwd = tm.tran2(1, new double[] {3.0}, new double[] {4.0}, true); + assertEquals(6.0, fwd[0][0], 1e-14); + assertEquals(8.0, fwd[1][0], 1e-14); + double[][] inv = tm.tran2(1, new double[] {3.0}, new double[] {4.0}, false); + assertEquals(0.6, inv[0][0], 1e-14); + assertEquals(0.8, inv[1][0], 1e-14); + } + + // ------------------------------------------------------------------ + // Equality + // ------------------------------------------------------------------ + + @Test + void equalSameComponents() { + assertTrue(tz(2.0, 3.0).astEqual(tz(2.0, 3.0))); + } + + @Test + void equalDifferentComponents() { + assertFalse(tz(2.0, 3.0).astEqual(tz(2.0, 4.0))); + } + + @Test + void equalInvertedVsSwapped() { + TranMap tm1 = inv(tz(2.0, 3.0)); + TranMap tm2 = new TranMap(inv(zoom(1, 3.0)), inv(zoom(1, 2.0))); + assertTrue(tm1.astEqual(tm2)); + } + + @Test + void notEqualToNonTranmap() { + assertFalse(tz(2.0, 3.0).astEqual(zoom(1, 2.0))); + } + + /** Every comparison of the probe's {@code equal} case gives C's {@code astEqual}. */ + @Test + void equalityMatchesC() { + TranMap a = tz(2.0, 3.0); + TranMap b = tz(2.0, 3.0); + TranMap c = tz(2.0, 4.0); + TranMap d = new TranMap(inv(zoom(1, 3.0)), inv(zoom(1, 2.0))); + TranMap ainv = inv((TranMap) a.copy()); + ZoomMap z2 = zoom(1, 2.0); + TranMap e = new TranMap(z2, zoom(1, 3.0)); + z2.invert(); + String got = "same_components " + flag(a.astEqual(b)) + "\n" + + "different_components " + flag(a.astEqual(c)) + "\n" + + "inverted_vs_swapped " + flag(ainv.astEqual(d)) + "\n" + + "swapped_vs_inverted " + flag(d.astEqual(ainv)) + "\n" + + "not_a_tranmap " + flag(a.astEqual(zoom(1, 2.0))) + "\n" + + "inverted_vs_plain " + flag(ainv.astEqual(a)) + "\n" + + "component_inverted_after " + flag(e.astEqual(a)) + "\n"; + assertEquals(probe("equal"), got); + // The comparison sets the components' Invert attributes back. + assertTrue(z2.getInvert()); + assertTrue(d.getMap1().getInvert()); + } + + private static int flag(boolean b) { + return b ? 1 : 0; + } + + // ------------------------------------------------------------------ + // Simplification + // ------------------------------------------------------------------ + + @Test + void simplifyEqualComponents() { + Mapping simp = tz(2.0, 2.0).simplify(); + assertInstanceOf(ZoomMap.class, simp); + assertEquals(10.0, at(simp, 5.0, true), 1e-14); + assertEquals(2.5, at(simp, 5.0, false), 1e-14); + } + + @Test + void simplifyInvertNormalize() { + TranMap tm = inv(new TranMap(zoom(1, 2.0), zoom(1, 0.5))); + Mapping simp = tm.simplify(); + assertInstanceOf(TranMap.class, simp); + assertFalse(simp.getInvert()); + assertEquals(10.0, at(simp, 5.0, true), 1e-14); + } + + @Test + void simplifyComponentSimplification() { + CmpMap cmp1 = new CmpMap(zoom(1, 2.0), zoom(1, 3.0), true); + CmpMap cmp2 = new CmpMap(zoom(1, 0.5), zoom(1, 2.0), true); + Mapping simp = new TranMap(cmp1, cmp2).simplify(); + assertEquals(30.0, at(simp, 5.0, true), 1e-14); + } + + @Test + void mergeAdjacentTranmaps() { + TranMap tm1 = new TranMap(zoom(1, 2.0), zoom(1, 0.5)); + TranMap tm2 = new TranMap(zoom(1, 3.0), zoom(1, 1.0 / 3.0)); + Mapping simp = new CmpMap(tm1, tm2, true).simplify(); + assertEquals(30.0, at(simp, 5.0, true), 1e-14); + assertEquals(30.0, at(simp, 5.0, false), 1e-12); + } + + /** Two TranMaps in parallel do not merge (Rust {@code no_merge_parallel_tranmaps}). */ + @Test + void noMergeParallelTranmaps() { + assertSimplifies("simp_pair_parallel", new CmpMap(tz(2.0, 3.0), tz(5.0, 7.0), false), 6.0); + } + + /** A TranMap does not merge with a ZoomMap (Rust {@code no_merge_with_non_tranmap}). */ + @Test + void noMergeWithNonTranmap() { + assertSimplifies("simp_beside_zoommap", new CmpMap(tz(2.0, 3.0), zoom(1, 4.0), true), 6.0); + } + + @Test + void cloneProducesIndependentCopy() { + TranMap tm1 = tz(2.0, 3.0); + TranMap tm2 = (TranMap) tm1.copy(); + tm2.invert(); + assertFalse(tm1.getInvert()); + assertTrue(tm2.getInvert()); + } + + /** The simplified {@code tranmap_invert_normalize} fixture is dumped as C's {@code .simp}. */ + @Test + void simplifyInvertNormalizeFixtureRoundtrip() { + String input = Fixtures.read("simplify/tranmap_invert_normalize.map"); + String ref = Fixtures.read("simplify/tranmap_invert_normalize.simp"); + Mapping simplified = ((Mapping) ChannelText.read(input)).simplify(); + assertTrue(simplified.astEqual(ChannelText.read(ref))); + assertEquals(ref, ChannelText.dump(simplified)); + } + + /** The error simplifying an encapsulated Mapping is passed up, as in C. */ + @Test + void anErrorSimplifyingAComponentIsPassedUp() { + TranMap map = new TranMap(failingComponent(), new UnitMap(2)); + AstException e = assertThrows(AstException.class, map::simplify); + assertEquals(AstException.AST__WCSPA, e.getStatus()); + } + + /** Two TranMaps in series merge; an error doing so is passed up, as in C. */ + @Test + void anErrorMergingTwoTranmapsIsPassedUp() { + TranMap constants = new TranMap( + new PermMap(2, new int[] {0, 0}, 2, new int[] {-1, -2}, new double[] {0.1, 0.2}), new UnitMap(2)); + TranMap conic = new TranMap(new WcsMap(2, WcsMap.AST__COE, 1, 2), new UnitMap(2)); + AstException e = assertThrows(AstException.class, () -> new CmpMap(constants, conic, true).simplify()); + assertEquals(AstException.AST__WCSPA, e.getStatus()); + } + + /** + * A PermMap supplying constants to a conic WcsMap that lacks its PV2_1 parameter: simplifying + * it raises an error that is not an undefined transformation. + */ + private static CmpMap failingComponent() { + return new CmpMap( + new PermMap(2, new int[] {0, 0}, 2, new int[] {-1, -2}, new double[] {0.1, 0.2}), + new WcsMap(2, WcsMap.AST__COE, 1, 2), + true); + } + + /** A merged TranMap's inverse applies the higher TranMap's inverse first, as the series does. */ + @Test + void aMergedTranmapKeepsTheOrderOfTheInverses() { + TranMap lower = new TranMap(new UnitMap(2), new MatrixMap(2, 2, new double[][] {{1.0, 2.0}, {0.0, 1.0}})); + TranMap higher = new TranMap(new UnitMap(2), new MatrixMap(2, 2, new double[][] {{1.0, 0.0}, {3.0, 1.0}})); + CmpMap map = new CmpMap(lower, higher, true); + Mapping simplified = map.simplify(); + assertInstanceOf(TranMap.class, simplified); + double[][] expected = map.tran2(1, new double[] {1.0}, new double[] {2.0}, false); + double[][] got = simplified.tran2(1, new double[] {1.0}, new double[] {2.0}, false); + assertEquals(expected[0][0], got[0][0], 1e-12); + assertEquals(expected[1][0], got[1][0], 1e-12); + } + + /** TranMaps of 2-to-3 then 3-to-4 Mappings merge, their inverse Mappings combining lower first. */ + @Test + void tranmapsOfDifferingDimensionsMerge() { + TranMap lower = new TranMap( + new PermMap(2, new int[] {1, 2}, 3, new int[] {1, 2, -1}, new double[] {5.0}), + new PermMap(2, new int[] {2, 1}, 3, new int[] {2, 1, -1}, new double[] {6.0})); + TranMap higher = new TranMap( + new PermMap(3, new int[] {1, 2, 3}, 4, new int[] {1, 2, 3, -1}, new double[] {5.0}), + new PermMap(3, new int[] {3, 2, 1}, 4, new int[] {3, 2, 1, -1}, new double[] {6.0})); + assertInstanceOf(TranMap.class, new CmpMap(lower, higher, true).simplify()); + } + + // ------------------------------------------------------------------ + // Simplification against the probe + // ------------------------------------------------------------------ + + private static void assertSimplifies(String name, Mapping map, double x) { + Mapping s = map.simplify(); + String got = "class " + s.astClass() + "\n" + ChannelText.dump(s) + "-- transformations\n" + trans(map, x) + + "-- transformations simplified\n" + trans(s, x); + assertEquals(probe(name), got, name); + } + + /** As {@link #assertSimplifies}, with the transformations at two values. */ + private static void assertSimplifies(String name, Mapping map, double x1, double x2) { + Mapping s = map.simplify(); + String got = "class " + s.astClass() + "\n" + ChannelText.dump(s) + "-- transformations\n" + trans(map, x1) + + trans(map, x2) + "-- transformations simplified\n" + trans(s, x1) + trans(s, x2); + assertEquals(probe(name), got, name); + } + + private static String trans(Mapping m, double x) { + if (m.getNin() != 1) { + return ""; + } + return "fwd " + CFormat.format("%.17g", x) + " -> " + CFormat.format("%.17g", at(m, x, true)) + "\n" + "inv " + + CFormat.format("%.17g", x) + " -> " + CFormat.format("%.17g", at(m, x, false)) + "\n"; + } + + /** A TranMap alone simplifies its components, and is left as it is when they do not change. */ + @Test + void aTranMapAloneSimplifiesAsC() { + assertSimplifies("simp_plain", tz(2.0, 3.0), 6.0); + assertSimplifies("simp_inverted", inv(tz(2.0, 3.0)), 6.0); + assertSimplifies("simp_unequal_mathmaps", new TranMap(square(false), square(false)), 2.5); + } + + /** + * A TranMap whose components are equal becomes one of them, unless they are the same object, + * which C inverts as the second component before combining it with itself as the first. + */ + @Test + void equalComponentsCollapseAsC() { + assertSimplifies("simp_equal", tz(2.0, 2.0), 6.0); + assertSimplifies("simp_equal_inverted_tranmap", inv(tz(2.0, 2.0)), 6.0); + assertSimplifies("simp_equal_inverted_components", new TranMap(inv(zoom(1, 2.0)), inv(zoom(1, 2.0))), 6.0); + ZoomMap z = zoom(1, 2.0); + assertSimplifies("simp_same_object", new TranMap(z, z), 6.0); + assertSimplifies("simp_equal_lutmaps", new TranMap(lut(), lut()), 2.5); + assertSimplifies("simp_equal_mathmaps", new TranMap(square(true), square(true)), 2.5); + } + + /** + * C replaces a TranMap of equal components that were inverted when it was made with a copy of + * the first, applied forward, so the simplified Mapping transforms the other way; Java does as + * C does (docs/rust-c-differences.md). + */ + @Test + void equalInvertedComponentsCollapseToTheForwardComponentAsC() { + assertSimplifies("simp_equal_inverted_mathmaps", new TranMap(inv(square(true)), inv(square(true))), 2.5); + assertSimplifies("simp_equal_inverted_lutmaps", new TranMap(inv(lut()), inv(lut())), 2.5, 3.0); + } + + /** A TranMap beside the Mappings C merges, and beside other TranMaps. */ + @Test + void aTranMapBesideOtherMappingsSimplifiesAsC() { + assertSimplifies( + "simp_lutmap_beside_its_inverse", new CmpMap(new TranMap(lut(), zoom(1, 3.0)), inv(lut()), true), 2.5); + assertSimplifies("simp_pair_second_inverted", new CmpMap(tz(2.0, 3.0), inv(tz(5.0, 7.0)), true), 6.0); + assertSimplifies("simp_pair_inverted_series", inv(new CmpMap(tz(2.0, 3.0), tz(5.0, 7.0), true)), 6.0); + TranMap t = new TranMap(zoom(1, 2.0), zoom(1, 3.0)); + assertSimplifies("simp_pair_shared_tranmap", new CmpMap(t, t, true), 6.0); + } + + // ------------------------------------------------------------------ + // Native dumps + // ------------------------------------------------------------------ + + private static void assertRoundTrips(String name, Mapping m, double x) { + String dump = ChannelText.dump(m); + Mapping back = (Mapping) ChannelText.read(dump); + String got = dump + "-- read back\n" + ChannelText.dump(back) + "-- transformations\n" + trans(m, x) + + "-- transformations read back\n" + trans(back, x); + assertEquals(probe(name), got, name); + } + + @Test + void serializationRoundtrip() { + TranMap tm = tz(2.0, 3.0); + String text = ChannelText.dump(tm); + assertTrue(text.contains("TranMap")); + assertTrue(text.contains("MapA")); + assertTrue(text.contains("MapB")); + Mapping restored = (Mapping) ChannelText.read(text); + assertEquals(at(tm, 5.0, true), at(restored, 5.0, true), 1e-14); + assertEquals(at(tm, 5.0, false), at(restored, 5.0, false), 1e-14); + } + + @Test + void serializationRoundtripInverted() { + TranMap tm = inv(tz(2.0, 3.0)); + String text = ChannelText.dump(tm); + assertTrue(text.contains("Invert")); + Mapping restored = (Mapping) ChannelText.read(text); + assertEquals(at(tm, 5.0, true), at(restored, 5.0, true), 1e-14); + } + + @Test + void serializationWithInvAFlag() { + TranMap tm = new TranMap(inv(zoom(1, 2.0)), zoom(1, 3.0)); + String text = ChannelText.dump(tm); + assertTrue(text.contains("InvA")); + Mapping restored = (Mapping) ChannelText.read(text); + assertEquals(at(tm, 10.0, true), at(restored, 10.0, true), 1e-14); + assertEquals(5.0, at(tm, 10.0, true), 1e-14); + } + + /** Each component inverted, when the TranMap is made or afterwards, dumps and reads back as in C. */ + @Test + void nativeDumpsWithInvertedComponentsMatchC() { + assertRoundTrips("dump_plain", tz(2.0, 3.0), 6.0); + assertRoundTrips("dump_inva", new TranMap(inv(zoom(1, 2.0)), zoom(1, 3.0)), 6.0); + assertRoundTrips("dump_invb", new TranMap(zoom(1, 2.0), inv(zoom(1, 3.0))), 6.0); + assertRoundTrips("dump_both_inverted", new TranMap(inv(zoom(1, 2.0)), inv(zoom(1, 3.0))), 6.0); + assertRoundTrips("dump_tranmap_inverted", inv(tz(2.0, 3.0)), 6.0); + ZoomMap a = zoom(1, 2.0); + ZoomMap b = zoom(1, 3.0); + TranMap t = new TranMap(a, b); + a.invert(); + b.invert(); + assertRoundTrips("dump_components_inverted_after", t, 6.0); + } + + /** A LutMap and a MathMap inside a TranMap dump and read back as in C. */ + @Test + void nativeDumpsOfLutMapAndMathMapComponentsMatchC() { + assertRoundTrips("dump_lutmap_mathmap", new TranMap(lut(), square(false)), 2.5); + assertRoundTrips("dump_lutmap_mathmap_inverted", new TranMap(inv(square(false)), inv(lut())), 2.5); + } + + // ------------------------------------------------------------------ + // Rates, decomposition, splits and errors + // ------------------------------------------------------------------ + + /** The rate is the forward component's, in the orientation the TranMap gives it, as in C. */ + @Test + void ratesMatchC() { + WinMap w = new WinMap( + 2, new double[] {0.0, 0.0}, new double[] {1.0, 1.0}, new double[] {1.0, 3.0}, new double[] {3.0, 5.0}); + WinMap wi = inv((WinMap) w.copy()); + TranMap t = new TranMap(w, wi); + double[] pos = {1.0, 2.0}; + StringBuilder sb = new StringBuilder(); + for (String dir : new String[] {"fwd", "inv"}) { + for (int i = 1; i <= 2; i++) { + for (int j = 1; j <= 2; j++) { + sb.append(dir) + .append(' ') + .append(i) + .append(' ') + .append(j) + .append(' ') + .append(CFormat.format("%.17g", t.rate(pos, i, j))) + .append('\n'); + } + } + t.invert(); + } + TranMap z = tz(2.0, 3.0); + sb.append(rateLine("zoom fwd", z.rate(new double[] {1.0}, 1, 1))); + z.invert(); + sb.append(rateLine("zoom inv", z.rate(new double[] {1.0}, 1, 1))); + TranMap m = new TranMap(square(false), zoom(1, 3.0)); + sb.append(rateLine("mathmap fwd", m.rate(new double[] {3.0}, 1, 1))); + assertEquals(probe("rates"), sb.toString()); + } + + private static String rateLine(String label, double rate) { + return label + " " + CFormat.format("%.17g", rate) + "\n"; + } + + /** + * The components and the Invert values to use with them, swapped for an inverted TranMap, as + * in the probe's {@code decompose} case; C leaves the series flag as it was, and it is false + * here. + */ + @Test + void decomposeGivesComponentsAndInvertValuesLikeC() { + ShiftMap shift = inv(new ShiftMap(new double[] {1.0})); + TranMap map = new TranMap(zoom(1, 2.0), shift); + boolean[] series = {true}; + boolean[] inverts = new boolean[2]; + Mapping[] d = map.decompose(series, inverts); + assertInstanceOf(ZoomMap.class, d[0]); + assertSame(shift, d[1]); + assertFalse(series[0]); + assertFalse(inverts[0]); + assertTrue(inverts[1]); + map.invert(); + d = map.decompose(series, inverts); + assertSame(shift, d[0]); + assertInstanceOf(ZoomMap.class, d[1]); + assertFalse(inverts[0]); + assertTrue(inverts[1]); + assertTrue(probe("decompose").contains("forward ZoomMap ShiftMap series 7 inverts 0 1\n")); + assertTrue(probe("decompose").contains("inverted ShiftMap ZoomMap series 7 inverts 0 1\n")); + } + + /** The Invert values recorded in a loaded TranMap, not its components' own. */ + @Test + void decomposeGivesRecordedInvertValuesNotComponentFlags() { + String text = " Begin TranMap \t# Compound Transformation Mapping\n" + + " Nin = 1 \t# Number of input coordinates\n" + + " IsA Mapping \t# Mapping between coordinate systems\n" + + " InvA = 1 \t# First Mapping used in inverse direction\n" + + " MapA = \t# Mapping for forward transformation\n" + + " Begin ZoomMap \t# Zoom about the origin\n" + + " Nin = 1 \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# Mapping for inverse transformation\n" + + " Begin ZoomMap \t# Zoom about the origin\n" + + " Nin = 1 \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 TranMap\n"; + TranMap map = (TranMap) ChannelText.read(text); + boolean[] inverts = new boolean[2]; + Mapping[] d = map.decompose(null, inverts); + assertFalse(d[0].getInvert()); + assertTrue(inverts[0]); + assertFalse(inverts[1]); + } + + private static String split(Mapping m, int[] in) { + int[] out = new int[m.getNout()]; + Mapping s = m.mapSplit(in, out); + if (s == null) { + return "split none\n"; + } + StringBuilder sb = new StringBuilder("outputs"); + for (int i = 0; i < s.getNout(); i++) { + sb.append(' ').append(out[i]); + } + return sb.append('\n').append(ChannelText.dump(s)).toString(); + } + + /** Splits of a TranMap, inverted or not, and one whose inverse cannot follow, as in C. */ + @Test + void splitsMatchC() { + ShiftMap f = new ShiftMap(new double[] {10.0, 20.0, 30.0}); + ShiftMap i = inv(new ShiftMap(new double[] {-10.0, -20.0, -30.0})); + TranMap t = new TranMap(f, i); + assertEquals(probe("split_shiftmaps"), split(t, new int[] {2})); + t.invert(); + assertEquals(probe("split_inverted"), split(t, new int[] {3, 1})); + int[] perm = {2, 1, 3}; + TranMap tp = new TranMap(f, new PermMap(3, perm, 3, perm, null)); + assertEquals(probe("split_mismatched"), split(tp, new int[] {1})); + } + + private static String report(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 case without the line naming the C source of the error. */ + private static String errorCase(String name) { + StringBuilder sb = new StringBuilder(); + for (String line : probe(name).split("\n", -1)) { + if (!line.startsWith("!! ") && !line.isEmpty()) { + sb.append(line).append('\n'); + } + } + return sb.toString(); + } + + private static PolyMap fwdOnlyPolymap() { + PolyMap pm = new PolyMap(1, 1, 1, new double[] {1.0, 1.0, 1.0}, 0, null); + pm.setIterInverse(false); + return pm; + } + + /** The constructor refuses Mappings without the directions it needs, or that do not fit. */ + @Test + void constructorErrorsMatchC() { + assertEquals( + errorCase("error_no_forward"), + report(assertThrows(AstException.class, () -> new TranMap(inv(fwdOnlyPolymap()), zoom(1, 2.0))))); + assertEquals( + errorCase("error_no_inverse"), + report(assertThrows(AstException.class, () -> new TranMap(zoom(1, 2.0), fwdOnlyPolymap())))); + assertEquals( + errorCase("error_nin"), + report(assertThrows(AstException.class, () -> new TranMap(zoom(1, 2.0), zoom(2, 3.0))))); + PermMap p = new PermMap(1, new int[] {1}, 2, new int[] {1, 1}, null); + assertEquals( + errorCase("error_nout"), report(assertThrows(AstException.class, () -> new TranMap(zoom(1, 2.0), p)))); + PermMap p21 = new PermMap(2, new int[] {1, 1}, 1, new int[] {1}, null); + assertEquals( + errorCase("error_nin_equal_nout"), + report(assertThrows(AstException.class, () -> new TranMap(p21, zoom(1, 2.0))))); + } +} diff --git a/src/test/java/uk/ac/starlink/ast/TransformOracleTest.java b/src/test/java/uk/ac/starlink/ast/TransformOracleTest.java index ec236cc..f2d0810 100644 --- a/src/test/java/uk/ac/starlink/ast/TransformOracleTest.java +++ b/src/test/java/uk/ac/starlink/ast/TransformOracleTest.java @@ -61,7 +61,7 @@ * FrameSet's base-to-current Mapping, and its base and current Frames say which axes are angular. * Why a {@code .head} fixture cannot be read is measured, not listed by hand: when the read throws * {@code UnsupportedOperationException}, the reason is the text of its message from {@code needs} - * on (such as {@code needs MathMap}), or {@code encoding } for an encoding whose read is not + * on (such as {@code needs FitsTable}), or {@code encoding } for an encoding whose read is not * available; a failed read of the NATIVE encoding needs the classes its {@code BEGAST} cards name * that are not ported. Any other read that gives no FrameSet, or throws {@code AstException}, is a * failure the gate reports unless a measured cause is written for it by hand. diff --git a/src/test/java/uk/ac/starlink/ast/TransformValidationTest.java b/src/test/java/uk/ac/starlink/ast/TransformValidationTest.java index 3fd53de..edc0610 100644 --- a/src/test/java/uk/ac/starlink/ast/TransformValidationTest.java +++ b/src/test/java/uk/ac/starlink/ast/TransformValidationTest.java @@ -14,10 +14,7 @@ * makes the checks C's base-class {@code Transform} (mapping.c) makes before any class transforms * a point. * - *

    {@code an_undefined_direction_is_trnnd} uses a RateMap, which is outside the first phase; a - * Mapping whose inverse is undefined, as a RateMap's is, stands in for it. The Region part of - * {@code a_region_and_a_frameset_check_too} needs a class outside the first phase. In {@code rate_checks_its_axes}, the same stand-in, inverted, has - * no forward transformation for the numerical rate to use, as the RateMap does. + *

    The Region part of {@code a_region_and_a_frameset_check_too} needs a class not yet ported. */ class TransformValidationTest { @@ -65,7 +62,7 @@ void tooSmallAnOutputIsNoptsOrNocts() { @Test void anUndefinedDirectionIsTrnnd() { - Mapping rate = new NoInverseMap(); + Mapping rate = new RateMap(new ZoomMap(1, 3.0), 1, 1); double[][] pts = fromRows(new double[] {1.0}); assertEquals(AstException.AST__TRNND, code(() -> rate.transform(pts, 1, false))); assertEquals(AstException.AST__TRNND, code(() -> rate.transformNanProtocol(pts, 1, false))); @@ -91,7 +88,7 @@ void rateChecksItsAxes() { assertEquals(AstException.AST__NCPIN, code(() -> map.rate(new double[] {1.0}, 1, 1)), map.astClass()); } - NoInverseMap rate = new NoInverseMap(); + RateMap rate = new RateMap(new ZoomMap(1, 3.0), 1, 1); rate.invert(); assertEquals(AstException.AST__NODEF, code(() -> rate.rate(new double[] {1.0}, 1, 1))); } diff --git a/src/test/java/uk/ac/starlink/ast/UnitsTest.java b/src/test/java/uk/ac/starlink/ast/UnitsTest.java index d3ae3a1..514c3cb 100644 --- a/src/test/java/uk/ac/starlink/ast/UnitsTest.java +++ b/src/test/java/uk/ac/starlink/ast/UnitsTest.java @@ -11,22 +11,25 @@ import java.util.ArrayList; import java.util.List; +import java.util.Map; import org.junit.jupiter.api.Test; import uk.ac.starlink.ast.UnitsTree.Node; import uk.ac.starlink.ast.UnitsTree.Oper; +import uk.ac.starlink.ast.testsupport.ProbeOutput; /** * Translation of the unit tests in Rust {@code src/units/} ({@code tests.rs}, {@code table.rs}, * {@code parser.rs}, {@code simplify.rs} and {@code dim_anal.rs}), with Java-only tests of C * behaviour the Rust port does not share. * - *

    The four {@code tests.rs} tests of conversions that need a MathMap ({@code - * log_hz_to_hz_is_mathmap}, {@code sqrt_hz_to_hz_is_mathmap}, {@code log_kms_to_ms_is_mathmap}, - * {@code hz_to_log_hz_is_mathmap}) are deferred until MathMap is ported; {@link - * #conversionsNeedingMathMapThrow} checks that they report it. + *

    The MathMaps of conversions that need one are checked against the C probe {@code + * probes/mathmap_simplify_probe.c}. */ class UnitsTest { + /** The cases of the probe that pins the MathMaps of units conversions. */ + private static final Map UNITS_PROBE = ProbeOutput.load("mathmap_simplify_probe"); + // ---------------------------------------------------------------- tests.rs /** The forward image of {@code x} under {@code map}. */ @@ -42,6 +45,35 @@ private static void assertZoomFactor(Mapping map, double expected) { assertTrue(Math.abs(got - expected) <= tol, "expected zoom factor " + expected + ", got " + got); } + @Test + void logHzToHzIsMathmap() { + Mapping map = Units.unitMapper("log(Hz)", "Hz"); + assertInstanceOf(MathMap.class, map); + assertEquals(1.0, forwardOne(map, 0.0), 1e-12); + assertEquals(100.0, forwardOne(map, 2.0), 1e-9); + } + + @Test + void sqrtHzToHzIsMathmap() { + Mapping map = Units.unitMapper("sqrt(Hz)", "Hz"); + assertInstanceOf(MathMap.class, map); + assertEquals(4.0, forwardOne(map, 2.0), 1e-12); + } + + @Test + void logKmsToMsIsMathmap() { + Mapping map = Units.unitMapper("log(km/s)", "m/s"); + assertInstanceOf(MathMap.class, map); + assertEquals(1000.0, forwardOne(map, 0.0), 1e-9); + } + + @Test + void hzToLogHzIsMathmap() { + Mapping map = Units.unitMapper("Hz", "log(Hz)"); + assertInstanceOf(MathMap.class, map); + assertEquals(2.0, forwardOne(map, 100.0), 1e-12); + } + @Test void identityReturnsUnitmap() { assertInstanceOf(UnitMap.class, Units.unitMapper("Hz", "Hz")); @@ -402,17 +434,81 @@ void quantIndexLookupWorks() { // ---------------------------------------------------------------- Java-only - /** A conversion C builds as a MathMap (unit.c {@code MakeMapping}) is not available. */ + /** + * The conversions C makes with a MathMap (unit.c {@code MakeMapping}) give C's MathMap, with + * its functions, SimpFI and SimpIF set, and the label C gives for "Frequency"; the MathMap + * transforms the probe's values forward and back as C's does, to within the last bits of the + * maths library. + */ @Test - void conversionsNeedingMathMapThrow() { - String[][] pairs = {{"log(Hz)", "Hz"}, {"sqrt(Hz)", "Hz"}, {"log(km/s)", "m/s"}, {"Hz", "log(Hz)"}}; - for (String[] p : pairs) { - UnsupportedOperationException e = - assertThrows(UnsupportedOperationException.class, () -> Units.unitMapper(p[0], p[1])); - assertTrue(e.getMessage().contains("MathMap"), e.getMessage()); + void conversionsNeedingMathMapGiveCsMathMap() { + String[][] cases = { + {"units_log_hz_to_hz", "log(Hz)", "Hz", "v1"}, + {"units_sqrt_hz_to_hz", "sqrt(Hz)", "Hz", "v2"}, + {"units_log_kms_to_ms", "log(km/s)", "m/s", "v1"}, + {"units_hz_to_log_hz", "Hz", "log(Hz)", "v2"}, + {"units_hz_to_sqrt_hz", "Hz", "sqrt(Hz)", "v2"}, + {"units_ln_hz_to_mhz", "ln(Hz)", "MHz", "v1"}, + {"units_exp_hz_to_hz", "exp(Hz)", "Hz", "v2"}, + {"units_log_mhz_to_log_hz", "log(MHz)", "log(Hz)", "v1"}, + {"units_hz_to_per_hz", "Hz", "1/Hz", "v2"}, + {"units_hz15_to_hz", "Hz**1.5", "Hz", "v2"}, + {"units_m2_to_cm", "m**2", "cm", "v2"}, + {"units_log_jy_to_w", "log(Jy)", "W/m**2/Hz", "v1"}, + }; + double[] v1 = {0.0, 2.0, -1.5}; + double[] v2 = {2.0, 0.25, 100.0}; + for (String[] c : cases) { + String want = UNITS_PROBE.get(c[0]); + Units.LabelledMapping lm = Units.unitMapperLabel(c[1], c[2], "Frequency"); + assertNotNull(lm, c[0]); + assertInstanceOf(MathMap.class, lm.mapping, c[0]); + String[] lines = want.split("\n", -1); + assertEquals(lines[0], "label " + lm.label, c[0]); + String dump = ChannelText.dump(lm.mapping); + int ndump = dump.split("\n", -1).length - 1; + StringBuilder wantDump = new StringBuilder(); + for (int i = 1; i <= ndump; i++) { + wantDump.append(lines[i]).append('\n'); + } + assertEquals(wantDump.toString(), dump, c[0]); + double[] vals = "v1".equals(c[3]) ? v1 : v2; + double[] fwd = lm.mapping.tran1(vals.length, vals, true); + double[] inv = lm.mapping.tran1(vals.length, fwd, false); + for (int i = 0; i < vals.length; i++) { + String[] parts = lines[ndump + 1 + i].split(" -> ", -1); + assertClose(Double.parseDouble(parts[1]), fwd[i], c[0] + " forward " + vals[i]); + assertClose(Double.parseDouble(parts[2]), inv[i], c[0] + " inverse " + vals[i]); + } } } + /** Asserts that {@code got} is {@code want} to within the last bits of the maths library. */ + private static void assertClose(double want, double got, String what) { + double tol = 1e-14 * Math.max(1.0, Math.abs(want)); + assertTrue(Math.abs(got - want) <= tol, what + ": expected " + want + ", got " + got); + } + + /** + * A conversion and its reverse in series do not cancel, as their functions are not each + * other's inverse functions as text; a conversion and its inverse do. + */ + @Test + void unitsMathMapsSimplifyAsC() { + Mapping m1 = Units.unitMapper("log(Hz)", "Hz"); + Mapping m2 = Units.unitMapper("Hz", "log(Hz)"); + Mapping s = new CmpMap(m1, m2, true).simplify(); + assertEquals( + UNITS_PROBE.get("units_there_and_back"), + s.astClass() + " " + s.getNin() + " " + s.getNout() + "\n" + ChannelText.dump(s)); + Mapping m3 = (Mapping) m1.copy(); + m3.invert(); + s = new CmpMap(m1, m3, true).simplify(); + assertEquals( + UNITS_PROBE.get("units_with_inverse"), + s.astClass() + " " + s.getNin() + " " + s.getNout() + "\n" + ChannelText.dump(s)); + } + /** * NormUnit of a one-axis Frame in C, which is {@code astNormUnit} of its Unit (frame.c {@code * GetNormUnit}), from the table {@code C_ORACLE} in Rust {@code tests/test_frame.rs}. Task 15 diff --git a/src/test/java/uk/ac/starlink/ast/WcsMapTest.java b/src/test/java/uk/ac/starlink/ast/WcsMapTest.java index 744b146..b9ecfe8 100644 --- a/src/test/java/uk/ac/starlink/ast/WcsMapTest.java +++ b/src/test/java/uk/ac/starlink/ast/WcsMapTest.java @@ -781,4 +781,27 @@ void jniastAccessors() { assertThrows(AstException.class, () -> w.setPVi_m(1.0f)).getStatus()); assertSame(WcsMap.class, w.getClass()); } + + // ------------------------------------------------------------------ + // Equality (wcsmap.c Equal compares the projection parameters) + // ------------------------------------------------------------------ + + @Test + void wcsmapEqualDifferentParams() { + WcsMap w1 = wcs(2, WcsMap.AST__ZPN, 1, 2); + WcsMap w2 = wcs(2, WcsMap.AST__ZPN, 1, 2); + assertTrue(w1.astEqual(w2)); + w1.setD("PV2_1", 0.5); + w2.setD("PV2_1", 0.7); + assertFalse(w1.astEqual(w2)); + } + + @Test + void wcsmapEqualSameParams() { + WcsMap w1 = wcs(2, WcsMap.AST__ZPN, 1, 2); + WcsMap w2 = wcs(2, WcsMap.AST__ZPN, 1, 2); + w1.setD("PV2_1", 0.5); + w2.setD("PV2_1", 0.5); + assertTrue(w1.astEqual(w2)); + } } diff --git a/src/test/java/uk/ac/starlink/ast/testsupport/CValues.java b/src/test/java/uk/ac/starlink/ast/testsupport/CValues.java index 22193b1..7e6df5d 100644 --- a/src/test/java/uk/ac/starlink/ast/testsupport/CValues.java +++ b/src/test/java/uk/ac/starlink/ast/testsupport/CValues.java @@ -176,6 +176,14 @@ public static boolean nativeStringsWithin(String got, String want, double atol) return linesMatch(got, want, (a, b) -> Math.abs(a - b) <= atol); } + /** + * {@link #nativeStringsEquivalent} with a relative tolerance {@code rtol} on numbers: each + * within {@code rtol} of the larger of the two in magnitude. + */ + public static boolean nativeStringsWithinRelative(String got, String want, double rtol) { + return linesMatch(got, want, (a, b) -> Math.abs(a - b) <= rtol * Math.max(Math.abs(a), Math.abs(b))); + } + /** {@link #nativeStringsEquivalent} with C's {@code astEQUAL} tolerance on numbers. */ public static boolean nativeStringsAstEqual(String got, String want) { return linesMatch(got, want, CValues::astEqualClose); diff --git a/src/test/java/uk/ac/starlink/ast/testsupport/DeferredTest.java b/src/test/java/uk/ac/starlink/ast/testsupport/DeferredTest.java index 355d6e0..fc08daf 100644 --- a/src/test/java/uk/ac/starlink/ast/testsupport/DeferredTest.java +++ b/src/test/java/uk/ac/starlink/ast/testsupport/DeferredTest.java @@ -67,7 +67,9 @@ void unavailableReasonIsMeasuredFromTheMessage() { assertEquals( "needs SpecFrame", Deferred.unavailableReason("FitsChan: the spectral axis 3 (CTYPE 'FREQ') needs SpecFrame")); - assertEquals("needs MathMap", Deferred.unavailableReason("FitsChan: axis 1 (CTYPE 'X-LOG') needs MathMap")); + assertEquals( + "needs FitsTable", + Deferred.unavailableReason("FitsChan: the -TAB table in extension 'WCS-TAB' needs FitsTable")); assertEquals( "encoding FITS-IRAF", Deferred.unavailableReason("FitsChan: reading the FITS-IRAF encoding is not available")); 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 8fb1530..7216955 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,33 @@ 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 GrismMap \t# Grism Mapping\n" + + " Begin XphMap \t# Xph Mapping\n" + " Ax1 = \n" - + " Begin LutMap\n" - + " End LutMap\n" - + " End GrismMap\n" + + " Begin SplineMap\n" + + " End SplineMap\n" + + " End XphMap\n" + " Map2 = \n" + " Begin CmpMap\n" + " MapA = \n" + " Begin ZoomMap\n" + " End ZoomMap\n" + " MapB = \n" - + " Begin GrismMap\n" - + " End GrismMap\n" + + " Begin XphMap\n" + + " End XphMap\n" + " End CmpMap\n" + " End FrameSet\n"; @Test void listsTheBegunClassesInOrder() { assertEquals( - Arrays.asList("FrameSet", "GrismMap", "LutMap", "CmpMap", "ZoomMap", "GrismMap"), + Arrays.asList("FrameSet", "XphMap", "SplineMap", "CmpMap", "ZoomMap", "XphMap"), NativeClasses.begun(DUMP)); } @Test void missingClassesAreSortedWithoutRepeats() { - assertEquals(Arrays.asList("GrismMap", "LutMap"), NativeClasses.missing(DUMP)); - assertEquals("needs GrismMap, LutMap", NativeClasses.needs(DUMP)); + assertEquals(Arrays.asList("SplineMap", "XphMap"), NativeClasses.missing(DUMP)); + assertEquals("needs SplineMap, XphMap", NativeClasses.needs(DUMP)); } @Test @@ -52,11 +52,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= 'MathMap ' / Transformation using mathematical functions\n" - + "BEGAST_D= 'LutMap '\n" - + "BEGAST_E= 'MathMap '\n" + + "BEGAST_C= 'ChebyMap' / Chebyshev polynomial transformation\n" + + "BEGAST_D= 'SplineMap'\n" + + "BEGAST_E= 'ChebyMap'\n" + "CTYPE1 = 'RA---TAN'\n"; - assertEquals("needs LutMap, MathMap", NativeClasses.needsInFitsHeader(header)); + assertEquals("needs ChebyMap, SplineMap", NativeClasses.needsInFitsHeader(header)); assertNull(NativeClasses.needsInFitsHeader("BEGAST_A= 'ZoomMap '\nZOOM_A = 2.0\n")); } } diff --git a/src/test/java/uk/ac/starlink/ast/testsupport/ProbeOutput.java b/src/test/java/uk/ac/starlink/ast/testsupport/ProbeOutput.java new file mode 100644 index 0000000..fcad100 --- /dev/null +++ b/src/test/java/uk/ac/starlink/ast/testsupport/ProbeOutput.java @@ -0,0 +1,112 @@ +package uk.ac.starlink.ast.testsupport; + +import com.fasterxml.jackson.databind.ObjectMapper; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.UncheckedIOException; +import java.nio.charset.StandardCharsets; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * The output of a C probe run against the pinned C library, committed under {@code + * src/test/resources/probes/} beside the probe's source. The output is a sequence of cases, each + * starting with a line {@code == }; the lines that follow, up to the next such line, are the + * case's text. Trailing white space is removed from every line, so that the committed file and + * the text a test makes compare alike however the file's hooks treat it. + */ +public final class ProbeOutput { + + private ProbeOutput() {} + + /** + * The cases of {@code probes/.out}, in order, each mapped to its text, every line ending + * with a newline. Where there is no such file the output is the string {@code output} of + * {@code probes/.json}, the form an output takes when it holds words of C's, such as + * attribute names, that the spelling check of text files would reject. + * + * @throws IllegalStateException if there is neither file, or a case name appears twice + */ + public static Map load(String name) { + String text = resource("/probes/" + name + ".out"); + if (text == null) { + String json = resource("/probes/" + name + ".json"); + if (json == null) { + throw new IllegalStateException("No probe output /probes/" + name + ".out or .json"); + } + try { + text = new ObjectMapper().readTree(json).get("output").asText(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + Map cases = new LinkedHashMap<>(); + String current = null; + StringBuilder sb = new StringBuilder(); + String[] lines = text.split("\n", -1); + // The piece after the newline that ends the file is not a line. + int nline = lines.length > 0 && lines[lines.length - 1].isEmpty() ? lines.length - 1 : lines.length; + for (int i = 0; i < nline; i++) { + String line = lines[i]; + if (line.startsWith("== ")) { + if (current != null) { + put(cases, current, sb.toString()); + } + current = line.substring(3); + sb.setLength(0); + } else if (current != null) { + sb.append(trimEnd(line)).append('\n'); + } + } + if (current != null) { + put(cases, current, sb.toString()); + } + return cases; + } + + /** The text of the resource {@code res}, or null if there is none. */ + private static String resource(String res) { + try (InputStream in = ProbeOutput.class.getResourceAsStream(res)) { + if (in == null) { + return null; + } + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + byte[] buf = new byte[8192]; + int n; + while ((n = in.read(buf)) > 0) { + bytes.write(buf, 0, n); + } + return new String(bytes.toByteArray(), StandardCharsets.UTF_8); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + private static void put(Map cases, String name, String body) { + if (cases.put(name, body) != null) { + throw new IllegalStateException("Probe case " + name + " appears twice"); + } + } + + /** {@code text} with the trailing white space of every line removed. */ + public static String trimLines(String text) { + StringBuilder sb = new StringBuilder(); + String[] lines = text.split("\n", -1); + for (int i = 0; i < lines.length; i++) { + sb.append(trimEnd(lines[i])); + if (i < lines.length - 1) { + sb.append('\n'); + } + } + return sb.toString(); + } + + private static String trimEnd(String line) { + int end = line.length(); + while (end > 0 && Character.isWhitespace(line.charAt(end - 1))) { + end--; + } + return line.substring(0, end); + } +} diff --git a/src/test/resources/deferred/framesets.txt b/src/test/resources/deferred/framesets.txt index 525abfb..7ce4804 100644 --- a/src/test/resources/deferred/framesets.txt +++ b/src/test/resources/deferred/framesets.txt @@ -1,13 +1,6 @@ # Fixtures of fixtures/oracle/framesets.oracle whose sections do not all match C: # | # Rewritten by TransformOracleTest with -Dast.writeDeferred=true. -programs/testcmpmap/splittest1.ast | needs LutMap -programs/testfitschan/sparse.ast | needs LutMap programs/teststcschan/stcschan-test1-doc3.ast | needs Box, Circle, PointList, PointSet, Prism -serialisation/c_dssmap.ast | needs DssMap serialisation/region_in_cmpframe.ast | needs Box, PointSet -wcsconv/framesets/freq-log-head.ast | needs MathMap -wcsconv/framesets/grism-head.ast | needs GrismMap -wcsconv/framesets/polco-head.ast | needs MathMap -wcsconv/framesets/polco2-head.ast | needs MathMap 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 838d77b..c120828 100644 --- a/src/test/resources/deferred/full-dumps.txt +++ b/src/test/resources/deferred/full-dumps.txt @@ -1,10 +1,7 @@ # Native fixtures whose Full = 1 dump differs from C's: # | # Rewritten by FixtureFullDumpOracleTest with -Dast.writeDeferred=true. -programs/testcmpmap/splittest1.ast | needs LutMap -programs/testfitschan/sparse.ast | needs LutMap programs/teststcschan/stcschan-test1-doc3.ast | needs Box, Circle, PointList, PointSet, Prism -serialisation/c_dssmap.ast | needs DssMap serialisation/region_in_cmpframe.ast | needs Box, PointSet simplify/box_nullregion_merge.map | needs Box, NullRegion, PointSet simplify/box_nullregion_merge.simp | needs Interval, PointSet @@ -16,8 +13,6 @@ simplify/box_self_simplify.map | needs Box, PointSet simplify/box_self_simplify.simp | needs Box, PointSet simplify/box_unc_fillfactor_merge.map | needs Box, PointSet simplify/box_unc_fillfactor_merge.simp | needs Box, PointSet -simplify/brad.map | needs LutMap -simplify/brad.simp | needs LutMap simplify/cap_box_permmap_const.map | needs Box, PointSet simplify/cap_box_permmap_const.simp | needs Box, PointSet simplify/cap_box_permmap_nonbidi.map | needs Box, PointSet @@ -27,21 +22,8 @@ simplify/cap_box_permmap_null.map | needs Box, PointSet simplify/cap_box_permmap_null.simp | needs NullRegion simplify/cap_cheby_consolidate.map | needs ChebyMap simplify/cap_cheby_consolidate.simp | needs ChebyMap -simplify/cap_cmpmap_01.map | needs MathMap, RateMap, TranMap -simplify/cap_cmpmap_01.simp | needs MathMap, RateMap, TranMap -simplify/cap_cmpmap_02.map | needs MathMap -simplify/cap_cmpmap_02.simp | needs MathMap -simplify/cap_cmpmap_04.map | needs MathMap, RateMap, TranMap -simplify/cap_cmpmap_04.simp | needs MathMap, RateMap, TranMap -simplify/cap_cmpperm_resume_inv.map | needs MathMap -simplify/cap_cmpperm_resume_inv.simp | needs MathMap -simplify/cap_cmpperm_resume.map | needs MathMap -simplify/cap_cmpperm_resume.simp | needs MathMap simplify/cap_interval_01.map | needs Box, Interval, NullRegion, PointSet, Prism simplify/cap_interval_01.simp | needs Box, Interval, PointSet -simplify/cap_lutmap_01.map | needs LutMap, MathMap -simplify/cap_lutmap_01.simp | needs MathMap -simplify/cap_mathmap_01.map | needs MathMap simplify/cap_matrixmap_04.map | needs ChebyMap simplify/cap_normmap_cmpframe.map | needs NormMap simplify/cap_normmap_cmpframe.simp | needs NormMap @@ -51,23 +33,16 @@ simplify/cap_pointlist_01.map | needs Box, PointList, PointSet, Prism simplify/cap_pointlist_01.simp | needs Box, PointList, PointSet, Prism simplify/cap_pointlist_02.map | needs Interval, PointList, PointSet, Prism simplify/cap_pointlist_02.simp | needs PointList, PointSet -simplify/cap_poly_bend_allowed.map | needs Box, MathMap, PointSet, Polygon -simplify/cap_poly_bend_allowed.simp | needs Box, MathMap, PointSet, Polygon -simplify/cap_poly_bent_edges.map | needs Box, MathMap, PointSet, Polygon -simplify/cap_poly_bent_edges.simp | needs Box, MathMap, PointSet, Polygon +simplify/cap_poly_bend_allowed.map | needs Box, PointSet, Polygon +simplify/cap_poly_bend_allowed.simp | needs Box, PointSet, Polygon +simplify/cap_poly_bent_edges.map | needs Box, PointSet, Polygon +simplify/cap_poly_bent_edges.simp | needs Box, PointSet, Polygon simplify/cap_poly_unc_frame.map | needs Box, PointSet, Polygon simplify/cap_poly_unc_frame.simp | needs Box, PointSet, Polygon -simplify/cap_restricted_component_flags.map | needs MathMap -simplify/cap_restricted_component_flags.simp | needs MathMap simplify/cap_slamap_02.map | needs Box, PointSet simplify/cap_slamap_02.simp | needs Box, PointSet, Polygon, Prism simplify/cap_slamap_07.map | needs Box, Circle, CmpRegion, PointSet simplify/cap_slamap_07.simp | needs NullRegion -simplify/cap_specmap_02.map | needs LutMap -simplify/cap_specmap_02.simp | needs LutMap -simplify/cap_specmap_09.map | needs LutMap -simplify/cap_specmap_14.map | needs MathMap -simplify/cap_specmap_14.simp | needs MathMap simplify/cap_timemap_02.map | needs Box, Interval, PointSet, StcResourceProfile simplify/cap_timemap_02.simp | needs Box, Interval, PointSet, StcResourceProfile simplify/cap_unitnormmap_01.map | needs UnitNormMap @@ -75,33 +50,18 @@ 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/cap_zoommap_04.map | needs Box, MathMap, PointList, PointSet +simplify/cap_zoommap_04.map | needs Box, PointList, PointSet simplify/cap_zoommap_04.simp | needs Box, PointList, PointSet simplify/cefit_circle_conformal.map | needs Circle, PointSet simplify/cefit_circle_conformal.simp | needs Circle, PointSet -simplify/cefit_circle_nonconformal_keep.map | needs Circle, MathMap, PointSet -simplify/cefit_circle_nonconformal_keep.simp | needs Circle, MathMap, PointSet +simplify/cefit_circle_nonconformal_keep.map | needs Circle, PointSet +simplify/cefit_circle_nonconformal_keep.simp | needs Circle, PointSet simplify/cefit_circle_to_ellipse.map | needs Ellipse, PointSet simplify/cefit_circle_to_ellipse.simp | needs Ellipse, PointSet simplify/cefit_ellipse_to_circle.map | needs Circle, PointSet simplify/cefit_ellipse_to_circle.simp | needs Circle, PointSet simplify/cheby_linear_lone_reduce.map | needs ChebyMap simplify/chebymap_inverse_cancel.map | needs ChebyMap -simplify/cmpmap_decompose_middle.map | needs MathMap -simplify/cmpmap_decompose_middle.simp | needs MathMap -simplify/cmpmap_inverted_nested.map | needs MathMap -simplify/cmpmap_inverted_nested.simp | needs MathMap -simplify/cmpmap_parallel_in_series_merge.map | needs MathMap -simplify/cmpmap_parallel_series_dim_mismatch.map | needs MathMap -simplify/cmpmap_parallel_series_dim_mismatch.simp | needs MathMap -simplify/cmpmap_perm_swap_aconstants.map | needs MathMap -simplify/cmpmap_perm_swap_aconstants.simp | needs MathMap -simplify/cmpmap_perm_swap_bconstants.map | needs MathMap -simplify/cmpmap_perm_swap_bconstants.simp | needs MathMap -simplify/cmpmap_series_in_parallel_inverted.map | needs MathMap -simplify/cmpmap_series_in_parallel_inverted.simp | needs MathMap -simplify/cmpmap_solo_after_unit.map | needs MathMap -simplify/cmpmap_solo_after_unit.simp | needs MathMap simplify/defunc_cmpregion_component_unc.map | needs Box, PointSet simplify/defunc_cmpregion_component_unc.simp | needs Box, PointSet simplify/defunc_interval_point_at_origin.map | needs Box, PointSet @@ -114,18 +74,6 @@ simplify/defunc_pointlist_origin_axis.map | needs Box, PointSet simplify/defunc_pointlist_origin_axis.simp | needs Box, PointSet simplify/defunc_prism_box_interval.map | needs Box, PointSet, Prism simplify/defunc_prism_box_interval.simp | needs Box, PointSet -simplify/dssmap_inv_winmap_absorb.map | needs DssMap -simplify/dssmap_inv_winmap_absorb.simp | needs DssMap -simplify/dssmap_winmap_absorb.map | needs DssMap -simplify/dssmap_winmap_absorb.simp | needs DssMap -simplify/dssmap_zoom_no_merge.map | needs DssMap -simplify/dssmap_zoom_no_merge.simp | needs DssMap -simplify/grism_inverse_cancel_tail.map | needs GrismMap -simplify/grism_inverse_cancel.map | needs GrismMap -simplify/grism_zoom_inv_merge.map | needs GrismMap -simplify/grism_zoom_inv_merge.simp | needs GrismMap -simplify/grism_zoom_merge.map | needs GrismMap -simplify/grism_zoom_merge.simp | needs GrismMap simplify/interval_halfinf_simplify.map | needs Interval, PointSet simplify/interval_nullregion_merge.map | needs Interval, NullRegion, PointSet simplify/interval_nullregion_merge.simp | needs Interval, PointSet @@ -140,10 +88,6 @@ simplify/interval_self_simplify.map | needs Interval, PointSet simplify/interval_self_simplify.simp | needs Box, PointSet simplify/interval_unc_fillfactor_merge.map | needs Box, Interval, PointSet simplify/interval_unc_fillfactor_merge.simp | needs Box, Interval, PointSet -simplify/lut_exactly_linear.map | needs LutMap -simplify/lut_inverse_cancel.map | needs LutMap -simplify/lut_linear_to_win.map | needs LutMap -simplify/math_inverse_cancel.map | needs MathMap simplify/merge_box_fillfactor_product.map | needs Box, PointSet simplify/merge_box_fillfactor_product.simp | needs Box, PointSet simplify/merge_box_meshsize_scaled.map | needs Box, PointSet @@ -157,28 +101,9 @@ simplify/neg_box_unc_mismatch.map | needs Box, PointSet simplify/neg_cheby_quadratic_no_reduce.map | needs ChebyMap simplify/neg_chebymap_standalone.map | needs ChebyMap simplify/neg_circle_cmpframe_sky_second.map | needs Circle, PointSet -simplify/neg_cmpmap_mode_mismatch.map | needs MathMap -simplify/neg_cmpmap_neighbour_nonexcmpmap.map | needs MathMap -simplify/neg_grism_different_attrs.map | needs GrismMap -simplify/neg_grism_fwd_then_nonzoom.map | needs GrismMap -simplify/neg_grism_inv_then_zoom.map | needs GrismMap -simplify/neg_grism_nonzoom_before_inv.map | needs GrismMap -simplify/neg_grism_parallel.map | needs GrismMap -simplify/neg_grism_same_direction.map | needs GrismMap -simplify/neg_grism_zoom_before_fwd.map | needs GrismMap simplify/neg_interval_parallel_nonregion.map | needs Interval, PointSet simplify/neg_interval_series.map | needs Interval, PointSet simplify/neg_interval_unbounded_pointlist.map | needs Interval, PointList, PointSet -simplify/neg_lut_constant.map | needs LutMap -simplify/neg_lut_different_tables.map | needs LutMap -simplify/neg_lut_near_linear.map | needs LutMap -simplify/neg_lut_nonlinear.map | needs LutMap -simplify/neg_lut_nonlut_neighbour.map | needs LutMap -simplify/neg_lut_parallel.map | needs LutMap -simplify/neg_math_inv_text_mismatch.map | needs MathMap -simplify/neg_math_lone.map | needs MathMap -simplify/neg_math_no_simpfi.map | needs MathMap -simplify/neg_math_nonmath_neighbour.map | needs MathMap 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 @@ -187,25 +112,8 @@ simplify/neg_normmap_parallel_sky.map | needs NormMap simplify/neg_normmap_parallel.map | needs NormMap simplify/neg_nullregion_parallel_nonregion.map | needs NullRegion simplify/neg_nullregion_series.map | needs NullRegion -simplify/neg_parpair_aligned_irreducible.map | needs MathMap -simplify/neg_pcd_diff_centre.map | needs PcdMap -simplify/neg_pcd_diff_disco.map | needs PcdMap -simplify/neg_pcd_nonpcd_neighbour.map | needs PcdMap -simplify/neg_pcd_nonswappable_between.map | needs PcdMap -simplify/neg_pcd_parallel.map | needs PcdMap -simplify/neg_pcd_perm_nonswap.map | needs PcdMap -simplify/neg_pcd_same_invert.map | needs PcdMap -simplify/neg_pcd_zoom_no_target.map | needs PcdMap -simplify/neg_perm_no_merge.map | needs MathMap simplify/neg_pointlist_parallel_nonregion.map | needs PointList, PointSet simplify/neg_pointlist_series.map | needs PointList, PointSet -simplify/neg_ratemap_diff_indices.map | needs RateMap -simplify/neg_ratemap_diff_inner.map | needs RateMap -simplify/neg_ratemap_different_inner.map | needs RateMap -simplify/neg_ratemap_lower_nonrate.map | needs RateMap -simplify/neg_ratemap_nonratemap_neighbour.map | needs RateMap -simplify/neg_ratemap_parallel.map | needs RateMap -simplify/neg_ratemap_same_invert.map | needs RateMap simplify/neg_selectormap_not_equal.map | needs Box, PointSet, SelectorMap simplify/neg_selectormap_parallel.map | needs Box, PointSet, SelectorMap simplify/neg_selectormap_series_lower.map | needs Box, PointSet, SelectorMap @@ -214,16 +122,6 @@ 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_switchmap_not_equal.map | needs SwitchMap -simplify/neg_switchmap_parallel.map | needs SwitchMap -simplify/neg_switchmap_series_lower.map | needs SwitchMap -simplify/neg_switchmap_series.map | needs SwitchMap -simplify/neg_tranmap_adjacent_no_merge.map | needs MathMap, TranMap -simplify/neg_tranmap_nontranmap_neighbour.map | needs TranMap -simplify/neg_tranmap_oneway.map | needs MathMap, TranMap -simplify/neg_tranmap_parallel.map | needs TranMap -simplify/neg_tranmap_unequal_components.map | needs TranMap -simplify/neg_unit_parallel_forward.map | needs PcdMap simplify/neg_unitnormmap_flanked.map | needs UnitNormMap simplify/neg_unitnormmap_fwd_shift.map | needs UnitNormMap simplify/neg_unitnormmap_inv_fwd_diffcentre.map | needs UnitNormMap @@ -232,13 +130,9 @@ 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_wcs_nonperm_between.map | needs MathMap -simplify/neg_win_cmpmap_split_no_simplify.map | needs MathMap -simplify/neg_win_nonmergeable_series.map | needs MathMap simplify/neg_xph_nonxph_neighbour.map | needs XphMap simplify/neg_xph_not_opposite.map | needs XphMap simplify/neg_xph_parallel.map | needs XphMap -simplify/neg_zoom_parallel_lone.map | needs MathMap simplify/normmap_basic_frame_to_unit.map | needs NormMap simplify/normmap_duplicate_elim.map | needs NormMap simplify/normmap_duplicate_elim.simp | needs NormMap @@ -254,40 +148,12 @@ simplify/nullregion_self_simplify.map | needs NullRegion simplify/nullregion_self_simplify.simp | needs NullRegion simplify/nullregion_unc_fillfactor_merge.map | needs Box, NullRegion, PointSet simplify/nullregion_unc_fillfactor_merge.simp | needs Box, NullRegion, PointSet -simplify/parcomp_inverted_nested_reemitted.map | needs MathMap -simplify/parcomp_inverted_nested_reemitted.simp | needs MathMap -simplify/parcomp_inverted_reemitted.map | needs MathMap -simplify/parcomp_inverted_reemitted.simp | needs MathMap -simplify/parpair_one_side_reduces.map | needs MathMap -simplify/parpair_one_side_reduces.simp | needs MathMap -simplify/pcd_inverse_cancel_tail.map | needs PcdMap -simplify/pcd_inverse_cancel.map | needs PcdMap -simplify/pcd_inverted_zoom_swap.map | needs PcdMap -simplify/pcd_inverted_zoom_swap.simp | needs PcdMap -simplify/pcd_perm_swap_cancel.map | needs PcdMap -simplify/pcd_search_blocked.map | needs PcdMap -simplify/pcd_search_blocked.simp | needs PcdMap -simplify/pcd_swap_zoom_simplifies.map | needs PcdMap -simplify/pcd_swap_zoom_simplifies.simp | needs PcdMap -simplify/pcd_unit_series_merge.map | needs PcdMap -simplify/pcd_unit_series_merge.simp | needs PcdMap -simplify/pcd_zero_disc_lone.map | needs PcdMap -simplify/pcd_zero_disc_series.map | needs PcdMap -simplify/pcd_zero_to_unit.map | needs PcdMap -simplify/pcd_zoom_swap_cancel.map | needs PcdMap simplify/pointlist_parallel_merge_pair.map | needs PointList, PointSet simplify/pointlist_parallel_merge_pair.simp | needs PointList, PointSet simplify/pointlist_self_simplify.map | needs PointList, PointSet simplify/pointlist_self_simplify.simp | needs PointList, PointSet simplify/pointlist_unc_fillfactor_merge.map | needs Box, PointList, PointSet simplify/pointlist_unc_fillfactor_merge.simp | needs Box, PointList, PointSet -simplify/rate_inner_reduce_lone.map | needs RateMap -simplify/rate_inner_reduce_lone.simp | needs RateMap -simplify/rate_inner_reduce_series.map | needs RateMap -simplify/rate_inner_reduce_series.simp | needs RateMap -simplify/ratemap_inverse_cancel.map | needs RateMap -simplify/ratemap_simplify_interior.map | needs RateMap -simplify/ratemap_simplify_interior.simp | needs RateMap simplify/regbasepick_circle_permaxes.map | needs Circle, PointSet simplify/regbasepick_circle_permaxes.simp | needs Circle, PointSet simplify/regbasepick_cmpregion_subset.map | needs CmpRegion, Interval, PointSet @@ -308,41 +174,11 @@ simplify/setunc_unitmap_regionfs_omitted.map | needs Box, PointSet simplify/setunc_unitmap_regionfs_omitted.simp | needs Box, PointSet simplify/simpstab_box_linear_unc.map | needs Box, PointSet simplify/simpstab_box_linear_unc.simp | needs Box, PointSet -simplify/simpstab_box_nonlinear_unc.map | needs Box, MathMap, PointSet -simplify/simpstab_box_nonlinear_unc.simp | needs Box, MathMap, PointSet +simplify/simpstab_box_nonlinear_unc.map | needs Box, PointSet +simplify/simpstab_box_nonlinear_unc.simp | needs Box, PointSet simplify/simpstab_permmap_slice_unc.map | needs Box, PointSet simplify/simpstab_permmap_slice_unc.simp | needs Box, PointSet simplify/spline_inverse_cancel.map | needs SplineMap -simplify/switchmap_fwdonly_simplify.map | needs SwitchMap -simplify/switchmap_fwdonly_simplify.simp | needs SwitchMap -simplify/switchmap_internal_simplify.map | needs SwitchMap -simplify/switchmap_internal_simplify.simp | needs SwitchMap -simplify/switchmap_inv_fwdonly.map | needs SwitchMap -simplify/switchmap_inv_fwdonly.simp | needs SwitchMap -simplify/switchmap_inv_invonly.map | needs SwitchMap -simplify/switchmap_inv_invonly.simp | needs SwitchMap -simplify/switchmap_inverse_cancel_tail.map | needs SwitchMap -simplify/switchmap_inverse_cancel.map | needs SwitchMap -simplify/switchmap_invert_normalize.map | needs SwitchMap -simplify/switchmap_invert_normalize.simp | needs SwitchMap -simplify/switchmap_invonly_simplify.map | needs SwitchMap -simplify/switchmap_invonly_simplify.simp | needs SwitchMap -simplify/tranmap_adjacent_merge.map | needs TranMap -simplify/tranmap_adjacent_merge.simp | needs TranMap -simplify/tranmap_component_simplify.map | needs TranMap -simplify/tranmap_component_simplify.simp | needs TranMap -simplify/tranmap_equal_components_in_list.map | needs TranMap -simplify/tranmap_equal_components.map | needs TranMap -simplify/tranmap_invert_in_list.map | needs TranMap -simplify/tranmap_invert_in_list.simp | needs TranMap -simplify/tranmap_invert_normalize.map | needs TranMap -simplify/tranmap_invert_normalize.simp | needs TranMap -simplify/tranmap_merge_tail.map | needs TranMap -simplify/tranmap_merge_tail.simp | needs TranMap -simplify/unit_parallel_invert_clear.map | needs MathMap -simplify/unit_parallel_invert_clear.simp | needs MathMap -simplify/unit_parallel_invert_pcd.map | needs PcdMap -simplify/unit_parallel_invert_pcd.simp | needs PcdMap 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 @@ -361,8 +197,4 @@ 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/framesets/freq-log-head.ast | needs MathMap -wcsconv/framesets/grism-head.ast | needs GrismMap -wcsconv/framesets/polco-head.ast | needs MathMap -wcsconv/framesets/polco2-head.ast | needs MathMap wcsconv/inputs/lsst2.ast | needs SplineMap diff --git a/src/test/resources/deferred/headers.txt b/src/test/resources/deferred/headers.txt index 4c2413d..41d9e81 100644 --- a/src/test/resources/deferred/headers.txt +++ b/src/test/resources/deferred/headers.txt @@ -1,7 +1,3 @@ # Fixtures of fixtures/oracle/headers.oracle whose sections do not all match C: # | # Rewritten by TransformOracleTest with -Dast.writeDeferred=true. -wcsconv/inputs/freq-log.head | needs MathMap -wcsconv/inputs/grism.head | needs GrismMap -wcsconv/inputs/polco.head | needs MathMap -wcsconv/inputs/polco2.head | needs MathMap diff --git a/src/test/resources/deferred/read-warnings.txt b/src/test/resources/deferred/read-warnings.txt index 8c9b191..cbd463c 100644 --- a/src/test/resources/deferred/read-warnings.txt +++ b/src/test/resources/deferred/read-warnings.txt @@ -1,12 +1,9 @@ # Native fixtures whose reads through a Channel differ from C's: # ./ | # Rewritten by FixtureReadWarningsOracleTest with -Dast.writeDeferred=true. -./programs/testcmpmap/splittest1.ast | needs LutMap -./programs/testfitschan/sparse.ast | needs LutMap ./programs/testmocchan/backcompat_json.ast | needs MocChan ./programs/testmocchan/backcompat_string.ast | needs MocChan ./programs/teststcschan/stcschan-test1-doc3.ast | needs Box, Circle, PointList, PointSet, Prism -./serialisation/c_dssmap.ast | needs DssMap ./serialisation/region_in_cmpframe.ast | needs Box, PointSet ./simplify/box_nullregion_merge.map | needs Box, NullRegion, PointSet ./simplify/box_nullregion_merge.simp | needs Interval, PointSet @@ -18,8 +15,6 @@ ./simplify/box_self_simplify.simp | needs Box, PointSet ./simplify/box_unc_fillfactor_merge.map | needs Box, PointSet ./simplify/box_unc_fillfactor_merge.simp | needs Box, PointSet -./simplify/brad.map | needs LutMap -./simplify/brad.simp | needs LutMap ./simplify/cap_box_permmap_const.map | needs Box, PointSet ./simplify/cap_box_permmap_const.simp | needs Box, PointSet ./simplify/cap_box_permmap_nonbidi.map | needs Box, PointSet @@ -29,21 +24,8 @@ ./simplify/cap_box_permmap_null_first.simp | needs NullRegion ./simplify/cap_cheby_consolidate.map | needs ChebyMap ./simplify/cap_cheby_consolidate.simp | needs ChebyMap -./simplify/cap_cmpmap_01.map | needs MathMap, RateMap, TranMap -./simplify/cap_cmpmap_01.simp | needs MathMap, RateMap, TranMap -./simplify/cap_cmpmap_02.map | needs MathMap -./simplify/cap_cmpmap_02.simp | needs MathMap -./simplify/cap_cmpmap_04.map | needs MathMap, RateMap, TranMap -./simplify/cap_cmpmap_04.simp | needs MathMap, RateMap, TranMap -./simplify/cap_cmpperm_resume.map | needs MathMap -./simplify/cap_cmpperm_resume.simp | needs MathMap -./simplify/cap_cmpperm_resume_inv.map | needs MathMap -./simplify/cap_cmpperm_resume_inv.simp | needs MathMap ./simplify/cap_interval_01.map | needs Box, Interval, NullRegion, PointSet, Prism ./simplify/cap_interval_01.simp | needs Box, Interval, PointSet -./simplify/cap_lutmap_01.map | needs LutMap, MathMap -./simplify/cap_lutmap_01.simp | needs MathMap -./simplify/cap_mathmap_01.map | needs MathMap ./simplify/cap_matrixmap_04.map | needs ChebyMap ./simplify/cap_normmap_cmpframe.map | needs NormMap ./simplify/cap_normmap_cmpframe.simp | needs NormMap @@ -53,23 +35,16 @@ ./simplify/cap_pointlist_01.simp | needs Box, PointList, PointSet, Prism ./simplify/cap_pointlist_02.map | needs Interval, PointList, PointSet, Prism ./simplify/cap_pointlist_02.simp | needs PointList, PointSet -./simplify/cap_poly_bend_allowed.map | needs Box, MathMap, PointSet, Polygon -./simplify/cap_poly_bend_allowed.simp | needs Box, MathMap, PointSet, Polygon -./simplify/cap_poly_bent_edges.map | needs Box, MathMap, PointSet, Polygon -./simplify/cap_poly_bent_edges.simp | needs Box, MathMap, PointSet, Polygon +./simplify/cap_poly_bend_allowed.map | needs Box, PointSet, Polygon +./simplify/cap_poly_bend_allowed.simp | needs Box, PointSet, Polygon +./simplify/cap_poly_bent_edges.map | needs Box, PointSet, Polygon +./simplify/cap_poly_bent_edges.simp | needs Box, PointSet, Polygon ./simplify/cap_poly_unc_frame.map | needs Box, PointSet, Polygon ./simplify/cap_poly_unc_frame.simp | needs Box, PointSet, Polygon -./simplify/cap_restricted_component_flags.map | needs MathMap -./simplify/cap_restricted_component_flags.simp | needs MathMap ./simplify/cap_slamap_02.map | needs Box, PointSet ./simplify/cap_slamap_02.simp | needs Box, PointSet, Polygon, Prism ./simplify/cap_slamap_07.map | needs Box, Circle, CmpRegion, PointSet ./simplify/cap_slamap_07.simp | needs NullRegion -./simplify/cap_specmap_02.map | needs LutMap -./simplify/cap_specmap_02.simp | needs LutMap -./simplify/cap_specmap_09.map | needs LutMap -./simplify/cap_specmap_14.map | needs MathMap -./simplify/cap_specmap_14.simp | needs MathMap ./simplify/cap_timemap_02.map | needs Box, Interval, PointSet, StcResourceProfile ./simplify/cap_timemap_02.simp | needs Box, Interval, PointSet, StcResourceProfile ./simplify/cap_unitnormmap_01.map | needs UnitNormMap @@ -77,33 +52,18 @@ ./simplify/cap_xphmap_01.map | needs XphMap ./simplify/cap_xphmap_02.map | needs XphMap ./simplify/cap_xphmap_02.simp | needs XphMap -./simplify/cap_zoommap_04.map | needs Box, MathMap, PointList, PointSet +./simplify/cap_zoommap_04.map | needs Box, PointList, PointSet ./simplify/cap_zoommap_04.simp | needs Box, PointList, PointSet ./simplify/cefit_circle_conformal.map | needs Circle, PointSet ./simplify/cefit_circle_conformal.simp | needs Circle, PointSet -./simplify/cefit_circle_nonconformal_keep.map | needs Circle, MathMap, PointSet -./simplify/cefit_circle_nonconformal_keep.simp | needs Circle, MathMap, PointSet +./simplify/cefit_circle_nonconformal_keep.map | needs Circle, PointSet +./simplify/cefit_circle_nonconformal_keep.simp | needs Circle, PointSet ./simplify/cefit_circle_to_ellipse.map | needs Ellipse, PointSet ./simplify/cefit_circle_to_ellipse.simp | needs Ellipse, PointSet ./simplify/cefit_ellipse_to_circle.map | needs Circle, PointSet ./simplify/cefit_ellipse_to_circle.simp | needs Circle, PointSet ./simplify/cheby_linear_lone_reduce.map | needs ChebyMap ./simplify/chebymap_inverse_cancel.map | needs ChebyMap -./simplify/cmpmap_decompose_middle.map | needs MathMap -./simplify/cmpmap_decompose_middle.simp | needs MathMap -./simplify/cmpmap_inverted_nested.map | needs MathMap -./simplify/cmpmap_inverted_nested.simp | needs MathMap -./simplify/cmpmap_parallel_in_series_merge.map | needs MathMap -./simplify/cmpmap_parallel_series_dim_mismatch.map | needs MathMap -./simplify/cmpmap_parallel_series_dim_mismatch.simp | needs MathMap -./simplify/cmpmap_perm_swap_aconstants.map | needs MathMap -./simplify/cmpmap_perm_swap_aconstants.simp | needs MathMap -./simplify/cmpmap_perm_swap_bconstants.map | needs MathMap -./simplify/cmpmap_perm_swap_bconstants.simp | needs MathMap -./simplify/cmpmap_series_in_parallel_inverted.map | needs MathMap -./simplify/cmpmap_series_in_parallel_inverted.simp | needs MathMap -./simplify/cmpmap_solo_after_unit.map | needs MathMap -./simplify/cmpmap_solo_after_unit.simp | needs MathMap ./simplify/defunc_cmpregion_component_unc.map | needs Box, PointSet ./simplify/defunc_cmpregion_component_unc.simp | needs Box, PointSet ./simplify/defunc_interval_point_at_origin.map | needs Box, PointSet @@ -116,20 +76,6 @@ ./simplify/defunc_pointlist_origin_axis.simp | needs Box, PointSet ./simplify/defunc_prism_box_interval.map | needs Box, PointSet, Prism ./simplify/defunc_prism_box_interval.simp | needs Box, PointSet -./simplify/dssmap_inv_winmap_absorb.map | needs DssMap -./simplify/dssmap_inv_winmap_absorb.simp | needs DssMap -./simplify/dssmap_winmap_absorb.map | needs DssMap -./simplify/dssmap_winmap_absorb.simp | needs DssMap -./simplify/dssmap_zoom_no_merge.map | needs DssMap -./simplify/dssmap_zoom_no_merge.simp | needs DssMap -./simplify/fitschan_tab_spectral.map | needs LutMap -./simplify/fitschan_tab_spectral.simp | needs LutMap -./simplify/grism_inverse_cancel.map | needs GrismMap -./simplify/grism_inverse_cancel_tail.map | needs GrismMap -./simplify/grism_zoom_inv_merge.map | needs GrismMap -./simplify/grism_zoom_inv_merge.simp | needs GrismMap -./simplify/grism_zoom_merge.map | needs GrismMap -./simplify/grism_zoom_merge.simp | needs GrismMap ./simplify/interval_halfinf_simplify.map | needs Interval, PointSet ./simplify/interval_nullregion_merge.map | needs Interval, NullRegion, PointSet ./simplify/interval_nullregion_merge.simp | needs Interval, PointSet @@ -144,13 +90,6 @@ ./simplify/interval_self_simplify_cmp.simp | needs Box, PointSet ./simplify/interval_unc_fillfactor_merge.map | needs Box, Interval, PointSet ./simplify/interval_unc_fillfactor_merge.simp | needs Box, Interval, PointSet -./simplify/intra_invfwd_cancel.map | needs IntraMap -./simplify/intra_invfwd_cancel_tail.map | needs IntraMap -./simplify/intramap_inverse_cancel.map | needs IntraMap -./simplify/lut_exactly_linear.map | needs LutMap -./simplify/lut_inverse_cancel.map | needs LutMap -./simplify/lut_linear_to_win.map | needs LutMap -./simplify/math_inverse_cancel.map | needs MathMap ./simplify/merge_box_fillfactor_product.map | needs Box, PointSet ./simplify/merge_box_fillfactor_product.simp | needs Box, PointSet ./simplify/merge_box_meshsize_scaled.map | needs Box, PointSet @@ -164,35 +103,9 @@ ./simplify/neg_cheby_quadratic_no_reduce.map | needs ChebyMap ./simplify/neg_chebymap_standalone.map | needs ChebyMap ./simplify/neg_circle_cmpframe_sky_second.map | needs Circle, PointSet -./simplify/neg_cmpmap_mode_mismatch.map | needs MathMap -./simplify/neg_cmpmap_neighbour_nonexcmpmap.map | needs MathMap -./simplify/neg_grism_different_attrs.map | needs GrismMap -./simplify/neg_grism_fwd_then_nonzoom.map | needs GrismMap -./simplify/neg_grism_inv_then_zoom.map | needs GrismMap -./simplify/neg_grism_nonzoom_before_inv.map | needs GrismMap -./simplify/neg_grism_parallel.map | needs GrismMap -./simplify/neg_grism_same_direction.map | needs GrismMap -./simplify/neg_grism_zoom_before_fwd.map | needs GrismMap ./simplify/neg_interval_parallel_nonregion.map | needs Interval, PointSet ./simplify/neg_interval_series.map | needs Interval, PointSet ./simplify/neg_interval_unbounded_pointlist.map | needs Interval, PointList, PointSet -./simplify/neg_intra_diff_flag.map | needs IntraMap -./simplify/neg_intra_diff_func.map | needs IntraMap -./simplify/neg_intra_no_simpfi.map | needs IntraMap -./simplify/neg_intra_no_simpif.map | needs IntraMap -./simplify/neg_intra_nonintra_neighbour.map | needs IntraMap -./simplify/neg_intra_parallel.map | needs IntraMap -./simplify/neg_intra_same_direction.map | needs IntraMap -./simplify/neg_lut_constant.map | needs LutMap -./simplify/neg_lut_different_tables.map | needs LutMap -./simplify/neg_lut_near_linear.map | needs LutMap -./simplify/neg_lut_nonlinear.map | needs LutMap -./simplify/neg_lut_nonlut_neighbour.map | needs LutMap -./simplify/neg_lut_parallel.map | needs LutMap -./simplify/neg_math_inv_text_mismatch.map | needs MathMap -./simplify/neg_math_lone.map | needs MathMap -./simplify/neg_math_no_simpfi.map | needs MathMap -./simplify/neg_math_nonmath_neighbour.map | needs MathMap ./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 @@ -201,25 +114,8 @@ ./simplify/neg_normmap_parallel_sky.map | needs NormMap ./simplify/neg_nullregion_parallel_nonregion.map | needs NullRegion ./simplify/neg_nullregion_series.map | needs NullRegion -./simplify/neg_parpair_aligned_irreducible.map | needs MathMap -./simplify/neg_pcd_diff_centre.map | needs PcdMap -./simplify/neg_pcd_diff_disco.map | needs PcdMap -./simplify/neg_pcd_nonpcd_neighbour.map | needs PcdMap -./simplify/neg_pcd_nonswappable_between.map | needs PcdMap -./simplify/neg_pcd_parallel.map | needs PcdMap -./simplify/neg_pcd_perm_nonswap.map | needs PcdMap -./simplify/neg_pcd_same_invert.map | needs PcdMap -./simplify/neg_pcd_zoom_no_target.map | needs PcdMap -./simplify/neg_perm_no_merge.map | needs MathMap ./simplify/neg_pointlist_parallel_nonregion.map | needs PointList, PointSet ./simplify/neg_pointlist_series.map | needs PointList, PointSet -./simplify/neg_ratemap_diff_indices.map | needs RateMap -./simplify/neg_ratemap_diff_inner.map | needs RateMap -./simplify/neg_ratemap_different_inner.map | needs RateMap -./simplify/neg_ratemap_lower_nonrate.map | needs RateMap -./simplify/neg_ratemap_nonratemap_neighbour.map | needs RateMap -./simplify/neg_ratemap_parallel.map | needs RateMap -./simplify/neg_ratemap_same_invert.map | needs RateMap ./simplify/neg_selectormap_not_equal.map | needs Box, PointSet, SelectorMap ./simplify/neg_selectormap_parallel.map | needs Box, PointSet, SelectorMap ./simplify/neg_selectormap_series_lower.map | needs Box, PointSet, SelectorMap @@ -228,16 +124,6 @@ ./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_switchmap_not_equal.map | needs SwitchMap -./simplify/neg_switchmap_parallel.map | needs SwitchMap -./simplify/neg_switchmap_series.map | needs SwitchMap -./simplify/neg_switchmap_series_lower.map | needs SwitchMap -./simplify/neg_tranmap_adjacent_no_merge.map | needs MathMap, TranMap -./simplify/neg_tranmap_nontranmap_neighbour.map | needs TranMap -./simplify/neg_tranmap_oneway.map | needs MathMap, TranMap -./simplify/neg_tranmap_parallel.map | needs TranMap -./simplify/neg_tranmap_unequal_components.map | needs TranMap -./simplify/neg_unit_parallel_forward.map | needs PcdMap ./simplify/neg_unitnormmap_flanked.map | needs UnitNormMap ./simplify/neg_unitnormmap_fwd_shift.map | needs UnitNormMap ./simplify/neg_unitnormmap_inv_fwd_diffcentre.map | needs UnitNormMap @@ -246,13 +132,9 @@ ./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_wcs_nonperm_between.map | needs MathMap -./simplify/neg_win_cmpmap_split_no_simplify.map | needs MathMap -./simplify/neg_win_nonmergeable_series.map | needs MathMap ./simplify/neg_xph_nonxph_neighbour.map | needs XphMap ./simplify/neg_xph_not_opposite.map | needs XphMap ./simplify/neg_xph_parallel.map | needs XphMap -./simplify/neg_zoom_parallel_lone.map | needs MathMap ./simplify/normmap_basic_frame_to_unit.map | needs NormMap ./simplify/normmap_duplicate_elim.map | needs NormMap ./simplify/normmap_duplicate_elim.simp | needs NormMap @@ -268,40 +150,12 @@ ./simplify/nullregion_self_simplify.simp | needs NullRegion ./simplify/nullregion_unc_fillfactor_merge.map | needs Box, NullRegion, PointSet ./simplify/nullregion_unc_fillfactor_merge.simp | needs Box, NullRegion, PointSet -./simplify/parcomp_inverted_nested_reemitted.map | needs MathMap -./simplify/parcomp_inverted_nested_reemitted.simp | needs MathMap -./simplify/parcomp_inverted_reemitted.map | needs MathMap -./simplify/parcomp_inverted_reemitted.simp | needs MathMap -./simplify/parpair_one_side_reduces.map | needs MathMap -./simplify/parpair_one_side_reduces.simp | needs MathMap -./simplify/pcd_inverse_cancel.map | needs PcdMap -./simplify/pcd_inverse_cancel_tail.map | needs PcdMap -./simplify/pcd_inverted_zoom_swap.map | needs PcdMap -./simplify/pcd_inverted_zoom_swap.simp | needs PcdMap -./simplify/pcd_perm_swap_cancel.map | needs PcdMap -./simplify/pcd_search_blocked.map | needs PcdMap -./simplify/pcd_search_blocked.simp | needs PcdMap -./simplify/pcd_swap_zoom_simplifies.map | needs PcdMap -./simplify/pcd_swap_zoom_simplifies.simp | needs PcdMap -./simplify/pcd_unit_series_merge.map | needs PcdMap -./simplify/pcd_unit_series_merge.simp | needs PcdMap -./simplify/pcd_zero_disc_lone.map | needs PcdMap -./simplify/pcd_zero_disc_series.map | needs PcdMap -./simplify/pcd_zero_to_unit.map | needs PcdMap -./simplify/pcd_zoom_swap_cancel.map | needs PcdMap ./simplify/pointlist_parallel_merge_pair.map | needs PointList, PointSet ./simplify/pointlist_parallel_merge_pair.simp | needs PointList, PointSet ./simplify/pointlist_self_simplify.map | needs PointList, PointSet ./simplify/pointlist_self_simplify.simp | needs PointList, PointSet ./simplify/pointlist_unc_fillfactor_merge.map | needs Box, PointList, PointSet ./simplify/pointlist_unc_fillfactor_merge.simp | needs Box, PointList, PointSet -./simplify/rate_inner_reduce_lone.map | needs RateMap -./simplify/rate_inner_reduce_lone.simp | needs RateMap -./simplify/rate_inner_reduce_series.map | needs RateMap -./simplify/rate_inner_reduce_series.simp | needs RateMap -./simplify/ratemap_inverse_cancel.map | needs RateMap -./simplify/ratemap_simplify_interior.map | needs RateMap -./simplify/ratemap_simplify_interior.simp | needs RateMap ./simplify/regbasepick_circle_permaxes.map | needs Circle, PointSet ./simplify/regbasepick_circle_permaxes.simp | needs Circle, PointSet ./simplify/regbasepick_cmpregion_subset.map | needs CmpRegion, Interval, PointSet @@ -322,46 +176,11 @@ ./simplify/setunc_unitmap_regionfs_omitted.simp | needs Box, PointSet ./simplify/simpstab_box_linear_unc.map | needs Box, PointSet ./simplify/simpstab_box_linear_unc.simp | needs Box, PointSet -./simplify/simpstab_box_nonlinear_unc.map | needs Box, MathMap, PointSet -./simplify/simpstab_box_nonlinear_unc.simp | needs Box, MathMap, PointSet +./simplify/simpstab_box_nonlinear_unc.map | needs Box, PointSet +./simplify/simpstab_box_nonlinear_unc.simp | needs Box, PointSet ./simplify/simpstab_permmap_slice_unc.map | needs Box, PointSet ./simplify/simpstab_permmap_slice_unc.simp | needs Box, PointSet ./simplify/spline_inverse_cancel.map | needs SplineMap -./simplify/switchmap_fwdonly_simplify.map | needs SwitchMap -./simplify/switchmap_fwdonly_simplify.simp | needs SwitchMap -./simplify/switchmap_internal_simplify.map | needs SwitchMap -./simplify/switchmap_internal_simplify.simp | needs SwitchMap -./simplify/switchmap_inv_fwdonly.map | needs SwitchMap -./simplify/switchmap_inv_fwdonly.simp | needs SwitchMap -./simplify/switchmap_inv_invonly.map | needs SwitchMap -./simplify/switchmap_inv_invonly.simp | needs SwitchMap -./simplify/switchmap_inverse_cancel.map | needs SwitchMap -./simplify/switchmap_inverse_cancel_distinct_selectors.map | needs MathMap, SwitchMap -./simplify/switchmap_inverse_cancel_tail.map | needs SwitchMap -./simplify/switchmap_invert_normalize.map | needs SwitchMap -./simplify/switchmap_invert_normalize.simp | needs SwitchMap -./simplify/switchmap_invonly_simplify.map | needs SwitchMap -./simplify/switchmap_invonly_simplify.simp | needs SwitchMap -./simplify/tranmap_adjacent_merge.map | needs TranMap -./simplify/tranmap_adjacent_merge.simp | needs TranMap -./simplify/tranmap_adjacent_merge_inverse_order.map | needs TranMap -./simplify/tranmap_adjacent_merge_inverse_order.simp | needs TranMap -./simplify/tranmap_adjacent_merge_nonsquare.map | needs TranMap -./simplify/tranmap_adjacent_merge_nonsquare.simp | needs TranMap -./simplify/tranmap_component_simplify.map | needs TranMap -./simplify/tranmap_component_simplify.simp | needs TranMap -./simplify/tranmap_equal_components.map | needs TranMap -./simplify/tranmap_equal_components_in_list.map | needs TranMap -./simplify/tranmap_invert_in_list.map | needs TranMap -./simplify/tranmap_invert_in_list.simp | needs TranMap -./simplify/tranmap_invert_normalize.map | needs TranMap -./simplify/tranmap_invert_normalize.simp | needs TranMap -./simplify/tranmap_merge_tail.map | needs TranMap -./simplify/tranmap_merge_tail.simp | needs TranMap -./simplify/unit_parallel_invert_clear.map | needs MathMap -./simplify/unit_parallel_invert_clear.simp | needs MathMap -./simplify/unit_parallel_invert_pcd.map | needs PcdMap -./simplify/unit_parallel_invert_pcd.simp | needs PcdMap ./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 @@ -380,8 +199,4 @@ ./simplify/unitnormmap_winmap_inv_refused.map | needs UnitNormMap ./simplify/unitnormmap_winmap_inv_refused.simp | needs UnitNormMap ./simplify/xph_inverse_cancel.map | needs XphMap -./wcsconv/framesets/freq-log-head.ast | needs MathMap -./wcsconv/framesets/grism-head.ast | needs GrismMap -./wcsconv/framesets/polco-head.ast | needs MathMap -./wcsconv/framesets/polco2-head.ast | needs MathMap ./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 c7e8302..40caac4 100644 --- a/src/test/resources/deferred/rust-tests.txt +++ b/src/test/resources/deferred/rust-tests.txt @@ -9,8 +9,6 @@ tests/error_model.rs::new_has_no_location | Rust-only API (AstError source locat tests/test_keymap_serial.rs::the_c_fixture_keymap_round_trips | Box (Region, out of scope) tests/test_keymap_serial.rs::the_c_fixture_map_sz_matches | Box (Region, out of scope) 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_lutmap | LutMap (out of scope) -tests/test_nan_protocol.rs::nan_protocol_grismmap | GrismMap (out of scope) 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) @@ -18,6 +16,38 @@ tests/test_bulk_kernels.rs::unitnormmap_kernel_keeps_each_points_state_across_bl 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 and NullRegion (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) @@ -46,137 +76,31 @@ 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_matrixmap.rs::an_inverted_non_square_matrixmap_equals_its_copy | astEqual (out-of-scope method) -tests/test_permmap.rs::perm_equal_same_constant_index_differing_values | astEqual (out-of-scope method) -tests/test_permmap.rs::perm_equal_same_constant_index_same_value | astEqual (out-of-scope method) -tests/test_permmap.rs::perm_equal_different_index_same_referenced_value | astEqual (out-of-scope method) -tests/test_permmap.rs::perm_equal_different_index_different_referenced_value | astEqual (out-of-scope method) -tests/test_permmap.rs::perm_equal_ignores_unreferenced_surplus_constants | astEqual (out-of-scope method) -tests/test_cmpmap.rs::series_inverse_pair_of_mathmaps_cancels_to_unitmap | MathMap (out of scope) -tests/test_cmpmap.rs::parallel_with_inverted_cmpmap_child_canonicalises_for_serialisation | MathMap (out of scope) -tests/test_cmpmap.rs::cmpmap_equality_compares_components_as_applied | astEqual (out-of-scope method) -tests/test_constructor_checks.rs::a_tranmap_needs_its_two_directions | TranMap and RateMap (out of scope) -tests/test_constructor_checks.rs::a_switchmap_selector_needs_its_direction | SwitchMap and RateMap (out of scope) 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_constructor_checks.rs::a_selectormap_needs_regions_in_one_frame | SelectorMap and Circle (out of scope) -tests/test_constructor_checks.rs::a_mathmap_needs_a_function_per_output | MathMap (out of scope) -tests/test_mapping_load.rs::a_dssmap_dump_needs_its_plate_solution | DssMap (out of scope) -tests/test_equal.rs::float_tolerance_within | astEqual (out-of-scope method) -tests/test_equal.rs::float_tolerance_outside | astEqual (out-of-scope method) -tests/test_equal.rs::bad_value_comparison | astEqual (out-of-scope method) -tests/test_equal.rs::bad_vs_non_bad_same_index_is_not_equal | astEqual (out-of-scope method) -tests/test_equal.rs::bad_vs_non_bad_different_index_is_not_equal | astEqual (out-of-scope method) -tests/test_equal.rs::unitmap_identity | astEqual (out-of-scope method) -tests/test_equal.rs::unitmap_same_ncoord | astEqual (out-of-scope method) -tests/test_equal.rs::unitmap_different_ncoord | astEqual (out-of-scope method) -tests/test_equal.rs::zoommap_identity | astEqual (out-of-scope method) -tests/test_equal.rs::zoommap_same_values | astEqual (out-of-scope method) -tests/test_equal.rs::zoommap_different_factor | astEqual (out-of-scope method) -tests/test_equal.rs::zoommap_different_ncoord | astEqual (out-of-scope method) -tests/test_equal.rs::zoommap_invert_aware | astEqual (out-of-scope method) -tests/test_equal.rs::zoommap_invert_aware_mismatch | astEqual (out-of-scope method) -tests/test_equal.rs::shiftmap_identity | astEqual (out-of-scope method) -tests/test_equal.rs::shiftmap_same_values | astEqual (out-of-scope method) -tests/test_equal.rs::shiftmap_different_shifts | astEqual (out-of-scope method) -tests/test_equal.rs::shiftmap_different_length | astEqual (out-of-scope method) -tests/test_equal.rs::shiftmap_invert_aware | astEqual (out-of-scope method) -tests/test_equal.rs::shiftmap_invert_aware_mismatch | astEqual (out-of-scope method) -tests/test_equal.rs::matrixmap_same | astEqual (out-of-scope method) -tests/test_equal.rs::matrixmap_different_element | astEqual (out-of-scope method) -tests/test_equal.rs::matrixmap_inverted_not_equal | astEqual (out-of-scope method) -tests/test_equal.rs::permmap_same | astEqual (out-of-scope method) -tests/test_equal.rs::permmap_different_perm | astEqual (out-of-scope method) -tests/test_equal.rs::permmap_equal_cross_inversion | astEqual (out-of-scope method) -tests/test_equal.rs::winmap_same | astEqual (out-of-scope method) -tests/test_equal.rs::winmap_different_scale | astEqual (out-of-scope method) -tests/test_equal.rs::winmap_inverted_not_equal | astEqual (out-of-scope method) -tests/test_equal.rs::winmap_equal_cross_inversion | astEqual (out-of-scope method) -tests/test_equal.rs::cmpmap_series_same | astEqual (out-of-scope method) -tests/test_equal.rs::cmpmap_different_component | astEqual (out-of-scope method) -tests/test_equal.rs::cmpmap_different_kind | astEqual (out-of-scope method) -tests/test_equal.rs::polymap_same | astEqual (out-of-scope method) -tests/test_equal.rs::polymap_different_coeff | astEqual (out-of-scope method) -tests/test_equal.rs::chebymap_same | astEqual (out-of-scope method) -tests/test_equal.rs::chebymap_different_bounds | astEqual (out-of-scope method) -tests/test_equal.rs::lutmap_same | astEqual (out-of-scope method) -tests/test_equal.rs::lutmap_different_values | astEqual (out-of-scope method) -tests/test_equal.rs::lutmap_different_start | astEqual (out-of-scope method) -tests/test_equal.rs::wcsmap_same | astEqual (out-of-scope method) -tests/test_equal.rs::wcsmap_different_proj | astEqual (out-of-scope method) -tests/test_equal.rs::wcsmap_different_axes | astEqual (out-of-scope method) -tests/test_equal.rs::slamap_same | astEqual (out-of-scope method) -tests/test_equal.rs::slamap_different_type | astEqual (out-of-scope method) -tests/test_equal.rs::slamap_different_args | astEqual (out-of-scope method) -tests/test_equal.rs::sphmap_same | astEqual (out-of-scope method) -tests/test_equal.rs::sphmap_different_polar_long | astEqual (out-of-scope method) -tests/test_equal.rs::sphmap_different_unit_radius | astEqual (out-of-scope method) -tests/test_equal.rs::sphmap_inverted | astEqual (out-of-scope method) -tests/test_equal.rs::cmpmap_equal_different_tree_structure | astEqual (out-of-scope method) -tests/test_equal.rs::cross_type_zoom_vs_shift | astEqual (out-of-scope method) -tests/test_equal.rs::cross_type_unit_vs_zoom | astEqual (out-of-scope method) -tests/test_equal.rs::cross_type_winmap_vs_shiftmap | astEqual (out-of-scope method) -tests/test_equal.rs::basicframe_same | astEqual (out-of-scope method) -tests/test_equal.rs::basicframe_different_naxes | astEqual (out-of-scope method) -tests/test_equal.rs::basicframe_different_title_is_equal | astEqual (out-of-scope method) -tests/test_equal.rs::basicframe_different_domain | astEqual (out-of-scope method) -tests/test_equal.rs::basicframe_different_epoch_is_equal | astEqual (out-of-scope method) -tests/test_equal.rs::basicframe_epoch_set_vs_unset_is_equal | astEqual (out-of-scope method) -tests/test_equal.rs::basicframe_different_labels_is_equal | astEqual (out-of-scope method) -tests/test_equal.rs::cmpframe_same | astEqual (out-of-scope method) -tests/test_equal.rs::cmpframe_different_child | astEqual (out-of-scope method) -tests/test_equal.rs::skyframe_same | astEqual (out-of-scope method) -tests/test_equal.rs::skyframe_different_system | astEqual (out-of-scope method) -tests/test_equal.rs::skyframe_different_equinox | astEqual (out-of-scope method) -tests/test_equal.rs::skyframe_equinox_set_vs_unset_default_is_equal | astEqual (out-of-scope method) -tests/test_equal.rs::skyframe_different_epoch | astEqual (out-of-scope method) -tests/test_equal.rs::skyframe_sky_ref_is_origin_without_sky_ref_is_equal | astEqual (out-of-scope method) -tests/test_equal.rs::skyframe_offset_origin_with_sky_ref_is_not_equal | astEqual (out-of-scope method) -tests/test_equal.rs::skyframe_sky_ref_without_sky_ref_is_is_equal | astEqual (out-of-scope method) -tests/test_equal.rs::skyframe_different_neglon_is_equal | astEqual (out-of-scope method) -tests/test_equal.rs::skyframe_different_title_is_equal | astEqual (out-of-scope method) -tests/test_equal.rs::cross_type_skyframe_vs_basicframe | astEqual (out-of-scope method) -tests/test_equal.rs::cross_type_basicframe_vs_skyframe | astEqual (out-of-scope method) -tests/test_equal.rs::frameset_same | astEqual (out-of-scope method) -tests/test_equal.rs::frameset_different_mapping | astEqual (out-of-scope method) -tests/test_equal.rs::serialise_round_trip_zoommap | astEqual (out-of-scope method) -tests/test_equal.rs::serialise_round_trip_shiftmap | astEqual (out-of-scope method) -tests/test_equal.rs::serialise_round_trip_skyframe | astEqual (out-of-scope method) -tests/test_equal.rs::matrixmap_equal_cross_inversion | astEqual (out-of-scope method) -tests/test_equal_oracle.rs::equality_matches_the_c_library | astEqual (out-of-scope method) -tests/test_equal_oracle.rs::wcsmap_equality_is_symmetric_where_c_checks_it | astEqual (out-of-scope method) -tests/test_trangrid.rs::tranmap | TranMap (out of scope) -tests/test_trangrid.rs::nonlinear_mathmap_1d | MathMap (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_map_split.rs::tranmap_split_picks_per_axis | TranMap (out of scope) -tests/test_map_split.rs::ratemap_split_diff_output_dropped_returns_none | RateMap (out of scope) -tests/test_map_split.rs::ratemap_split_rejects_when_inverted | RateMap (out of scope) -tests/test_map_split.rs::testcmpmap_split_of_splittest1 | LutMap (out of scope) -tests/test_map_split_oracle.rs::issimp_component_exclusions_still_differ | RateMap and TranMap (out of scope) tests/test_tran_definedness.rs::chebymap_forward_only_has_no_inverse | ChebyMap (out of scope) -tests/test_tran_definedness.rs::tranmap_needs_both_directions | TranMap (out of scope) -tests/test_rate.rs::tran_map | TranMap (out of scope) -tests/test_numeric_rate.rs::numeric_rate_tan_at_zero | MathMap (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) -tests/test_rate_oracle.rs::rates_match_the_c_library | RateMap, TranMap and SwitchMap (out of scope) +tests/test_rate_oracle.rs::rates_match_the_c_library | Box (Region, out of scope) +tests/test_region_equal_oracle.rs::equality_and_overlap_match_the_c_library | Box (Region, out of scope) +tests/test_region_nulltran_oracle.rs::transform_matches_the_c_library | NullRegion (Region, 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_native_roundtrip_all.rs::round_trip_lutmap | LutMap (out of scope) +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_pcdmap | PcdMap (out of scope) -tests/test_native_roundtrip_all.rs::round_trip_grismmap | GrismMap (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_tranmap | TranMap (out of scope) -tests/test_native_roundtrip_all.rs::round_trip_ratemap | RateMap (out of scope) tests/test_native_roundtrip_all.rs::round_trip_splinemap | SplineMap (out of scope) -tests/test_native_roundtrip_all.rs::round_trip_mathmap | MathMap (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 @@ -223,39 +147,20 @@ src/wcslib/prj.rs::csc_margin_covers_the_kernels_drift_and_a_zero_margin_does_no src/wcslib/prj.rs::quadcube_slice_builds_agree | hardware SIMD src/mappings/wcsmap.rs::inverse_longitudes_near_a_limit_are_decided_as_per_value | hardware SIMD src/mappings/sphmap.rs::counts_only_the_calls_c_makes | Rust-only API (call counts) -tests/test_wcsmap.rs::wcsmap_equal_different_params | astEqual (out-of-scope method) -tests/test_wcsmap.rs::wcsmap_equal_same_params | astEqual (out-of-scope method) tests/test_polymap.rs::polymap_bad_powers_len_rejected | Rust-only API (PolyTerm power vectors; C's coefficient array has none) -tests/test_polymap.rs::polymap_equal_compares_the_inverse_coefficients | astEqual (out-of-scope method) -tests/test_polymap.rs::polymap_with_more_outputs_than_inputs_equals_its_copy | astEqual (out-of-scope method) tests/test_polymap_simd.rs::simd_falls_back_below_threshold | hardware SIMD tests/test_polymap_simd.rs::simd_inverse_falls_back_below_threshold | hardware SIMD tests/test_slamap.rs::cvt_from_int | Rust-only API (SlaCvtType integer codes) -tests/test_specmap.rs::equality | astEqual (out-of-scope method) -tests/test_specframe.rs::test_equal_same | astEqual (out-of-scope method) -tests/test_specframe.rs::test_not_equal_different_system | astEqual (out-of-scope method) -tests/test_specframe.rs::test_not_equal_different_sor | astEqual (out-of-scope method) tests/test_dsbspecframe.rs::observed_sideband_usb | Rust-only API (DSBSpecFrame::observed_freq) tests/test_dsbspecframe.rs::observed_sideband_lsb | Rust-only API (DSBSpecFrame::observed_freq) tests/test_dsbspecframe.rs::observed_sideband_lo | Rust-only API (DSBSpecFrame::observed_freq) -tests/test_timemap.rs::equality | astEqual (out-of-scope method) tests/test_timemap.rs::cvt_type_codes_match_c | Rust-only API (TimeCvtType integer codes) 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) -src/units/tests.rs::log_hz_to_hz_is_mathmap | MathMap (out of scope) -src/units/tests.rs::sqrt_hz_to_hz_is_mathmap | MathMap (out of scope) -src/units/tests.rs::log_kms_to_ms_is_mathmap | MathMap (out of scope) -src/units/tests.rs::hz_to_log_hz_is_mathmap | MathMap (out of scope) tests/test_basicframe.rs::map_from_returns_unit | Rust-only API (Frame::map_from) -tests/test_frame_equality.rs::basic_frames_differing_only_in_cosmetics_are_equal | astEqual (out-of-scope method) -tests/test_frame_equality.rs::basic_frames_differing_in_domain_are_not_equal | astEqual (out-of-scope method) -tests/test_frame_equality.rs::skyframes_differing_only_in_title_are_equal | astEqual (out-of-scope method) -tests/test_frame_equality.rs::skyframe_explicit_default_domain_equals_unset_domain | astEqual (out-of-scope method) -tests/test_frame_equality.rs::skyframes_differing_in_system_are_not_equal | astEqual (out-of-scope method) tests/test_frame_equality.rs::normmap_pair_over_cosmetically_different_frames_cancels | NormMap (out of scope) tests/test_norm_points.rs::a_circle_mesh_is_normalised_as_c_does | Circle (Region, out of scope) tests/test_frameset.rs::debug_formatting | Rust-only API (Debug) -tests/test_frameset.rs::convert_stops_at_the_first_domain_that_gives_a_conversion | MathMap (out of scope) tests/test_convert.rs::convert_between_regions_does_not_clip | Circle (Region, out of scope) tests/test_frame_in_map_slot.rs::a_region_inside_a_cmpmap_still_reads | Region classes (out of scope) tests/test_frame_in_map_slot.rs::a_region_inside_a_cmpframe_still_reads | Box (Region, out of scope) @@ -264,42 +169,18 @@ tests/test_skyframe.rs::skyframe_is_send | Rust-only API (Send) tests/test_skyframe.rs::debug_formatting | Rust-only API (Debug formatting) tests/test_skyframe.rs::serialise_skyframe_not_a_mapping | Rust-only API (AnyObject::as_mapping; in AST every Frame is a Mapping) tests/test_sky_convert.rs::fk_licences_name_existing_cases | hardware SIMD -tests/test_timeframe.rs::test_equal | astEqual (out-of-scope method) tests/test_timeframe.rs::test_map_from_timescale_change | Rust-only API (Frame::map_from) tests/test_cmpframe.rs::norm_box_probe_carries_bad_on_the_other_components_axes | astNormBox (out-of-scope method) tests/test_cmpframe.rs::norm_box_reaches_the_sky_component | astNormBox (out-of-scope method) tests/test_cmpframe.rs::norm_box_delegates_to_a_second_component_of_a_different_size | astNormBox (out-of-scope method) tests/test_cmpframe.rs::norm_box_reaches_a_sky_second_component | astNormBox (out-of-scope method) tests/test_cmpframe.rs::norm_box_bounds_do_not_depend_on_component_order | Circle (Region, out of scope) -tests/test_frameset_integrity.rs::unit_change_leaves_mappings_alone | LutMap (out of scope) 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::lut_interp_discards_the_record | LutMap (out of scope) -tests/test_clear_on_set.rs::math_simp_fi_discards_the_record | MathMap (out of scope) -tests/test_clear_on_set.rs::math_simp_if_discards_the_record | MathMap (out of scope) -tests/test_clear_on_set.rs::math_seed_discards_the_record | MathMap (out of scope) -tests/test_clear_on_set.rs::clearing_math_seed_discards_the_record | MathMap (out of scope) 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_clear_on_set.rs::lut_epsilon_discards_the_record | LutMap (out of scope) -tests/test_clear_on_set.rs::pcd_disco_discards_the_record | PcdMap (out of scope) -tests/test_clear_on_set.rs::grism_nr_discards_the_record | GrismMap (out of scope) -tests/test_clear_on_set.rs::grism_nrp_discards_the_record | GrismMap (out of scope) -tests/test_clear_on_set.rs::grism_wave_r_discards_the_record | GrismMap (out of scope) -tests/test_clear_on_set.rs::grism_alpha_discards_the_record | GrismMap (out of scope) -tests/test_clear_on_set.rs::grism_g_discards_the_record | GrismMap (out of scope) -tests/test_clear_on_set.rs::grism_m_discards_the_record | GrismMap (out of scope) -tests/test_clear_on_set.rs::grism_eps_discards_the_record | GrismMap (out of scope) -tests/test_clear_on_set.rs::grism_theta_discards_the_record | GrismMap (out of scope) -tests/test_clear_on_set.rs::grism_setters_recompute_the_constants | GrismMap (out of scope) -tests/test_clear_on_set.rs::grism_sentinel_restores_the_default_and_untests_the_attribute | GrismMap (out of scope) -tests/test_clear_on_set.rs::setting_an_unset_seed_to_its_own_default_discards_the_record | MathMap (out of scope) -tests/test_clear_on_set.rs::re_setting_an_explicit_seed_to_the_same_value_keeps_the_record | MathMap (out of scope) -tests/test_fluxframe.rs::test_fluxframe_equal_same | astEqual (out-of-scope method) -tests/test_fluxframe.rs::test_fluxframe_equal_different_system | astEqual (out-of-scope method) -tests/test_fluxframe.rs::test_fluxframe_equal_different_specval_is_equal | astEqual (out-of-scope method) tests/test_channel_dump_oracle.rs::a_clone_shares_the_sink | MocChan (out of scope) tests/test_channel_dump_oracle.rs::a_channel_read_from_a_dump_has_no_source | MocChan (out of scope) 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) @@ -322,19 +203,24 @@ tests/test_serialisation.rs::round_trip_pointlist | PointList (Region, out of sc tests/test_serialisation.rs::round_trip_cmpregion | CmpRegion and Circle (Region, out of scope) tests/test_serialisation.rs::round_trip_prism | Prism, Circle and Interval (Region, out of scope) tests/test_serialisation.rs::round_trip_negated_circle | Circle (Region, out of scope) -tests/test_fitschan_native_keyword.rs::polco_loads | MathMap (out of scope) -tests/test_fitschan_native_keyword.rs::polco2_loads | MathMap (out of scope) -tests/test_fitschan_read.rs::log_suffix_is_stripped_from_the_domain_and_symbol | MathMap (out of scope) 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_c_inline.rs::log_spectral_axis_writes_freq_log | MathMap (out of scope) -tests/test_fitschan_wcs_write.rs::grism_interference_order_survives_a_round_trip | GrismMap (out of scope) -tests/test_fitschan_wcs_write.rs::a_non_linear_grism_axis_writes_a_header_that_reads_back | GrismMap (out of scope) -src/fitschan/fset_to_store/spectral_axes.rs::try_grism_cascade_emits_gri_pv_and_chain | GrismMap (out of scope) 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_wcs_write.rs::a_sip_description_is_rejected_when_it_is_not_linear_over_the_image | MathMap (out of scope) -tests/test_fitschan_encodings.rs::freq_log_builds_log_mapping | MathMap (out of scope) -tests/test_fitschan_encodings.rs::grism_builds_grism_mapping | GrismMap (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 +tests/test_fitschan_tab.rs::check_tab2 | needs FitsTable +tests/test_fitschan_tab.rs::strict_sweep_error_asks_no_table_source | needs FitsTable +tests/test_switchmap.rs::switchmap_basic_construction | Box (Region, out of scope) +tests/test_switchmap.rs::switchmap_forward_route1 | Box (Region, out of scope) +tests/test_switchmap.rs::switchmap_forward_route2 | Box (Region, out of scope) +tests/test_switchmap.rs::switchmap_forward_no_route | Box (Region, out of scope) +tests/test_switchmap.rs::switchmap_forward_bad_input | Box (Region, out of scope) +tests/test_switchmap.rs::switchmap_forward_multiple_points | Box (Region, out of scope) +tests/test_switchmap.rs::switchmap_equal | Box (Region, out of scope) +tests/test_switchmap.rs::switchmap_remove_regions | Box (Region, out of scope) +tests/test_switchmap.rs::switchmap_serialization_roundtrip | Box (Region, out of scope) +tests/test_switchmap.rs::testswitchmap_c::section_3_two_images | Box (Region, out of scope) diff --git a/src/test/resources/deferred/serialisation.txt b/src/test/resources/deferred/serialisation.txt index 13991f2..d28218c 100644 --- a/src/test/resources/deferred/serialisation.txt +++ b/src/test/resources/deferred/serialisation.txt @@ -11,8 +11,6 @@ simplify/box_self_simplify.map | needs Box, PointSet simplify/box_self_simplify.simp | needs Box, PointSet simplify/box_unc_fillfactor_merge.map | needs Box, PointSet simplify/box_unc_fillfactor_merge.simp | needs Box, PointSet -simplify/brad.map | needs LutMap -simplify/brad.simp | needs LutMap simplify/cap_box_permmap_const.map | needs Box, PointSet simplify/cap_box_permmap_const.simp | needs Box, PointSet simplify/cap_box_permmap_nonbidi.map | needs Box, PointSet @@ -22,21 +20,8 @@ simplify/cap_box_permmap_null_first.map | needs Box, PointSet simplify/cap_box_permmap_null_first.simp | needs NullRegion simplify/cap_cheby_consolidate.map | needs ChebyMap simplify/cap_cheby_consolidate.simp | needs ChebyMap -simplify/cap_cmpmap_01.map | needs MathMap, RateMap, TranMap -simplify/cap_cmpmap_01.simp | needs MathMap, RateMap, TranMap -simplify/cap_cmpmap_02.map | needs MathMap -simplify/cap_cmpmap_02.simp | needs MathMap -simplify/cap_cmpmap_04.map | needs MathMap, RateMap, TranMap -simplify/cap_cmpmap_04.simp | needs MathMap, RateMap, TranMap -simplify/cap_cmpperm_resume.map | needs MathMap -simplify/cap_cmpperm_resume.simp | needs MathMap -simplify/cap_cmpperm_resume_inv.map | needs MathMap -simplify/cap_cmpperm_resume_inv.simp | needs MathMap simplify/cap_interval_01.map | needs Box, Interval, NullRegion, PointSet, Prism simplify/cap_interval_01.simp | needs Box, Interval, PointSet -simplify/cap_lutmap_01.map | needs LutMap, MathMap -simplify/cap_lutmap_01.simp | needs MathMap -simplify/cap_mathmap_01.map | needs MathMap simplify/cap_matrixmap_04.map | needs ChebyMap simplify/cap_normmap_cmpframe.map | needs NormMap simplify/cap_normmap_cmpframe.simp | needs NormMap @@ -46,23 +31,16 @@ simplify/cap_pointlist_01.map | needs Box, PointList, PointSet, Prism simplify/cap_pointlist_01.simp | needs Box, PointList, PointSet, Prism simplify/cap_pointlist_02.map | needs Interval, PointList, PointSet, Prism simplify/cap_pointlist_02.simp | needs PointList, PointSet -simplify/cap_poly_bend_allowed.map | needs Box, MathMap, PointSet, Polygon -simplify/cap_poly_bend_allowed.simp | needs Box, MathMap, PointSet, Polygon -simplify/cap_poly_bent_edges.map | needs Box, MathMap, PointSet, Polygon -simplify/cap_poly_bent_edges.simp | needs Box, MathMap, PointSet, Polygon +simplify/cap_poly_bend_allowed.map | needs Box, PointSet, Polygon +simplify/cap_poly_bend_allowed.simp | needs Box, PointSet, Polygon +simplify/cap_poly_bent_edges.map | needs Box, PointSet, Polygon +simplify/cap_poly_bent_edges.simp | needs Box, PointSet, Polygon simplify/cap_poly_unc_frame.map | needs Box, PointSet, Polygon simplify/cap_poly_unc_frame.simp | needs Box, PointSet, Polygon -simplify/cap_restricted_component_flags.map | needs MathMap -simplify/cap_restricted_component_flags.simp | needs MathMap simplify/cap_slamap_02.map | needs Box, PointSet simplify/cap_slamap_02.simp | needs Box, PointSet, Polygon, Prism simplify/cap_slamap_07.map | needs Box, Circle, CmpRegion, PointSet simplify/cap_slamap_07.simp | needs NullRegion -simplify/cap_specmap_02.map | needs LutMap -simplify/cap_specmap_02.simp | needs LutMap -simplify/cap_specmap_09.map | needs LutMap -simplify/cap_specmap_14.map | needs MathMap -simplify/cap_specmap_14.simp | needs MathMap simplify/cap_timemap_02.map | needs Box, Interval, PointSet, StcResourceProfile simplify/cap_timemap_02.simp | needs Box, Interval, PointSet, StcResourceProfile simplify/cap_unitnormmap_01.map | needs UnitNormMap @@ -70,33 +48,18 @@ 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/cap_zoommap_04.map | needs Box, MathMap, PointList, PointSet +simplify/cap_zoommap_04.map | needs Box, PointList, PointSet simplify/cap_zoommap_04.simp | needs Box, PointList, PointSet simplify/cefit_circle_conformal.map | needs Circle, PointSet simplify/cefit_circle_conformal.simp | needs Circle, PointSet -simplify/cefit_circle_nonconformal_keep.map | needs Circle, MathMap, PointSet -simplify/cefit_circle_nonconformal_keep.simp | needs Circle, MathMap, PointSet +simplify/cefit_circle_nonconformal_keep.map | needs Circle, PointSet +simplify/cefit_circle_nonconformal_keep.simp | needs Circle, PointSet simplify/cefit_circle_to_ellipse.map | needs Ellipse, PointSet simplify/cefit_circle_to_ellipse.simp | needs Ellipse, PointSet simplify/cefit_ellipse_to_circle.map | needs Circle, PointSet simplify/cefit_ellipse_to_circle.simp | needs Circle, PointSet simplify/cheby_linear_lone_reduce.map | needs ChebyMap simplify/chebymap_inverse_cancel.map | needs ChebyMap -simplify/cmpmap_decompose_middle.map | needs MathMap -simplify/cmpmap_decompose_middle.simp | needs MathMap -simplify/cmpmap_inverted_nested.map | needs MathMap -simplify/cmpmap_inverted_nested.simp | needs MathMap -simplify/cmpmap_parallel_in_series_merge.map | needs MathMap -simplify/cmpmap_parallel_series_dim_mismatch.map | needs MathMap -simplify/cmpmap_parallel_series_dim_mismatch.simp | needs MathMap -simplify/cmpmap_perm_swap_aconstants.map | needs MathMap -simplify/cmpmap_perm_swap_aconstants.simp | needs MathMap -simplify/cmpmap_perm_swap_bconstants.map | needs MathMap -simplify/cmpmap_perm_swap_bconstants.simp | needs MathMap -simplify/cmpmap_series_in_parallel_inverted.map | needs MathMap -simplify/cmpmap_series_in_parallel_inverted.simp | needs MathMap -simplify/cmpmap_solo_after_unit.map | needs MathMap -simplify/cmpmap_solo_after_unit.simp | needs MathMap simplify/defunc_cmpregion_component_unc.map | needs Box, PointSet simplify/defunc_cmpregion_component_unc.simp | needs Box, PointSet simplify/defunc_interval_point_at_origin.map | needs Box, PointSet @@ -109,20 +72,6 @@ simplify/defunc_pointlist_origin_axis.map | needs Box, PointSet simplify/defunc_pointlist_origin_axis.simp | needs Box, PointSet simplify/defunc_prism_box_interval.map | needs Box, PointSet, Prism simplify/defunc_prism_box_interval.simp | needs Box, PointSet -simplify/dssmap_inv_winmap_absorb.map | needs DssMap -simplify/dssmap_inv_winmap_absorb.simp | needs DssMap -simplify/dssmap_winmap_absorb.map | needs DssMap -simplify/dssmap_winmap_absorb.simp | needs DssMap -simplify/dssmap_zoom_no_merge.map | needs DssMap -simplify/dssmap_zoom_no_merge.simp | needs DssMap -simplify/fitschan_tab_spectral.map | needs LutMap -simplify/fitschan_tab_spectral.simp | needs LutMap -simplify/grism_inverse_cancel.map | needs GrismMap -simplify/grism_inverse_cancel_tail.map | needs GrismMap -simplify/grism_zoom_inv_merge.map | needs GrismMap -simplify/grism_zoom_inv_merge.simp | needs GrismMap -simplify/grism_zoom_merge.map | needs GrismMap -simplify/grism_zoom_merge.simp | needs GrismMap simplify/interval_halfinf_simplify.map | needs Interval, PointSet simplify/interval_nullregion_merge.map | needs Interval, NullRegion, PointSet simplify/interval_nullregion_merge.simp | needs Interval, PointSet @@ -137,13 +86,6 @@ simplify/interval_self_simplify_cmp.map | needs Interval, PointSet simplify/interval_self_simplify_cmp.simp | needs Box, PointSet simplify/interval_unc_fillfactor_merge.map | needs Box, Interval, PointSet simplify/interval_unc_fillfactor_merge.simp | needs Box, Interval, PointSet -simplify/intra_invfwd_cancel.map | needs IntraMap -simplify/intra_invfwd_cancel_tail.map | needs IntraMap -simplify/intramap_inverse_cancel.map | needs IntraMap -simplify/lut_exactly_linear.map | needs LutMap -simplify/lut_inverse_cancel.map | needs LutMap -simplify/lut_linear_to_win.map | needs LutMap -simplify/math_inverse_cancel.map | needs MathMap simplify/merge_box_fillfactor_product.map | needs Box, PointSet simplify/merge_box_fillfactor_product.simp | needs Box, PointSet simplify/merge_box_meshsize_scaled.map | needs Box, PointSet @@ -157,35 +99,9 @@ simplify/neg_box_unc_mismatch.map | needs Box, PointSet simplify/neg_cheby_quadratic_no_reduce.map | needs ChebyMap simplify/neg_chebymap_standalone.map | needs ChebyMap simplify/neg_circle_cmpframe_sky_second.map | needs Circle, PointSet -simplify/neg_cmpmap_mode_mismatch.map | needs MathMap -simplify/neg_cmpmap_neighbour_nonexcmpmap.map | needs MathMap -simplify/neg_grism_different_attrs.map | needs GrismMap -simplify/neg_grism_fwd_then_nonzoom.map | needs GrismMap -simplify/neg_grism_inv_then_zoom.map | needs GrismMap -simplify/neg_grism_nonzoom_before_inv.map | needs GrismMap -simplify/neg_grism_parallel.map | needs GrismMap -simplify/neg_grism_same_direction.map | needs GrismMap -simplify/neg_grism_zoom_before_fwd.map | needs GrismMap simplify/neg_interval_parallel_nonregion.map | needs Interval, PointSet simplify/neg_interval_series.map | needs Interval, PointSet simplify/neg_interval_unbounded_pointlist.map | needs Interval, PointList, PointSet -simplify/neg_intra_diff_flag.map | needs IntraMap -simplify/neg_intra_diff_func.map | needs IntraMap -simplify/neg_intra_no_simpfi.map | needs IntraMap -simplify/neg_intra_no_simpif.map | needs IntraMap -simplify/neg_intra_nonintra_neighbour.map | needs IntraMap -simplify/neg_intra_parallel.map | needs IntraMap -simplify/neg_intra_same_direction.map | needs IntraMap -simplify/neg_lut_constant.map | needs LutMap -simplify/neg_lut_different_tables.map | needs LutMap -simplify/neg_lut_near_linear.map | needs LutMap -simplify/neg_lut_nonlinear.map | needs LutMap -simplify/neg_lut_nonlut_neighbour.map | needs LutMap -simplify/neg_lut_parallel.map | needs LutMap -simplify/neg_math_inv_text_mismatch.map | needs MathMap -simplify/neg_math_lone.map | needs MathMap -simplify/neg_math_no_simpfi.map | needs MathMap -simplify/neg_math_nonmath_neighbour.map | needs MathMap 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 @@ -194,25 +110,8 @@ simplify/neg_normmap_parallel.map | needs NormMap simplify/neg_normmap_parallel_sky.map | needs NormMap simplify/neg_nullregion_parallel_nonregion.map | needs NullRegion simplify/neg_nullregion_series.map | needs NullRegion -simplify/neg_parpair_aligned_irreducible.map | needs MathMap -simplify/neg_pcd_diff_centre.map | needs PcdMap -simplify/neg_pcd_diff_disco.map | needs PcdMap -simplify/neg_pcd_nonpcd_neighbour.map | needs PcdMap -simplify/neg_pcd_nonswappable_between.map | needs PcdMap -simplify/neg_pcd_parallel.map | needs PcdMap -simplify/neg_pcd_perm_nonswap.map | needs PcdMap -simplify/neg_pcd_same_invert.map | needs PcdMap -simplify/neg_pcd_zoom_no_target.map | needs PcdMap -simplify/neg_perm_no_merge.map | needs MathMap simplify/neg_pointlist_parallel_nonregion.map | needs PointList, PointSet simplify/neg_pointlist_series.map | needs PointList, PointSet -simplify/neg_ratemap_diff_indices.map | needs RateMap -simplify/neg_ratemap_diff_inner.map | needs RateMap -simplify/neg_ratemap_different_inner.map | needs RateMap -simplify/neg_ratemap_lower_nonrate.map | needs RateMap -simplify/neg_ratemap_nonratemap_neighbour.map | needs RateMap -simplify/neg_ratemap_parallel.map | needs RateMap -simplify/neg_ratemap_same_invert.map | needs RateMap simplify/neg_selectormap_not_equal.map | needs Box, PointSet, SelectorMap simplify/neg_selectormap_parallel.map | needs Box, PointSet, SelectorMap simplify/neg_selectormap_series_lower.map | needs Box, PointSet, SelectorMap @@ -221,16 +120,6 @@ 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_switchmap_not_equal.map | needs SwitchMap -simplify/neg_switchmap_parallel.map | needs SwitchMap -simplify/neg_switchmap_series.map | needs SwitchMap -simplify/neg_switchmap_series_lower.map | needs SwitchMap -simplify/neg_tranmap_adjacent_no_merge.map | needs MathMap, TranMap -simplify/neg_tranmap_nontranmap_neighbour.map | needs TranMap -simplify/neg_tranmap_oneway.map | needs MathMap, TranMap -simplify/neg_tranmap_parallel.map | needs TranMap -simplify/neg_tranmap_unequal_components.map | needs TranMap -simplify/neg_unit_parallel_forward.map | needs PcdMap simplify/neg_unitnormmap_flanked.map | needs UnitNormMap simplify/neg_unitnormmap_fwd_shift.map | needs UnitNormMap simplify/neg_unitnormmap_inv_fwd_diffcentre.map | needs UnitNormMap @@ -239,13 +128,9 @@ 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_wcs_nonperm_between.map | needs MathMap -simplify/neg_win_cmpmap_split_no_simplify.map | needs MathMap -simplify/neg_win_nonmergeable_series.map | needs MathMap simplify/neg_xph_nonxph_neighbour.map | needs XphMap simplify/neg_xph_not_opposite.map | needs XphMap simplify/neg_xph_parallel.map | needs XphMap -simplify/neg_zoom_parallel_lone.map | needs MathMap simplify/normmap_basic_frame_to_unit.map | needs NormMap simplify/normmap_duplicate_elim.map | needs NormMap simplify/normmap_duplicate_elim.simp | needs NormMap @@ -261,40 +146,12 @@ simplify/nullregion_self_simplify.map | needs NullRegion simplify/nullregion_self_simplify.simp | needs NullRegion simplify/nullregion_unc_fillfactor_merge.map | needs Box, NullRegion, PointSet simplify/nullregion_unc_fillfactor_merge.simp | needs Box, NullRegion, PointSet -simplify/parcomp_inverted_nested_reemitted.map | needs MathMap -simplify/parcomp_inverted_nested_reemitted.simp | needs MathMap -simplify/parcomp_inverted_reemitted.map | needs MathMap -simplify/parcomp_inverted_reemitted.simp | needs MathMap -simplify/parpair_one_side_reduces.map | needs MathMap -simplify/parpair_one_side_reduces.simp | needs MathMap -simplify/pcd_inverse_cancel.map | needs PcdMap -simplify/pcd_inverse_cancel_tail.map | needs PcdMap -simplify/pcd_inverted_zoom_swap.map | needs PcdMap -simplify/pcd_inverted_zoom_swap.simp | needs PcdMap -simplify/pcd_perm_swap_cancel.map | needs PcdMap -simplify/pcd_search_blocked.map | needs PcdMap -simplify/pcd_search_blocked.simp | needs PcdMap -simplify/pcd_swap_zoom_simplifies.map | needs PcdMap -simplify/pcd_swap_zoom_simplifies.simp | needs PcdMap -simplify/pcd_unit_series_merge.map | needs PcdMap -simplify/pcd_unit_series_merge.simp | needs PcdMap -simplify/pcd_zero_disc_lone.map | needs PcdMap -simplify/pcd_zero_disc_series.map | needs PcdMap -simplify/pcd_zero_to_unit.map | needs PcdMap -simplify/pcd_zoom_swap_cancel.map | needs PcdMap simplify/pointlist_parallel_merge_pair.map | needs PointList, PointSet simplify/pointlist_parallel_merge_pair.simp | needs PointList, PointSet simplify/pointlist_self_simplify.map | needs PointList, PointSet simplify/pointlist_self_simplify.simp | needs PointList, PointSet simplify/pointlist_unc_fillfactor_merge.map | needs Box, PointList, PointSet simplify/pointlist_unc_fillfactor_merge.simp | needs Box, PointList, PointSet -simplify/rate_inner_reduce_lone.map | needs RateMap -simplify/rate_inner_reduce_lone.simp | needs RateMap -simplify/rate_inner_reduce_series.map | needs RateMap -simplify/rate_inner_reduce_series.simp | needs RateMap -simplify/ratemap_inverse_cancel.map | needs RateMap -simplify/ratemap_simplify_interior.map | needs RateMap -simplify/ratemap_simplify_interior.simp | needs RateMap simplify/regbasepick_circle_permaxes.map | needs Circle, PointSet simplify/regbasepick_circle_permaxes.simp | needs Circle, PointSet simplify/regbasepick_cmpregion_subset.map | needs CmpRegion, Interval, PointSet @@ -315,46 +172,11 @@ simplify/setunc_unitmap_regionfs_omitted.map | needs Box, PointSet simplify/setunc_unitmap_regionfs_omitted.simp | needs Box, PointSet simplify/simpstab_box_linear_unc.map | needs Box, PointSet simplify/simpstab_box_linear_unc.simp | needs Box, PointSet -simplify/simpstab_box_nonlinear_unc.map | needs Box, MathMap, PointSet -simplify/simpstab_box_nonlinear_unc.simp | needs Box, MathMap, PointSet +simplify/simpstab_box_nonlinear_unc.map | needs Box, PointSet +simplify/simpstab_box_nonlinear_unc.simp | needs Box, PointSet simplify/simpstab_permmap_slice_unc.map | needs Box, PointSet simplify/simpstab_permmap_slice_unc.simp | needs Box, PointSet simplify/spline_inverse_cancel.map | needs SplineMap -simplify/switchmap_fwdonly_simplify.map | needs SwitchMap -simplify/switchmap_fwdonly_simplify.simp | needs SwitchMap -simplify/switchmap_internal_simplify.map | needs SwitchMap -simplify/switchmap_internal_simplify.simp | needs SwitchMap -simplify/switchmap_inv_fwdonly.map | needs SwitchMap -simplify/switchmap_inv_fwdonly.simp | needs SwitchMap -simplify/switchmap_inv_invonly.map | needs SwitchMap -simplify/switchmap_inv_invonly.simp | needs SwitchMap -simplify/switchmap_inverse_cancel.map | needs SwitchMap -simplify/switchmap_inverse_cancel_distinct_selectors.map | needs MathMap, SwitchMap -simplify/switchmap_inverse_cancel_tail.map | needs SwitchMap -simplify/switchmap_invert_normalize.map | needs SwitchMap -simplify/switchmap_invert_normalize.simp | needs SwitchMap -simplify/switchmap_invonly_simplify.map | needs SwitchMap -simplify/switchmap_invonly_simplify.simp | needs SwitchMap -simplify/tranmap_adjacent_merge.map | needs TranMap -simplify/tranmap_adjacent_merge.simp | needs TranMap -simplify/tranmap_adjacent_merge_inverse_order.map | needs TranMap -simplify/tranmap_adjacent_merge_inverse_order.simp | needs TranMap -simplify/tranmap_adjacent_merge_nonsquare.map | needs TranMap -simplify/tranmap_adjacent_merge_nonsquare.simp | needs TranMap -simplify/tranmap_component_simplify.map | needs TranMap -simplify/tranmap_component_simplify.simp | needs TranMap -simplify/tranmap_equal_components.map | needs TranMap -simplify/tranmap_equal_components_in_list.map | needs TranMap -simplify/tranmap_invert_in_list.map | needs TranMap -simplify/tranmap_invert_in_list.simp | needs TranMap -simplify/tranmap_invert_normalize.map | needs TranMap -simplify/tranmap_invert_normalize.simp | needs TranMap -simplify/tranmap_merge_tail.map | needs TranMap -simplify/tranmap_merge_tail.simp | needs TranMap -simplify/unit_parallel_invert_clear.map | needs MathMap -simplify/unit_parallel_invert_clear.simp | needs MathMap -simplify/unit_parallel_invert_pcd.map | needs PcdMap -simplify/unit_parallel_invert_pcd.simp | needs PcdMap 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 @@ -373,14 +195,7 @@ 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/framesets/freq-log-head.ast | needs MathMap -wcsconv/framesets/grism-head.ast | needs GrismMap -wcsconv/framesets/polco-head.ast | needs MathMap -wcsconv/framesets/polco2-head.ast | needs MathMap -programs/testcmpmap/splittest1.ast | needs LutMap -programs/testfitschan/sparse.ast | needs LutMap programs/testmocchan/backcompat_json.ast | needs MocChan programs/testmocchan/backcompat_string.ast | needs MocChan programs/teststcschan/stcschan-test1-doc3.ast | needs Box, Circle, PointList, PointSet, Prism -serialisation/c_dssmap.ast | needs DssMap serialisation/region_in_cmpframe.ast | needs Box, PointSet diff --git a/src/test/resources/deferred/simplify-cases.txt b/src/test/resources/deferred/simplify-cases.txt index 74240e1..6b35e2e 100644 --- a/src/test/resources/deferred/simplify-cases.txt +++ b/src/test/resources/deferred/simplify-cases.txt @@ -1,80 +1,20 @@ # Rows of fixtures/simplify/cases.txt whose simplification does not match C: # | # Rewritten by SimplifyRegressionTest with -Dast.writeDeferred=true. -brad | needs LutMap -lut_linear_to_win | needs LutMap -lut_inverse_cancel | needs LutMap -pcd_zero_to_unit | needs PcdMap -pcd_inverse_cancel | needs PcdMap -grism_inverse_cancel | needs GrismMap -grism_zoom_merge | needs GrismMap spline_inverse_cancel | needs SplineMap -math_inverse_cancel | needs MathMap -ratemap_inverse_cancel | needs RateMap -tranmap_equal_components | needs TranMap -intramap_inverse_cancel | needs IntraMap -tranmap_invert_normalize | needs TranMap -tranmap_component_simplify | needs TranMap -ratemap_simplify_interior | needs RateMap 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 -grism_zoom_inv_merge | needs GrismMap -pcd_unit_series_merge | needs PcdMap -pcd_zoom_swap_cancel | needs PcdMap -switchmap_invert_normalize | needs SwitchMap -switchmap_internal_simplify | needs SwitchMap -tranmap_adjacent_merge | needs TranMap -tranmap_adjacent_merge_inverse_order | needs TranMap -tranmap_adjacent_merge_nonsquare | needs TranMap -tranmap_invert_in_list | needs TranMap -tranmap_equal_components_in_list | needs TranMap selectormap_inverse_cancel | needs Box, PointSet, SelectorMap -switchmap_inverse_cancel | needs SwitchMap -pcd_perm_swap_cancel | needs PcdMap -pcd_swap_zoom_simplifies | needs PcdMap -pcd_inverted_zoom_swap | needs PcdMap -neg_win_nonmergeable_series | needs MathMap -neg_math_no_simpfi | needs MathMap -neg_grism_same_direction | needs GrismMap -neg_lut_nonlinear | needs LutMap -neg_lut_different_tables | needs LutMap -neg_pcd_parallel | needs PcdMap -neg_pcd_nonpcd_neighbour | needs PcdMap -neg_tranmap_unequal_components | needs TranMap neg_spline_same_direction | needs SplineMap neg_normmap_parallel | needs NormMap -neg_perm_no_merge | needs MathMap -neg_ratemap_nonratemap_neighbour | needs RateMap -neg_ratemap_different_inner | needs RateMap -neg_lut_parallel | needs LutMap -neg_grism_different_attrs | needs GrismMap neg_normmap_different_frames | needs NormMap -neg_grism_parallel | needs GrismMap -neg_grism_inv_then_zoom | needs GrismMap -neg_grism_fwd_then_nonzoom | needs GrismMap -neg_math_nonmath_neighbour | needs MathMap neg_spline_parallel | needs SplineMap -neg_lut_nonlut_neighbour | needs LutMap neg_spline_nonspline_neighbour | needs SplineMap -neg_tranmap_parallel | needs TranMap -neg_tranmap_nontranmap_neighbour | needs TranMap -neg_pcd_nonswappable_between | needs PcdMap -neg_wcs_nonperm_between | needs MathMap neg_normmap_nonnorm_neighbour | needs NormMap -neg_grism_zoom_before_fwd | needs GrismMap -neg_grism_nonzoom_before_inv | needs GrismMap -neg_ratemap_parallel | needs RateMap neg_spline_different_coeffs | needs SplineMap -cmpmap_parallel_in_series_merge | needs MathMap -cmpmap_perm_swap_aconstants | needs MathMap -cmpmap_perm_swap_bconstants | needs MathMap -cmpmap_decompose_middle | needs MathMap -cmpmap_series_in_parallel_inverted | needs MathMap -cmpmap_parallel_series_dim_mismatch | needs MathMap -unit_parallel_invert_clear | needs MathMap normmap_inverse_cancel_upper | needs NormMap unitnormmap_inv_fwd_cancel | needs UnitNormMap box_parallel_merge | needs Box, PointSet @@ -86,57 +26,22 @@ nullregion_parallel_merge | needs Box, NullRegion, PointSet pointlist_self_simplify | needs PointList, PointSet cap_normmap_cmpframe | needs NormMap selectormap_region_simplify | needs Box, PointSet, SelectorMap -dssmap_inv_winmap_absorb | needs DssMap -dssmap_winmap_absorb | needs DssMap -dssmap_zoom_no_merge | needs DssMap neg_box_asymmetric_2d | needs Box, PointSet -fitschan_tab_spectral | needs LutMap -switchmap_inverse_cancel_distinct_selectors | needs MathMap, SwitchMap -cap_cmpmap_01 | needs MathMap, RateMap, TranMap -cap_cmpmap_02 | needs MathMap -cap_cmpmap_04 | needs MathMap, RateMap, TranMap cap_interval_01 | needs Box, Interval, NullRegion, PointSet, Prism -cap_lutmap_01 | needs LutMap, MathMap -cap_mathmap_01 | needs MathMap cap_matrixmap_04 | needs ChebyMap cap_permmap_01 | needs NormMap cap_pointlist_01 | needs Box, PointList, PointSet, Prism cap_pointlist_02 | needs Interval, PointList, PointSet, Prism cap_slamap_02 | needs Box, PointSet, Polygon, Prism cap_slamap_07 | needs Box, Circle, CmpRegion, NullRegion, PointSet -cap_specmap_02 | needs LutMap -cap_specmap_09 | needs LutMap -cap_specmap_14 | needs MathMap cap_timemap_02 | needs Box, Interval, PointSet, StcResourceProfile cap_unitnormmap_01 | needs UnitNormMap cap_xphmap_01 | needs XphMap cap_xphmap_02 | needs XphMap -cap_zoommap_04 | needs Box, MathMap, PointList, PointSet -neg_tranmap_adjacent_no_merge | needs MathMap, TranMap -neg_lut_constant | needs LutMap -neg_math_lone | needs MathMap -neg_pcd_zoom_no_target | needs PcdMap -neg_ratemap_lower_nonrate | needs RateMap -neg_ratemap_same_invert | needs RateMap -neg_ratemap_diff_indices | needs RateMap -neg_ratemap_diff_inner | needs RateMap -neg_zoom_parallel_lone | needs MathMap -neg_cmpmap_neighbour_nonexcmpmap | needs MathMap -neg_tranmap_oneway | needs MathMap, TranMap -neg_math_inv_text_mismatch | needs MathMap -pcd_search_blocked | needs PcdMap -cmpmap_solo_after_unit | needs MathMap +cap_zoommap_04 | needs Box, PointList, PointSet neg_normmap_diff_frame | needs NormMap neg_normmap_inv_diff_frame | needs NormMap neg_normmap_parallel_sky | needs NormMap -intra_invfwd_cancel | needs IntraMap -neg_intra_parallel | needs IntraMap -neg_intra_nonintra_neighbour | needs IntraMap -neg_intra_diff_flag | needs IntraMap -neg_intra_same_direction | needs IntraMap -neg_intra_diff_func | needs IntraMap -neg_intra_no_simpfi | needs IntraMap -neg_intra_no_simpif | needs IntraMap xph_inverse_cancel | needs XphMap neg_xph_parallel | needs XphMap neg_xph_nonxph_neighbour | needs XphMap @@ -159,15 +64,6 @@ neg_selectormap_series_lower | needs Box, PointSet, SelectorMap neg_selectormap_not_equal | needs Box, PointSet, SelectorMap neg_selectormap_parallel | needs Box, PointSet, SelectorMap selectormap_inverse_cancel_tail | needs Box, PointSet, SelectorMap -neg_switchmap_not_equal | needs SwitchMap -neg_switchmap_series | needs SwitchMap -neg_switchmap_parallel | needs SwitchMap -switchmap_inverse_cancel_tail | needs SwitchMap -switchmap_fwdonly_simplify | needs SwitchMap -switchmap_invonly_simplify | needs SwitchMap -switchmap_inv_invonly | needs SwitchMap -switchmap_inv_fwdonly | needs SwitchMap -neg_switchmap_series_lower | needs SwitchMap unitnormmap_shift_fwd_merge | needs UnitNormMap unitnormmap_winmap_fwd_merge | needs UnitNormMap unitnormmap_inv_shift_merge | needs UnitNormMap @@ -193,35 +89,11 @@ box_unc_fillfactor_merge | needs Box, PointSet neg_box_unc_mismatch | needs Box, PointSet nullregion_unc_fillfactor_merge | needs Box, NullRegion, PointSet pointlist_unc_fillfactor_merge | needs Box, PointList, PointSet -neg_pcd_diff_disco | needs PcdMap -neg_pcd_diff_centre | needs PcdMap -neg_pcd_same_invert | needs PcdMap -neg_pcd_perm_nonswap | needs PcdMap -pcd_inverse_cancel_tail | needs PcdMap nullregion_merge_tail | needs NullRegion -grism_inverse_cancel_tail | needs GrismMap -intra_invfwd_cancel_tail | needs IntraMap -tranmap_merge_tail | needs TranMap interval_remapped_simplify | needs Interval, PointSet interval_halfinf_simplify | needs Interval, PointSet -unit_parallel_invert_pcd | needs PcdMap -neg_unit_parallel_forward | needs PcdMap -pcd_zero_disc_series | needs PcdMap -pcd_zero_disc_lone | needs PcdMap -parcomp_inverted_reemitted | needs MathMap -parcomp_inverted_nested_reemitted | needs MathMap -lut_exactly_linear | needs LutMap -neg_lut_near_linear | needs LutMap -parpair_one_side_reduces | needs MathMap -neg_parpair_aligned_irreducible | needs MathMap -cmpmap_inverted_nested | needs MathMap -rate_inner_reduce_series | needs RateMap -rate_inner_reduce_lone | needs RateMap cheby_linear_lone_reduce | needs ChebyMap neg_cheby_quadratic_no_reduce | needs ChebyMap -cap_restricted_component_flags | needs MathMap -cap_cmpperm_resume | needs MathMap -cap_cmpperm_resume_inv | needs MathMap cap_cheby_consolidate | needs ChebyMap cap_box_permmap_const | needs Box, PointSet cap_box_permmap_null | needs Box, NullRegion, PointSet @@ -229,13 +101,11 @@ cap_box_permmap_null_first | needs Box, NullRegion, PointSet cap_box_permmap_nonbidi | needs Box, PointSet neg_circle_cmpframe_sky_second | needs Circle, PointSet cap_poly_unc_frame | needs Box, PointSet, Polygon -cap_poly_bent_edges | needs Box, MathMap, PointSet, Polygon -cap_poly_bend_allowed | needs Box, MathMap, PointSet, Polygon +cap_poly_bent_edges | needs Box, PointSet, Polygon +cap_poly_bend_allowed | needs Box, PointSet, Polygon neg_unitnormmap_nonunit_scale | needs UnitNormMap -neg_cmpmap_mode_mismatch | needs MathMap -neg_win_cmpmap_split_no_simplify | needs MathMap cefit_circle_conformal | needs Circle, PointSet -cefit_circle_nonconformal_keep | needs Circle, MathMap, PointSet +cefit_circle_nonconformal_keep | needs Circle, PointSet cefit_circle_to_ellipse | needs Ellipse, PointSet cefit_ellipse_to_circle | needs Circle, PointSet defunc_cmpregion_component_unc | needs Box, PointSet @@ -254,5 +124,5 @@ setunc_box_remapped_unc | needs Box, PointSet setunc_unbounded_negated | needs Box, PointSet setunc_unitmap_regionfs_omitted | needs Box, PointSet simpstab_box_linear_unc | needs Box, PointSet -simpstab_box_nonlinear_unc | needs Box, MathMap, PointSet +simpstab_box_nonlinear_unc | needs Box, PointSet simpstab_permmap_slice_unc | needs Box, PointSet diff --git a/src/test/resources/deferred/simplify.txt b/src/test/resources/deferred/simplify.txt index 2b5efbb..127789e 100644 --- a/src/test/resources/deferred/simplify.txt +++ b/src/test/resources/deferred/simplify.txt @@ -11,8 +11,6 @@ simplify/box_self_simplify.map | needs Box, PointSet simplify/box_self_simplify.simp | needs Box, PointSet simplify/box_unc_fillfactor_merge.map | needs Box, PointSet simplify/box_unc_fillfactor_merge.simp | needs Box, PointSet -simplify/brad.map | needs LutMap -simplify/brad.simp | needs LutMap simplify/cap_box_permmap_const.map | needs Box, PointSet simplify/cap_box_permmap_const.simp | needs Box, PointSet simplify/cap_box_permmap_nonbidi.map | needs Box, PointSet @@ -22,21 +20,8 @@ simplify/cap_box_permmap_null_first.map | needs Box, PointSet simplify/cap_box_permmap_null_first.simp | needs NullRegion simplify/cap_cheby_consolidate.map | needs ChebyMap simplify/cap_cheby_consolidate.simp | needs ChebyMap -simplify/cap_cmpmap_01.map | needs MathMap, RateMap, TranMap -simplify/cap_cmpmap_01.simp | needs MathMap, RateMap, TranMap -simplify/cap_cmpmap_02.map | needs MathMap -simplify/cap_cmpmap_02.simp | needs MathMap -simplify/cap_cmpmap_04.map | needs MathMap, RateMap, TranMap -simplify/cap_cmpmap_04.simp | needs MathMap, RateMap, TranMap -simplify/cap_cmpperm_resume.map | needs MathMap -simplify/cap_cmpperm_resume.simp | needs MathMap -simplify/cap_cmpperm_resume_inv.map | needs MathMap -simplify/cap_cmpperm_resume_inv.simp | needs MathMap simplify/cap_interval_01.map | needs Box, Interval, NullRegion, PointSet, Prism simplify/cap_interval_01.simp | needs Box, Interval, PointSet -simplify/cap_lutmap_01.map | needs LutMap, MathMap -simplify/cap_lutmap_01.simp | needs MathMap -simplify/cap_mathmap_01.map | needs MathMap simplify/cap_normmap_cmpframe.map | needs NormMap simplify/cap_normmap_cmpframe.simp | needs NormMap simplify/cap_permmap_01.map | needs NormMap @@ -45,21 +30,16 @@ simplify/cap_pointlist_01.map | needs Box, PointList, PointSet, Prism simplify/cap_pointlist_01.simp | needs Box, PointList, PointSet, Prism simplify/cap_pointlist_02.map | needs Interval, PointList, PointSet, Prism simplify/cap_pointlist_02.simp | needs PointList, PointSet -simplify/cap_poly_bend_allowed.map | needs Box, MathMap, PointSet, Polygon -simplify/cap_poly_bend_allowed.simp | needs Box, MathMap, PointSet, Polygon -simplify/cap_poly_bent_edges.map | needs Box, MathMap, PointSet, Polygon -simplify/cap_poly_bent_edges.simp | needs Box, MathMap, PointSet, Polygon +simplify/cap_poly_bend_allowed.map | needs Box, PointSet, Polygon +simplify/cap_poly_bend_allowed.simp | needs Box, PointSet, Polygon +simplify/cap_poly_bent_edges.map | needs Box, PointSet, Polygon +simplify/cap_poly_bent_edges.simp | needs Box, PointSet, Polygon simplify/cap_poly_unc_frame.map | needs Box, PointSet, Polygon simplify/cap_poly_unc_frame.simp | needs Box, PointSet, Polygon -simplify/cap_restricted_component_flags.map | needs MathMap -simplify/cap_restricted_component_flags.simp | needs MathMap simplify/cap_slamap_02.map | needs Box, PointSet simplify/cap_slamap_02.simp | needs Box, PointSet, Polygon, Prism simplify/cap_slamap_07.map | needs Box, Circle, CmpRegion, PointSet simplify/cap_slamap_07.simp | needs NullRegion -simplify/cap_specmap_09.map | needs LutMap -simplify/cap_specmap_14.map | needs MathMap -simplify/cap_specmap_14.simp | needs MathMap simplify/cap_timemap_02.map | needs Box, Interval, PointSet, StcResourceProfile simplify/cap_timemap_02.simp | needs Box, Interval, PointSet, StcResourceProfile simplify/cap_unitnormmap_01.map | needs UnitNormMap @@ -67,33 +47,18 @@ 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/cap_zoommap_04.map | needs Box, MathMap, PointList, PointSet +simplify/cap_zoommap_04.map | needs Box, PointList, PointSet simplify/cap_zoommap_04.simp | needs Box, PointList, PointSet simplify/cefit_circle_conformal.map | needs Circle, PointSet simplify/cefit_circle_conformal.simp | needs Circle, PointSet -simplify/cefit_circle_nonconformal_keep.map | needs Circle, MathMap, PointSet -simplify/cefit_circle_nonconformal_keep.simp | needs Circle, MathMap, PointSet +simplify/cefit_circle_nonconformal_keep.map | needs Circle, PointSet +simplify/cefit_circle_nonconformal_keep.simp | needs Circle, PointSet simplify/cefit_circle_to_ellipse.map | needs Ellipse, PointSet simplify/cefit_circle_to_ellipse.simp | needs Ellipse, PointSet simplify/cefit_ellipse_to_circle.map | needs Circle, PointSet simplify/cefit_ellipse_to_circle.simp | needs Circle, PointSet simplify/cheby_linear_lone_reduce.map | needs ChebyMap simplify/chebymap_inverse_cancel.map | needs ChebyMap -simplify/cmpmap_decompose_middle.map | needs MathMap -simplify/cmpmap_decompose_middle.simp | needs MathMap -simplify/cmpmap_inverted_nested.map | needs MathMap -simplify/cmpmap_inverted_nested.simp | needs MathMap -simplify/cmpmap_parallel_in_series_merge.map | needs MathMap -simplify/cmpmap_parallel_series_dim_mismatch.map | needs MathMap -simplify/cmpmap_parallel_series_dim_mismatch.simp | needs MathMap -simplify/cmpmap_perm_swap_aconstants.map | needs MathMap -simplify/cmpmap_perm_swap_aconstants.simp | needs MathMap -simplify/cmpmap_perm_swap_bconstants.map | needs MathMap -simplify/cmpmap_perm_swap_bconstants.simp | needs MathMap -simplify/cmpmap_series_in_parallel_inverted.map | needs MathMap -simplify/cmpmap_series_in_parallel_inverted.simp | needs MathMap -simplify/cmpmap_solo_after_unit.map | needs MathMap -simplify/cmpmap_solo_after_unit.simp | needs MathMap simplify/defunc_cmpregion_component_unc.map | needs Box, PointSet simplify/defunc_cmpregion_component_unc.simp | needs Box, PointSet simplify/defunc_interval_point_at_origin.map | needs Box, PointSet @@ -106,18 +71,6 @@ simplify/defunc_pointlist_origin_axis.map | needs Box, PointSet simplify/defunc_pointlist_origin_axis.simp | needs Box, PointSet simplify/defunc_prism_box_interval.map | needs Box, PointSet, Prism simplify/defunc_prism_box_interval.simp | needs Box, PointSet -simplify/dssmap_inv_winmap_absorb.map | needs DssMap -simplify/dssmap_inv_winmap_absorb.simp | needs DssMap -simplify/dssmap_winmap_absorb.map | needs DssMap -simplify/dssmap_winmap_absorb.simp | needs DssMap -simplify/dssmap_zoom_no_merge.map | needs DssMap -simplify/dssmap_zoom_no_merge.simp | needs DssMap -simplify/grism_inverse_cancel.map | needs GrismMap -simplify/grism_inverse_cancel_tail.map | needs GrismMap -simplify/grism_zoom_inv_merge.map | needs GrismMap -simplify/grism_zoom_inv_merge.simp | needs GrismMap -simplify/grism_zoom_merge.map | needs GrismMap -simplify/grism_zoom_merge.simp | needs GrismMap simplify/interval_halfinf_simplify.map | needs Interval, PointSet simplify/interval_nullregion_merge.map | needs Interval, NullRegion, PointSet simplify/interval_nullregion_merge.simp | needs Interval, PointSet @@ -132,13 +85,6 @@ simplify/interval_self_simplify_cmp.map | needs Interval, PointSet simplify/interval_self_simplify_cmp.simp | needs Box, PointSet simplify/interval_unc_fillfactor_merge.map | needs Box, Interval, PointSet simplify/interval_unc_fillfactor_merge.simp | needs Box, Interval, PointSet -simplify/intra_invfwd_cancel.map | needs IntraMap -simplify/intra_invfwd_cancel_tail.map | needs IntraMap -simplify/intramap_inverse_cancel.map | needs IntraMap -simplify/lut_exactly_linear.map | needs LutMap -simplify/lut_inverse_cancel.map | needs LutMap -simplify/lut_linear_to_win.map | needs LutMap -simplify/math_inverse_cancel.map | needs MathMap simplify/merge_box_fillfactor_product.map | needs Box, PointSet simplify/merge_box_fillfactor_product.simp | needs Box, PointSet simplify/merge_box_meshsize_scaled.map | needs Box, PointSet @@ -152,35 +98,9 @@ simplify/neg_box_unc_mismatch.map | needs Box, PointSet simplify/neg_cheby_quadratic_no_reduce.map | needs ChebyMap simplify/neg_chebymap_standalone.map | needs ChebyMap simplify/neg_circle_cmpframe_sky_second.map | needs Circle, PointSet -simplify/neg_cmpmap_mode_mismatch.map | needs MathMap -simplify/neg_cmpmap_neighbour_nonexcmpmap.map | needs MathMap -simplify/neg_grism_different_attrs.map | needs GrismMap -simplify/neg_grism_fwd_then_nonzoom.map | needs GrismMap -simplify/neg_grism_inv_then_zoom.map | needs GrismMap -simplify/neg_grism_nonzoom_before_inv.map | needs GrismMap -simplify/neg_grism_parallel.map | needs GrismMap -simplify/neg_grism_same_direction.map | needs GrismMap -simplify/neg_grism_zoom_before_fwd.map | needs GrismMap simplify/neg_interval_parallel_nonregion.map | needs Interval, PointSet simplify/neg_interval_series.map | needs Interval, PointSet simplify/neg_interval_unbounded_pointlist.map | needs Interval, PointList, PointSet -simplify/neg_intra_diff_flag.map | needs IntraMap -simplify/neg_intra_diff_func.map | needs IntraMap -simplify/neg_intra_no_simpfi.map | needs IntraMap -simplify/neg_intra_no_simpif.map | needs IntraMap -simplify/neg_intra_nonintra_neighbour.map | needs IntraMap -simplify/neg_intra_parallel.map | needs IntraMap -simplify/neg_intra_same_direction.map | needs IntraMap -simplify/neg_lut_constant.map | needs LutMap -simplify/neg_lut_different_tables.map | needs LutMap -simplify/neg_lut_near_linear.map | needs LutMap -simplify/neg_lut_nonlinear.map | needs LutMap -simplify/neg_lut_nonlut_neighbour.map | needs LutMap -simplify/neg_lut_parallel.map | needs LutMap -simplify/neg_math_inv_text_mismatch.map | needs MathMap -simplify/neg_math_lone.map | needs MathMap -simplify/neg_math_no_simpfi.map | needs MathMap -simplify/neg_math_nonmath_neighbour.map | needs MathMap 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 @@ -189,22 +109,8 @@ simplify/neg_normmap_parallel.map | needs NormMap simplify/neg_normmap_parallel_sky.map | needs NormMap simplify/neg_nullregion_parallel_nonregion.map | needs NullRegion simplify/neg_nullregion_series.map | needs NullRegion -simplify/neg_parpair_aligned_irreducible.map | needs MathMap -simplify/neg_pcd_diff_centre.map | needs PcdMap -simplify/neg_pcd_diff_disco.map | needs PcdMap -simplify/neg_pcd_nonpcd_neighbour.map | needs PcdMap -simplify/neg_pcd_nonswappable_between.map | needs PcdMap -simplify/neg_pcd_parallel.map | needs PcdMap -simplify/neg_pcd_perm_nonswap.map | needs PcdMap -simplify/neg_pcd_same_invert.map | needs PcdMap -simplify/neg_pcd_zoom_no_target.map | needs PcdMap -simplify/neg_perm_no_merge.map | needs MathMap simplify/neg_pointlist_parallel_nonregion.map | needs PointList, PointSet simplify/neg_pointlist_series.map | needs PointList, PointSet -simplify/neg_ratemap_lower_nonrate.map | needs RateMap -simplify/neg_ratemap_nonratemap_neighbour.map | needs RateMap -simplify/neg_ratemap_parallel.map | needs RateMap -simplify/neg_ratemap_same_invert.map | needs RateMap simplify/neg_selectormap_not_equal.map | needs Box, PointSet, SelectorMap simplify/neg_selectormap_parallel.map | needs Box, PointSet, SelectorMap simplify/neg_selectormap_series_lower.map | needs Box, PointSet, SelectorMap @@ -213,16 +119,6 @@ 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_switchmap_not_equal.map | needs SwitchMap -simplify/neg_switchmap_parallel.map | needs SwitchMap -simplify/neg_switchmap_series.map | needs SwitchMap -simplify/neg_switchmap_series_lower.map | needs SwitchMap -simplify/neg_tranmap_adjacent_no_merge.map | needs MathMap, TranMap -simplify/neg_tranmap_nontranmap_neighbour.map | needs TranMap -simplify/neg_tranmap_oneway.map | needs MathMap, TranMap -simplify/neg_tranmap_parallel.map | needs TranMap -simplify/neg_tranmap_unequal_components.map | needs TranMap -simplify/neg_unit_parallel_forward.map | needs PcdMap simplify/neg_unitnormmap_flanked.map | needs UnitNormMap simplify/neg_unitnormmap_fwd_shift.map | needs UnitNormMap simplify/neg_unitnormmap_inv_fwd_diffcentre.map | needs UnitNormMap @@ -231,13 +127,9 @@ 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_wcs_nonperm_between.map | needs MathMap -simplify/neg_win_cmpmap_split_no_simplify.map | needs MathMap -simplify/neg_win_nonmergeable_series.map | needs MathMap simplify/neg_xph_nonxph_neighbour.map | needs XphMap simplify/neg_xph_not_opposite.map | needs XphMap simplify/neg_xph_parallel.map | needs XphMap -simplify/neg_zoom_parallel_lone.map | needs MathMap simplify/normmap_basic_frame_to_unit.map | needs NormMap simplify/normmap_duplicate_elim.map | needs NormMap simplify/normmap_duplicate_elim.simp | needs NormMap @@ -253,39 +145,12 @@ simplify/nullregion_self_simplify.map | needs NullRegion simplify/nullregion_self_simplify.simp | needs NullRegion simplify/nullregion_unc_fillfactor_merge.map | needs Box, NullRegion, PointSet simplify/nullregion_unc_fillfactor_merge.simp | needs Box, NullRegion, PointSet -simplify/parcomp_inverted_nested_reemitted.map | needs MathMap -simplify/parcomp_inverted_nested_reemitted.simp | needs MathMap -simplify/parcomp_inverted_reemitted.map | needs MathMap -simplify/parcomp_inverted_reemitted.simp | needs MathMap -simplify/parpair_one_side_reduces.map | needs MathMap -simplify/parpair_one_side_reduces.simp | needs MathMap -simplify/pcd_inverse_cancel.map | needs PcdMap -simplify/pcd_inverse_cancel_tail.map | needs PcdMap -simplify/pcd_inverted_zoom_swap.map | needs PcdMap -simplify/pcd_inverted_zoom_swap.simp | needs PcdMap -simplify/pcd_perm_swap_cancel.map | needs PcdMap -simplify/pcd_search_blocked.map | needs PcdMap -simplify/pcd_search_blocked.simp | needs PcdMap -simplify/pcd_swap_zoom_simplifies.map | needs PcdMap -simplify/pcd_swap_zoom_simplifies.simp | needs PcdMap -simplify/pcd_unit_series_merge.map | needs PcdMap -simplify/pcd_unit_series_merge.simp | needs PcdMap -simplify/pcd_zero_disc_lone.map | needs PcdMap -simplify/pcd_zero_disc_series.map | needs PcdMap -simplify/pcd_zero_to_unit.map | needs PcdMap -simplify/pcd_zoom_swap_cancel.map | needs PcdMap simplify/pointlist_parallel_merge_pair.map | needs PointList, PointSet simplify/pointlist_parallel_merge_pair.simp | needs PointList, PointSet simplify/pointlist_self_simplify.map | needs PointList, PointSet simplify/pointlist_self_simplify.simp | needs PointList, PointSet simplify/pointlist_unc_fillfactor_merge.map | needs Box, PointList, PointSet simplify/pointlist_unc_fillfactor_merge.simp | needs Box, PointList, PointSet -simplify/rate_inner_reduce_lone.map | needs RateMap -simplify/rate_inner_reduce_lone.simp | needs RateMap -simplify/rate_inner_reduce_series.map | needs RateMap -simplify/rate_inner_reduce_series.simp | needs RateMap -simplify/ratemap_simplify_interior.map | needs RateMap -simplify/ratemap_simplify_interior.simp | needs RateMap simplify/regbasepick_circle_permaxes.map | needs Circle, PointSet simplify/regbasepick_circle_permaxes.simp | needs Circle, PointSet simplify/regbasepick_cmpregion_subset.map | needs CmpRegion, Interval, PointSet @@ -304,41 +169,11 @@ simplify/setunc_unitmap_regionfs_omitted.map | needs Box, PointSet simplify/setunc_unitmap_regionfs_omitted.simp | needs Box, PointSet simplify/simpstab_box_linear_unc.map | needs Box, PointSet simplify/simpstab_box_linear_unc.simp | needs Box, PointSet -simplify/simpstab_box_nonlinear_unc.map | needs Box, MathMap, PointSet -simplify/simpstab_box_nonlinear_unc.simp | needs Box, MathMap, PointSet +simplify/simpstab_box_nonlinear_unc.map | needs Box, PointSet +simplify/simpstab_box_nonlinear_unc.simp | needs Box, PointSet simplify/simpstab_permmap_slice_unc.map | needs Box, PointSet simplify/simpstab_permmap_slice_unc.simp | needs Box, PointSet simplify/spline_inverse_cancel.map | needs SplineMap -simplify/switchmap_fwdonly_simplify.map | needs SwitchMap -simplify/switchmap_fwdonly_simplify.simp | needs SwitchMap -simplify/switchmap_internal_simplify.map | needs SwitchMap -simplify/switchmap_internal_simplify.simp | needs SwitchMap -simplify/switchmap_inv_fwdonly.map | needs SwitchMap -simplify/switchmap_inv_fwdonly.simp | needs SwitchMap -simplify/switchmap_inv_invonly.map | needs SwitchMap -simplify/switchmap_inv_invonly.simp | needs SwitchMap -simplify/switchmap_inverse_cancel.map | needs SwitchMap -simplify/switchmap_inverse_cancel_tail.map | needs SwitchMap -simplify/switchmap_invert_normalize.map | needs SwitchMap -simplify/switchmap_invert_normalize.simp | needs SwitchMap -simplify/switchmap_invonly_simplify.map | needs SwitchMap -simplify/switchmap_invonly_simplify.simp | needs SwitchMap -simplify/tranmap_adjacent_merge.map | needs TranMap -simplify/tranmap_adjacent_merge.simp | needs TranMap -simplify/tranmap_component_simplify.map | needs TranMap -simplify/tranmap_component_simplify.simp | needs TranMap -simplify/tranmap_equal_components.map | needs TranMap -simplify/tranmap_equal_components_in_list.map | needs TranMap -simplify/tranmap_invert_in_list.map | needs TranMap -simplify/tranmap_invert_in_list.simp | needs TranMap -simplify/tranmap_invert_normalize.map | needs TranMap -simplify/tranmap_invert_normalize.simp | needs TranMap -simplify/tranmap_merge_tail.map | needs TranMap -simplify/tranmap_merge_tail.simp | needs TranMap -simplify/unit_parallel_invert_clear.map | needs MathMap -simplify/unit_parallel_invert_clear.simp | needs MathMap -simplify/unit_parallel_invert_pcd.map | needs PcdMap -simplify/unit_parallel_invert_pcd.simp | needs PcdMap 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 diff --git a/src/test/resources/deferred/wcsconv.txt b/src/test/resources/deferred/wcsconv.txt index 16cad8c..f487199 100644 --- a/src/test/resources/deferred/wcsconv.txt +++ b/src/test/resources/deferred/wcsconv.txt @@ -2,8 +2,3 @@ # | # Rewritten by WcsconvTest with -Dast.writeDeferred=true. lsst2_fits-wcs | needs SplineMap -polco_native | needs MathMap -polco2_native | needs MathMap -freq-log_native | needs MathMap -grism_native | needs GrismMap -grism_fits-wcs | needs GrismMap diff --git a/src/test/resources/jniast-api-exclusions.txt b/src/test/resources/jniast-api-exclusions.txt index a694ee4..078758b 100644 --- a/src/test/resources/jniast-api-exclusions.txt +++ b/src/test/resources/jniast-api-exclusions.txt @@ -7,3 +7,5 @@ AstObject.finalize() | releases the C object behind a JNI wrapper; there is no C AstObject.getAstConstantI(String) | reads constants from the C library; they are ordinary static final fields Channel.finalize() | releases the C channel behind a JNI wrapper; there is no C object FitsChan.finalize() | writes the cards to the sink when the garbage collector frees the JNI wrapper; close() does it +IntraMap.finalize() | frees the JNI global reference to the Transformer behind the C IntraMap; there is no C object +DssMap.() | the default constructor Java gives jniast's DssMap, which makes a wrapper with no C object; C has no public DssMap constructor, so a DssMap is only read from a dump or made by simplification diff --git a/src/test/resources/oracle/dss_merge.json b/src/test/resources/oracle/dss_merge.json new file mode 100644 index 0000000..14e0524 --- /dev/null +++ b/src/test/resources/oracle/dss_merge.json @@ -0,0 +1,8 @@ +{ + "source": "crates/starlink-ast/tests/dss_merge_oracle/cases.rs", + "generator": "tools/oracle_fixtures/dss_merge_probe.c", + "rustCommit": "10f61689f19a5f1eacc7e653c7eab9b03809939f", + "consts": { + "CASES": [["0.1","0.7",0.09999999999999999,0.7],["1.234567890123456","-0.3333333333333333",1.234567890123456,-0.3333333333333333],["5.9","-1.2",5.9,-1.2],["2.8272374655684112","-1.0518122540502668",2.827237465568411,-1.0518122540502668]] + } +} diff --git a/src/test/resources/oracle/equal.json b/src/test/resources/oracle/equal.json new file mode 100644 index 0000000..b4d911b --- /dev/null +++ b/src/test/resources/oracle/equal.json @@ -0,0 +1,8 @@ +{ + "source": "crates/starlink-ast/tests/equal_oracle/cases.rs", + "generator": "tools/oracle_fixtures/equal_probe.c", + "rustCommit": "10f61689f19a5f1eacc7e653c7eab9b03809939f", + "consts": { + "CASES": [["winmap_self_inverse_vs_inverted_copy",false],["winmap_inverse_of_its_inverse",true],["selectormap_one_region_vs_two",false],["selectormap_vs_inverted_copy",false],["selectormap_1d_vs_inverted_copy",true],["wcsmap_pv_vs_none",false],["wcsmap_zero_pv_vs_none",false],["wcsmap_pv_vs_pv_with_one_cleared",true],["wcsmap_same_pv",true],["tranmap_vs_reread_without_component_invert",true]] + } +} diff --git a/src/test/resources/oracle/intramap.json b/src/test/resources/oracle/intramap.json new file mode 100644 index 0000000..4cea1d1 --- /dev/null +++ b/src/test/resources/oracle/intramap.json @@ -0,0 +1,12 @@ +{ + "source": "crates/starlink-ast/tests/intramap_oracle/cases.rs", + "generator": "tools/oracle_fixtures/intramap_probe.c", + "rustCommit": "10f61689f19a5f1eacc7e653c7eab9b03809939f", + "consts": { + "DUMPS": [["double_with_flag"," Begin IntraMap \t# Map points using a private transformation function\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Fname = \"double\" \t# Name of transformation function\n Iflag = \"v1\" \t# IntraMap identification string\n Purp = \"Double the value\" \t# Purpose of function\n Auth = \"AST test suite\" \t# Author's name\n Cntact = \"starlink-ast\" \t# Contact address\n End IntraMap\n"],["double_inverted"," Begin IntraMap \t# Map points using a private transformation function\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Fname = \"double\" \t# Name of transformation function\n Iflag = \"v1\" \t# IntraMap identification string\n Purp = \"Double the value\" \t# Purpose of function\n Auth = \"AST test suite\" \t# Author's name\n Cntact = \"starlink-ast\" \t# Contact address\n End IntraMap\n"],["nofwd"," Begin IntraMap \t# Map points using a private transformation function\n Nin = 1 \t# Number of input coordinates\n Fwd = 0 \t# Forward transformation not defined\n IsA Mapping \t# Mapping between coordinate systems\n Fname = \"nofwd\" \t# Name of transformation function\n Purp = \"No forward transformation\" \t# Purpose of function\n Auth = \"AST test suite\" \t# Author's name\n Cntact = \"starlink-ast\" \t# Contact address\n End IntraMap\n"]], + "INPUT": [1.5,-2.0,"BAD"], + "FORWARD": [3.0,-4.0,"BAD"], + "INVERSE": [0.75,-1.0,"BAD"], + "FULL_DUMPS": [["double_with_flag"," Begin IntraMap \t# Map points using a private transformation function\n# ID = \"\" \t# Object identification string\n# Ident = \"\" \t# Permanent Object identification string\n# UseDfs = 1 \t# Default attribute values can be used\n IsA Object \t# AST Object\n Nin = 1 \t# Number of input coordinates\n# Nout = 1 \t# Number of output coordinates\n# IsSimp = 0 \t# Mapping has not been simplified\n# ReSimp = 0 \t# Simplify uses all Mappings\n# AlSimp = 0 \t# Will not be used by restricted Simplify\n# Invert = 0 \t# Mapping not inverted\n# Fwd = 1 \t# Forward transformation defined\n# Inv = 1 \t# Inverse transformation defined\n# Report = 0 \t# Don't report coordinate transformations\n IsA Mapping \t# Mapping between coordinate systems\n Fname = \"double\" \t# Name of transformation function\n Iflag = \"v1\" \t# IntraMap identification string\n Purp = \"Double the value\" \t# Purpose of function\n Auth = \"AST test suite\" \t# Author's name\n Cntact = \"starlink-ast\" \t# Contact address\n End IntraMap\n"],["double_inverted"," Begin IntraMap \t# Map points using a private transformation function\n# ID = \"\" \t# Object identification string\n# Ident = \"\" \t# Permanent Object identification string\n# UseDfs = 1 \t# Default attribute values can be used\n IsA Object \t# AST Object\n Nin = 1 \t# Number of input coordinates\n# Nout = 1 \t# Number of output coordinates\n# IsSimp = 0 \t# Mapping has not been simplified\n# ReSimp = 0 \t# Simplify uses all Mappings\n# AlSimp = 0 \t# Will not be used by restricted Simplify\n Invert = 1 \t# Mapping inverted\n# Fwd = 1 \t# Forward transformation defined\n# Inv = 1 \t# Inverse transformation defined\n# Report = 0 \t# Don't report coordinate transformations\n IsA Mapping \t# Mapping between coordinate systems\n Fname = \"double\" \t# Name of transformation function\n Iflag = \"v1\" \t# IntraMap identification string\n Purp = \"Double the value\" \t# Purpose of function\n Auth = \"AST test suite\" \t# Author's name\n Cntact = \"starlink-ast\" \t# Contact address\n End IntraMap\n"],["nofwd"," Begin IntraMap \t# Map points using a private transformation function\n# ID = \"\" \t# Object identification string\n# Ident = \"\" \t# Permanent Object identification string\n# UseDfs = 1 \t# Default attribute values can be used\n IsA Object \t# AST Object\n Nin = 1 \t# Number of input coordinates\n# Nout = 1 \t# Number of output coordinates\n# IsSimp = 0 \t# Mapping has not been simplified\n# ReSimp = 0 \t# Simplify uses all Mappings\n# AlSimp = 0 \t# Will not be used by restricted Simplify\n# Invert = 0 \t# Mapping not inverted\n Fwd = 0 \t# Forward transformation not defined\n# Inv = 1 \t# Inverse transformation defined\n# Report = 0 \t# Don't report coordinate transformations\n IsA Mapping \t# Mapping between coordinate systems\n Fname = \"nofwd\" \t# Name of transformation function\n# Iflag = \"\" \t# IntraMap identification string\n Purp = \"No forward transformation\" \t# Purpose of function\n Auth = \"AST test suite\" \t# Author's name\n Cntact = \"starlink-ast\" \t# Contact address\n End IntraMap\n"]] + } +} diff --git a/src/test/resources/oracle/lutmap_forward.json b/src/test/resources/oracle/lutmap_forward.json new file mode 100644 index 0000000..cac311b --- /dev/null +++ b/src/test/resources/oracle/lutmap_forward.json @@ -0,0 +1,8 @@ +{ + "source": "crates/starlink-ast/tests/lutmap_forward_oracle/cases.rs", + "generator": "tools/oracle_fixtures/lutmap_forward_probe.c", + "rustCommit": "10f61689f19a5f1eacc7e653c7eab9b03809939f", + "consts": { + "CASES": [["linear_between_nodes",[0.1,0.7,2.9,3.3,8.15],1.0,0.3,false,[1.05,1.17,1.31,1.44,1.59,1.9,2.21,2.2],[0.20000000000000007,0.43999999999999984,0.773333333333334,1.7266666666666666,2.826666666666667,3.3,8.311666666666666,8.150000000000004]],["linear_beyond_ends",[0.1,0.7,2.9,3.3,8.15],1.0,0.3,false,[-3.0,0.4,2.3,9.0],[-7.9,-1.0999999999999999,9.766666666666666,118.08333333333336]],["linear_last_node_beside_bad",[1.0,"BAD",3.0],1.0,1.0,false,[1.0,2.0,3.0,3.5],["BAD","BAD","BAD","BAD"]],["nearest_half_increments",[0.1,0.7,2.9,3.3,8.15],1.0,0.3,true,[0.85,1.0,1.15,1.45,2.2,2.35,2.36],["BAD",0.1,0.1,2.9,8.15,"BAD","BAD"]],["nearest_last_node_beside_bad",[1.0,"BAD",3.0],1.0,1.0,true,[1.0,2.0,3.0,3.5],[1.0,"BAD",3.0,"BAD"]],["nearest_exact_half_increments",[0.1,0.7,2.9,3.3,8.15],1.0,1.0,true,[0.5,1.5,2.5,5.5],[0.1,0.7,2.9,"BAD"]]] + } +} diff --git a/src/test/resources/oracle/lutmap_inverse.json b/src/test/resources/oracle/lutmap_inverse.json new file mode 100644 index 0000000..77232e7 --- /dev/null +++ b/src/test/resources/oracle/lutmap_inverse.json @@ -0,0 +1,8 @@ +{ + "source": "crates/starlink-ast/tests/lutmap_inverse_oracle/cases.rs", + "generator": "tools/oracle_fixtures/lutmap_inverse_probe.c", + "rustCommit": "10f61689f19a5f1eacc7e653c7eab9b03809939f", + "consts": { + "CASES": [["one_bad_linear",[1.0,"BAD",3.0],1.0,1.0,false,[[1.0,"BAD"],[2.0,"BAD"],[3.0,"BAD"],[-0.5,0.25],[5.0,"BAD"],["BAD","BAD"]]],["one_bad_nearest",[1.0,"BAD",3.0],1.0,1.0,true,[[1.0,"BAD"],[2.0,"BAD"],[3.0,"BAD"],[-0.5,"BAD"],[5.0,"BAD"],["BAD","BAD"]]],["increasing_linear",[1.0,2.0,4.0,8.0],1.0,1.0,false,[[1.0,1.0],[1.5,1.5],[2.0,2.0],[3.0,2.5],[4.0,3.0],[6.0,3.5],[8.0,4.0],[-0.5,-0.5],[10.0,4.5],["BAD","BAD"]]],["increasing_nearest",[1.0,2.0,4.0,8.0],1.0,1.0,true,[[1.0,1.0],[1.5,2.0],[2.0,2.0],[3.0,3.0],[4.0,3.0],[6.0,4.0],[8.0,4.0],[-0.5,"BAD"],[10.0,"BAD"],["BAD","BAD"]]],["decreasing_linear",[8.0,4.0,2.0,1.0],1.0,1.0,false,[[8.0,1.0],[6.0,1.5],[4.0,2.0],[3.0,2.5],[2.0,3.0],[1.5,3.5],[1.0,4.0],[-0.5,5.5],[10.0,0.5],["BAD","BAD"]]],["decreasing_nearest",[8.0,4.0,2.0,1.0],1.0,1.0,true,[[8.0,1.0],[6.0,2.0],[4.0,2.0],[3.0,3.0],[2.0,3.0],[1.5,4.0],[1.0,4.0],[-0.5,"BAD"],[10.0,"BAD"],["BAD","BAD"]]],["increasing_bad_runs_linear",[0.0,"BAD",2.0,3.0,"BAD","BAD",6.0,7.0],0.0,2.0,false,[[0.0,"BAD"],[1.0,"BAD"],[2.0,"BAD"],[2.5,"BAD"],[3.0,"BAD"],[4.5,"BAD"],[6.0,12.0],[6.5,13.0],[7.0,14.0],[-1.5,-1.5],[9.0,18.0],["BAD","BAD"]]],["increasing_bad_runs_nearest",[0.0,"BAD",2.0,3.0,"BAD","BAD",6.0,7.0],0.0,2.0,true,[[0.0,"BAD"],[1.0,"BAD"],[2.0,"BAD"],[2.5,"BAD"],[3.0,"BAD"],[4.5,"BAD"],[6.0,12.0],[6.5,14.0],[7.0,14.0],[-1.5,"BAD"],[9.0,"BAD"],["BAD","BAD"]]],["decreasing_bad_linear",[7.0,"BAD",5.0,4.0,"BAD",2.0],-3.0,0.5,false,[[7.0,-3.0],[6.0,"BAD"],[5.0,"BAD"],[4.5,"BAD"],[4.0,"BAD"],[3.0,"BAD"],[2.0,"BAD"],[0.5,"BAD"],[9.0,-3.5],["BAD","BAD"]]],["decreasing_bad_nearest",[7.0,"BAD",5.0,4.0,"BAD",2.0],-3.0,0.5,true,[[7.0,-3.0],[6.0,"BAD"],[5.0,"BAD"],[4.5,"BAD"],[4.0,"BAD"],[3.0,"BAD"],[2.0,"BAD"],[0.5,"BAD"],[9.0,"BAD"],["BAD","BAD"]]],["flat_linear",[1.0,2.0,2.0,3.0],0.0,1.0,false,[[1.0,0.0],[1.5,0.5],[2.0,"BAD"],[2.0,"BAD"],[2.0,"BAD"],[2.5,2.5],[3.0,3.0],[-0.5,-1.5],[5.0,5.0],["BAD","BAD"]]],["flat_nearest",[1.0,2.0,2.0,3.0],0.0,1.0,true,[[1.0,0.0],[1.5,1.0],[2.0,"BAD"],[2.0,"BAD"],[2.0,"BAD"],[2.5,3.0],[3.0,3.0],[-0.5,"BAD"],[5.0,"BAD"],["BAD","BAD"]]],["flat_after_bad_linear",[1.0,"BAD",2.0,2.0,3.0],0.0,1.0,false,[[1.0,"BAD"],[1.5,"BAD"],[2.0,"BAD"],[2.0,"BAD"],[2.0,"BAD"],[2.5,3.5],[3.0,4.0],[-0.5,-1.5],[5.0,6.0],["BAD","BAD"]]],["flat_after_bad_nearest",[1.0,"BAD",2.0,2.0,3.0],0.0,1.0,true,[[1.0,"BAD"],[1.5,"BAD"],[2.0,"BAD"],[2.0,"BAD"],[2.0,"BAD"],[2.5,4.0],[3.0,4.0],[-0.5,"BAD"],[5.0,"BAD"],["BAD","BAD"]]],["bad_ends_linear",["BAD",1.0,2.0,4.0,"BAD"],0.0,1.0,false,[[1.0,1.0],[1.5,1.5],[2.0,2.0],[3.0,2.5],[4.0,3.0],[-0.5,-0.5],[6.0,4.0],["BAD","BAD"]]],["bad_ends_nearest",["BAD",1.0,2.0,4.0,"BAD"],0.0,1.0,true,[[1.0,1.0],[1.5,2.0],[2.0,2.0],[3.0,3.0],[4.0,3.0],[-0.5,"BAD"],[6.0,"BAD"],["BAD","BAD"]]],["negative_increment_linear",[1.0,3.0,6.0,"BAD",10.0],10.0,-0.5,false,[[1.0,10.0],[2.0,9.75],[3.0,9.5],[4.5,9.25],[6.0,"BAD"],[8.0,"BAD"],[10.0,"BAD"],[-0.5,10.375],[12.0,"BAD"],["BAD","BAD"]]],["negative_increment_nearest",[1.0,3.0,6.0,"BAD",10.0],10.0,-0.5,true,[[1.0,10.0],[2.0,9.5],[3.0,9.5],[4.5,9.0],[6.0,"BAD"],[8.0,"BAD"],[10.0,"BAD"],[-0.5,"BAD"],[12.0,"BAD"],["BAD","BAD"]]],["uneven_linear",[1.0,1.5,4.0],2.0,3.0,false,[[1.0,2.0],[1.25,3.5],[1.5,5.0],[2.75,6.5],[4.0,8.0],[-0.5,-7.0],[6.0,10.399999999999999],["BAD","BAD"]]],["uneven_nearest",[1.0,1.5,4.0],2.0,3.0,true,[[1.0,2.0],[1.25,5.0],[1.5,5.0],[2.75,8.0],[4.0,8.0],[-0.5,"BAD"],[6.0,"BAD"],["BAD","BAD"]]]] + } +} diff --git a/src/test/resources/probes/alt_offset_probe.c b/src/test/resources/probes/alt_offset_probe.c new file mode 100644 index 0000000..c7bba8c --- /dev/null +++ b/src/test/resources/probes/alt_offset_probe.c @@ -0,0 +1,71 @@ +/* alt_offset_probe -- the Mapping C writes alternate description B of + * case alt_axes_alt_offset of oracle/fitschan_cursor.json from: the header + * of that case read with FITS-WCS, the simplified Mapping from the pixel + * Frame to Frame 3 (the offset SkyFrame, Ident B, Domain SKY_POLE) dumped, + * and transformed at a grid of 101 by 11 pixel positions spanning the + * image, (1 + 0.99 i, 1 + 19.9 j), each output printed with %a. + * + * Built against the C library at 3d3f255f with its static libraries (see + * fitslog_probe.c) and run as ./alt_offset_probe > alt_offset_probe.out; + * the output is committed as the string "output" of alt_offset_probe.json, + * as fitslog_probe.c describes. */ +#include +#include "ast.h" + +int main( void ) { + int status = 0; + astWatch( &status ); + astBegin; + const char *cards[] = { + "NAXIS = 2", + "NAXIS1 = 100", + "NAXIS2 = 200", + "CRPIX1 = 50", + "CRPIX2 = 100", + "CRVAL1 = 10", + "CRVAL2 = 20", + "CD1_1 = -0.001", + "CD2_2 = 0.001", + "RADESYS = 'ICRS'", + "CTYPE1 = 'RA---TAN'", + "CTYPE2 = 'DEC--TAN'", + "MJD-OBS = 55000.0", + "CTYPE1B = 'OFLN-TAN'", + "CTYPE2B = 'OFLT-TAN'", + "CRVAL1B = 0", + "CRVAL2B = 0", + "CRPIX1B = 1", + "CRPIX2B = 1", + "CD1_1B = -0.001", + "CD2_2B = 0.001", + "RADESYSB= 'ICRS'", + "SREF1B = 0.5", + "SREF2B = 0.3", + "SREFISB = 'POLE'", + "CTYPE1D = 'GLON-TAN'", + "CTYPE2D = 'GLAT-TAN'", + "CRVAL1D = 1", + "CRVAL2D = 2", + "CRPIX1D = 1", + "CRPIX2D = 1", + "CD1_1D = -0.001", + "CD2_2D = 0.001", + NULL }; + AstFitsChan *fc = astFitsChan( NULL, NULL, "Encoding=FITS-WCS" ); + for( int i = 0; cards[ i ]; i++ ) astPutFits( fc, cards[ i ], 0 ); + astClear( fc, "Card" ); + AstFrameSet *fs = astRead( fc ); + AstMapping *map = astSimplify( astGetMapping( fs, AST__BASE, 3 ) ); + printf( "== dump\n" ); + astShow( map ); + printf( "== grid\n" ); + for( int j = 0; j < 11; j++ ) { + for( int i = 0; i < 101; i++ ) { + double in[ 2 ] = { 1.0 + 0.99*i, 1.0 + 19.9*j }, out[ 2 ]; + astTranN( map, 1, 2, 1, in, 1, 2, 1, out ); + printf( "%a %a\n", out[ 0 ], out[ 1 ] ); + } + } + astEnd; + return 0; +} diff --git a/src/test/resources/probes/alt_offset_probe.json b/src/test/resources/probes/alt_offset_probe.json new file mode 100644 index 0000000..4f5dd63 --- /dev/null +++ b/src/test/resources/probes/alt_offset_probe.json @@ -0,0 +1,4 @@ +{ + "source": "probes/alt_offset_probe.c", + "output": "== dump\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.7453292519943296e-05 \t# Shift for axis 1\n Scl1 = -1.7453292519943296e-05 \t# Scale factor for axis 1\n Sft2 = -1.7453292519943296e-05 \t# Shift for axis 2\n Scl2 = 1.7453292519943296e-05 \t# Scale factor for axis 2\n End WinMap\n MapB = \t# Second 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 InvA = 1 \t# First Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin WcsMap \t# FITS-WCS sky projection\n Nin = 2 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n Type = \"TAN\" \t# Gnomonic projection\n End WcsMap\n MapB = \t# Second 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 InvA = 1 \t# First Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin SphMap \t# Cartesian to Spherical mapping\n Nin = 3 \t# Number of input coordinates\n Nout = 2 \t# Number of output coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n UntRd = 1 \t# All input vectors have unit length\n PlrLg = 0 \t# Polar longitude (rad.s)\n End SphMap\n MapB = \t# Second component Mapping\n Begin CmpMap \t# Compound Mapping\n Nin = 3 \t# Number of input coordinates\n Nout = 2 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin MatrixMap \t# Matrix transformation\n Nin = 3 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n M0 = 6.123233995736766e-17 \t# Forward matrix value\n M1 = 0 \t# Forward matrix value\n M2 = 1 \t# Forward matrix value\n M3 = 0 \t# Forward matrix value\n M4 = 1 \t# Forward matrix value\n M5 = 0 \t# Forward matrix value\n M6 = -1 \t# Forward matrix value\n M7 = 0 \t# Forward matrix value\n M8 = 6.123233995736766e-17 \t# Forward matrix value\n IM0 = 6.123233995736766e-17 \t# Inverse matrix value\n IM1 = 0 \t# Inverse matrix value\n IM2 = -1 \t# Inverse matrix value\n IM3 = 0 \t# Inverse matrix value\n IM4 = 1 \t# Inverse matrix value\n IM5 = 0 \t# Inverse matrix value\n IM6 = 1 \t# Inverse matrix value\n IM7 = 0 \t# Inverse matrix value\n IM8 = 6.123233995736766e-17 \t# Inverse matrix value\n Form = \"Full\" \t# Matrix storage form\n End MatrixMap\n MapB = \t# Second component Mapping\n Begin SphMap \t# Cartesian to Spherical mapping\n Nin = 3 \t# Number of input coordinates\n Nout = 2 \t# Number of output coordinates\n IsA Mapping \t# Mapping between coordinate systems\n UntRd = 1 \t# All input vectors have unit length\n PlrLg = 0 \t# Polar longitude (rad.s)\n End SphMap\n End CmpMap\n End CmpMap\n End CmpMap\n End CmpMap\n== grid\n0x0p+0 0x0p+0\n-0x1.21e3b515f4699p-16 0x1.1a61236c51bbfp-54\n-0x1.21e3b5149234cp-15 0x1.1a5fe3a5f3a2fp-54\n-0x1.b2d58f9b4234cp-15 0x1.1a5ea3de2b7abp-54\n-0x1.21e3b50ec51a6p-14 0x1.1a5d6414f9481p-54\n-0x1.6a5ca24d011a7p-14 0x1.1a5c244a5d0fap-54\n-0x1.b2d58f87a51a6p-14 0x1.1a5ae47e56d62p-54\n-0x1.fb4e7cbde91a6p-14 0x1.1a59a4b0e6a08p-54\n-0x1.21e3b4f78a8d3p-13 0x1.1a5864e20c73ap-54\n-0x1.46202b8d3a8d3p-13 0x1.1a572511c8543p-54\n-0x1.6a5ca21fa68d3p-13 0x1.1a55e5401a471p-54\n-0x1.8e9918ae708d3p-13 0x1.1a54a56d0251p-54\n-0x1.b2d58f393c8d3p-13 0x1.1a5365988076dp-54\n-0x1.d71205bfac8d3p-13 0x1.1a5225c294bd7p-54\n-0x1.fb4e7c41648d3p-13 0x1.1a50e5eb3f298p-54\n-0x1.0fc5795f0446ap-12 0x1.1a4fa6127fbffp-54\n-0x1.21e3b49a9d46ap-12 0x1.1a4e663856858p-54\n-0x1.3401efd34d46ap-12 0x1.1a4d265cc37fp-54\n-0x1.46202b08e9469p-12 0x1.1a4be67fc6b13p-54\n-0x1.583e663b40469p-12 0x1.1a4aa6a16021p-54\n-0x1.6a5ca16a23469p-12 0x1.1a4966c18fd35p-54\n-0x1.7c7adc9567469p-12 0x1.1a4826e055ccap-54\n-0x1.8e9917bcda46ap-12 0x1.1a46e6fdb211fp-54\n-0x1.a0b752e04f469p-12 0x1.1a45a719a4a82p-54\n-0x1.b2d58dff9846ap-12 0x1.1a4467342d93dp-54\n-0x1.c4f3c91a8546ap-12 0x1.1a43274d4cdap-54\n-0x1.d7120430e846ap-12 0x1.1a41e765027f6p-54\n-0x1.e9303f4293469p-12 0x1.1a40a77b4e88fp-54\n-0x1.fb4e7a4f5846ap-12 0x1.1a3f679030fb5p-54\n-0x1.06b65aab84235p-11 0x1.1a3e27a3a9db3p-54\n-0x1.0fc5782cba235p-11 0x1.1a3ce7b5b92dbp-54\n-0x1.18d495ab37235p-11 0x1.1a3ba7c65ef78p-54\n-0x1.21e3b326e4235p-11 0x1.1a3a67d59b3d6p-54\n-0x1.2af2d09fa9a34p-11 0x1.1a3927e36e042p-54\n-0x1.3401ee1570a35p-11 0x1.1a37e7efd750ap-54\n-0x1.3d110b8821235p-11 0x1.1a36a7fad727cp-54\n-0x1.462028f7a5235p-11 0x1.1a3568046d8e2p-54\n-0x1.4f2f4663e4a35p-11 0x1.1a34280c9a88cp-54\n-0x1.583e63ccc8235p-11 0x1.1a32e8135e1c6p-54\n-0x1.614d813239234p-11 0x1.1a31a818b84dcp-54\n-0x1.6a5c9e9420235p-11 0x1.1a30681ca921cp-54\n-0x1.736bbbf265235p-11 0x1.1a2f281f309d5p-54\n-0x1.7c7ad94cf2a35p-11 0x1.1a2de8204ec4ep-54\n-0x1.8589f6a3b0234p-11 0x1.1a2ca820039dap-54\n-0x1.8e9913f686234p-11 0x1.1a2b681e4f2c5p-54\n-0x1.97a831455da35p-11 0x1.1a2a281b3175cp-54\n-0x1.a0b74e9020a35p-11 0x1.1a28e816aa7e7p-54\n-0x1.a9c66bd6b6235p-11 0x1.1a27a810ba4bbp-54\n-0x1.b2d5891908a35p-11 0x1.1a26680960e1fp-54\n-0x1.bbe4a656ffa36p-11 0x1.1a2528009e464p-54\n-0x1.c4f3c39084235p-11 0x1.1a23e7f6727d4p-54\n-0x1.ce02e0c57ea35p-11 0x1.1a22a7eadd8bep-54\n-0x1.d711fdf5d8235p-11 0x1.1a2167dddf77p-54\n-0x1.e0211b217aa34p-11 0x1.1a2027cf78432p-54\n-0x1.e93038484d234p-11 0x1.1a1ee7bfa7f58p-54\n-0x1.f23f556a38a35p-11 0x1.1a1da7ae6e92bp-54\n-0x1.fb4e728727235p-11 0x1.1a1c679bcc1f9p-54\n-0x1.022ec7cf8011bp-10 0x1.1a1b2787c0a1p-54\n-0x1.06b65658d691bp-10 0x1.1a19e7724c1bbp-54\n-0x1.0b3de4df8b11ap-10 0x1.1a18a75b6e94ap-54\n-0x1.0fc573639291bp-10 0x1.1a17674328104p-54\n-0x1.144d01e4e0d1ap-10 0x1.1a1627297893fp-54\n-0x1.18d490636a91ap-10 0x1.1a14e70e60242p-54\n-0x1.1d5c1edf2411bp-10 0x1.1a13a6f1dec5cp-54\n-0x1.21e3ad5801d1ap-10 0x1.1a1266d3f47dap-54\n-0x1.266b3bcdf811bp-10 0x1.1a1126b4a1509p-54\n-0x1.2af2ca40fb11ap-10 0x1.1a0fe693e5436p-54\n-0x1.2f7a58b10011bp-10 0x1.1a0ea671c05adp-54\n-0x1.3401e71dfa51ap-10 0x1.1a0d664e329bdp-54\n-0x1.38897587de91bp-10 0x1.1a0c26293c0b3p-54\n-0x1.3d1103eea191ap-10 0x1.1a0ae602dcadcp-54\n-0x1.419892523711ap-10 0x1.1a09a5db14886p-54\n-0x1.462020b293d1ap-10 0x1.1a0865b1e39fdp-54\n-0x1.4aa7af0fac51bp-10 0x1.1a07258749f8dp-54\n-0x1.4f2f3d697511ap-10 0x1.1a05e55b47984p-54\n-0x1.53b6cbbfe251bp-10 0x1.1a04a52ddc82fp-54\n-0x1.583e5a12e811bp-10 0x1.1a0364ff08bddp-54\n-0x1.5cc5e8627b11ap-10 0x1.1a0224cecc4d9p-54\n-0x1.614d76ae8f91bp-10 0x1.1a00e49d27372p-54\n-0x1.65d504f719d1ap-10 0x1.19ffa46a197f5p-54\n-0x1.6a5c933c0e91bp-10 0x1.19fe6435a32aep-54\n-0x1.6ee4217d61d1ap-10 0x1.19fd23ffc43ebp-54\n-0x1.736bafbb0851ap-10 0x1.19fbe3c87cbf7p-54\n-0x1.77f33df4f651ap-10 0x1.19faa38fccb23p-54\n-0x1.7c7acc2b2051ap-10 0x1.19f96355b41b9p-54\n-0x1.81025a5d7a51ap-10 0x1.19f8231a33009p-54\n-0x1.8589e88bf911bp-10 0x1.19f6e2dd4965dp-54\n-0x1.8a1176b69091ap-10 0x1.19f5a29ef7506p-54\n-0x1.8e9904dd35d1bp-10 0x1.19f4625f3cc4ep-54\n-0x1.932092ffdcd1bp-10 0x1.19f3221e19c82p-54\n-0x1.97a8211e79d1bp-10 0x1.19f1e1db8e5f2p-54\n-0x1.9c2faf390151ap-10 0x1.19f0a1979a8eap-54\n-0x1.a0b73d4f67d1bp-10 0x1.19ef61523e5b7p-54\n-0x1.a53ecb61a191ap-10 0x1.19ee210b79ca8p-54\n-0x1.a9c6596fa2d1ap-10 0x1.19ece0c34ce07p-54\n-0x1.ae4de7796091bp-10 0x1.19eba079b7a22p-54\n-0x1.b2d5757ece91ap-10 0x1.19ea602eba147p-54\n-0x1.b75d037fe151bp-10 0x1.19e91fe2543c6p-54\n-0x1.bbe4917c8d91ap-10 0x1.19e7df94861e6p-54\n-0x1.c06c1f74c711ap-10 0x1.19e69f454fbfbp-54\n-0x1.c4f3ad6882d1ap-10 0x1.19e55ef4b124ep-54\n0x1.91ba1a1a6ae4dp-65 0x1.6c3123835e8d3p-12\n-0x1.21e3b516097fcp-16 0x1.6c3123827578p-12\n-0x1.21e3b51495588p-15 0x1.6c31237fb86e1p-12\n-0x1.b2d58f9b3e42bp-15 0x1.6c31237b288fp-12\n-0x1.21e3b50ec6d3ap-14 0x1.6c312374c6e6fp-12\n-0x1.6a5ca24d064b6p-14 0x1.6c31236c91201p-12\n-0x1.b2d58f87a412bp-14 0x1.6c312362881fbp-12\n-0x1.fb4e7cbde74afp-14 0x1.6c312356acb3dp-12\n-0x1.21e3b4f78aed9p-13 0x1.6c312348fe7efp-12\n-0x1.46202b8d399a4p-13 0x1.6c3123397bed9p-12\n-0x1.6a5ca21fa5984p-13 0x1.6c3123282847ep-12\n-0x1.8e9918ae6f6b5p-13 0x1.6c31231500b0ap-12\n-0x1.b2d58f393b2dcp-13 0x1.6c31230006436p-12\n-0x1.d71205bfac315p-13 0x1.6c3122e939263p-12\n-0x1.fb4e7c4163dbp-13 0x1.6c3122d09815dp-12\n-0x1.0fc5795f043e8p-12 0x1.6c3122b625703p-12\n-0x1.21e3b49a9c994p-12 0x1.6c312299de73dp-12\n-0x1.3401efd34e39cp-12 0x1.6c31227bc55f6p-12\n-0x1.46202b08e925dp-12 0x1.6c31225bd85cdp-12\n-0x1.583e663b40d68p-12 0x1.6c31223a199e3p-12\n-0x1.6a5ca16a247fcp-12 0x1.6c312216869b1p-12\n-0x1.7c7adc95668e7p-12 0x1.6c3121f1205c1p-12\n-0x1.8e9917bcda5fap-12 0x1.6c3121c9e8952p-12\n-0x1.a0b752e04f75bp-12 0x1.6c3121a0dd505p-12\n-0x1.b2d58dff97e0fp-12 0x1.6c312175ff0e9p-12\n-0x1.c4f3c91a8477fp-12 0x1.6c3121494d404p-12\n-0x1.d7120430e8655p-12 0x1.6c31211ac9389p-12\n-0x1.e9303f42935c8p-12 0x1.6c3120ea7183cp-12\n-0x1.fb4e7a4f5874ep-12 0x1.6c3120b84753p-12\n-0x1.06b65aab842a9p-11 0x1.6c31208449fb9p-12\n-0x1.0fc5782cb994ep-11 0x1.6c31204e7897ep-12\n-0x1.18d495ab3728ep-11 0x1.6c312016d5beep-12\n-0x1.21e3b326e40a9p-11 0x1.6c311fdd5f406p-12\n-0x1.2af2d09fa9d22p-11 0x1.6c311fa2162d2p-12\n-0x1.3401ee157040bp-11 0x1.6c311f64f949dp-12\n-0x1.3d110b8821766p-11 0x1.6c311f260a36dp-12\n-0x1.462028f7a5469p-11 0x1.6c311ee547d5ep-12\n-0x1.4f2f4663e48cfp-11 0x1.6c311ea2b246ap-12\n-0x1.583e63ccc8514p-11 0x1.6c311e5e49d4ap-12\n-0x1.614d8132389edp-11 0x1.6c311e180dbdap-12\n-0x1.6a5c9e9420523p-11 0x1.6c311dd0002ap-12\n-0x1.736bbbf265dd7p-11 0x1.6c311d861eb5cp-12\n-0x1.7c7ad94cf225dp-11 0x1.6c311d3a69909p-12\n-0x1.8589f6a3b00b4p-11 0x1.6c311cece2bfp-12\n-0x1.8e9913f68651cp-11 0x1.6c311c9d8856cp-12\n-0x1.97a831455e181p-11 0x1.6c311c4c5ab18p-12\n-0x1.a0b74e9020eb1p-11 0x1.6c311bf95a82fp-12\n-0x1.a9c66bd6b6767p-11 0x1.6c311ba486d32p-12\n-0x1.b2d5891908e2bp-11 0x1.6c311b4de0d43p-12\n-0x1.bbe4a656ffb87p-11 0x1.6c311af56778ep-12\n-0x1.c4f3c39083eb5p-11 0x1.6c311a9b1aec2p-12\n-0x1.ce02e0c57ee2cp-11 0x1.6c311a3efbb1cp-12\n-0x1.d711fdf5d8c4ep-11 0x1.6c3119e1094a7p-12\n-0x1.e0211b217a4cap-11 0x1.6c31198143b14p-12\n-0x1.e93038484c545p-11 0x1.6c31191faaf9dp-12\n-0x1.f23f556a38b4bp-11 0x1.6c3118bc3fefap-12\n-0x1.fb4e728726e2dp-11 0x1.6c3118570198ap-12\n-0x1.022ec7cf80039p-10 0x1.6c3117eff03efp-12\n-0x1.06b65658d64ddp-10 0x1.6c3117870bb02p-12\n-0x1.0b3de4df8b11p-10 0x1.6c31171c546ecp-12\n-0x1.0fc5736392638p-10 0x1.6c3116afca124p-12\n-0x1.144d01e4e0c51p-10 0x1.6c3116416cc25p-12\n-0x1.18d490636ab9cp-10 0x1.6c3115d13caafp-12\n-0x1.1d5c1edf241e7p-10 0x1.6c31155f391ebp-12\n-0x1.21e3ad5801d9ap-10 0x1.6c3114eb62c8cp-12\n-0x1.266b3bcdf8174p-10 0x1.6c311475b964dp-12\n-0x1.2af2ca40fb683p-10 0x1.6c3113fe3d2bbp-12\n-0x1.2f7a58b1000acp-10 0x1.6c311384edf03p-12\n-0x1.3401e71dfa2bcp-10 0x1.6c311309cb73ep-12\n-0x1.38897587de924p-10 0x1.6c31128cd62e8p-12\n-0x1.3d1103eea1686p-10 0x1.6c31120e0dddap-12\n-0x1.41989252373cdp-10 0x1.6c31118d72b43p-12\n-0x1.462020b29412p-10 0x1.6c31110b0445bp-12\n-0x1.4aa7af0facc66p-10 0x1.6c311086c31d8p-12\n-0x1.4f2f3d69753a7p-10 0x1.6c311000aeabep-12\n-0x1.53b6cbbfe2401p-10 0x1.6c310f78c76bbp-12\n-0x1.583e5a12e8209p-10 0x1.6c310eef0d41p-12\n-0x1.5cc5e8627af52p-10 0x1.6c310e637fdd8p-12\n-0x1.614d76ae8f3fdp-10 0x1.6c310dd61f65ap-12\n-0x1.65d504f719c6cp-10 0x1.6c310d46ec3f8p-12\n-0x1.6a5c933c0e896p-10 0x1.6c310cb5e6049p-12\n-0x1.6ee4217d620e5p-10 0x1.6c310c230cda1p-12\n-0x1.736bafbb08938p-10 0x1.6c310b8e609bp-12\n-0x1.77f33df4f6881p-10 0x1.6c310af7e1551p-12\n-0x1.7c7acc2b204cp-10 0x1.6c310a5f8f074p-12\n-0x1.81025a5d7a591p-10 0x1.6c3109c569c79p-12\n-0x1.8589e88bf8c77p-10 0x1.6c310929714fcp-12\n-0x1.8a1176b6909cap-10 0x1.6c31088ba6398p-12\n-0x1.8e9904dd35e08p-10 0x1.6c3107ec082ecp-12\n-0x1.932092ffdcc6cp-10 0x1.6c31074a97052p-12\n-0x1.97a8211e79b17p-10 0x1.6c3106a752bd8p-12\n-0x1.9c2faf39015d8p-10 0x1.6c3106023ba8ep-12\n-0x1.a0b73d4f67d1p-10 0x1.6c31055b51751p-12\n-0x1.a53ecb61a188dp-10 0x1.6c3104b2943bp-12\n-0x1.a9c6596fa3117p-10 0x1.6c310408041dfp-12\n-0x1.ae4de779609fp-10 0x1.6c31035ba0f6fp-12\n-0x1.b2d5757ece8d6p-10 0x1.6c3102ad6abf9p-12\n-0x1.b75d037fe18bep-10 0x1.6c3101fd61bap-12\n-0x1.bbe4917c8d8fcp-10 0x1.6c31014b858b4p-12\n-0x1.c06c1f74c6e64p-10 0x1.6c310097d621cp-12\n-0x1.c4f3ad6882bffp-10 0x1.6c30ffe254273p-12\n0x1.91ba1a1a6aa0ep-64 0x1.6c3120a24b469p-11\n-0x1.21e3b51608fcap-16 0x1.6c3120a161ccfp-11\n-0x1.21e3b5149587fp-15 0x1.6c31209ea5a08p-11\n-0x1.b2d58f9b3eb73p-15 0x1.6c31209a15e7cp-11\n-0x1.21e3b50ec6989p-14 0x1.6c312093b3939p-11\n-0x1.6a5ca24d063f2p-14 0x1.6c31208b7e0b1p-11\n-0x1.b2d58f87a445bp-14 0x1.6c31208175424p-11\n-0x1.fb4e7cbde7c6ep-14 0x1.6c3120759a04p-11\n-0x1.21e3b4f78adaap-13 0x1.6c312067eb5fp-11\n-0x1.46202b8d39fcep-13 0x1.6c31205869543p-11\n-0x1.6a5ca21fa5da9p-13 0x1.6c31204715832p-11\n-0x1.8e9918ae6ffe7p-13 0x1.6c312033ee318p-11\n-0x1.b2d58f393b75ep-13 0x1.6c31201ef379fp-11\n-0x1.d71205bfac1cep-13 0x1.6c31200826111p-11\n-0x1.fb4e7c41645d3p-13 0x1.6c311fef856f2p-11\n-0x1.0fc5795f03ae4p-12 0x1.6c311fd511aacp-11\n-0x1.21e3b49a9cd4p-12 0x1.6c311fb8cbb9bp-11\n-0x1.3401efd34d92cp-12 0x1.6c311f9ab1972p-11\n-0x1.46202b08e9109p-12 0x1.6c311f7ac5431p-11\n-0x1.583e663b40607p-12 0x1.6c311f5906201p-11\n-0x1.6a5ca16a249bep-12 0x1.6c311f3573b79p-11\n-0x1.7c7adc9567817p-12 0x1.6c311f100e454p-11\n-0x1.8e9917bcdab47p-12 0x1.6c311ee8d5e46p-11\n-0x1.a0b752e04fae4p-12 0x1.6c311ebfca842p-11\n-0x1.b2d58dff979a3p-12 0x1.6c311e94ebd74p-11\n-0x1.c4f3c91a8502fp-12 0x1.6c311e683ab44p-11\n-0x1.d7120430e7fe7p-12 0x1.6c311e39b5ee7p-11\n-0x1.e9303f42935c4p-12 0x1.6c311e095e8bp-11\n-0x1.fb4e7a4f57b17p-12 0x1.6c311dd733cecp-11\n-0x1.06b65aab83fbep-11 0x1.6c311da336c4p-11\n-0x1.0fc5782cb9f44p-11 0x1.6c311d6d66225p-11\n-0x1.18d495ab3761cp-11 0x1.6c311d35c3148p-11\n-0x1.21e3b326e423cp-11 0x1.6c311cfc4c6d5p-11\n-0x1.2af2d09fa99ebp-11 0x1.6c311cc102fd5p-11\n-0x1.3401ee157097p-11 0x1.6c311c83e6bffp-11\n-0x1.3d110b8820e73p-11 0x1.6c311c44f6a3ap-11\n-0x1.462028f7a5126p-11 0x1.6c311c0434aebp-11\n-0x1.4f2f4663e46dfp-11 0x1.6c311bc19f39bp-11\n-0x1.583e63ccc858bp-11 0x1.6c311b7d36f2ap-11\n-0x1.614d81323959fp-11 0x1.6c311b36fb96fp-11\n-0x1.6a5c9e9420352p-11 0x1.6c311aeeed263p-11\n-0x1.736bbbf265c0bp-11 0x1.6c311aa50bb4cp-11\n-0x1.7c7ad94cf2b62p-11 0x1.6c311a595737ap-11\n-0x1.8589f6a3b00b2p-11 0x1.6c311a0bcfde5p-11\n-0x1.8e9913f686476p-11 0x1.6c3119bc756dfp-11\n-0x1.97a831455e02bp-11 0x1.6c31196b47c11p-11\n-0x1.a0b74e9020da7p-11 0x1.6c31191847991p-11\n-0x1.a9c66bd6b6deep-11 0x1.6c3118c374534p-11\n-0x1.b2d5891908bffp-11 0x1.6c31186ccdep-11\n-0x1.bbe4a656ff862p-11 0x1.6c311814547abp-11\n-0x1.c4f3c39084087p-11 0x1.6c3117ba0830cp-11\n-0x1.ce02e0c57eb2ap-11 0x1.6c31175de8bb1p-11\n-0x1.d711fdf5d878ep-11 0x1.6c3116fff6412p-11\n-0x1.e0211b217a46ep-11 0x1.6c3116a030e0cp-11\n-0x1.e93038484cab9p-11 0x1.6c31163e9870cp-11\n-0x1.f23f556a38ddcp-11 0x1.6c3115db2d45fp-11\n-0x1.fb4e72872701ep-11 0x1.6c311575eee97p-11\n-0x1.022ec7cf8004dp-10 0x1.6c31150edd7dfp-11\n-0x1.06b65658d669cp-10 0x1.6c3114a5f9164p-11\n-0x1.0b3de4df8b0bep-10 0x1.6c31143b41aa2p-11\n-0x1.0fc573639269dp-10 0x1.6c3113ceb75f9p-11\n-0x1.144d01e4e0cbfp-10 0x1.6c3113605a12fp-11\n-0x1.18d490636a9c6p-10 0x1.6c3112f029cecp-11\n-0x1.1d5c1edf24251p-10 0x1.6c31127e2673cp-11\n-0x1.21e3ad5801b05p-10 0x1.6c31120a4fe4dp-11\n-0x1.266b3bcdf839bp-10 0x1.6c311194a6e1dp-11\n-0x1.2af2ca40fb57p-10 0x1.6c31111d2a6bdp-11\n-0x1.2f7a58b0ffc77p-10 0x1.6c3110a3daf79p-11\n-0x1.3401e71dfa3e5p-10 0x1.6c311028b8e4fp-11\n-0x1.38897587dea56p-10 0x1.6c310fabc3a3p-11\n-0x1.3d1103eea1793p-10 0x1.6c310f2cfb523p-11\n-0x1.4198925237113p-10 0x1.6c310eac5fe6cp-11\n-0x1.462020b2941a4p-10 0x1.6c310e29f1b6p-11\n-0x1.4aa7af0fac669p-10 0x1.6c310da5b01e7p-11\n-0x1.4f2f3d69754e2p-10 0x1.6c310d1f9c2e9p-11\n-0x1.53b6cbbfe243ep-10 0x1.6c310c97b4e09p-11\n-0x1.583e5a12e81cbp-10 0x1.6c310c0dfab0ap-11\n-0x1.5cc5e8627af2dp-10 0x1.6c310b826d52ap-11\n-0x1.614d76ae8f574p-10 0x1.6c310af50cf88p-11\n-0x1.65d504f719cdfp-10 0x1.6c310a65d9c52p-11\n-0x1.6a5c933c0e823p-10 0x1.6c3109d4d37edp-11\n-0x1.6ee4217d61ec7p-10 0x1.6c310941fa3cfp-11\n-0x1.736bafbb0897bp-10 0x1.6c3108ad4e27ap-11\n-0x1.77f33df4f6785p-10 0x1.6c310816ced1dp-11\n-0x1.7c7acc2b2071bp-10 0x1.6c31077e7cbb2p-11\n-0x1.81025a5d7a68ep-10 0x1.6c3106e457699p-11\n-0x1.8589e88bf926cp-10 0x1.6c3106485f3fdp-11\n-0x1.8a1176b690c7bp-10 0x1.6c3105aa93fc7p-11\n-0x1.8e9904dd35d2dp-10 0x1.6c31050af5c11p-11\n-0x1.932092ffdcc95p-10 0x1.6c31046984a9dp-11\n-0x1.97a8211e79bd2p-10 0x1.6c3103c6406e2p-11\n-0x1.9c2faf39015cfp-10 0x1.6c31032129529p-11\n-0x1.a0b73d4f67bf2p-10 0x1.6c31027a3f13ep-11\n-0x1.a53ecb61a185ep-10 0x1.6c3101d181ea9p-11\n-0x1.a9c6596fa3277p-10 0x1.6c310126f1e71p-11\n-0x1.ae4de77960a7dp-10 0x1.6c31007a8eb85p-11\n-0x1.b2d5757ece5d6p-10 0x1.6c30ffcc5855fp-11\n-0x1.b75d037fe163fp-10 0x1.6c30ff1c4f5bbp-11\n-0x1.bbe4917c8d928p-10 0x1.6c30fe6a7353cp-11\n-0x1.c06c1f74c7363p-10 0x1.6c30fdb6c42dbp-11\n-0x1.c4f3ad6882fa7p-10 0x1.6c30fd0142254p-11\n0x1.2d4b9393d0315p-63 0x1.1124d4e061235p-10\n-0x1.21e3b516092f5p-16 0x1.1124d4dfb2051p-10\n-0x1.21e3b514954dcp-15 0x1.1124d4dda47ep-10\n-0x1.b2d58f9b3ec64p-15 0x1.1124d4da38f15p-10\n-0x1.21e3b50ec67a9p-14 0x1.1124d4d56f0e6p-10\n-0x1.6a5ca24d0645bp-14 0x1.1124d4cf47097p-10\n-0x1.b2d58f87a49edp-14 0x1.1124d4c7c0a4ap-10\n-0x1.fb4e7cbde7d7ep-14 0x1.1124d4bedc08ep-10\n-0x1.21e3b4f78aebfp-13 0x1.1124d4b49914fp-10\n-0x1.46202b8d3a6bbp-13 0x1.1124d4a8f7d8ep-10\n-0x1.6a5ca21fa6011p-13 0x1.1124d49bf8bccp-10\n-0x1.8e9918ae6fed6p-13 0x1.1124d48d9b175p-10\n-0x1.b2d58f393b808p-13 0x1.1124d47ddf207p-10\n-0x1.d71205bfabe2bp-13 0x1.1124d46cc4eabp-10\n-0x1.fb4e7c41648e7p-13 0x1.1124d45a4cae6p-10\n-0x1.0fc5795f040fbp-12 0x1.1124d4467623p-10\n-0x1.21e3b49a9ccf5p-12 0x1.1124d4314148bp-10\n-0x1.3401efd34df9ap-12 0x1.1124d41aae0fcp-10\n-0x1.46202b08e9824p-12 0x1.1124d402bcd5cp-10\n-0x1.583e663b40a52p-12 0x1.1124d3e96d536p-10\n-0x1.6a5ca16a24d97p-12 0x1.1124d3cebf7d9p-10\n-0x1.7c7adc95678e9p-12 0x1.1124d3b2b344bp-10\n-0x1.8e9917bcdab04p-12 0x1.1124d39548f02p-10\n-0x1.a0b752e04f6ecp-12 0x1.1124d3768042dp-10\n-0x1.b2d58dff97896p-12 0x1.1124d3565960fp-10\n-0x1.c4f3c91a84a33p-12 0x1.1124d334d4594p-10\n-0x1.d7120430e803p-12 0x1.1124d311f1034p-10\n-0x1.e9303f4293517p-12 0x1.1124d2edaf709p-10\n-0x1.fb4e7a4f5808fp-12 0x1.1124d2c80f9a4p-10\n-0x1.06b65aab83aa2p-11 0x1.1124d2a1114fap-10\n-0x1.0fc5782cba24ep-11 0x1.1124d278b55e5p-10\n-0x1.18d495ab37496p-11 0x1.1124d24efacc9p-10\n-0x1.21e3b326e4096p-11 0x1.1124d223e1cfbp-10\n-0x1.2af2d09fa98c8p-11 0x1.1124d1f76ac5dp-10\n-0x1.3401ee1570845p-11 0x1.1124d1c99599ap-10\n-0x1.3d110b88215f8p-11 0x1.1124d19a61feap-10\n-0x1.462028f7a518p-11 0x1.1124d169d0263p-10\n-0x1.4f2f4663e466dp-11 0x1.1124d137e0057p-10\n-0x1.583e63ccc86cep-11 0x1.1124d10491e7fp-10\n-0x1.614d8132391dap-11 0x1.1124d0cfe5265p-10\n-0x1.6a5c9e941fd56p-11 0x1.1124d099da3abp-10\n-0x1.736bbbf265bebp-11 0x1.1124d062716efp-10\n-0x1.7c7ad94cf2a2cp-11 0x1.1124d029aa069p-10\n-0x1.8589f6a3afbcdp-11 0x1.1124cfef845cap-10\n-0x1.8e9913f6860eap-11 0x1.1124cfb4009afp-10\n-0x1.97a831455e22ep-11 0x1.1124cf771e984p-10\n-0x1.a0b74e9020813p-11 0x1.1124cf38de2c7p-10\n-0x1.a9c66bd6b68fap-11 0x1.1124cef93fc24p-10\n-0x1.b2d5891908bddp-11 0x1.1124ceb843204p-10\n-0x1.bbe4a656ff6fcp-11 0x1.1124ce75e80a1p-10\n-0x1.c4f3c390837b8p-11 0x1.1124ce322e8e1p-10\n-0x1.ce02e0c57ebd1p-11 0x1.1124cded1753bp-10\n-0x1.d711fdf5d8ad3p-11 0x1.1124cda6a1932p-10\n-0x1.e0211b217a853p-11 0x1.1124cd5ecd92dp-10\n-0x1.e93038484cf71p-11 0x1.1124cd159b48bp-10\n-0x1.f23f556a38c33p-11 0x1.1124cccb0ab29p-10\n-0x1.fb4e728726f7cp-11 0x1.1124cc7f1bf98p-10\n-0x1.022ec7cf80115p-10 0x1.1124cc31cefe9p-10\n-0x1.06b65658d6905p-10 0x1.1124cbe323ceap-10\n-0x1.0b3de4df8aedep-10 0x1.1124cb9319fa6p-10\n-0x1.0fc57363927bdp-10 0x1.1124cb41b2761p-10\n-0x1.144d01e4e0e91p-10 0x1.1124caeeec8aap-10\n-0x1.18d490636a9f8p-10 0x1.1124ca9ac8416p-10\n-0x1.1d5c1edf24265p-10 0x1.1124ca4545be4p-10\n-0x1.21e3ad5801d9dp-10 0x1.1124c9ee64fc7p-10\n-0x1.266b3bcdf7fa7p-10 0x1.1124c99625dc5p-10\n-0x1.2af2ca40fb5e7p-10 0x1.1124c93c88c87p-10\n-0x1.2f7a58b1000a2p-10 0x1.1124c8e18d6a2p-10\n-0x1.3401e71dfa308p-10 0x1.1124c88533975p-10\n-0x1.38897587deac5p-10 0x1.1124c8277bbbfp-10\n-0x1.3d1103eea16cfp-10 0x1.1124c7c865729p-10\n-0x1.41989252371f4p-10 0x1.1124c767f0fc5p-10\n-0x1.462020b294166p-10 0x1.1124c7061e4c8p-10\n-0x1.4aa7af0fac975p-10 0x1.1124c6a2ed4ap-10\n-0x1.4f2f3d6975564p-10 0x1.1124c63e5e38ap-10\n-0x1.53b6cbbfe2484p-10 0x1.1124c5d870bf2p-10\n-0x1.583e5a12e7fb5p-10 0x1.1124c57125015p-10\n-0x1.5cc5e8627b0d5p-10 0x1.1124c5087b2dfp-10\n-0x1.614d76ae8f5f8p-10 0x1.1124c49e72e07p-10\n-0x1.65d504f719eedp-10 0x1.1124c4330c906p-10\n-0x1.6a5c933c0e8f7p-10 0x1.1124c3c647d11p-10\n-0x1.6ee4217d62023p-10 0x1.1124c35824ea2p-10\n-0x1.736bafbb0899dp-10 0x1.1124c2e8a3cffp-10\n-0x1.77f33df4f6861p-10 0x1.1124c277c45cdp-10\n-0x1.7c7acc2b20749p-10 0x1.1124c20586c81p-10\n-0x1.81025a5d7a88p-10 0x1.1124c191eae3bp-10\n-0x1.8589e88bf93a9p-10 0x1.1124c11cf0c0ep-10\n-0x1.8a1176b690cc3p-10 0x1.1124c0a69847ep-10\n-0x1.8e9904dd35dbbp-10 0x1.1124c02ee1a33p-10\n-0x1.932092ffdccbap-10 0x1.1124bfb5ccd22p-10\n-0x1.97a8211e79bddp-10 0x1.1124bf3b59a92p-10\n-0x1.9c2faf39016cp-10 0x1.1124bebf8862dp-10\n-0x1.a0b73d4f67de7p-10 0x1.1124be4258c36p-10\n-0x1.a53ecb61a18b1p-10 0x1.1124bdc3cad82p-10\n-0x1.a9c6596fa2f63p-10 0x1.1124bd43deb76p-10\n-0x1.ae4de77960935p-10 0x1.1124bcc2946cp-10\n-0x1.b2d5757ecea01p-10 0x1.1124bc3febde6p-10\n-0x1.b75d037fe127ap-10 0x1.1124bbbbe4d89p-10\n-0x1.bbe4917c8d77cp-10 0x1.1124bb367fecep-10\n-0x1.c06c1f74c71f3p-10 0x1.1124baafbc983p-10\n-0x1.c4f3ad6882ee2p-10 0x1.1124ba279b1dfp-10\n0x1.91ba1a1a6ad96p-63 0x1.6c31151e00a34p-10\n-0x1.21e3b5160904ep-16 0x1.6c31151d1705dp-10\n-0x1.21e3b514954f1p-15 0x1.6c31151a5a856p-10\n-0x1.b2d58f9b3ebbep-15 0x1.6c311515cb155p-10\n-0x1.21e3b50ec6945p-14 0x1.6c31150f68b8cp-10\n-0x1.6a5ca24d06236p-14 0x1.6c311507331b7p-10\n-0x1.b2d58f87a4657p-14 0x1.6c3114fd2a893p-10\n-0x1.fb4e7cbde7a32p-14 0x1.6c3114f14f178p-10\n-0x1.21e3b4f78ae9ap-13 0x1.6c3114e3a0a2p-10\n-0x1.46202b8d3a9a9p-13 0x1.6c3114d41f35bp-10\n-0x1.6a5ca21fa5d9fp-13 0x1.6c3114c2cab45p-10\n-0x1.8e9918ae6fa3dp-13 0x1.6c3114afa311dp-10\n-0x1.b2d58f393b926p-13 0x1.6c31149aa8c7bp-10\n-0x1.d71205bfac281p-13 0x1.6c311483db522p-10\n-0x1.fb4e7c416422bp-13 0x1.6c31146b3a7ecp-10\n-0x1.0fc5795f04038p-12 0x1.6c311450c7595p-10\n-0x1.21e3b49a9cc8dp-12 0x1.6c31143480eb2p-10\n-0x1.3401efd34e161p-12 0x1.6c31141667754p-10\n-0x1.46202b08e97f5p-12 0x1.6c3113f67b03cp-10\n-0x1.583e663b40305p-12 0x1.6c3113d4bb369p-10\n-0x1.6a5ca16a249b5p-12 0x1.6c3113b129025p-10\n-0x1.7c7adc9567a3ap-12 0x1.6c31138bc3b58p-10\n-0x1.8e9917bcda747p-12 0x1.6c3113648afep-10\n-0x1.a0b752e04f338p-12 0x1.6c31133b7f6fdp-10\n-0x1.b2d58dff97d61p-12 0x1.6c311310a164cp-10\n-0x1.c4f3c91a84cp-12 0x1.6c3112e3efde1p-10\n-0x1.d7120430e8376p-12 0x1.6c3112b56b7e6p-10\n-0x1.e9303f429373ap-12 0x1.6c31128514048p-10\n-0x1.fb4e7a4f58319p-12 0x1.6c311252e9987p-10\n-0x1.06b65aab84p-11 0x1.6c31121eec3bfp-10\n-0x1.0fc5782cba04fp-11 0x1.6c3111e91bbp-10\n-0x1.18d495ab374bcp-11 0x1.6c3111b17874bp-10\n-0x1.21e3b326e41aap-11 0x1.6c31117801e3ep-10\n-0x1.2af2d09fa9864p-11 0x1.6c31113cb866ep-10\n-0x1.3401ee15708d1p-11 0x1.6c3110ff9c414p-10\n-0x1.3d110b8821499p-11 0x1.6c3110c0aca81p-10\n-0x1.462028f7a50ddp-11 0x1.6c31107fea431p-10\n-0x1.4f2f4663e4881p-11 0x1.6c31103d54f5ep-10\n-0x1.583e63ccc837ap-11 0x1.6c310ff8ec75fp-10\n-0x1.614d81323926cp-11 0x1.6c310fb2b10eap-10\n-0x1.6a5c9e942019ap-11 0x1.6c310f6aa2beep-10\n-0x1.736bbbf265c35p-11 0x1.6c310f20c1726p-10\n-0x1.7c7ad94cf2d51p-11 0x1.6c310ed50d176p-10\n-0x1.8589f6a3aff37p-11 0x1.6c310e878591bp-10\n-0x1.8e9913f686658p-11 0x1.6c310e382b5abp-10\n-0x1.97a831455e45dp-11 0x1.6c310de6fdd65p-10\n-0x1.a0b74e9020fd6p-11 0x1.6c310d93fd981p-10\n-0x1.a9c66bd6b6c6cp-11 0x1.6c310d3f2a26fp-10\n-0x1.b2d5891908a12p-11 0x1.6c310ce883b79p-10\n-0x1.bbe4a656ffa4cp-11 0x1.6c310c900a8cep-10\n-0x1.c4f3c39083f93p-11 0x1.6c310c35be267p-10\n-0x1.ce02e0c57ec22p-11 0x1.6c310bd99ed1ap-10\n-0x1.d711fdf5d87e2p-11 0x1.6c310b7bac586p-10\n-0x1.e0211b217a78bp-11 0x1.6c310b1be7239p-10\n-0x1.e93038484cac2p-11 0x1.6c310aba4e978p-10\n-0x1.f23f556a38e55p-11 0x1.6c310a56e37abp-10\n-0x1.fb4e728726c6cp-11 0x1.6c3109f1a4f7dp-10\n-0x1.022ec7cf7fff3p-10 0x1.6c31098a93b8bp-10\n-0x1.06b65658d67b6p-10 0x1.6c310921af7b4p-10\n-0x1.0b3de4df8b21p-10 0x1.6c3108b6f81d6p-10\n-0x1.0fc57363927b3p-10 0x1.6c31084a6dd7dp-10\n-0x1.144d01e4e0cefp-10 0x1.6c3107dc10822p-10\n-0x1.18d490636aa5cp-10 0x1.6c31076be051p-10\n-0x1.1d5c1edf240e2p-10 0x1.6c3106f9dcd75p-10\n-0x1.21e3ad5801e7ap-10 0x1.6c31068606b63p-10\n-0x1.266b3bcdf83bbp-10 0x1.6c3106105d7b7p-10\n-0x1.2af2ca40fb5dcp-10 0x1.6c310598e116ap-10\n-0x1.2f7a58b0ffcb2p-10 0x1.6c31051f91a9cp-10\n-0x1.3401e71dfa4aep-10 0x1.6c3104a46fad6p-10\n-0x1.38897587de935p-10 0x1.6c3104277a534p-10\n-0x1.3d1103eea183ap-10 0x1.6c3103a8b22f6p-10\n-0x1.41989252370adp-10 0x1.6c31032816bdap-10\n-0x1.462020b294038p-10 0x1.6c3102a5a8868p-10\n-0x1.4aa7af0fac989p-10 0x1.6c310221674bdp-10\n-0x1.4f2f3d69754b7p-10 0x1.6c31019b532efp-10\n-0x1.53b6cbbfe22ep-10 0x1.6c3101136bd95p-10\n-0x1.583e5a12e7fd1p-10 0x1.6c310089b1ac4p-10\n-0x1.5cc5e8627ae39p-10 0x1.6c30fffe246dp-10\n-0x1.614d76ae8f421p-10 0x1.6c30ff70c41afp-10\n-0x1.65d504f719c82p-10 0x1.6c30fee191047p-10\n-0x1.6a5c933c0e8ap-10 0x1.6c30fe508ad9bp-10\n-0x1.6ee4217d61dfap-10 0x1.6c30fdbdb1914p-10\n-0x1.736bafbb08776p-10 0x1.6c30fd290576fp-10\n-0x1.77f33df4f6874p-10 0x1.6c30fc92865dep-10\n-0x1.7c7acc2b20697p-10 0x1.6c30fbfa343fp-10\n-0x1.81025a5d7a6d3p-10 0x1.6c30fb600f085p-10\n-0x1.8589e88bf939bp-10 0x1.6c30fac416fb4p-10\n-0x1.8a1176b690cccp-10 0x1.6c30fa264bb98p-10\n-0x1.8e9904dd35fa6p-10 0x1.6c30f986adac8p-10\n-0x1.932092ffdcbbap-10 0x1.6c30f8e53c74bp-10\n-0x1.97a8211e79bcp-10 0x1.6c30f841f8535p-10\n-0x1.9c2faf3901524p-10 0x1.6c30f79ce13eep-10\n-0x1.a0b73d4f67ba1p-10 0x1.6c30f6f5f7152p-10\n-0x1.a53ecb61a1a19p-10 0x1.6c30f64d3a182p-10\n-0x1.a9c6596fa3033p-10 0x1.6c30f5a2a9eep-10\n-0x1.ae4de779608b9p-10 0x1.6c30f4f646d6fp-10\n-0x1.b2d5757ece652p-10 0x1.6c30f44810a35p-10\n-0x1.b75d037fe154ap-10 0x1.6c30f39807a67p-10\n-0x1.bbe4917c8d711p-10 0x1.6c30f2e62ba0ep-10\n-0x1.c06c1f74c71e6p-10 0x1.6c30f2327c941p-10\n-0x1.c4f3ad6882c83p-10 0x1.6c30f17cfa87ap-10\n0x1.f628a0a1056d6p-63 0x1.c73d4f997ba34p-10\n-0x1.21e3b51609155p-16 0x1.c73d4f9857d06p-10\n-0x1.21e3b5149569fp-15 0x1.c73d4f94ec564p-10\n-0x1.b2d58f9b3eb71p-15 0x1.c73d4f8f38cb2p-10\n-0x1.21e3b50ec68bfp-14 0x1.c73d4f873dd24p-10\n-0x1.6a5ca24d06279p-14 0x1.c73d4f7cfade2p-10\n-0x1.b2d58f87a4788p-14 0x1.c73d4f7070392p-10\n-0x1.fb4e7cbde75fep-14 0x1.c73d4f619d9c6p-10\n-0x1.21e3b4f78afabp-13 0x1.c73d4f5083dfdp-10\n-0x1.46202b8d3aad2p-13 0x1.c73d4f3d22187p-10\n-0x1.6a5ca21fa5edbp-13 0x1.c73d4f277877fp-10\n-0x1.8e9918ae6fcdbp-13 0x1.c73d4f0f8706ep-10\n-0x1.b2d58f393ba3bp-13 0x1.c73d4ef54e0c1p-10\n-0x1.d71205bfac2f5p-13 0x1.c73d4ed8cd31ap-10\n-0x1.fb4e7c4164b01p-13 0x1.c73d4eba04a47p-10\n-0x1.0fc5795f03fb6p-12 0x1.c73d4e98f42bep-10\n-0x1.21e3b49a9cb6dp-12 0x1.c73d4e759c148p-10\n-0x1.3401efd34e2c4p-12 0x1.c73d4e4ffc803p-10\n-0x1.46202b08e9762p-12 0x1.c73d4e2814c96p-10\n-0x1.583e663b407d8p-12 0x1.c73d4dfde57d3p-10\n-0x1.6a5ca16a2479ep-12 0x1.c73d4dd16e2f8p-10\n-0x1.7c7adc9567aa4p-12 0x1.c73d4da2afc68p-10\n-0x1.8e9917bcdac6fp-12 0x1.c73d4d71a9384p-10\n-0x1.a0b752e04f628p-12 0x1.c73d4d3e5aa0ep-10\n-0x1.b2d58dff97b33p-12 0x1.c73d4d08c4bd5p-10\n-0x1.c4f3c91a84755p-12 0x1.c73d4cd0e6b3ap-10\n-0x1.d7120430e7fe1p-12 0x1.c73d4c96c1538p-10\n-0x1.e9303f42937d9p-12 0x1.c73d4c5a54406p-10\n-0x1.fb4e7a4f5849ep-12 0x1.c73d4c1b9f497p-10\n-0x1.06b65aab840c2p-11 0x1.c73d4bdaa29b4p-10\n-0x1.0fc5782cba186p-11 0x1.c73d4b975dfc6p-10\n-0x1.18d495ab374b7p-11 0x1.c73d4b51d1d66p-10\n-0x1.21e3b326e4264p-11 0x1.c73d4b09fdb8bp-10\n-0x1.2af2d09fa9a4ep-11 0x1.c73d4abfe1fdep-10\n-0x1.3401ee157088fp-11 0x1.c73d4a737e9fep-10\n-0x1.3d110b88214eep-11 0x1.c73d4a24d3342p-10\n-0x1.462028f7a4f28p-11 0x1.c73d49d3e00ddp-10\n-0x1.4f2f4663e482cp-11 0x1.c73d4980a592p-10\n-0x1.583e63ccc8284p-11 0x1.c73d492b22eaep-10\n-0x1.614d813239365p-11 0x1.c73d48d358d86p-10\n-0x1.6a5c9e941fefdp-11 0x1.c73d487946b14p-10\n-0x1.736bbbf265c07p-11 0x1.c73d481ced49cp-10\n-0x1.7c7ad94cf2ad6p-11 0x1.c73d47be4bb35p-10\n-0x1.8589f6a3afff5p-11 0x1.c73d475d629p-10\n-0x1.8e9913f68654ep-11 0x1.c73d46fa31b16p-10\n-0x1.97a831455e4b3p-11 0x1.c73d4694b8ebdp-10\n-0x1.a0b74e9020f2ap-11 0x1.c73d462cf894bp-10\n-0x1.a9c66bd6b6c9ep-11 0x1.c73d45c2f05ddp-10\n-0x1.b2d5891908d63p-11 0x1.c73d4556a08d9p-10\n-0x1.bbe4a656ff865p-11 0x1.c73d44e808ca2p-10\n-0x1.c4f3c39083db6p-11 0x1.c73d44772953ap-10\n-0x1.ce02e0c57ec69p-11 0x1.c73d44040253bp-10\n-0x1.d711fdf5d8a37p-11 0x1.c73d438e93647p-10\n-0x1.e0211b217a78bp-11 0x1.c73d4316dcc6p-10\n-0x1.e93038484ce7bp-11 0x1.c73d429cde571p-10\n-0x1.f23f556a38e3ep-11 0x1.c73d42209843fp-10\n-0x1.fb4e72872708bp-11 0x1.c73d41a20a65ap-10\n-0x1.022ec7cf800e3p-10 0x1.c73d412134bf1p-10\n-0x1.06b65658d683p-10 0x1.c73d409e176e8p-10\n-0x1.0b3de4df8b381p-10 0x1.c73d4018b25d8p-10\n-0x1.0fc5736392886p-10 0x1.c73d3f91057ecp-10\n-0x1.144d01e4e0dccp-10 0x1.c73d3f0710ddcp-10\n-0x1.18d490636a9e2p-10 0x1.c73d3e7ad486fp-10\n-0x1.1d5c1edf24345p-10 0x1.c73d3dec50827p-10\n-0x1.21e3ad5801df1p-10 0x1.c73d3d5b8498fp-10\n-0x1.266b3bcdf829ep-10 0x1.c73d3cc8710c1p-10\n-0x1.2af2ca40fb6b3p-10 0x1.c73d3c3315c85p-10\n-0x1.2f7a58b1000bp-10 0x1.c73d3b9b72d6fp-10\n-0x1.3401e71dfa181p-10 0x1.c73d3b0187bacp-10\n-0x1.38897587de9eep-10 0x1.c73d3a655571ap-10\n-0x1.3d1103eea16ffp-10 0x1.c73d39c6db22dp-10\n-0x1.4198925237131p-10 0x1.c73d392619075p-10\n-0x1.462020b2942b4p-10 0x1.c73d38830f7a7p-10\n-0x1.4aa7af0faca89p-10 0x1.c73d37ddbddb8p-10\n-0x1.4f2f3d6975368p-10 0x1.c73d373624916p-10\n-0x1.53b6cbbfe250bp-10 0x1.c73d368c43bcbp-10\n-0x1.583e5a12e80fdp-10 0x1.c73d35e01afb4p-10\n-0x1.5cc5e8627af08p-10 0x1.c73d3531aa70bp-10\n-0x1.614d76ae8f607p-10 0x1.c73d3480f22c3p-10\n-0x1.65d504f719eb6p-10 0x1.c73d33cdf262dp-10\n-0x1.6a5c933c0e904p-10 0x1.c73d3318aa95cp-10\n-0x1.6ee4217d61ee6p-10 0x1.c73d32611b126p-10\n-0x1.736bafbb08812p-10 0x1.c73d31a743f89p-10\n-0x1.77f33df4f6759p-10 0x1.c73d30eb25055p-10\n-0x1.7c7acc2b2059p-10 0x1.c73d302cbe6e1p-10\n-0x1.81025a5d7a62ap-10 0x1.c73d2f6c0ffe2p-10\n-0x1.8589e88bf91dep-10 0x1.c73d2ea919e7dp-10\n-0x1.8a1176b690ba3p-10 0x1.c73d2de3dbee5p-10\n-0x1.8e9904dd35d93p-10 0x1.c73d2d1c565c5p-10\n-0x1.932092ffdcc8bp-10 0x1.c73d2c528918fp-10\n-0x1.97a8211e79ba7p-10 0x1.c73d2b8673edep-10\n-0x1.9c2faf39015f9p-10 0x1.c73d2ab817337p-10\n-0x1.a0b73d4f67935p-10 0x1.c73d29e772558p-10\n-0x1.a53ecb61a17a6p-10 0x1.c73d29148627bp-10\n-0x1.a9c6596fa311p-10 0x1.c73d283f523b4p-10\n-0x1.ae4de77960abap-10 0x1.c73d2767d6809p-10\n-0x1.b2d5757ece8e9p-10 0x1.c73d268e12d9ap-10\n-0x1.b75d037fe175fp-10 0x1.c73d25b207a47p-10\n-0x1.bbe4917c8d8ddp-10 0x1.c73d24d3b4a82p-10\n-0x1.c06c1f74c71bap-10 0x1.c73d23f319c74p-10\n-0x1.c4f3ad6882ebp-10 0x1.c73d2310376ep-10\n0x1.2d4b9393d0025p-62 0x1.1124c1712511ap-9\n-0x1.21e3b516091c2p-16 0x1.1124c17076063p-9\n-0x1.21e3b51495521p-15 0x1.1124c16e689ccp-9\n-0x1.b2d58f9b3ec6dp-15 0x1.1124c16afd0dep-9\n-0x1.21e3b50ec67p-14 0x1.1124c16633204p-9\n-0x1.6a5ca24d061cdp-14 0x1.1124c1600b074p-9\n-0x1.b2d58f87a47b8p-14 0x1.1124c15884ac6p-9\n-0x1.fb4e7cbde7d46p-14 0x1.1124c14fa0286p-9\n-0x1.21e3b4f78acdap-13 0x1.1124c1455d1a2p-9\n-0x1.46202b8d3a855p-13 0x1.1124c139bc14p-9\n-0x1.6a5ca21fa5d5cp-13 0x1.1124c12cbcc44p-9\n-0x1.8e9918ae6febdp-13 0x1.1124c11e5f409p-9\n-0x1.b2d58f393b819p-13 0x1.1124c10ea34e8p-9\n-0x1.d71205bfac251p-13 0x1.1124c0fd89425p-9\n-0x1.fb4e7c416484bp-13 0x1.1124c0eb10de4p-9\n-0x1.0fc5795f0411p-12 0x1.1124c0d73a5ep-9\n-0x1.21e3b49a9cabap-12 0x1.1124c0c205661p-9\n-0x1.3401efd34e1b1p-12 0x1.1124c0ab72706p-9\n-0x1.46202b08e9857p-12 0x1.1124c0938120ap-9\n-0x1.583e663b407bep-12 0x1.1124c07a318p-9\n-0x1.6a5ca16a24b82p-12 0x1.1124c05f83b75p-9\n-0x1.7c7adc9567889p-12 0x1.1124c04377992p-9\n-0x1.8e9917bcdaafep-12 0x1.1124c0260d5p-9\n-0x1.a0b752e04fb13p-12 0x1.1124c00744d46p-9\n-0x1.b2d58dff97de4p-12 0x1.1124bfe71e035p-9\n-0x1.c4f3c91a84e96p-12 0x1.1124bfc598f7cp-9\n-0x1.d7120430e8252p-12 0x1.1124bfa2b5923p-9\n-0x1.e9303f429374ap-12 0x1.1124bf7e74075p-9\n-0x1.fb4e7a4f584dbp-12 0x1.1124bf58d44b7p-9\n-0x1.06b65aab83f8cp-11 0x1.1124bf31d6356p-9\n-0x1.0fc5782cba0ddp-11 0x1.1124bf0979e2fp-9\n-0x1.18d495ab37407p-11 0x1.1124bedfbf696p-9\n-0x1.21e3b326e4232p-11 0x1.1124beb4a6969p-9\n-0x1.2af2d09fa9acp-11 0x1.1124be882f9b1p-9\n-0x1.3401ee15707bep-11 0x1.1124be5a5a53ep-9\n-0x1.3d110b8821508p-11 0x1.1124be2b26bd6p-9\n-0x1.462028f7a511cp-11 0x1.1124bdfa94f72p-9\n-0x1.4f2f4663e477cp-11 0x1.1124bdc8a4f48p-9\n-0x1.583e63ccc858bp-11 0x1.1124bd9556c3ep-9\n-0x1.614d813239306p-11 0x1.1124bd60aa2bdp-9\n-0x1.6a5c9e94201fcp-11 0x1.1124bd2a9f756p-9\n-0x1.736bbbf265addp-11 0x1.1124bcf33670bp-9\n-0x1.7c7ad94cf2b1bp-11 0x1.1124bcba6f2c3p-9\n-0x1.8589f6a3afe4ep-11 0x1.1124bc8049ap-9\n-0x1.8e9913f686401p-11 0x1.1124bc44c5f12p-9\n-0x1.97a831455e4c7p-11 0x1.1124bc07e3f4dp-9\n-0x1.a0b74e9020c8bp-11 0x1.1124bbc9a3a94p-9\n-0x1.a9c66bd6b6c32p-11 0x1.1124bb8a053ecp-9\n-0x1.b2d5891908ad8p-11 0x1.1124bb49087f5p-9\n-0x1.bbe4a656ff7cdp-11 0x1.1124bb06ad89ep-9\n-0x1.c4f3c39083a5ep-11 0x1.1124bac2f42dcp-9\n-0x1.ce02e0c57e7a1p-11 0x1.1124ba7ddcc0dp-9\n-0x1.d711fdf5d85p-11 0x1.1124ba3767014p-9\n-0x1.e0211b217a655p-11 0x1.1124b9ef9333dp-9\n-0x1.e93038484ce22p-11 0x1.1124b9a660ffbp-9\n-0x1.f23f556a38ecbp-11 0x1.1124b95bd09cp-9\n-0x1.fb4e728726de2p-11 0x1.1124b90fe1cebp-9\n-0x1.022ec7cf80068p-10 0x1.1124b8c294e67p-9\n-0x1.06b65658d67f6p-10 0x1.1124b873e9c12p-9\n-0x1.0b3de4df8b26cp-10 0x1.1124b823e0499p-9\n-0x1.0fc57363927a9p-10 0x1.1124b7d2789bdp-9\n-0x1.144d01e4e0d9ep-10 0x1.1124b77fb2b4p-9\n-0x1.18d490636a966p-10 0x1.1124b72b8e827p-9\n-0x1.1d5c1edf242ccp-10 0x1.1124b6d60c20fp-9\n-0x1.21e3ad5801dbep-10 0x1.1124b67f2b6d5p-9\n-0x1.266b3bcdf8248p-10 0x1.1124b626ec84dp-9\n-0x1.2af2ca40fb5ffp-10 0x1.1124b5cd4f5efp-9\n-0x1.2f7a58b0ffeebp-10 0x1.1124b57253f9ep-9\n-0x1.3401e71dfa4cdp-10 0x1.1124b515fa6ccp-9\n-0x1.38897587dea7dp-10 0x1.1124b4b842881p-9\n-0x1.3d1103eea181cp-10 0x1.1124b4592c68ep-9\n-0x1.4198925237273p-10 0x1.1124b3f8b7fc3p-9\n-0x1.462020b294198p-10 0x1.1124b396e55d5p-9\n-0x1.4aa7af0faca76p-10 0x1.1124b333b47acp-9\n-0x1.4f2f3d6975385p-10 0x1.1124b2cf2558cp-9\n-0x1.53b6cbbfe2382p-10 0x1.1124b26938007p-9\n-0x1.583e5a12e80f4p-10 0x1.1124b201ec753p-9\n-0x1.5cc5e8627afc7p-10 0x1.1124b199429bdp-9\n-0x1.614d76ae8f718p-10 0x1.1124b12f3a7f7p-9\n-0x1.65d504f719d06p-10 0x1.1124b0c3d4216p-9\n-0x1.6a5c933c0e67fp-10 0x1.1124b0570f72bp-9\n-0x1.6ee4217d61e8fp-10 0x1.1124afe8ecaecp-9\n-0x1.736bafbb08922p-10 0x1.1124af796bb96p-9\n-0x1.77f33df4f67e3p-10 0x1.1124af088c5dfp-9\n-0x1.7c7acc2b204dep-10 0x1.1124ae964ecb9p-9\n-0x1.81025a5d7a708p-10 0x1.1124ae22b30aep-9\n-0x1.8589e88bf9199p-10 0x1.1124adadb8fadp-9\n-0x1.8a1176b690c83p-10 0x1.1124ad3760af4p-9\n-0x1.8e9904dd35debp-10 0x1.1124acbfaa29p-9\n-0x1.932092ffdcbcdp-10 0x1.1124ac469565bp-9\n-0x1.97a8211e79b43p-10 0x1.1124abcc225a6p-9\n-0x1.9c2faf39014dep-10 0x1.1124ab505120fp-9\n-0x1.a0b73d4f67c11p-10 0x1.1124aad3219cbp-9\n-0x1.a53ecb61a18b2p-10 0x1.1124aa5493ep-9\n-0x1.a9c6596fa2dfap-10 0x1.1124a9d4a7cc2p-9\n-0x1.ae4de77960769p-10 0x1.1124a9535d98cp-9\n-0x1.b2d5757ecea73p-10 0x1.1124a8d0b53e1p-9\n-0x1.b75d037fe1609p-10 0x1.1124a84cae732p-9\n-0x1.bbe4917c8d716p-10 0x1.1124a7c7497c5p-9\n-0x1.c06c1f74c73bdp-10 0x1.1124a7408659ap-9\n-0x1.c4f3ad6882a8bp-10 0x1.1124a6b864c11p-9\n0x1.5f82d6d71d417p-62 0x1.3eaad6c3f251ap-9\n-0x1.21e3b51609189p-16 0x1.3eaad6c326295p-9\n-0x1.21e3b51495565p-15 0x1.3eaad6c0c1349p-9\n-0x1.b2d58f9b3e8c6p-15 0x1.3eaad6bcc388cp-9\n-0x1.21e3b50ec67d1p-14 0x1.3eaad6b72d879p-9\n-0x1.6a5ca24d061e2p-14 0x1.3eaad6affeb3ep-9\n-0x1.b2d58f87a4497p-14 0x1.3eaad6a737262p-9\n-0x1.fb4e7cbde7c8ap-14 0x1.3eaad69cd7501p-9\n-0x1.21e3b4f78af22p-13 0x1.3eaad690de9d5p-9\n-0x1.46202b8d3aa87p-13 0x1.3eaad6834d65bp-9\n-0x1.6a5ca21fa5d51p-13 0x1.3eaad67423677p-9\n-0x1.8e9918ae6fcd1p-13 0x1.3eaad66360e2fp-9\n-0x1.b2d58f393b7dp-13 0x1.3eaad65105b6fp-9\n-0x1.d71205bfac18cp-13 0x1.3eaad63d11fbfp-9\n-0x1.fb4e7c4164a6p-13 0x1.3eaad62785a3ap-9\n-0x1.0fc5795f040ccp-12 0x1.3eaad61060a21p-9\n-0x1.21e3b49a9cd49p-12 0x1.3eaad5f7a309dp-9\n-0x1.3401efd34e207p-12 0x1.3eaad5dd4cc7dp-9\n-0x1.46202b08e98bap-12 0x1.3eaad5c15decdp-9\n-0x1.583e663b40777p-12 0x1.3eaad5a3d655cp-9\n-0x1.6a5ca16a24b25p-12 0x1.3eaad584b6447p-9\n-0x1.7c7adc95678f8p-12 0x1.3eaad563fd832p-9\n-0x1.8e9917bcdaa4cp-12 0x1.3eaad541ac225p-9\n-0x1.a0b752e04f8fcp-12 0x1.3eaad51dc2312p-9\n-0x1.b2d58dff97d2ap-12 0x1.3eaad4f83fa72p-9\n-0x1.c4f3c91a84be5p-12 0x1.3eaad4d1245e3p-9\n-0x1.d7120430e805dp-12 0x1.3eaad4a87075p-9\n-0x1.e9303f429384cp-12 0x1.3eaad47e2420bp-9\n-0x1.fb4e7a4f583e6p-12 0x1.3eaad4523f0ap-9\n-0x1.06b65aab83daap-11 0x1.3eaad424c1301p-9\n-0x1.0fc5782cb9f42p-11 0x1.3eaad3f5aadbp-9\n-0x1.18d495ab3744dp-11 0x1.3eaad3c4fc1ffp-9\n-0x1.21e3b326e435fp-11 0x1.3eaad392b4942p-9\n-0x1.2af2d09fa999ap-11 0x1.3eaad35ed44bfp-9\n-0x1.3401ee15707d2p-11 0x1.3eaad3295b946p-9\n-0x1.3d110b8821669p-11 0x1.3eaad2f24a293p-9\n-0x1.462028f7a522fp-11 0x1.3eaad2b9a0172p-9\n-0x1.4f2f4663e479ap-11 0x1.3eaad27f5d617p-9\n-0x1.583e63ccc8491p-11 0x1.3eaad243821ebp-9\n-0x1.614d813239396p-11 0x1.3eaad2060e347p-9\n-0x1.6a5c9e941fefep-11 0x1.3eaad1c701896p-9\n-0x1.736bbbf2658d9p-11 0x1.3eaad1865c6d8p-9\n-0x1.7c7ad94cf2b74p-11 0x1.3eaad1441ec53p-9\n-0x1.8589f6a3afcf8p-11 0x1.3eaad100483c8p-9\n-0x1.8e9913f686402p-11 0x1.3eaad0bad95e6p-9\n-0x1.97a831455e61ap-11 0x1.3eaad073d1d05p-9\n-0x1.a0b74e9020c99p-11 0x1.3eaad02b316fap-9\n-0x1.a9c66bd6b6c86p-11 0x1.3eaacfe0f8a95p-9\n-0x1.b2d5891908c35p-11 0x1.3eaacf952732ep-9\n-0x1.bbe4a656ff9abp-11 0x1.3eaacf47bd224p-9\n-0x1.c4f3c39084013p-11 0x1.3eaacef8ba696p-9\n-0x1.ce02e0c57eb85p-11 0x1.3eaacea81f087p-9\n-0x1.d711fdf5d89b4p-11 0x1.3eaace55eb0ep-9\n-0x1.e0211b217a652p-11 0x1.3eaace021e746p-9\n-0x1.e93038484cdd3p-11 0x1.3eaacdacb93d2p-9\n-0x1.f23f556a38e2ap-11 0x1.3eaacd55bb796p-9\n-0x1.fb4e728727099p-11 0x1.3eaaccfd25098p-9\n-0x1.022ec7cf7feeap-10 0x1.3eaacca2f5cbap-9\n-0x1.06b65658d6735p-10 0x1.3eaacc472e387p-9\n-0x1.0b3de4df8b361p-10 0x1.3eaacbe9ce019p-9\n-0x1.0fc57363928c4p-10 0x1.3eaacb8ad5184p-9\n-0x1.144d01e4e0d91p-10 0x1.3eaacb2a437e5p-9\n-0x1.18d490636aa5bp-10 0x1.3eaacac819611p-9\n-0x1.1d5c1edf240a9p-10 0x1.3eaaca64566cap-9\n-0x1.21e3ad5801e79p-10 0x1.3eaac9fefb2dep-9\n-0x1.266b3bcdf83ap-10 0x1.3eaac9980733dp-9\n-0x1.2af2ca40fb6b8p-10 0x1.3eaac92f7a874p-9\n-0x1.2f7a58b0fff96p-10 0x1.3eaac8c55545ep-9\n-0x1.3401e71dfa1cbp-10 0x1.3eaac85997446p-9\n-0x1.38897587de954p-10 0x1.3eaac7ec40e43p-9\n-0x1.3d1103eea168ap-10 0x1.3eaac77d51c5p-9\n-0x1.41989252370c4p-10 0x1.3eaac70cc9fa6p-9\n-0x1.462020b2941bbp-10 0x1.3eaac69aa9be9p-9\n-0x1.4aa7af0facb3ap-10 0x1.3eaac626f0cbfp-9\n-0x1.4f2f3d69753e2p-10 0x1.3eaac5b19f2a9p-9\n-0x1.53b6cbbfe2441p-10 0x1.3eaac53ab4fffp-9\n-0x1.583e5a12e8083p-10 0x1.3eaac4c2322ddp-9\n-0x1.5cc5e8627af81p-10 0x1.3eaac44816becp-9\n-0x1.614d76ae8f74cp-10 0x1.3eaac3cc62b1ep-9\n-0x1.65d504f719defp-10 0x1.3eaac34f1606p-9\n-0x1.6a5c933c0e8abp-10 0x1.3eaac2d030ad5p-9\n-0x1.6ee4217d61f08p-10 0x1.3eaac24fb2bdep-9\n-0x1.736bafbb08691p-10 0x1.3eaac1cd9c2dap-9\n-0x1.77f33df4f694fp-10 0x1.3eaac149ed329p-9\n-0x1.7c7acc2b205e2p-10 0x1.3eaac0c4a5653p-9\n-0x1.81025a5d7a658p-10 0x1.3eaac03dc4fb3p-9\n-0x1.8589e88bf9316p-10 0x1.3eaabfb54c133p-9\n-0x1.8a1176b690d56p-10 0x1.3eaabf2b3a6bp-9\n-0x1.8e9904dd35f3dp-10 0x1.3eaabe9f90383p-9\n-0x1.932092ffdcb7cp-10 0x1.3eaabe124d4ep-9\n-0x1.97a8211e79be5p-10 0x1.3eaabd8371db2p-9\n-0x1.9c2faf39015a3p-10 0x1.3eaabcf2fdd34p-9\n-0x1.a0b73d4f67a6p-10 0x1.3eaabc60f0ff8p-9\n-0x1.a53ecb61a1857p-10 0x1.3eaabbcd4bc27p-9\n-0x1.a9c6596fa2f4p-10 0x1.3eaabb380dcecp-9\n-0x1.ae4de779609f8p-10 0x1.3eaabaa1375bbp-9\n-0x1.b2d5757ecea6fp-10 0x1.3eaaba08c838p-9\n-0x1.b75d037fe1769p-10 0x1.3eaab96ec06bap-9\n-0x1.bbe4917c8d523p-10 0x1.3eaab8d31fe01p-9\n-0x1.c06c1f74c7265p-10 0x1.3eaab835e6f98p-9\n-0x1.c4f3ad6882e7p-10 0x1.3eaab7971568cp-9\n0x1.91ba1a1a6aa2bp-62 0x1.6c30e70ce271ap-9\n-0x1.21e3b5160911fp-16 0x1.6c30e70bf9115p-9\n-0x1.21e3b514955b5p-15 0x1.6c30e7093c9b1p-9\n-0x1.b2d58f9b3eab5p-15 0x1.6c30e704ad07ap-9\n-0x1.21e3b50ec67c4p-14 0x1.6c30e6fe4aa2bp-9\n-0x1.6a5ca24d06253p-14 0x1.6c30e6f61522ep-9\n-0x1.b2d58f87a48bep-14 0x1.6c30e6ec0cb55p-9\n-0x1.fb4e7cbde7c71p-14 0x1.6c30e6e03142ep-9\n-0x1.21e3b4f78ae96p-13 0x1.6c30e6d282b5cp-9\n-0x1.46202b8d3a74fp-13 0x1.6c30e6c30125cp-9\n-0x1.6a5ca21fa5d7ap-13 0x1.6c30e6b1acd54p-9\n-0x1.8e9918ae6fb03p-13 0x1.6c30e69e854a3p-9\n-0x1.b2d58f393b80cp-13 0x1.6c30e6898aeaap-9\n-0x1.d71205bfac2bbp-13 0x1.6c30e672bd906p-9\n-0x1.fb4e7c41649f1p-13 0x1.6c30e65a1d1b3p-9\n-0x1.0fc5795f040d8p-12 0x1.6c30e63fa9b49p-9\n-0x1.21e3b49a9cbeap-12 0x1.6c30e62363367p-9\n-0x1.3401efd34e028p-12 0x1.6c30e60549c25p-9\n-0x1.46202b08e9898p-12 0x1.6c30e5e55d805p-9\n-0x1.583e663b40905p-12 0x1.6c30e5c39e17cp-9\n-0x1.6a5ca16a24a34p-12 0x1.6c30e5a00b94ap-9\n-0x1.7c7adc9567a81p-12 0x1.6c30e57aa651cp-9\n-0x1.8e9917bcdab66p-12 0x1.6c30e5536de0fp-9\n-0x1.a0b752e04f97dp-12 0x1.6c30e52a627f8p-9\n-0x1.b2d58dff97c28p-12 0x1.6c30e4ff841bbp-9\n-0x1.c4f3c91a84c3ep-12 0x1.6c30e4d2d2b9ep-9\n-0x1.d7120430e823ap-12 0x1.6c30e4a44e598p-9\n-0x1.e9303f42935edp-12 0x1.6c30e473f6f15p-9\n-0x1.fb4e7a4f58255p-12 0x1.6c30e441cc9e4p-9\n-0x1.06b65aab84027p-11 0x1.6c30e40dcf61fp-9\n-0x1.0fc5782cba212p-11 0x1.6c30e3d7ff0cap-9\n-0x1.18d495ab373a9p-11 0x1.6c30e3a05baadp-9\n-0x1.21e3b326e4114p-11 0x1.6c30e366e53ap-9\n-0x1.2af2d09fa99cap-11 0x1.6c30e32b9bfbap-9\n-0x1.3401ee15706d6p-11 0x1.6c30e2ee7fac4p-9\n-0x1.3d110b8821621p-11 0x1.6c30e2af906cep-9\n-0x1.462028f7a4fbdp-11 0x1.6c30e26ecdf01p-9\n-0x1.4f2f4663e4889p-11 0x1.6c30e22c38d09p-9\n-0x1.583e63ccc83f4p-11 0x1.6c30e1e7d072bp-9\n-0x1.614d813239442p-11 0x1.6c30e1a1953c5p-9\n-0x1.6a5c9e9420286p-11 0x1.6c30e15986f6ep-9\n-0x1.736bbbf265b85p-11 0x1.6c30e10fa5adcp-9\n-0x1.7c7ad94cf298dp-11 0x1.6c30e0c3f1401p-9\n-0x1.8589f6a3afd49p-11 0x1.6c30e07669f4dp-9\n-0x1.8e9913f686443p-11 0x1.6c30e0270fdb2p-9\n-0x1.97a831455e5f6p-11 0x1.6c30dfd5e2aa5p-9\n-0x1.a0b74e9020dd3p-11 0x1.6c30df82e2581p-9\n-0x1.a9c66bd6b6d0cp-11 0x1.6c30df2e0f2c5p-9\n-0x1.b2d5891908c35p-11 0x1.6c30ded768f1ap-9\n-0x1.bbe4a656ff79p-11 0x1.6c30de7eefa82p-9\n-0x1.c4f3c39083f8ep-11 0x1.6c30de24a3872p-9\n-0x1.ce02e0c57eb4cp-11 0x1.6c30ddc8844b7p-9\n-0x1.d711fdf5d86b9p-11 0x1.6c30dd6a91f1ep-9\n-0x1.e0211b217a4cbp-11 0x1.6c30dd0acccdcp-9\n-0x1.e93038484ced4p-11 0x1.6c30dca934b8ep-9\n-0x1.f23f556a38c41p-11 0x1.6c30dc45c979ep-9\n-0x1.fb4e72872701dp-11 0x1.6c30dbe08b603p-9\n-0x1.022ec7cf80094p-10 0x1.6c30db797a2b9p-9\n-0x1.06b65658d673p-10 0x1.6c30db1095fcp-9\n-0x1.0b3de4df8b373p-10 0x1.6c30daa5def09p-9\n-0x1.0fc57363927bfp-10 0x1.6c30da3954b6dp-9\n-0x1.144d01e4e0cb4p-10 0x1.6c30d9caf7859p-9\n-0x1.18d490636aa69p-10 0x1.6c30d95ac784bp-9\n-0x1.1d5c1edf242c6p-10 0x1.6c30d8e8c45bap-9\n-0x1.21e3ad5801e2ep-10 0x1.6c30d874ee3ap-9\n-0x1.266b3bcdf8332p-10 0x1.6c30d7ff45275p-9\n-0x1.2af2ca40fb606p-10 0x1.6c30d787c8fd3p-9\n-0x1.2f7a58b0ffff1p-10 0x1.6c30d70e79f9fp-9\n-0x1.3401e71dfa415p-10 0x1.6c30d69357e22p-9\n-0x1.38897587de92bp-10 0x1.6c30d61662c23p-9\n-0x1.3d1103eea14d2p-10 0x1.6c30d5979a90bp-9\n-0x1.41989252372d4p-10 0x1.6c30d516ffb51p-9\n-0x1.462020b294159p-10 0x1.6c30d494919cfp-9\n-0x1.4aa7af0fac8e5p-10 0x1.6c30d4105075p-9\n-0x1.4f2f3d6975408p-10 0x1.6c30d38a3c8a4p-9\n-0x1.53b6cbbfe2489p-10 0x1.6c30d30255909p-9\n-0x1.583e5a12e8043p-10 0x1.6c30d2789b83p-9\n-0x1.5cc5e8627afc1p-10 0x1.6c30d1ed0e8aap-9\n-0x1.614d76ae8f6e3p-10 0x1.6c30d15fae81bp-9\n-0x1.65d504f719e49p-10 0x1.6c30d0d07b916p-9\n-0x1.6a5c933c0e98dp-10 0x1.6c30d03f75903p-9\n-0x1.6ee4217d620ep-10 0x1.6c30cfac9c9dfp-9\n-0x1.736bafbb08905p-10 0x1.6c30cf17f0a6dp-9\n-0x1.77f33df4f68e4p-10 0x1.6c30ce8171b5p-9\n-0x1.7c7acc2b205fdp-10 0x1.6c30cde91fcp-9\n-0x1.81025a5d7a7c3p-10 0x1.6c30cd4efadb2p-9\n-0x1.8589e88bf9221p-10 0x1.6c30ccb302e52p-9\n-0x1.8a1176b690e48p-10 0x1.6c30cc15380b4p-9\n-0x1.8e9904dd35f95p-10 0x1.6c30cb759a24p-9\n-0x1.932092ffdca6bp-10 0x1.6c30cad42916fp-9\n-0x1.97a8211e79c5dp-10 0x1.6c30ca30e5504p-9\n-0x1.9c2faf3901647p-10 0x1.6c30c98bce817p-9\n-0x1.a0b73d4f67d6dp-10 0x1.6c30c8e4e49fcp-9\n-0x1.a53ecb61a16a5p-10 0x1.6c30c83c279ap-9\n-0x1.a9c6596fa2fcp-10 0x1.6c30c79197d9ep-9\n-0x1.ae4de7796092ap-10 0x1.6c30c6e535104p-9\n-0x1.b2d5757ece9f4p-10 0x1.6c30c636ff4a4p-9\n-0x1.b75d037fe15cep-10 0x1.6c30c586f665cp-9\n-0x1.bbe4917c8d8dfp-10 0x1.6c30c4d51ab48p-9\n-0x1.c06c1f74c72c4p-10 0x1.6c30c4216bdf4p-9\n-0x1.c4f3ad6882d9ep-10 0x1.6c30c36bea1b3p-9\n0x1.c3f15d5db837cp-62 0x1.99b6f193b2b1ap-9\n-0x1.21e3b516090bbp-16 0x1.99b6f192abe57p-9\n-0x1.21e3b514955b3p-15 0x1.99b6f18f97e1fp-9\n-0x1.b2d58f9b3edp-15 0x1.99b6f18a76896p-9\n-0x1.21e3b50ec6888p-14 0x1.99b6f18347bc7p-9\n-0x1.6a5ca24d061b3p-14 0x1.99b6f17a0b764p-9\n-0x1.b2d58f87a48c7p-14 0x1.99b6f16ec2096p-9\n-0x1.fb4e7cbde7bb5p-14 0x1.99b6f1616b1fap-9\n-0x1.21e3b4f78af4ap-13 0x1.99b6f15206df6p-9\n-0x1.46202b8d3a983p-13 0x1.99b6f14095395p-9\n-0x1.6a5ca21fa5e33p-13 0x1.99b6f12d16445p-9\n-0x1.8e9918ae6fdc7p-13 0x1.99b6f11789e97p-9\n-0x1.b2d58f393b976p-13 0x1.99b6f0fff0279p-9\n-0x1.d71205bfac2f1p-13 0x1.99b6f0e649125p-9\n-0x1.fb4e7c4164a31p-13 0x1.99b6f0ca9494dp-9\n-0x1.0fc5795f0409bp-12 0x1.99b6f0acd2bc6p-9\n-0x1.21e3b49a9cd13p-12 0x1.99b6f08d03955p-9\n-0x1.3401efd34e1e2p-12 0x1.99b6f06b26fefp-9\n-0x1.46202b08e962ep-12 0x1.99b6f0473ce21p-9\n-0x1.583e663b407d4p-12 0x1.99b6f02145af5p-9\n-0x1.6a5ca16a24bd1p-12 0x1.99b6eff941135p-9\n-0x1.7c7adc95679d8p-12 0x1.99b6efcf2f058p-9\n-0x1.8e9917bcdabdep-12 0x1.99b6efa30f9efp-9\n-0x1.a0b752e04f6a9p-12 0x1.99b6ef74e2a39p-9\n-0x1.b2d58dff97a1cp-12 0x1.99b6ef44a886cp-9\n-0x1.c4f3c91a84c0dp-12 0x1.99b6ef12611b2p-9\n-0x1.d7120430e843p-12 0x1.99b6eede0c542p-9\n-0x1.e9303f4293819p-12 0x1.99b6eea7aa08cp-9\n-0x1.fb4e7a4f5834dp-12 0x1.99b6ee6f3a624p-9\n-0x1.06b65aab83f61p-11 0x1.99b6ee34bd66cp-9\n-0x1.0fc5782cba0f7p-11 0x1.99b6edf83307fp-9\n-0x1.18d495ab3742cp-11 0x1.99b6edb99b675p-9\n-0x1.21e3b326e421cp-11 0x1.99b6ed78f63ccp-9\n-0x1.2af2d09fa99c9p-11 0x1.99b6ed3643c83p-9\n-0x1.3401ee1570778p-11 0x1.99b6ecf184065p-9\n-0x1.3d110b882157bp-11 0x1.99b6ecaab6ccfp-9\n-0x1.462028f7a51d1p-11 0x1.99b6ec61dc40ep-9\n-0x1.4f2f4663e481cp-11 0x1.99b6ec16f4565p-9\n-0x1.583e63ccc8451p-11 0x1.99b6ebc9ff052p-9\n-0x1.614d8132393c7p-11 0x1.99b6eb7afc62cp-9\n-0x1.6a5c9e942013fp-11 0x1.99b6eb29ec525p-9\n-0x1.736bbbf265a98p-11 0x1.99b6ead6cef1ep-9\n-0x1.7c7ad94cf2c03p-11 0x1.99b6ea81a43e1p-9\n-0x1.8589f6a3affc4p-11 0x1.99b6ea2a6c132p-9\n-0x1.8e9913f68627ep-11 0x1.99b6e9d1267aap-9\n-0x1.97a831455e488p-11 0x1.99b6e975d3b61p-9\n-0x1.a0b74e9020dbp-11 0x1.99b6e918737cbp-9\n-0x1.a9c66bd6b6dcep-11 0x1.99b6e8b90604fp-9\n-0x1.b2d5891908c4fp-11 0x1.99b6e8578b05fp-9\n-0x1.bbe4a656ff79ep-11 0x1.99b6e7f402ap-9\n-0x1.c4f3c39083e33p-11 0x1.99b6e78e6cf4ap-9\n-0x1.ce02e0c57eafep-11 0x1.99b6e726c9eebp-9\n-0x1.d711fdf5d87acp-11 0x1.99b6e6bd19699p-9\n-0x1.e0211b217a6ebp-11 0x1.99b6e6515bbf7p-9\n-0x1.e93038484cd6ap-11 0x1.99b6e5e39086ep-9\n-0x1.f23f556a38e32p-11 0x1.99b6e573b81acp-9\n-0x1.fb4e728727075p-11 0x1.99b6e501d2377p-9\n-0x1.022ec7cf80049p-10 0x1.99b6e48ddee0ap-9\n-0x1.06b65658d6847p-10 0x1.99b6e417de5ecp-9\n-0x1.0b3de4df8b349p-10 0x1.99b6e39fd062bp-9\n-0x1.0fc57363926aap-10 0x1.99b6e325b4db2p-9\n-0x1.144d01e4e0d85p-10 0x1.99b6e2a98c41bp-9\n-0x1.18d490636aa4dp-10 0x1.99b6e22b563cp-9\n-0x1.1d5c1edf242e1p-10 0x1.99b6e1ab12c48p-9\n-0x1.21e3ad5801ea4p-10 0x1.99b6e128c1f7bp-9\n-0x1.266b3bcdf82d8p-10 0x1.99b6e0a463c1dp-9\n-0x1.2af2ca40fb74dp-10 0x1.99b6e01df849dp-9\n-0x1.2f7a58b0ffff8p-10 0x1.99b6df957f5bfp-9\n-0x1.3401e71dfa495p-10 0x1.99b6df0af91e3p-9\n-0x1.38897587dea55p-10 0x1.99b6de7e657abp-9\n-0x1.3d1103eea1585p-10 0x1.99b6ddefc44c9p-9\n-0x1.41989252372bdp-10 0x1.99b6dd5f16182p-9\n-0x1.462020b29411ap-10 0x1.99b6dccc5a4ep-9\n-0x1.4aa7af0faca01p-10 0x1.99b6dc37912fcp-9\n-0x1.4f2f3d69754f5p-10 0x1.99b6dba0bad87p-9\n-0x1.53b6cbbfe21eap-10 0x1.99b6db07d6cfp-9\n-0x1.583e5a12e8047p-10 0x1.99b6da6ce5c7ap-9\n-0x1.5cc5e8627af3ep-10 0x1.99b6d9cfe73b7p-9\n-0x1.614d76ae8f6d2p-10 0x1.99b6d930db4f7p-9\n-0x1.65d504f719e9fp-10 0x1.99b6d88fc21e4p-9\n-0x1.6a5c933c0e9a8p-10 0x1.99b6d7ec9b6d8p-9\n-0x1.6ee4217d61e79p-10 0x1.99b6d7476746cp-9\n-0x1.736bafbb08944p-10 0x1.99b6d6a026162p-9\n-0x1.77f33df4f6868p-10 0x1.99b6d5f6d7505p-9\n-0x1.7c7acc2b2055bp-10 0x1.99b6d54b7b318p-9\n-0x1.81025a5d7a71fp-10 0x1.99b6d49e11c7ap-9\n-0x1.8589e88bf9205p-10 0x1.99b6d3ee9af29p-9\n-0x1.8a1176b690d76p-10 0x1.99b6d33d16c9dp-9\n-0x1.8e9904dd35f55p-10 0x1.99b6d28985476p-9\n-0x1.932092ffdccfdp-10 0x1.99b6d1d3e65f2p-9\n-0x1.97a8211e79c47p-10 0x1.99b6d11c3a0d1p-9\n-0x1.9c2faf3901608p-10 0x1.99b6d062807b1p-9\n-0x1.a0b73d4f67b8ap-10 0x1.99b6cfa6b95c7p-9\n-0x1.a53ecb61a18d1p-10 0x1.99b6cee8e50eep-9\n-0x1.a9c6596fa3106p-10 0x1.99b6ce2903629p-9\n-0x1.ae4de77960962p-10 0x1.99b6cd6714497p-9\n-0x1.b2d5757ece972p-10 0x1.99b6cca317d95p-9\n-0x1.b75d037fe17b7p-10 0x1.99b6cbdd0e17cp-9\n-0x1.bbe4917c8d821p-10 0x1.99b6cb14f6e3cp-9\n-0x1.c06c1f74c7233p-10 0x1.99b6ca4ad251fp-9\n-0x1.c4f3ad6882bf1p-10 0x1.99b6c97ea0602p-9\n0x1.f628a0a10577dp-62 0x1.c73cf5a02051ap-9\n-0x1.21e3b51608ef3p-16 0x1.c73cf59efc75fp-9\n-0x1.21e3b51495638p-15 0x1.c73cf59b90e44p-9\n-0x1.b2d58f9b3eb3ap-15 0x1.c73cf595dd763p-9\n-0x1.21e3b50ec6556p-14 0x1.c73cf58de23d6p-9\n-0x1.6a5ca24d0621p-14 0x1.c73cf5839f8efp-9\n-0x1.b2d58f87a47f2p-14 0x1.c73cf57714facp-9\n-0x1.fb4e7cbde793fp-14 0x1.c73cf568428f6p-9\n-0x1.21e3b4f78af8fp-13 0x1.c73cf55728ac8p-9\n-0x1.46202b8d3a8aap-13 0x1.c73cf543c6c5dp-9\n-0x1.6a5ca21fa5e5ep-13 0x1.c73cf52e1d566p-9\n-0x1.8e9918ae6fda6p-13 0x1.c73cf5162c09ap-9\n-0x1.b2d58f393b89dp-13 0x1.c73cf4fbf2f93p-9\n-0x1.d71205bfac2afp-13 0x1.c73cf4df72452p-9\n-0x1.fb4e7c4164aa4p-13 0x1.c73cf4c0a9c81p-9\n-0x1.0fc5795f03fc9p-12 0x1.c73cf49f996adp-9\n-0x1.21e3b49a9cc2dp-12 0x1.c73cf47c417a2p-9\n-0x1.3401efd34e13dp-12 0x1.c73cf456a1c53p-9\n-0x1.46202b08e9743p-12 0x1.c73cf42eba45bp-9\n-0x1.583e663b407e6p-12 0x1.c73cf4048b16bp-9\n-0x1.6a5ca16a24ac2p-12 0x1.c73cf3d814214p-9\n-0x1.7c7adc9567994p-12 0x1.c73cf3a9557f2p-9\n-0x1.8e9917bcdabfep-12 0x1.c73cf3784f1d1p-9\n-0x1.a0b752e04f91bp-12 0x1.c73cf34500de6p-9\n-0x1.b2d58dff97d44p-12 0x1.c73cf30f6b09dp-9\n-0x1.c4f3c91a84d9bp-12 0x1.c73cf2d78d63ap-9\n-0x1.d7120430e839bp-12 0x1.c73cf29d67fbbp-9\n-0x1.e9303f42935e6p-12 0x1.c73cf260fab4bp-9\n-0x1.fb4e7a4f580dep-12 0x1.c73cf22245cb5p-9\n-0x1.06b65aab84015p-11 0x1.c73cf1e149647p-9\n-0x1.0fc5782cba1cdp-11 0x1.c73cf19e05092p-9\n-0x1.18d495ab37405p-11 0x1.c73cf15878f14p-9\n-0x1.21e3b326e4247p-11 0x1.c73cf110a50dep-9\n-0x1.2af2d09fa9adep-11 0x1.c73cf0c689915p-9\n-0x1.3401ee15707dfp-11 0x1.c73cf07a26428p-9\n-0x1.3d110b8821549p-11 0x1.c73cf02b7b1c5p-9\n-0x1.462028f7a524dp-11 0x1.c73cefda8864cp-9\n-0x1.4f2f4663e4613p-11 0x1.c73cef874da65p-9\n-0x1.583e63ccc844p-11 0x1.c73cef31cb849p-9\n-0x1.614d8132393f7p-11 0x1.c73ceeda018d4p-9\n-0x1.6a5c9e9420224p-11 0x1.c73cee7fefcf3p-9\n-0x1.736bbbf265b83p-11 0x1.c73cee2396556p-9\n-0x1.7c7ad94cf2cbp-11 0x1.c73cedc4f5257p-9\n-0x1.8589f6a3b00e3p-11 0x1.c73ced640c288p-9\n-0x1.8e9913f6864aep-11 0x1.c73ced00db67ep-9\n-0x1.97a831455e633p-11 0x1.c73cec9b6304fp-9\n-0x1.a0b74e9020f99p-11 0x1.c73cec33a2d76p-9\n-0x1.a9c66bd6b6c31p-11 0x1.c73cebc99ad09p-9\n-0x1.b2d5891908a51p-11 0x1.c73ceb5d4b15p-9\n-0x1.bbe4a656ff8fep-11 0x1.c73ceaeeb3d01p-9\n-0x1.c4f3c39083f83p-11 0x1.c73cea7dd4aeap-9\n-0x1.ce02e0c57ea84p-11 0x1.c73cea0aadb8dp-9\n-0x1.d711fdf5d898cp-11 0x1.c73ce9953f245p-9\n-0x1.e0211b217a65dp-11 0x1.c73ce91d88c3ap-9\n-0x1.e93038484ce55p-11 0x1.c73ce8a38aad2p-9\n-0x1.f23f556a38cdbp-11 0x1.c73ce82744d27p-9\n-0x1.fb4e728726f54p-11 0x1.c73ce7a8b740ep-9\n-0x1.022ec7cf8011bp-10 0x1.c73ce727e1ff1p-9\n-0x1.06b65658d67a1p-10 0x1.c73ce6a4c4e6bp-9\n-0x1.0b3de4df8b2bbp-10 0x1.c73ce61f601e7p-9\n-0x1.0fc5736392791p-10 0x1.c73ce597b38bap-9\n-0x1.144d01e4e0d6p-10 0x1.c73ce50dbf4b8p-9\n-0x1.18d490636a9cbp-10 0x1.c73ce48183514p-9\n-0x1.1d5c1edf24315p-10 0x1.c73ce3f2ff9dap-9\n-0x1.21e3ad5801ecp-10 0x1.c73ce36234235p-9\n-0x1.266b3bcdf8281p-10 0x1.c73ce2cf20d5bp-9\n-0x1.2af2ca40fb6a5p-10 0x1.c73ce239c5ec5p-9\n-0x1.2f7a58b100025p-10 0x1.c73ce1a223497p-9\n-0x1.3401e71dfa449p-10 0x1.c73ce10838d75p-9\n-0x1.38897587dea33p-10 0x1.c73ce06c06aecp-9\n-0x1.3d1103eea16a7p-10 0x1.c73cdfcd8cb11p-9\n-0x1.419892523730bp-10 0x1.c73cdf2ccb261p-9\n-0x1.462020b294124p-10 0x1.c73cde89c1ad8p-9\n-0x1.4aa7af0facb59p-10 0x1.c73cdde470a4ep-9\n-0x1.4f2f3d697543ap-10 0x1.c73cdd3cd7bdcp-9\n-0x1.53b6cbbfe248ap-10 0x1.c73cdc92f7319p-9\n-0x1.583e5a12e8122p-10 0x1.c73cdbe6cee3ep-9\n-0x1.5cc5e8627af38p-10 0x1.c73cdb385ec15p-9\n-0x1.614d76ae8f70ap-10 0x1.c73cda87a6f6fp-9\n-0x1.65d504f719dcbp-10 0x1.c73cd9d4a76ffp-9\n-0x1.6a5c933c0e94p-10 0x1.c73cd91f60252p-9\n-0x1.6ee4217d620d7p-10 0x1.c73cd867d1317p-9\n-0x1.736bafbb08946p-10 0x1.c73cd7adfa764p-9\n-0x1.77f33df4f6912p-10 0x1.c73cd6f1dbfc4p-9\n-0x1.7c7acc2b206c7p-10 0x1.c73cd63375cc1p-9\n-0x1.81025a5d7a7d9p-10 0x1.c73cd572c7d7p-9\n-0x1.8589e88bf91c4p-10 0x1.c73cd4afd2127p-9\n-0x1.8a1176b690b43p-10 0x1.c73cd3ea94891p-9\n-0x1.8e9904dd35e95p-10 0x1.c73cd3230f868p-9\n-0x1.932092ffdca2ap-10 0x1.c73cd259427d6p-9\n-0x1.97a8211e79aedp-10 0x1.c73cd18d2de96p-9\n-0x1.9c2faf39014ffp-10 0x1.c73cd0bed1a54p-9\n-0x1.a0b73d4f67cc2p-10 0x1.c73ccfee2d922p-9\n-0x1.a53ecb61a1a1dp-10 0x1.c73ccf1b41ce1p-9\n-0x1.a9c6596fa3057p-10 0x1.c73cce460e291p-9\n-0x1.ae4de779607ap-10 0x1.c73ccd6e92c5fp-9\n-0x1.b2d5757ece992p-10 0x1.c73ccc94cfdf8p-9\n-0x1.b75d037fe17bbp-10 0x1.c73ccbb8c5276p-9\n-0x1.bbe4917c8d913p-10 0x1.c73ccada72accp-9\n-0x1.c06c1f74c70a3p-10 0x1.c73cc9f9d83c2p-9\n-0x1.c4f3ad6882d57p-10 0x1.c73cc916f665fp-9\n" +} diff --git a/src/test/resources/probes/dssmap_probe.c b/src/test/resources/probes/dssmap_probe.c new file mode 100644 index 0000000..9428b40 --- /dev/null +++ b/src/test/resources/probes/dssmap_probe.c @@ -0,0 +1,318 @@ +/* dssmap_probe -- DssMap behaviour of the pinned C library that no fixture + * or oracle holds. C has no public DssMap constructor, so every DssMap is + * read from the fixture serialisation/c_dssmap.ast, some with one item + * removed or its value replaced: transformations both ways, inverted, with + * bad and far-off points, and with a plate centre near RA zero; rates; astEqual against altered plate solutions; + * loads with an item missing; and simplification with WinMaps and ZoomMaps + * on either side, inverted, and in parallel, with the value of the Invert + * attribute of the WinMap before and after. + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * Built against the C library at 3d3f255f with its static libraries: + * cc -std=c11 -I -o dssmap_probe dssmap_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 + * ./dssmap_probe /serialisation/c_dssmap.ast > dssmap_probe.out 2>&1 + * then trailing white space removed from every line (the tests compare + * lines without it). */ +#include +#include +#include +#include "ast.h" + +/* The lines of the fixture. */ +#define MAXLINES 400 +static char *fixture[ MAXLINES ]; +static int nfixture = 0; + +/* The lines a Channel reads. */ +static char *lines[ MAXLINES ]; +static int nline = 0; +static int iline = 0; + +static const char *source( void ) { + return ( iline < nline ) ? lines[ iline++ ] : NULL; +} + +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; +} + +/* Whether a fixture line holds the item "key". */ +static int has_key( const char *line, const char *key ) { + while( *line == ' ' ) line++; + size_t n = strlen( key ); + return !strncmp( line, key, n ) && line[ n ] == ' ' && line[ n + 1 ] == '='; +} + +/* The DssMap the fixture describes, with the item "drop" left out and the + value of item "key" replaced by "value" (either may be NULL). */ +static AstMapping *dss( const char *drop, const char *key, const char *value ) { + for( int i = 0; i < nline; i++ ) free( lines[ i ] ); + nline = iline = 0; + for( int i = 0; i < nfixture; i++ ) { + if( drop && has_key( fixture[ i ], drop ) ) continue; + char buf[ 300 ]; + if( key && has_key( fixture[ i ], key ) ) { + const char *comment = strchr( fixture[ i ], '#' ); + sprintf( buf, " %s = %s \t%s", key, value, comment ); + } else { + strcpy( buf, fixture[ i ] ); + } + lines[ nline++ ] = strcpy( malloc( strlen( buf ) + 1 ), buf ); + } + AstChannel *ch = astChannel( source, NULL, " " ); + AstMapping *m = astRead( ch ); + ch = astAnnul( ch ); + return m; +} + +static AstMapping *inv( void *m ) { + astInvert( m ); + return m; +} + +/* The pixel positions every forward transformation is given. */ +#define NPIX 7 +static const double xs[ NPIX ] = { 1000.0, 1.0, 500.0, 4000.0, 2000.0, AST__BAD, 100.0 }; +static const double ys[ NPIX ] = { 2000.0, 1.0, 500.0, 4000.0, 3000.0, 100.0, AST__BAD }; + +/* The sky positions (radians) every inverse transformation is given: near + the plate centre, on the far side of the sky, and ninety degrees from + the plate centre. */ +#define NSKY 6 +static const double ras[ NSKY ] = { 2.83, 2.8, 5.97, 1.25, AST__BAD, 2.85 }; +static const double decs[ NSKY ] = { -1.05, -1.0, 1.05, 0.0, -1.0, AST__BAD }; + +static void tran_points( AstMapping *m, int forward, int n, const double *x, const double *y ) { + double ox[ NPIX ], oy[ NPIX ]; + astTran2( m, n, x, y, forward, ox, oy ); + if( failed() ) return; + for( int i = 0; i < n; i++ ) { + printf( "%s %.17g %.17g -> %.17g %.17g\n", forward ? "fwd" : "inv", x[ i ], y[ i ], ox[ i ], + oy[ i ] ); + } +} + +/* The forward transformation of the pixel positions, the inverse of the + results, and the inverse of the sky positions; for an inverted Mapping + the directions are exchanged. */ +static void tran( AstMapping *m ) { + int pixfwd = !astGetI( m, "Invert" ); + double ox[ NPIX ], oy[ NPIX ]; + tran_points( m, pixfwd, NPIX, xs, ys ); + astTran2( m, NPIX, xs, ys, pixfwd, ox, oy ); + tran_points( m, !pixfwd, NPIX, ox, oy ); + tran_points( m, !pixfwd, NSKY, ras, decs ); +} + +/* The class of the simplified Mapping, its dump, and the transformations + of the original and the simplified Mapping, of the pixel positions in + the direction "fwd", when it has two inputs. */ +static void simp( const char *name, AstMapping *m, int fwd ) { + head( name ); + AstMapping *s = astSimplify( m ); + if( failed() ) return; + printf( "class %s\n", astGetC( s, "Class" ) ); + astShow( s ); + if( astGetI( m, "Nin" ) != 2 ) return; + double ox[ NPIX ], oy[ NPIX ]; + printf( "-- transformations\n" ); + astTran2( m, NPIX, xs, ys, fwd, ox, oy ); + for( int i = 0; i < NPIX; i++ ) printf( "%.17g %.17g\n", ox[ i ], oy[ i ] ); + printf( "-- transformations simplified\n" ); + astTran2( s, NPIX, xs, ys, fwd, ox, oy ); + for( int i = 0; i < NPIX; i++ ) printf( "%.17g %.17g\n", ox[ i ], oy[ i ] ); + failed(); +} + +/* The WinMap x -> 2x - 0.5 on both axes. */ +static AstWinMap *win( void ) { + 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 }; + return astWinMap( 2, ina, inb, outa, outb, " " ); +} + +/* The WinMap x -> 2x on both axes. */ +static AstWinMap *win_no_shift( void ) { + double ina[ 2 ] = { 0.0, 0.0 }, inb[ 2 ] = { 1.0, 1.0 }; + double outa[ 2 ] = { 0.0, 0.0 }, outb[ 2 ] = { 2.0, 2.0 }; + return astWinMap( 2, ina, inb, outa, outb, " " ); +} + +static AstCmpMap *series( void *a, void *b ) { + return astCmpMap( a, b, 1, " " ); +} + +int main( int argc, char **argv ) { + int status = 0; + setvbuf( stdout, NULL, _IONBF, 0 ); + if( argc < 2 ) return 1; + FILE *f = fopen( argv[ 1 ], "r" ); + if( !f ) return 1; + char buf[ 300 ]; + while( nfixture < MAXLINES && fgets( buf, sizeof( buf ), f ) ) { + buf[ strcspn( buf, "\n" ) ] = 0; + fixture[ nfixture++ ] = strcpy( malloc( strlen( buf ) + 1 ), buf ); + } + fclose( f ); + + astWatch( &status ); + astBegin; + + /* Transformations. */ + head( "tran" ); + tran( dss( NULL, NULL, NULL ) ); + head( "tran_inverted" ); + tran( inv( dss( NULL, NULL, NULL ) ) ); + head( "tran_cnpix_4200" ); + tran( dss( NULL, "CNPix1", "4200" ) ); + + /* A plate centre just east of RA zero, so that pixel positions to the + west of it have their right ascension wrapped by platepos's own + value of two pi. */ + head( "tran_pltra_small" ); + tran( dss( NULL, "PltRA", "0.0001" ) ); + + /* Rates of the forward transformation. */ + head( "rate" ); + { + AstMapping *m = dss( NULL, NULL, NULL ); + double at[ 2 ] = { 1000.0, 2000.0 }; + for( int ax1 = 1; ax1 <= 2; ax1++ ) { + for( int ax2 = 1; ax2 <= 2; ax2++ ) { + double r = astRate( m, at, ax1, ax2 ); + if( failed() ) continue; + printf( "rate %d %d %.17g\n", ax1, ax2, r ); + } + } + } + + /* astEqual against a DssMap with one item replaced. */ + head( "equal" ); + { + AstMapping *m = dss( NULL, NULL, NULL ); + static const char *keys[] = { + "PltRA", "PltRA", "PltDec", "PltScl", "CNPix1", "CNPix2", "XPixSz", "YPixSz", + "PPO1", "PPO2", "PPO3", "PPO4", "PPO5", "PPO6", "AMDX1", "AMDX13", "AMDX14", + "AMDX19", "AMDY1", "AMDY13", "AMDY14", "AMDY19" + }; + static const char *values[] = { + "2.8272374655684120", "2.8272374655685", "-1.05", "60", "4200", "4200", "25.3", "25.3", + "1", "1", "105990", "1", "1", "105990", "67.15", "1.5e-12", "1", "1", "67.15", + "1.4e-12", "1", "1" + }; + printf( "same %d\n", astEqual( m, dss( NULL, NULL, NULL ) ) ); + printf( "copy %d\n", astEqual( m, astCopy( m ) ) ); + printf( "inverted %d\n", astEqual( m, inv( dss( NULL, NULL, NULL ) ) ) ); + printf( "both_inverted %d\n", astEqual( inv( astCopy( m ) ), inv( dss( NULL, NULL, NULL ) ) ) ); + printf( "winmap %d\n", astEqual( m, win() ) ); + for( size_t i = 0; i < sizeof( keys ) / sizeof( keys[ 0 ] ); i++ ) { + int eq = astEqual( m, dss( NULL, keys[ i ], values[ i ] ) ); + if( failed() ) continue; + printf( "%s %s %d\n", keys[ i ], values[ i ], eq ); + } + } + + /* Loads with one item missing. */ + head( "load_missing" ); + { + static const char *keys[] = { + "PltRA", "PltDec", "PltScl", "CNPix1", "CNPix2", "XPixSz", "YPixSz", "PPO1", "PPO2", + "PPO3", "PPO4", "PPO5", "PPO6", "AMDX1", "AMDX2", "AMDX13", "AMDX14", "AMDX19", + "AMDY1", "AMDY12", "AMDY13", "AMDY14", "AMDY19" + }; + for( size_t i = 0; i < sizeof( keys ) / sizeof( keys[ 0 ] ); i++ ) { + printf( "-- %s\n", keys[ i ] ); + AstMapping *m = dss( keys[ i ], NULL, NULL ); + if( failed() ) continue; + printf( "class %s\n", astGetC( m, "Class" ) ); + } + } + + /* A load with AMDX14 non-zero: coefficients 14 to 19 (the magnitude and + colour terms) take no part in the transformations. */ + head( "load_amdx14_nonzero" ); + tran( dss( NULL, "AMDX14", "5" ) ); + + /* Simplification. */ + simp( "alone", dss( NULL, NULL, NULL ), 1 ); + simp( "winmap_then_dssmap_fractional", + (AstMapping *) series( win(), dss( NULL, NULL, NULL ) ), 1 ); + simp( "winmap_then_dssmap_fractional_cnpix2", + (AstMapping *) series( win(), dss( NULL, "CNPix1", "4200" ) ), 1 ); + { + /* Both CNPix values 4200. */ + AstMapping *d = dss( NULL, "CNPix1", "4200" ); + AstMapping *e; + for( int i = 0; i < nline; i++ ) { + if( has_key( lines[ i ], "CNPix2" ) ) { + const char *comment = strchr( lines[ i ], '#' ); + sprintf( buf, " CNPix2 = 4200 \t%s", comment ); + free( lines[ i ] ); + lines[ i ] = strcpy( malloc( strlen( buf ) + 1 ), buf ); + } + } + iline = 0; + AstChannel *ch = astChannel( source, NULL, " " ); + e = astRead( ch ); + ch = astAnnul( ch ); + d = astAnnul( d ); + + simp( "winmap_then_dssmap_4200", (AstMapping *) series( win(), e ), 1 ); + simp( "inverted_winmap_then_dssmap_4200", (AstMapping *) series( inv( win() ), e ), 1 ); + simp( "winmap_no_shift_then_dssmap_4200", (AstMapping *) series( win_no_shift(), e ), 1 ); + simp( "dssmap_then_winmap_4200", (AstMapping *) series( e, win() ), 1 ); + simp( "inverted_dssmap_then_winmap", (AstMapping *) series( inv( astCopy( e ) ), win() ), 0 ); + simp( "winmap_then_inverted_dssmap", (AstMapping *) series( win(), inv( astCopy( e ) ) ), 0 ); + simp( "zoommap_then_dssmap", (AstMapping *) series( astZoomMap( 2, 2.0, " " ), e ), 1 ); + simp( "parallel", (AstMapping *) astCmpMap( win(), e, 0, " " ), 1 ); + + /* The WinMap's Invert attribute (its value; whether it is set is + left out) before and after simplifying the inverse of a CmpMap + that merges: an inverted DssMap followed by an inverted WinMap, + the whole inverted, applies the WinMap forward before the DssMap + forward. */ + { + head( "invert_attr_both_inverted" ); + AstWinMap *w = (AstWinMap *) inv( win() ); + AstCmpMap *c = series( inv( astCopy( e ) ), w ); + astInvert( c ); + printf( "before %d\n", astGetI( w, "Invert" ) ); + AstMapping *s = astSimplify( c ); + printf( "class %s\n", astGetC( s, "Class" ) ); + printf( "after %d\n", astGetI( w, "Invert" ) ); + failed(); + simp( "inverted_dssmap_then_winmap_both_inverted", (AstMapping *) c, 1 ); + } + + /* The same with a DssMap whose merge fails (fractional CNPix). */ + { + head( "invert_attr_no_merge" ); + AstWinMap *w = (AstWinMap *) inv( win() ); + AstCmpMap *c = series( inv( dss( NULL, NULL, NULL ) ), w ); + astInvert( c ); + printf( "before %d\n", astGetI( w, "Invert" ) ); + AstMapping *s = astSimplify( c ); + printf( "class %s\n", astGetC( s, "Class" ) ); + printf( "after %d\n", astGetI( w, "Invert" ) ); + failed(); + } + } + + astEnd; + return 0; +} diff --git a/src/test/resources/probes/dssmap_probe.out b/src/test/resources/probes/dssmap_probe.out new file mode 100644 index 0000000..d4cde88 --- /dev/null +++ b/src/test/resources/probes/dssmap_probe.out @@ -0,0 +1,1206 @@ +== tran +fwd 1000 2000 -> 2.8083346239617448 -1.0343153598165549 +fwd 1 1 -> 2.8243236575347148 -1.0508322209249645 +fwd 500 500 -> 2.8161439608570813 -1.0467029611634802 +fwd 4000 4000 -> 2.7619802120535324 -1.0170010158886906 +fwd 2000 3000 -> 2.79273848535049 -1.0259086050587363 +fwd -1.7976931348623157e+308 100 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +fwd 100 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 2.8083346239617448 -1.0343153598165549 -> 999.99999999998818 2000.0000000000291 +inv 2.8243236575347148 -1.0508322209249645 -> 1.0000000000118234 1.0000000000254659 +inv 2.8161439608570813 -1.0467029611634802 -> 499.99999999996635 500.00000000001091 +inv 2.7619802120535324 -1.0170010158886906 -> 4000 4000.0000000000018 +inv 2.79273848535049 -1.0259086050587363 -> 1999.9999999999991 2999.9999999999955 +inv -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 2.8300000000000001 -1.05 -> -342.13828458891885 102.2257321518473 +inv 2.7999999999999998 -1 -> 1617.1678235011241 6166.6231601991112 +inv 5.9699999999999998 1.05 -> -245.78731831672849 102.3841654908947 +inv 1.25 0 -> -334276.482090351 1860.1224983535485 +inv -1.7976931348623157e+308 -1 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 2.8500000000000001 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== tran_inverted +inv 1000 2000 -> 2.8083346239617448 -1.0343153598165549 +inv 1 1 -> 2.8243236575347148 -1.0508322209249645 +inv 500 500 -> 2.8161439608570813 -1.0467029611634802 +inv 4000 4000 -> 2.7619802120535324 -1.0170010158886906 +inv 2000 3000 -> 2.79273848535049 -1.0259086050587363 +inv -1.7976931348623157e+308 100 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 100 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +fwd 2.8083346239617448 -1.0343153598165549 -> 999.99999999998818 2000.0000000000291 +fwd 2.8243236575347148 -1.0508322209249645 -> 1.0000000000118234 1.0000000000254659 +fwd 2.8161439608570813 -1.0467029611634802 -> 499.99999999996635 500.00000000001091 +fwd 2.7619802120535324 -1.0170010158886906 -> 4000 4000.0000000000018 +fwd 2.79273848535049 -1.0259086050587363 -> 1999.9999999999991 2999.9999999999955 +fwd -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +fwd -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +fwd 2.8300000000000001 -1.05 -> -342.13828458891885 102.2257321518473 +fwd 2.7999999999999998 -1 -> 1617.1678235011241 6166.6231601991112 +fwd 5.9699999999999998 1.05 -> -245.78731831672849 102.3841654908947 +fwd 1.25 0 -> -334276.482090351 1860.1224983535485 +fwd -1.7976931348623157e+308 -1 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +fwd 2.8500000000000001 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== tran_cnpix_4200 +fwd 1000 2000 -> 2.8083507094891389 -1.0343154939234542 +fwd 1 1 -> 2.8243402112567479 -1.0508322421330032 +fwd 500 500 -> 2.8161603947839868 -1.0467030405683626 +fwd 4000 4000 -> 2.7619957998052245 -1.0170014721586804 +fwd 2000 3000 -> 2.7927543360192209 -1.0259088480898237 +fwd -1.7976931348623157e+308 100 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +fwd 100 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 2.8083507094891389 -1.0343154939234542 -> 1000.0000000000127 2000.0000000000064 +inv 2.8243402112567479 -1.0508322421330032 -> 1.0000000000327418 1.0000000000027285 +inv 2.8161603947839868 -1.0467030405683626 -> 500.00000000001 500.00000000000091 +inv 2.7619957998052245 -1.0170014721586804 -> 4000.0000000000091 4000.0000000000273 +inv 2.7927543360192209 -1.0259088480898237 -> 1999.9999999999891 3000.0000000000082 +inv -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 2.8300000000000001 -1.05 -> -341.13828458891885 102.2257321518473 +inv 2.7999999999999998 -1 -> 1618.1678235011241 6166.6231601991112 +inv 5.9699999999999998 1.05 -> -244.78731831672849 102.3841654908947 +inv 1.25 0 -> -334275.482090351 1860.1224983535485 +inv -1.7976931348623157e+308 -1 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 2.8500000000000001 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== tran_pltra_small +fwd 1000 2000 -> 6.2643824655616953 -1.0343153598165549 +fwd 1 1 -> 6.2803714991346649 -1.0508322209249645 +fwd 500 500 -> 6.2721918024570318 -1.0467029611634802 +fwd 4000 4000 -> 6.2180280536534829 -1.0170010158886906 +fwd 2000 3000 -> 6.24878632695044 -1.0259086050587363 +fwd -1.7976931348623157e+308 100 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +fwd 100 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 6.2643824655616953 -1.0343153598165549 -> 999.99999999975535 2000.0000000000291 +inv 6.2803714991346649 -1.0508322209249645 -> 0.99999999978444976 1.0000000000254659 +inv 6.2721918024570318 -1.0467029611634802 -> 499.99999999976535 500.00000000001728 +inv 6.2180280536534829 -1.0170010158886906 -> 3999.9999999997581 4000.0000000000146 +inv 6.24878632695044 -1.0259086050587363 -> 1999.9999999997908 3000.0000000000018 +inv -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 2.8300000000000001 -1.05 -> -18284.114516483853 -100040.14214231048 +inv 2.7999999999999998 -1 -> -21861.721026482424 -103050.9953774332 +inv 5.9699999999999998 1.05 -> -18373.580043042748 -100012.74937664633 +inv 1.25 0 -> -141302.95105078415 40557.046783529462 +inv -1.7976931348623157e+308 -1 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 2.8500000000000001 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== rate +rate 1 1 -1.60855225875e-05 +rate 1 2 2.6544782499999998e-07 +rate 2 1 1.3416370000000001e-07 +rate 2 2 8.2207366812499995e-06 +== equal +same 1 +copy 1 +inverted 0 +both_inverted 1 +winmap 0 +PltRA 2.8272374655684120 1 +PltRA 2.8272374655685 1 +PltDec -1.05 0 +PltScl 60 1 +CNPix1 4200 0 +CNPix2 4200 0 +XPixSz 25.3 0 +YPixSz 25.3 0 +PPO1 1 1 +PPO2 1 1 +PPO3 105990 0 +PPO4 1 1 +PPO5 1 1 +PPO6 105990 0 +AMDX1 67.15 0 +AMDX13 1.5e-12 1 +AMDX14 1 1 +AMDX19 1 1 +AMDY1 67.15 0 +AMDY13 1.4e-12 1 +AMDY14 1 1 +AMDY19 1 1 +== load_missing +-- PltRA +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'PltRA' object (Plate centre RA) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- PltDec +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'PltDec' object (Plate centre Dec) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- PltScl +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'PltScl' object (Plate scale) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- CNPix1 +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'CNPix1' object (X pixel offset) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- CNPix2 +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'CNPix2' object (Y pixel offset) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- XPixSz +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'XPixSz' object (X pixel size) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- YPixSz +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'YPixSz' object (Y pixel size) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- PPO1 +class DssMap +-- PPO2 +class DssMap +-- PPO3 +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'PPO3' object (orientation coefficient 3) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- PPO4 +class DssMap +-- PPO5 +class DssMap +-- PPO6 +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'PPO6' object (orientation coefficient 6) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- AMDX1 +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'AMDX1' object (plate solution X coefficient 1) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- AMDX2 +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'AMDX2' object (plate solution X coefficient 2) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- AMDX13 +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'AMDX13' object (plate solution X coefficient 13) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- AMDX14 +class DssMap +-- AMDX19 +class DssMap +-- AMDY1 +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'AMDY1' object (plate solution Y coefficient 1) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- AMDY12 +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'AMDY12' object (plate solution Y coefficient 12) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- AMDY13 +!! AST: Error in routine dss at line 78 in file dssmap_probe.c. +! astRead(DssMap): 'AMDY13' object (plate solution Y coefficient 13) missing from input. +! Error while reading a DssMap from a Channel. +status 233933650 +-- AMDY14 +class DssMap +-- AMDY19 +class DssMap +== load_amdx14_nonzero +fwd 1000 2000 -> 2.8083346239617448 -1.0343153598165549 +fwd 1 1 -> 2.8243236575347148 -1.0508322209249645 +fwd 500 500 -> 2.8161439608570813 -1.0467029611634802 +fwd 4000 4000 -> 2.7619802120535324 -1.0170010158886906 +fwd 2000 3000 -> 2.79273848535049 -1.0259086050587363 +fwd -1.7976931348623157e+308 100 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +fwd 100 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 2.8083346239617448 -1.0343153598165549 -> 999.99999999998818 2000.0000000000291 +inv 2.8243236575347148 -1.0508322209249645 -> 1.0000000000118234 1.0000000000254659 +inv 2.8161439608570813 -1.0467029611634802 -> 499.99999999996635 500.00000000001091 +inv 2.7619802120535324 -1.0170010158886906 -> 4000 4000.0000000000018 +inv 2.79273848535049 -1.0259086050587363 -> 1999.9999999999991 2999.9999999999955 +inv -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 2.8300000000000001 -1.05 -> -342.13828458891885 102.2257321518473 +inv 2.7999999999999998 -1 -> 1617.1678235011241 6166.6231601991112 +inv 5.9699999999999998 1.05 -> -245.78731831672849 102.3841654908947 +inv 1.25 0 -> -334276.482090351 1860.1224983535485 +inv -1.7976931348623157e+308 -1 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 2.8500000000000001 -1.7976931348623157e+308 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== alone +class DssMap + Begin DssMap # DSS plate fit mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + PltRA = 2.8272374655684112 # Plate centre RA (radians) + PltDec = -1.0518122540502668 # Plate centre Dec (radians) + PltScl = 67.200000000000003 # Plate scale (arcsec/mm) + CNPix1 = 4201 # X Pixel offset (pixels) + CNPix2 = 4201 # Y Pixel offset (pixels) + XPixSz = 25.263000000000002 # X Pixel size (microns) + YPixSz = 25.263000000000002 # Y Pixel size (microns) + PPO1 = 0 # Orientation coefficients + PPO2 = 0 # Orientation coefficients + PPO3 = 105990.5119 # Orientation coefficients + PPO4 = 0 # Orientation coefficients + PPO5 = 0 # Orientation coefficients + PPO6 = 105990.5119 # Orientation coefficients + AMDX1 = 67.152600000000007 # Plate solution X coefficients + AMDX2 = 0.0051200000000000004 # Plate solution X coefficients + AMDX3 = -288.40899999999999 # Plate solution X coefficients + AMDX4 = -8.8400000000000001e-06 # Plate solution X coefficients + AMDX5 = -2.9300000000000001e-05 # Plate solution X coefficients + AMDX6 = 3.9099999999999998e-06 # Plate solution X coefficients + AMDX7 = -4.16e-06 # Plate solution X coefficients + AMDX8 = -9.7500000000000005e-10 # Plate solution X coefficients + AMDX9 = 3.2600000000000001e-10 # Plate solution X coefficients + AMDX10 = 7.78e-10 # Plate solution X coefficients + AMDX11 = 2.0700000000000001e-10 # Plate solution X coefficients + AMDX12 = 5.5500000000000001e-09 # Plate solution X coefficients + AMDX13 = 1.4899999999999999e-12 # Plate solution X coefficients + AMDX14 = 0 # Plate solution X coefficients + AMDX15 = 0 # Plate solution X coefficients + AMDX16 = 0 # Plate solution X coefficients + AMDX17 = 0 # Plate solution X coefficients + AMDX18 = 0 # Plate solution X coefficients + AMDX19 = 0 # Plate solution X coefficients + AMDY1 = 67.154200000000003 # Plate solution Y coefficients + AMDY2 = -0.0038300000000000001 # Plate solution Y coefficients + AMDY3 = 191.56200000000001 # Plate solution Y coefficients + AMDY4 = -2.12e-05 # Plate solution Y coefficients + AMDY5 = -2.9200000000000002e-05 # Plate solution Y coefficients + AMDY6 = -9.4399999999999994e-06 # Plate solution Y coefficients + AMDY7 = -4.1400000000000002e-06 # Plate solution Y coefficients + AMDY8 = 6.6699999999999997e-10 # Plate solution Y coefficients + AMDY9 = 6.9399999999999998e-10 # Plate solution Y coefficients + AMDY10 = -2.0800000000000001e-10 # Plate solution Y coefficients + AMDY11 = -1.2e-09 # Plate solution Y coefficients + AMDY12 = 5.5599999999999998e-09 # Plate solution Y coefficients + AMDY13 = 1.5000000000000001e-12 # Plate solution Y coefficients + AMDY14 = 0 # Plate solution Y coefficients + AMDY15 = 0 # Plate solution Y coefficients + AMDY16 = 0 # Plate solution Y coefficients + AMDY17 = 0 # Plate solution Y coefficients + AMDY18 = 0 # Plate solution Y coefficients + AMDY19 = 0 # Plate solution Y coefficients + End DssMap +-- transformations +2.8083346239617448 -1.0343153598165549 +2.8243236575347148 -1.0508322209249645 +2.8161439608570813 -1.0467029611634802 +2.7619802120535324 -1.0170010158886906 +2.79273848535049 -1.0259086050587363 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +2.8083346239617448 -1.0343153598165549 +2.8243236575347148 -1.0508322209249645 +2.8161439608570813 -1.0467029611634802 +2.7619802120535324 -1.0170010158886906 +2.79273848535049 -1.0259086050587363 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +== winmap_then_dssmap_fractional +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin WinMap # Map one window on to another + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = -0.5 # Shift for axis 1 + Scl1 = 2 # Scale factor for axis 1 + Sft2 = -0.5 # Shift for axis 2 + Scl2 = 2 # Scale factor for axis 2 + End WinMap + MapB = # Second component Mapping + Begin DssMap # DSS plate fit mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PltRA = 2.8272374655684112 # Plate centre RA (radians) + PltDec = -1.0518122540502668 # Plate centre Dec (radians) + PltScl = 67.200000000000003 # Plate scale (arcsec/mm) + CNPix1 = 4201 # X Pixel offset (pixels) + CNPix2 = 4201 # Y Pixel offset (pixels) + XPixSz = 25.263000000000002 # X Pixel size (microns) + YPixSz = 25.263000000000002 # Y Pixel size (microns) + PPO1 = 0 # Orientation coefficients + PPO2 = 0 # Orientation coefficients + PPO3 = 105990.5119 # Orientation coefficients + PPO4 = 0 # Orientation coefficients + PPO5 = 0 # Orientation coefficients + PPO6 = 105990.5119 # Orientation coefficients + AMDX1 = 67.152600000000007 # Plate solution X coefficients + AMDX2 = 0.0051200000000000004 # Plate solution X coefficients + AMDX3 = -288.40899999999999 # Plate solution X coefficients + AMDX4 = -8.8400000000000001e-06 # Plate solution X coefficients + AMDX5 = -2.9300000000000001e-05 # Plate solution X coefficients + AMDX6 = 3.9099999999999998e-06 # Plate solution X coefficients + AMDX7 = -4.16e-06 # Plate solution X coefficients + AMDX8 = -9.7500000000000005e-10 # Plate solution X coefficients + AMDX9 = 3.2600000000000001e-10 # Plate solution X coefficients + AMDX10 = 7.78e-10 # Plate solution X coefficients + AMDX11 = 2.0700000000000001e-10 # Plate solution X coefficients + AMDX12 = 5.5500000000000001e-09 # Plate solution X coefficients + AMDX13 = 1.4899999999999999e-12 # Plate solution X coefficients + AMDX14 = 0 # Plate solution X coefficients + AMDX15 = 0 # Plate solution X coefficients + AMDX16 = 0 # Plate solution X coefficients + AMDX17 = 0 # Plate solution X coefficients + AMDX18 = 0 # Plate solution X coefficients + AMDX19 = 0 # Plate solution X coefficients + AMDY1 = 67.154200000000003 # Plate solution Y coefficients + AMDY2 = -0.0038300000000000001 # Plate solution Y coefficients + AMDY3 = 191.56200000000001 # Plate solution Y coefficients + AMDY4 = -2.12e-05 # Plate solution Y coefficients + AMDY5 = -2.9200000000000002e-05 # Plate solution Y coefficients + AMDY6 = -9.4399999999999994e-06 # Plate solution Y coefficients + AMDY7 = -4.1400000000000002e-06 # Plate solution Y coefficients + AMDY8 = 6.6699999999999997e-10 # Plate solution Y coefficients + AMDY9 = 6.9399999999999998e-10 # Plate solution Y coefficients + AMDY10 = -2.0800000000000001e-10 # Plate solution Y coefficients + AMDY11 = -1.2e-09 # Plate solution Y coefficients + AMDY12 = 5.5599999999999998e-09 # Plate solution Y coefficients + AMDY13 = 1.5000000000000001e-12 # Plate solution Y coefficients + AMDY14 = 0 # Plate solution Y coefficients + AMDY15 = 0 # Plate solution Y coefficients + AMDY16 = 0 # Plate solution Y coefficients + AMDY17 = 0 # Plate solution Y coefficients + AMDY18 = 0 # Plate solution Y coefficients + AMDY19 = 0 # Plate solution Y coefficients + End DssMap + End CmpMap +-- transformations +2.7932160884189003 -1.0177004481235701 +2.8243154023073029 -1.0508280978270057 +2.8080734286818534 -1.0425413240805228 +2.7064609247333031 -0.98176109163331693 +2.7637124571539498 -1.0006201529549985 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +2.7932160884189003 -1.0177004481235701 +2.8243154023073029 -1.0508280978270057 +2.8080734286818534 -1.0425413240805228 +2.7064609247333031 -0.98176109163331693 +2.7637124571539498 -1.0006201529549985 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +== winmap_then_dssmap_fractional_cnpix2 +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin WinMap # Map one window on to another + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = -0.5 # Shift for axis 1 + Scl1 = 2 # Scale factor for axis 1 + Sft2 = -0.5 # Shift for axis 2 + Scl2 = 2 # Scale factor for axis 2 + End WinMap + MapB = # Second component Mapping + Begin DssMap # DSS plate fit mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PltRA = 2.8272374655684112 # Plate centre RA (radians) + PltDec = -1.0518122540502668 # Plate centre Dec (radians) + PltScl = 67.200000000000003 # Plate scale (arcsec/mm) + CNPix1 = 4200 # X Pixel offset (pixels) + CNPix2 = 4201 # Y Pixel offset (pixels) + XPixSz = 25.263000000000002 # X Pixel size (microns) + YPixSz = 25.263000000000002 # Y Pixel size (microns) + PPO1 = 0 # Orientation coefficients + PPO2 = 0 # Orientation coefficients + PPO3 = 105990.5119 # Orientation coefficients + PPO4 = 0 # Orientation coefficients + PPO5 = 0 # Orientation coefficients + PPO6 = 105990.5119 # Orientation coefficients + AMDX1 = 67.152600000000007 # Plate solution X coefficients + AMDX2 = 0.0051200000000000004 # Plate solution X coefficients + AMDX3 = -288.40899999999999 # Plate solution X coefficients + AMDX4 = -8.8400000000000001e-06 # Plate solution X coefficients + AMDX5 = -2.9300000000000001e-05 # Plate solution X coefficients + AMDX6 = 3.9099999999999998e-06 # Plate solution X coefficients + AMDX7 = -4.16e-06 # Plate solution X coefficients + AMDX8 = -9.7500000000000005e-10 # Plate solution X coefficients + AMDX9 = 3.2600000000000001e-10 # Plate solution X coefficients + AMDX10 = 7.78e-10 # Plate solution X coefficients + AMDX11 = 2.0700000000000001e-10 # Plate solution X coefficients + AMDX12 = 5.5500000000000001e-09 # Plate solution X coefficients + AMDX13 = 1.4899999999999999e-12 # Plate solution X coefficients + AMDX14 = 0 # Plate solution X coefficients + AMDX15 = 0 # Plate solution X coefficients + AMDX16 = 0 # Plate solution X coefficients + AMDX17 = 0 # Plate solution X coefficients + AMDX18 = 0 # Plate solution X coefficients + AMDX19 = 0 # Plate solution X coefficients + AMDY1 = 67.154200000000003 # Plate solution Y coefficients + AMDY2 = -0.0038300000000000001 # Plate solution Y coefficients + AMDY3 = 191.56200000000001 # Plate solution Y coefficients + AMDY4 = -2.12e-05 # Plate solution Y coefficients + AMDY5 = -2.9200000000000002e-05 # Plate solution Y coefficients + AMDY6 = -9.4399999999999994e-06 # Plate solution Y coefficients + AMDY7 = -4.1400000000000002e-06 # Plate solution Y coefficients + AMDY8 = 6.6699999999999997e-10 # Plate solution Y coefficients + AMDY9 = 6.9399999999999998e-10 # Plate solution Y coefficients + AMDY10 = -2.0800000000000001e-10 # Plate solution Y coefficients + AMDY11 = -1.2e-09 # Plate solution Y coefficients + AMDY12 = 5.5599999999999998e-09 # Plate solution Y coefficients + AMDY13 = 1.5000000000000001e-12 # Plate solution Y coefficients + AMDY14 = 0 # Plate solution Y coefficients + AMDY15 = 0 # Plate solution Y coefficients + AMDY16 = 0 # Plate solution Y coefficients + AMDY17 = 0 # Plate solution Y coefficients + AMDY18 = 0 # Plate solution Y coefficients + AMDY19 = 0 # Plate solution Y coefficients + End DssMap + End CmpMap +-- transformations +2.793231724129992 -1.0177006866582459 +2.8243319559095421 -1.0508281190939217 +2.8080897422809477 -1.0425414606130279 +2.7064755617912351 -0.98176191523115552 +2.7637276358882721 -1.000620592699879 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +2.793231724129992 -1.0177006866582459 +2.8243319559095421 -1.0508281190939217 +2.8080897422809477 -1.0425414606130279 +2.7064755617912351 -0.98176191523115552 +2.7637276358882721 -1.000620592699879 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +== winmap_then_dssmap_4200 +class DssMap + Begin DssMap # DSS plate fit mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + PltRA = 2.8272374655684112 # Plate centre RA (radians) + PltDec = -1.0518122540502668 # Plate centre Dec (radians) + PltScl = 67.200000000000003 # Plate scale (arcsec/mm) + CNPix1 = 2100 # X Pixel offset (pixels) + CNPix2 = 2100 # Y Pixel offset (pixels) + XPixSz = 50.526000000000003 # X Pixel size (microns) + YPixSz = 50.526000000000003 # Y Pixel size (microns) + PPO1 = 0 # Orientation coefficients + PPO2 = 0 # Orientation coefficients + PPO3 = 105990.5119 # Orientation coefficients + PPO4 = 0 # Orientation coefficients + PPO5 = 0 # Orientation coefficients + PPO6 = 105990.5119 # Orientation coefficients + AMDX1 = 67.152600000000007 # Plate solution X coefficients + AMDX2 = 0.0051200000000000004 # Plate solution X coefficients + AMDX3 = -288.40899999999999 # Plate solution X coefficients + AMDX4 = -8.8400000000000001e-06 # Plate solution X coefficients + AMDX5 = -2.9300000000000001e-05 # Plate solution X coefficients + AMDX6 = 3.9099999999999998e-06 # Plate solution X coefficients + AMDX7 = -4.16e-06 # Plate solution X coefficients + AMDX8 = -9.7500000000000005e-10 # Plate solution X coefficients + AMDX9 = 3.2600000000000001e-10 # Plate solution X coefficients + AMDX10 = 7.78e-10 # Plate solution X coefficients + AMDX11 = 2.0700000000000001e-10 # Plate solution X coefficients + AMDX12 = 5.5500000000000001e-09 # Plate solution X coefficients + AMDX13 = 1.4899999999999999e-12 # Plate solution X coefficients + AMDX14 = 0 # Plate solution X coefficients + AMDX15 = 0 # Plate solution X coefficients + AMDX16 = 0 # Plate solution X coefficients + AMDX17 = 0 # Plate solution X coefficients + AMDX18 = 0 # Plate solution X coefficients + AMDX19 = 0 # Plate solution X coefficients + AMDY1 = 67.154200000000003 # Plate solution Y coefficients + AMDY2 = -0.0038300000000000001 # Plate solution Y coefficients + AMDY3 = 191.56200000000001 # Plate solution Y coefficients + AMDY4 = -2.12e-05 # Plate solution Y coefficients + AMDY5 = -2.9200000000000002e-05 # Plate solution Y coefficients + AMDY6 = -9.4399999999999994e-06 # Plate solution Y coefficients + AMDY7 = -4.1400000000000002e-06 # Plate solution Y coefficients + AMDY8 = 6.6699999999999997e-10 # Plate solution Y coefficients + AMDY9 = 6.9399999999999998e-10 # Plate solution Y coefficients + AMDY10 = -2.0800000000000001e-10 # Plate solution Y coefficients + AMDY11 = -1.2e-09 # Plate solution Y coefficients + AMDY12 = 5.5599999999999998e-09 # Plate solution Y coefficients + AMDY13 = 1.5000000000000001e-12 # Plate solution Y coefficients + AMDY14 = 0 # Plate solution Y coefficients + AMDY15 = 0 # Plate solution Y coefficients + AMDY16 = 0 # Plate solution Y coefficients + AMDY17 = 0 # Plate solution Y coefficients + AMDY18 = 0 # Plate solution Y coefficients + AMDY19 = 0 # Plate solution Y coefficients + End DssMap +-- transformations +2.793231260829788 -1.0177088969714392 +2.8243319128812465 -1.0508363439936359 +2.8080894695840812 -1.042549683267664 +2.7064740214574168 -0.98177004370681353 +2.7637267965791148 -1.0006287797893743 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +2.793231260829788 -1.0177088969714392 +2.8243319128812465 -1.0508363439936359 +2.8080894695840812 -1.042549683267664 +2.7064740214574168 -0.98177004370681353 +2.7637267965791148 -1.0006287797893743 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +== inverted_winmap_then_dssmap_4200 +class DssMap + Begin DssMap # DSS plate fit mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + PltRA = 2.8272374655684112 # Plate centre RA (radians) + PltDec = -1.0518122540502668 # Plate centre Dec (radians) + PltScl = 67.200000000000003 # Plate scale (arcsec/mm) + CNPix1 = 8400 # X Pixel offset (pixels) + CNPix2 = 8400 # Y Pixel offset (pixels) + XPixSz = 12.631500000000001 # X Pixel size (microns) + YPixSz = 12.631500000000001 # Y Pixel size (microns) + PPO1 = 0 # Orientation coefficients + PPO2 = 0 # Orientation coefficients + PPO3 = 105990.5119 # Orientation coefficients + PPO4 = 0 # Orientation coefficients + PPO5 = 0 # Orientation coefficients + PPO6 = 105990.5119 # Orientation coefficients + AMDX1 = 67.152600000000007 # Plate solution X coefficients + AMDX2 = 0.0051200000000000004 # Plate solution X coefficients + AMDX3 = -288.40899999999999 # Plate solution X coefficients + AMDX4 = -8.8400000000000001e-06 # Plate solution X coefficients + AMDX5 = -2.9300000000000001e-05 # Plate solution X coefficients + AMDX6 = 3.9099999999999998e-06 # Plate solution X coefficients + AMDX7 = -4.16e-06 # Plate solution X coefficients + AMDX8 = -9.7500000000000005e-10 # Plate solution X coefficients + AMDX9 = 3.2600000000000001e-10 # Plate solution X coefficients + AMDX10 = 7.78e-10 # Plate solution X coefficients + AMDX11 = 2.0700000000000001e-10 # Plate solution X coefficients + AMDX12 = 5.5500000000000001e-09 # Plate solution X coefficients + AMDX13 = 1.4899999999999999e-12 # Plate solution X coefficients + AMDX14 = 0 # Plate solution X coefficients + AMDX15 = 0 # Plate solution X coefficients + AMDX16 = 0 # Plate solution X coefficients + AMDX17 = 0 # Plate solution X coefficients + AMDX18 = 0 # Plate solution X coefficients + AMDX19 = 0 # Plate solution X coefficients + AMDY1 = 67.154200000000003 # Plate solution Y coefficients + AMDY2 = -0.0038300000000000001 # Plate solution Y coefficients + AMDY3 = 191.56200000000001 # Plate solution Y coefficients + AMDY4 = -2.12e-05 # Plate solution Y coefficients + AMDY5 = -2.9200000000000002e-05 # Plate solution Y coefficients + AMDY6 = -9.4399999999999994e-06 # Plate solution Y coefficients + AMDY7 = -4.1400000000000002e-06 # Plate solution Y coefficients + AMDY8 = 6.6699999999999997e-10 # Plate solution Y coefficients + AMDY9 = 6.9399999999999998e-10 # Plate solution Y coefficients + AMDY10 = -2.0800000000000001e-10 # Plate solution Y coefficients + AMDY11 = -1.2e-09 # Plate solution Y coefficients + AMDY12 = 5.5599999999999998e-09 # Plate solution Y coefficients + AMDY13 = 1.5000000000000001e-12 # Plate solution Y coefficients + AMDY14 = 0 # Plate solution Y coefficients + AMDY15 = 0 # Plate solution Y coefficients + AMDY16 = 0 # Plate solution Y coefficients + AMDY17 = 0 # Plate solution Y coefficients + AMDY18 = 0 # Plate solution Y coefficients + AMDY19 = 0 # Plate solution Y coefficients + End DssMap +-- transformations +2.8162353425781337 -1.0425972229107545 +2.8243442961243943 -1.050842528541726 +2.8202395599888272 -1.0487815202301161 +2.7922669873347568 -1.0341307895452183 +2.8082129118871975 -1.0384322808795139 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +2.8162353425781337 -1.0425972229107545 +2.8243442961243943 -1.050842528541726 +2.8202395599888272 -1.0487815202301161 +2.7922669873347568 -1.0341307895452183 +2.8082129118871975 -1.0384322808795139 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +== winmap_no_shift_then_dssmap_4200 +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin DssMap # DSS plate fit mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PltRA = 2.8272374655684112 # Plate centre RA (radians) + PltDec = -1.0518122540502668 # Plate centre Dec (radians) + PltScl = 67.200000000000003 # Plate scale (arcsec/mm) + CNPix1 = 4200 # X Pixel offset (pixels) + CNPix2 = 4200 # Y Pixel offset (pixels) + XPixSz = 25.263000000000002 # X Pixel size (microns) + YPixSz = 25.263000000000002 # Y Pixel size (microns) + PPO1 = 0 # Orientation coefficients + PPO2 = 0 # Orientation coefficients + PPO3 = 105990.5119 # Orientation coefficients + PPO4 = 0 # Orientation coefficients + PPO5 = 0 # Orientation coefficients + PPO6 = 105990.5119 # Orientation coefficients + AMDX1 = 67.152600000000007 # Plate solution X coefficients + AMDX2 = 0.0051200000000000004 # Plate solution X coefficients + AMDX3 = -288.40899999999999 # Plate solution X coefficients + AMDX4 = -8.8400000000000001e-06 # Plate solution X coefficients + AMDX5 = -2.9300000000000001e-05 # Plate solution X coefficients + AMDX6 = 3.9099999999999998e-06 # Plate solution X coefficients + AMDX7 = -4.16e-06 # Plate solution X coefficients + AMDX8 = -9.7500000000000005e-10 # Plate solution X coefficients + AMDX9 = 3.2600000000000001e-10 # Plate solution X coefficients + AMDX10 = 7.78e-10 # Plate solution X coefficients + AMDX11 = 2.0700000000000001e-10 # Plate solution X coefficients + AMDX12 = 5.5500000000000001e-09 # Plate solution X coefficients + AMDX13 = 1.4899999999999999e-12 # Plate solution X coefficients + AMDX14 = 0 # Plate solution X coefficients + AMDX15 = 0 # Plate solution X coefficients + AMDX16 = 0 # Plate solution X coefficients + AMDX17 = 0 # Plate solution X coefficients + AMDX18 = 0 # Plate solution X coefficients + AMDX19 = 0 # Plate solution X coefficients + AMDY1 = 67.154200000000003 # Plate solution Y coefficients + AMDY2 = -0.0038300000000000001 # Plate solution Y coefficients + AMDY3 = 191.56200000000001 # Plate solution Y coefficients + AMDY4 = -2.12e-05 # Plate solution Y coefficients + AMDY5 = -2.9200000000000002e-05 # Plate solution Y coefficients + AMDY6 = -9.4399999999999994e-06 # Plate solution Y coefficients + AMDY7 = -4.1400000000000002e-06 # Plate solution Y coefficients + AMDY8 = 6.6699999999999997e-10 # Plate solution Y coefficients + AMDY9 = 6.9399999999999998e-10 # Plate solution Y coefficients + AMDY10 = -2.0800000000000001e-10 # Plate solution Y coefficients + AMDY11 = -1.2e-09 # Plate solution Y coefficients + AMDY12 = 5.5599999999999998e-09 # Plate solution Y coefficients + AMDY13 = 1.5000000000000001e-12 # Plate solution Y coefficients + AMDY14 = 0 # Plate solution Y coefficients + AMDY15 = 0 # Plate solution Y coefficients + AMDY16 = 0 # Plate solution Y coefficients + AMDY17 = 0 # Plate solution Y coefficients + AMDY18 = 0 # Plate solution Y coefficients + AMDY19 = 0 # Plate solution Y coefficients + End DssMap + End CmpMap +-- transformations +2.7932236745708341 -1.0177046725594903 +2.8243236575347148 -1.0508322209249645 +2.8080814490748809 -1.0425455036877651 +2.7064674730485061 -0.98176556767793721 +2.7637196268159423 -1.0006244663824764 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +2.7932236745708341 -1.0177046725594903 +2.8243236575347148 -1.0508322209249645 +2.8080814490748809 -1.0425455036877651 +2.7064674730485061 -0.98176556767793721 +2.7637196268159423 -1.0006244663824764 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +== dssmap_then_winmap_4200 +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin DssMap # DSS plate fit mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PltRA = 2.8272374655684112 # Plate centre RA (radians) + PltDec = -1.0518122540502668 # Plate centre Dec (radians) + PltScl = 67.200000000000003 # Plate scale (arcsec/mm) + CNPix1 = 4200 # X Pixel offset (pixels) + CNPix2 = 4200 # Y Pixel offset (pixels) + XPixSz = 25.263000000000002 # X Pixel size (microns) + YPixSz = 25.263000000000002 # Y Pixel size (microns) + PPO1 = 0 # Orientation coefficients + PPO2 = 0 # Orientation coefficients + PPO3 = 105990.5119 # Orientation coefficients + PPO4 = 0 # Orientation coefficients + PPO5 = 0 # Orientation coefficients + PPO6 = 105990.5119 # Orientation coefficients + AMDX1 = 67.152600000000007 # Plate solution X coefficients + AMDX2 = 0.0051200000000000004 # Plate solution X coefficients + AMDX3 = -288.40899999999999 # Plate solution X coefficients + AMDX4 = -8.8400000000000001e-06 # Plate solution X coefficients + AMDX5 = -2.9300000000000001e-05 # Plate solution X coefficients + AMDX6 = 3.9099999999999998e-06 # Plate solution X coefficients + AMDX7 = -4.16e-06 # Plate solution X coefficients + AMDX8 = -9.7500000000000005e-10 # Plate solution X coefficients + AMDX9 = 3.2600000000000001e-10 # Plate solution X coefficients + AMDX10 = 7.78e-10 # Plate solution X coefficients + AMDX11 = 2.0700000000000001e-10 # Plate solution X coefficients + AMDX12 = 5.5500000000000001e-09 # Plate solution X coefficients + AMDX13 = 1.4899999999999999e-12 # Plate solution X coefficients + AMDX14 = 0 # Plate solution X coefficients + AMDX15 = 0 # Plate solution X coefficients + AMDX16 = 0 # Plate solution X coefficients + AMDX17 = 0 # Plate solution X coefficients + AMDX18 = 0 # Plate solution X coefficients + AMDX19 = 0 # Plate solution X coefficients + AMDY1 = 67.154200000000003 # Plate solution Y coefficients + AMDY2 = -0.0038300000000000001 # Plate solution Y coefficients + AMDY3 = 191.56200000000001 # Plate solution Y coefficients + AMDY4 = -2.12e-05 # Plate solution Y coefficients + AMDY5 = -2.9200000000000002e-05 # Plate solution Y coefficients + AMDY6 = -9.4399999999999994e-06 # Plate solution Y coefficients + AMDY7 = -4.1400000000000002e-06 # Plate solution Y coefficients + AMDY8 = 6.6699999999999997e-10 # Plate solution Y coefficients + AMDY9 = 6.9399999999999998e-10 # Plate solution Y coefficients + AMDY10 = -2.0800000000000001e-10 # Plate solution Y coefficients + AMDY11 = -1.2e-09 # Plate solution Y coefficients + AMDY12 = 5.5599999999999998e-09 # Plate solution Y coefficients + AMDY13 = 1.5000000000000001e-12 # Plate solution Y coefficients + AMDY14 = 0 # Plate solution Y coefficients + AMDY15 = 0 # Plate solution Y coefficients + AMDY16 = 0 # Plate solution Y coefficients + AMDY17 = 0 # Plate solution Y coefficients + AMDY18 = 0 # Plate solution Y coefficients + AMDY19 = 0 # Plate solution Y coefficients + End DssMap + MapB = # Second component Mapping + Begin WinMap # Map one window on to another + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = -0.5 # Shift for axis 1 + Scl1 = 2 # Scale factor for axis 1 + Sft2 = -0.5 # Shift for axis 2 + Scl2 = 2 # Scale factor for axis 2 + End WinMap + End CmpMap +-- transformations +5.1167008885247238 -2.5686474293276396 +5.1486803366937961 -2.601680934066037 +5.1323204707205958 -2.5934225295085351 +5.0239898278578679 -2.5340193392401651 +5.0855077194351503 -2.551834124764091 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +5.1167008885247238 -2.5686474293276396 +5.1486803366937961 -2.601680934066037 +5.1323204707205958 -2.5934225295085351 +5.0239898278578679 -2.5340193392401651 +5.0855077194351503 -2.551834124764091 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +== inverted_dssmap_then_winmap +class DssMap + Begin DssMap # DSS plate fit mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PltRA = 2.8272374655684112 # Plate centre RA (radians) + PltDec = -1.0518122540502668 # Plate centre Dec (radians) + PltScl = 67.200000000000003 # Plate scale (arcsec/mm) + CNPix1 = 8400 # X Pixel offset (pixels) + CNPix2 = 8400 # Y Pixel offset (pixels) + XPixSz = 12.631500000000001 # X Pixel size (microns) + YPixSz = 12.631500000000001 # Y Pixel size (microns) + PPO1 = 0 # Orientation coefficients + PPO2 = 0 # Orientation coefficients + PPO3 = 105990.5119 # Orientation coefficients + PPO4 = 0 # Orientation coefficients + PPO5 = 0 # Orientation coefficients + PPO6 = 105990.5119 # Orientation coefficients + AMDX1 = 67.152600000000007 # Plate solution X coefficients + AMDX2 = 0.0051200000000000004 # Plate solution X coefficients + AMDX3 = -288.40899999999999 # Plate solution X coefficients + AMDX4 = -8.8400000000000001e-06 # Plate solution X coefficients + AMDX5 = -2.9300000000000001e-05 # Plate solution X coefficients + AMDX6 = 3.9099999999999998e-06 # Plate solution X coefficients + AMDX7 = -4.16e-06 # Plate solution X coefficients + AMDX8 = -9.7500000000000005e-10 # Plate solution X coefficients + AMDX9 = 3.2600000000000001e-10 # Plate solution X coefficients + AMDX10 = 7.78e-10 # Plate solution X coefficients + AMDX11 = 2.0700000000000001e-10 # Plate solution X coefficients + AMDX12 = 5.5500000000000001e-09 # Plate solution X coefficients + AMDX13 = 1.4899999999999999e-12 # Plate solution X coefficients + AMDX14 = 0 # Plate solution X coefficients + AMDX15 = 0 # Plate solution X coefficients + AMDX16 = 0 # Plate solution X coefficients + AMDX17 = 0 # Plate solution X coefficients + AMDX18 = 0 # Plate solution X coefficients + AMDX19 = 0 # Plate solution X coefficients + AMDY1 = 67.154200000000003 # Plate solution Y coefficients + AMDY2 = -0.0038300000000000001 # Plate solution Y coefficients + AMDY3 = 191.56200000000001 # Plate solution Y coefficients + AMDY4 = -2.12e-05 # Plate solution Y coefficients + AMDY5 = -2.9200000000000002e-05 # Plate solution Y coefficients + AMDY6 = -9.4399999999999994e-06 # Plate solution Y coefficients + AMDY7 = -4.1400000000000002e-06 # Plate solution Y coefficients + AMDY8 = 6.6699999999999997e-10 # Plate solution Y coefficients + AMDY9 = 6.9399999999999998e-10 # Plate solution Y coefficients + AMDY10 = -2.0800000000000001e-10 # Plate solution Y coefficients + AMDY11 = -1.2e-09 # Plate solution Y coefficients + AMDY12 = 5.5599999999999998e-09 # Plate solution Y coefficients + AMDY13 = 1.5000000000000001e-12 # Plate solution Y coefficients + AMDY14 = 0 # Plate solution Y coefficients + AMDY15 = 0 # Plate solution Y coefficients + AMDY16 = 0 # Plate solution Y coefficients + AMDY17 = 0 # Plate solution Y coefficients + AMDY18 = 0 # Plate solution Y coefficients + AMDY19 = 0 # Plate solution Y coefficients + End DssMap +-- transformations +2.8162353425781337 -1.0425972229107545 +2.8243442961243943 -1.050842528541726 +2.8202395599888272 -1.0487815202301161 +2.7922669873347568 -1.0341307895452183 +2.8082129118871975 -1.0384322808795139 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +2.8162353425781337 -1.0425972229107545 +2.8243442961243943 -1.050842528541726 +2.8202395599888272 -1.0487815202301161 +2.7922669873347568 -1.0341307895452183 +2.8082129118871975 -1.0384322808795139 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +== winmap_then_inverted_dssmap +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin WinMap # Map one window on to another + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = -0.5 # Shift for axis 1 + Scl1 = 2 # Scale factor for axis 1 + Sft2 = -0.5 # Shift for axis 2 + Scl2 = 2 # Scale factor for axis 2 + End WinMap + MapB = # Second component Mapping + Begin DssMap # DSS plate fit mapping + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PltRA = 2.8272374655684112 # Plate centre RA (radians) + PltDec = -1.0518122540502668 # Plate centre Dec (radians) + PltScl = 67.200000000000003 # Plate scale (arcsec/mm) + CNPix1 = 4200 # X Pixel offset (pixels) + CNPix2 = 4200 # Y Pixel offset (pixels) + XPixSz = 25.263000000000002 # X Pixel size (microns) + YPixSz = 25.263000000000002 # Y Pixel size (microns) + PPO1 = 0 # Orientation coefficients + PPO2 = 0 # Orientation coefficients + PPO3 = 105990.5119 # Orientation coefficients + PPO4 = 0 # Orientation coefficients + PPO5 = 0 # Orientation coefficients + PPO6 = 105990.5119 # Orientation coefficients + AMDX1 = 67.152600000000007 # Plate solution X coefficients + AMDX2 = 0.0051200000000000004 # Plate solution X coefficients + AMDX3 = -288.40899999999999 # Plate solution X coefficients + AMDX4 = -8.8400000000000001e-06 # Plate solution X coefficients + AMDX5 = -2.9300000000000001e-05 # Plate solution X coefficients + AMDX6 = 3.9099999999999998e-06 # Plate solution X coefficients + AMDX7 = -4.16e-06 # Plate solution X coefficients + AMDX8 = -9.7500000000000005e-10 # Plate solution X coefficients + AMDX9 = 3.2600000000000001e-10 # Plate solution X coefficients + AMDX10 = 7.78e-10 # Plate solution X coefficients + AMDX11 = 2.0700000000000001e-10 # Plate solution X coefficients + AMDX12 = 5.5500000000000001e-09 # Plate solution X coefficients + AMDX13 = 1.4899999999999999e-12 # Plate solution X coefficients + AMDX14 = 0 # Plate solution X coefficients + AMDX15 = 0 # Plate solution X coefficients + AMDX16 = 0 # Plate solution X coefficients + AMDX17 = 0 # Plate solution X coefficients + AMDX18 = 0 # Plate solution X coefficients + AMDX19 = 0 # Plate solution X coefficients + AMDY1 = 67.154200000000003 # Plate solution Y coefficients + AMDY2 = -0.0038300000000000001 # Plate solution Y coefficients + AMDY3 = 191.56200000000001 # Plate solution Y coefficients + AMDY4 = -2.12e-05 # Plate solution Y coefficients + AMDY5 = -2.9200000000000002e-05 # Plate solution Y coefficients + AMDY6 = -9.4399999999999994e-06 # Plate solution Y coefficients + AMDY7 = -4.1400000000000002e-06 # Plate solution Y coefficients + AMDY8 = 6.6699999999999997e-10 # Plate solution Y coefficients + AMDY9 = 6.9399999999999998e-10 # Plate solution Y coefficients + AMDY10 = -2.0800000000000001e-10 # Plate solution Y coefficients + AMDY11 = -1.2e-09 # Plate solution Y coefficients + AMDY12 = 5.5599999999999998e-09 # Plate solution Y coefficients + AMDY13 = 1.5000000000000001e-12 # Plate solution Y coefficients + AMDY14 = 0 # Plate solution Y coefficients + AMDY15 = 0 # Plate solution Y coefficients + AMDY16 = 0 # Plate solution Y coefficients + AMDY17 = 0 # Plate solution Y coefficients + AMDY18 = 0 # Plate solution Y coefficients + AMDY19 = 0 # Plate solution Y coefficients + End DssMap + End CmpMap +-- transformations +1.654175222131181 -0.26716185733190989 +1.662170084173449 -0.27542023351650924 +1.658080117680149 -0.27335563237713378 +1.630997456964467 -0.25850483481004127 +1.6463769298587876 -0.26295853119102275 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +1.654175222131181 -0.26716185733190989 +1.662170084173449 -0.27542023351650924 +1.658080117680149 -0.27335563237713378 +1.630997456964467 -0.25850483481004127 +1.6463769298587876 -0.26295853119102275 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +== zoommap_then_dssmap +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin DssMap # DSS plate fit mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PltRA = 2.8272374655684112 # Plate centre RA (radians) + PltDec = -1.0518122540502668 # Plate centre Dec (radians) + PltScl = 67.200000000000003 # Plate scale (arcsec/mm) + CNPix1 = 4200 # X Pixel offset (pixels) + CNPix2 = 4200 # Y Pixel offset (pixels) + XPixSz = 25.263000000000002 # X Pixel size (microns) + YPixSz = 25.263000000000002 # Y Pixel size (microns) + PPO1 = 0 # Orientation coefficients + PPO2 = 0 # Orientation coefficients + PPO3 = 105990.5119 # Orientation coefficients + PPO4 = 0 # Orientation coefficients + PPO5 = 0 # Orientation coefficients + PPO6 = 105990.5119 # Orientation coefficients + AMDX1 = 67.152600000000007 # Plate solution X coefficients + AMDX2 = 0.0051200000000000004 # Plate solution X coefficients + AMDX3 = -288.40899999999999 # Plate solution X coefficients + AMDX4 = -8.8400000000000001e-06 # Plate solution X coefficients + AMDX5 = -2.9300000000000001e-05 # Plate solution X coefficients + AMDX6 = 3.9099999999999998e-06 # Plate solution X coefficients + AMDX7 = -4.16e-06 # Plate solution X coefficients + AMDX8 = -9.7500000000000005e-10 # Plate solution X coefficients + AMDX9 = 3.2600000000000001e-10 # Plate solution X coefficients + AMDX10 = 7.78e-10 # Plate solution X coefficients + AMDX11 = 2.0700000000000001e-10 # Plate solution X coefficients + AMDX12 = 5.5500000000000001e-09 # Plate solution X coefficients + AMDX13 = 1.4899999999999999e-12 # Plate solution X coefficients + AMDX14 = 0 # Plate solution X coefficients + AMDX15 = 0 # Plate solution X coefficients + AMDX16 = 0 # Plate solution X coefficients + AMDX17 = 0 # Plate solution X coefficients + AMDX18 = 0 # Plate solution X coefficients + AMDX19 = 0 # Plate solution X coefficients + AMDY1 = 67.154200000000003 # Plate solution Y coefficients + AMDY2 = -0.0038300000000000001 # Plate solution Y coefficients + AMDY3 = 191.56200000000001 # Plate solution Y coefficients + AMDY4 = -2.12e-05 # Plate solution Y coefficients + AMDY5 = -2.9200000000000002e-05 # Plate solution Y coefficients + AMDY6 = -9.4399999999999994e-06 # Plate solution Y coefficients + AMDY7 = -4.1400000000000002e-06 # Plate solution Y coefficients + AMDY8 = 6.6699999999999997e-10 # Plate solution Y coefficients + AMDY9 = 6.9399999999999998e-10 # Plate solution Y coefficients + AMDY10 = -2.0800000000000001e-10 # Plate solution Y coefficients + AMDY11 = -1.2e-09 # Plate solution Y coefficients + AMDY12 = 5.5599999999999998e-09 # Plate solution Y coefficients + AMDY13 = 1.5000000000000001e-12 # Plate solution Y coefficients + AMDY14 = 0 # Plate solution Y coefficients + AMDY15 = 0 # Plate solution Y coefficients + AMDY16 = 0 # Plate solution Y coefficients + AMDY17 = 0 # Plate solution Y coefficients + AMDY18 = 0 # Plate solution Y coefficients + AMDY19 = 0 # Plate solution Y coefficients + End DssMap + End CmpMap +-- transformations +2.7932236745708341 -1.0177046725594903 +2.8243236575347148 -1.0508322209249645 +2.8080814490748809 -1.0425455036877651 +2.7064674730485061 -0.98176556767793721 +2.7637196268159423 -1.0006244663824764 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +2.7932236745708341 -1.0177046725594903 +2.8243236575347148 -1.0508322209249645 +2.8080814490748809 -1.0425455036877651 +2.7064674730485061 -0.98176556767793721 +2.7637196268159423 -1.0006244663824764 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +== parallel +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 4 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin WinMap # Map one window on to another + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = -0.5 # Shift for axis 1 + Scl1 = 2 # Scale factor for axis 1 + Sft2 = -0.5 # Shift for axis 2 + Scl2 = 2 # Scale factor for axis 2 + End WinMap + MapB = # Second component Mapping + Begin DssMap # DSS plate fit mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PltRA = 2.8272374655684112 # Plate centre RA (radians) + PltDec = -1.0518122540502668 # Plate centre Dec (radians) + PltScl = 67.200000000000003 # Plate scale (arcsec/mm) + CNPix1 = 4200 # X Pixel offset (pixels) + CNPix2 = 4200 # Y Pixel offset (pixels) + XPixSz = 25.263000000000002 # X Pixel size (microns) + YPixSz = 25.263000000000002 # Y Pixel size (microns) + PPO1 = 0 # Orientation coefficients + PPO2 = 0 # Orientation coefficients + PPO3 = 105990.5119 # Orientation coefficients + PPO4 = 0 # Orientation coefficients + PPO5 = 0 # Orientation coefficients + PPO6 = 105990.5119 # Orientation coefficients + AMDX1 = 67.152600000000007 # Plate solution X coefficients + AMDX2 = 0.0051200000000000004 # Plate solution X coefficients + AMDX3 = -288.40899999999999 # Plate solution X coefficients + AMDX4 = -8.8400000000000001e-06 # Plate solution X coefficients + AMDX5 = -2.9300000000000001e-05 # Plate solution X coefficients + AMDX6 = 3.9099999999999998e-06 # Plate solution X coefficients + AMDX7 = -4.16e-06 # Plate solution X coefficients + AMDX8 = -9.7500000000000005e-10 # Plate solution X coefficients + AMDX9 = 3.2600000000000001e-10 # Plate solution X coefficients + AMDX10 = 7.78e-10 # Plate solution X coefficients + AMDX11 = 2.0700000000000001e-10 # Plate solution X coefficients + AMDX12 = 5.5500000000000001e-09 # Plate solution X coefficients + AMDX13 = 1.4899999999999999e-12 # Plate solution X coefficients + AMDX14 = 0 # Plate solution X coefficients + AMDX15 = 0 # Plate solution X coefficients + AMDX16 = 0 # Plate solution X coefficients + AMDX17 = 0 # Plate solution X coefficients + AMDX18 = 0 # Plate solution X coefficients + AMDX19 = 0 # Plate solution X coefficients + AMDY1 = 67.154200000000003 # Plate solution Y coefficients + AMDY2 = -0.0038300000000000001 # Plate solution Y coefficients + AMDY3 = 191.56200000000001 # Plate solution Y coefficients + AMDY4 = -2.12e-05 # Plate solution Y coefficients + AMDY5 = -2.9200000000000002e-05 # Plate solution Y coefficients + AMDY6 = -9.4399999999999994e-06 # Plate solution Y coefficients + AMDY7 = -4.1400000000000002e-06 # Plate solution Y coefficients + AMDY8 = 6.6699999999999997e-10 # Plate solution Y coefficients + AMDY9 = 6.9399999999999998e-10 # Plate solution Y coefficients + AMDY10 = -2.0800000000000001e-10 # Plate solution Y coefficients + AMDY11 = -1.2e-09 # Plate solution Y coefficients + AMDY12 = 5.5599999999999998e-09 # Plate solution Y coefficients + AMDY13 = 1.5000000000000001e-12 # Plate solution Y coefficients + AMDY14 = 0 # Plate solution Y coefficients + AMDY15 = 0 # Plate solution Y coefficients + AMDY16 = 0 # Plate solution Y coefficients + AMDY17 = 0 # Plate solution Y coefficients + AMDY18 = 0 # Plate solution Y coefficients + AMDY19 = 0 # Plate solution Y coefficients + End DssMap + End CmpMap +== invert_attr_both_inverted +before 1 +class DssMap +after 0 +== inverted_dssmap_then_winmap_both_inverted +class DssMap + Begin DssMap # DSS plate fit mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + PltRA = 2.8272374655684112 # Plate centre RA (radians) + PltDec = -1.0518122540502668 # Plate centre Dec (radians) + PltScl = 67.200000000000003 # Plate scale (arcsec/mm) + CNPix1 = 2100 # X Pixel offset (pixels) + CNPix2 = 2100 # Y Pixel offset (pixels) + XPixSz = 50.526000000000003 # X Pixel size (microns) + YPixSz = 50.526000000000003 # Y Pixel size (microns) + PPO1 = 0 # Orientation coefficients + PPO2 = 0 # Orientation coefficients + PPO3 = 105990.5119 # Orientation coefficients + PPO4 = 0 # Orientation coefficients + PPO5 = 0 # Orientation coefficients + PPO6 = 105990.5119 # Orientation coefficients + AMDX1 = 67.152600000000007 # Plate solution X coefficients + AMDX2 = 0.0051200000000000004 # Plate solution X coefficients + AMDX3 = -288.40899999999999 # Plate solution X coefficients + AMDX4 = -8.8400000000000001e-06 # Plate solution X coefficients + AMDX5 = -2.9300000000000001e-05 # Plate solution X coefficients + AMDX6 = 3.9099999999999998e-06 # Plate solution X coefficients + AMDX7 = -4.16e-06 # Plate solution X coefficients + AMDX8 = -9.7500000000000005e-10 # Plate solution X coefficients + AMDX9 = 3.2600000000000001e-10 # Plate solution X coefficients + AMDX10 = 7.78e-10 # Plate solution X coefficients + AMDX11 = 2.0700000000000001e-10 # Plate solution X coefficients + AMDX12 = 5.5500000000000001e-09 # Plate solution X coefficients + AMDX13 = 1.4899999999999999e-12 # Plate solution X coefficients + AMDX14 = 0 # Plate solution X coefficients + AMDX15 = 0 # Plate solution X coefficients + AMDX16 = 0 # Plate solution X coefficients + AMDX17 = 0 # Plate solution X coefficients + AMDX18 = 0 # Plate solution X coefficients + AMDX19 = 0 # Plate solution X coefficients + AMDY1 = 67.154200000000003 # Plate solution Y coefficients + AMDY2 = -0.0038300000000000001 # Plate solution Y coefficients + AMDY3 = 191.56200000000001 # Plate solution Y coefficients + AMDY4 = -2.12e-05 # Plate solution Y coefficients + AMDY5 = -2.9200000000000002e-05 # Plate solution Y coefficients + AMDY6 = -9.4399999999999994e-06 # Plate solution Y coefficients + AMDY7 = -4.1400000000000002e-06 # Plate solution Y coefficients + AMDY8 = 6.6699999999999997e-10 # Plate solution Y coefficients + AMDY9 = 6.9399999999999998e-10 # Plate solution Y coefficients + AMDY10 = -2.0800000000000001e-10 # Plate solution Y coefficients + AMDY11 = -1.2e-09 # Plate solution Y coefficients + AMDY12 = 5.5599999999999998e-09 # Plate solution Y coefficients + AMDY13 = 1.5000000000000001e-12 # Plate solution Y coefficients + AMDY14 = 0 # Plate solution Y coefficients + AMDY15 = 0 # Plate solution Y coefficients + AMDY16 = 0 # Plate solution Y coefficients + AMDY17 = 0 # Plate solution Y coefficients + AMDY18 = 0 # Plate solution Y coefficients + AMDY19 = 0 # Plate solution Y coefficients + End DssMap +-- transformations +2.793231260829788 -1.0177088969714392 +2.8243319128812465 -1.0508363439936359 +2.8080894695840812 -1.042549683267664 +2.7064740214574168 -0.98177004370681353 +2.7637267965791148 -1.0006287797893743 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +2.793231260829788 -1.0177088969714392 +2.8243319128812465 -1.0508363439936359 +2.8080894695840812 -1.042549683267664 +2.7064740214574168 -0.98177004370681353 +2.7637267965791148 -1.0006287797893743 +-1.7976931348623157e+308 -1.7976931348623157e+308 +-1.7976931348623157e+308 -1.7976931348623157e+308 +== invert_attr_no_merge +before 1 +class CmpMap +after 1 diff --git a/src/test/resources/probes/equal_probe.c b/src/test/resources/probes/equal_probe.c new file mode 100644 index 0000000..74d04d5 --- /dev/null +++ b/src/test/resources/probes/equal_probe.c @@ -0,0 +1,631 @@ +/* equal_probe -- astEqual in the pinned C library for the comparisons of the + * Rust tests tests/test_equal.rs, test_matrixmap.rs, test_permmap.rs, + * test_cmpmap.rs, test_wcsmap.rs, test_polymap.rs, test_specmap.rs, + * test_specframe.rs, test_timemap.rs, test_frame_equality.rs, + * test_timeframe.rs and test_fluxframe.rs, and for comparisons where C's + * Equal and a comparison of native text disagree: an inverted ZoomMap + * against one of the reciprocal factor, Mappings differing only in ID or + * Ident, MathMaps differing only in their last opcode, CmpMaps that share a + * component (Equal leaves the component with the first CmpMap's Invert + * value), CmpMaps with Ident set (compared through copies of their + * components), FrameSets whose Frames differ only in Title, ZoomMaps whose + * Zoom attribute has been cleared, an inverted FrameSet, and KeyMaps. + * + * Each case starts with a line "== ", followed by "equal 0" or + * "equal 1" for each comparison and any further values the case prints; + * error reports, which the error module writes to standard error, are merged + * in order (stdout unbuffered). Built against the C library at 3d3f255f with + * its static libraries: + * cc -I -o equal_probe equal_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 ./equal_probe > equal_probe.out 2>&1. */ +#include +#include +#include +#include "ast.h" + +static void head( const char *name ) { + printf( "== %s\n", name ); +} + +/* Prints the result of one comparison, or the status of a failed one. */ +static void eq( void *a, void *b ) { + int r = astEqual( a, b ); + if( !astOK ) { + printf( "status %d\n", astStatus ); + astClearStatus; + return; + } + printf( "equal %d\n", r ? 1 : 0 ); +} + +static void *inv( void *m ) { + astInvert( m ); + return m; +} + +static AstZoomMap *zoom( int n, double f ) { + return astZoomMap( n, f, " " ); +} + +static AstShiftMap *shift2( double a, double b ) { + double s[] = { a, b }; + return astShiftMap( 2, s, " " ); +} + +/* A WinMap of shifts and scales, as Rust's WinMap::new makes it. */ +static AstWinMap *winss( int n, const double *shift, const double *scale ) { + double ina[ 3 ], inb[ 3 ], outa[ 3 ], outb[ 3 ]; + for( int i = 0; i < n; i++ ) { + ina[ i ] = 0.0; + inb[ i ] = 1.0; + outa[ i ] = shift[ i ]; + outb[ i ] = shift[ i ] + scale[ i ]; + } + return astWinMap( n, ina, inb, outa, outb, " " ); +} + +static AstWinMap *wincorners( double ina, double inb, double outa, double outb ) { + return astWinMap( 1, &ina, &inb, &outa, &outb, " " ); +} + +static AstPermMap *perm1( int in, int out, int ncon, const double *con ) { + int inperm[] = { in }; + int outperm[] = { out }; + return astPermMap( 1, inperm, 1, outperm, ncon ? con : NULL, " " ); +} + +static AstMathMap *mathmap( const char *f, const char *i ) { + const char *fwd[] = { f }; + const char *invf[] = { i }; + return astMathMap( 1, 1, 1, fwd, 1, invf, " " ); +} + +static AstWcsMap *sin_pv( int n, const int *m, const double *v ) { + AstWcsMap *w = astWcsMap( 2, AST__SIN, 1, 2, " " ); + char attr[ 20 ]; + for( int i = 0; i < n; i++ ) { + sprintf( attr, "PV2_%d", m[ i ] ); + astSetD( w, attr, v[ i ] ); + } + return w; +} + +static AstObject *roundtrip( AstObject *o ) { + char *s = astToString( o ); + AstObject *back = astFromString( s ); + s = astFree( s ); + return back; +} + +int main( void ) { + int status = 0; + setvbuf( stdout, NULL, _IONBF, 0 ); + astWatch( &status ); + astBegin; + + /* tests/test_equal.rs */ + head( "float_tolerance_within" ); + eq( zoom( 2, 1.0 ), zoom( 2, 1.0 + 1.0e-14 ) ); + head( "float_tolerance_outside" ); + eq( zoom( 2, 1.0 ), zoom( 2, 1.1 ) ); + { + double bad[] = { AST__BAD }; + double c42[] = { 42.0 }; + double bad0[] = { AST__BAD, 0.0 }; + double c042[] = { 0.0, 42.0 }; + head( "bad_value_comparison" ); + eq( perm1( -1, -1, 1, bad ), perm1( -1, -1, 1, bad ) ); + head( "bad_vs_non_bad_same_index_is_not_equal" ); + eq( perm1( -1, -1, 1, bad ), perm1( -1, -1, 1, c42 ) ); + head( "bad_vs_non_bad_different_index_is_not_equal" ); + eq( perm1( -1, -1, 2, bad0 ), perm1( -2, -2, 2, c042 ) ); + } + { + AstUnitMap *a = astUnitMap( 3, " " ); + head( "unitmap_identity" ); + eq( a, a ); + head( "unitmap_same_ncoord" ); + eq( a, astUnitMap( 3, " " ) ); + head( "unitmap_different_ncoord" ); + eq( a, astUnitMap( 2, " " ) ); + } + { + AstZoomMap *a = zoom( 2, 3.5 ); + head( "zoommap_identity" ); + eq( a, a ); + head( "zoommap_same_values" ); + eq( a, zoom( 2, 3.5 ) ); + head( "zoommap_different_factor" ); + eq( a, zoom( 2, 4.0 ) ); + head( "zoommap_different_ncoord" ); + eq( a, zoom( 3, 3.5 ) ); + head( "zoommap_invert_aware" ); + eq( inv( zoom( 2, 2.0 ) ), zoom( 2, 0.5 ) ); + head( "zoommap_invert_aware_mismatch" ); + eq( inv( zoom( 2, 3.0 ) ), zoom( 2, 0.5 ) ); + } + { + double s3[] = { 1.0, 2.0, 3.0 }; + AstShiftMap *a = astShiftMap( 3, s3, " " ); + head( "shiftmap_identity" ); + eq( a, a ); + head( "shiftmap_same_values" ); + eq( shift2( 1.0, 2.0 ), shift2( 1.0, 2.0 ) ); + head( "shiftmap_different_shifts" ); + eq( shift2( 1.0, 2.0 ), shift2( 1.0, 3.0 ) ); + head( "shiftmap_different_length" ); + eq( shift2( 1.0, 2.0 ), a ); + head( "shiftmap_invert_aware" ); + eq( inv( shift2( 1.0, 2.0 ) ), shift2( -1.0, -2.0 ) ); + head( "shiftmap_invert_aware_mismatch" ); + eq( inv( shift2( 1.0, 2.0 ) ), shift2( 1.0, 2.0 ) ); + } + { + double m23[] = { 2.0, 0.0, 0.0, 3.0 }; + double m24[] = { 2.0, 0.0, 0.0, 4.0 }; + head( "matrixmap_same" ); + eq( astMatrixMap( 2, 2, 0, m23, " " ), astMatrixMap( 2, 2, 0, m23, " " ) ); + head( "matrixmap_different_element" ); + eq( astMatrixMap( 2, 2, 0, m23, " " ), astMatrixMap( 2, 2, 0, m24, " " ) ); + head( "matrixmap_inverted_not_equal" ); + eq( inv( astMatrixMap( 2, 2, 0, m23, " " ) ), astMatrixMap( 2, 2, 0, m23, " " ) ); + } + { + int p12[] = { 1, 2 }; + int p21[] = { 2, 1 }; + head( "permmap_same" ); + eq( astPermMap( 2, p12, 2, p21, NULL, " " ), astPermMap( 2, p12, 2, p21, NULL, " " ) ); + head( "permmap_different_perm" ); + eq( astPermMap( 2, p12, 2, p21, NULL, " " ), astPermMap( 2, p12, 2, p12, NULL, " " ) ); + head( "permmap_equal_cross_inversion" ); + eq( astPermMap( 2, p21, 2, p21, NULL, " " ), inv( astPermMap( 2, p21, 2, p21, NULL, " " ) ) ); + int p231[] = { 2, 3, 1 }; + int p312[] = { 3, 1, 2 }; + AstPermMap *pm3 = astPermMap( 3, p231, 3, p312, NULL, " " ); + eq( inv( astCopy( pm3 ) ), astPermMap( 3, p312, 3, p231, NULL, " " ) ); + } + { + double a12[] = { 1.0, 2.0 }; + double b34[] = { 3.0, 4.0 }; + double b35[] = { 3.0, 5.0 }; + head( "winmap_same" ); + eq( winss( 2, a12, b34 ), winss( 2, a12, b34 ) ); + head( "winmap_different_scale" ); + eq( winss( 2, a12, b34 ), winss( 2, a12, b35 ) ); + head( "winmap_inverted_not_equal" ); + eq( inv( winss( 2, a12, b34 ) ), winss( 2, a12, b34 ) ); + double s2[] = { 2.0 }; + double c3[] = { 3.0 }; + double sm[] = { -2.0 / 3.0 }; + double c13[] = { 1.0 / 3.0 }; + head( "winmap_equal_cross_inversion" ); + eq( inv( winss( 1, s2, c3 ) ), winss( 1, sm, c13 ) ); + } + head( "cmpmap_series_same" ); + eq( astCmpMap( zoom( 2, 3.0 ), shift2( 1.0, 2.0 ), 1, " " ), + astCmpMap( zoom( 2, 3.0 ), shift2( 1.0, 2.0 ), 1, " " ) ); + head( "cmpmap_different_component" ); + eq( astCmpMap( zoom( 2, 3.0 ), shift2( 1.0, 2.0 ), 1, " " ), + astCmpMap( zoom( 2, 4.0 ), shift2( 1.0, 2.0 ), 1, " " ) ); + head( "cmpmap_different_kind" ); + eq( astCmpMap( astUnitMap( 2, " " ), astUnitMap( 2, " " ), 1, " " ), + astCmpMap( astUnitMap( 2, " " ), astUnitMap( 2, " " ), 0, " " ) ); + { + double c1[] = { 2.0, 1.0, 1.0, 0.0, 3.0, 2.0, 0.0, 1.0 }; + double ca[] = { 2.0, 1.0, 1.0 }; + double cb[] = { 3.0, 1.0, 1.0 }; + head( "polymap_same" ); + eq( astPolyMap( 2, 2, 2, c1, 0, NULL, " " ), astPolyMap( 2, 2, 2, c1, 0, NULL, " " ) ); + head( "polymap_different_coeff" ); + eq( astPolyMap( 1, 1, 1, ca, 0, NULL, " " ), astPolyMap( 1, 1, 1, cb, 0, NULL, " " ) ); + } + { + double lut[] = { 0.0, 1.0, 4.0, 9.0 }; + double lut16[] = { 0.0, 1.0, 4.0, 16.0 }; + head( "lutmap_same" ); + eq( astLutMap( 4, lut, 0.0, 1.0, " " ), astLutMap( 4, lut, 0.0, 1.0, " " ) ); + head( "lutmap_different_values" ); + eq( astLutMap( 4, lut, 0.0, 1.0, " " ), astLutMap( 4, lut16, 0.0, 1.0, " " ) ); + head( "lutmap_different_start" ); + eq( astLutMap( 2, lut, 0.0, 1.0, " " ), astLutMap( 2, lut, 1.0, 1.0, " " ) ); + } + head( "wcsmap_same" ); + eq( astWcsMap( 2, AST__TAN, 1, 2, " " ), astWcsMap( 2, AST__TAN, 1, 2, " " ) ); + head( "wcsmap_different_proj" ); + eq( astWcsMap( 2, AST__TAN, 1, 2, " " ), astWcsMap( 2, AST__SIN, 1, 2, " " ) ); + head( "wcsmap_different_axes" ); + eq( astWcsMap( 3, AST__TAN, 1, 2, " " ), astWcsMap( 3, AST__TAN, 1, 3, " " ) ); + { + double prec1[] = { 50000.0, 51000.0 }; + double prec2[] = { 50000.0, 52000.0 }; + AstSlaMap *a = astSlaMap( 0, " " ); + AstSlaMap *b = astSlaMap( 0, " " ); + astSlaAdd( a, "EQGAL", 0, NULL ); + astSlaAdd( b, "EQGAL", 0, NULL ); + head( "slamap_same" ); + eq( a, b ); + a = astSlaMap( 0, " " ); + b = astSlaMap( 0, " " ); + astSlaAdd( a, "EQGAL", 0, NULL ); + astSlaAdd( b, "GALEQ", 0, NULL ); + head( "slamap_different_type" ); + eq( a, b ); + a = astSlaMap( 0, " " ); + b = astSlaMap( 0, " " ); + astSlaAdd( a, "PREC", 2, prec1 ); + astSlaAdd( b, "PREC", 2, prec2 ); + head( "slamap_different_args" ); + eq( a, b ); + } + head( "sphmap_same" ); + eq( astSphMap( " " ), astSphMap( " " ) ); + head( "sphmap_different_polar_long" ); + eq( astSphMap( "PolarLong=1.5" ), astSphMap( " " ) ); + head( "sphmap_different_unit_radius" ); + eq( astSphMap( "UnitRadius=1" ), astSphMap( " " ) ); + head( "sphmap_inverted" ); + eq( inv( astSphMap( " " ) ), astSphMap( " " ) ); + { + AstShiftMap *a = shift2( 1.0, 2.0 ); + AstZoomMap *b = zoom( 2, 3.0 ); + AstShiftMap *c = shift2( 4.0, 5.0 ); + AstCmpMap *abc1 = astCmpMap( astCopy( a ), astCmpMap( astCopy( b ), astCopy( c ), 1, " " ), 1, " " ); + AstCmpMap *abc2 = astCmpMap( astCmpMap( astCopy( a ), astCopy( b ), 1, " " ), astCopy( c ), 1, " " ); + head( "cmpmap_equal_different_tree_structure" ); + eq( abc1, abc2 ); + } + head( "cross_type_zoom_vs_shift" ); + eq( zoom( 2, 1.0 ), shift2( 0.0, 0.0 ) ); + head( "cross_type_unit_vs_zoom" ); + eq( astUnitMap( 2, " " ), zoom( 2, 1.0 ) ); + { + double z[] = { 0.0 }; + double o[] = { 1.0 }; + head( "cross_type_winmap_vs_shiftmap" ); + eq( winss( 1, z, o ), astShiftMap( 1, z, " " ) ); + } + head( "basicframe_same" ); + eq( astFrame( 2, "Title=test,Domain=PIXEL" ), astFrame( 2, "Title=test,Domain=PIXEL" ) ); + head( "basicframe_different_naxes" ); + eq( astFrame( 2, " " ), astFrame( 3, " " ) ); + head( "basicframe_different_title_is_equal" ); + eq( astFrame( 2, "Title=A" ), astFrame( 2, "Title=B" ) ); + head( "basicframe_different_domain" ); + eq( astFrame( 2, "Domain=X" ), astFrame( 2, "Domain=Y" ) ); + head( "basicframe_different_epoch_is_equal" ); + eq( astFrame( 2, "Epoch=MJD 50000" ), astFrame( 2, "Epoch=MJD 51000" ) ); + head( "basicframe_epoch_set_vs_unset_is_equal" ); + eq( astFrame( 2, "Epoch=MJD 50000" ), astFrame( 2, " " ) ); + head( "basicframe_different_labels_is_equal" ); + eq( astFrame( 2, "Label(1)=X" ), astFrame( 2, "Label(1)=Y" ) ); + head( "cmpframe_same" ); + eq( astCmpFrame( astFrame( 1, " " ), astFrame( 1, " " ), " " ), + astCmpFrame( astFrame( 1, " " ), astFrame( 1, " " ), " " ) ); + head( "cmpframe_different_child" ); + eq( astCmpFrame( astFrame( 1, "Domain=A" ), astFrame( 1, " " ), " " ), + astCmpFrame( astFrame( 1, "Domain=B" ), astFrame( 1, " " ), " " ) ); + head( "skyframe_same" ); + eq( astSkyFrame( "System=FK5" ), astSkyFrame( "System=FK5" ) ); + head( "skyframe_different_system" ); + eq( astSkyFrame( "System=FK5" ), astSkyFrame( "System=Galactic" ) ); + head( "skyframe_different_equinox" ); + eq( astSkyFrame( "System=FK5,Equinox=MJD 50000" ), astSkyFrame( "System=FK5,Equinox=MJD 51000" ) ); + head( "skyframe_equinox_set_vs_unset_default_is_equal" ); + eq( astSkyFrame( "System=FK5,Equinox=MJD 51544.5" ), astSkyFrame( "System=FK5" ) ); + head( "skyframe_different_epoch" ); + eq( astSkyFrame( "System=FK5,Epoch=MJD 50000" ), astSkyFrame( "System=FK5,Epoch=MJD 51000" ) ); + head( "skyframe_sky_ref_is_origin_without_sky_ref_is_equal" ); + eq( astSkyFrame( "System=FK5,SkyRefIs=Origin" ), astSkyFrame( "System=FK5" ) ); + { + AstSkyFrame *a = astSkyFrame( "System=FK5,SkyRefIs=Origin" ); + astSetD( a, "SkyRef(1)", 1.0 ); + astSetD( a, "SkyRef(2)", 0.5 ); + head( "skyframe_offset_origin_with_sky_ref_is_not_equal" ); + eq( a, astSkyFrame( "System=FK5" ) ); + a = astSkyFrame( "System=FK5" ); + astSetD( a, "SkyRef(1)", 1.0 ); + astSetD( a, "SkyRef(2)", 0.5 ); + head( "skyframe_sky_ref_without_sky_ref_is_is_equal" ); + eq( a, astSkyFrame( "System=FK5" ) ); + } + head( "skyframe_different_neglon_is_equal" ); + eq( astSkyFrame( "System=FK5,NegLon=1" ), astSkyFrame( "System=FK5" ) ); + head( "skyframe_different_title_is_equal" ); + eq( astSkyFrame( "System=FK5,Title=A" ), astSkyFrame( "System=FK5,Title=B" ) ); + head( "cross_type_skyframe_vs_basicframe" ); + eq( astSkyFrame( "System=FK5" ), astFrame( 2, " " ) ); + head( "cross_type_basicframe_vs_skyframe" ); + eq( astFrame( 2, " " ), astSkyFrame( "System=FK5" ) ); + { + AstFrameSet *a = astFrameSet( astFrame( 2, " " ), " " ); + astAddFrame( a, AST__BASE, zoom( 2, 2.0 ), astFrame( 2, "Title=current" ) ); + AstFrameSet *b = astFrameSet( astFrame( 2, " " ), " " ); + astAddFrame( b, AST__BASE, zoom( 2, 2.0 ), astFrame( 2, "Title=current" ) ); + head( "frameset_same" ); + eq( a, b ); + a = astFrameSet( astFrame( 2, " " ), " " ); + astAddFrame( a, AST__BASE, zoom( 2, 2.0 ), astFrame( 2, " " ) ); + b = astFrameSet( astFrame( 2, " " ), " " ); + astAddFrame( b, AST__BASE, zoom( 2, 3.0 ), astFrame( 2, " " ) ); + head( "frameset_different_mapping" ); + eq( a, b ); + } + { + double s[] = { 1.5, -2.7, 0.001 }; + AstObject *z = (AstObject *) zoom( 2, 3.14159 ); + AstObject *sm = (AstObject *) astShiftMap( 3, s, " " ); + AstObject *sky = (AstObject *) astSkyFrame( "System=FK5,Epoch=MJD 52000,Equinox=MJD 51544.5," + "NegLon=1,Title=Test Sky" ); + head( "serialise_round_trip_zoommap" ); + eq( z, roundtrip( z ) ); + head( "serialise_round_trip_shiftmap" ); + eq( sm, roundtrip( sm ) ); + head( "serialise_round_trip_skyframe" ); + eq( sky, roundtrip( sky ) ); + } + { + double m[] = { 1.0, 2.0, 3.0, 4.0 }; + double minv[] = { -2.0, 1.0, 1.5, -0.5 }; + AstMatrixMap *mminv = inv( astMatrixMap( 2, 2, 0, m, " " ) ); + head( "matrixmap_equal_cross_inversion" ); + eq( mminv, astMatrixMap( 2, 2, 0, minv, " " ) ); + eq( astMatrixMap( 2, 2, 0, m, " " ), mminv ); + } + + /* tests/test_matrixmap.rs */ + { + double m[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 }; + double m7[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 7.0 }; + AstMatrixMap *a = inv( astMatrixMap( 3, 2, 0, m, " " ) ); + head( "an_inverted_non_square_matrixmap_equals_its_copy" ); + eq( a, astCopy( a ) ); + eq( a, inv( astMatrixMap( 3, 2, 0, m7, " " ) ) ); + } + + /* tests/test_permmap.rs */ + { + double c5[] = { 5.0 }; + double c7[] = { 7.0 }; + double c90[] = { 9.0, 0.0 }; + double c09[] = { 0.0, 9.0 }; + double c04[] = { 0.0, 4.0 }; + double c1[] = { 1.0 }; + double c2[] = { 2.0 }; + head( "perm_equal_same_constant_index_differing_values" ); + eq( perm1( -1, 1, 1, c5 ), perm1( -1, 1, 1, c7 ) ); + head( "perm_equal_same_constant_index_same_value" ); + eq( perm1( -1, 1, 1, c5 ), perm1( -1, 1, 1, c5 ) ); + head( "perm_equal_different_index_same_referenced_value" ); + eq( perm1( -1, 1, 2, c90 ), perm1( -2, 1, 2, c09 ) ); + head( "perm_equal_different_index_different_referenced_value" ); + eq( perm1( -1, 1, 2, c90 ), perm1( -2, 1, 2, c04 ) ); + head( "perm_equal_ignores_unreferenced_surplus_constants" ); + eq( perm1( 1, 1, 1, c1 ), perm1( 1, 1, 1, c2 ) ); + } + + /* tests/test_cmpmap.rs */ + { + double one[] = { 1.0 }; + head( "cmpmap_equality_compares_components_as_applied" ); + eq( astCmpMap( inv( astUnitMap( 1, " " ) ), zoom( 1, 2.0 ), 1, " " ), + astCmpMap( astUnitMap( 1, " " ), zoom( 1, 2.0 ), 1, " " ) ); + eq( astCmpMap( inv( zoom( 1, 2.0 ) ), astShiftMap( 1, one, " " ), 1, " " ), + astCmpMap( zoom( 1, 0.5 ), astShiftMap( 1, one, " " ), 1, " " ) ); + eq( astCmpMap( zoom( 1, 2.0 ), astShiftMap( 1, one, " " ), 1, " " ), + astCmpMap( zoom( 1, 0.5 ), astShiftMap( 1, one, " " ), 1, " " ) ); + } + + /* tests/test_wcsmap.rs */ + { + AstWcsMap *w1 = astWcsMap( 2, AST__ZPN, 1, 2, " " ); + AstWcsMap *w2 = astWcsMap( 2, AST__ZPN, 1, 2, " " ); + head( "wcsmap_equal_different_params" ); + eq( w1, w2 ); + astSetD( w1, "PV2_1", 0.5 ); + astSetD( w2, "PV2_1", 0.7 ); + eq( w1, w2 ); + w1 = astWcsMap( 2, AST__ZPN, 1, 2, " " ); + w2 = astWcsMap( 2, AST__ZPN, 1, 2, " " ); + astSetD( w1, "PV2_1", 0.5 ); + astSetD( w2, "PV2_1", 0.5 ); + head( "wcsmap_equal_same_params" ); + eq( w1, w2 ); + } + + /* tests/test_polymap.rs */ + { + double fwd[] = { 1.0, 1.0, 2.0 }; + double half[] = { 0.5, 1.0, 1.0 }; + double seven[] = { 0.7, 1.0, 1.0 }; + AstPolyMap *a = astPolyMap( 1, 1, 1, fwd, 1, half, " " ); + AstPolyMap *same = astPolyMap( 1, 1, 1, fwd, 1, half, " " ); + AstPolyMap *differ = astPolyMap( 1, 1, 1, fwd, 1, seven, " " ); + head( "polymap_equal_compares_the_inverse_coefficients" ); + eq( a, same ); + eq( same, a ); + eq( a, differ ); + eq( differ, a ); + AstMapping *s = astSimplify( astCmpMap( astPolyMap( 1, 1, 1, fwd, 1, half, " " ), inv( differ ), 1, " " ) ); + printf( "class %s\n", astGetC( s, "Class" ) ); + s = astSimplify( astCmpMap( astPolyMap( 1, 1, 1, fwd, 1, half, " " ), + inv( astPolyMap( 1, 1, 1, fwd, 1, half, " " ) ), 1, " " ) ); + printf( "class %s\n", astGetC( s, "Class" ) ); + + double wfwd[ 24 ]; + double winv[ 10 ]; + for( int io = 1; io <= 8; io++ ) { + wfwd[ 3*( io - 1 ) ] = io; + wfwd[ 3*( io - 1 ) + 1 ] = io; + wfwd[ 3*( io - 1 ) + 2 ] = 1.0; + } + winv[ 0 ] = 1.0; + winv[ 1 ] = 1.0; + for( int i = 0; i < 8; i++ ) winv[ 2 + i ] = 1.0; + AstPolyMap *wide = astPolyMap( 1, 8, 8, wfwd, 1, winv, " " ); + AstPolyMap *copy = astCopy( wide ); + head( "polymap_with_more_outputs_than_inputs_equals_its_copy" ); + eq( wide, copy ); + eq( copy, wide ); + } + + /* tests/test_specmap.rs */ + { + double a1[] = { 1.0, 0.5 }; + double a2[] = { 2.0, 0.5 }; + AstSpecMap *s1 = astSpecMap( 1, 0, " " ); + astSpecAdd( s1, "FRTOWV", 0, NULL ); + astSpecAdd( s1, "LKF2HL", 2, a1 ); + AstSpecMap *s2 = astSpecMap( 1, 0, " " ); + astSpecAdd( s2, "FRTOWV", 0, NULL ); + astSpecAdd( s2, "LKF2HL", 2, a1 ); + AstSpecMap *s3 = astSpecMap( 1, 0, " " ); + astSpecAdd( s3, "FRTOWV", 0, NULL ); + astSpecAdd( s3, "LKF2HL", 2, a2 ); + head( "specmap_equality" ); + eq( s1, s2 ); + eq( s1, s3 ); + } + + /* tests/test_specframe.rs */ + head( "test_equal_same" ); + eq( astSpecFrame( "System=FREQ" ), astSpecFrame( "System=FREQ" ) ); + head( "test_not_equal_different_system" ); + eq( astSpecFrame( "System=FREQ" ), astSpecFrame( "System=WAVE" ) ); + head( "test_not_equal_different_sor" ); + eq( astSpecFrame( "System=FREQ,StdOfRest=Heliocentric" ), astSpecFrame( "System=FREQ,StdOfRest=LSRK" ) ); + + /* tests/test_timemap.rs */ + { + double mj[] = { 0.0, 0.0 }; + double u32[] = { 0.0, 32.0 }; + double u33[] = { 0.0, 33.0 }; + AstTimeMap *t1 = astTimeMap( 0, " " ); + astTimeAdd( t1, "MJDTOJD", 2, mj ); + astTimeAdd( t1, "UTCTOTAI", 2, u32 ); + AstTimeMap *t2 = astTimeMap( 0, " " ); + astTimeAdd( t2, "MJDTOJD", 2, mj ); + astTimeAdd( t2, "UTCTOTAI", 2, u32 ); + AstTimeMap *t3 = astTimeMap( 0, " " ); + astTimeAdd( t3, "MJDTOJD", 2, mj ); + astTimeAdd( t3, "UTCTOTAI", 2, u33 ); + head( "timemap_equality" ); + eq( t1, t2 ); + eq( t1, t3 ); + } + + /* tests/test_frame_equality.rs */ + head( "basic_frames_differing_only_in_cosmetics_are_equal" ); + eq( astFrame( 2, "Title=First frame,Label(1)=X,Symbol(1)=x,Format(1)=3" ), + astFrame( 2, "Title=Second frame,Label(1)=Different label,Symbol(1)=q,Format(1)=7" ) ); + head( "basic_frames_differing_in_domain_are_not_equal" ); + eq( astFrame( 2, "Domain=PIXEL" ), astFrame( 2, "Domain=GRID" ) ); + head( "skyframes_differing_only_in_title_are_equal" ); + eq( astSkyFrame( "System=ICRS" ), astSkyFrame( "System=ICRS,Title=A different description" ) ); + head( "skyframe_explicit_default_domain_equals_unset_domain" ); + eq( astSkyFrame( "System=ICRS" ), astSkyFrame( "System=ICRS,Domain=SKY" ) ); + head( "skyframes_differing_in_system_are_not_equal" ); + eq( astSkyFrame( "System=ICRS" ), astSkyFrame( "System=Galactic" ) ); + + /* tests/test_timeframe.rs */ + head( "timeframe_test_equal" ); + eq( astTimeFrame( "System=MJD" ), astTimeFrame( "System=MJD" ) ); + eq( astTimeFrame( "System=MJD" ), astTimeFrame( "System=JD" ) ); + + /* tests/test_fluxframe.rs */ + head( "test_fluxframe_equal_same" ); + eq( astFluxFrame( AST__BAD, NULL, " " ), astFluxFrame( AST__BAD, NULL, " " ) ); + head( "test_fluxframe_equal_different_system" ); + eq( astFluxFrame( AST__BAD, NULL, " " ), astFluxFrame( AST__BAD, NULL, "System=FLXDNW" ) ); + head( "test_fluxframe_equal_different_specval_is_equal" ); + eq( astFluxFrame( AST__BAD, NULL, "SpecVal=1.0E9" ), astFluxFrame( AST__BAD, NULL, "SpecVal=2.0E9" ) ); + + /* Comparisons where C's Equal and a comparison of native text disagree. */ + head( "zoommap_inverted_vs_reciprocal" ); + eq( inv( zoom( 1, 2.0 ) ), zoom( 1, 0.5 ) ); + head( "differing_id" ); + eq( astZoomMap( 1, 2.0, "ID=a" ), astZoomMap( 1, 2.0, "ID=b" ) ); + head( "differing_ident" ); + eq( astZoomMap( 1, 2.0, "Ident=a" ), astZoomMap( 1, 2.0, "Ident=b" ) ); + head( "mathmap_last_opcode" ); + eq( mathmap( "y = x + 1", "x = y - 1" ), mathmap( "y = x - 1", "x = y + 1" ) ); + eq( mathmap( "y = x * 2", "x = y / 2" ), mathmap( "y = x / 2", "x = y * 2" ) ); + eq( mathmap( "y = x + 1", "x = y - 1" ), mathmap( "y = x + 2", "x = y - 2" ) ); + head( "cmpmap_shared_component" ); + { + /* The same ZoomMap is the first component of both CmpMaps, recorded + not inverted in the first and inverted in the second. */ + AstZoomMap *z = zoom( 1, 2.0 ); + AstUnitMap *u = astUnitMap( 1, " " ); + AstCmpMap *a = astCmpMap( z, u, 1, " " ); + astInvert( z ); + AstCmpMap *b = astCmpMap( z, u, 1, " " ); + printf( "invert before %d set %d\n", astGetI( z, "Invert" ), astTest( z, "Invert" ) ); + eq( a, b ); + printf( "invert after %d set %d\n", astGetI( z, "Invert" ), astTest( z, "Invert" ) ); + eq( b, a ); + printf( "invert after reverse %d set %d\n", astGetI( z, "Invert" ), astTest( z, "Invert" ) ); + } + head( "cmpmap_ident" ); + { + /* CmpMaps with Ident set are expanded explicitly and their components + compared through copies. */ + AstZoomMap *z = zoom( 1, 2.0 ); + AstUnitMap *u = astUnitMap( 1, " " ); + eq( astCmpMap( zoom( 1, 2.0 ), u, 1, "Ident=a" ), astCmpMap( zoom( 1, 2.0 ), u, 1, "Ident=b" ) ); + eq( astCmpMap( zoom( 1, 2.0 ), u, 1, "Ident=a" ), astCmpMap( zoom( 1, 3.0 ), u, 1, "Ident=b" ) ); + eq( astCmpMap( zoom( 1, 2.0 ), u, 1, "Ident=a" ), astCmpMap( zoom( 1, 2.0 ), u, 1, " " ) ); + AstCmpMap *a = astCmpMap( z, u, 1, "Ident=a" ); + astInvert( z ); + AstCmpMap *b = astCmpMap( z, u, 1, "Ident=b" ); + eq( a, b ); + printf( "invert after %d set %d\n", astGetI( z, "Invert" ), astTest( z, "Invert" ) ); + eq( inv( astCmpMap( zoom( 1, 2.0 ), zoom( 1, 3.0 ), 1, "Ident=a" ) ), + astCmpMap( zoom( 1, 1.0 / 3.0 ), zoom( 1, 0.5 ), 1, "Ident=b" ) ); + } + head( "frameset_frames_differ_in_title" ); + { + AstFrameSet *a = astFrameSet( astFrame( 2, "Title=A" ), " " ); + astAddFrame( a, AST__BASE, zoom( 2, 2.0 ), astFrame( 2, "Title=B" ) ); + AstFrameSet *b = astFrameSet( astFrame( 2, "Title=C" ), " " ); + astAddFrame( b, AST__BASE, zoom( 2, 2.0 ), astFrame( 2, "Title=D" ) ); + eq( a, b ); + astSetI( b, "Current", 1 ); + eq( a, b ); + eq( a, astFrame( 2, " " ) ); + eq( astFrame( 2, " " ), a ); + } + head( "zoommap_cleared_zoom" ); + { + /* Equal compares the factors as stored: zero once Zoom is cleared. */ + AstZoomMap *a = zoom( 1, 2.0 ); + astClear( a, "Zoom" ); + AstZoomMap *b = zoom( 1, 2.0 ); + astClear( b, "Zoom" ); + eq( a, zoom( 1, 1.0 ) ); + eq( zoom( 1, 1.0 ), a ); + eq( a, inv( b ) ); + eq( zoom( 1, 3.0 ), inv( astCopy( a ) ) ); + } + head( "frameset_inverted" ); + { + AstFrameSet *a = astFrameSet( astFrame( 2, " " ), " " ); + astAddFrame( a, AST__BASE, zoom( 2, 2.0 ), astFrame( 2, " " ) ); + eq( a, inv( astCopy( a ) ) ); + } + head( "object_classes" ); + eq( astKeyMap( " " ), astKeyMap( " " ) ); + { + AstKeyMap *k1 = astKeyMap( " " ); + AstKeyMap *k2 = astKeyMap( " " ); + astMapPut0I( k1, "A", 1, NULL ); + astMapPut0I( k2, "B", 2, NULL ); + eq( k1, k2 ); + eq( k1, zoom( 1, 1.0 ) ); + } + + astEnd; + return 0; +} diff --git a/src/test/resources/probes/equal_probe.out b/src/test/resources/probes/equal_probe.out new file mode 100644 index 0000000..f574e55 --- /dev/null +++ b/src/test/resources/probes/equal_probe.out @@ -0,0 +1,262 @@ +== float_tolerance_within +equal 1 +== float_tolerance_outside +equal 0 +== bad_value_comparison +equal 1 +== bad_vs_non_bad_same_index_is_not_equal +equal 0 +== bad_vs_non_bad_different_index_is_not_equal +equal 0 +== unitmap_identity +equal 1 +== unitmap_same_ncoord +equal 1 +== unitmap_different_ncoord +equal 0 +== zoommap_identity +equal 1 +== zoommap_same_values +equal 1 +== zoommap_different_factor +equal 0 +== zoommap_different_ncoord +equal 0 +== zoommap_invert_aware +equal 1 +== zoommap_invert_aware_mismatch +equal 0 +== shiftmap_identity +equal 1 +== shiftmap_same_values +equal 1 +== shiftmap_different_shifts +equal 0 +== shiftmap_different_length +equal 0 +== shiftmap_invert_aware +equal 1 +== shiftmap_invert_aware_mismatch +equal 0 +== matrixmap_same +equal 1 +== matrixmap_different_element +equal 0 +== matrixmap_inverted_not_equal +equal 0 +== permmap_same +equal 1 +== permmap_different_perm +equal 0 +== permmap_equal_cross_inversion +equal 1 +equal 1 +== winmap_same +equal 1 +== winmap_different_scale +equal 0 +== winmap_inverted_not_equal +equal 0 +== winmap_equal_cross_inversion +equal 1 +== cmpmap_series_same +equal 1 +== cmpmap_different_component +equal 0 +== cmpmap_different_kind +equal 0 +== polymap_same +equal 1 +== polymap_different_coeff +equal 0 +== lutmap_same +equal 1 +== lutmap_different_values +equal 0 +== lutmap_different_start +equal 0 +== wcsmap_same +equal 1 +== wcsmap_different_proj +equal 0 +== wcsmap_different_axes +equal 0 +== slamap_same +equal 1 +== slamap_different_type +equal 0 +== slamap_different_args +equal 0 +== sphmap_same +equal 1 +== sphmap_different_polar_long +equal 0 +== sphmap_different_unit_radius +equal 0 +== sphmap_inverted +equal 0 +== cmpmap_equal_different_tree_structure +equal 1 +== cross_type_zoom_vs_shift +equal 0 +== cross_type_unit_vs_zoom +equal 0 +== cross_type_winmap_vs_shiftmap +equal 0 +== basicframe_same +equal 1 +== basicframe_different_naxes +equal 0 +== basicframe_different_title_is_equal +equal 1 +== basicframe_different_domain +equal 0 +== basicframe_different_epoch_is_equal +equal 1 +== basicframe_epoch_set_vs_unset_is_equal +equal 1 +== basicframe_different_labels_is_equal +equal 1 +== cmpframe_same +equal 1 +== cmpframe_different_child +equal 0 +== skyframe_same +equal 1 +== skyframe_different_system +equal 0 +== skyframe_different_equinox +equal 0 +== skyframe_equinox_set_vs_unset_default_is_equal +equal 1 +== skyframe_different_epoch +equal 0 +== skyframe_sky_ref_is_origin_without_sky_ref_is_equal +equal 1 +== skyframe_offset_origin_with_sky_ref_is_not_equal +equal 0 +== skyframe_sky_ref_without_sky_ref_is_is_equal +equal 1 +== skyframe_different_neglon_is_equal +equal 1 +== skyframe_different_title_is_equal +equal 1 +== cross_type_skyframe_vs_basicframe +equal 0 +== cross_type_basicframe_vs_skyframe +equal 0 +== frameset_same +equal 1 +== frameset_different_mapping +equal 0 +== serialise_round_trip_zoommap +equal 1 +== serialise_round_trip_shiftmap +equal 1 +== serialise_round_trip_skyframe +equal 1 +== matrixmap_equal_cross_inversion +equal 1 +equal 0 +== an_inverted_non_square_matrixmap_equals_its_copy +equal 1 +equal 0 +== perm_equal_same_constant_index_differing_values +equal 0 +== perm_equal_same_constant_index_same_value +equal 1 +== perm_equal_different_index_same_referenced_value +equal 1 +== perm_equal_different_index_different_referenced_value +equal 0 +== perm_equal_ignores_unreferenced_surplus_constants +equal 1 +== cmpmap_equality_compares_components_as_applied +equal 1 +equal 1 +equal 0 +== wcsmap_equal_different_params +equal 1 +equal 0 +== wcsmap_equal_same_params +equal 1 +== polymap_equal_compares_the_inverse_coefficients +equal 1 +equal 1 +equal 0 +equal 0 +class CmpMap +class UnitMap +== polymap_with_more_outputs_than_inputs_equals_its_copy +equal 1 +equal 1 +== specmap_equality +equal 1 +equal 0 +== test_equal_same +equal 1 +== test_not_equal_different_system +equal 0 +== test_not_equal_different_sor +equal 0 +== timemap_equality +equal 1 +equal 0 +== basic_frames_differing_only_in_cosmetics_are_equal +equal 1 +== basic_frames_differing_in_domain_are_not_equal +equal 0 +== skyframes_differing_only_in_title_are_equal +equal 1 +== skyframe_explicit_default_domain_equals_unset_domain +equal 1 +== skyframes_differing_in_system_are_not_equal +equal 0 +== timeframe_test_equal +equal 1 +equal 0 +== test_fluxframe_equal_same +equal 1 +== test_fluxframe_equal_different_system +equal 0 +== test_fluxframe_equal_different_specval_is_equal +equal 1 +== zoommap_inverted_vs_reciprocal +equal 1 +== differing_id +equal 1 +== differing_ident +equal 1 +== mathmap_last_opcode +equal 1 +equal 1 +equal 0 +== cmpmap_shared_component +invert before 1 set 1 +equal 1 +invert after 0 set 1 +equal 1 +invert after reverse 1 set 1 +== cmpmap_ident +equal 1 +equal 0 +equal 0 +equal 0 +invert after 1 set 1 +equal 1 +== frameset_frames_differ_in_title +equal 1 +equal 0 +equal 0 +equal 0 +== zoommap_cleared_zoom +equal 0 +equal 0 +equal 1 +equal 1 +== frameset_inverted +equal 1 +== object_classes +equal 1 +equal 1 +equal 0 diff --git a/src/test/resources/probes/fitslog_probe.c b/src/test/resources/probes/fitslog_probe.c new file mode 100644 index 0000000..c528a36 --- /dev/null +++ b/src/test/resources/probes/fitslog_probe.c @@ -0,0 +1,282 @@ +/* fitslog_probe -- FITS-WCS -LOG axes in the pinned C library: headers with + * a -LOG axis that is not spectral and one that is, read, dumped, and + * written back in each FITS encoding and read again; FrameSets whose world + * axis is exponential in the pixel axis written with FITS-WCS; and a + * FREQ axis whose Unit is log(Hz). + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * A write prints the value it returns and the cards the FitsChan then holds + * (astFindFits with "%f" from the first card); a read prints its dump and + * transforms the pixel positions 1, 50 and 100 (and 512 and 1024 for a + * header with NAXIS1 = 1024). + * Built against the C library at 3d3f255f with its static libraries: + * cc -I -o fitslog_probe fitslog_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 ./fitslog_probe > fitslog_probe.out 2>&1, then trailing white + * space removed from every line. The output holds words of C's (the + * attribute name of the current Frame and the comment of CTYPE cards) that + * the spelling check of text files rejects, so it is committed as the + * string "output" of fitslog_probe.json: + * python3 -c 'import json; json.dump({"source": "probes/fitslog_probe.c", + * "output": open("fitslog_probe.out").read()}, + * open("fitslog_probe.json", "w"), indent=1)' */ +#include +#include +#include "ast.h" + +static const char *encodings[] = { "FITS-WCS", "FITS-PC", "FITS-IRAF", + "FITS-AIPS", "FITS-AIPS++", "FITS-CLASS", + NULL }; + +static void head( const char *name ) { + printf( "== %s\n", name ); +} + +static void cards( AstFitsChan *fc ) { + char card[ 81 ]; + astClear( fc, "Card" ); + while( astFindFits( fc, "%f", card, 1 ) ) printf( "%s\n", card ); +} + +/* The pixel positions along the first pixel axis, the others at 1. */ +static void trans( AstFrameSet *fs, int big ) { + double pix[] = { 1.0, 50.0, 100.0, 512.0, 1024.0 }; + int np = big ? 5 : 3; + int nin = astGetI( fs, "Nin" ); + int nout = astGetI( fs, "Nout" ); + double in[ 3 ][ 5 ], out[ 3 ][ 5 ], back[ 3 ][ 5 ]; + for( int i = 0; i < np; i++ ) { + in[ 0 ][ i ] = pix[ i ]; + for( int j = 1; j < nin; j++ ) in[ j ][ i ] = 1.0; + } + astTranN( fs, np, nin, 5, (const double *) in, 1, nout, 5, (double *) out ); + astTranN( fs, np, nout, 5, (const double *) out, 0, nin, 5, (double *) back ); + for( int i = 0; i < np; i++ ) { + printf( "pix" ); + for( int j = 0; j < nin; j++ ) printf( " %.17g", in[ j ][ i ] ); + printf( " -> wcs" ); + for( int j = 0; j < nout; j++ ) printf( " %.17g", out[ j ][ i ] ); + printf( " -> pix" ); + for( int j = 0; j < nin; j++ ) printf( " %.17g", back[ j ][ i ] ); + printf( "\n" ); + } +} + +/* Writes fs with the encoding into a FitsChan holding the NAXIS cards, + prints the result and the cards, and reads it back. */ +static void writeback( AstFrameSet *fs, const char *enc, const char **naxis, int big ) { + printf( "-- write %s\n", enc ); + AstFitsChan *fc = astFitsChan( NULL, NULL, "Encoding=%s", enc ); + for( int i = 0; naxis[ i ]; i++ ) astPutFits( fc, naxis[ i ], 0 ); + int n = astWrite( fc, fs ); + if( !astOK ) { + printf( "write status %d\n", astStatus ); + astClearStatus; + return; + } + printf( "wrote %d\n", n ); + cards( fc ); + if( n ) { + astClear( fc, "Card" ); + AstFrameSet *back = astRead( fc ); + if( !astOK ) { + printf( "read back status %d\n", astStatus ); + astClearStatus; + return; + } + printf( "-- read back %s\n", back ? astGetC( back, "Class" ) : "nothing" ); + if( back ) { + printf( "domain %s\n", astGetC( back, "Domain" ) ); + trans( back, big ); + } + } +} + +/* Reads the header, prints the FrameSet and its transformations, then + writes it in each encoding. */ +static void readhead( const char *name, const char **hdr, const char **naxis, int big ) { + head( name ); + AstFitsChan *fc = astFitsChan( NULL, NULL, "" ); + for( int i = 0; hdr[ i ]; i++ ) astPutFits( fc, hdr[ i ], 0 ); + astClear( fc, "Card" ); + printf( "encoding %s\n", astGetC( fc, "Encoding" ) ); + AstFrameSet *fs = astRead( fc ); + if( !astOK ) { + printf( "read status %d\n", astStatus ); + astClearStatus; + return; + } + if( !fs ) { + printf( "read nothing\n" ); + return; + } + printf( "-- read\n" ); + astShow( fs ); + printf( "domain %s\n", astGetC( fs, "Domain" ) ); + int naxes = astGetI( fs, "Naxes" ); + for( int i = 1; i <= naxes; i++ ) { + char attr[ 20 ]; + sprintf( attr, "Symbol(%d)", i ); + printf( "symbol(%d) %s\n", i, astGetC( fs, attr ) ); + } + trans( fs, big ); + for( int i = 0; encodings[ i ]; i++ ) writeback( fs, encodings[ i ], naxis, big ); +} + +/* The PolyMap of the Taylor series to degree 20 of sr exp(slope p). */ +static AstPolyMap *exponential( double sr, double slope ) { + double coeffs[ 21*3 ]; + double term = sr; + for( int k = 0; k <= 20; k++ ) { + coeffs[ 3*k ] = term; + coeffs[ 3*k + 1 ] = 1; + coeffs[ 3*k + 2 ] = k; + term = term*slope/( k + 1 ); + } + return astPolyMap( 1, 1, 21, coeffs, 0, NULL, "IterInverse=1" ); +} + +static AstFrameSet *frameset( int nin, AstMapping *map, AstFrame *wcs ) { + AstFrame *pix = astFrame( nin, "Domain=GRID" ); + AstFrameSet *fs = astFrameSet( pix, " " ); + astAddFrame( fs, AST__BASE, map, wcs ); + return fs; +} + +int main( void ) { + int status = 0; + setvbuf( stdout, NULL, _IONBF, 0 ); + astWatch( &status ); + astBegin; + + const char *naxis1[] = { "NAXIS = 1", "NAXIS1 = 100", NULL }; + const char *naxis1k[] = { "NAXIS = 1", "NAXIS1 = 1024", NULL }; + const char *naxis2[] = { "NAXIS = 2", "NAXIS1 = 100", "NAXIS2 = 100", NULL }; + + /* A -LOG axis that is not spectral. */ + { + const char *h[] = { "NAXIS = 1", "NAXIS1 = 100", "CTYPE1 = 'ZZZZ-LOG'", + "CRPIX1 = 1", "CRVAL1 = 10.0", "CDELT1 = 0.1", NULL }; + readhead( "other_log", h, naxis1, 0 ); + } + + /* A linear axis and a -LOG axis with a unit. */ + { + const char *h[] = { "NAXIS = 2", "NAXIS1 = 100", "NAXIS2 = 100", + "CTYPE1 = 'XPOS'", "CTYPE2 = 'YPOS-LOG'", + "CUNIT2 = 'V'", "CRPIX1 = 1", "CRPIX2 = 50", + "CRVAL1 = 3.0", "CRVAL2 = 250.0", + "CDELT1 = 2.0", "CDELT2 = 5.0", NULL }; + readhead( "other_log_2d", h, naxis2, 0 ); + } + + /* A spectral -LOG axis. */ + { + const char *h[] = { "NAXIS = 1", "NAXIS1 = 1024", "CTYPE1 = 'FREQ-LOG'", + "CUNIT1 = 'Hz'", "CRPIX1 = 512", "CRVAL1 = 1.4204E9", + "CDELT1 = 1.0E5", "SPECSYS = 'BARYCENT'", + "RESTFRQ = 1.4204E9", NULL }; + readhead( "freq_log", h, naxis1k, 1 ); + } + + /* A spectral -LOG axis in velocity. */ + { + const char *h[] = { "NAXIS = 1", "NAXIS1 = 100", "CTYPE1 = 'VRAD-LOG'", + "CUNIT1 = 'km/s'", "CRPIX1 = 50", "CRVAL1 = 1000.0", + "CDELT1 = 2.0", "SPECSYS = 'LSRK'", + "RESTFRQ = 1.4204E9", NULL }; + readhead( "vrad_log", h, naxis1, 0 ); + } + + /* An axis exponential in the pixel axis, not spectral: 10 exp(0.01 p). */ + head( "write_other_exp" ); + writeback( frameset( 1, (AstMapping *) exponential( 10.0, 0.01 ), + astFrame( 1, "Domain=WORLD" ) ), + "FITS-WCS", naxis1, 0 ); + + /* A frequency axis exponential in the pixel axis: 1.4 exp(0.001 p). */ + head( "write_freq_exp" ); + writeback( frameset( 1, (AstMapping *) exponential( 1.4, 0.001 ), + (AstFrame *) astSpecFrame( "System=FREQ" ) ), + "FITS-WCS", naxis1, 0 ); + + /* testfitschan.c 680-683: a MathMap frequency axis. */ + { + const char *fwd[] = { "s = 1.4204e9 * exp( p * 1.0e-4 )" }; + const char *inv[] = { "p = 1.0e4 * log( s / 1.4204e9 )" }; + AstMathMap *mm = astMathMap( 1, 1, 1, fwd, 1, inv, " " ); + AstSpecFrame *sf = astSpecFrame( "System=FREQ,Unit=Hz,StdOfRest=Bary,RestFreq=1.4204e9 Hz" ); + head( "write_mathmap_freq" ); + writeback( frameset( 1, (AstMapping *) mm, (AstFrame *) sf ), "FITS-WCS", naxis1k, 1 ); + } + + /* A frequency axis in log(Hz), linear in the pixel axis, beside a + linear axis. */ + { + AstFrame *f1 = astFrame( 1, " " ); + AstSpecFrame *sf = astSpecFrame( "System=FREQ,Unit=log(Hz)" ); + AstCmpFrame *cf = astCmpFrame( f1, sf, " " ); + double shift[] = { 0.0, 8.95 }; + double zoom[] = { 1.0, 0.001 }; + AstShiftMap *sm = astShiftMap( 2, shift, " " ); + AstMatrixMap *zm = astMatrixMap( 2, 2, 1, zoom, " " ); + head( "write_log_unit" ); + writeback( frameset( 2, (AstMapping *) astCmpMap( zm, sm, 1, " " ), (AstFrame *) cf ), + "FITS-WCS", naxis2, 0 ); + } + + /* The header wcsconv/inputs/freq-log.head of the C fixtures, whose + logarithmic increment is so small that the axis is linear to within + FitsTol: written back with FITS-WCS. */ + { + const char *h[] = { "SIMPLE = T / Fits standard", + "BITPIX = -32 / Bits per pixel", + "NAXIS = 1 / Number of dimensions", + "NAXIS1 = 1024 / Length of axis", + "CTYPE1 = 'FREQ-LOG' / Logarithmic frequency axis", + "CRVAL1 = 1.4204E+09 / Reference frequency (Hz)", + "CRPIX1 = 512.500 / Reference pixel", + "CDELT1 = 1.0000E-03 / Log increment", + "CUNIT1 = 'Hz ' / Axis units", + "RESTFRQ = 1.4204E+09 / Rest frequency (Hz)", + "SPECSYS = 'BARYCENT' / Spectral reference frame", + NULL }; + head( "freq_log_head" ); + AstFitsChan *fc = astFitsChan( NULL, NULL, "" ); + for( int i = 0; h[ i ]; i++ ) astPutFits( fc, h[ i ], 0 ); + astClear( fc, "Card" ); + AstFrameSet *fs = astRead( fc ); + trans( fs, 1 ); + writeback( fs, "FITS-WCS", naxis1k, 1 ); + + /* The Unit of the FrameSet written, before and after the write. */ + head( "freq_log_head_unit" ); + fc = astFitsChan( NULL, NULL, "" ); + for( int i = 0; h[ i ]; i++ ) astPutFits( fc, h[ i ], 0 ); + astClear( fc, "Card" ); + fs = astRead( fc ); + printf( "unit before %s test %d\n", astGetC( fs, "Unit(1)" ), astTest( fs, "Unit(1)" ) ); + AstFitsChan *wfc = astFitsChan( NULL, NULL, "Encoding=FITS-WCS" ); + for( int i = 0; naxis1k[ i ]; i++ ) astPutFits( wfc, naxis1k[ i ], 0 ); + printf( "wrote %d\n", astWrite( wfc, fs ) ); + printf( "unit after %s test %d\n", astGetC( fs, "Unit(1)" ), astTest( fs, "Unit(1)" ) ); + } + + /* FitsSpectralAxesTest.nonlinearUnitIsCleared: a pixel Frame and a + CmpFrame of a Frame and a FREQ SpecFrame in log(Hz), joined by a + UnitMap. */ + { + AstSpecFrame *sf = astSpecFrame( "System=FREQ,Unit(1)=log(Hz)" ); + AstCmpFrame *cf = astCmpFrame( astFrame( 1, " " ), sf, " " ); + AstFrameSet *fs = frameset( 2, (AstMapping *) astUnitMap( 2, " " ), (AstFrame *) cf ); + head( "write_log_unit_unitmap" ); + writeback( fs, "FITS-WCS", naxis2, 0 ); + printf( "unit after %s\n", astGetC( fs, "Unit(2)" ) ); + } + + astEnd; + return 0; +} diff --git a/src/test/resources/probes/fitslog_probe.json b/src/test/resources/probes/fitslog_probe.json new file mode 100644 index 0000000..e19ef39 --- /dev/null +++ b/src/test/resources/probes/fitslog_probe.json @@ -0,0 +1,4 @@ +{ + "source": "probes/fitslog_probe.c", + "output": "== other_log\nencoding FITS-WCS\n-- read\n Begin FrameSet \t# Set of inter-related coordinate systems\n# Title = \"1-d coordinate system\" \t# Title of coordinate system\n# Naxes = 1 \t# Number of coordinate axes\n# Domain = \"ZZZZ\" \t# Coordinate system domain\n# Lbl1 = \"ZZZZ\" \t# Label for axis 1\n IsA Frame \t# Coordinate system description\n Nframe = 2 \t# Number of Frames in FrameSet\n Base = 1 \t# Index of base Frame\n Currnt = 2 \t# Index of current Frame\n Lnk2 = 1 \t# Node 2 is derived from node 1\n Frm1 = \t# Frame number 1\n Begin Frame \t# Coordinate system description\n Title = \"Pixel Coordinates\" \t# Title of coordinate system\n Naxes = 1 \t# Number of coordinate axes\n Domain = \"GRID\" \t# Coordinate system domain\n# Lbl1 = \"Pixel axis 1\" \t# Label for axis 1\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n Label = \"Pixel axis 1\" \t# Axis Label\n End Axis\n End Frame\n Frm2 = \t# Frame number 2\n Begin Frame \t# Coordinate system description\n Ident = \" \" \t# Permanent Object identification string\n IsA Object \t# AST Object\n# Title = \"1-d coordinate system\" \t# Title of coordinate system\n Naxes = 1 \t# Number of coordinate axes\n Domain = \"ZZZZ\" \t# Coordinate system domain\n# Lbl1 = \"ZZZZ\" \t# Label for axis 1\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n Label = \"ZZZZ\" \t# Axis Label\n Symbol = \"ZZZZ\" \t# Axis symbol\n End Axis\n End Frame\n Map2 = \t# Mapping between nodes 1 and 2\n Begin CmpMap \t# Compound 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 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 = -0.10000000000000001 \t# Shift for axis 1\n Scl1 = 0.10000000000000001 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin MathMap \t# Transformation using mathematical functions\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Fwd1 = \"s=10*exp(w/10)\" \t# Forward function 1\n Inv1 = \"w=10*log(s/10)\" \t# Inverse function 1\n SimpFI = 1 \t# Forward-inverse pairs may simplify\n SimpIF = 1 \t# Inverse-forward pairs may simplify\n End MathMap\n End CmpMap\n End FrameSet\ndomain ZZZZ\nsymbol(1) ZZZZ\npix 1 -> wcs 10 -> pix 1\npix 50 -> wcs 16.323162199553792 -> pix 50.000000000000014\npix 100 -> wcs 26.91234472349262 -> pix 99.999999999999986\n-- write FITS-WCS\nwrote 1\nNAXIS = 1\nNAXIS1 = 100\nWCSNAME = 'ZZZZ ' / Reference name for the coord. frame\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRVAL1 = 16.323162199553792 / Value at ref. pixel on axis 1\nCTYPE1 = 'ZZZZ-LOG' / Type of co-ordinate on axis 1\nCDELT1 = 0.1632316219955379 / Pixel size on axis 1\n-- read back FrameSet\ndomain ZZZZ\npix 1 -> wcs 10.000000000000002 -> pix 0.99999999999999289\npix 50 -> wcs 16.323162199553792 -> pix 49.999999999999993\npix 100 -> wcs 26.912344723492623 -> pix 99.999999999999986\n-- write FITS-PC\nwrote 1\nNAXIS = 1\nNAXIS1 = 100\nCDELT1 = 0.1632316219955379 / Pixel scale on axis 1\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRVAL1 = 16.323162199553792 / Value at ref. pixel on axis 1\nCTYPE1 = 'ZZZZ-LOG' / Type of co-ordinate on axis 1\n-- read back FrameSet\ndomain ZZZZ\npix 1 -> wcs 10.000000000000002 -> pix 0.99999999999999289\npix 50 -> wcs 16.323162199553792 -> pix 49.999999999999993\npix 100 -> wcs 26.912344723492623 -> pix 99.999999999999986\n-- write FITS-IRAF\nwrote 1\nNAXIS = 1\nNAXIS1 = 100\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRVAL1 = 16.323162199553792 / Value at ref. pixel on axis 1\nCTYPE1 = 'ZZZZ-LOG' / Type of co-ordinate on axis 1\nCD1_1 = 0.1632316219955379 / Transformation matrix element\n-- read back FrameSet\ndomain ZZZZ\npix 1 -> wcs 10.000000000000002 -> pix 0.99999999999999289\npix 50 -> wcs 16.323162199553792 -> pix 49.999999999999993\npix 100 -> wcs 26.912344723492623 -> pix 99.999999999999986\n-- write FITS-AIPS\nwrote 1\nNAXIS = 1\nNAXIS1 = 100\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRVAL1 = 16.323162199553792 / Value at ref. pixel on axis 1\nCTYPE1 = 'ZZZZ-LOG' / Type of co-ordinate on axis 1\nCDELT1 = 0.1632316219955379 / Pixel size\n-- read back FrameSet\ndomain ZZZZ\npix 1 -> wcs 10.000000000000002 -> pix 0.99999999999999289\npix 50 -> wcs 16.323162199553792 -> pix 49.999999999999993\npix 100 -> wcs 26.912344723492623 -> pix 99.999999999999986\n-- write FITS-AIPS++\nwrote 1\nNAXIS = 1\nNAXIS1 = 100\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRVAL1 = 16.323162199553792 / Value at ref. pixel on axis 1\nCTYPE1 = 'ZZZZ-LOG' / Type of co-ordinate on axis 1\nCDELT1 = 0.1632316219955379 / Pixel size\n-- read back FrameSet\ndomain ZZZZ\npix 1 -> wcs 10.000000000000002 -> pix 0.99999999999999289\npix 50 -> wcs 16.323162199553792 -> pix 49.999999999999993\npix 100 -> wcs 26.912344723492623 -> pix 99.999999999999986\n-- write FITS-CLASS\nwrote 0\nNAXIS = 1\nNAXIS1 = 100\n== other_log_2d\nencoding FITS-WCS\n-- read\n Begin FrameSet \t# Set of inter-related coordinate systems\n# Title = \"2-d coordinate system\" \t# Title of coordinate system\n# Naxes = 2 \t# Number of coordinate axes\n# Domain = \"XPOS-YPOS\" \t# Coordinate system domain\n# Lbl1 = \"XPOS\" \t# Label for axis 1\n# Lbl2 = \"YPOS\" \t# Label for axis 2\n# Uni2 = \"V\" \t# Units for axis 2 (Volt)\n IsA Frame \t# Coordinate system description\n Nframe = 2 \t# Number of Frames in FrameSet\n Base = 1 \t# Index of base Frame\n Currnt = 2 \t# Index of current Frame\n Lnk2 = 1 \t# Node 2 is derived from node 1\n Frm1 = \t# Frame number 1\n Begin Frame \t# Coordinate system description\n Title = \"Pixel Coordinates\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n Domain = \"GRID\" \t# Coordinate system domain\n# Lbl1 = \"Pixel axis 1\" \t# Label for axis 1\n# Lbl2 = \"Pixel axis 2\" \t# Label for axis 2\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n Label = \"Pixel axis 1\" \t# Axis Label\n End Axis\n Ax2 = \t# Axis number 2\n Begin Axis \t# Coordinate axis\n Label = \"Pixel axis 2\" \t# Axis Label\n End Axis\n End Frame\n Frm2 = \t# Frame number 2\n Begin Frame \t# Coordinate system description\n Ident = \" \" \t# Permanent Object identification string\n IsA Object \t# AST Object\n# Title = \"2-d coordinate system\" \t# Title of coordinate system\n Naxes = 2 \t# Number of coordinate axes\n Domain = \"XPOS-YPOS\" \t# Coordinate system domain\n# Lbl1 = \"XPOS\" \t# Label for axis 1\n# Lbl2 = \"YPOS\" \t# Label for axis 2\n# Uni2 = \"V\" \t# Units for axis 2 (Volt)\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n Label = \"XPOS\" \t# Axis Label\n Symbol = \"XPOS\" \t# Axis symbol\n End Axis\n Ax2 = \t# Axis number 2\n Begin Axis \t# Coordinate axis\n Label = \"YPOS\" \t# Axis Label\n Symbol = \"YPOS\" \t# Axis symbol\n Unit = \"V\" \t# Axis units (Volt)\n End Axis\n End Frame\n Map2 = \t# Mapping between nodes 1 and 2\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 Series = 0 \t# Component Mappings applied in parallel\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 IsSimp = 1 \t# Mapping has been simplified\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 End WinMap\n MapB = \t# Second component Mapping\n Begin CmpMap \t# Compound 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 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 = -250 \t# Shift for axis 1\n Scl1 = 5 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin MathMap \t# Transformation using mathematical functions\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Fwd1 = \"s=250*exp(w/250)\" \t# Forward function 1\n Inv1 = \"w=250*log(s/250)\" \t# Inverse function 1\n SimpFI = 1 \t# Forward-inverse pairs may simplify\n SimpIF = 1 \t# Inverse-forward pairs may simplify\n End MathMap\n End CmpMap\n End CmpMap\n End FrameSet\ndomain XPOS-YPOS\nsymbol(1) XPOS\nsymbol(2) YPOS\npix 1 1 -> wcs 3 93.827774712849887 -> pix 1 1\npix 50 1 -> wcs 101 93.827774712849887 -> pix 50 1\npix 100 1 -> wcs 201 93.827774712849887 -> pix 100 1\n-- write FITS-WCS\nwrote 1\nNAXIS = 2\nNAXIS1 = 100\nNAXIS2 = 100\nWCSNAME = 'XPOS-YPOS' / Reference name for the coord. frame\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRPIX2 = 50.0 / Reference pixel on axis 2\nCRVAL1 = 101.0 / Value at ref. pixel on axis 1\nCRVAL2 = 250.0 / Value at ref. pixel on axis 2\nCTYPE1 = 'XPOS ' / Type of co-ordinate on axis 1\nCTYPE2 = 'YPOS-LOG' / Type of co-ordinate on axis 2\nCDELT1 = 2.0 / Pixel size on axis 1\nCDELT2 = 5.0 / Pixel size on axis 2\nCUNIT2 = 'V ' / Units for axis 2\n-- read back FrameSet\ndomain XPOS-YPOS\npix 1 1 -> wcs 3 93.827774712849845 -> pix 1 1\npix 50 1 -> wcs 101 93.827774712849845 -> pix 50 1\npix 100 1 -> wcs 201 93.827774712849845 -> pix 100 1\n-- write FITS-PC\nwrote 1\nNAXIS = 2\nNAXIS1 = 100\nNAXIS2 = 100\nCDELT1 = 2.0 / Pixel scale on axis 1\nCDELT2 = 5.0 / Pixel scale on axis 2\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRPIX2 = 50.0 / Reference pixel on axis 2\nCRVAL1 = 101.0 / Value at ref. pixel on axis 1\nCRVAL2 = 250.0 / Value at ref. pixel on axis 2\nCTYPE1 = 'XPOS ' / Type of co-ordinate on axis 1\nCTYPE2 = 'YPOS-LOG' / Type of co-ordinate on axis 2\nCUNIT2 = 'V ' / Units for axis 2\n-- read back FrameSet\ndomain XPOS-YPOS\npix 1 1 -> wcs 3 93.827774712849845 -> pix 1 1\npix 50 1 -> wcs 101 93.827774712849845 -> pix 50 1\npix 100 1 -> wcs 201 93.827774712849845 -> pix 100 1\n-- write FITS-IRAF\nwrote 1\nNAXIS = 2\nNAXIS1 = 100\nNAXIS2 = 100\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRPIX2 = 50.0 / Reference pixel on axis 2\nCRVAL1 = 101.0 / Value at ref. pixel on axis 1\nCRVAL2 = 250.0 / Value at ref. pixel on axis 2\nCTYPE1 = 'XPOS ' / Type of co-ordinate on axis 1\nCTYPE2 = 'YPOS-LOG' / Type of co-ordinate on axis 2\nCD1_1 = 2.0 / Transformation matrix element\nCD2_2 = 5.0 / Transformation matrix element\nCUNIT2 = 'V ' / Units for axis 2\n-- read back FrameSet\ndomain XPOS-YPOS\npix 1 1 -> wcs 3 93.827774712849845 -> pix 1 1\npix 50 1 -> wcs 101 93.827774712849845 -> pix 50 1\npix 100 1 -> wcs 201 93.827774712849845 -> pix 100 1\n-- write FITS-AIPS\nwrote 1\nNAXIS = 2\nNAXIS1 = 100\nNAXIS2 = 100\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRPIX2 = 50.0 / Reference pixel on axis 2\nCRVAL1 = 101.0 / Value at ref. pixel on axis 1\nCRVAL2 = 250.0 / Value at ref. pixel on axis 2\nCTYPE1 = 'XPOS ' / Type of co-ordinate on axis 1\nCTYPE2 = 'YPOS-LOG' / Type of co-ordinate on axis 2\nCDELT1 = 2.0 / Pixel size\nCDELT2 = 5.0 / Pixel size\nCUNIT2 = 'V ' / Units for axis 2\nCROTA1 = 0.0 / Axis rotation\n-- read back FrameSet\ndomain XPOS-YPOS\npix 1 1 -> wcs 3 93.827774712849845 -> pix 1 1\npix 50 1 -> wcs 101 93.827774712849845 -> pix 50 1\npix 100 1 -> wcs 201 93.827774712849845 -> pix 100 1\n-- write FITS-AIPS++\nwrote 1\nNAXIS = 2\nNAXIS1 = 100\nNAXIS2 = 100\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRPIX2 = 50.0 / Reference pixel on axis 2\nCRVAL1 = 101.0 / Value at ref. pixel on axis 1\nCRVAL2 = 250.0 / Value at ref. pixel on axis 2\nCTYPE1 = 'XPOS ' / Type of co-ordinate on axis 1\nCTYPE2 = 'YPOS-LOG' / Type of co-ordinate on axis 2\nCDELT1 = 2.0 / Pixel size\nCDELT2 = 5.0 / Pixel size\nCUNIT2 = 'V ' / Units for axis 2\n-- read back FrameSet\ndomain XPOS-YPOS\npix 1 1 -> wcs 3 93.827774712849845 -> pix 1 1\npix 50 1 -> wcs 101 93.827774712849845 -> pix 50 1\npix 100 1 -> wcs 201 93.827774712849845 -> pix 100 1\n-- write FITS-CLASS\nwrote 0\nNAXIS = 2\nNAXIS1 = 100\nNAXIS2 = 100\n== freq_log\nencoding FITS-WCS\n-- read\n Begin FrameSet \t# Set of inter-related coordinate systems\n# Title = \"Frequency (Barycentric)\" \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 = \"Frequency\" \t# Label for axis 1\n# System = \"FREQ\" \t# Coordinate system type\n# Uni1 = \"Hz\" \t# Units for axis 1 (Hertz)\n IsA Frame \t# Coordinate system description\n Nframe = 2 \t# Number of Frames in FrameSet\n Base = 1 \t# Index of base Frame\n Currnt = 2 \t# Index of current Frame\n Lnk2 = 1 \t# Node 2 is derived from node 1\n Frm1 = \t# Frame number 1\n Begin Frame \t# Coordinate system description\n Title = \"Pixel Coordinates\" \t# Title of coordinate system\n Naxes = 1 \t# Number of coordinate axes\n Domain = \"GRID\" \t# Coordinate system domain\n# Lbl1 = \"Pixel axis 1\" \t# Label for axis 1\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n Label = \"Pixel axis 1\" \t# Axis Label\n End Axis\n End Frame\n Frm2 = \t# Frame number 2\n Begin SpecFrame \t# Description of spectral coordinate system\n Ident = \" \" \t# Permanent Object identification string\n IsA Object \t# AST Object\n# Title = \"Frequency (Barycentric)\" \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 = \"Frequency\" \t# Label for axis 1\n System = \"FREQ\" \t# Coordinate system type\n# Uni1 = \"Hz\" \t# Units for axis 1 (Hertz)\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n Unit = \"Hz\" \t# Axis units (Hertz)\n End Axis\n IsA Frame \t# Coordinate system description\n SoR = \"Barycentric\" \t# Standard of rest\n RstFrq = 1420400000 \t# Rest frequency (Hz)\n UFreq = \"Hz\" \t# Preferred units for frequency\n End SpecFrame\n Map2 = \t# Mapping between nodes 1 and 2\n Begin CmpMap \t# Compound 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 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 = -51200000 \t# Shift for axis 1\n Scl1 = 100000 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin MathMap \t# Transformation using mathematical functions\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Fwd1 = \"s=1420400000*exp(w/1420400000)\" \t# Forward function 1\n Inv1 = \"w=1420400000*log(s/1420400000)\" \t# Inverse function 1\n SimpFI = 1 \t# Forward-inverse pairs may simplify\n SimpIF = 1 \t# Inverse-forward pairs may simplify\n End MathMap\n End CmpMap\n End FrameSet\ndomain SPECTRUM\nsymbol(1) FREQ\npix 1 -> wcs 1370208256.8913562 -> pix 0.99999999999926104\npix 50 -> wcs 1374943271.3762355 -> pix 49.999999999997897\npix 100 -> wcs 1379791786.2541921 -> pix 100.00000000000006\npix 512 -> wcs 1420400000 -> pix 512\npix 1024 -> wcs 1472533970.5496309 -> pix 1024.0000000000011\n-- write FITS-WCS\nwrote 1\nNAXIS = 1\nNAXIS1 = 1024\nCRPIX1 = 522.0 / Reference pixel on axis 1\nCRVAL1 = 1421400352.0961409 / Value at ref. pixel on axis 1\nCTYPE1 = 'FREQ-LOG' / Type of co-ordinate on axis 1\nCDELT1 = 100070.42749198402 / Pixel size on axis 1\nCUNIT1 = 'Hz ' / Units for axis 1\nSPECSYS = 'BARYCENT' / Standard of rest for spectral axis\nVELOSYS = 29327.576999852943 / [m/s] Topo. apparent velocity of rest frame\nRESTFRQ = 1420400000.0 / [Hz] Rest frequency\n-- read back FrameSet\ndomain SPECTRUM\npix 1 -> wcs 1370208256.8913562 -> pix 0.99999999999863576\npix 50 -> wcs 1374943271.3762357 -> pix 50.00000000000199\npix 100 -> wcs 1379791786.2541921 -> pix 100.00000000000051\npix 512 -> wcs 1420400000 -> pix 511.99999999999949\npix 1024 -> wcs 1472533970.5496306 -> pix 1024\n-- write FITS-PC\nwrote 1\nNAXIS = 1\nNAXIS1 = 1024\nCDELT1 = 100070.42749198402 / Pixel scale on axis 1\nCRPIX1 = 522.0 / Reference pixel on axis 1\nCRVAL1 = 1421400352.0961409 / Value at ref. pixel on axis 1\nCTYPE1 = 'FREQ-LOG' / Type of co-ordinate on axis 1\nCUNIT1 = 'Hz ' / Units for axis 1\n-- read back FrameSet\ndomain SPECTRUM\npix 1 -> wcs 1370208256.8913562 -> pix 0.99999999999863576\npix 50 -> wcs 1374943271.3762357 -> pix 50.00000000000199\npix 100 -> wcs 1379791786.2541921 -> pix 100.00000000000051\npix 512 -> wcs 1420400000 -> pix 511.99999999999949\npix 1024 -> wcs 1472533970.5496306 -> pix 1024\n-- write FITS-IRAF\nwrote 1\nNAXIS = 1\nNAXIS1 = 1024\nCRPIX1 = 522.0 / Reference pixel on axis 1\nCRVAL1 = 1421400352.0961409 / Value at ref. pixel on axis 1\nCTYPE1 = 'FREQ-LOG' / Type of co-ordinate on axis 1\nCD1_1 = 100070.42749198402 / Transformation matrix element\nCUNIT1 = 'Hz ' / Units for axis 1\n-- read back FrameSet\ndomain SPECTRUM\npix 1 -> wcs 1370208256.8913562 -> pix 0.99999999999863576\npix 50 -> wcs 1374943271.3762357 -> pix 50.00000000000199\npix 100 -> wcs 1379791786.2541921 -> pix 100.00000000000051\npix 512 -> wcs 1420400000 -> pix 511.99999999999949\npix 1024 -> wcs 1472533970.5496306 -> pix 1024\n-- write FITS-AIPS\nwrote 0\nNAXIS = 1\nNAXIS1 = 1024\n-- write FITS-AIPS++\nwrote 0\nNAXIS = 1\nNAXIS1 = 1024\n-- write FITS-CLASS\nwrote 0\nNAXIS = 1\nNAXIS1 = 1024\n== vrad_log\nencoding FITS-WCS\n-- read\n Begin FrameSet \t# Set of inter-related coordinate systems\n# Title = \"Radio velocity (LSRK), rest frequency = 1.4204 GHz\" \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 = \"Radio velocity\" \t# Label for axis 1\n# System = \"VRAD\" \t# Coordinate system type\n# Uni1 = \"km/s\" \t# Units for axis 1\n IsA Frame \t# Coordinate system description\n Nframe = 2 \t# Number of Frames in FrameSet\n Base = 1 \t# Index of base Frame\n Currnt = 2 \t# Index of current Frame\n Lnk2 = 1 \t# Node 2 is derived from node 1\n Frm1 = \t# Frame number 1\n Begin Frame \t# Coordinate system description\n Title = \"Pixel Coordinates\" \t# Title of coordinate system\n Naxes = 1 \t# Number of coordinate axes\n Domain = \"GRID\" \t# Coordinate system domain\n# Lbl1 = \"Pixel axis 1\" \t# Label for axis 1\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n Label = \"Pixel axis 1\" \t# Axis Label\n End Axis\n End Frame\n Frm2 = \t# Frame number 2\n Begin SpecFrame \t# Description of spectral coordinate system\n Ident = \" \" \t# Permanent Object identification string\n IsA Object \t# AST Object\n# Title = \"Radio velocity (LSRK), rest frequency = 1.4204 GHz\" \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 = \"Radio velocity\" \t# Label for axis 1\n System = \"VRAD\" \t# Coordinate system type\n# Uni1 = \"km/s\" \t# Units for axis 1\n Ax1 = \t# Axis number 1\n Begin Axis \t# Coordinate axis\n Unit = \"km/s\" \t# Axis units\n End Axis\n IsA Frame \t# Coordinate system description\n SoR = \"LSRK\" \t# Standard of rest\n RstFrq = 1420400000 \t# Rest frequency (Hz)\n UVrad = \"km/s\" \t# Preferred units for radio velocity\n End SpecFrame\n Map2 = \t# Mapping between nodes 1 and 2\n Begin CmpMap \t# Compound 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 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 = -100 \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 MathMap \t# Transformation using mathematical functions\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Fwd1 = \"s=1000*exp(w/1000)\" \t# Forward function 1\n Inv1 = \"w=1000*log(s/1000)\" \t# Inverse function 1\n SimpFI = 1 \t# Forward-inverse pairs may simplify\n SimpIF = 1 \t# Inverse-forward pairs may simplify\n End MathMap\n End CmpMap\n End FrameSet\ndomain SPECTRUM\nsymbol(1) VRAD\npix 1 -> wcs 906.64890375392088 -> pix 1.0000000000000071\npix 50 -> wcs 1000 -> pix 50\npix 100 -> wcs 1105.1709180756477 -> pix 100.00000000000003\n-- write FITS-WCS\nwrote 1\nNAXIS = 1\nNAXIS1 = 100\nCRPIX1 = 53.0 / Reference pixel on axis 1\nCRVAL1 = 1006.018036054065 / Value at ref. pixel on axis 1\nCTYPE1 = 'VRAD-LOG' / Type of co-ordinate on axis 1\nCDELT1 = 2.012036072108129 / Pixel size on axis 1\nCUNIT1 = 'km/s ' / Units for axis 1\nSPECSYS = 'LSRK ' / Standard of rest for spectral axis\nVELOSYS = 29046.889455044307 / [m/s] Topo. apparent velocity of rest frame\nRESTFRQ = 1420400000.0 / [Hz] Rest frequency\n-- read back FrameSet\ndomain SPECTRUM\npix 1 -> wcs 906.6489037539211 -> pix 1.0000000000000071\npix 50 -> wcs 1000.0000000000001 -> pix 50.000000000000007\npix 100 -> wcs 1105.1709180756477 -> pix 99.999999999999972\n-- write FITS-PC\nwrote 1\nNAXIS = 1\nNAXIS1 = 100\nCDELT1 = 2.012036072108129 / Pixel scale on axis 1\nCRPIX1 = 53.0 / Reference pixel on axis 1\nCRVAL1 = 1006.018036054065 / Value at ref. pixel on axis 1\nCTYPE1 = 'VRAD-LOG' / Type of co-ordinate on axis 1\nCUNIT1 = 'km/s ' / Units for axis 1\n-- read back FrameSet\ndomain SPECTRUM\npix 1 -> wcs 906.6489037539211 -> pix 1.0000000000000071\npix 50 -> wcs 1000.0000000000001 -> pix 50.000000000000007\npix 100 -> wcs 1105.1709180756477 -> pix 99.999999999999972\n-- write FITS-IRAF\nwrote 1\nNAXIS = 1\nNAXIS1 = 100\nCRPIX1 = 53.0 / Reference pixel on axis 1\nCRVAL1 = 1006.018036054065 / Value at ref. pixel on axis 1\nCTYPE1 = 'VRAD-LOG' / Type of co-ordinate on axis 1\nCD1_1 = 2.012036072108129 / Transformation matrix element\nCUNIT1 = 'km/s ' / Units for axis 1\n-- read back FrameSet\ndomain SPECTRUM\npix 1 -> wcs 906.6489037539211 -> pix 1.0000000000000071\npix 50 -> wcs 1000.0000000000001 -> pix 50.000000000000007\npix 100 -> wcs 1105.1709180756477 -> pix 99.999999999999972\n-- write FITS-AIPS\nwrote 0\nNAXIS = 1\nNAXIS1 = 100\n-- write FITS-AIPS++\nwrote 0\nNAXIS = 1\nNAXIS1 = 100\n-- write FITS-CLASS\nwrote 0\nNAXIS = 1\nNAXIS1 = 100\n== write_other_exp\n-- write FITS-WCS\nwrote 1\nNAXIS = 1\nNAXIS1 = 100\nWCSNAME = 'WORLD ' / Reference name for the coord. frame\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRVAL1 = 16.48721270700128 / Value at ref. pixel on axis 1\nCTYPE1 = 'WORL-LOG' / Type of co-ordinate on axis 1\nCDELT1 = 0.16487212707001278 / Pixel size on axis 1\n-- read back FrameSet\ndomain WORLD\npix 1 -> wcs 10.10050167084168 -> pix 0.99999999999999289\npix 50 -> wcs 16.48721270700128 -> pix 49.999999999999993\npix 100 -> wcs 27.182818284590446 -> pix 99.999999999999986\n== write_freq_exp\n-- write FITS-WCS\nwrote 1\nNAXIS = 1\nNAXIS1 = 100\nCRPIX1 = 52.0 / Reference pixel on axis 1\nCRVAL1 = 1.4747260395187105 / Value at ref. pixel on axis 1\nCTYPE1 = 'FREQ-LOG' / Type of co-ordinate on axis 1\nCDELT1 = 0.0014747260395187112 / Pixel size on axis 1\nCUNIT1 = 'GHz ' / Units for axis 1\nSPECSYS = 'HELIOCEN' / Standard of rest for spectral axis\nVELOSYS = 29336.889452278185 / [m/s] Topo. apparent velocity of rest frame\n-- read back FrameSet\ndomain SPECTRUM\npix 1 -> wcs 1.4014007002333915 -> pix 0.99999999999995737\npix 50 -> wcs 1.4717795349264335 -> pix 50.000000000000014\npix 100 -> wcs 1.5472392853059067 -> pix 100.00000000000009\n== write_mathmap_freq\n-- write FITS-WCS\nwrote 1\nNAXIS = 1\nNAXIS1 = 1024\nCRPIX1 = 526.0 / Reference pixel on axis 1\nCRVAL1 = 1497112902.9813375 / Value at ref. pixel on axis 1\nCTYPE1 = 'FREQ-LOG' / Type of co-ordinate on axis 1\nCDELT1 = 149711.29029813374 / Pixel size on axis 1\nCUNIT1 = 'Hz ' / Units for axis 1\nSPECSYS = 'BARYCENT' / Standard of rest for spectral axis\nVELOSYS = 29327.576999852943 / [m/s] Topo. apparent velocity of rest frame\nRESTFRQ = 1420400000.0 / [Hz] Rest frequency\n-- read back FrameSet\ndomain SPECTRUM\npix 1 -> wcs 1420542047.1022367 -> pix 0.99999999999965894\npix 50 -> wcs 1427519784.6286931 -> pix 49.999999999998295\npix 100 -> wcs 1434675257.3263524 -> pix 99.999999999999773\npix 512 -> wcs 1495018411.4033685 -> pix 511.99999999999983\npix 1024 -> wcs 1573556780.0866318 -> pix 1024.0000000000005\n== write_log_unit\n-- write FITS-WCS\nwrote 1\nNAXIS = 2\nNAXIS1 = 100\nNAXIS2 = 100\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRPIX2 = 53.0 / Reference pixel on axis 2\nCRVAL1 = 50.0 / Value at ref. pixel on axis 1\nCRVAL2 = 1.0069316688518057 / Value at ref. pixel on axis 2\nCTYPE1 = 'x1 ' / Type of co-ordinate on axis 1\nCTYPE2 = 'FREQ-LOG' / Type of co-ordinate on axis 2\nCDELT1 = 1.0 / Pixel size on axis 1\nCDELT2 = 0.0023185458503617719 / Pixel size on axis 2\nCUNIT2 = 'GHz ' / Units for axis 2\nSPECSYS = 'HELIOCEN' / Standard of rest for spectral axis\nVELOSYS = 29336.889452278185 / [m/s] Topo. apparent velocity of rest frame\n-- read back FrameSet\ndomain X1-SPECTRUM\npix 1 1 -> wcs 1 0.89330548373329721 -> pix 1 0.99999999999997868\npix 50 1 -> wcs 50 0.89330548373329721 -> pix 50 0.99999999999997868\npix 100 1 -> wcs 100 0.89330548373329721 -> pix 100 0.99999999999997868\n== freq_log_head\npix 1 -> wcs 1420399999.4884999 -> pix 0.99983848147604704\npix 50 -> wcs 1420399999.5374999 -> pix 49.99995246463385\npix 100 -> wcs 1420399999.5875001 -> pix 100.00001727963905\npix 512 -> wcs 1420399999.9995 -> pix 512.0001034314156\npix 1024 -> wcs 1420400000.5114999 -> pix 1023.9998459421711\n-- write FITS-WCS\nwrote 1\nNAXIS = 1\nNAXIS1 = 1024\nCRPIX1 = 511.999956 / Reference pixel on axis 1\nCRVAL1 = 1.4204 / Value at ref. pixel on axis 1\nCTYPE1 = 'FREQ ' / Type of co-ordinate on axis 1\nCDELT1 = 1.000000023045475E-12 / Pixel size on axis 1\nCUNIT1 = 'GHz ' / Units for axis 1\n-- read back FrameSet\ndomain SPECTRUM\npix 1 -> wcs 1.4203999994885002 -> pix 1.000244140625\npix 50 -> wcs 1.4203999995375001 -> pix 50\npix 100 -> wcs 1.4203999995875001 -> pix 100\npix 512 -> wcs 1.4203999999995001 -> pix 512\npix 1024 -> wcs 1.4204000005115001 -> pix 1024\n== freq_log_head_unit\nunit before Hz test 1\nwrote 1\nunit after Hz test 1\n== write_log_unit_unitmap\n-- write FITS-WCS\nwrote 1\nNAXIS = 2\nNAXIS1 = 100\nNAXIS2 = 100\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRPIX2 = 100.0 / Reference pixel on axis 2\nCRVAL1 = 50.0 / Value at ref. pixel on axis 1\nCRVAL2 = 1.0E+91 / Value at ref. pixel on axis 2\nCTYPE1 = 'x1 ' / Type of co-ordinate on axis 1\nCTYPE2 = 'FREQ-LOG' / Type of co-ordinate on axis 2\nCDELT1 = 1.0 / Pixel size on axis 1\nCDELT2 = 2.3025850929940716E+91 / Pixel size on axis 2\nCUNIT2 = 'GHz ' / Units for axis 2\nSPECSYS = 'HELIOCEN' / Standard of rest for spectral axis\nVELOSYS = 29336.889452278185 / [m/s] Topo. apparent velocity of rest frame\n-- read back FrameSet\ndomain X1-SPECTRUM\npix 1 1 -> wcs 1 9.9999999999999043e-09 -> pix 1 1.0000000000000142\npix 50 1 -> wcs 50 9.9999999999999043e-09 -> pix 50 1.0000000000000142\npix 100 1 -> wcs 100 9.9999999999999043e-09 -> pix 100 1.0000000000000142\nunit after log(Hz)\n" +} diff --git a/src/test/resources/probes/grismmap_probe.c b/src/test/resources/probes/grismmap_probe.c new file mode 100644 index 0000000..11b149b --- /dev/null +++ b/src/test/resources/probes/grismmap_probe.c @@ -0,0 +1,547 @@ +/* grismmap_probe -- GrismMap behaviour of the pinned C library that no + * fixture or oracle holds: attribute values, tests, clears and settings + * (a fractional or bad value, a GrismMap shared by a CmpMap); native dumps + * with each attribute set and unset, read back through a Channel; + * transformations, a rate and astEqual; simplification beside ZoomMaps, + * WinMaps and another GrismMap; and FITS headers with -GRI and -GRA axes + * read with each encoding and written back, and FrameSets holding a + * GrismMap written as FITS-WCS. + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * Built against the C library at 3d3f255f with its static libraries: + * cc -std=c11 -I -o grismmap_probe grismmap_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 ./grismmap_probe > out 2>&1, then trailing white space removed + * from every line (the tests compare lines without it). The output is kept + * as the string "output" of grismmap_probe.json, since the spelling check of + * text files rejects a spelling in the FITS comments C writes. */ +#include +#include +#include +#include "ast.h" + +/* The lines a Channel writes, which a second Channel reads back. */ +#define MAXLINES 400 +static char *lines[ MAXLINES ]; +static int nline = 0; +static int iline = 0; + +static void sink( const char *line ) { + if( nline < MAXLINES ) lines[ nline++ ] = strcpy( malloc( strlen( line ) + 1 ), line ); +} + +static const char *source( void ) { + return ( iline < nline ) ? lines[ iline++ ] : NULL; +} + +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 const char *attrs[] = { "GrismNR", "GrismNRP", "GrismWaveR", "GrismAlpha", + "GrismG", "GrismM", "GrismEps", "GrismTheta" }; + +/* Each attribute: whether it is set and its value as astGetC gives it. */ +static void attributes( AstMapping *m ) { + for( int i = 0; i < 8; i++ ) { + int t = astTest( m, attrs[ i ] ); + const char *v = astGetC( m, attrs[ i ] ); + if( failed() ) return; + printf( "%s %d %s\n", attrs[ i ], t, v ); + } +} + +/* The forward transformation of xf and the inverse of xi, given to every + coordinate. */ +static void tran( AstMapping *m, double xf, double xi ) { + double in[ 2 ], out[ 2 ]; + int n = astGetI( m, "Nin" ); + for( int i = 0; i < n; i++ ) in[ i ] = xf; + astTranN( m, 1, n, 1, in, 1, n, 1, out ); + if( failed() ) return; + printf( "fwd" ); + for( int i = 0; i < n; i++ ) printf( " %.17g", in[ i ] ); + printf( " ->" ); + for( int i = 0; i < n; i++ ) printf( " %.17g", out[ i ] ); + printf( "\n" ); + for( int i = 0; i < n; i++ ) in[ i ] = xi; + astTranN( m, 1, n, 1, in, 0, n, 1, out ); + if( failed() ) return; + printf( "inv" ); + for( int i = 0; i < n; i++ ) printf( " %.17g", in[ i ] ); + printf( " ->" ); + for( int i = 0; i < n; i++ ) printf( " %.17g", out[ i ] ); + printf( "\n" ); +} + +/* A GrismMap with every attribute set, wavelengths in Angstrom. */ +static AstGrismMap *typical( void ) { + return astGrismMap( "GrismNR=1.5,GrismNRP=-1.0E-6,GrismWaveR=5000,GrismAlpha=0.1," + "GrismG=2.0E-4,GrismM=1,GrismEps=0.02,GrismTheta=0.03" ); +} + +/* The same with GrismM set to m. */ +static AstGrismMap *typical_m( int m ) { + AstGrismMap *g = typical(); + astSetI( g, "GrismM", m ); + return g; +} + +static AstMapping *inv( AstMapping *m ) { + astInvert( m ); + return m; +} + +/* The dump, the Object read back from it through a Channel and that + Object's dump, then the transformations of both. */ +static void roundtrip( const char *name, AstMapping *m, double xf, double xi ) { + head( name ); + astShow( m ); + for( int i = 0; i < nline; i++ ) free( lines[ i ] ); + nline = iline = 0; + AstChannel *ch = astChannel( source, sink, " " ); + astWrite( ch, m ); + AstMapping *back = astRead( ch ); + if( failed() ) return; + printf( "-- read back\n" ); + astShow( back ); + printf( "-- equal %d\n", astEqual( m, back ) ); + printf( "-- transformations\n" ); + tran( m, xf, xi ); + printf( "-- transformations read back\n" ); + tran( back, xf, xi ); + ch = astAnnul( ch ); +} + +/* The class of the simplified Mapping, its dump, and the transformations + of the original and the simplified Mapping. */ +static void simp( const char *name, AstMapping *m, double xf, double xi ) { + head( name ); + AstMapping *s = astSimplify( m ); + if( failed() ) return; + printf( "class %s\n", astGetC( s, "Class" ) ); + astShow( s ); + printf( "-- transformations\n" ); + tran( m, xf, xi ); + printf( "-- transformations simplified\n" ); + tran( s, xf, xi ); +} + +static AstZoomMap *zoom( double f ) { + return astZoomMap( 1, f, " " ); +} + +static AstWinMap *win( double scale, double shift ) { + double ina[] = { 0.0 }, inb[] = { 1.0 }; + double outa[] = { shift }, outb[] = { shift + scale }; + return astWinMap( 1, ina, inb, outa, outb, " " ); +} + +static AstCmpMap *series( void *a, void *b ) { + return astCmpMap( a, b, 1, " " ); +} + +/* The cards of a FitsChan. */ +static void cards( AstFitsChan *fc ) { + char card[ 81 ]; + astClear( fc, "Card" ); + while( astFindFits( fc, "%f", card, 1 ) ) printf( "%s\n", card ); +} + +/* The forward transformation of pixels 1, 50 and 100, and the inverse of + the results. */ +static void pixels( AstFrameSet *fs ) { + double pix[] = { 1.0, 50.0, 100.0 }, w[ 3 ], back[ 3 ]; + astTran1( fs, 3, pix, 1, w ); + astTran1( fs, 3, w, 0, back ); + if( failed() ) return; + for( int i = 0; i < 3; i++ ) printf( "pixel %.17g -> %.17g -> %.17g\n", pix[ i ], w[ i ], back[ i ] ); +} + +/* Reads the header with the encoding, then writes what it read with that + encoding and reads the cards written back with it. */ +static void fitsrw( const char *name, const char *encoding, const char **header ) { + head( name ); + AstFitsChan *fc = astFitsChan( NULL, NULL, " " ); + for( int i = 0; header[ i ]; i++ ) astPutFits( fc, header[ i ], 0 ); + astSetC( fc, "Encoding", encoding ); + astClear( fc, "Card" ); + AstFrameSet *fs = astRead( fc ); + if( failed() ) return; + if( !fs ) { + printf( "read nothing\n" ); + return; + } + printf( "read %s\n", astGetC( fs, "Class" ) ); + pixels( fs ); + AstMapping *map = astGetMapping( fs, AST__BASE, AST__CURRENT ); + astShow( astSimplify( map ) ); + AstFitsChan *out = astFitsChan( NULL, NULL, " " ); + astSetC( out, "Encoding", encoding ); + int n = astWrite( out, fs ); + if( failed() ) return; + printf( "-- written %d\n", n ); + cards( out ); + if( n ) { + astClear( out, "Card" ); + AstFrameSet *back = astRead( out ); + if( failed() ) return; + if( !back ) { + printf( "-- read back nothing\n" ); + return; + } + printf( "-- read back %s\n", astGetC( back, "Class" ) ); + pixels( back ); + } +} + +/* Writes a FrameSet from a GRID Frame to a SpecFrame through the Mapping + as FITS-WCS, and reads back what is written. */ +static void fitswrite( const char *name, AstMapping *map, const char *specattrs ) { + head( name ); + AstFrameSet *fs = astFrameSet( astFrame( 1, "Domain=GRID" ), " " ); + astAddFrame( fs, AST__BASE, map, astSpecFrame( specattrs ) ); + AstFitsChan *out = astFitsChan( NULL, NULL, "Encoding=FITS-WCS" ); + int n = astWrite( out, fs ); + if( failed() ) return; + printf( "written %d\n", n ); + cards( out ); + pixels( fs ); + if( n ) { + astClear( out, "Card" ); + AstFrameSet *back = astRead( out ); + if( failed() ) return; + printf( "-- read back\n" ); + pixels( back ); + } +} + +int main( void ) { + int status = 0; + setvbuf( stdout, NULL, _IONBF, 0 ); + astWatch( &status ); + astBegin; + + /* Attributes. */ + head( "attributes_default" ); + attributes( (AstMapping *) astGrismMap( " " ) ); + head( "attributes_set" ); + attributes( (AstMapping *) typical() ); + head( "attributes_cleared" ); + { + AstGrismMap *g = typical(); + astClear( g, "GrismNR,GrismNRP,GrismWaveR,GrismAlpha,GrismG,GrismM,GrismEps,GrismTheta" ); + attributes( (AstMapping *) g ); + } + head( "attributes_set_to_defaults" ); + attributes( (AstMapping *) astGrismMap( "GrismNR=1,GrismNRP=0,GrismWaveR=5000,GrismAlpha=0," + "GrismG=0,GrismM=0,GrismEps=0,GrismTheta=0" ) ); + head( "set_m_fraction" ); + { + AstGrismMap *g = astGrismMap( " " ); + astSet( g, "GrismM=2.7" ); + printf( "2.7 -> %s\n", astGetC( g, "GrismM" ) ); + astSet( g, "GrismM=-2.7" ); + printf( "-2.7 -> %s\n", astGetC( g, "GrismM" ) ); + astSetD( g, "GrismM", 3.5 ); + printf( "setd 3.5 -> %s\n", astGetC( g, "GrismM" ) ); + printf( "getd %.17g\n", astGetD( g, "GrismM" ) ); + failed(); + } + head( "set_bad_unsets" ); + { + AstGrismMap *g = typical(); + astSetD( g, "GrismNR", AST__BAD ); + astSetD( g, "GrismTheta", AST__BAD ); + attributes( (AstMapping *) g ); + } + head( "set_m_int_max_unsets" ); + { + AstGrismMap *g = typical(); + astSetI( g, "GrismM", 2147483647 ); + attributes( (AstMapping *) g ); + } + head( "set_not_a_number" ); + { + AstGrismMap *g = astGrismMap( " " ); + astSet( g, "GrismNR=abc" ); + failed(); + } + head( "shared_set" ); + { + AstGrismMap *g = typical(); + AstCmpMap *c = series( g, zoom( 2.0 ) ); + astSetD( g, "GrismNR", 2.0 ); + failed(); + astClear( g, "GrismM" ); + failed(); + printf( "GrismNR %s\n", astGetC( g, "GrismNR" ) ); + astInvert( g ); + failed(); + printf( "Invert %d\n", astGetI( g, "Invert" ) ); + AstGrismMap *copy = astCopy( g ); + astSetD( copy, "GrismNR", 2.0 ); + failed(); + printf( "copy GrismNR %s\n", astGetC( copy, "GrismNR" ) ); + c = astAnnul( c ); + } + + /* Native dumps, each attribute set alone and each cleared from a + GrismMap with all set. */ + roundtrip( "dump_default", (AstMapping *) astGrismMap( " " ), 0.01, 5100.0 ); + roundtrip( "dump_all_set", (AstMapping *) typical(), 0.01, 5100.0 ); + roundtrip( "dump_inverted", inv( (AstMapping *) typical() ), 5100.0, 0.01 ); + { + const char *one[] = { "GrismNR=1.5", "GrismNRP=-1.0E-6", "GrismWaveR=5000", "GrismAlpha=0.1", + "GrismG=2.0E-4", "GrismM=1", "GrismEps=0.02", "GrismTheta=0.03" }; + char name[ 64 ]; + for( int i = 0; i < 8; i++ ) { + snprintf( name, sizeof( name ), "dump_only_%s", attrs[ i ] ); + roundtrip( name, (AstMapping *) astGrismMap( one[ i ] ), 0.01, 5100.0 ); + } + for( int i = 0; i < 8; i++ ) { + AstGrismMap *g = typical(); + astClear( g, attrs[ i ] ); + snprintf( name, sizeof( name ), "dump_without_%s", attrs[ i ] ); + roundtrip( name, (AstMapping *) g, 0.01, 5100.0 ); + } + } + { + AstGrismMap *g = typical(); + astSetI( g, "GrismM", -2 ); + roundtrip( "dump_negative_order", (AstMapping *) g, 0.01, 5100.0 ); + } + + roundtrip( "dump_simplified", (AstMapping *) astSimplify( typical() ), 0.01, 5100.0 ); + head( "split" ); + { + int in[] = { 1 }, out[ 1 ]; + AstMapping *s; + astMapSplit( inv( (AstMapping *) typical() ), 1, in, out, &s ); + printf( "output %d\n", out[ 0 ] ); + astShow( s ); + failed(); + } + + /* Transformations. */ + head( "transformations" ); + { + AstGrismMap *g = typical(); + double gp[] = { 0.0, 0.01, -0.01, 0.05, AST__BAD }; + double wl[] = { 4900.0, 5000.0, 5100.0, 5200.0, AST__BAD }; + double out[ 5 ]; + astTran1( g, 5, gp, 1, out ); + for( int i = 0; i < 5; i++ ) printf( "fwd %.17g -> %.17g\n", gp[ i ], out[ i ] ); + astTran1( g, 5, wl, 0, out ); + for( int i = 0; i < 5; i++ ) printf( "inv %.17g -> %.17g\n", wl[ i ], out[ i ] ); + double far[] = { 1.0e6, -1.0e6 }; + astTran1( g, 2, far, 0, out ); + for( int i = 0; i < 2; i++ ) printf( "inv %.17g -> %.17g\n", far[ i ], out[ i ] ); + AstGrismMap *d = astGrismMap( " " ); + double dp[] = { 0.0, 0.5 }; + astTran1( d, 2, dp, 1, out ); + for( int i = 0; i < 2; i++ ) printf( "default fwd %.17g -> %.17g\n", dp[ i ], out[ i ] ); + astTran1( d, 2, wl, 0, out ); + for( int i = 0; i < 2; i++ ) printf( "default inv %.17g -> %.17g\n", wl[ i ], out[ i ] ); + AstGrismMap *e = typical(); + astSetD( e, "GrismEps", 1.5707963267948966 ); + astTran1( e, 2, dp, 1, out ); + for( int i = 0; i < 2; i++ ) printf( "eps 90 fwd %.17g -> %.17g\n", dp[ i ], out[ i ] ); + AstGrismMap *b = typical(); + astSetD( b, "GrismG", 1.0 ); + astTran1( b, 2, dp, 1, out ); + for( int i = 0; i < 2; i++ ) printf( "sinbeta_r over 1 fwd %.17g -> %.17g\n", dp[ i ], out[ i ] ); + failed(); + } + head( "rate" ); + { + double at[] = { 0.0 }; + AstGrismMap *g = typical(); + printf( "fwd %.17g\n", astRate( g, at, 1, 1 ) ); + double atw[] = { 5100.0 }; + printf( "inv %.17g\n", astRate( inv( (AstMapping *) g ), atw, 1, 1 ) ); + failed(); + } + + /* Equality. */ + head( "equal" ); + { + AstGrismMap *a = typical(); + printf( "same %d\n", astEqual( a, typical() ) ); + printf( "copy %d\n", astEqual( a, astCopy( a ) ) ); + AstGrismMap *b = typical(); + astSetD( b, "GrismNR", 1.6 ); + printf( "different_nr %d\n", astEqual( a, b ) ); + printf( "different_m %d\n", astEqual( a, typical_m( -1 ) ) ); + printf( "inverted %d\n", astEqual( a, inv( (AstMapping *) typical() ) ) ); + printf( "both_inverted %d\n", astEqual( inv( (AstMapping *) typical() ), inv( (AstMapping *) typical() ) ) ); + printf( "default %d\n", astEqual( astGrismMap( " " ), astGrismMap( " " ) ) ); + printf( "default_vs_set_to_defaults %d\n", + astEqual( astGrismMap( " " ), + astGrismMap( "GrismNR=1,GrismNRP=0,GrismWaveR=5000,GrismAlpha=0," + "GrismG=0,GrismM=0,GrismEps=0,GrismTheta=0" ) ) ); + printf( "not_a_grismmap %d\n", astEqual( a, zoom( 2.0 ) ) ); + failed(); + } + + /* Simplification. */ + simp( "zoom_after_forward", (AstMapping *) series( typical(), zoom( 2.0 ) ), 0.01, 10200.0 ); + simp( "inverted_zoom_after_forward", (AstMapping *) series( typical(), inv( (AstMapping *) zoom( 2.0 ) ) ), + 0.01, 2550.0 ); + simp( "zoom_before_inverted", (AstMapping *) series( zoom( 0.5 ), inv( (AstMapping *) typical() ) ), + 10200.0, 0.01 ); + simp( "inverted_zoom_before_inverted", + (AstMapping *) series( inv( (AstMapping *) zoom( 2.0 ) ), inv( (AstMapping *) typical() ) ), 10200.0, 0.01 ); + simp( "zoom_before_forward", (AstMapping *) series( zoom( 2.0 ), typical() ), 0.01, 5100.0 ); + simp( "zoom_after_inverted", (AstMapping *) series( inv( (AstMapping *) typical() ), zoom( 2.0 ) ), 5100.0, 0.01 ); + simp( "zooms_both_sides", + (AstMapping *) series( series( zoom( 0.5 ), inv( (AstMapping *) typical() ) ), zoom( 3.0 ) ), 10200.0, 0.03 ); + simp( "zoom_forward_zoom", (AstMapping *) series( series( zoom( 3.0 ), typical() ), zoom( 2.0 ) ), 0.01, 10200.0 ); + { + AstZoomMap *z = zoom( 2.0 ); + AstCmpMap *c = series( typical(), z ); + astInvert( z ); + simp( "zoom_inverted_after_combining", (AstMapping *) c, 0.01, 10200.0 ); + } + { + AstZoomMap *z = zoom( 2.0 ); + AstCmpMap *c = series( z, inv( (AstMapping *) typical() ) ); + astInvert( z ); + simp( "zoom_inverted_after_combining_before", (AstMapping *) c, 10200.0, 0.01 ); + } + { + AstGrismMap *g = typical(); + AstCmpMap *c = series( g, zoom( 2.0 ) ); + astInvert( g ); + simp( "grism_inverted_after_combining", (AstMapping *) c, 0.01, 10200.0 ); + } + simp( "zoom_after_default", (AstMapping *) series( astGrismMap( " " ), zoom( 2.0 ) ), 0.01, 10200.0 ); + simp( "zoom_after_two_grisms", + (AstMapping *) series( series( typical(), inv( (AstMapping *) typical_m( 2 ) ) ), zoom( 2.0 ) ), 0.01, 0.02 ); + simp( "winmap_scale_after_forward", (AstMapping *) series( typical(), win( 2.0, 0.0 ) ), 0.01, 10200.0 ); + simp( "winmap_after_forward", (AstMapping *) series( typical(), win( 2.0, 10.0 ) ), 0.01, 10210.0 ); + simp( "winmap_scale_before_inverted", (AstMapping *) series( win( 0.5, 0.0 ), inv( (AstMapping *) typical() ) ), + 10200.0, 0.01 ); + simp( "winmap_before_inverted", (AstMapping *) series( win( 0.5, -5.0 ), inv( (AstMapping *) typical() ) ), + 10210.0, 0.01 ); + simp( "shiftmap_after_forward", (AstMapping *) series( typical(), astShiftMap( 1, (double[]){ 10.0 }, " " ) ), + 0.01, 5110.0 ); + simp( "inverse_cancel", (AstMapping *) series( typical(), inv( (AstMapping *) typical_m( -1 ) ) ), 0.01, 0.01 ); + simp( "inverse_cancel_lower", (AstMapping *) series( inv( (AstMapping *) typical_m( -1 ) ), typical() ), + 5100.0, 5100.0 ); + simp( "inverse_same_order", (AstMapping *) series( typical(), inv( (AstMapping *) typical() ) ), 0.01, 0.01 ); + { + AstGrismMap *b = typical_m( -1 ); + astSetD( b, "GrismNR", 1.6 ); + simp( "inverse_different_nr", (AstMapping *) series( typical(), inv( (AstMapping *) b ) ), 0.01, 0.01 ); + } + simp( "same_direction", (AstMapping *) series( typical(), typical_m( -1 ) ), 0.0, 0.0 ); + simp( "parallel", (AstMapping *) astCmpMap( typical(), inv( (AstMapping *) typical_m( -1 ) ), 0, " " ), 0.01, 0.01 ); + simp( "parallel_zoom", (AstMapping *) astCmpMap( typical(), zoom( 2.0 ), 0, " " ), 0.01, 0.01 ); + simp( "alone", (AstMapping *) typical(), 0.01, 5100.0 ); + simp( "alone_inverted", inv( (AstMapping *) typical() ), 5100.0, 0.01 ); + { + AstGrismMap *g = typical(); + simp( "shared_pair", (AstMapping *) series( g, inv( (AstMapping *) astCopy( g ) ) ), 0.01, 0.01 ); + } + + /* FITS headers with grism axes. */ + { + const char *encodings[] = { "FITS-WCS", "FITS-PC", "FITS-IRAF", "FITS-AIPS", "FITS-AIPS++", + "FITS-CLASS", "NATIVE", "DSS" }; + const char *gri[] = { "CTYPE1 = 'WAVE-GRI'", "CRVAL1 = 5.0E-7", + "CRPIX1 = 1.0", "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", "PV1_0 = 9.0E5", + "PV1_1 = 1.0", "PV1_2 = 0.0", + "PV1_3 = 1.0", "PV1_4 = 0.0", + "PV1_5 = 0.0", "PV1_6 = 0.0", NULL }; + const char *gra[] = { "CTYPE1 = 'AWAV-GRA'", "CRVAL1 = 5.0E-7", + "CRPIX1 = 10.0", "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", "PV1_0 = 6.0E5", + "PV1_1 = -2.0", "PV1_2 = 10.0", + "PV1_3 = 1.5", "PV1_4 = -100.0", + "PV1_5 = 2.0", "PV1_6 = 3.0", NULL }; + char name[ 64 ]; + for( int i = 0; i < 8; i++ ) { + snprintf( name, sizeof( name ), "fits_gri_%s", encodings[ i ] ); + fitsrw( name, encodings[ i ], gri ); + snprintf( name, sizeof( name ), "fits_gra_%s", encodings[ i ] ); + fitsrw( name, encodings[ i ], gra ); + } + const char *grawave[] = { "CTYPE1 = 'WAVE-GRA'", "CRVAL1 = 5.0E-7", + "CRPIX1 = 1.0", "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", "PV1_0 = 9.0E5", + "PV1_1 = 1.0", NULL }; + fitsrw( "fits_wave_gra", "FITS-WCS", grawave ); + const char *freq[] = { "CTYPE1 = 'FREQ-GRI'", "CRVAL1 = 6.0E14", + "CRPIX1 = 1.0", "CDELT1 = 1.0E12", + "CUNIT1 = 'Hz '", "PV1_0 = 9.0E5", + "PV1_1 = 1.0", NULL }; + fitsrw( "fits_freq_gri", "FITS-WCS", freq ); + const char *nm[] = { "CTYPE1 = 'WAVE-GRI'", "CRVAL1 = 500.0", + "CRPIX1 = 1.0", "CDELT1 = 1.0", + "CUNIT1 = 'nm '", "PV1_0 = 9.0E5", + "PV1_1 = 1.0", NULL }; + fitsrw( "fits_gri_nm", "FITS-WCS", nm ); + const char *noconv[] = { "CTYPE1 = 'VRAD-GRI'", "CRVAL1 = 100.0", + "CRPIX1 = 1.0", "CDELT1 = 1.0", + "PV1_0 = 9.0E5", "PV1_1 = 1.0", NULL }; + fitsrw( "fits_vrad_gri", "FITS-WCS", noconv ); + const char *order[] = { "CTYPE1 = 'WAVE-GRI'", "CRVAL1 = 5.0E-7", + "CRPIX1 = 1.0", "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", "PV1_0 = 9.0E5", + "PV1_1 = 1.5", NULL }; + fitsrw( "fits_gri_half_order", "FITS-WCS", order ); + const char *order2[] = { "CTYPE1 = 'WAVE-GRI'", "CRVAL1 = 5.0E-7", + "CRPIX1 = 1.0", "CDELT1 = 1.0E-9", + "CUNIT1 = 'm '", "PV1_0 = 9.0E5", + "PV1_1 = -2.5", NULL }; + fitsrw( "fits_gri_negative_half_order", "FITS-WCS", order2 ); + } + + /* FrameSets holding a GrismMap, written as FITS-WCS. */ + { + AstGrismMap *g = astGrismMap( "GrismG=9.0E5,GrismM=1,GrismWaveR=5.0E-7" ); + fitswrite( "write_shift_zoom_grism", + (AstMapping *) series( series( astShiftMap( 1, (double[]){ -50.0 }, " " ), zoom( 0.002 ) ), g ), + "System=WAVE,Unit=m" ); + AstGrismMap *g2 = astGrismMap( "GrismG=9.0E5,GrismM=1,GrismWaveR=5.0E-7" ); + fitswrite( "write_grism_then_zoom_nm", + (AstMapping *) series( series( astShiftMap( 1, (double[]){ -50.0 }, " " ), zoom( 0.002 ) ), + series( g2, zoom( 1.0E9 ) ) ), + "System=WAVE,Unit=nm" ); + AstGrismMap *g3 = astGrismMap( "GrismG=9.0E5,GrismM=1,GrismWaveR=5.0E-7" ); + AstSpecMap *w2f = astSpecMap( 1, 0, " " ); + astSpecAdd( w2f, "WVTOFR", 0, NULL ); + fitswrite( "write_grism_freq", + (AstMapping *) series( series( astShiftMap( 1, (double[]){ -50.0 }, " " ), zoom( 0.002 ) ), + series( g3, w2f ) ), + "System=FREQ,Unit=Hz" ); + AstGrismMap *g4 = astGrismMap( "GrismG=9.0E5,GrismM=1,GrismWaveR=5.0E-7" ); + fitswrite( "write_grism_then_shift", + (AstMapping *) series( series( series( astShiftMap( 1, (double[]){ -50.0 }, " " ), zoom( 0.002 ) ), g4 ), + astShiftMap( 1, (double[]){ 1.0E-9 }, " " ) ), + "System=WAVE,Unit=m" ); + AstGrismMap *g5 = astGrismMap( "GrismG=9.0E5,GrismM=1,GrismWaveR=5.0E-7" ); + fitswrite( "write_grism_inverted", + (AstMapping *) series( series( astShiftMap( 1, (double[]){ -50.0 }, " " ), zoom( 0.002 ) ), + inv( (AstMapping *) inv( (AstMapping *) g5 ) ) ), + "System=WAVE,Unit=m" ); + } + + astEnd; + return 0; +} diff --git a/src/test/resources/probes/grismmap_probe.json b/src/test/resources/probes/grismmap_probe.json new file mode 100644 index 0000000..105880c --- /dev/null +++ b/src/test/resources/probes/grismmap_probe.json @@ -0,0 +1,4 @@ +{ + "source": "probes/grismmap_probe.c", + "output": "== attributes_default\nGrismNR 0 1\nGrismNRP 0 0\nGrismWaveR 0 5000\nGrismAlpha 0 0\nGrismG 0 0\nGrismM 0 0\nGrismEps 0 0\nGrismTheta 0 0\n== attributes_set\nGrismNR 1 1.5\nGrismNRP 1 -9.9999999999999995e-07\nGrismWaveR 1 5000\nGrismAlpha 1 0.10000000000000001\nGrismG 1 0.00020000000000000001\nGrismM 1 1\nGrismEps 1 0.02\nGrismTheta 1 0.029999999999999999\n== attributes_cleared\nGrismNR 0 1\nGrismNRP 0 0\nGrismWaveR 0 5000\nGrismAlpha 0 0\nGrismG 0 0\nGrismM 0 0\nGrismEps 0 0\nGrismTheta 0 0\n== attributes_set_to_defaults\nGrismNR 1 1\nGrismNRP 1 0\nGrismWaveR 1 5000\nGrismAlpha 1 0\nGrismG 1 0\nGrismM 1 0\nGrismEps 1 0\nGrismTheta 1 0\n== set_m_fraction\n2.7 -> 2\n-2.7 -> -2\nsetd 3.5 -> 3\ngetd 3\n== set_bad_unsets\nGrismNR 0 1\nGrismNRP 1 -9.9999999999999995e-07\nGrismWaveR 1 5000\nGrismAlpha 1 0.10000000000000001\nGrismG 1 0.00020000000000000001\nGrismM 1 1\nGrismEps 1 0.02\nGrismTheta 0 0\n== set_m_int_max_unsets\nGrismNR 1 1.5\nGrismNRP 1 -9.9999999999999995e-07\nGrismWaveR 1 5000\nGrismAlpha 1 0.10000000000000001\nGrismG 1 0.00020000000000000001\nGrismM 0 0\nGrismEps 1 0.02\nGrismTheta 1 0.029999999999999999\n== set_not_a_number\n!! AST: Error in routine main at line 280 in file src/test/resources/probes/grismmap_probe.c.\n! astSet: The attribute setting \"grismnr=abc\" is invalid for a GrismMap.\nstatus 233933186\n== shared_set\n!! AST: Error in routine main at line 287 in file src/test/resources/probes/grismmap_probe.c.\n! astSet(GrismMap): The GrismNRattribute of the supplied GrismMap cannot be changed because the GrismMap has been cloned (programming error).\nstatus 233934418\n!! AST: Error in routine main at line 289 in file src/test/resources/probes/grismmap_probe.c.\n! astClear(GrismMap): The GrismMattribute of the supplied GrismMap cannot be cleared because the GrismMap has been cloned (programming error).\nstatus 233934418\nGrismNR 1.5\nInvert 1\ncopy GrismNR 2\n== dump_default\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n-- transformations read back\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n== dump_all_set\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> 5101.7098721896446\ninv 5100 -> 0.0093042794386218701\n-- transformations read back\nfwd 0.01 -> 5101.7098721896446\ninv 5100 -> 0.0093042794386218701\n== dump_inverted\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 5100 -> 0.0093042794386218701\ninv 0.01 -> 5101.7098721896446\n-- transformations read back\nfwd 5100 -> 0.0093042794386218701\ninv 0.01 -> 5101.7098721896446\n== dump_only_GrismNR\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n-- transformations read back\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n== dump_only_GrismNRP\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n-- transformations read back\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n== dump_only_GrismWaveR\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n-- transformations read back\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n== dump_only_GrismAlpha\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n-- transformations read back\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n== dump_only_GrismG\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n-- transformations read back\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n== dump_only_GrismM\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n-- transformations read back\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n== dump_only_GrismEps\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n-- transformations read back\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> 0\n== dump_only_GrismTheta\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> -0.030009003241180714\n-- transformations read back\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> -0.030009003241180714\n== dump_without_GrismNR\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n# GrmNR = 1 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> 5083.343292806202\ninv 5100 -> 0.018443484990092188\n-- transformations read back\nfwd 0.01 -> 5083.343292806202\ninv 5100 -> 0.018443484990092188\n== dump_without_GrismNRP\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n# GrmNRP = 0 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> 5101.760632256176\ninv 5100 -> 0.0092839962806251543\n-- transformations read back\nfwd 0.01 -> 5101.760632256176\ninv 5100 -> 0.0092839962806251543\n== dump_without_GrismWaveR\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n# GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> 5101.7098721896446\ninv 5100 -> 0.0093042794386218701\n-- transformations read back\nfwd 0.01 -> 5101.7098721896446\ninv 5100 -> 0.0093042794386218701\n== dump_without_GrismAlpha\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> -1.7976931348623157e+308\n-- transformations read back\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> -1.7976931348623157e+308\n== dump_without_GrismG\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n# GrmG = 0 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> 402240.35908260307\ninv 5100 -> -0.02999889696008903\n-- transformations read back\nfwd 0.01 -> 402240.35908260307\ninv 5100 -> -0.02999889696008903\n== dump_without_GrismM\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> 402240.35908260307\ninv 5100 -> -0.02999889696008903\n-- transformations read back\nfwd 0.01 -> 402240.35908260307\ninv 5100 -> -0.02999889696008903\n== dump_without_GrismEps\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> 5101.7956064141199\ninv 5100 -> 0.0092700549245915611\n-- transformations read back\nfwd 0.01 -> 5101.7956064141199\ninv 5100 -> 0.0092700549245915611\n== dump_without_GrismTheta\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> 5026.0706616247871\ninv 5100 -> 0.039324262491752082\n-- transformations read back\nfwd 0.01 -> 5026.0706616247871\ninv 5100 -> 0.039324262491752082\n== dump_negative_order\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = -2 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = -2 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> -1.7976931348623157e+308\n-- transformations read back\nfwd 0.01 -> -1.7976931348623157e+308\ninv 5100 -> -1.7976931348623157e+308\n== dump_simplified\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\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 GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- read back\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\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 GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- equal 1\n-- transformations\nfwd 0.01 -> 5101.7098721896446\ninv 5100 -> 0.0093042794386218701\n-- transformations read back\nfwd 0.01 -> 5101.7098721896446\ninv 5100 -> 0.0093042794386218701\n== split\noutput 1\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n== transformations\nfwd 0 -> 5076.9294118588923\nfwd 0.01 -> 5101.7098721896446\nfwd -0.01 -> 5051.7163631863532\nfwd 0.050000000000000003 -> 5196.3658468601716\nfwd -1.7976931348623157e+308 -> -1.7976931348623157e+308\ninv 4900 -> -0.067050465022329642\ninv 5000 -> -0.030009003241180741\ninv 5100 -> 0.0093042794386218701\ninv 5200 -> 0.051600080957845434\ninv -1.7976931348623157e+308 -> -1.7976931348623157e+308\ninv 1000000 -> -1.7976931348623157e+308\ninv -1000000 -> -1.7976931348623157e+308\ndefault fwd 0 -> -1.7976931348623157e+308\ndefault fwd 0.5 -> -1.7976931348623157e+308\ndefault inv 4900 -> 0\ndefault inv 5000 -> 0\neps 90 fwd 0 -> -1.7976931348623157e+308\neps 90 fwd 0.5 -> -1.7976931348623157e+308\nsinbeta_r over 1 fwd 0 -> -1.7976931348623157e+308\nsinbeta_r over 1 fwd 0.5 -> -1.7976931348623157e+308\n== rate\nfwd 2499.8004129791998\ninv 0.0004066315357116607\n== equal\nsame 1\ncopy 1\ndifferent_nr 0\ndifferent_m 0\ninverted 0\nboth_inverted 1\ndefault 1\ndefault_vs_set_to_defaults 0\nnot_a_grismmap 0\n== zoom_after_forward\nclass GrismMap\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\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 GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -4.9999999999999998e-07 \t# Rate of change of refractive index\n GrmWR = 10000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.0001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- transformations\nfwd 0.01 -> 10203.419744379289\ninv 10200 -> 0.0093042794386218701\n-- transformations simplified\nfwd 0.01 -> 10203.419744379289\ninv 10200 -> 0.0093042794386218701\n== inverted_zoom_after_forward\nclass GrismMap\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\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 GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -4.9999999999999998e-07 \t# Rate of change of refractive index\n GrmWR = 10000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.0001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- transformations\nfwd 0.01 -> 2550.8549360948223\ninv 2550 -> 0.0093042794386218701\n-- transformations simplified\nfwd 0.01 -> 10203.419744379289\ninv 2550 -> -1.3741834277077565\n== zoom_before_inverted\nclass GrismMap\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\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 GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -4.9999999999999998e-07 \t# Rate of change of refractive index\n GrmWR = 10000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.0001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- transformations\nfwd 10200 -> 0.0093042794386218701\ninv 0.01 -> 10203.419744379289\n-- transformations simplified\nfwd 10200 -> 0.0093042794386218701\ninv 0.01 -> 10203.419744379289\n== inverted_zoom_before_inverted\nclass GrismMap\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\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 GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -4.9999999999999998e-07 \t# Rate of change of refractive index\n GrmWR = 10000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.0001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- transformations\nfwd 10200 -> 0.0093042794386218701\ninv 0.01 -> 10203.419744379289\n-- transformations simplified\nfwd 10200 -> 0.0093042794386218701\ninv 0.01 -> 10203.419744379289\n== zoom_before_forward\nclass CmpMap\n Begin CmpMap \t# Compound 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 MapA = \t# First component Mapping\n Begin ZoomMap \t# Zoom about the origin\n Nin = 1 \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 GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- transformations\nfwd 0.01 -> 5126.0504421868754\ninv 5100 -> 0.004652139719310935\n-- transformations simplified\nfwd 0.01 -> 5126.0504421868754\ninv 5100 -> 0.004652139719310935\n== zoom_after_inverted\nclass CmpMap\n Begin CmpMap \t# Compound 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 InvA = 1 \t# First Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n MapB = \t# Second component Mapping\n Begin ZoomMap \t# Zoom about the origin\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Zoom = 2 \t# Zoom factor\n End ZoomMap\n End CmpMap\n-- transformations\nfwd 5100 -> 0.01860855887724374\ninv 0.01 -> 5089.3741811940872\n-- transformations simplified\nfwd 5100 -> 0.01860855887724374\ninv 0.01 -> 5089.3741811940872\n== zooms_both_sides\nclass CmpMap\n Begin CmpMap \t# Compound 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 InvA = 1 \t# First Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -4.9999999999999998e-07 \t# Rate of change of refractive index\n GrmWR = 10000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.0001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n MapB = \t# Second component Mapping\n Begin ZoomMap \t# Zoom about the origin\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Zoom = 3 \t# Zoom factor\n End ZoomMap\n End CmpMap\n-- transformations\nfwd 10200 -> 0.02791283831586561\ninv 0.029999999999999999 -> 10203.419744379289\n-- transformations simplified\nfwd 10200 -> 0.02791283831586561\ninv 0.029999999999999999 -> 10203.419744379289\n== zoom_forward_zoom\nclass CmpMap\n Begin CmpMap \t# Compound 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 MapA = \t# First component Mapping\n Begin ZoomMap \t# Zoom about the origin\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Zoom = 3 \t# Zoom factor\n End ZoomMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -4.9999999999999998e-07 \t# Rate of change of refractive index\n GrmWR = 10000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.0001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- transformations\nfwd 0.01 -> 10299.888439610548\ninv 10200 -> 0.0031014264795406234\n-- transformations simplified\nfwd 0.01 -> 10299.888439610548\ninv 10200 -> 0.0031014264795406234\n== zoom_inverted_after_combining\nclass GrismMap\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\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 GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -1.9999999999999999e-06 \t# Rate of change of refractive index\n GrmWR = 2500 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00040000000000000002 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- transformations\nfwd 0.01 -> 10203.419744379289\ninv 10200 -> 0.0093042794386218701\n-- transformations simplified\nfwd 0.01 -> 2550.8549360948223\ninv 10200 -> -1.7976931348623157e+308\n== zoom_inverted_after_combining_before\nclass GrismMap\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\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 GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -4.9999999999999998e-07 \t# Rate of change of refractive index\n GrmWR = 10000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.0001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- transformations\nfwd 10200 -> -1.7976931348623157e+308\ninv 0.01 -> 2550.8549360948223\n-- transformations simplified\nfwd 10200 -> 0.0093042794386218701\ninv 0.01 -> 10203.419744379289\n== grism_inverted_after_combining\nclass GrismMap\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\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 GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -4.9999999999999998e-07 \t# Rate of change of refractive index\n GrmWR = 10000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.0001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- transformations\nfwd 0.01 -> 10203.419744379289\ninv 10200 -> 0.0093042794386218701\n-- transformations simplified\nfwd 0.01 -> 10203.419744379289\ninv 10200 -> 0.0093042794386218701\n== zoom_after_default\nclass GrismMap\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\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# GrmNR = 1 \t# Refractive index at the ref. wavelength\n GrmNRP = 0 \t# Rate of change of refractive index\n GrmWR = 10000 \t# Ref. wavelength\n# GrmAlp = 0 \t# Angle of incidence of incoming light\n GrmG = 0 \t# Grating ruling density\n# GrmM = 0 \t# The interference order\n# GrmEps = 0 \t# Angle between grating normal and dispersion plane\n# GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 10200 -> 0\n-- transformations simplified\nfwd 0.01 -> -1.7976931348623157e+308\ninv 10200 -> 0\n== zoom_after_two_grisms\nclass ZoomMap\n Begin ZoomMap \t# Zoom about the origin\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 Zoom = 2 \t# Zoom factor\n End ZoomMap\n-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 0.02 -> -1.7976931348623157e+308\n-- transformations simplified\nfwd 0.01 -> 0.02\ninv 0.02 -> 0.01\n== winmap_scale_after_forward\nclass GrismMap\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\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 GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -4.9999999999999998e-07 \t# Rate of change of refractive index\n GrmWR = 10000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.0001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- transformations\nfwd 0.01 -> 10203.419744379289\ninv 10200 -> 0.0093042794386218701\n-- transformations simplified\nfwd 0.01 -> 10203.419744379289\ninv 10200 -> 0.0093042794386218701\n== winmap_after_forward\nclass CmpMap\n Begin CmpMap \t# Compound 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 MapA = \t# First component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\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 = 10 \t# Shift for axis 1\n Scl1 = 2 \t# Scale factor for axis 1\n End WinMap\n End CmpMap\n-- transformations\nfwd 0.01 -> 10213.419744379289\ninv 10210 -> 0.0093042794386218701\n-- transformations simplified\nfwd 0.01 -> 10213.419744379289\ninv 10210 -> 0.0093042794386218701\n== winmap_scale_before_inverted\nclass GrismMap\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\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 GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -4.9999999999999998e-07 \t# Rate of change of refractive index\n GrmWR = 10000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.0001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- transformations\nfwd 10200 -> 0.0093042794386218701\ninv 0.01 -> 10203.419744379289\n-- transformations simplified\nfwd 10200 -> 0.0093042794386218701\ninv 0.01 -> 10203.419744379289\n== winmap_before_inverted\nclass CmpMap\n Begin CmpMap \t# Compound 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 InvB = 1 \t# Second Mapping used in inverse direction\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 = -5 \t# Shift for axis 1\n Scl1 = 0.5 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- transformations\nfwd 10210 -> 0.0093042794386218701\ninv 0.01 -> 10213.419744379289\n-- transformations simplified\nfwd 10210 -> 0.0093042794386218701\ninv 0.01 -> 10213.419744379289\n== shiftmap_after_forward\nclass CmpMap\n Begin CmpMap \t# Compound 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 MapA = \t# First component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n MapB = \t# Second component Mapping\n Begin ShiftMap \t# Shift each coordinate axis\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Sft1 = 10 \t# Shift for axis 1\n End ShiftMap\n End CmpMap\n-- transformations\nfwd 0.01 -> 5111.7098721896446\ninv 5110 -> 0.0093042794386218701\n-- transformations simplified\nfwd 0.01 -> 5111.7098721896446\ninv 5110 -> 0.0093042794386218701\n== inverse_cancel\nclass UnitMap\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-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 0.01 -> -1.7976931348623157e+308\n-- transformations simplified\nfwd 0.01 -> 0.01\ninv 0.01 -> 0.01\n== inverse_cancel_lower\nclass UnitMap\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-- transformations\nfwd 5100 -> -1.7976931348623157e+308\ninv 5100 -> -1.7976931348623157e+308\n-- transformations simplified\nfwd 5100 -> 5100\ninv 5100 -> 5100\n== inverse_same_order\nclass CmpMap\n Begin CmpMap \t# Compound 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 InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- transformations\nfwd 0.01 -> 0.010000000000000061\ninv 0.01 -> 0.010000000000000061\n-- transformations simplified\nfwd 0.01 -> 0.010000000000000061\ninv 0.01 -> 0.010000000000000061\n== inverse_different_nr\nclass CmpMap\n Begin CmpMap \t# Compound 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 InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.6000000000000001 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = -1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- transformations\nfwd 0.01 -> -1.7976931348623157e+308\ninv 0.01 -> -1.7976931348623157e+308\n-- transformations simplified\nfwd 0.01 -> -1.7976931348623157e+308\ninv 0.01 -> -1.7976931348623157e+308\n== same_direction\nclass CmpMap\n Begin CmpMap \t# Compound 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 MapA = \t# First component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = -1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- transformations\nfwd 0 -> -1.7976931348623157e+308\ninv 0 -> -1.7976931348623157e+308\n-- transformations simplified\nfwd 0 -> -1.7976931348623157e+308\ninv 0 -> -1.7976931348623157e+308\n== parallel\nclass CmpMap\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 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 GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = -1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- transformations\nfwd 0.01 0.01 -> 5101.7098721896446 -1.7976931348623157e+308\ninv 0.01 0.01 -> -2.5544244363162107 -1.7976931348623157e+308\n-- transformations simplified\nfwd 0.01 0.01 -> 5101.7098721896446 -1.7976931348623157e+308\ninv 0.01 0.01 -> -2.5544244363162107 -1.7976931348623157e+308\n== parallel_zoom\nclass CmpMap\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 Series = 0 \t# Component Mappings applied in parallel\n MapA = \t# First component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n MapB = \t# Second component Mapping\n Begin ZoomMap \t# Zoom about the origin\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Zoom = 2 \t# Zoom factor\n End ZoomMap\n End CmpMap\n-- transformations\nfwd 0.01 0.01 -> 5101.7098721896446 0.02\ninv 0.01 0.01 -> -2.5544244363162107 0.0050000000000000001\n-- transformations simplified\nfwd 0.01 0.01 -> 5101.7098721896446 0.02\ninv 0.01 0.01 -> -2.5544244363162107 0.0050000000000000001\n== alone\nclass GrismMap\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\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 GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- transformations\nfwd 0.01 -> 5101.7098721896446\ninv 5100 -> 0.0093042794386218701\n-- transformations simplified\nfwd 0.01 -> 5101.7098721896446\ninv 5100 -> 0.0093042794386218701\n== alone_inverted\nclass GrismMap\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\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 GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n-- transformations\nfwd 5100 -> 0.0093042794386218701\ninv 0.01 -> 5101.7098721896446\n-- transformations simplified\nfwd 5100 -> 0.0093042794386218701\ninv 0.01 -> 5101.7098721896446\n== shared_pair\nclass CmpMap\n Begin CmpMap \t# Compound 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 InvB = 1 \t# Second Mapping used in inverse direction\n MapA = \t# First component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -9.9999999999999995e-07 \t# Rate of change of refractive index\n GrmWR = 5000 \t# Ref. wavelength\n GrmAlp = 0.10000000000000001 \t# Angle of incidence of incoming light\n GrmG = 0.00020000000000000001 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0.02 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.029999999999999999 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- transformations\nfwd 0.01 -> 0.010000000000000061\ninv 0.01 -> 0.010000000000000061\n-- transformations simplified\nfwd 0.01 -> 0.010000000000000061\ninv 0.01 -> 0.010000000000000061\n== fits_gri_FITS-WCS\nread FrameSet\npixel 1 -> 4.9999999999999998e-07 -> 1\npixel 50 -> 5.4833181710932719e-07 -> 49.999999999999979\npixel 100 -> 5.9604066731558777e-07 -> 99.999999999999972\n Begin CmpMap \t# Compound 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 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 = -0.0010078065215999999 \t# Shift for axis 1\n Scl1 = 0.0010078065215999999 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1 \t# Refractive index at the ref. wavelength\n GrmNRP = 0 \t# Rate of change of refractive index\n GrmWR = 4.9999999999999998e-07 \t# Ref. wavelength\n GrmAlp = 0 \t# Angle of incidence of incoming light\n GrmG = 900000 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0 \t# Angle between grating normal and dispersion plane\n GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- written 1\nWCSAXES = 1 / Number of WCS axes\nCRPIX1 = 1.0 / Reference pixel on axis 1\nCRVAL1 = 5.0E-7 / Value at ref. pixel on axis 1\nCTYPE1 = 'WAVE-GRI' / Type of co-ordinate on axis 1\nCDELT1 = 10.0E-10 / Pixel size on axis 1\nCUNIT1 = 'm ' / Units for axis 1\nPV1_0 = 900000.0 / Projection parameter\nPV1_1 = 1.0 / Projection parameter\nSPECSYS = 'HELIOCEN' / Standard of rest for spectral axis\nVELOSYS = 29336.889452278185 / [m/s] Topo. apparent velocity of rest frame\n-- read back FrameSet\npixel 1 -> 4.9999999999999998e-07 -> 1\npixel 50 -> 5.4833181710932719e-07 -> 50\npixel 100 -> 5.9604066731558777e-07 -> 100.00000000000003\n== fits_gra_FITS-WCS\nread FrameSet\npixel 1 -> 4.9083004828706071e-07 -> 0.99999999999988276\npixel 50 -> 5.3648768798813591e-07 -> 49.999999999999979\npixel 100 -> 5.7180204408155262e-07 -> 100\n Begin CmpMap \t# Compound 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 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 = -0.028747701287041169 \t# Shift for axis 1\n Scl1 = -0.0023660077996000002 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -100 \t# Rate of change of refractive index\n GrmWR = 4.9999999999999998e-07 \t# Ref. wavelength\n GrmAlp = 0.17453292519943295 \t# Angle of incidence of incoming light\n GrmG = 600000 \t# Grating ruling density\n GrmM = -2 \t# The interference order\n GrmEps = 0.034906585039886591 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.05235987755982989 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- written 1\nWCSAXES = 1 / Number of WCS axes\nCRPIX1 = 10.0 / Reference pixel on axis 1\nCRVAL1 = 5.0E-7 / Value at ref. pixel on axis 1\nCTYPE1 = 'AWAV-GRA' / Type of co-ordinate on axis 1\nCDELT1 = 1.0E-9 / Pixel size on axis 1\nCUNIT1 = 'm ' / Units for axis 1\nPV1_0 = 600000.0 / Projection parameter\nPV1_1 = -2.0 / Projection parameter\nPV1_2 = 10.0 / Projection parameter\nPV1_3 = 1.5 / Projection parameter\nPV1_4 = -100.0 / Projection parameter\nPV1_5 = 2.0 / Projection parameter\nPV1_6 = 3.0 / Projection parameter\nSPECSYS = 'HELIOCEN' / Standard of rest for spectral axis\nVELOSYS = 29336.889452278185 / [m/s] Topo. apparent velocity of rest frame\n-- read back FrameSet\npixel 1 -> 4.9083004828706071e-07 -> 0.99999999999988809\npixel 50 -> 5.3648768798813591e-07 -> 49.999999999999957\npixel 100 -> 5.7180204408155262e-07 -> 99.999999999999957\n== fits_gri_FITS-PC\nread FrameSet\npixel 1 -> 4.9999999999999998e-07 -> 1\npixel 50 -> 5.4833181710932719e-07 -> 49.999999999999979\npixel 100 -> 5.9604066731558777e-07 -> 99.999999999999972\n Begin CmpMap \t# Compound 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 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 = -0.0010078065215999999 \t# Shift for axis 1\n Scl1 = 0.0010078065215999999 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1 \t# Refractive index at the ref. wavelength\n GrmNRP = 0 \t# Rate of change of refractive index\n GrmWR = 4.9999999999999998e-07 \t# Ref. wavelength\n GrmAlp = 0 \t# Angle of incidence of incoming light\n GrmG = 900000 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0 \t# Angle between grating normal and dispersion plane\n GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- written 1\nCDELT1 = 10.0E-10 / Pixel scale on axis 1\nCRPIX1 = 1.0 / Reference pixel on axis 1\nCRVAL1 = 5.0E-7 / Value at ref. pixel on axis 1\nCTYPE1 = 'WAVE-GRI' / Type of co-ordinate on axis 1\nCUNIT1 = 'm ' / Units for axis 1\n! AST: Error in routine fitsrw at line 200 in file src/test/resources/probes/grismmap_probe.c.\n! astRead(FitsChan): Cannot implement spectral algorithm code '-GRI' specified in FITS keyword 'CTYPE1'.\n! astRead(FitsChan): Unknown algorithm code or unusable parameter values.\nstatus 233933266\n== fits_gra_FITS-PC\nread FrameSet\npixel 1 -> 4.9083004828706071e-07 -> 0.99999999999988276\npixel 50 -> 5.3648768798813591e-07 -> 49.999999999999979\npixel 100 -> 5.7180204408155262e-07 -> 100\n Begin CmpMap \t# Compound 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 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 = -0.028747701287041169 \t# Shift for axis 1\n Scl1 = -0.0023660077996000002 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -100 \t# Rate of change of refractive index\n GrmWR = 4.9999999999999998e-07 \t# Ref. wavelength\n GrmAlp = 0.17453292519943295 \t# Angle of incidence of incoming light\n GrmG = 600000 \t# Grating ruling density\n GrmM = -2 \t# The interference order\n GrmEps = 0.034906585039886591 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.05235987755982989 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- written 1\nCDELT1 = 1.0E-9 / Pixel scale on axis 1\nCRPIX1 = 10.0 / Reference pixel on axis 1\nCRVAL1 = 5.0E-7 / Value at ref. pixel on axis 1\nCTYPE1 = 'AWAV-GRA' / Type of co-ordinate on axis 1\nCUNIT1 = 'm ' / Units for axis 1\n! AST: Error in routine fitsrw at line 200 in file src/test/resources/probes/grismmap_probe.c.\n! astRead(FitsChan): Cannot implement spectral algorithm code '-GRA' specified in FITS keyword 'CTYPE1'.\n! astRead(FitsChan): Unknown algorithm code or unusable parameter values.\nstatus 233933266\n== fits_gri_FITS-IRAF\nread FrameSet\npixel 1 -> 4.9999999999999998e-07 -> 1\npixel 50 -> 5.4833181710932719e-07 -> 49.999999999999979\npixel 100 -> 5.9604066731558777e-07 -> 99.999999999999972\n Begin CmpMap \t# Compound 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 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 = -0.0010078065215999999 \t# Shift for axis 1\n Scl1 = 0.0010078065215999999 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1 \t# Refractive index at the ref. wavelength\n GrmNRP = 0 \t# Rate of change of refractive index\n GrmWR = 4.9999999999999998e-07 \t# Ref. wavelength\n GrmAlp = 0 \t# Angle of incidence of incoming light\n GrmG = 900000 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0 \t# Angle between grating normal and dispersion plane\n GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- written 1\nCRPIX1 = 1.0 / Reference pixel on axis 1\nCRVAL1 = 5.0E-7 / Value at ref. pixel on axis 1\nCTYPE1 = 'WAVE-GRI' / Type of co-ordinate on axis 1\nCD1_1 = 10.0E-10 / Transformation matrix element\nCUNIT1 = 'm ' / Units for axis 1\n! AST: Error in routine fitsrw at line 200 in file src/test/resources/probes/grismmap_probe.c.\n! astRead(FitsChan): Cannot implement spectral algorithm code '-GRI' specified in FITS keyword 'CTYPE1'.\n! astRead(FitsChan): Unknown algorithm code or unusable parameter values.\nstatus 233933266\n== fits_gra_FITS-IRAF\nread FrameSet\npixel 1 -> 4.9083004828706071e-07 -> 0.99999999999988276\npixel 50 -> 5.3648768798813591e-07 -> 49.999999999999979\npixel 100 -> 5.7180204408155262e-07 -> 100\n Begin CmpMap \t# Compound 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 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 = -0.028747701287041169 \t# Shift for axis 1\n Scl1 = -0.0023660077996000002 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -100 \t# Rate of change of refractive index\n GrmWR = 4.9999999999999998e-07 \t# Ref. wavelength\n GrmAlp = 0.17453292519943295 \t# Angle of incidence of incoming light\n GrmG = 600000 \t# Grating ruling density\n GrmM = -2 \t# The interference order\n GrmEps = 0.034906585039886591 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.05235987755982989 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- written 1\nCRPIX1 = 10.0 / Reference pixel on axis 1\nCRVAL1 = 5.0E-7 / Value at ref. pixel on axis 1\nCTYPE1 = 'AWAV-GRA' / Type of co-ordinate on axis 1\nCD1_1 = 1.0E-9 / Transformation matrix element\nCUNIT1 = 'm ' / Units for axis 1\n! AST: Error in routine fitsrw at line 200 in file src/test/resources/probes/grismmap_probe.c.\n! astRead(FitsChan): Cannot implement spectral algorithm code '-GRA' specified in FITS keyword 'CTYPE1'.\n! astRead(FitsChan): Unknown algorithm code or unusable parameter values.\nstatus 233933266\n== fits_gri_FITS-AIPS\nread FrameSet\npixel 1 -> 4.9999999999999998e-07 -> 1\npixel 50 -> 5.4833181710932719e-07 -> 49.999999999999979\npixel 100 -> 5.9604066731558777e-07 -> 99.999999999999972\n Begin CmpMap \t# Compound 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 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 = -0.0010078065215999999 \t# Shift for axis 1\n Scl1 = 0.0010078065215999999 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1 \t# Refractive index at the ref. wavelength\n GrmNRP = 0 \t# Rate of change of refractive index\n GrmWR = 4.9999999999999998e-07 \t# Ref. wavelength\n GrmAlp = 0 \t# Angle of incidence of incoming light\n GrmG = 900000 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0 \t# Angle between grating normal and dispersion plane\n GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- written 0\n== fits_gra_FITS-AIPS\nread FrameSet\npixel 1 -> 4.9083004828706071e-07 -> 0.99999999999988276\npixel 50 -> 5.3648768798813591e-07 -> 49.999999999999979\npixel 100 -> 5.7180204408155262e-07 -> 100\n Begin CmpMap \t# Compound 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 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 = -0.028747701287041169 \t# Shift for axis 1\n Scl1 = -0.0023660077996000002 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -100 \t# Rate of change of refractive index\n GrmWR = 4.9999999999999998e-07 \t# Ref. wavelength\n GrmAlp = 0.17453292519943295 \t# Angle of incidence of incoming light\n GrmG = 600000 \t# Grating ruling density\n GrmM = -2 \t# The interference order\n GrmEps = 0.034906585039886591 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.05235987755982989 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- written 0\n== fits_gri_FITS-AIPS++\nread FrameSet\npixel 1 -> 4.9999999999999998e-07 -> 1\npixel 50 -> 5.4833181710932719e-07 -> 49.999999999999979\npixel 100 -> 5.9604066731558777e-07 -> 99.999999999999972\n Begin CmpMap \t# Compound 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 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 = -0.0010078065215999999 \t# Shift for axis 1\n Scl1 = 0.0010078065215999999 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1 \t# Refractive index at the ref. wavelength\n GrmNRP = 0 \t# Rate of change of refractive index\n GrmWR = 4.9999999999999998e-07 \t# Ref. wavelength\n GrmAlp = 0 \t# Angle of incidence of incoming light\n GrmG = 900000 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0 \t# Angle between grating normal and dispersion plane\n GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- written 0\n== fits_gra_FITS-AIPS++\nread FrameSet\npixel 1 -> 4.9083004828706071e-07 -> 0.99999999999988276\npixel 50 -> 5.3648768798813591e-07 -> 49.999999999999979\npixel 100 -> 5.7180204408155262e-07 -> 100\n Begin CmpMap \t# Compound 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 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 = -0.028747701287041169 \t# Shift for axis 1\n Scl1 = -0.0023660077996000002 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1.5 \t# Refractive index at the ref. wavelength\n GrmNRP = -100 \t# Rate of change of refractive index\n GrmWR = 4.9999999999999998e-07 \t# Ref. wavelength\n GrmAlp = 0.17453292519943295 \t# Angle of incidence of incoming light\n GrmG = 600000 \t# Grating ruling density\n GrmM = -2 \t# The interference order\n GrmEps = 0.034906585039886591 \t# Angle between grating normal and dispersion plane\n GrmTh = 0.05235987755982989 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- written 0\n== fits_gri_FITS-CLASS\n!! AST: Error in routine fitsrw at line 182 in file src/test/resources/probes/grismmap_probe.c.\n! astRead(FitsChan): Keyword RESTFREQ not found in CLASS FITS header.\nstatus 233933266\n== fits_gra_FITS-CLASS\n!! AST: Error in routine fitsrw at line 182 in file src/test/resources/probes/grismmap_probe.c.\n! astRead(FitsChan): Keyword RESTFREQ not found in CLASS FITS header.\nstatus 233933266\n== fits_gri_NATIVE\nread nothing\n== fits_gra_NATIVE\nread nothing\n== fits_gri_DSS\n!! AST: Error in routine fitsrw at line 182 in file src/test/resources/probes/grismmap_probe.c.\n! astRead(FitsChan): Unable to find a value for FITS keyword \"PPO3\".\nstatus 233933266\n== fits_gra_DSS\n!! AST: Error in routine fitsrw at line 182 in file src/test/resources/probes/grismmap_probe.c.\n! astRead(FitsChan): Unable to find a value for FITS keyword \"PPO3\".\nstatus 233933266\n== fits_wave_gra\nread FrameSet\npixel 1 -> 4.9999999999999998e-07 -> 1\npixel 50 -> 5.4833233197136793e-07 -> 50.000000000000007\npixel 100 -> 5.9604290587546031e-07 -> 100.00000000000003\n Begin CmpMap \t# Compound 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 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 = -0.0010074487040000006 \t# Shift for axis 1\n Scl1 = 0.0010074487040000006 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin CmpMap \t# Compound Mapping\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1 \t# Refractive index at the ref. wavelength\n GrmNRP = 0 \t# Rate of change of refractive index\n GrmWR = 4.9985286697270975e-07 \t# Ref. wavelength\n GrmAlp = 0 \t# Angle of incidence of incoming light\n GrmG = 900000 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0 \t# Angle between grating normal and dispersion plane\n GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n MapB = \t# Second component Mapping\n Begin SpecMap \t# Conversion between spectral coordinate systems\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Nspec = 2 \t# Number of conversion steps\n Spec1 = \"AWTOFR\" \t# Convert wavelength (air) to frequency\n Spec2 = \"FRTOWV\" \t# Convert frequency to wavelength (vacuum)\n End SpecMap\n End CmpMap\n End CmpMap\n-- written 1\nWCSAXES = 1 / Number of WCS axes\nCRPIX1 = 1.0 / Reference pixel on axis 1\nCRVAL1 = 5.0E-7 / Value at ref. pixel on axis 1\nCTYPE1 = 'WAVE-GRA' / Type of co-ordinate on axis 1\nCDELT1 = 1.0E-9 / Pixel size on axis 1\nCUNIT1 = 'm ' / Units for axis 1\nPV1_0 = 900000.0 / Projection parameter\nPV1_1 = 1.0 / Projection parameter\nSPECSYS = 'HELIOCEN' / Standard of rest for spectral axis\nVELOSYS = 29336.889452278185 / [m/s] Topo. apparent velocity of rest frame\n-- read back FrameSet\npixel 1 -> 4.9999999999999998e-07 -> 1\npixel 50 -> 5.4833233197136793e-07 -> 50.000000000000007\npixel 100 -> 5.9604290587546031e-07 -> 100.00000000000003\n== fits_freq_gri\nread FrameSet\npixel 1 -> 600000000000000 -> 0.99999999999999989\npixel 50 -> 653909568614661.62 -> 50\npixel 100 -> 721037993838264.62 -> 100.00000000000003\n Begin CmpMap \t# Compound 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 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 = 0.00083911042779035285 \t# Shift for axis 1\n Scl1 = -0.00083911042779035285 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin CmpMap \t# Compound Mapping\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n MapA = \t# First component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1 \t# Refractive index at the ref. wavelength\n GrmNRP = 0 \t# Rate of change of refractive index\n GrmWR = 4.9965409666666669e-07 \t# Ref. wavelength\n GrmAlp = 0 \t# Angle of incidence of incoming light\n GrmG = 900000 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0 \t# Angle between grating normal and dispersion plane\n GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n MapB = \t# Second component Mapping\n Begin SpecMap \t# Conversion between spectral coordinate systems\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n Nspec = 1 \t# Number of conversion steps\n Spec1 = \"WVTOFR\" \t# Convert wavelength (vacuum) to frequency\n End SpecMap\n End CmpMap\n End CmpMap\n-- written 1\nWCSAXES = 1 / Number of WCS axes\nCRPIX1 = 1.0 / Reference pixel on axis 1\nCRVAL1 = 600000000000000.0 / Value at ref. pixel on axis 1\nCTYPE1 = 'FREQ-GRI' / Type of co-ordinate on axis 1\nCDELT1 = 1000000000000.0 / Pixel size on axis 1\nCUNIT1 = 'Hz ' / Units for axis 1\nPV1_0 = 900000.0 / Projection parameter\nPV1_1 = 1.0 / Projection parameter\nSPECSYS = 'HELIOCEN' / Standard of rest for spectral axis\nVELOSYS = 29336.889452278185 / [m/s] Topo. apparent velocity of rest frame\n-- read back FrameSet\npixel 1 -> 600000000000000 -> 1\npixel 50 -> 653909568614661.62 -> 49.999999999999993\npixel 100 -> 721037993838264.62 -> 100.00000000000001\n== fits_gri_nm\nread FrameSet\npixel 1 -> 500 -> 1\npixel 50 -> 548.33181699716602 -> 50.000000000000142\npixel 100 -> 596.04066709733627 -> 100.00000000000001\n Begin CmpMap \t# Compound 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 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 = -0.0010078065192255957 \t# Shift for axis 1\n Scl1 = 0.0010078065192255957 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1 \t# Refractive index at the ref. wavelength\n GrmNRP = 0 \t# Rate of change of refractive index\n GrmWR = 500 \t# Ref. wavelength\n GrmAlp = 0 \t# Angle of incidence of incoming light\n GrmG = 0.00090000000000000008 \t# Grating ruling density\n GrmM = 1 \t# The interference order\n GrmEps = 0 \t# Angle between grating normal and dispersion plane\n GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- written 1\nWCSAXES = 1 / Number of WCS axes\nCRPIX1 = 1.0 / Reference pixel on axis 1\nCRVAL1 = 500.0 / Value at ref. pixel on axis 1\nCTYPE1 = 'WAVE-GRI' / Type of co-ordinate on axis 1\nCDELT1 = 1.0000000001015878 / Pixel size on axis 1\nCUNIT1 = 'nm ' / Units for axis 1\nPV1_0 = 900000.0 / Projection parameter\nPV1_1 = 1.0 / Projection parameter\nSPECSYS = 'HELIOCEN' / Standard of rest for spectral axis\nVELOSYS = 29336.889452278185 / [m/s] Topo. apparent velocity of rest frame\n-- read back FrameSet\npixel 1 -> 499.99999999999994 -> 1\npixel 50 -> 548.33181699716579 -> 49.999999999999865\npixel 100 -> 596.04066709733615 -> 99.999999999999972\n== fits_vrad_gri\n! AST: Error in routine fitsrw at line 182 in file src/test/resources/probes/grismmap_probe.c.\n! astRead(FitsChan): Cannot implement spectral algorithm code '-GRI' specified in FITS keyword 'CTYPE1'.\n! astRead(FitsChan): Unknown algorithm code or unusable parameter values.\nstatus 233933266\n== fits_gri_half_order\nread FrameSet\npixel 1 -> 4.9999999999999998e-07 -> 1\npixel 50 -> 5.3809479742775646e-07 -> 50.000000000000171\npixel 100 -> 5.5445547646877842e-07 -> 99.999999999999901\n Begin CmpMap \t# Compound 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 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 = -0.0041294832128000022 \t# Shift for axis 1\n Scl1 = 0.0041294832128000022 \t# Scale factor for axis 1\n End WinMap\n MapB = \t# Second component Mapping\n Begin GrismMap \t# Map 1-d coordinates using a spectral disperser\n Nin = 1 \t# Number of input coordinates\n Invert = 1 \t# Mapping inverted\n IsA Mapping \t# Mapping between coordinate systems\n GrmNR = 1 \t# Refractive index at the ref. wavelength\n GrmNRP = 0 \t# Rate of change of refractive index\n GrmWR = 4.9999999999999998e-07 \t# Ref. wavelength\n GrmAlp = 0 \t# Angle of incidence of incoming light\n GrmG = 900000 \t# Grating ruling density\n GrmM = 2 \t# The interference order\n GrmEps = 0 \t# Angle between grating normal and dispersion plane\n GrmTh = 0 \t# Angle between detector normal and reference ray\n End GrismMap\n End CmpMap\n-- written 1\nWCSAXES = 1 / Number of WCS axes\nCRPIX1 = 1.0 / Reference pixel on axis 1\nCRVAL1 = 5.0E-7 / Value at ref. pixel on axis 1\nCTYPE1 = 'WAVE-GRI' / Type of co-ordinate on axis 1\nCDELT1 = 1.0E-9 / Pixel size on axis 1\nCUNIT1 = 'm ' / Units for axis 1\nPV1_0 = 900000.0 / Projection parameter\nPV1_1 = 2.0 / Projection parameter\nSPECSYS = 'HELIOCEN' / Standard of rest for spectral axis\nVELOSYS = 29336.889452278185 / [m/s] Topo. apparent velocity of rest frame\n-- read back FrameSet\npixel 1 -> 4.9999999999999998e-07 -> 1\npixel 50 -> 5.3809479742775646e-07 -> 50.000000000000156\npixel 100 -> 5.5445547646877842e-07 -> 99.999999999999886\n== fits_gri_negative_half_order\n! AST: Error in routine fitsrw at line 182 in file src/test/resources/probes/grismmap_probe.c.\n! astRead(FitsChan): Cannot implement spectral algorithm code '-GRI' specified in FITS keyword 'CTYPE1'.\n! astRead(FitsChan): Unknown algorithm code or unusable parameter values.\nstatus 233933266\n== write_shift_zoom_grism\nwritten 1\nWCSAXES = 1 / Number of WCS axes\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRVAL1 = 5.0E-7 / Value at ref. pixel on axis 1\nCTYPE1 = 'WAVE-GRI' / Type of co-ordinate on axis 1\nCDELT1 = 1.9845078962426118E-9 / Pixel size on axis 1\nCUNIT1 = 'm ' / Units for axis 1\nPV1_0 = 900000.0 / Projection parameter\nPV1_1 = 1.0 / Projection parameter\nSPECSYS = 'HELIOCEN' / Standard of rest for spectral axis\nVELOSYS = 29336.889452278185 / [m/s] Topo. apparent velocity of rest frame\npixel 1 -> 4.0083888403425058e-07 -> 1.0000000000000071\npixel 50 -> 4.9999999999999998e-07 -> 50\npixel 100 -> 5.9625155334046132e-07 -> 100.00000000000003\n-- read back\npixel 1 -> 4.0083888403425058e-07 -> 1.0000000000000071\npixel 50 -> 4.9999999999999998e-07 -> 49.999999999999993\npixel 100 -> 5.9625155334046132e-07 -> 100.00000000000001\n== write_grism_then_zoom_nm\nwritten 0\npixel 1 -> 400.83888403425055 -> 1.0000000000000071\npixel 50 -> 500 -> 50.000000000000057\npixel 100 -> 596.25155334046133 -> 100.00000000000003\n== write_grism_freq\nwritten 1\nWCSAXES = 1 / Number of WCS axes\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRVAL1 = 599584916000000.0 / Value at ref. pixel on axis 1\nCTYPE1 = 'FREQ-GRI' / Type of co-ordinate on axis 1\nCDELT1 = -2379762012622.6841 / Pixel size on axis 1\nCUNIT1 = 'Hz ' / Units for axis 1\nPV1_0 = 900000.0 / Projection parameter\nPV1_1 = 1.0 / Projection parameter\nSPECSYS = 'HELIOCEN' / Standard of rest for spectral axis\nVELOSYS = 29336.889452278185 / [m/s] Topo. apparent velocity of rest frame\npixel 1 -> 747912615120402.25 -> 1.0000000000000071\npixel 50 -> 599584916000000 -> 50\npixel 100 -> 502795265388294.38 -> 100.00000000000003\n-- read back\npixel 1 -> 747912615120402.25 -> 1.0000000000000071\npixel 50 -> 599584916000000 -> 50\npixel 100 -> 502795265388294.38 -> 100.00000000000003\n== write_grism_then_shift\nwritten 0\npixel 1 -> 4.018388840342506e-07 -> 1.0000000000000071\npixel 50 -> 5.0099999999999995e-07 -> 50\npixel 100 -> 5.9725155334046129e-07 -> 100.00000000000003\n== write_grism_inverted\nwritten 1\nWCSAXES = 1 / Number of WCS axes\nCRPIX1 = 50.0 / Reference pixel on axis 1\nCRVAL1 = 5.0E-7 / Value at ref. pixel on axis 1\nCTYPE1 = 'WAVE-GRI' / Type of co-ordinate on axis 1\nCDELT1 = 1.9845078962426118E-9 / Pixel size on axis 1\nCUNIT1 = 'm ' / Units for axis 1\nPV1_0 = 900000.0 / Projection parameter\nPV1_1 = 1.0 / Projection parameter\nSPECSYS = 'HELIOCEN' / Standard of rest for spectral axis\nVELOSYS = 29336.889452278185 / [m/s] Topo. apparent velocity of rest frame\npixel 1 -> 4.0083888403425058e-07 -> 1.0000000000000071\npixel 50 -> 4.9999999999999998e-07 -> 50\npixel 100 -> 5.9625155334046132e-07 -> 100.00000000000003\n-- read back\npixel 1 -> 4.0083888403425058e-07 -> 1.0000000000000071\npixel 50 -> 4.9999999999999998e-07 -> 49.999999999999993\npixel 100 -> 5.9625155334046132e-07 -> 100.00000000000001\n" +} diff --git a/src/test/resources/probes/intramap_load_probe.c b/src/test/resources/probes/intramap_load_probe.c new file mode 100644 index 0000000..c6115d9 --- /dev/null +++ b/src/test/resources/probes/intramap_load_probe.c @@ -0,0 +1,96 @@ +/* intramap_load_probe -- reading back an IntraMap whose function maps + * different numbers of input and output coordinates. "sum2" is registered + * with 2 inputs and 1 output (forward: the sum of the inputs; inverse: half + * the input on each output). An IntraMap of it is written, read back and + * applied, as made and inverted; astLoadIntraMap compares the numbers of + * coordinates of the IntraMap read, as its Invert attribute leaves them, + * with those registered. + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * Built against the C library at 3d3f255f with its static libraries: + * cc -std=c11 -I -o intramap_load_probe intramap_load_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 ./intramap_load_probe > intramap_load_probe.out 2>&1, then + * trailing white space removed from every line. */ +#include +#include +#include +#include "ast.h" + +#define MAXLINES 100 +static char *lines[ MAXLINES ]; +static int nline = 0; +static int iline = 0; + +static void sink( const char *line ) { + if( nline < MAXLINES ) lines[ nline++ ] = strcpy( malloc( strlen( line ) + 1 ), line ); +} + +static const char *source( void ) { + return ( iline < nline ) ? lines[ iline++ ] : NULL; +} + +static void Sum2( AstMapping *mapping, int npoint, int ncoord_in, + const double *ptr_in[], int forward, int ncoord_out, + double *ptr_out[] ) { + (void) mapping; + (void) ncoord_in; + (void) ncoord_out; + for( int i = 0; i < npoint; i++ ) { + if( forward ) { + ptr_out[ 0 ][ i ] = ptr_in[ 0 ][ i ] + ptr_in[ 1 ][ i ]; + } else { + ptr_out[ 0 ][ i ] = 0.5 * ptr_in[ 0 ][ i ]; + ptr_out[ 1 ][ i ] = 0.5 * ptr_in[ 0 ][ i ]; + } + } +} + +/* Writes m, prints the text, reads it back and reports the result. */ +static void roundtrip( const char *name, AstMapping *m ) { + printf( "== %s\n", name ); + nline = iline = 0; + AstChannel *out = astChannel( NULL, sink, "" ); + astWrite( out, m ); + out = astAnnul( out ); + for( int i = 0; i < nline; i++ ) printf( "%s\n", lines[ i ] ); + printf( "-- read\n" ); + AstChannel *in = astChannel( source, NULL, "" ); + AstMapping *back = astRead( in ); + in = astAnnul( in ); + if( !astOK ) { + printf( "status %d\n", astStatus ); + astClearStatus; + return; + } + int nin = astGetI( back, "Nin" ); + double xin[ 2 ] = { 1.5, 2.25 }; + double xout[ 2 ] = { 0.0, 0.0 }; + if( nin == 2 ) { + astTranN( back, 1, 2, 1, xin, 1, 1, 1, xout ); + } else { + astTranN( back, 1, 1, 1, xin, 1, 2, 1, xout ); + } + printf( "Nin %d forward of (%.17g, %.17g): %.17g %.17g\n", nin, xin[ 0 ], + xin[ 1 ], xout[ 0 ], nin == 2 ? 0.0 : xout[ 1 ] ); + back = astAnnul( back ); +} + +int main( void ) { + int status_value = 0; + int *status = &status_value; + setvbuf( stdout, NULL, _IONBF, 0 ); + astWatch( status ); + astIntraReg_( "sum2", 2, 1, Sum2, 0, "Sum of two inputs", "AST test suite", + "starlink-ast", status ); + AstIntraMap *m = astIntraMap( "sum2", 2, 1, "" ); + roundtrip( "as_made", (AstMapping *) m ); + astInvert( m ); + roundtrip( "inverted", (AstMapping *) m ); + m = astAnnul( m ); + return 0; +} diff --git a/src/test/resources/probes/intramap_load_probe.out b/src/test/resources/probes/intramap_load_probe.out new file mode 100644 index 0000000..b32a532 --- /dev/null +++ b/src/test/resources/probes/intramap_load_probe.out @@ -0,0 +1,28 @@ +== as_made + Begin IntraMap # Map points using a private transformation function + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Fname = "sum2" # Name of transformation function + Purp = "Sum of two inputs" # Purpose of function + Auth = "AST test suite" # Author's name + Cntact = "starlink-ast" # Contact address + End IntraMap +-- read +Nin 2 forward of (1.5, 2.25): 3.75 0 +== inverted + Begin IntraMap # Map points using a private transformation function + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fname = "sum2" # Name of transformation function + Purp = "Sum of two inputs" # Purpose of function + Auth = "AST test suite" # Author's name + Cntact = "starlink-ast" # Contact address + End IntraMap +-- read +!! AST: Error in routine roundtrip at line 63 in file intramap_load_probe.c. +! astLoadIntraMap(Channel): The number of input coordinates for the IntraMap read (1) does not match the number used by the registered "sum2" transformation function (2). +! Error while reading a IntraMap from a Channel. +status 233933210 diff --git a/src/test/resources/probes/lutmap_probe.c b/src/test/resources/probes/lutmap_probe.c new file mode 100644 index 0000000..fda71c8 --- /dev/null +++ b/src/test/resources/probes/lutmap_probe.c @@ -0,0 +1,263 @@ +/* lutmap_probe -- LutMap behaviour of the pinned C library that no fixture + * or oracle holds: simplification beside WinMaps, ZoomMaps and its own + * inverse; native dumps with LutInterp and LutEpsilon set, cleared and + * unset, through a Channel and a FitsChan, and read back; the attribute + * strings; the last-value cache of Transform; and FITS-WCS reads of -TAB + * axes with TabOK set and no tables. + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * Built against the C library at 3d3f255f with its static libraries: + * cc -I -o lutmap_probe lutmap_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 ./lutmap_probe > lutmap_probe.out 2>&1, then trailing white + * space removed from every line (LutMapTest compares lines without it). */ +#include +#include +#include +#include "ast.h" + +static double curved[] = { 0.0, 1.0, 4.0, 9.0, 16.0 }; +static double linear[] = { 1.0, 3.0, 5.0, 7.0, 9.0 }; + +static void head( const char *name ) { + printf( "== %s\n", name ); +} + +/* The class of the simplified Mapping, then its dump. */ +static void simp( const char *name, AstMapping *map ) { + head( name ); + AstMapping *s = astSimplify( map ); + printf( "class %s\n", astGetC( s, "Class" ) ); + astShow( s ); +} + +static AstLutMap *lut( int n, double *t, double start, double inc ) { + return astLutMap( n, t, start, inc, " " ); +} + +static AstLutMap *inverted( AstLutMap *m ) { + AstLutMap *c = astCopy( m ); + astInvert( c ); + return c; +} + +static void attrs( AstLutMap *m ) { + printf( "LutInterp %s test %d\n", astGetC( m, "LutInterp" ), astTest( m, "LutInterp" ) ); + printf( "LutEpsilon %s test %d\n", astGetC( m, "LutEpsilon" ), astTest( m, "LutEpsilon" ) ); +} + +/* The dump, then the cards of a native FitsChan write, then the dump of + the Object read back from them. */ +static void dumps( const char *name, AstObject *obj ) { + head( name ); + astShow( obj ); + AstFitsChan *fc = astFitsChan( NULL, NULL, "Encoding=NATIVE" ); + astWrite( fc, obj ); + printf( "-- fits\n" ); + char card[ 81 ]; + astClear( fc, "Card" ); + while( astFindFits( fc, "%f", card, 1 ) ) printf( "%s\n", card ); + astClear( fc, "Card" ); + AstObject *back = astRead( fc ); + printf( "-- read back from fits\n" ); + astShow( back ); +} + +static void tran( AstMapping *m, double x, int fwd ) { + double y; + astTran1( m, 1, &x, fwd, &y ); + printf( "%s %.17g -> %.17g\n", fwd ? "fwd" : "inv", x, y ); +} + +static void tabread( const char *name, const char **cards, const char *attrs ) { + head( name ); + AstFitsChan *fc = astFitsChan( NULL, NULL, "" ); + if( attrs ) astSet( fc, "%s", attrs ); + for( int i = 0; cards[ i ]; i++ ) astPutFits( fc, cards[ i ], 0 ); + astClear( fc, "Card" ); + AstObject *obj = astRead( fc ); + if( !astOK ) { + printf( "read status %d\n", astStatus ); + astClearStatus; + return; + } + if( !obj ) { + printf( "read nothing\n" ); + return; + } + AstKeyMap *warn = astWarnings( fc ); + if( warn ) { + int n = astMapSize( warn ); + for( int i = 0; i < n; i++ ) { + const char *k = astMapKey( warn, i ); + const char *v; + astMapGet0C( warn, k, &v ); + printf( "warning %s: %s\n", k, v ); + } + } + printf( "nframe %d\n", astGetI( obj, "Nframe" ) ); +} + +int main( void ) { + int status = 0; + setvbuf( stdout, NULL, _IONBF, 0 ); + astWatch( &status ); + astBegin; + + /* Simplification. */ + AstLutMap *lc = lut( 5, curved, 0.0, 1.0 ); + AstLutMap *ll = lut( 5, linear, 0.0, 1.0 ); + double ina = 0.0, inb = 1.0, outa = 1.0, outb = 3.0; + AstWinMap *wm = astWinMap( 1, &ina, &inb, &outa, &outb, " " ); + AstZoomMap *zm = astZoomMap( 1, 2.0, " " ); + + simp( "win_lut", (AstMapping *) astCmpMap( wm, lc, 1, " " ) ); + simp( "lut_win", (AstMapping *) astCmpMap( lc, wm, 1, " " ) ); + simp( "zoom_lut", (AstMapping *) astCmpMap( zm, lc, 1, " " ) ); + simp( "lut_zoom", (AstMapping *) astCmpMap( lc, zm, 1, " " ) ); + simp( "zoom_linlut", (AstMapping *) astCmpMap( zm, ll, 1, " " ) ); + simp( "linlut_win", (AstMapping *) astCmpMap( ll, wm, 1, " " ) ); + simp( "linlut_alone", (AstMapping *) ll ); + simp( "linlut_inverted", (AstMapping *) inverted( ll ) ); + simp( "lut_lutinv", (AstMapping *) astCmpMap( lc, inverted( lc ), 1, " " ) ); + simp( "lutinv_lut", (AstMapping *) astCmpMap( inverted( lc ), lc, 1, " " ) ); + { + AstCmpMap *cm = astCmpMap( lc, inverted( lc ), 1, " " ); + astInvert( cm ); + simp( "inverted_cmp_lut_lutinv", (AstMapping *) cm ); + } + { + AstCmpMap *cm = astCmpMap( lc, astCopy( lc ), 1, " " ); + astInvert( cm ); + simp( "inverted_cmp_lut_lut", (AstMapping *) cm ); + } + { + AstCmpMap *inner = astCmpMap( zm, lc, 1, " " ); + astInvert( inner ); + simp( "inverted_inner_then_lut", (AstMapping *) astCmpMap( inner, lc, 1, " " ) ); + } + simp( "lut_lut", (AstMapping *) astCmpMap( lc, astCopy( lc ), 1, " " ) ); + simp( "lut_lutinv_parallel", (AstMapping *) astCmpMap( lc, inverted( lc ), 0, " " ) ); + { + AstLutMap *ln = astCopy( lc ); + astSet( ln, "LutInterp=1" ); + simp( "lut_nearestinv", (AstMapping *) astCmpMap( lc, inverted( ln ), 1, " " ) ); + } + { + double flat[] = { 1.0, 1.0 + DBL_EPSILON, 1.0 }; + AstLutMap *lf = lut( 3, flat, 0.0, 1.0 ); + simp( "flat_linear_lutinv", (AstMapping *) astCmpMap( lf, inverted( lf ), 1, " " ) ); + double con[] = { 5.0, 5.0, 5.0 }; + AstLutMap *lk = lut( 3, con, 0.0, 1.0 ); + simp( "constant_lutinv", (AstMapping *) astCmpMap( lk, inverted( lk ), 1, " " ) ); + } + { + double near[] = { 1.0, 3.0 + 1.0E-9, 5.0, 7.0, 9.0 }; + AstLutMap *ln = lut( 5, near, 0.0, 1.0 ); + simp( "near_linear_default_eps", (AstMapping *) ln ); + AstLutMap *le = lut( 5, near, 0.0, 1.0 ); + astSet( le, "LutEpsilon=1.0E-7" ); + simp( "near_linear_eps", (AstMapping *) le ); + } + + /* Attributes and dumps. */ + double t4[] = { 0.0, 10.0, 20.0, 30.0 }; + { + AstLutMap *m = lut( 4, t4, 5.0, 2.0 ); + head( "attrs_default" ); + attrs( m ); + dumps( "dump_default", (AstObject *) m ); + astSet( m, "LutInterp=1" ); + head( "attrs_interp1" ); + attrs( m ); + dumps( "dump_interp1", (AstObject *) m ); + astSet( m, "LutEpsilon=1.0E-7" ); + head( "attrs_both" ); + attrs( m ); + dumps( "dump_both", (AstObject *) m ); + astClear( m, "LutInterp" ); + astClear( m, "LutEpsilon" ); + head( "attrs_cleared" ); + attrs( m ); + dumps( "dump_cleared", (AstObject *) m ); + astSet( m, "LutInterp=5" ); + head( "attrs_interp5" ); + attrs( m ); + astSet( m, "LutInterp=0" ); + astSet( m, "LutEpsilon=0.25" ); + head( "attrs_interp0_eps" ); + attrs( m ); + dumps( "dump_interp0_eps", (AstObject *) m ); + } + { + double tb[] = { AST__BAD, 1.0, 2.0, 4.0 }; + AstLutMap *m = lut( 4, tb, 0.0, 1.0 ); + dumps( "dump_bad_first", (AstObject *) m ); + double tn[] = { 0.0, 1.0, 0.5, 4.0 }; + AstLutMap *n = lut( 4, tn, 0.0, 1.0 ); + astInvert( n ); + dumps( "dump_nonmonotonic_inverted", (AstObject *) n ); + AstLutMap *k = lut( 4, t4, 0.0, 1.0 ); + astSet( k, "LutInterp=1,LutEpsilon=1.0E-7" ); + dumps( "dump_in_cmpmap", (AstObject *) astCmpMap( zm, k, 1, " " ) ); + } + + /* The last-value cache. */ + { + double t3[] = { 0.0, 10.0, 20.0 }; + AstLutMap *m = lut( 3, t3, 1.0, 1.0 ); + head( "cache" ); + tran( (AstMapping *) m, 1.4, 1 ); + astSet( m, "LutInterp=1" ); + tran( (AstMapping *) m, 1.4, 1 ); + tran( (AstMapping *) m, 1.6, 1 ); + tran( (AstMapping *) m, 1.4, 1 ); + tran( (AstMapping *) m, 4.0, 0 ); + astClear( m, "LutInterp" ); + tran( (AstMapping *) m, 4.0, 0 ); + tran( (AstMapping *) m, 5.0, 0 ); + tran( (AstMapping *) m, 4.0, 0 ); + AstLutMap *c = lut( 3, t3, 1.0, 1.0 ); + head( "cache_copy" ); + tran( (AstMapping *) c, 1.4, 1 ); + AstLutMap *cc = astCopy( c ); + astSet( cc, "LutInterp=1" ); + tran( (AstMapping *) cc, 1.4, 1 ); + astInvert( cc ); + tran( (AstMapping *) cc, 1.4, 0 ); + tran( (AstMapping *) cc, 1.6, 0 ); + } + + /* -TAB axes with TabOK set and no tables. */ + { + const char *h1[] = { "NAXIS = 1", "NAXIS1 = 10", "CRPIX1 = 1", + "CDELT1 = 1.0E6", "CTYPE1 = 'WAVE-TAB'", + "CRVAL1 = 1.4E9", "PS1_0 = 'WCS-TAB'", NULL }; + tabread( "tab_spectral", h1, "TabOK=1" ); + const char *h2[] = { "NAXIS = 1", "NAXIS1 = 10", "CRPIX1 = 1", + "CDELT1 = 1.0E6", "CTYPE1 = 'WAVE-TAB'", + "CRVAL1 = 1.4E9", NULL }; + tabread( "tab_no_extname", h2, "TabOK=1" ); + const char *h3[] = { "NAXIS = 2", "NAXIS1 = 10", "NAXIS2 = 10", + "CRPIX1 = 1", "CRPIX2 = 1", "CDELT1 = 1.0", + "CDELT2 = 1.0", "CTYPE1 = 'XPOS'", + "CTYPE2 = 'YPOS-TAB'", "CRVAL1 = 0.0", + "CRVAL2 = 0.0", "PS2_0 = 'TABLE2'", + "PV2_1 = 3", "PV2_2 = 2", NULL }; + tabread( "tab_other_extver", h3, "TabOK=1" ); + tabread( "tab_other_tabok0", h3, NULL ); + const char *h4[] = { "NAXIS = 1", "NAXIS1 = 10", "CRPIX1 = 1", + "CDELT1 = 1.0", "CTYPE1 = 'XPOS'", + "CRVAL1 = 0.0", "CRPIX1A = 1", + "CDELT1A = 1.0E6", "CTYPE1A = 'WAVE-TAB'", + "CRVAL1A = 1.4E9", "PS1_0A = 'WCS-TAB'", NULL }; + tabread( "tab_alternate", h4, "TabOK=1" ); + } + + astEnd; + printf( "== end status %d\n", status ); + return 0; +} diff --git a/src/test/resources/probes/lutmap_probe.out b/src/test/resources/probes/lutmap_probe.out new file mode 100644 index 0000000..7a71ad3 --- /dev/null +++ b/src/test/resources/probes/lutmap_probe.out @@ -0,0 +1,917 @@ +== win_lut +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 1 # Shift for axis 1 + Scl1 = 2 # Scale factor for axis 1 + End WinMap + MapB = # Second component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + End CmpMap +== lut_win +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + MapB = # Second component Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 1 # Shift for axis 1 + Scl1 = 2 # Scale factor for axis 1 + End WinMap + End CmpMap +== zoom_lut +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + End CmpMap +== lut_zoom +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End CmpMap +== zoom_linlut +class WinMap + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 1 # Shift for axis 1 + Scl1 = 4 # Scale factor for axis 1 + End WinMap +== linlut_win +class WinMap + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 3 # Shift for axis 1 + Scl1 = 4 # Scale factor for axis 1 + End WinMap +== linlut_alone +class WinMap + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 1 # Shift for axis 1 + Scl1 = 2 # Scale factor for axis 1 + End WinMap +== linlut_inverted +class WinMap + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = -0.5 # Shift for axis 1 + Scl1 = 0.5 # Scale factor for axis 1 + End WinMap +== lut_lutinv +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +== lutinv_lut +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +== inverted_cmp_lut_lutinv +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + MapB = # Second component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + End CmpMap +== inverted_cmp_lut_lut +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +== inverted_inner_then_lut +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 0.5 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + End CmpMap + End CmpMap +== lut_lut +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + MapB = # Second component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + End CmpMap +== lut_lutinv_parallel +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + MapB = # Second component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + End CmpMap +== lut_nearestinv +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + MapB = # Second component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 1 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + End CmpMap +== flat_linear_lutinv +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Nlut = 3 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 1 # Lookup table elements... + L2 = 1.0000000000000002 + L3 = 1 + End LutMap + MapB = # Second component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Nlut = 3 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 1 # Lookup table elements... + L2 = 1.0000000000000002 + L3 = 1 + End LutMap + End CmpMap +== constant_lutinv +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Nlut = 3 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 5 # Lookup table elements... + L2 = 5 + L3 = 5 + End LutMap + MapB = # Second component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Nlut = 3 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 5 # Lookup table elements... + L2 = 5 + L3 = 5 + End LutMap + End CmpMap +== near_linear_default_eps +class LutMap + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 1 # Lookup table elements... + L2 = 3.0000000010000001 + L3 = 5 + L4 = 7 + L5 = 9 + End LutMap +== near_linear_eps +class WinMap + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 1 # Shift for axis 1 + Scl1 = 2 # Scale factor for axis 1 + End WinMap +== attrs_default +LutInterp 0 test 1 +LutEpsilon 2.2204460492503131e-16 test 0 +== dump_default + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements + Start = 5 # Input value at first element + Incr = 2 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 10 + L3 = 20 + L4 = 30 + End LutMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for LutMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'LutMap ' / Map 1-d coordinates using a lookup table +NIN_A = 1 / Number of input coordinates +ISA_A = 'Mapping ' / Mapping between coordinate systems +NLUT_A = 4 / Number of lookup table elements +START_A = 5.0 / Input value at first element +INCR_A = 2.0 / Input value increment between elements +LUTINT_A= 0 / Interpolation method +L1_A = 0.0 / Lookup table elements... +L2_A = 10.0 +L3_A = 20.0 +L4_A = 30.0 +ENDAST_A= 'LutMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for LutMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements + Start = 5 # Input value at first element + Incr = 2 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 10 + L3 = 20 + L4 = 30 + End LutMap +== attrs_interp1 +LutInterp 1 test 1 +LutEpsilon 2.2204460492503131e-16 test 0 +== dump_interp1 + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements + Start = 5 # Input value at first element + Incr = 2 # Input value increment between elements + LutInt = 1 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 10 + L3 = 20 + L4 = 30 + End LutMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for LutMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'LutMap ' / Map 1-d coordinates using a lookup table +NIN_A = 1 / Number of input coordinates +ISA_A = 'Mapping ' / Mapping between coordinate systems +NLUT_A = 4 / Number of lookup table elements +START_A = 5.0 / Input value at first element +INCR_A = 2.0 / Input value increment between elements +LUTINT_A= 1 / Interpolation method +L1_A = 0.0 / Lookup table elements... +L2_A = 10.0 +L3_A = 20.0 +L4_A = 30.0 +ENDAST_A= 'LutMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for LutMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements + Start = 5 # Input value at first element + Incr = 2 # Input value increment between elements + LutInt = 1 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 10 + L3 = 20 + L4 = 30 + End LutMap +== attrs_both +LutInterp 1 test 1 +LutEpsilon 9.9999999999999995e-08 test 1 +== dump_both + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements + Start = 5 # Input value at first element + Incr = 2 # Input value increment between elements + LutInt = 1 # Interpolation method + LutEps = 9.9999999999999995e-08 # Table relative error + L1 = 0 # Lookup table elements... + L2 = 10 + L3 = 20 + L4 = 30 + End LutMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for LutMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'LutMap ' / Map 1-d coordinates using a lookup table +NIN_A = 1 / Number of input coordinates +ISA_A = 'Mapping ' / Mapping between coordinate systems +NLUT_A = 4 / Number of lookup table elements +START_A = 5.0 / Input value at first element +INCR_A = 2.0 / Input value increment between elements +LUTINT_A= 1 / Interpolation method +LUTEPS_A= 10.0E-8 / Table relative error +L1_A = 0.0 / Lookup table elements... +L2_A = 10.0 +L3_A = 20.0 +L4_A = 30.0 +ENDAST_A= 'LutMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for LutMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements + Start = 5 # Input value at first element + Incr = 2 # Input value increment between elements + LutInt = 1 # Interpolation method + LutEps = 9.9999999999999995e-08 # Table relative error + L1 = 0 # Lookup table elements... + L2 = 10 + L3 = 20 + L4 = 30 + End LutMap +== attrs_cleared +LutInterp 0 test 0 +LutEpsilon 2.2204460492503131e-16 test 0 +== dump_cleared + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements + Start = 5 # Input value at first element + Incr = 2 # Input value increment between elements +# LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 10 + L3 = 20 + L4 = 30 + End LutMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for LutMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'LutMap ' / Map 1-d coordinates using a lookup table +NIN_A = 1 / Number of input coordinates +ISA_A = 'Mapping ' / Mapping between coordinate systems +NLUT_A = 4 / Number of lookup table elements +START_A = 5.0 / Input value at first element +INCR_A = 2.0 / Input value increment between elements +L1_A = 0.0 / Lookup table elements... +L2_A = 10.0 +L3_A = 20.0 +L4_A = 30.0 +ENDAST_A= 'LutMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for LutMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements + Start = 5 # Input value at first element + Incr = 2 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 10 + L3 = 20 + L4 = 30 + End LutMap +== attrs_interp5 +LutInterp 1 test 1 +LutEpsilon 2.2204460492503131e-16 test 0 +== attrs_interp0_eps +LutInterp 0 test 1 +LutEpsilon 0.25 test 1 +== dump_interp0_eps + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements + Start = 5 # Input value at first element + Incr = 2 # Input value increment between elements + LutInt = 0 # Interpolation method + LutEps = 0.25 # Table relative error + L1 = 0 # Lookup table elements... + L2 = 10 + L3 = 20 + L4 = 30 + End LutMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for LutMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'LutMap ' / Map 1-d coordinates using a lookup table +NIN_A = 1 / Number of input coordinates +ISA_A = 'Mapping ' / Mapping between coordinate systems +NLUT_A = 4 / Number of lookup table elements +START_A = 5.0 / Input value at first element +INCR_A = 2.0 / Input value increment between elements +LUTINT_A= 0 / Interpolation method +LUTEPS_A= 0.25 / Table relative error +L1_A = 0.0 / Lookup table elements... +L2_A = 10.0 +L3_A = 20.0 +L4_A = 30.0 +ENDAST_A= 'LutMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for LutMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements + Start = 5 # Input value at first element + Incr = 2 # Input value increment between elements + LutInt = 0 # Interpolation method + LutEps = 0.25 # Table relative error + L1 = 0 # Lookup table elements... + L2 = 10 + L3 = 20 + L4 = 30 + End LutMap +== dump_bad_first + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L2 = 1 + L3 = 2 + L4 = 4 + End LutMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for LutMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'LutMap ' / Map 1-d coordinates using a lookup table +NIN_A = 1 / Number of input coordinates +ISA_A = 'Mapping ' / Mapping between coordinate systems +NLUT_A = 4 / Number of lookup table elements +LUTINT_A= 0 / Interpolation method +L2_A = 1.0 +L3_A = 2.0 +L4_A = 4.0 +ENDAST_A= 'LutMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for LutMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L2 = 1 + L3 = 2 + L4 = 4 + End LutMap +== dump_nonmonotonic_inverted + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 0.5 + L4 = 4 + End LutMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for LutMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'LutMap ' / Map 1-d coordinates using a lookup table +NIN_A = 1 / Number of input coordinates +INVERT_A= 1 / Mapping inverted +INV_A = 0 / Inverse transformation not defined +ISA_A = 'Mapping ' / Mapping between coordinate systems +NLUT_A = 4 / Number of lookup table elements +LUTINT_A= 0 / Interpolation method +L1_A = 0.0 / Lookup table elements... +L2_A = 1.0 +L3_A = 0.5 +L4_A = 4.0 +ENDAST_A= 'LutMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for LutMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 0.5 + L4 = 4 + End LutMap +== dump_in_cmpmap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 1 # Interpolation method + LutEps = 9.9999999999999995e-08 # Table relative error + L1 = 0 # Lookup table elements... + L2 = 10 + L3 = 20 + L4 = 30 + End LutMap + End CmpMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for CmpMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'CmpMap ' / Compound Mapping +NIN_A = 1 / Number of input coordinates +ISA_A = 'Mapping ' / Mapping between coordinate systems +MAPA_A = ' ' / First component Mapping +BEGAST_B= 'ZoomMap ' / Zoom about the origin +NIN_B = 1 / Number of input coordinates +ISA_B = 'Mapping ' / Mapping between coordinate systems +ZOOM_A = 2.0 / Zoom factor +ENDAST_A= 'ZoomMap ' / End of object definition +MAPB_A = ' ' / Second component Mapping +BEGAST_C= 'LutMap ' / Map 1-d coordinates using a lookup table +NIN_C = 1 / Number of input coordinates +ISA_C = 'Mapping ' / Mapping between coordinate systems +NLUT_A = 4 / Number of lookup table elements +LUTINT_A= 1 / Interpolation method +LUTEPS_A= 10.0E-8 / Table relative error +L1_A = 0.0 / Lookup table elements... +L2_A = 10.0 +L3_A = 20.0 +L4_A = 30.0 +ENDAST_B= 'LutMap ' / End of object definition +ENDAST_C= 'CmpMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for CmpMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 4 # Number of lookup table elements +# Start = 0 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 1 # Interpolation method + LutEps = 9.9999999999999995e-08 # Table relative error + L1 = 0 # Lookup table elements... + L2 = 10 + L3 = 20 + L4 = 30 + End LutMap + End CmpMap +== cache +fwd 1.3999999999999999 -> 3.9999999999999991 +fwd 1.3999999999999999 -> 3.9999999999999991 +fwd 1.6000000000000001 -> 10 +fwd 1.3999999999999999 -> 0 +inv 4 -> 1 +inv 4 -> 1 +inv 5 -> 1.5 +inv 4 -> 1.3999999999999999 +== cache_copy +fwd 1.3999999999999999 -> 3.9999999999999991 +fwd 1.3999999999999999 -> 3.9999999999999991 +inv 1.3999999999999999 -> 3.9999999999999991 +inv 1.6000000000000001 -> 10 +== tab_spectral +! AST: Error in routine tabread at line 75 in file lutmap_probe.c. +! astRead(FitsChan): Failed to read FITS binary table from extension 'WCS-TAB' (extver=1, extlevel=1). +read status 233934338 +== tab_no_extname +! AST: Error in routine tabread at line 75 in file lutmap_probe.c. +! astRead(FitsChan): No value can be found for PS1_0 . +read status 233933554 +== tab_other_extver +! AST: Error in routine tabread at line 75 in file lutmap_probe.c. +! astRead(FitsChan): Failed to read FITS binary table from extension 'TABLE2' (extver=3, extlevel=2). +read status 233934338 +== tab_other_tabok0 +nframe 2 +== tab_alternate +! AST: Error in routine tabread at line 75 in file lutmap_probe.c. +! astRead(FitsChan): Failed to read FITS binary table from extension 'WCS-TAB' (extver=1, extlevel=1). +read status 233934338 +== end status 0 diff --git a/src/test/resources/probes/mathmap_probe.c b/src/test/resources/probes/mathmap_probe.c new file mode 100644 index 0000000..a6f5422 --- /dev/null +++ b/src/test/resources/probes/mathmap_probe.c @@ -0,0 +1,559 @@ +/* mathmap_probe -- MathMap behaviour of the pinned C library that no fixture + * or oracle holds: the value of every operator, function and constant of + * the symbol table at a set of arguments, bad and out-of-domain ones + * included; the status and messages of each malformed function; the + * random-number functions for a given Seed, on copies and on two MathMaps + * used in turn; the attribute strings; and native dumps through a Channel + * and a FitsChan, read back. + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * Built against the C library at 3d3f255f with its static libraries: + * cc -I -o mathmap_probe mathmap_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 ./mathmap_probe > mathmap_probe.out 2>&1, then trailing white + * space removed from every line (MathMapTest compares lines without it). + * It was run on macOS, whose maths library does not set errno, so where + * mathmap.c traps an error through errno (CATCH_MATHS_OVERFLOW and + * CATCH_MATHS_ERROR) the output holds the library's infinity or NaN, not + * the bad value; MathMapTest overrides those values (ERRNO_TRAPPED, + * ERRNO_CASES). */ +#include +#include +#include +#include +#include "ast.h" + +static void head( const char *name ) { + printf( "== %s\n", name ); +} + +/* The arguments at which each expression of the "evaluate" case is + evaluated. */ +static const double xs[] = { -2.5, -1.0, -0.5, 0.0, 0.25, 1.0, 2.0, 1000.0, + 1.0e300, -1.0e300, AST__BAD }; +#define NX ( sizeof( xs ) / sizeof( xs[ 0 ] ) ) + +/* The expressions of the "evaluate" case, each the right-hand side of the + forward function "y = " of a MathMap with input "x". */ +static const char *exprs[] = { + "x", "", "", "", "", "", "", + "", "", "", "", "", "", + "", "", + "abs(x)", "acos(x)", "acosd(x)", "acosh(x)", "acoth(x)", "acsch(x)", + "aint(x)", "asech(x)", "asin(x)", "asind(x)", "asinh(x)", "atan(x)", + "atand(x)", "atanh(x)", "ceil(x)", "cos(x)", "cosd(x)", "cosh(x)", + "coth(x)", "csch(x)", "exp(x)", "fabs(x)", "floor(x)", "int(x)", + "isbad(x)", "log(x)", "log10(x)", "nint(x)", "sech(x)", "sin(x)", + "sinc(x)", "sind(x)", "sinh(x)", "sqr(x)", "sqrt(x)", "tan(x)", "tand(x)", + "tanh(x)", + "atan2(x,0.5)", "atan2(0.5,x)", "atan2d(x,-0.5)", "dim(x,1)", "dim(1,x)", + "fmod(x,0.75)", "mod(x,0)", "mod(7.5,x)", "pow(x,0.5)", "pow(x,2)", + "pow(x,-1)", "pow(2,x)", "sign(2,x)", "sign(x,-1)", "qif(x,2,3)", + "qif(1,x,3)", "qif(0,2,x)", "max(x,1,-1)", "min(x,1,-1)", "max(x,)", + "min(2,x)", + "-x", "+x", "!x", ".not.x", "x+1", "x-1", "x*2", "x/0.5", "x/0", "1/x", + "x**2", "x**0.5", "x**-1", "x<<2", "x>>1", "x<1", "x.gt.1", "x>=1", "x.ge.1", "x==1", "x.eq.1", + "x!=1", "x.ne.1", "x&3", "x^3", "x|3", "x&&1", "x&&0", "x.and.1", "x^^1", + "x||0", "x||1", "x.or.0", "x.eqv.1", "x.neqv.1", "x.xor.1", + "x*1e300", "x+", "x-", "/x", "x/", "x*x*x", + "1e999", "1e999-1e999", "sin(1e999)", + "-x**2", "!x**2", "2**-x**2", "-x*3", "x<<1<3", "x.or.x.xor.x", + "x||x^^x", "x^^x.eqv.x", "x<3==1", "(x+1)*2", "sin(x)**2+cos(x)**2", + "max(x,1,2,3,4)-min(x,-1,-2)", "1.e1+1.d1+.5e-1+2.5d+1", "x.or.1", + NULL +}; + +/* Reports a failed call, then clears the status. */ +static int failed( void ) { + if( !astOK ) { + printf( "status %d\n", astStatus ); + astClearStatus; + return 1; + } + return 0; +} + +/* A MathMap of the forward and inverse functions given, NULL-terminated, + and the status if it cannot be made. */ +static AstMathMap *make( int nin, int nout, const char **fwd, + const char **inv ) { + int nfwd = 0, ninv = 0; + while( fwd[ nfwd ] ) nfwd++; + while( inv[ ninv ] ) ninv++; + AstMathMap *m = astMathMap( nin, nout, nfwd, fwd, ninv, inv, " " ); + if( failed() ) return NULL; + printf( "made\n" ); + return m; +} + +/* The status and messages of a MathMap with input "x", output "y" and the + forward function "y = ". */ +static void bad_expr( const char *expr ) { + char fwd[ 200 ]; + sprintf( fwd, "y = %s", expr ); + const char *f[] = { fwd, NULL }; + const char *i[] = { "x", NULL }; + printf( "-- %s\n", expr ); + make( 1, 1, f, i ); +} + +/* Values of a 1-input, 1-output MathMap applied forward to "npoint" + copies of "x". */ +static void draws( AstMapping *m, int npoint, double x ) { + double in[ 100 ], out[ 100 ]; + for( int i = 0; i < npoint; i++ ) in[ i ] = x; + astTran1( m, npoint, in, 1, out ); + if( failed() ) return; + for( int i = 0; i < npoint; i++ ) printf( "%.17g\n", out[ i ] ); +} + +static AstMathMap *random1( const char *expr, int seed ) { + char fwd[ 200 ]; + sprintf( fwd, "y = %s", expr ); + const char *f[] = { fwd, NULL }; + const char *i[] = { "x", NULL }; + AstMathMap *m = astMathMap( 1, 1, 1, f, 1, i, " " ); + astSetI( m, "Seed", seed ); + return m; +} + +static void attrs( AstMathMap *m ) { + printf( "SimpFI %s test %d\n", astGetC( m, "SimpFI" ), astTest( m, "SimpFI" ) ); + printf( "SimpIF %s test %d\n", astGetC( m, "SimpIF" ), astTest( m, "SimpIF" ) ); + int set = astTest( m, "Seed" ); + if( set ) { + printf( "Seed %s test 1\n", astGetC( m, "Seed" ) ); + } else { + printf( "Seed test 0\n" ); + } +} + +/* The dump, then the cards of a native FitsChan write, then the dump of + the Object read back from them. */ +static void dumps( const char *name, AstObject *obj ) { + head( name ); + astShow( obj ); + AstFitsChan *fc = astFitsChan( NULL, NULL, "Encoding=NATIVE" ); + astWrite( fc, obj ); + printf( "-- fits\n" ); + char card[ 81 ]; + astClear( fc, "Card" ); + while( astFindFits( fc, "%f", card, 1 ) ) printf( "%s\n", card ); + astClear( fc, "Card" ); + AstObject *back = astRead( fc ); + printf( "-- read back from fits\n" ); + astShow( back ); +} + +static void tran2( AstMapping *m, double x, double y, int fwd ) { + double xo, yo; + astTran2( m, 1, &x, &y, fwd, &xo, &yo ); + if( failed() ) return; + printf( "%s %.17g %.17g -> %.17g %.17g\n", fwd ? "fwd" : "inv", x, y, xo, yo ); +} + +int main( void ) { + int status = 0; + setvbuf( stdout, NULL, _IONBF, 0 ); + astWatch( &status ); + astBegin; + + /* Every operator, function and constant. */ + head( "evaluate" ); + for( int ie = 0; exprs[ ie ]; ie++ ) { + char fwd[ 200 ]; + sprintf( fwd, "y = %s", exprs[ ie ] ); + const char *f[] = { fwd, NULL }; + const char *i[] = { "x", NULL }; + AstMathMap *m = astMathMap( 1, 1, 1, f, 1, i, " " ); + if( failed() ) continue; + double out[ NX ]; + astTran1( m, (int) NX, xs, 1, out ); + if( failed() ) continue; + for( size_t ix = 0; ix < NX; ix++ ) { + printf( "%s @ %.17g = %.17g\n", exprs[ ie ], xs[ ix ], out[ ix ] ); + } + } + + /* Malformed expressions. */ + head( "expression_errors" ); + { + const char *bad[] = { + "1.or.0", "1 .and. 1", "x .not. 1", "2x", "x(1)", "x!", "(x)(x)", + "2.eq.2", ".eq.x", "1.e", "1.0.5", "x", "sin", "q", "*x", + "max(1,)", "x,1", "(x,1)", "sin((x,1))", "max(x,(1,2))", "x,1)+(", + "x)", "x)+(", "sin(x,1)", "atan2(x)", "atan2(x,1,2)", "qif(1,2)", + "max(x)", "max(x)+(", "min(x,)", "x+", "x+)", "(,x)", ")", "(x", + "sin(x", "1e", "1e+", "1.5e-x", "x y", "x**", "--x", "-+x", + "x+-1", "x--1", "x*-1", ".5.", "1d5d", "", NULL }; + for( int ib = 0; bad[ ib ]; ib++ ) bad_expr( bad[ ib ] ); + } + + /* Unary operators that follow another operator. */ + head( "unary_sequences" ); + { + const char *ok[] = { "--x", "-+x", "+-x", "x+-1", "x--1", "x*-1", + "-(-x)", "x**--2", "!!x", "-!x", NULL }; + for( int io = 0; ok[ io ]; io++ ) { + char fwd[ 200 ]; + sprintf( fwd, "y = %s", ok[ io ] ); + const char *f[] = { fwd, NULL }; + const char *i[] = { "x", NULL }; + printf( "-- %s\n", ok[ io ] ); + AstMathMap *m = astMathMap( 1, 1, 1, f, 1, i, " " ); + if( failed() ) continue; + double x = 2.0, y; + astTran1( m, 1, &x, 1, &y ); + printf( "%.17g\n", y ); + } + } + + /* Errors in the functions as a whole. */ + head( "function_errors" ); + { + const char *f1[] = { "y = x1 + 1", NULL }; + const char *i1[] = { "x + 1", NULL }; + printf( "-- varin_expression\n" ); + make( 1, 1, f1, i1 ); + const char *f2[] = { "y = x", NULL }; + const char *i2[] = { "x <= y", NULL }; + printf( "-- varin_relational\n" ); + make( 1, 1, f2, i2 ); + const char *i3[] = { "x + 1 = y", NULL }; + printf( "-- varin_lhs\n" ); + make( 1, 1, f2, i3 ); + const char *i4[] = { "_x", NULL }; + printf( "-- varin_underscore\n" ); + make( 1, 1, f2, i4 ); + const char *i5[] = { "1x", NULL }; + printf( "-- varin_digit\n" ); + make( 1, 1, f2, i5 ); + const char *f6[] = { "y = x + 1", NULL }; + const char *i6[] = { "x = y - 1", "x = 2", NULL }; + printf( "-- duvar_inverse\n" ); + make( 1, 1, f6, i6 ); + const char *i7[] = { "y", NULL }; + printf( "-- duvar_input_output\n" ); + make( 1, 1, f2, i7 ); + const char *i8[] = { "= y - 1", NULL }; + printf( "-- misvn_no_lhs\n" ); + make( 1, 1, f6, i8 ); + const char *i9[] = { "", NULL }; + printf( "-- misvn_empty\n" ); + make( 1, 1, f6, i9 ); + const char *i10[] = { " ", NULL }; + printf( "-- misvn_blank\n" ); + make( 1, 1, f6, i10 ); + const char *f11[] = { "y ==", NULL }; + const char *i11[] = { "x", NULL }; + printf( "-- miopa_double_equals\n" ); + make( 1, 1, f11, i11 ); + const char *f12[] = { "y = = x", NULL }; + printf( "-- miopa_equals_equals\n" ); + make( 1, 1, f12, i11 ); + const char *f13[] = { "y =", NULL }; + printf( "-- norhs_empty\n" ); + make( 1, 1, f13, i11 ); + const char *f14[] = { "t", "y = x", NULL }; + printf( "-- norhs_mixed\n" ); + make( 1, 1, f14, i11 ); + const char *f15[] = { "a = x", "b = a", "y = b + c", NULL }; + printf( "-- udvof_third_function\n" ); + make( 1, 1, f15, i11 ); + const char *f16[] = { "y = x", NULL }; + const char *i16[] = { "t = y", "x = t + @ -2.5 = -1.7976931348623157e+308 + @ -1 = -1.7976931348623157e+308 + @ -0.5 = -1.7976931348623157e+308 + @ 0 = -1.7976931348623157e+308 + @ 0.25 = -1.7976931348623157e+308 + @ 1 = -1.7976931348623157e+308 + @ 2 = -1.7976931348623157e+308 + @ 1000 = -1.7976931348623157e+308 + @ 1.0000000000000001e+300 = -1.7976931348623157e+308 + @ -1.0000000000000001e+300 = -1.7976931348623157e+308 + @ -1.7976931348623157e+308 = -1.7976931348623157e+308 + @ -2.5 = 17 + @ -1 = 17 + @ -0.5 = 17 + @ 0 = 17 + @ 0.25 = 17 + @ 1 = 17 + @ 2 = 17 + @ 1000 = 17 + @ 1.0000000000000001e+300 = 17 + @ -1.0000000000000001e+300 = 17 + @ -1.7976931348623157e+308 = 17 + @ -2.5 = 2.2204460492503131e-16 + @ -1 = 2.2204460492503131e-16 + @ -0.5 = 2.2204460492503131e-16 + @ 0 = 2.2204460492503131e-16 + @ 0.25 = 2.2204460492503131e-16 + @ 1 = 2.2204460492503131e-16 + @ 2 = 2.2204460492503131e-16 + @ 1000 = 2.2204460492503131e-16 + @ 1.0000000000000001e+300 = 2.2204460492503131e-16 + @ -1.0000000000000001e+300 = 2.2204460492503131e-16 + @ -1.7976931348623157e+308 = 2.2204460492503131e-16 + @ -2.5 = 53 + @ -1 = 53 + @ -0.5 = 53 + @ 0 = 53 + @ 0.25 = 53 + @ 1 = 53 + @ 2 = 53 + @ 1000 = 53 + @ 1.0000000000000001e+300 = 53 + @ -1.0000000000000001e+300 = 53 + @ -1.7976931348623157e+308 = 53 + @ -2.5 = 1.7976931348623157e+308 + @ -1 = 1.7976931348623157e+308 + @ -0.5 = 1.7976931348623157e+308 + @ 0 = 1.7976931348623157e+308 + @ 0.25 = 1.7976931348623157e+308 + @ 1 = 1.7976931348623157e+308 + @ 2 = 1.7976931348623157e+308 + @ 1000 = 1.7976931348623157e+308 + @ 1.0000000000000001e+300 = 1.7976931348623157e+308 + @ -1.0000000000000001e+300 = 1.7976931348623157e+308 + @ -1.7976931348623157e+308 = 1.7976931348623157e+308 + @ -2.5 = 308 + @ -1 = 308 + @ -0.5 = 308 + @ 0 = 308 + @ 0.25 = 308 + @ 1 = 308 + @ 2 = 308 + @ 1000 = 308 + @ 1.0000000000000001e+300 = 308 + @ -1.0000000000000001e+300 = 308 + @ -1.7976931348623157e+308 = 308 + @ -2.5 = 1024 + @ -1 = 1024 + @ -0.5 = 1024 + @ 0 = 1024 + @ 0.25 = 1024 + @ 1 = 1024 + @ 2 = 1024 + @ 1000 = 1024 + @ 1.0000000000000001e+300 = 1024 + @ -1.0000000000000001e+300 = 1024 + @ -1.7976931348623157e+308 = 1024 + @ -2.5 = 2.2250738585072014e-308 + @ -1 = 2.2250738585072014e-308 + @ -0.5 = 2.2250738585072014e-308 + @ 0 = 2.2250738585072014e-308 + @ 0.25 = 2.2250738585072014e-308 + @ 1 = 2.2250738585072014e-308 + @ 2 = 2.2250738585072014e-308 + @ 1000 = 2.2250738585072014e-308 + @ 1.0000000000000001e+300 = 2.2250738585072014e-308 + @ -1.0000000000000001e+300 = 2.2250738585072014e-308 + @ -1.7976931348623157e+308 = 2.2250738585072014e-308 + @ -2.5 = -307 + @ -1 = -307 + @ -0.5 = -307 + @ 0 = -307 + @ 0.25 = -307 + @ 1 = -307 + @ 2 = -307 + @ 1000 = -307 + @ 1.0000000000000001e+300 = -307 + @ -1.0000000000000001e+300 = -307 + @ -1.7976931348623157e+308 = -307 + @ -2.5 = -1021 + @ -1 = -1021 + @ -0.5 = -1021 + @ 0 = -1021 + @ 0.25 = -1021 + @ 1 = -1021 + @ 2 = -1021 + @ 1000 = -1021 + @ 1.0000000000000001e+300 = -1021 + @ -1.0000000000000001e+300 = -1021 + @ -1.7976931348623157e+308 = -1021 + @ -2.5 = 2 + @ -1 = 2 + @ -0.5 = 2 + @ 0 = 2 + @ 0.25 = 2 + @ 1 = 2 + @ 2 = 2 + @ 1000 = 2 + @ 1.0000000000000001e+300 = 2 + @ -1.0000000000000001e+300 = 2 + @ -1.7976931348623157e+308 = 2 + @ -2.5 = 1 + @ -1 = 1 + @ -0.5 = 1 + @ 0 = 1 + @ 0.25 = 1 + @ 1 = 1 + @ 2 = 1 + @ 1000 = 1 + @ 1.0000000000000001e+300 = 1 + @ -1.0000000000000001e+300 = 1 + @ -1.7976931348623157e+308 = 1 + @ -2.5 = 2.7182818284590451 + @ -1 = 2.7182818284590451 + @ -0.5 = 2.7182818284590451 + @ 0 = 2.7182818284590451 + @ 0.25 = 2.7182818284590451 + @ 1 = 2.7182818284590451 + @ 2 = 2.7182818284590451 + @ 1000 = 2.7182818284590451 + @ 1.0000000000000001e+300 = 2.7182818284590451 + @ -1.0000000000000001e+300 = 2.7182818284590451 + @ -1.7976931348623157e+308 = 2.7182818284590451 + @ -2.5 = 3.1415926535897931 + @ -1 = 3.1415926535897931 + @ -0.5 = 3.1415926535897931 + @ 0 = 3.1415926535897931 + @ 0.25 = 3.1415926535897931 + @ 1 = 3.1415926535897931 + @ 2 = 3.1415926535897931 + @ 1000 = 3.1415926535897931 + @ 1.0000000000000001e+300 = 3.1415926535897931 + @ -1.0000000000000001e+300 = 3.1415926535897931 + @ -1.7976931348623157e+308 = 3.1415926535897931 +abs(x) @ -2.5 = 2.5 +abs(x) @ -1 = 1 +abs(x) @ -0.5 = 0.5 +abs(x) @ 0 = 0 +abs(x) @ 0.25 = 0.25 +abs(x) @ 1 = 1 +abs(x) @ 2 = 2 +abs(x) @ 1000 = 1000 +abs(x) @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +abs(x) @ -1.0000000000000001e+300 = 1.0000000000000001e+300 +abs(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +acos(x) @ -2.5 = -1.7976931348623157e+308 +acos(x) @ -1 = 3.1415926535897931 +acos(x) @ -0.5 = 2.0943951023931957 +acos(x) @ 0 = 1.5707963267948966 +acos(x) @ 0.25 = 1.318116071652818 +acos(x) @ 1 = 0 +acos(x) @ 2 = -1.7976931348623157e+308 +acos(x) @ 1000 = -1.7976931348623157e+308 +acos(x) @ 1.0000000000000001e+300 = -1.7976931348623157e+308 +acos(x) @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +acos(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +acosd(x) @ -2.5 = -1.7976931348623157e+308 +acosd(x) @ -1 = 180 +acosd(x) @ -0.5 = 120.00000000000001 +acosd(x) @ 0 = 90 +acosd(x) @ 0.25 = 75.522487814070075 +acosd(x) @ 1 = 0 +acosd(x) @ 2 = -1.7976931348623157e+308 +acosd(x) @ 1000 = -1.7976931348623157e+308 +acosd(x) @ 1.0000000000000001e+300 = -1.7976931348623157e+308 +acosd(x) @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +acosd(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +acosh(x) @ -2.5 = -1.7976931348623157e+308 +acosh(x) @ -1 = -1.7976931348623157e+308 +acosh(x) @ -0.5 = -1.7976931348623157e+308 +acosh(x) @ 0 = -1.7976931348623157e+308 +acosh(x) @ 0.25 = -1.7976931348623157e+308 +acosh(x) @ 1 = 0 +acosh(x) @ 2 = 1.3169578969248166 +acosh(x) @ 1000 = 7.6009022095419887 +acosh(x) @ 1.0000000000000001e+300 = 691.46867507877357 +acosh(x) @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +acosh(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +acoth(x) @ -2.5 = -0.42364893019360184 +acoth(x) @ -1 = -1.7976931348623157e+308 +acoth(x) @ -0.5 = -1.7976931348623157e+308 +acoth(x) @ 0 = -1.7976931348623157e+308 +acoth(x) @ 0.25 = -1.7976931348623157e+308 +acoth(x) @ 1 = -1.7976931348623157e+308 +acoth(x) @ 2 = 0.54930614433405489 +acoth(x) @ 1000 = 0.0010000003333335108 +acoth(x) @ 1.0000000000000001e+300 = 0 +acoth(x) @ -1.0000000000000001e+300 = 0 +acoth(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +acsch(x) @ -2.5 = -0.39003531977071548 +acsch(x) @ -1 = -0.88137358701954294 +acsch(x) @ -0.5 = -1.4436354751788103 +acsch(x) @ 0 = -1.7976931348623157e+308 +acsch(x) @ 0.25 = 2.0947125472611012 +acsch(x) @ 1 = 0.88137358701954294 +acsch(x) @ 2 = 0.48121182505960347 +acsch(x) @ 1000 = 0.00099999983333335686 +acsch(x) @ 1.0000000000000001e+300 = 0 +acsch(x) @ -1.0000000000000001e+300 = -0 +acsch(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +aint(x) @ -2.5 = -2 +aint(x) @ -1 = -1 +aint(x) @ -0.5 = -0 +aint(x) @ 0 = 0 +aint(x) @ 0.25 = 0 +aint(x) @ 1 = 1 +aint(x) @ 2 = 2 +aint(x) @ 1000 = 1000 +aint(x) @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +aint(x) @ -1.0000000000000001e+300 = -1.0000000000000001e+300 +aint(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +asech(x) @ -2.5 = -1.7976931348623157e+308 +asech(x) @ -1 = -1.7976931348623157e+308 +asech(x) @ -0.5 = -1.7976931348623157e+308 +asech(x) @ 0 = -1.7976931348623157e+308 +asech(x) @ 0.25 = 2.0634370688955608 +asech(x) @ 1 = 0 +asech(x) @ 2 = -1.7976931348623157e+308 +asech(x) @ 1000 = -1.7976931348623157e+308 +asech(x) @ 1.0000000000000001e+300 = -1.7976931348623157e+308 +asech(x) @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +asech(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +asin(x) @ -2.5 = -1.7976931348623157e+308 +asin(x) @ -1 = -1.5707963267948966 +asin(x) @ -0.5 = -0.52359877559829882 +asin(x) @ 0 = 0 +asin(x) @ 0.25 = 0.25268025514207865 +asin(x) @ 1 = 1.5707963267948966 +asin(x) @ 2 = -1.7976931348623157e+308 +asin(x) @ 1000 = -1.7976931348623157e+308 +asin(x) @ 1.0000000000000001e+300 = -1.7976931348623157e+308 +asin(x) @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +asin(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +asind(x) @ -2.5 = -1.7976931348623157e+308 +asind(x) @ -1 = -90 +asind(x) @ -0.5 = -29.999999999999996 +asind(x) @ 0 = 0 +asind(x) @ 0.25 = 14.477512185929925 +asind(x) @ 1 = 90 +asind(x) @ 2 = -1.7976931348623157e+308 +asind(x) @ 1000 = -1.7976931348623157e+308 +asind(x) @ 1.0000000000000001e+300 = -1.7976931348623157e+308 +asind(x) @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +asind(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +asinh(x) @ -2.5 = -1.6472311463710958 +asinh(x) @ -1 = -0.88137358701954294 +asinh(x) @ -0.5 = -0.48121182505960347 +asinh(x) @ 0 = 0 +asinh(x) @ 0.25 = 0.24746646154726346 +asinh(x) @ 1 = 0.88137358701954294 +asinh(x) @ 2 = 1.4436354751788103 +asinh(x) @ 1000 = 7.6009027095419883 +asinh(x) @ 1.0000000000000001e+300 = 691.46867507877357 +asinh(x) @ -1.0000000000000001e+300 = -691.46867507877357 +asinh(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +atan(x) @ -2.5 = -1.1902899496825317 +atan(x) @ -1 = -0.78539816339744828 +atan(x) @ -0.5 = -0.46364760900080615 +atan(x) @ 0 = 0 +atan(x) @ 0.25 = 0.24497866312686414 +atan(x) @ 1 = 0.78539816339744828 +atan(x) @ 2 = 1.1071487177940906 +atan(x) @ 1000 = 1.5697963271282298 +atan(x) @ 1.0000000000000001e+300 = 1.5707963267948966 +atan(x) @ -1.0000000000000001e+300 = -1.5707963267948966 +atan(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +atand(x) @ -2.5 = -68.198590513648185 +atand(x) @ -1 = -45 +atand(x) @ -0.5 = -26.565051177077994 +atand(x) @ 0 = 0 +atand(x) @ 0.25 = 14.036243467926479 +atand(x) @ 1 = 45 +atand(x) @ 2 = 63.434948822922017 +atand(x) @ 1000 = 89.94270423958551 +atand(x) @ 1.0000000000000001e+300 = 90 +atand(x) @ -1.0000000000000001e+300 = -90 +atand(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +atanh(x) @ -2.5 = -1.7976931348623157e+308 +atanh(x) @ -1 = -1.7976931348623157e+308 +atanh(x) @ -0.5 = -0.54930614433405489 +atanh(x) @ 0 = 0 +atanh(x) @ 0.25 = 0.25541281188299536 +atanh(x) @ 1 = -1.7976931348623157e+308 +atanh(x) @ 2 = -1.7976931348623157e+308 +atanh(x) @ 1000 = -1.7976931348623157e+308 +atanh(x) @ 1.0000000000000001e+300 = -1.7976931348623157e+308 +atanh(x) @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +atanh(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +ceil(x) @ -2.5 = -2 +ceil(x) @ -1 = -1 +ceil(x) @ -0.5 = -0 +ceil(x) @ 0 = 0 +ceil(x) @ 0.25 = 1 +ceil(x) @ 1 = 1 +ceil(x) @ 2 = 2 +ceil(x) @ 1000 = 1000 +ceil(x) @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +ceil(x) @ -1.0000000000000001e+300 = -1.0000000000000001e+300 +ceil(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +cos(x) @ -2.5 = -0.8011436155469337 +cos(x) @ -1 = 0.54030230586813977 +cos(x) @ -0.5 = 0.87758256189037276 +cos(x) @ 0 = 1 +cos(x) @ 0.25 = 0.96891242171064473 +cos(x) @ 1 = 0.54030230586813977 +cos(x) @ 2 = -0.41614683654714241 +cos(x) @ 1000 = 0.56237907629070305 +cos(x) @ 1.0000000000000001e+300 = -0.57538611195754907 +cos(x) @ -1.0000000000000001e+300 = -0.57538611195754907 +cos(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +cosd(x) @ -2.5 = 0.9990482215818578 +cosd(x) @ -1 = 0.99984769515639127 +cosd(x) @ -0.5 = 0.99996192306417131 +cosd(x) @ 0 = 1 +cosd(x) @ 0.25 = 0.99999048072073449 +cosd(x) @ 1 = 0.99984769515639127 +cosd(x) @ 2 = 0.99939082701909576 +cosd(x) @ 1000 = 0.17364817766693125 +cosd(x) @ 1.0000000000000001e+300 = -0.66554742494619046 +cosd(x) @ -1.0000000000000001e+300 = -0.66554742494619046 +cosd(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +cosh(x) @ -2.5 = 6.1322894796636858 +cosh(x) @ -1 = 1.5430806348152437 +cosh(x) @ -0.5 = 1.1276259652063807 +cosh(x) @ 0 = 1 +cosh(x) @ 0.25 = 1.0314130998795732 +cosh(x) @ 1 = 1.5430806348152437 +cosh(x) @ 2 = 3.7621956910836314 +cosh(x) @ 1000 = inf +cosh(x) @ 1.0000000000000001e+300 = inf +cosh(x) @ -1.0000000000000001e+300 = inf +cosh(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +coth(x) @ -2.5 = -1.0135673098126083 +coth(x) @ -1 = -1.3130352854993315 +coth(x) @ -0.5 = -2.1639534137386529 +coth(x) @ 0 = -1.7976931348623157e+308 +coth(x) @ 0.25 = 4.0829881650735969 +coth(x) @ 1 = 1.3130352854993315 +coth(x) @ 2 = 1.0373147207275482 +coth(x) @ 1000 = 1 +coth(x) @ 1.0000000000000001e+300 = 1 +coth(x) @ -1.0000000000000001e+300 = -1 +coth(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +csch(x) @ -2.5 = -0.16528366985509557 +csch(x) @ -1 = -0.85091812823932156 +csch(x) @ -0.5 = -1.9190347513349437 +csch(x) @ 0 = -1.7976931348623157e+308 +csch(x) @ 0.25 = 3.9586351633020005 +csch(x) @ 1 = 0.85091812823932156 +csch(x) @ 2 = 0.27572056477178325 +csch(x) @ 1000 = 0 +csch(x) @ 1.0000000000000001e+300 = 0 +csch(x) @ -1.0000000000000001e+300 = -0 +csch(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +exp(x) @ -2.5 = 0.0820849986238988 +exp(x) @ -1 = 0.36787944117144233 +exp(x) @ -0.5 = 0.60653065971263342 +exp(x) @ 0 = 1 +exp(x) @ 0.25 = 1.2840254166877414 +exp(x) @ 1 = 2.7182818284590451 +exp(x) @ 2 = 7.3890560989306504 +exp(x) @ 1000 = inf +exp(x) @ 1.0000000000000001e+300 = inf +exp(x) @ -1.0000000000000001e+300 = 0 +exp(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +fabs(x) @ -2.5 = 2.5 +fabs(x) @ -1 = 1 +fabs(x) @ -0.5 = 0.5 +fabs(x) @ 0 = 0 +fabs(x) @ 0.25 = 0.25 +fabs(x) @ 1 = 1 +fabs(x) @ 2 = 2 +fabs(x) @ 1000 = 1000 +fabs(x) @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +fabs(x) @ -1.0000000000000001e+300 = 1.0000000000000001e+300 +fabs(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +floor(x) @ -2.5 = -3 +floor(x) @ -1 = -1 +floor(x) @ -0.5 = -1 +floor(x) @ 0 = 0 +floor(x) @ 0.25 = 0 +floor(x) @ 1 = 1 +floor(x) @ 2 = 2 +floor(x) @ 1000 = 1000 +floor(x) @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +floor(x) @ -1.0000000000000001e+300 = -1.0000000000000001e+300 +floor(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +int(x) @ -2.5 = -2 +int(x) @ -1 = -1 +int(x) @ -0.5 = -0 +int(x) @ 0 = 0 +int(x) @ 0.25 = 0 +int(x) @ 1 = 1 +int(x) @ 2 = 2 +int(x) @ 1000 = 1000 +int(x) @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +int(x) @ -1.0000000000000001e+300 = -1.0000000000000001e+300 +int(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +isbad(x) @ -2.5 = 0 +isbad(x) @ -1 = 0 +isbad(x) @ -0.5 = 0 +isbad(x) @ 0 = 0 +isbad(x) @ 0.25 = 0 +isbad(x) @ 1 = 0 +isbad(x) @ 2 = 0 +isbad(x) @ 1000 = 0 +isbad(x) @ 1.0000000000000001e+300 = 0 +isbad(x) @ -1.0000000000000001e+300 = 0 +isbad(x) @ -1.7976931348623157e+308 = 1 +log(x) @ -2.5 = -1.7976931348623157e+308 +log(x) @ -1 = -1.7976931348623157e+308 +log(x) @ -0.5 = -1.7976931348623157e+308 +log(x) @ 0 = -1.7976931348623157e+308 +log(x) @ 0.25 = -1.3862943611198906 +log(x) @ 1 = 0 +log(x) @ 2 = 0.69314718055994529 +log(x) @ 1000 = 6.9077552789821368 +log(x) @ 1.0000000000000001e+300 = 690.77552789821368 +log(x) @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +log(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +log10(x) @ -2.5 = -1.7976931348623157e+308 +log10(x) @ -1 = -1.7976931348623157e+308 +log10(x) @ -0.5 = -1.7976931348623157e+308 +log10(x) @ 0 = -1.7976931348623157e+308 +log10(x) @ 0.25 = -0.6020599913279624 +log10(x) @ 1 = 0 +log10(x) @ 2 = 0.3010299956639812 +log10(x) @ 1000 = 3 +log10(x) @ 1.0000000000000001e+300 = 300 +log10(x) @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +log10(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +nint(x) @ -2.5 = -3 +nint(x) @ -1 = -1 +nint(x) @ -0.5 = -1 +nint(x) @ 0 = 0 +nint(x) @ 0.25 = 0 +nint(x) @ 1 = 1 +nint(x) @ 2 = 2 +nint(x) @ 1000 = 1000 +nint(x) @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +nint(x) @ -1.0000000000000001e+300 = -1.0000000000000001e+300 +nint(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +sech(x) @ -2.5 = 0.16307123192997783 +sech(x) @ -1 = 0.64805427366388546 +sech(x) @ -0.5 = 0.88681888397007402 +sech(x) @ 0 = 1 +sech(x) @ 0.25 = 0.96954362914021452 +sech(x) @ 1 = 0.64805427366388546 +sech(x) @ 2 = 0.26580222883407972 +sech(x) @ 1000 = 0 +sech(x) @ 1.0000000000000001e+300 = 0 +sech(x) @ -1.0000000000000001e+300 = 0 +sech(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +sin(x) @ -2.5 = -0.59847214410395644 +sin(x) @ -1 = -0.8414709848078965 +sin(x) @ -0.5 = -0.47942553860420301 +sin(x) @ 0 = 0 +sin(x) @ 0.25 = 0.24740395925452294 +sin(x) @ 1 = 0.8414709848078965 +sin(x) @ 2 = 0.90929742682568171 +sin(x) @ 1000 = 0.82687954053200252 +sin(x) @ 1.0000000000000001e+300 = -0.81788191211590855 +sin(x) @ -1.0000000000000001e+300 = 0.81788191211590855 +sin(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +sinc(x) @ -2.5 = 0.23938885764158258 +sinc(x) @ -1 = 0.8414709848078965 +sinc(x) @ -0.5 = 0.95885107720840601 +sinc(x) @ 0 = 1 +sinc(x) @ 0.25 = 0.98961583701809175 +sinc(x) @ 1 = 0.8414709848078965 +sinc(x) @ 2 = 0.45464871341284085 +sinc(x) @ 1000 = 0.00082687954053200249 +sinc(x) @ 1.0000000000000001e+300 = -8.1788191211590848e-301 +sinc(x) @ -1.0000000000000001e+300 = -8.1788191211590848e-301 +sinc(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +sind(x) @ -2.5 = -0.043619387365336 +sind(x) @ -1 = -0.017452406437283512 +sind(x) @ -0.5 = -0.0087265354983739347 +sind(x) @ 0 = 0 +sind(x) @ 0.25 = 0.0043633092847465711 +sind(x) @ 1 = 0.017452406437283512 +sind(x) @ 2 = 0.034899496702500969 +sind(x) @ 1000 = -0.98480775301220791 +sind(x) @ 1.0000000000000001e+300 = -0.74635556214681953 +sind(x) @ -1.0000000000000001e+300 = 0.74635556214681953 +sind(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +sinh(x) @ -2.5 = -6.0502044810397875 +sinh(x) @ -1 = -1.1752011936438014 +sinh(x) @ -0.5 = -0.52109530549374738 +sinh(x) @ 0 = 0 +sinh(x) @ 0.25 = 0.25261231680816831 +sinh(x) @ 1 = 1.1752011936438014 +sinh(x) @ 2 = 3.6268604078470186 +sinh(x) @ 1000 = inf +sinh(x) @ 1.0000000000000001e+300 = inf +sinh(x) @ -1.0000000000000001e+300 = -inf +sinh(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +sqr(x) @ -2.5 = 6.25 +sqr(x) @ -1 = 1 +sqr(x) @ -0.5 = 0.25 +sqr(x) @ 0 = 0 +sqr(x) @ 0.25 = 0.0625 +sqr(x) @ 1 = 1 +sqr(x) @ 2 = 4 +sqr(x) @ 1000 = 1000000 +sqr(x) @ 1.0000000000000001e+300 = -1.7976931348623157e+308 +sqr(x) @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +sqr(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +sqrt(x) @ -2.5 = -1.7976931348623157e+308 +sqrt(x) @ -1 = -1.7976931348623157e+308 +sqrt(x) @ -0.5 = -1.7976931348623157e+308 +sqrt(x) @ 0 = 0 +sqrt(x) @ 0.25 = 0.5 +sqrt(x) @ 1 = 1 +sqrt(x) @ 2 = 1.4142135623730951 +sqrt(x) @ 1000 = 31.622776601683793 +sqrt(x) @ 1.0000000000000001e+300 = 9.9999999999999998e+149 +sqrt(x) @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +sqrt(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +tan(x) @ -2.5 = 0.7470222972386602 +tan(x) @ -1 = -1.5574077246549021 +tan(x) @ -0.5 = -0.54630248984379048 +tan(x) @ 0 = 0 +tan(x) @ 0.25 = 0.25534192122103627 +tan(x) @ 1 = 1.5574077246549021 +tan(x) @ 2 = -2.1850398632615189 +tan(x) @ 1000 = 1.4703241557027187 +tan(x) @ 1.0000000000000001e+300 = 1.4214488238747243 +tan(x) @ -1.0000000000000001e+300 = -1.4214488238747243 +tan(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +tand(x) @ -2.5 = -0.043660942908512058 +tand(x) @ -1 = -0.017455064928217585 +tand(x) @ -0.5 = -0.0087268677907587893 +tand(x) @ 0 = 0 +tand(x) @ 0.25 = 0.0043633508207015668 +tand(x) @ 1 = 0.017455064928217585 +tand(x) @ 2 = 0.03492076949174773 +tand(x) @ 1000 = -5.6712818196176791 +tand(x) @ 1.0000000000000001e+300 = 1.1214160466583769 +tand(x) @ -1.0000000000000001e+300 = -1.1214160466583769 +tand(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +tanh(x) @ -2.5 = -0.98661429815143031 +tanh(x) @ -1 = -0.76159415595576485 +tanh(x) @ -0.5 = -0.46211715726000974 +tanh(x) @ 0 = 0 +tanh(x) @ 0.25 = 0.24491866240370913 +tanh(x) @ 1 = 0.76159415595576485 +tanh(x) @ 2 = 0.9640275800758169 +tanh(x) @ 1000 = 1 +tanh(x) @ 1.0000000000000001e+300 = 1 +tanh(x) @ -1.0000000000000001e+300 = -1 +tanh(x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +atan2(x,0.5) @ -2.5 = -1.3734007669450159 +atan2(x,0.5) @ -1 = -1.1071487177940904 +atan2(x,0.5) @ -0.5 = -0.78539816339744828 +atan2(x,0.5) @ 0 = 0 +atan2(x,0.5) @ 0.25 = 0.46364760900080609 +atan2(x,0.5) @ 1 = 1.1071487177940904 +atan2(x,0.5) @ 2 = 1.3258176636680326 +atan2(x,0.5) @ 1000 = 1.5702963268365633 +atan2(x,0.5) @ 1.0000000000000001e+300 = 1.5707963267948966 +atan2(x,0.5) @ -1.0000000000000001e+300 = -1.5707963267948966 +atan2(x,0.5) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +atan2(0.5,x) @ -2.5 = 2.9441970937399127 +atan2(0.5,x) @ -1 = 2.677945044588987 +atan2(0.5,x) @ -0.5 = 2.3561944901923448 +atan2(0.5,x) @ 0 = 1.5707963267948966 +atan2(0.5,x) @ 0.25 = 1.1071487177940904 +atan2(0.5,x) @ 1 = 0.46364760900080609 +atan2(0.5,x) @ 2 = 0.24497866312686414 +atan2(0.5,x) @ 1000 = 0.00049999995833333955 +atan2(0.5,x) @ 1.0000000000000001e+300 = 5.0000000000000001e-301 +atan2(0.5,x) @ -1.0000000000000001e+300 = 3.1415926535897931 +atan2(0.5,x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +atan2d(x,-0.5) @ -2.5 = -101.30993247402021 +atan2d(x,-0.5) @ -1 = -116.56505117707799 +atan2d(x,-0.5) @ -0.5 = -135 +atan2d(x,-0.5) @ 0 = 180 +atan2d(x,-0.5) @ 0.25 = 153.434948822922 +atan2d(x,-0.5) @ 1 = 116.56505117707799 +atan2d(x,-0.5) @ 2 = 104.03624346792648 +atan2d(x,-0.5) @ 1000 = 90.028647887369232 +atan2d(x,-0.5) @ 1.0000000000000001e+300 = 90 +atan2d(x,-0.5) @ -1.0000000000000001e+300 = -90 +atan2d(x,-0.5) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +dim(x,1) @ -2.5 = 0 +dim(x,1) @ -1 = 0 +dim(x,1) @ -0.5 = 0 +dim(x,1) @ 0 = 0 +dim(x,1) @ 0.25 = 0 +dim(x,1) @ 1 = 0 +dim(x,1) @ 2 = 1 +dim(x,1) @ 1000 = 999 +dim(x,1) @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +dim(x,1) @ -1.0000000000000001e+300 = 0 +dim(x,1) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +dim(1,x) @ -2.5 = 3.5 +dim(1,x) @ -1 = 2 +dim(1,x) @ -0.5 = 1.5 +dim(1,x) @ 0 = 1 +dim(1,x) @ 0.25 = 0.75 +dim(1,x) @ 1 = 0 +dim(1,x) @ 2 = 0 +dim(1,x) @ 1000 = 0 +dim(1,x) @ 1.0000000000000001e+300 = 0 +dim(1,x) @ -1.0000000000000001e+300 = 1.0000000000000001e+300 +dim(1,x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +fmod(x,0.75) @ -2.5 = -0.25 +fmod(x,0.75) @ -1 = -0.25 +fmod(x,0.75) @ -0.5 = -0.5 +fmod(x,0.75) @ 0 = 0 +fmod(x,0.75) @ 0.25 = 0.25 +fmod(x,0.75) @ 1 = 0.25 +fmod(x,0.75) @ 2 = 0.5 +fmod(x,0.75) @ 1000 = 0.25 +fmod(x,0.75) @ 1.0000000000000001e+300 = 0 +fmod(x,0.75) @ -1.0000000000000001e+300 = -0 +fmod(x,0.75) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +mod(x,0) @ -2.5 = -1.7976931348623157e+308 +mod(x,0) @ -1 = -1.7976931348623157e+308 +mod(x,0) @ -0.5 = -1.7976931348623157e+308 +mod(x,0) @ 0 = -1.7976931348623157e+308 +mod(x,0) @ 0.25 = -1.7976931348623157e+308 +mod(x,0) @ 1 = -1.7976931348623157e+308 +mod(x,0) @ 2 = -1.7976931348623157e+308 +mod(x,0) @ 1000 = -1.7976931348623157e+308 +mod(x,0) @ 1.0000000000000001e+300 = -1.7976931348623157e+308 +mod(x,0) @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +mod(x,0) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +mod(7.5,x) @ -2.5 = 0 +mod(7.5,x) @ -1 = 0.5 +mod(7.5,x) @ -0.5 = 0 +mod(7.5,x) @ 0 = -1.7976931348623157e+308 +mod(7.5,x) @ 0.25 = 0 +mod(7.5,x) @ 1 = 0.5 +mod(7.5,x) @ 2 = 1.5 +mod(7.5,x) @ 1000 = 7.5 +mod(7.5,x) @ 1.0000000000000001e+300 = 7.5 +mod(7.5,x) @ -1.0000000000000001e+300 = 7.5 +mod(7.5,x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +pow(x,0.5) @ -2.5 = nan +pow(x,0.5) @ -1 = nan +pow(x,0.5) @ -0.5 = nan +pow(x,0.5) @ 0 = 0 +pow(x,0.5) @ 0.25 = 0.5 +pow(x,0.5) @ 1 = 1 +pow(x,0.5) @ 2 = 1.4142135623730951 +pow(x,0.5) @ 1000 = 31.622776601683793 +pow(x,0.5) @ 1.0000000000000001e+300 = 9.9999999999999998e+149 +pow(x,0.5) @ -1.0000000000000001e+300 = nan +pow(x,0.5) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +pow(x,2) @ -2.5 = 6.25 +pow(x,2) @ -1 = 1 +pow(x,2) @ -0.5 = 0.25 +pow(x,2) @ 0 = 0 +pow(x,2) @ 0.25 = 0.0625 +pow(x,2) @ 1 = 1 +pow(x,2) @ 2 = 4 +pow(x,2) @ 1000 = 1000000 +pow(x,2) @ 1.0000000000000001e+300 = inf +pow(x,2) @ -1.0000000000000001e+300 = inf +pow(x,2) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +pow(x,-1) @ -2.5 = -0.40000000000000002 +pow(x,-1) @ -1 = -1 +pow(x,-1) @ -0.5 = -2 +pow(x,-1) @ 0 = inf +pow(x,-1) @ 0.25 = 4 +pow(x,-1) @ 1 = 1 +pow(x,-1) @ 2 = 0.5 +pow(x,-1) @ 1000 = 0.001 +pow(x,-1) @ 1.0000000000000001e+300 = 1e-300 +pow(x,-1) @ -1.0000000000000001e+300 = -1e-300 +pow(x,-1) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +pow(2,x) @ -2.5 = 0.17677669529663689 +pow(2,x) @ -1 = 0.5 +pow(2,x) @ -0.5 = 0.70710678118654757 +pow(2,x) @ 0 = 1 +pow(2,x) @ 0.25 = 1.189207115002721 +pow(2,x) @ 1 = 2 +pow(2,x) @ 2 = 4 +pow(2,x) @ 1000 = 1.0715086071862673e+301 +pow(2,x) @ 1.0000000000000001e+300 = inf +pow(2,x) @ -1.0000000000000001e+300 = 0 +pow(2,x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +sign(2,x) @ -2.5 = -2 +sign(2,x) @ -1 = -2 +sign(2,x) @ -0.5 = -2 +sign(2,x) @ 0 = 2 +sign(2,x) @ 0.25 = 2 +sign(2,x) @ 1 = 2 +sign(2,x) @ 2 = 2 +sign(2,x) @ 1000 = 2 +sign(2,x) @ 1.0000000000000001e+300 = 2 +sign(2,x) @ -1.0000000000000001e+300 = -2 +sign(2,x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +sign(x,-1) @ -2.5 = -2.5 +sign(x,-1) @ -1 = -1 +sign(x,-1) @ -0.5 = -0.5 +sign(x,-1) @ 0 = -0 +sign(x,-1) @ 0.25 = -0.25 +sign(x,-1) @ 1 = -1 +sign(x,-1) @ 2 = -2 +sign(x,-1) @ 1000 = -1000 +sign(x,-1) @ 1.0000000000000001e+300 = -1.0000000000000001e+300 +sign(x,-1) @ -1.0000000000000001e+300 = -1.0000000000000001e+300 +sign(x,-1) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +qif(x,2,3) @ -2.5 = 2 +qif(x,2,3) @ -1 = 2 +qif(x,2,3) @ -0.5 = 2 +qif(x,2,3) @ 0 = 3 +qif(x,2,3) @ 0.25 = 2 +qif(x,2,3) @ 1 = 2 +qif(x,2,3) @ 2 = 2 +qif(x,2,3) @ 1000 = 2 +qif(x,2,3) @ 1.0000000000000001e+300 = 2 +qif(x,2,3) @ -1.0000000000000001e+300 = 2 +qif(x,2,3) @ -1.7976931348623157e+308 = 2 +qif(1,x,3) @ -2.5 = -2.5 +qif(1,x,3) @ -1 = -1 +qif(1,x,3) @ -0.5 = -0.5 +qif(1,x,3) @ 0 = 0 +qif(1,x,3) @ 0.25 = 0.25 +qif(1,x,3) @ 1 = 1 +qif(1,x,3) @ 2 = 2 +qif(1,x,3) @ 1000 = 1000 +qif(1,x,3) @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +qif(1,x,3) @ -1.0000000000000001e+300 = -1.0000000000000001e+300 +qif(1,x,3) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +qif(0,2,x) @ -2.5 = -2.5 +qif(0,2,x) @ -1 = -1 +qif(0,2,x) @ -0.5 = -0.5 +qif(0,2,x) @ 0 = 0 +qif(0,2,x) @ 0.25 = 0.25 +qif(0,2,x) @ 1 = 1 +qif(0,2,x) @ 2 = 2 +qif(0,2,x) @ 1000 = 1000 +qif(0,2,x) @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +qif(0,2,x) @ -1.0000000000000001e+300 = -1.0000000000000001e+300 +qif(0,2,x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +max(x,1,-1) @ -2.5 = 1 +max(x,1,-1) @ -1 = 1 +max(x,1,-1) @ -0.5 = 1 +max(x,1,-1) @ 0 = 1 +max(x,1,-1) @ 0.25 = 1 +max(x,1,-1) @ 1 = 1 +max(x,1,-1) @ 2 = 2 +max(x,1,-1) @ 1000 = 1000 +max(x,1,-1) @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +max(x,1,-1) @ -1.0000000000000001e+300 = 1 +max(x,1,-1) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +min(x,1,-1) @ -2.5 = -2.5 +min(x,1,-1) @ -1 = -1 +min(x,1,-1) @ -0.5 = -1 +min(x,1,-1) @ 0 = -1 +min(x,1,-1) @ 0.25 = -1 +min(x,1,-1) @ 1 = -1 +min(x,1,-1) @ 2 = -1 +min(x,1,-1) @ 1000 = -1 +min(x,1,-1) @ 1.0000000000000001e+300 = -1 +min(x,1,-1) @ -1.0000000000000001e+300 = -1.0000000000000001e+300 +min(x,1,-1) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +max(x,) @ -2.5 = -1.7976931348623157e+308 +max(x,) @ -1 = -1.7976931348623157e+308 +max(x,) @ -0.5 = -1.7976931348623157e+308 +max(x,) @ 0 = -1.7976931348623157e+308 +max(x,) @ 0.25 = -1.7976931348623157e+308 +max(x,) @ 1 = -1.7976931348623157e+308 +max(x,) @ 2 = -1.7976931348623157e+308 +max(x,) @ 1000 = -1.7976931348623157e+308 +max(x,) @ 1.0000000000000001e+300 = -1.7976931348623157e+308 +max(x,) @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +max(x,) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +min(2,x) @ -2.5 = -2.5 +min(2,x) @ -1 = -1 +min(2,x) @ -0.5 = -0.5 +min(2,x) @ 0 = 0 +min(2,x) @ 0.25 = 0.25 +min(2,x) @ 1 = 1 +min(2,x) @ 2 = 2 +min(2,x) @ 1000 = 2 +min(2,x) @ 1.0000000000000001e+300 = 2 +min(2,x) @ -1.0000000000000001e+300 = -1.0000000000000001e+300 +min(2,x) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +-x @ -2.5 = 2.5 +-x @ -1 = 1 +-x @ -0.5 = 0.5 +-x @ 0 = -0 +-x @ 0.25 = -0.25 +-x @ 1 = -1 +-x @ 2 = -2 +-x @ 1000 = -1000 +-x @ 1.0000000000000001e+300 = -1.0000000000000001e+300 +-x @ -1.0000000000000001e+300 = 1.0000000000000001e+300 +-x @ -1.7976931348623157e+308 = -1.7976931348623157e+308 ++x @ -2.5 = -2.5 ++x @ -1 = -1 ++x @ -0.5 = -0.5 ++x @ 0 = 0 ++x @ 0.25 = 0.25 ++x @ 1 = 1 ++x @ 2 = 2 ++x @ 1000 = 1000 ++x @ 1.0000000000000001e+300 = 1.0000000000000001e+300 ++x @ -1.0000000000000001e+300 = -1.0000000000000001e+300 ++x @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +!x @ -2.5 = 0 +!x @ -1 = 0 +!x @ -0.5 = 0 +!x @ 0 = 1 +!x @ 0.25 = 0 +!x @ 1 = 0 +!x @ 2 = 0 +!x @ 1000 = 0 +!x @ 1.0000000000000001e+300 = 0 +!x @ -1.0000000000000001e+300 = 0 +!x @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +.not.x @ -2.5 = 0 +.not.x @ -1 = 0 +.not.x @ -0.5 = 0 +.not.x @ 0 = 1 +.not.x @ 0.25 = 0 +.not.x @ 1 = 0 +.not.x @ 2 = 0 +.not.x @ 1000 = 0 +.not.x @ 1.0000000000000001e+300 = 0 +.not.x @ -1.0000000000000001e+300 = 0 +.not.x @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x+1 @ -2.5 = -1.5 +x+1 @ -1 = 0 +x+1 @ -0.5 = 0.5 +x+1 @ 0 = 1 +x+1 @ 0.25 = 1.25 +x+1 @ 1 = 2 +x+1 @ 2 = 3 +x+1 @ 1000 = 1001 +x+1 @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +x+1 @ -1.0000000000000001e+300 = -1.0000000000000001e+300 +x+1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x-1 @ -2.5 = -3.5 +x-1 @ -1 = -2 +x-1 @ -0.5 = -1.5 +x-1 @ 0 = -1 +x-1 @ 0.25 = -0.75 +x-1 @ 1 = 0 +x-1 @ 2 = 1 +x-1 @ 1000 = 999 +x-1 @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +x-1 @ -1.0000000000000001e+300 = -1.0000000000000001e+300 +x-1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x*2 @ -2.5 = -5 +x*2 @ -1 = -2 +x*2 @ -0.5 = -1 +x*2 @ 0 = 0 +x*2 @ 0.25 = 0.5 +x*2 @ 1 = 2 +x*2 @ 2 = 4 +x*2 @ 1000 = 2000 +x*2 @ 1.0000000000000001e+300 = 2.0000000000000001e+300 +x*2 @ -1.0000000000000001e+300 = -2.0000000000000001e+300 +x*2 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x/0.5 @ -2.5 = -5 +x/0.5 @ -1 = -2 +x/0.5 @ -0.5 = -1 +x/0.5 @ 0 = 0 +x/0.5 @ 0.25 = 0.5 +x/0.5 @ 1 = 2 +x/0.5 @ 2 = 4 +x/0.5 @ 1000 = 2000 +x/0.5 @ 1.0000000000000001e+300 = 2.0000000000000001e+300 +x/0.5 @ -1.0000000000000001e+300 = -2.0000000000000001e+300 +x/0.5 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x/0 @ -2.5 = -1.7976931348623157e+308 +x/0 @ -1 = -1.7976931348623157e+308 +x/0 @ -0.5 = -1.7976931348623157e+308 +x/0 @ 0 = -1.7976931348623157e+308 +x/0 @ 0.25 = -1.7976931348623157e+308 +x/0 @ 1 = -1.7976931348623157e+308 +x/0 @ 2 = -1.7976931348623157e+308 +x/0 @ 1000 = -1.7976931348623157e+308 +x/0 @ 1.0000000000000001e+300 = -1.7976931348623157e+308 +x/0 @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +x/0 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +1/x @ -2.5 = -0.40000000000000002 +1/x @ -1 = -1 +1/x @ -0.5 = -2 +1/x @ 0 = -1.7976931348623157e+308 +1/x @ 0.25 = 4 +1/x @ 1 = 1 +1/x @ 2 = 0.5 +1/x @ 1000 = 0.001 +1/x @ 1.0000000000000001e+300 = 1e-300 +1/x @ -1.0000000000000001e+300 = -1e-300 +1/x @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x**2 @ -2.5 = 6.25 +x**2 @ -1 = 1 +x**2 @ -0.5 = 0.25 +x**2 @ 0 = 0 +x**2 @ 0.25 = 0.0625 +x**2 @ 1 = 1 +x**2 @ 2 = 4 +x**2 @ 1000 = 1000000 +x**2 @ 1.0000000000000001e+300 = inf +x**2 @ -1.0000000000000001e+300 = inf +x**2 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x**0.5 @ -2.5 = nan +x**0.5 @ -1 = nan +x**0.5 @ -0.5 = nan +x**0.5 @ 0 = 0 +x**0.5 @ 0.25 = 0.5 +x**0.5 @ 1 = 1 +x**0.5 @ 2 = 1.4142135623730951 +x**0.5 @ 1000 = 31.622776601683793 +x**0.5 @ 1.0000000000000001e+300 = 9.9999999999999998e+149 +x**0.5 @ -1.0000000000000001e+300 = nan +x**0.5 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x**-1 @ -2.5 = -0.40000000000000002 +x**-1 @ -1 = -1 +x**-1 @ -0.5 = -2 +x**-1 @ 0 = inf +x**-1 @ 0.25 = 4 +x**-1 @ 1 = 1 +x**-1 @ 2 = 0.5 +x**-1 @ 1000 = 0.001 +x**-1 @ 1.0000000000000001e+300 = 1e-300 +x**-1 @ -1.0000000000000001e+300 = -1e-300 +x**-1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x<<2 @ -2.5 = -10 +x<<2 @ -1 = -4 +x<<2 @ -0.5 = -2 +x<<2 @ 0 = 0 +x<<2 @ 0.25 = 1 +x<<2 @ 1 = 4 +x<<2 @ 2 = 8 +x<<2 @ 1000 = 4000 +x<<2 @ 1.0000000000000001e+300 = 4.0000000000000002e+300 +x<<2 @ -1.0000000000000001e+300 = -4.0000000000000002e+300 +x<<2 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x>>1 @ -2.5 = -1.25 +x>>1 @ -1 = -0.5 +x>>1 @ -0.5 = -0.25 +x>>1 @ 0 = 0 +x>>1 @ 0.25 = 0.125 +x>>1 @ 1 = 0.5 +x>>1 @ 2 = 1 +x>>1 @ 1000 = 500 +x>>1 @ 1.0000000000000001e+300 = 5.0000000000000003e+299 +x>>1 @ -1.0000000000000001e+300 = -5.0000000000000003e+299 +x>>1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x<1 @ -2.5 = 0 +x>1 @ -1 = 0 +x>1 @ -0.5 = 0 +x>1 @ 0 = 0 +x>1 @ 0.25 = 0 +x>1 @ 1 = 0 +x>1 @ 2 = 1 +x>1 @ 1000 = 1 +x>1 @ 1.0000000000000001e+300 = 1 +x>1 @ -1.0000000000000001e+300 = 0 +x>1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x.gt.1 @ -2.5 = 0 +x.gt.1 @ -1 = 0 +x.gt.1 @ -0.5 = 0 +x.gt.1 @ 0 = 0 +x.gt.1 @ 0.25 = 0 +x.gt.1 @ 1 = 0 +x.gt.1 @ 2 = 1 +x.gt.1 @ 1000 = 1 +x.gt.1 @ 1.0000000000000001e+300 = 1 +x.gt.1 @ -1.0000000000000001e+300 = 0 +x.gt.1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x>=1 @ -2.5 = 0 +x>=1 @ -1 = 0 +x>=1 @ -0.5 = 0 +x>=1 @ 0 = 0 +x>=1 @ 0.25 = 0 +x>=1 @ 1 = 1 +x>=1 @ 2 = 1 +x>=1 @ 1000 = 1 +x>=1 @ 1.0000000000000001e+300 = 1 +x>=1 @ -1.0000000000000001e+300 = 0 +x>=1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x.ge.1 @ -2.5 = 0 +x.ge.1 @ -1 = 0 +x.ge.1 @ -0.5 = 0 +x.ge.1 @ 0 = 0 +x.ge.1 @ 0.25 = 0 +x.ge.1 @ 1 = 1 +x.ge.1 @ 2 = 1 +x.ge.1 @ 1000 = 1 +x.ge.1 @ 1.0000000000000001e+300 = 1 +x.ge.1 @ -1.0000000000000001e+300 = 0 +x.ge.1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x==1 @ -2.5 = 0 +x==1 @ -1 = 0 +x==1 @ -0.5 = 0 +x==1 @ 0 = 0 +x==1 @ 0.25 = 0 +x==1 @ 1 = 1 +x==1 @ 2 = 0 +x==1 @ 1000 = 0 +x==1 @ 1.0000000000000001e+300 = 0 +x==1 @ -1.0000000000000001e+300 = 0 +x==1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x.eq.1 @ -2.5 = 0 +x.eq.1 @ -1 = 0 +x.eq.1 @ -0.5 = 0 +x.eq.1 @ 0 = 0 +x.eq.1 @ 0.25 = 0 +x.eq.1 @ 1 = 1 +x.eq.1 @ 2 = 0 +x.eq.1 @ 1000 = 0 +x.eq.1 @ 1.0000000000000001e+300 = 0 +x.eq.1 @ -1.0000000000000001e+300 = 0 +x.eq.1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x!=1 @ -2.5 = 1 +x!=1 @ -1 = 1 +x!=1 @ -0.5 = 1 +x!=1 @ 0 = 1 +x!=1 @ 0.25 = 1 +x!=1 @ 1 = 0 +x!=1 @ 2 = 1 +x!=1 @ 1000 = 1 +x!=1 @ 1.0000000000000001e+300 = 1 +x!=1 @ -1.0000000000000001e+300 = 1 +x!=1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x.ne.1 @ -2.5 = 1 +x.ne.1 @ -1 = 1 +x.ne.1 @ -0.5 = 1 +x.ne.1 @ 0 = 1 +x.ne.1 @ 0.25 = 1 +x.ne.1 @ 1 = 0 +x.ne.1 @ 2 = 1 +x.ne.1 @ 1000 = 1 +x.ne.1 @ 1.0000000000000001e+300 = 1 +x.ne.1 @ -1.0000000000000001e+300 = 1 +x.ne.1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x&3 @ -2.5 = 1 +x&3 @ -1 = 3 +x&3 @ -0.5 = 3 +x&3 @ 0 = 0 +x&3 @ 0.25 = 0 +x&3 @ 1 = 1 +x&3 @ 2 = 2 +x&3 @ 1000 = 0 +x&3 @ 1.0000000000000001e+300 = 0 +x&3 @ -1.0000000000000001e+300 = 0 +x&3 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x^3 @ -2.5 = -1.5 +x^3 @ -1 = -4 +x^3 @ -0.5 = -3.5 +x^3 @ 0 = 3 +x^3 @ 0.25 = 3.25 +x^3 @ 1 = 2 +x^3 @ 2 = 1 +x^3 @ 1000 = 1003 +x^3 @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +x^3 @ -1.0000000000000001e+300 = -1.0000000000000001e+300 +x^3 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x|3 @ -2.5 = -0.5 +x|3 @ -1 = -1 +x|3 @ -0.5 = -0.5 +x|3 @ 0 = 3 +x|3 @ 0.25 = 3.25 +x|3 @ 1 = 3 +x|3 @ 2 = 3 +x|3 @ 1000 = 1003 +x|3 @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +x|3 @ -1.0000000000000001e+300 = -1.0000000000000001e+300 +x|3 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x&&1 @ -2.5 = 1 +x&&1 @ -1 = 1 +x&&1 @ -0.5 = 1 +x&&1 @ 0 = 0 +x&&1 @ 0.25 = 1 +x&&1 @ 1 = 1 +x&&1 @ 2 = 1 +x&&1 @ 1000 = 1 +x&&1 @ 1.0000000000000001e+300 = 1 +x&&1 @ -1.0000000000000001e+300 = 1 +x&&1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x&&0 @ -2.5 = 0 +x&&0 @ -1 = 0 +x&&0 @ -0.5 = 0 +x&&0 @ 0 = 0 +x&&0 @ 0.25 = 0 +x&&0 @ 1 = 0 +x&&0 @ 2 = 0 +x&&0 @ 1000 = 0 +x&&0 @ 1.0000000000000001e+300 = 0 +x&&0 @ -1.0000000000000001e+300 = 0 +x&&0 @ -1.7976931348623157e+308 = 0 +x.and.1 @ -2.5 = 1 +x.and.1 @ -1 = 1 +x.and.1 @ -0.5 = 1 +x.and.1 @ 0 = 0 +x.and.1 @ 0.25 = 1 +x.and.1 @ 1 = 1 +x.and.1 @ 2 = 1 +x.and.1 @ 1000 = 1 +x.and.1 @ 1.0000000000000001e+300 = 1 +x.and.1 @ -1.0000000000000001e+300 = 1 +x.and.1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x^^1 @ -2.5 = 0 +x^^1 @ -1 = 0 +x^^1 @ -0.5 = 0 +x^^1 @ 0 = 1 +x^^1 @ 0.25 = 0 +x^^1 @ 1 = 0 +x^^1 @ 2 = 0 +x^^1 @ 1000 = 0 +x^^1 @ 1.0000000000000001e+300 = 0 +x^^1 @ -1.0000000000000001e+300 = 0 +x^^1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x||0 @ -2.5 = 1 +x||0 @ -1 = 1 +x||0 @ -0.5 = 1 +x||0 @ 0 = 0 +x||0 @ 0.25 = 1 +x||0 @ 1 = 1 +x||0 @ 2 = 1 +x||0 @ 1000 = 1 +x||0 @ 1.0000000000000001e+300 = 1 +x||0 @ -1.0000000000000001e+300 = 1 +x||0 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x||1 @ -2.5 = 1 +x||1 @ -1 = 1 +x||1 @ -0.5 = 1 +x||1 @ 0 = 1 +x||1 @ 0.25 = 1 +x||1 @ 1 = 1 +x||1 @ 2 = 1 +x||1 @ 1000 = 1 +x||1 @ 1.0000000000000001e+300 = 1 +x||1 @ -1.0000000000000001e+300 = 1 +x||1 @ -1.7976931348623157e+308 = 1 +x.or.0 @ -2.5 = 1 +x.or.0 @ -1 = 1 +x.or.0 @ -0.5 = 1 +x.or.0 @ 0 = 0 +x.or.0 @ 0.25 = 1 +x.or.0 @ 1 = 1 +x.or.0 @ 2 = 1 +x.or.0 @ 1000 = 1 +x.or.0 @ 1.0000000000000001e+300 = 1 +x.or.0 @ -1.0000000000000001e+300 = 1 +x.or.0 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x.eqv.1 @ -2.5 = 1 +x.eqv.1 @ -1 = 1 +x.eqv.1 @ -0.5 = 1 +x.eqv.1 @ 0 = 0 +x.eqv.1 @ 0.25 = 1 +x.eqv.1 @ 1 = 1 +x.eqv.1 @ 2 = 1 +x.eqv.1 @ 1000 = 1 +x.eqv.1 @ 1.0000000000000001e+300 = 1 +x.eqv.1 @ -1.0000000000000001e+300 = 1 +x.eqv.1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x.neqv.1 @ -2.5 = 0 +x.neqv.1 @ -1 = 0 +x.neqv.1 @ -0.5 = 0 +x.neqv.1 @ 0 = 1 +x.neqv.1 @ 0.25 = 0 +x.neqv.1 @ 1 = 0 +x.neqv.1 @ 2 = 0 +x.neqv.1 @ 1000 = 0 +x.neqv.1 @ 1.0000000000000001e+300 = 0 +x.neqv.1 @ -1.0000000000000001e+300 = 0 +x.neqv.1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x.xor.1 @ -2.5 = 0 +x.xor.1 @ -1 = 0 +x.xor.1 @ -0.5 = 0 +x.xor.1 @ 0 = 1 +x.xor.1 @ 0.25 = 0 +x.xor.1 @ 1 = 0 +x.xor.1 @ 2 = 0 +x.xor.1 @ 1000 = 0 +x.xor.1 @ 1.0000000000000001e+300 = 0 +x.xor.1 @ -1.0000000000000001e+300 = 0 +x.xor.1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x*1e300 @ -2.5 = -2.5000000000000001e+300 +x*1e300 @ -1 = -1.0000000000000001e+300 +x*1e300 @ -0.5 = -5.0000000000000003e+299 +x*1e300 @ 0 = 0 +x*1e300 @ 0.25 = 2.5000000000000001e+299 +x*1e300 @ 1 = 1.0000000000000001e+300 +x*1e300 @ 2 = 2.0000000000000001e+300 +x*1e300 @ 1000 = 1e+303 +x*1e300 @ 1.0000000000000001e+300 = -1.7976931348623157e+308 +x*1e300 @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +x*1e300 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x+ @ -2.5 = 1.7976931348623157e+308 +x+ @ -1 = 1.7976931348623157e+308 +x+ @ -0.5 = 1.7976931348623157e+308 +x+ @ 0 = 1.7976931348623157e+308 +x+ @ 0.25 = 1.7976931348623157e+308 +x+ @ 1 = 1.7976931348623157e+308 +x+ @ 2 = 1.7976931348623157e+308 +x+ @ 1000 = 1.7976931348623157e+308 +x+ @ 1.0000000000000001e+300 = -1.7976931348623157e+308 +x+ @ -1.0000000000000001e+300 = 1.7976931248623157e+308 +x+ @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x- @ -2.5 = -1.7976931348623157e+308 +x- @ -1 = -1.7976931348623157e+308 +x- @ -0.5 = -1.7976931348623157e+308 +x- @ 0 = -1.7976931348623157e+308 +x- @ 0.25 = -1.7976931348623157e+308 +x- @ 1 = -1.7976931348623157e+308 +x- @ 2 = -1.7976931348623157e+308 +x- @ 1000 = -1.7976931348623157e+308 +x- @ 1.0000000000000001e+300 = -1.7976931248623157e+308 +x- @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +x- @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +/x @ -2.5 = -7.190772539449263e+307 +/x @ -1 = -1.7976931348623157e+308 +/x @ -0.5 = -1.7976931348623157e+308 +/x @ 0 = -1.7976931348623157e+308 +/x @ 0.25 = -1.7976931348623157e+308 +/x @ 1 = 1.7976931348623157e+308 +/x @ 2 = 8.9884656743115785e+307 +/x @ 1000 = 1.7976931348623156e+305 +/x @ 1.0000000000000001e+300 = 179769313.48623157 +/x @ -1.0000000000000001e+300 = -179769313.48623157 +/x @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x/ @ -2.5 = -1.3906711615670009e-308 +x/ @ -1 = -5.5626846462680035e-309 +x/ @ -0.5 = -2.7813423231340017e-309 +x/ @ 0 = 0 +x/ @ 0.25 = 1.3906711615670009e-309 +x/ @ 1 = 5.5626846462680035e-309 +x/ @ 2 = 1.1125369292536007e-308 +x/ @ 1000 = 5.5626846462680041e-306 +x/ @ 1.0000000000000001e+300 = 5.5626846462680046e-09 +x/ @ -1.0000000000000001e+300 = -5.5626846462680046e-09 +x/ @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x*x*x @ -2.5 = -15.625 +x*x*x @ -1 = -1 +x*x*x @ -0.5 = -0.125 +x*x*x @ 0 = 0 +x*x*x @ 0.25 = 0.015625 +x*x*x @ 1 = 1 +x*x*x @ 2 = 8 +x*x*x @ 1000 = 1000000000 +x*x*x @ 1.0000000000000001e+300 = -1.7976931348623157e+308 +x*x*x @ -1.0000000000000001e+300 = -1.7976931348623157e+308 +x*x*x @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +1e999 @ -2.5 = inf +1e999 @ -1 = inf +1e999 @ -0.5 = inf +1e999 @ 0 = inf +1e999 @ 0.25 = inf +1e999 @ 1 = inf +1e999 @ 2 = inf +1e999 @ 1000 = inf +1e999 @ 1.0000000000000001e+300 = inf +1e999 @ -1.0000000000000001e+300 = inf +1e999 @ -1.7976931348623157e+308 = inf +1e999-1e999 @ -2.5 = nan +1e999-1e999 @ -1 = nan +1e999-1e999 @ -0.5 = nan +1e999-1e999 @ 0 = nan +1e999-1e999 @ 0.25 = nan +1e999-1e999 @ 1 = nan +1e999-1e999 @ 2 = nan +1e999-1e999 @ 1000 = nan +1e999-1e999 @ 1.0000000000000001e+300 = nan +1e999-1e999 @ -1.0000000000000001e+300 = nan +1e999-1e999 @ -1.7976931348623157e+308 = nan +sin(1e999) @ -2.5 = nan +sin(1e999) @ -1 = nan +sin(1e999) @ -0.5 = nan +sin(1e999) @ 0 = nan +sin(1e999) @ 0.25 = nan +sin(1e999) @ 1 = nan +sin(1e999) @ 2 = nan +sin(1e999) @ 1000 = nan +sin(1e999) @ 1.0000000000000001e+300 = nan +sin(1e999) @ -1.0000000000000001e+300 = nan +sin(1e999) @ -1.7976931348623157e+308 = nan +-x**2 @ -2.5 = -6.25 +-x**2 @ -1 = -1 +-x**2 @ -0.5 = -0.25 +-x**2 @ 0 = -0 +-x**2 @ 0.25 = -0.0625 +-x**2 @ 1 = -1 +-x**2 @ 2 = -4 +-x**2 @ 1000 = -1000000 +-x**2 @ 1.0000000000000001e+300 = -inf +-x**2 @ -1.0000000000000001e+300 = -inf +-x**2 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +!x**2 @ -2.5 = 0 +!x**2 @ -1 = 0 +!x**2 @ -0.5 = 0 +!x**2 @ 0 = 1 +!x**2 @ 0.25 = 0 +!x**2 @ 1 = 0 +!x**2 @ 2 = 0 +!x**2 @ 1000 = 0 +!x**2 @ 1.0000000000000001e+300 = 0 +!x**2 @ -1.0000000000000001e+300 = 0 +!x**2 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +2**-x**2 @ -2.5 = 0.013139006488339289 +2**-x**2 @ -1 = 0.5 +2**-x**2 @ -0.5 = 0.8408964152537145 +2**-x**2 @ 0 = 1 +2**-x**2 @ 0.25 = 0.9576032806985737 +2**-x**2 @ 1 = 0.5 +2**-x**2 @ 2 = 0.0625 +2**-x**2 @ 1000 = 0 +2**-x**2 @ 1.0000000000000001e+300 = 0 +2**-x**2 @ -1.0000000000000001e+300 = 0 +2**-x**2 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +-x*3 @ -2.5 = 7.5 +-x*3 @ -1 = 3 +-x*3 @ -0.5 = 1.5 +-x*3 @ 0 = -0 +-x*3 @ 0.25 = -0.75 +-x*3 @ 1 = -3 +-x*3 @ 2 = -6 +-x*3 @ 1000 = -3000 +-x*3 @ 1.0000000000000001e+300 = -3.0000000000000002e+300 +-x*3 @ -1.0000000000000001e+300 = 3.0000000000000002e+300 +-x*3 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x<<1<3 @ -2.5 = 1 +x<<1<3 @ -1 = 1 +x<<1<3 @ -0.5 = 1 +x<<1<3 @ 0 = 1 +x<<1<3 @ 0.25 = 1 +x<<1<3 @ 1 = 1 +x<<1<3 @ 2 = 0 +x<<1<3 @ 1000 = 0 +x<<1<3 @ 1.0000000000000001e+300 = 0 +x<<1<3 @ -1.0000000000000001e+300 = 1 +x<<1<3 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x.or.x.xor.x @ -2.5 = 0 +x.or.x.xor.x @ -1 = 0 +x.or.x.xor.x @ -0.5 = 0 +x.or.x.xor.x @ 0 = 0 +x.or.x.xor.x @ 0.25 = 0 +x.or.x.xor.x @ 1 = 0 +x.or.x.xor.x @ 2 = 0 +x.or.x.xor.x @ 1000 = 0 +x.or.x.xor.x @ 1.0000000000000001e+300 = 0 +x.or.x.xor.x @ -1.0000000000000001e+300 = 0 +x.or.x.xor.x @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x||x^^x @ -2.5 = 1 +x||x^^x @ -1 = 1 +x||x^^x @ -0.5 = 1 +x||x^^x @ 0 = 0 +x||x^^x @ 0.25 = 1 +x||x^^x @ 1 = 1 +x||x^^x @ 2 = 1 +x||x^^x @ 1000 = 1 +x||x^^x @ 1.0000000000000001e+300 = 1 +x||x^^x @ -1.0000000000000001e+300 = 1 +x||x^^x @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x^^x.eqv.x @ -2.5 = 0 +x^^x.eqv.x @ -1 = 0 +x^^x.eqv.x @ -0.5 = 0 +x^^x.eqv.x @ 0 = 1 +x^^x.eqv.x @ 0.25 = 0 +x^^x.eqv.x @ 1 = 0 +x^^x.eqv.x @ 2 = 0 +x^^x.eqv.x @ 1000 = 0 +x^^x.eqv.x @ 1.0000000000000001e+300 = 0 +x^^x.eqv.x @ -1.0000000000000001e+300 = 0 +x^^x.eqv.x @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +x<3==1 @ -2.5 = 1 +x<3==1 @ -1 = 1 +x<3==1 @ -0.5 = 1 +x<3==1 @ 0 = 1 +x<3==1 @ 0.25 = 1 +x<3==1 @ 1 = 1 +x<3==1 @ 2 = 1 +x<3==1 @ 1000 = 0 +x<3==1 @ 1.0000000000000001e+300 = 0 +x<3==1 @ -1.0000000000000001e+300 = 1 +x<3==1 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +(x+1)*2 @ -2.5 = -3 +(x+1)*2 @ -1 = 0 +(x+1)*2 @ -0.5 = 1 +(x+1)*2 @ 0 = 2 +(x+1)*2 @ 0.25 = 2.5 +(x+1)*2 @ 1 = 4 +(x+1)*2 @ 2 = 6 +(x+1)*2 @ 1000 = 2002 +(x+1)*2 @ 1.0000000000000001e+300 = 2.0000000000000001e+300 +(x+1)*2 @ -1.0000000000000001e+300 = -2.0000000000000001e+300 +(x+1)*2 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +sin(x)**2+cos(x)**2 @ -2.5 = 0.99999999999999989 +sin(x)**2+cos(x)**2 @ -1 = 1 +sin(x)**2+cos(x)**2 @ -0.5 = 1 +sin(x)**2+cos(x)**2 @ 0 = 1 +sin(x)**2+cos(x)**2 @ 0.25 = 0.99999999999999989 +sin(x)**2+cos(x)**2 @ 1 = 1 +sin(x)**2+cos(x)**2 @ 2 = 1 +sin(x)**2+cos(x)**2 @ 1000 = 1 +sin(x)**2+cos(x)**2 @ 1.0000000000000001e+300 = 1 +sin(x)**2+cos(x)**2 @ -1.0000000000000001e+300 = 1 +sin(x)**2+cos(x)**2 @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +max(x,1,2,3,4)-min(x,-1,-2) @ -2.5 = 6.5 +max(x,1,2,3,4)-min(x,-1,-2) @ -1 = 6 +max(x,1,2,3,4)-min(x,-1,-2) @ -0.5 = 6 +max(x,1,2,3,4)-min(x,-1,-2) @ 0 = 6 +max(x,1,2,3,4)-min(x,-1,-2) @ 0.25 = 6 +max(x,1,2,3,4)-min(x,-1,-2) @ 1 = 6 +max(x,1,2,3,4)-min(x,-1,-2) @ 2 = 6 +max(x,1,2,3,4)-min(x,-1,-2) @ 1000 = 1002 +max(x,1,2,3,4)-min(x,-1,-2) @ 1.0000000000000001e+300 = 1.0000000000000001e+300 +max(x,1,2,3,4)-min(x,-1,-2) @ -1.0000000000000001e+300 = 1.0000000000000001e+300 +max(x,1,2,3,4)-min(x,-1,-2) @ -1.7976931348623157e+308 = -1.7976931348623157e+308 +1.e1+1.d1+.5e-1+2.5d+1 @ -2.5 = 45.049999999999997 +1.e1+1.d1+.5e-1+2.5d+1 @ -1 = 45.049999999999997 +1.e1+1.d1+.5e-1+2.5d+1 @ -0.5 = 45.049999999999997 +1.e1+1.d1+.5e-1+2.5d+1 @ 0 = 45.049999999999997 +1.e1+1.d1+.5e-1+2.5d+1 @ 0.25 = 45.049999999999997 +1.e1+1.d1+.5e-1+2.5d+1 @ 1 = 45.049999999999997 +1.e1+1.d1+.5e-1+2.5d+1 @ 2 = 45.049999999999997 +1.e1+1.d1+.5e-1+2.5d+1 @ 1000 = 45.049999999999997 +1.e1+1.d1+.5e-1+2.5d+1 @ 1.0000000000000001e+300 = 45.049999999999997 +1.e1+1.d1+.5e-1+2.5d+1 @ -1.0000000000000001e+300 = 45.049999999999997 +1.e1+1.d1+.5e-1+2.5d+1 @ -1.7976931348623157e+308 = 45.049999999999997 +x.or.1 @ -2.5 = 1 +x.or.1 @ -1 = 1 +x.or.1 @ -0.5 = 1 +x.or.1 @ 0 = 1 +x.or.1 @ 0.25 = 1 +x.or.1 @ 1 = 1 +x.or.1 @ 2 = 1 +x.or.1 @ 1000 = 1 +x.or.1 @ 1.0000000000000001e+300 = 1 +x.or.1 @ -1.0000000000000001e+300 = 1 +x.or.1 @ -1.7976931348623157e+308 = 1 +== expression_errors +-- 1.or.0 +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Missing or invalid operator in the expression "1.o". +! Error in forward transformation function 1. +status 233933938 +-- 1 .and. 1 +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Missing or invalid operator in the expression "1.a". +! Error in forward transformation function 1. +status 233933938 +-- x .not. 1 +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Missing or invalid operator in the expression "x.". +! Error in forward transformation function 1. +status 233933938 +-- 2x +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Missing or invalid operator in the expression "2x". +! Error in forward transformation function 1. +status 233933938 +-- x(1) +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Missing or invalid operator in the expression "x(". +! Error in forward transformation function 1. +status 233933938 +-- x! +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Missing or invalid operator in the expression "x!". +! Error in forward transformation function 1. +status 233933938 +-- (x)(x) +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Missing or invalid operator in the expression "(x)(". +! Error in forward transformation function 1. +status 233933938 +-- 2.eq.2 +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Invalid constant syntax in the expression "2.e". +! Error in forward transformation function 1. +status 233933906 +-- .eq.x +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Invalid constant syntax in the expression ".e". +! Error in forward transformation function 1. +status 233933906 +-- 1.e +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Invalid constant syntax in the expression "1.e". +! Error in forward transformation function 1. +status 233933906 +-- 1.0.5 +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Invalid constant syntax in the expression "1.0.". +! Error in forward transformation function 1. +status 233933906 +-- x +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Undefined variable or function in the expression "x +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Missing or invalid operand in the expression "<". +! Error in forward transformation function 1. +status 233933930 +== unary_sequences +-- --x +2 +-- -+x +-2 +-- +-x +-2 +-- x+-1 +1 +-- x--1 +3 +-- x*-1 +-2 +-- -(-x) +2 +-- x**--2 +4 +-- !!x +1 +-- -!x +-0 +== function_errors +-- varin_expression +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Variable name is invalid: "x+1". +! Error in inverse transformation function 1. +status 233933986 +-- varin_relational +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Variable name is invalid: "x<". +! Error in inverse transformation function 1. +status 233933986 +-- varin_lhs +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Variable name is invalid: "x+1". +! Error in inverse transformation function 1. +status 233933986 +-- varin_underscore +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Variable name is invalid: "_x". +! Error in inverse transformation function 1. +status 233933986 +-- varin_digit +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Variable name is invalid: "1x". +! Error in inverse transformation function 1. +status 233933986 +-- duvar_inverse +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Duplicate definition of variable name: "x". +! Conflict between inverse function 2 and inverse function 1. +status 233933914 +-- duvar_input_output +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Duplicate definition of variable name: "y". +! Conflict between forward function 1 and inverse function 1. +status 233933914 +-- misvn_no_lhs +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): No left hand side in expression: "=y-1". +! Error in inverse transformation function 1. +status 233933946 +-- misvn_empty +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap: Transformation function contains no variable name. +! Error in inverse transformation function 1. +status 233933946 +-- misvn_blank +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap: Transformation function contains no variable name. +! Error in inverse transformation function 1. +status 233933946 +-- miopa_double_equals +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Missing or invalid operand in the expression "=". +! Error in forward transformation function 1. +status 233933930 +-- miopa_equals_equals +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Missing or invalid operand in the expression "=". +! Error in forward transformation function 1. +status 233933930 +-- norhs_empty +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Missing right hand side in expression: "y=". +! Error in forward transformation function 1. +status 233933970 +-- norhs_mixed +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Missing right hand side in function: "t". +! Error in forward transformation function 1. +status 233933970 +-- udvof_third_function +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Undefined variable or function in the expression "b+c". +! Error in forward transformation function 3. +status 233933978 +-- inverse_second_function +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Missing or invalid operand in the expression "t+<". +! Error in inverse transformation function 2. +status 233933930 +-- duvar_numbering +made +-- extra_forward_ok +made +-- extra_forward_varin +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Variable name is invalid: "y-2". +! Error in forward transformation function 2. +status 233933986 +-- extra_inverse_varin +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Undefined variable or function in the expression "y". +! Error in inverse transformation function 2. +status 233933978 +-- misvn_primary +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): No left hand side in expression: "=1". +! Error in inverse transformation function 2. +status 233933946 +== count_errors +-- nin_zero +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Bad number of input coordinates (0). +! This number should be one or more. +status 233933210 +-- nout_zero +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Bad number of output coordinates (0). +! This number should be one or more. +status 233933210 +-- nin_negative +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Bad number of input coordinates (-1). +! This number should be one or more. +status 233933210 +-- too_few_forward +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Too few forward transformation functions given (1). +! At least 2 forward transformation functions must be supplied. +status 233933922 +-- too_few_inverse +!! AST: Error in routine make at line 82 in file mathmap_probe.c. +! astInitMathMap(MathMap): Too few inverse transformation functions given (1). +! At least 2 inverse transformation functions must be supplied. +status 233933922 +== transformations +made +TranForward 1 TranInverse 0 +fwd 3 4 -> 10.5 13.999999999999998 +fwd -1 0.5 -> -1.125 0.56250000000000022 +fwd -1.7976931348623157e+308 0.5 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +!! AST: Error in routine tran2 at line 149 in file mathmap_probe.c. +! astTran2(MathMap): An inverse coordinate transformation is not defined by the MathMap supplied. +status 233933698 +TranForward 0 TranInverse 1 +inv 3 4 -> 10.5 13.999999999999998 +made +fwd 3 4 -> 5 0.92729521800161219 +inv 5 0.92729521800161219 -> 3 3.9999999999999996 +fwd 5 0.92729521800161219 -> 3 3.9999999999999996 +made +TranForward 0 TranInverse 1 +!! AST: Error in routine main at line 340 in file mathmap_probe.c. +! astTran1(MathMap): A forward coordinate transformation is not defined by the MathMap supplied. +status 233933698 +inv 6 +== random_seeds +-- rand seed 1 +0.71461910112010518 +0.90653146912958915 +0.096579739875152781 +0.53704645682451024 +0.87278424512758568 +0.46626103203324709 +-- rand seed 12345 +0.97280067652552638 +0.76083213202991229 +0.88501039445852481 +0.39604903740454644 +0.24713179601545177 +0.028842367888366693 +-- rand seed -7 +-308527335.2090919 +-1593660.0528217873 +-8212.6856654958028 +-40.87738843708722 +0.40010187296071531 +0.28611611740071108 +-- rand seed 0 +-308527334.59048891 +-1593659.7241794001 +-8213.4981877480004 +-40.253513352845637 +0.91572874989088782 +0.082349728486549756 +-- rand seed 2147483647 +0.95356398762557915 +0.7828520479103841 +0.27106400121110874 +0.60797198969063082 +0.49518081243217249 +0.20949205722120667 +-- rand seed -2147483648 +-308527334.51076329 +-1592064.5983997018 +-8213.9017043094427 +-40.121918454714177 +0.24179894675589808 +0.093883173322632962 +-- gauss seed 1 +-0.27065429215413289 +-0.51267331957594009 +0.9136099092301474 +-0.08389764571136063 +-1.0717780026608594 +0.097001641490694249 +-0.076140856900516724 +-- gauss seed 12345 +-0.91823803878248356 +0.24791987280614339 +0.45988417826090106 +0.73796333289951721 +0.34248037257849617 +-0.99592046985152449 +0.85364459807573612 +-- gauss seed -7 +0.73322305361587559 +1.5698451829532218 +-0.4695711550807935 +-0.35696775981643242 +-2.2107365258111606 +-0.5870949048915336 +0.21332124756925253 +-- rand range +2.401935837600611 +1.3256436255519173 +5.9914078068947099 +2.355637667954289 +6.9471334172270893 +-- gauss mean sd +8.2136259760448844 +6.4626714183551437 +13.377206570301666 +8.4487694162733096 +11.816163664815694 +-- poisson small +2 +4 +1 +3 +5 +3 +2 +1 +3 +4 +-- poisson large +14 +22 +20 +22 +19 +11 +26 +22 +27 +9 +-- poisson huge mean +1e+40 +1e+40 +-- poisson zero +0 +0 +-- poisson negative +-1.7976931348623157e+308 +-1.7976931348623157e+308 +-- poisson bad +-1.7976931348623157e+308 +-1.7976931348623157e+308 +-- rand bad +-1.7976931348623157e+308 +-1.7976931348623157e+308 +-- gauss pair +-0.27065429215413289 +-0.51267331957594009 +-- mixed +-8.6333816044446312 +-6.0347304166291211 +1.4408425614236653 +-3.6532671642249195 +-3.8279260026650643 +1.2937884321480675 +== random_copies +-- first +0.43587573783837319 +0.88339044457818261 +0.053904293239207757 +-- copy +0.74851816733627019 +0.83631994692906597 +0.91420085359637082 +-- original +0.74851816733627019 +0.83631994692906597 +0.91420085359637082 +-- reseeded +0.43587573783837319 +0.88339044457818261 +0.053904293239207757 +-- gauss first +0.1655436163709107 +-- gauss original +-0.98976328986914941 +0.35179682173430654 +0.26603590499969559 +-- gauss copy +0.35179682173430654 +0.26603590499969559 +0.30850705350833107 +== gauss_two_mathmaps +-- a +0.80026387895559459 +-- b +1.6532942550141092 +-- a +0.64212595580011556 +-- b +0.4732326979309166 +-- a alone +0.80026387895559459 +0.51227576242640549 +-- b alone +1.6532942550141092 +0.64212595580011556 +== attributes +SimpFI 0 test 0 +SimpIF 0 test 0 +Seed test 0 +SimpFI 1 test 1 +SimpIF 0 test 1 +Seed -12 test 1 +SimpFI 0 test 1 +SimpIF 1 test 1 +Seed -12 test 1 +SimpFI 0 test 0 +SimpIF 0 test 0 +Seed test 0 +-- shared +!! AST: Error in routine main at line 446 in file mathmap_probe.c. +! astSet(MathMap): The Seedattribute of the supplied MathMap cannot be changed because the MathMap has been cloned (programming error). +status 233934418 +!! AST: Error in routine main at line 448 in file mathmap_probe.c. +! astSet(MathMap): The SimpFIattribute of the supplied MathMap cannot be changed because the MathMap has been cloned (programming error). +status 233934418 +!! AST: Error in routine main at line 450 in file mathmap_probe.c. +! astClear(MathMap): The SimpIFattribute of the supplied MathMap cannot be cleared because the MathMap has been cloned (programming error). +status 233934418 +== dump_default + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nfwd = 4 # Number of forward transformation functions + Fwd1 = "r=sqrt(x*x+y*y)" # Forward function 1 + Fwd2 = "theta=atan2(y,x)" # Forward function 2 + Fwd3 = "rout=r*(1+0.1*r*r)+gauss(0,0.001)" # Forward function 3 + Fwd4 = "tout=theta+rand(-1.0e-6,1.0e-6)" # Forward function 4 + Inv1 = "x=rout*cos(tout)" # Inverse function 1 + Inv2 = "y=rout*sin(tout)" # Inverse function 2 + End MathMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for MathMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'MathMap ' / Transformation using mathematical functions +NIN_A = 2 / Number of input coordinates +ISA_A = 'Mapping ' / Mapping between coordinate systems +NFWD_A = 4 / Number of forward transformation functions +FWD1_A = 'r=sqrt(x*x+y*y)' / Forward function 1 +FWD2_A = 'theta=atan2(y,x)' / Forward function 2 +FWD3_A = 'rout=r*(1+0.1*r*r)+gauss(0,0.001)' / Forward function 3 +FWD4_A = 'tout=theta+rand(-1.0e-6,1.0e-6)' / Forward function 4 +INV1_A = 'x=rout*cos(tout)' / Inverse function 1 +INV2_A = 'y=rout*sin(tout)' / Inverse function 2 +ENDAST_A= 'MathMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for MathMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nfwd = 4 # Number of forward transformation functions + Fwd1 = "r=sqrt(x*x+y*y)" # Forward function 1 + Fwd2 = "theta=atan2(y,x)" # Forward function 2 + Fwd3 = "rout=r*(1+0.1*r*r)+gauss(0,0.001)" # Forward function 3 + Fwd4 = "tout=theta+rand(-1.0e-6,1.0e-6)" # Forward function 4 + Inv1 = "x=rout*cos(tout)" # Inverse function 1 + Inv2 = "y=rout*sin(tout)" # Inverse function 2 + End MathMap +== dump_simpfi + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nfwd = 4 # Number of forward transformation functions + Fwd1 = "r=sqrt(x*x+y*y)" # Forward function 1 + Fwd2 = "theta=atan2(y,x)" # Forward function 2 + Fwd3 = "rout=r*(1+0.1*r*r)+gauss(0,0.001)" # Forward function 3 + Fwd4 = "tout=theta+rand(-1.0e-6,1.0e-6)" # Forward function 4 + Inv1 = "x=rout*cos(tout)" # Inverse function 1 + Inv2 = "y=rout*sin(tout)" # Inverse function 2 + SimpFI = 1 # Forward-inverse pairs may simplify + End MathMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for MathMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'MathMap ' / Transformation using mathematical functions +NIN_A = 2 / Number of input coordinates +ISA_A = 'Mapping ' / Mapping between coordinate systems +NFWD_A = 4 / Number of forward transformation functions +FWD1_A = 'r=sqrt(x*x+y*y)' / Forward function 1 +FWD2_A = 'theta=atan2(y,x)' / Forward function 2 +FWD3_A = 'rout=r*(1+0.1*r*r)+gauss(0,0.001)' / Forward function 3 +FWD4_A = 'tout=theta+rand(-1.0e-6,1.0e-6)' / Forward function 4 +INV1_A = 'x=rout*cos(tout)' / Inverse function 1 +INV2_A = 'y=rout*sin(tout)' / Inverse function 2 +SIMPFI_A= 1 / Forward-inverse pairs may simplify +ENDAST_A= 'MathMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for MathMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nfwd = 4 # Number of forward transformation functions + Fwd1 = "r=sqrt(x*x+y*y)" # Forward function 1 + Fwd2 = "theta=atan2(y,x)" # Forward function 2 + Fwd3 = "rout=r*(1+0.1*r*r)+gauss(0,0.001)" # Forward function 3 + Fwd4 = "tout=theta+rand(-1.0e-6,1.0e-6)" # Forward function 4 + Inv1 = "x=rout*cos(tout)" # Inverse function 1 + Inv2 = "y=rout*sin(tout)" # Inverse function 2 + SimpFI = 1 # Forward-inverse pairs may simplify + End MathMap +== dump_all_set + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nfwd = 4 # Number of forward transformation functions + Fwd1 = "r=sqrt(x*x+y*y)" # Forward function 1 + Fwd2 = "theta=atan2(y,x)" # Forward function 2 + Fwd3 = "rout=r*(1+0.1*r*r)+gauss(0,0.001)" # Forward function 3 + Fwd4 = "tout=theta+rand(-1.0e-6,1.0e-6)" # Forward function 4 + Inv1 = "x=rout*cos(tout)" # Inverse function 1 + Inv2 = "y=rout*sin(tout)" # Inverse function 2 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 0 # Inverse-forward pairs do not simplify + Seeded = 1 # Explicit random number seed set + Seed = 1234 # Random number seed value + End MathMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for MathMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'MathMap ' / Transformation using mathematical functions +NIN_A = 2 / Number of input coordinates +ISA_A = 'Mapping ' / Mapping between coordinate systems +NFWD_A = 4 / Number of forward transformation functions +FWD1_A = 'r=sqrt(x*x+y*y)' / Forward function 1 +FWD2_A = 'theta=atan2(y,x)' / Forward function 2 +FWD3_A = 'rout=r*(1+0.1*r*r)+gauss(0,0.001)' / Forward function 3 +FWD4_A = 'tout=theta+rand(-1.0e-6,1.0e-6)' / Forward function 4 +INV1_A = 'x=rout*cos(tout)' / Inverse function 1 +INV2_A = 'y=rout*sin(tout)' / Inverse function 2 +SIMPFI_A= 1 / Forward-inverse pairs may simplify +SIMPIF_A= 0 / Inverse-forward pairs do not simplify +SEEDED_A= 1 / Explicit random number seed set +SEED_A = 1234 / Random number seed value +ENDAST_A= 'MathMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for MathMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nfwd = 4 # Number of forward transformation functions + Fwd1 = "r=sqrt(x*x+y*y)" # Forward function 1 + Fwd2 = "theta=atan2(y,x)" # Forward function 2 + Fwd3 = "rout=r*(1+0.1*r*r)+gauss(0,0.001)" # Forward function 3 + Fwd4 = "tout=theta+rand(-1.0e-6,1.0e-6)" # Forward function 4 + Inv1 = "x=rout*cos(tout)" # Inverse function 1 + Inv2 = "y=rout*sin(tout)" # Inverse function 2 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 0 # Inverse-forward pairs do not simplify + Seeded = 1 # Explicit random number seed set + Seed = 1234 # Random number seed value + End MathMap +== dump_cleared + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nfwd = 4 # Number of forward transformation functions + Fwd1 = "r=sqrt(x*x+y*y)" # Forward function 1 + Fwd2 = "theta=atan2(y,x)" # Forward function 2 + Fwd3 = "rout=r*(1+0.1*r*r)+gauss(0,0.001)" # Forward function 3 + Fwd4 = "tout=theta+rand(-1.0e-6,1.0e-6)" # Forward function 4 + Inv1 = "x=rout*cos(tout)" # Inverse function 1 + Inv2 = "y=rout*sin(tout)" # Inverse function 2 + End MathMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for MathMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'MathMap ' / Transformation using mathematical functions +NIN_A = 2 / Number of input coordinates +ISA_A = 'Mapping ' / Mapping between coordinate systems +NFWD_A = 4 / Number of forward transformation functions +FWD1_A = 'r=sqrt(x*x+y*y)' / Forward function 1 +FWD2_A = 'theta=atan2(y,x)' / Forward function 2 +FWD3_A = 'rout=r*(1+0.1*r*r)+gauss(0,0.001)' / Forward function 3 +FWD4_A = 'tout=theta+rand(-1.0e-6,1.0e-6)' / Forward function 4 +INV1_A = 'x=rout*cos(tout)' / Inverse function 1 +INV2_A = 'y=rout*sin(tout)' / Inverse function 2 +ENDAST_A= 'MathMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for MathMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nfwd = 4 # Number of forward transformation functions + Fwd1 = "r=sqrt(x*x+y*y)" # Forward function 1 + Fwd2 = "theta=atan2(y,x)" # Forward function 2 + Fwd3 = "rout=r*(1+0.1*r*r)+gauss(0,0.001)" # Forward function 3 + Fwd4 = "tout=theta+rand(-1.0e-6,1.0e-6)" # Forward function 4 + Inv1 = "x=rout*cos(tout)" # Inverse function 1 + Inv2 = "y=rout*sin(tout)" # Inverse function 2 + End MathMap +== dump_inverted + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Nfwd = 4 # Number of forward transformation functions + Fwd1 = "r=sqrt(x*x+y*y)" # Forward function 1 + Fwd2 = "theta=atan2(y,x)" # Forward function 2 + Fwd3 = "rout=r*(1+0.1*r*r)+gauss(0,0.001)" # Forward function 3 + Fwd4 = "tout=theta+rand(-1.0e-6,1.0e-6)" # Forward function 4 + Inv1 = "x=rout*cos(tout)" # Inverse function 1 + Inv2 = "y=rout*sin(tout)" # Inverse function 2 + SimpIF = 1 # Inverse-forward pairs may simplify + Seeded = 1 # Explicit random number seed set + Seed = -5 # Random number seed value + End MathMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for MathMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'MathMap ' / Transformation using mathematical functions +NIN_A = 2 / Number of input coordinates +INVERT_A= 1 / Mapping inverted +ISA_A = 'Mapping ' / Mapping between coordinate systems +NFWD_A = 4 / Number of forward transformation functions +FWD1_A = 'r=sqrt(x*x+y*y)' / Forward function 1 +FWD2_A = 'theta=atan2(y,x)' / Forward function 2 +FWD3_A = 'rout=r*(1+0.1*r*r)+gauss(0,0.001)' / Forward function 3 +FWD4_A = 'tout=theta+rand(-1.0e-6,1.0e-6)' / Forward function 4 +INV1_A = 'x=rout*cos(tout)' / Inverse function 1 +INV2_A = 'y=rout*sin(tout)' / Inverse function 2 +SIMPIF_A= 1 / Inverse-forward pairs may simplify +SEEDED_A= 1 / Explicit random number seed set +SEED_A = -5 / Random number seed value +ENDAST_A= 'MathMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for MathMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Nfwd = 4 # Number of forward transformation functions + Fwd1 = "r=sqrt(x*x+y*y)" # Forward function 1 + Fwd2 = "theta=atan2(y,x)" # Forward function 2 + Fwd3 = "rout=r*(1+0.1*r*r)+gauss(0,0.001)" # Forward function 3 + Fwd4 = "tout=theta+rand(-1.0e-6,1.0e-6)" # Forward function 4 + Inv1 = "x=rout*cos(tout)" # Inverse function 1 + Inv2 = "y=rout*sin(tout)" # Inverse function 2 + SimpIF = 1 # Inverse-forward pairs may simplify + Seeded = 1 # Explicit random number seed set + Seed = -5 # Random number seed value + End MathMap +== dump_no_forward + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y" # Forward function 1 + Ninv = 2 # Number of inverse transformation functions + Inv1 = "t=y*2" # Inverse function 1 + Inv2 = "x=t+1" # Inverse function 2 + End MathMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for MathMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'MathMap ' / Transformation using mathematical functions +NIN_A = 1 / Number of input coordinates +FWD_A = 0 / Forward transformation not defined +ISA_A = 'Mapping ' / Mapping between coordinate systems +FWD1_A = 'y ' / Forward function 1 +NINV_A = 2 / Number of inverse transformation functions +INV1_A = 't=y*2 ' / Inverse function 1 +INV2_A = 'x=t+1 ' / Inverse function 2 +ENDAST_A= 'MathMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for MathMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y" # Forward function 1 + Ninv = 2 # Number of inverse transformation functions + Inv1 = "t=y*2" # Inverse function 1 + Inv2 = "x=t+1" # Inverse function 2 + End MathMap +== dump_in_cmpmap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Nfwd = 4 # Number of forward transformation functions + Fwd1 = "r=sqrt(x*x+y*y)" # Forward function 1 + Fwd2 = "theta=atan2(y,x)" # Forward function 2 + Fwd3 = "rout=r*(1+0.1*r*r)+gauss(0,0.001)" # Forward function 3 + Fwd4 = "tout=theta+rand(-1.0e-6,1.0e-6)" # Forward function 4 + Inv1 = "x=rout*cos(tout)" # Inverse function 1 + Inv2 = "y=rout*sin(tout)" # Inverse function 2 + SimpIF = 1 # Inverse-forward pairs may simplify + Seeded = 1 # Explicit random number seed set + Seed = -5 # Random number seed value + End MathMap + End CmpMap +-- fits + +COMMENT AST ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ AST +COMMENT AST Beginning of AST data for CmpMap object AST +COMMENT AST ................................................................ AST +BEGAST_A= 'CmpMap ' / Compound Mapping +NIN_A = 2 / Number of input coordinates +ISA_A = 'Mapping ' / Mapping between coordinate systems +INVB_A = 1 / Second Mapping used in inverse direction +MAPA_A = ' ' / First component Mapping +BEGAST_B= 'ZoomMap ' / Zoom about the origin +NIN_B = 2 / Number of input coordinates +ISA_B = 'Mapping ' / Mapping between coordinate systems +ZOOM_A = 3.0 / Zoom factor +ENDAST_A= 'ZoomMap ' / End of object definition +MAPB_A = ' ' / Second component Mapping +BEGAST_C= 'MathMap ' / Transformation using mathematical functions +NIN_C = 2 / Number of input coordinates +INVERT_A= 1 / Mapping inverted +ISA_C = 'Mapping ' / Mapping between coordinate systems +NFWD_A = 4 / Number of forward transformation functions +FWD1_A = 'r=sqrt(x*x+y*y)' / Forward function 1 +FWD2_A = 'theta=atan2(y,x)' / Forward function 2 +FWD3_A = 'rout=r*(1+0.1*r*r)+gauss(0,0.001)' / Forward function 3 +FWD4_A = 'tout=theta+rand(-1.0e-6,1.0e-6)' / Forward function 4 +INV1_A = 'x=rout*cos(tout)' / Inverse function 1 +INV2_A = 'y=rout*sin(tout)' / Inverse function 2 +SIMPIF_A= 1 / Inverse-forward pairs may simplify +SEEDED_A= 1 / Explicit random number seed set +SEED_A = -5 / Random number seed value +ENDAST_B= 'MathMap ' / End of object definition +ENDAST_C= 'CmpMap ' / End of object definition +COMMENT AST ................................................................ AST +COMMENT AST End of AST data for CmpMap object AST +COMMENT AST ---------------------------------------------------------------- AST +-- read back from fits + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Nfwd = 4 # Number of forward transformation functions + Fwd1 = "r=sqrt(x*x+y*y)" # Forward function 1 + Fwd2 = "theta=atan2(y,x)" # Forward function 2 + Fwd3 = "rout=r*(1+0.1*r*r)+gauss(0,0.001)" # Forward function 3 + Fwd4 = "tout=theta+rand(-1.0e-6,1.0e-6)" # Forward function 4 + Inv1 = "x=rout*cos(tout)" # Inverse function 1 + Inv2 = "y=rout*sin(tout)" # Inverse function 2 + SimpIF = 1 # Inverse-forward pairs may simplify + Seeded = 1 # Explicit random number seed set + Seed = -5 # Random number seed value + End MathMap + End CmpMap +== seed_read_back +Seed 77 test 1 +0.94030456119038219 +0.86605399598217658 +0.36143246520385375 +0.94030456119038219 +0.86605399598217658 +0.36143246520385375 +== simplify_input_after + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + ReSimp = 1 # Simplify restricted to allowed Mappings + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + AlSimp = 1 # Will be used by restricted Simplify + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + AlSimp = 1 # Will be used by restricted Simplify + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=0.5*y" # Inverse function 1 + End MathMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 7 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap +== end status 0 diff --git a/src/test/resources/probes/mathmap_simplify_probe.c b/src/test/resources/probes/mathmap_simplify_probe.c new file mode 100644 index 0000000..a664f44 --- /dev/null +++ b/src/test/resources/probes/mathmap_simplify_probe.c @@ -0,0 +1,342 @@ +/* mathmap_simplify_probe -- MathMap simplification, equality and the + * MathMaps of units conversions in the pinned C library: a MathMap in + * series with its inverse for each setting of SimpFI and SimpIF, two + * MathMaps with equal and unequal functions, astEqual on pairs of + * MathMaps, the Mapping astUnitMapper makes for conversions that need a + * MathMap, with the label it gives, and a FluxFrame conversion to a + * logarithmic Unit. + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * Built against the C library at 3d3f255f with its static libraries: + * cc -I -o mathmap_simplify_probe mathmap_simplify_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 on macOS as ./mathmap_simplify_probe > mathmap_simplify_probe.out + * 2>&1, then trailing white space removed from every line. */ +#include +#include +#include "ast.h" + +/* astUnitMapper is protected; its prototype is in unit.h. */ +AstMapping *astUnitMapper_( const char *, const char *, const char *, + char **, int * ); + +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; +} + +/* A MathMap of the forward and inverse functions given, NULL-terminated, + with the attribute settings given. */ +static AstMathMap *make( int nin, int nout, const char **fwd, + const char **inv, const char *settings ) { + int nfwd = 0, ninv = 0; + while( fwd[ nfwd ] ) nfwd++; + while( inv[ ninv ] ) ninv++; + AstMathMap *m = astMathMap( nin, nout, nfwd, fwd, ninv, inv, "%s", + settings ); + if( failed() ) printf( "failed to make %s\n", fwd[ 0 ] ); + return m; +} + +/* The class, input and output counts of the simplified Mapping, then its + dump. */ +static void simplified( const char *name, AstMapping *map ) { + head( name ); + AstMapping *s = astSimplify( map ); + if( failed() ) return; + printf( "%s %d %d\n", astGetC( s, "Class" ), astGetI( s, "Nin" ), + astGetI( s, "Nout" ) ); + astShow( s ); + s = astAnnul( s ); +} + +/* The settings of SimpFI or SimpIF probed: unset, 0 and 1. */ +static const char *flag_settings[] = { "", "=0", "=1" }; +static const char *flag_names[] = { "unset", "0", "1" }; + +/* The Mapping astUnitMapper gives for the units "in" to "out", with the + label "Frequency", its forward and inverse images of the values given, + and the label. */ +static void units( const char *name, const char *in, const char *out, + int nval, const double *vals ) { + char *outlab = NULL; + head( name ); + AstMapping *m = astUnitMapper_( in, out, "Frequency", &outlab, + astGetStatusPtr ); + if( failed() ) return; + if( m ) m = astMakeId( m ); + if( !m ) { + printf( "no conversion\n" ); + return; + } + printf( "label %s\n", outlab ? outlab : "(null)" ); + astShow( m ); + double fwd[ 10 ], inv[ 10 ]; + astTran1( m, nval, vals, 1, fwd ); + astTran1( m, nval, fwd, 0, inv ); + if( failed() ) return; + for( int i = 0; i < nval; i++ ) { + printf( "%.17g -> %.17g -> %.17g\n", vals[ i ], fwd[ i ], inv[ i ] ); + } + outlab = astFree( outlab ); + m = astAnnul( m ); +} + +int main( void ) { + int status = 0; + setvbuf( stdout, NULL, _IONBF, 0 ); + astWatch( &status ); + astBegin; + + /* A MathMap in series with an inverted copy of itself, each way round, + for each setting of SimpFI and SimpIF. */ + { + const char *f[] = { "y = 2 * x", NULL }; + const char *i[] = { "x = y / 2", NULL }; + for( int fi = 0; fi < 3; fi++ ) { + for( int jf = 0; jf < 3; jf++ ) { + char settings[ 100 ] = ""; + if( fi ) sprintf( settings + strlen( settings ), "SimpFI%s", + flag_settings[ fi ] ); + if( fi && jf ) strcat( settings, "," ); + if( jf ) sprintf( settings + strlen( settings ), "SimpIF%s", + flag_settings[ jf ] ); + AstMathMap *m = make( 1, 1, f, i, settings ); + AstMathMap *mi = astCopy( m ); + astInvert( mi ); + char name[ 100 ]; + sprintf( name, "fwd_inv_simpfi_%s_simpif_%s", flag_names[ fi ], + flag_names[ jf ] ); + simplified( name, (AstMapping *) astCmpMap( m, mi, 1, " " ) ); + sprintf( name, "inv_fwd_simpfi_%s_simpif_%s", flag_names[ fi ], + flag_names[ jf ] ); + simplified( name, (AstMapping *) astCmpMap( mi, m, 1, " " ) ); + } + } + } + + /* Both MathMaps must consent: the second has SimpFI cleared. */ + { + const char *f[] = { "y = 2 * x", NULL }; + const char *i[] = { "x = y / 2", NULL }; + AstMathMap *m = make( 1, 1, f, i, "SimpFI=1,SimpIF=1" ); + AstMathMap *mi = astCopy( m ); + astClear( mi, "SimpFI" ); + astInvert( mi ); + simplified( "consent_of_both", (AstMapping *) astCmpMap( m, mi, 1, " " ) ); + } + + /* Two MathMaps made separately: functions that differ only in case and + white space are equal once cleaned; functions that are equivalent but + written differently are not. */ + { + const char *f1[] = { "Y = 2 * X", NULL }; + const char *i1[] = { "X = Y / 2", NULL }; + const char *f2[] = { "y=2*x", NULL }; + const char *i2[] = { "x=y/2", NULL }; + const char *f3[] = { "y = x * 2", NULL }; + const char *i3[] = { "x = y / 2", NULL }; + AstMathMap *a = make( 1, 1, f1, i1, "SimpFI=1,SimpIF=1" ); + AstMathMap *b = make( 1, 1, f2, i2, "SimpFI=1,SimpIF=1" ); + AstMathMap *c = make( 1, 1, f3, i3, "SimpFI=1,SimpIF=1" ); + astInvert( b ); + astInvert( c ); + simplified( "equal_functions", (AstMapping *) astCmpMap( a, b, 1, " " ) ); + simplified( "unequal_functions", (AstMapping *) astCmpMap( a, c, 1, " " ) ); + } + + /* Different numbers of inputs and outputs, and intermediate functions. */ + { + const char *f[] = { "r = sqrt( x * x + y * y )", NULL }; + const char *i[] = { "x = r", "y = 0", NULL }; + AstMathMap *m = make( 2, 1, f, i, "SimpFI=1,SimpIF=1" ); + AstMathMap *mi = astCopy( m ); + astInvert( mi ); + simplified( "nin_nout_fwd_inv", (AstMapping *) astCmpMap( m, mi, 1, " " ) ); + simplified( "nin_nout_inv_fwd", (AstMapping *) astCmpMap( mi, m, 1, " " ) ); + + const char *f2[] = { "t = x + 1", "u = y * t", "v = x - y", NULL }; + const char *i2[] = { "x = u + v", "y = u - v", NULL }; + AstMathMap *n = make( 2, 2, f2, i2, "SimpFI=1,SimpIF=1" ); + AstMathMap *ni = astCopy( n ); + astInvert( ni ); + simplified( "intermediate_functions", (AstMapping *) astCmpMap( n, ni, 1, " " ) ); + + /* The pair cancels within a longer series, and in parallel it does not. */ + AstZoomMap *z = astZoomMap( 2, 3.0, " " ); + AstCmpMap *pair = astCmpMap( n, ni, 1, " " ); + simplified( "pair_then_zoommap", (AstMapping *) astCmpMap( pair, z, 1, " " ) ); + simplified( "pair_in_parallel", (AstMapping *) astCmpMap( n, ni, 0, " " ) ); + + /* The same MathMap twice, not inverted. */ + simplified( "same_twice", (AstMapping *) astCmpMap( n, n, 1, " " ) ); + } + + /* An outer parallel CmpMap whose first component is an inverted series + CmpMap of two identical MathMaps. */ + { + const char *f[] = { "y=2*x", NULL }; + const char *i[] = { "x=0.5*y", NULL }; + AstMathMap *a = make( 1, 1, f, i, "SimpFI=1,SimpIF=1" ); + AstMathMap *b = astCopy( a ); + AstCmpMap *first = astCmpMap( a, b, 1, " " ); + astInvert( first ); + AstMathMap *c = make( 1, 1, f, i, "SimpFI=1,SimpIF=1" ); + AstMathMap *d = astCopy( c ); + AstCmpMap *second = astCmpMap( c, d, 1, " " ); + simplified( "parallel_with_inverted_series", (AstMapping *) astCmpMap( first, second, 0, " " ) ); + } + + /* astEqual on pairs of MathMaps. */ + head( "equal" ); + { + const char *fa[] = { "y = 2 * x", NULL }; + const char *ia[] = { "x = y / 2", NULL }; + const char *fb[] = { "y = 3 * x", NULL }; + const char *ib[] = { "x = y / 3", NULL }; + const char *fc[] = { "y = x + 1", NULL }; + const char *ic[] = { "x = y - 1", NULL }; + const char *fd[] = { "y = x - 1", NULL }; + const char *id[] = { "x = y + 1", NULL }; + const char *fe[] = { "y = x", NULL }; + const char *ie[] = { "x = y", NULL }; + const char *ff[] = { "b = a", NULL }; + const char *iff[] = { "a = b", NULL }; + const char *fg[] = { "y = max( x, 1 )", NULL }; + const char *fh[] = { "y = min( x, 1 )", NULL }; + const char *fi[] = { "y = max( x, 1, 2 )", NULL }; + const char *fj[] = { "y = max( x, 1, 3 )", NULL }; + const char *iu[] = { "x", NULL }; + const char *fu[] = { "y", NULL }; + const char *fk[] = { "y = x * 2", NULL }; + const char *f2[] = { "z = x", NULL }; + const char *f3[] = { "z = y", NULL }; + const char *i23[] = { "x = z", "y = z", NULL }; + const char *f4[] = { "y = 2 * x", "w = y", NULL }; + const char *i4[] = { "x = w / 2", NULL }; + const char *f5[] = { "y = x * x", NULL }; + const char *i5[] = { "x = sqrt( y )", NULL }; + const char *f6[] = { "y = x * x * x", NULL }; + + AstMathMap *a = make( 1, 1, fa, ia, " " ); + AstMathMap *a2 = make( 1, 1, fa, ia, "SimpFI=1" ); + AstMathMap *ainv = astCopy( a ); + astInvert( ainv ); + AstMathMap *ainv2 = astCopy( a ); + astInvert( ainv2 ); + AstMathMap *b = make( 1, 1, fb, ib, " " ); + AstMathMap *c = make( 1, 1, fc, ic, " " ); + AstMathMap *d = make( 1, 1, fd, id, " " ); + AstMathMap *e = make( 1, 1, fe, ie, " " ); + AstMathMap *f = make( 1, 1, ff, iff, " " ); + AstMathMap *g = make( 1, 1, fg, iu, " " ); + AstMathMap *h = make( 1, 1, fh, iu, " " ); + AstMathMap *i = make( 1, 1, fi, iu, " " ); + AstMathMap *j = make( 1, 1, fj, iu, " " ); + AstMathMap *u1 = make( 1, 1, fu, ia, " " ); + AstMathMap *u2 = make( 1, 1, fu, ia, " " ); + AstMathMap *k = make( 1, 1, fk, ia, " " ); + AstMathMap *m2 = make( 2, 1, f2, i23, " " ); + AstMathMap *m3 = make( 2, 1, f3, i23, " " ); + AstMathMap *m4 = make( 1, 1, f4, i4, " " ); + AstMathMap *m5 = make( 1, 1, f5, i5, " " ); + AstMathMap *m6 = make( 1, 1, f6, i5, " " ); + AstZoomMap *z = astZoomMap( 1, 2.0, " " ); + AstMathMap *u3 = make( 1, 1, fu, iu, " " ); + AstMathMap *u4 = make( 1, 1, fu, iu, " " ); + + printf( "same_object %d\n", astEqual( a, a ) ); + printf( "same_functions %d\n", astEqual( a, a2 ) ); + printf( "different_constant %d\n", astEqual( a, b ) ); + printf( "last_opcode_differs %d\n", astEqual( c, d ) ); + printf( "inverted_copy %d\n", astEqual( a, ainv ) ); + printf( "both_inverted %d\n", astEqual( ainv, ainv2 ) ); + printf( "renamed_variables %d\n", astEqual( e, f ) ); + printf( "max_min %d\n", astEqual( g, h ) ); + printf( "max_constant %d\n", astEqual( i, j ) ); + printf( "max_argument_count %d\n", astEqual( g, i ) ); + printf( "no_forward_both %d\n", astEqual( u1, u2 ) ); + printf( "no_forward_one %d\n", astEqual( u1, a ) ); + printf( "forward_one %d\n", astEqual( a, u1 ) ); + printf( "neither_direction %d\n", astEqual( u3, u4 ) ); + printf( "operand_order %d\n", astEqual( a, k ) ); + printf( "variable_index %d\n", astEqual( m2, m3 ) ); + printf( "nin_differs %d\n", astEqual( a, m2 ) ); + printf( "function_count_differs %d\n", astEqual( a, m4 ) ); + printf( "opcode_count_differs %d\n", astEqual( m5, m6 ) ); + printf( "zoommap %d\n", astEqual( a, z ) ); + failed(); + } + + /* The Mappings of units conversions that need a MathMap. */ + { + const double v1[] = { 0.0, 2.0, -1.5 }; + const double v2[] = { 2.0, 0.25, 100.0 }; + units( "units_log_hz_to_hz", "log(Hz)", "Hz", 3, v1 ); + units( "units_sqrt_hz_to_hz", "sqrt(Hz)", "Hz", 3, v2 ); + units( "units_log_kms_to_ms", "log(km/s)", "m/s", 3, v1 ); + units( "units_hz_to_log_hz", "Hz", "log(Hz)", 3, v2 ); + units( "units_hz_to_sqrt_hz", "Hz", "sqrt(Hz)", 3, v2 ); + units( "units_ln_hz_to_mhz", "ln(Hz)", "MHz", 3, v1 ); + units( "units_exp_hz_to_hz", "exp(Hz)", "Hz", 3, v2 ); + units( "units_log_mhz_to_log_hz", "log(MHz)", "log(Hz)", 3, v1 ); + units( "units_hz_to_per_hz", "Hz", "1/Hz", 3, v2 ); + units( "units_hz15_to_hz", "Hz**1.5", "Hz", 3, v2 ); + units( "units_m2_to_cm", "m**2", "cm", 3, v2 ); + units( "units_log_jy_to_w", "log(Jy)", "W/m**2/Hz", 3, v1 ); + } + + /* A conversion and its reverse in series do not cancel: their + functions are not each other's inverse functions as text. */ + { + AstMapping *m1 = astMakeId( astUnitMapper_( "log(Hz)", "Hz", NULL, NULL, + astGetStatusPtr ) ); + AstMapping *m2 = astMakeId( astUnitMapper_( "Hz", "log(Hz)", NULL, NULL, + astGetStatusPtr ) ); + simplified( "units_there_and_back", (AstMapping *) astCmpMap( m1, m2, 1, " " ) ); + AstMapping *m3 = astCopy( m1 ); + astInvert( m3 ); + simplified( "units_with_inverse", (AstMapping *) astCmpMap( m1, m3, 1, " " ) ); + } + + /* A FluxFrame in Jy converted to one in a logarithmic Unit. */ + head( "flux_log_conversion" ); + { + AstFluxFrame *jy = astFluxFrame( AST__BAD, NULL, "Unit=Jy" ); + AstFluxFrame *lg = astFluxFrame( AST__BAD, NULL, "Unit=log(W/m^2/Hz)" ); + AstFrameSet *fs = astConvert( jy, lg, "" ); + if( !failed() && fs ) { + AstMapping *m = astGetMapping( fs, AST__BASE, AST__CURRENT ); + AstMapping *s = astSimplify( m ); + printf( "%s\n", astGetC( s, "Class" ) ); + astShow( s ); + const double vals[] = { 1.0, 1000.0, 0.5 }; + double fwd[ 3 ], inv[ 3 ]; + astTran1( fs, 3, vals, 1, fwd ); + astTran1( fs, 3, fwd, 0, inv ); + failed(); + for( int i = 0; i < 3; i++ ) { + printf( "%.17g -> %.17g -> %.17g\n", vals[ i ], fwd[ i ], inv[ i ] ); + } + } else { + printf( "no conversion\n" ); + } + } + + astEnd; + printf( "== end status %d\n", status ); + return 0; +} diff --git a/src/test/resources/probes/mathmap_simplify_probe.out b/src/test/resources/probes/mathmap_simplify_probe.out new file mode 100644 index 0000000..5ece778 --- /dev/null +++ b/src/test/resources/probes/mathmap_simplify_probe.out @@ -0,0 +1,798 @@ +== fwd_inv_simpfi_unset_simpif_unset +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + End MathMap + End CmpMap +== inv_fwd_simpfi_unset_simpif_unset +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + End MathMap + End CmpMap +== fwd_inv_simpfi_unset_simpif_0 +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpIF = 0 # Inverse-forward pairs do not simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpIF = 0 # Inverse-forward pairs do not simplify + End MathMap + End CmpMap +== inv_fwd_simpfi_unset_simpif_0 +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpIF = 0 # Inverse-forward pairs do not simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpIF = 0 # Inverse-forward pairs do not simplify + End MathMap + End CmpMap +== fwd_inv_simpfi_unset_simpif_1 +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + End CmpMap +== inv_fwd_simpfi_unset_simpif_1 +UnitMap 1 1 + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +== fwd_inv_simpfi_0_simpif_unset +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 0 # Forward-inverse pairs do not simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 0 # Forward-inverse pairs do not simplify + End MathMap + End CmpMap +== inv_fwd_simpfi_0_simpif_unset +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 0 # Forward-inverse pairs do not simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 0 # Forward-inverse pairs do not simplify + End MathMap + End CmpMap +== fwd_inv_simpfi_0_simpif_0 +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 0 # Forward-inverse pairs do not simplify + SimpIF = 0 # Inverse-forward pairs do not simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 0 # Forward-inverse pairs do not simplify + SimpIF = 0 # Inverse-forward pairs do not simplify + End MathMap + End CmpMap +== inv_fwd_simpfi_0_simpif_0 +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 0 # Forward-inverse pairs do not simplify + SimpIF = 0 # Inverse-forward pairs do not simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 0 # Forward-inverse pairs do not simplify + SimpIF = 0 # Inverse-forward pairs do not simplify + End MathMap + End CmpMap +== fwd_inv_simpfi_0_simpif_1 +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 0 # Forward-inverse pairs do not simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 0 # Forward-inverse pairs do not simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + End CmpMap +== inv_fwd_simpfi_0_simpif_1 +UnitMap 1 1 + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +== fwd_inv_simpfi_1_simpif_unset +UnitMap 1 1 + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +== inv_fwd_simpfi_1_simpif_unset +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + End MathMap + End CmpMap +== fwd_inv_simpfi_1_simpif_0 +UnitMap 1 1 + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +== inv_fwd_simpfi_1_simpif_0 +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 0 # Inverse-forward pairs do not simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 0 # Inverse-forward pairs do not simplify + End MathMap + End CmpMap +== fwd_inv_simpfi_1_simpif_1 +UnitMap 1 1 + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +== inv_fwd_simpfi_1_simpif_1 +UnitMap 1 1 + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +== consent_of_both +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + End CmpMap +== equal_functions +UnitMap 1 1 + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +== unequal_functions +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*2" # Forward function 1 + Inv1 = "x=y/2" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + End CmpMap +== nin_nout_fwd_inv +UnitMap 2 2 + Begin UnitMap # Unit (null) Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +== nin_nout_inv_fwd +UnitMap 1 1 + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +== intermediate_functions +UnitMap 2 2 + Begin UnitMap # Unit (null) Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +== pair_then_zoommap +ZoomMap 2 2 + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap +== pair_in_parallel +CmpMap 4 4 + Begin CmpMap # Compound Mapping + Nin = 4 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nfwd = 3 # Number of forward transformation functions + Fwd1 = "t=x+1" # Forward function 1 + Fwd2 = "u=y*t" # Forward function 2 + Fwd3 = "v=x-y" # Forward function 3 + Inv1 = "x=u+v" # Inverse function 1 + Inv2 = "y=u-v" # Inverse function 2 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Nfwd = 3 # Number of forward transformation functions + Fwd1 = "t=x+1" # Forward function 1 + Fwd2 = "u=y*t" # Forward function 2 + Fwd3 = "v=x-y" # Forward function 3 + Inv1 = "x=u+v" # Inverse function 1 + Inv2 = "y=u-v" # Inverse function 2 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + End CmpMap +== same_twice +CmpMap 2 2 + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nfwd = 3 # Number of forward transformation functions + Fwd1 = "t=x+1" # Forward function 1 + Fwd2 = "u=y*t" # Forward function 2 + Fwd3 = "v=x-y" # Forward function 3 + Inv1 = "x=u+v" # Inverse function 1 + Inv2 = "y=u-v" # Inverse function 2 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nfwd = 3 # Number of forward transformation functions + Fwd1 = "t=x+1" # Forward function 1 + Fwd2 = "u=y*t" # Forward function 2 + Fwd3 = "v=x-y" # Forward function 3 + Inv1 = "x=u+v" # Inverse function 1 + Inv2 = "y=u-v" # Inverse function 2 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + End CmpMap +== parallel_with_inverted_series +CmpMap 2 2 + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=0.5*y" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=0.5*y" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=0.5*y" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=2*x" # Forward function 1 + Inv1 = "x=0.5*y" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + End CmpMap + End CmpMap +== equal +same_object 1 +same_functions 1 +different_constant 0 +last_opcode_differs 1 +inverted_copy 0 +both_inverted 1 +renamed_variables 1 +max_min 1 +max_constant 0 +max_argument_count 0 +no_forward_both 1 +no_forward_one 0 +forward_one 0 +neither_direction 1 +operand_order 0 +variable_index 0 +nin_differs 0 +function_count_differs 0 +opcode_count_differs 0 +zoommap 0 +== units_log_hz_to_hz +label exp( Frequency ) + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=exp(2.3025850929940459*input_units)" # Forward function 1 + Inv1 = "input_units=log10(output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap +0 -> 1 -> 0 +2 -> 100.00000000000004 -> 2 +-1.5 -> 0.031622776601683784 -> -1.5000000000000002 +== units_sqrt_hz_to_hz +label ( Frequency )**2 + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=input_units**2" # Forward function 1 + Inv1 = "input_units=sqrt(output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap +2 -> 4 -> 2 +0.25 -> 0.0625 -> 0.25 +100 -> 10000 -> 100 +== units_log_kms_to_ms +label exp( Frequency ) + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=1000*exp(2.3025850929940459*input_units)" # Forward function 1 + Inv1 = "input_units=log10(0.001*output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap +0 -> 1000 -> 0 +2 -> 100000.00000000004 -> 2 +-1.5 -> 31.622776601683785 -> -1.5000000000000002 +== units_hz_to_log_hz +label log( Frequency ) + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=log10(input_units)" # Forward function 1 + Inv1 = "input_units=exp(2.3025850929940459*output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap +2 -> 0.3010299956639812 -> 2 +0.25 -> -0.6020599913279624 -> 0.24999999999999994 +100 -> 2 -> 100.00000000000004 +== units_hz_to_sqrt_hz +label sqrt( Frequency ) + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=sqrt(input_units)" # Forward function 1 + Inv1 = "input_units=output_units**2" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap +2 -> 1.4142135623730951 -> 2.0000000000000004 +0.25 -> 0.5 -> 0.25 +100 -> 10 -> 100 +== units_ln_hz_to_mhz +label exp( Frequency ) + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=9.9999999999999995e-07*exp(input_units)" # Forward function 1 + Inv1 = "input_units=log(1000000*output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap +0 -> 9.9999999999999995e-07 -> 0 +2 -> 7.3890560989306502e-06 -> 2 +-1.5 -> 2.231301601484298e-07 -> -1.5000000000000002 +== units_exp_hz_to_hz +label ln( Frequency ) + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=log(input_units)" # Forward function 1 + Inv1 = "input_units=exp(output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap +2 -> 0.69314718055994529 -> 2 +0.25 -> -1.3862943611198906 -> 0.25 +100 -> 4.6051701859880918 -> 100.00000000000004 +== units_log_mhz_to_log_hz +label log((9.9999999999999995e-07*exp( Frequency ))**-1) + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=log10((9.9999999999999995e-07*exp(-2.3025850929940459*input_units))**-1)" # Forward function 1 + Inv1 = "input_units=log10((1000000*exp(-2.3025850929940459*output_units))**-1)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap +0 -> 6 -> 5.7859647993197191e-16 +2 -> 8 -> 2.0000000000000009 +-1.5 -> 4.5 -> -1.4999999999999993 +== units_hz_to_per_hz +label ( Frequency )**-1 + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=input_units**-1" # Forward function 1 + Inv1 = "input_units=output_units**-1" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap +2 -> 0.5 -> 2 +0.25 -> 4 -> 0.25 +100 -> 0.01 -> 100 +== units_hz15_to_hz +label ( Frequency )**0.66666666666666663 + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=input_units**0.66666666666666663" # Forward function 1 + Inv1 = "input_units=output_units**1.5" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap +2 -> 1.5874010519681994 -> 1.9999999999999998 +0.25 -> 0.3968502629920499 -> 0.25 +100 -> 21.544346900318832 -> 99.999999999999957 +== units_m2_to_cm +label sqrt( Frequency ) + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=sqrt(10000*input_units)" # Forward function 1 + Inv1 = "input_units=(0.01*output_units)**2" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap +2 -> 141.42135623730951 -> 2.0000000000000004 +0.25 -> 50 -> 0.25 +100 -> 1000 -> 100 +== units_log_jy_to_w +label exp( Frequency ) + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=1.0000000000000002e-26*exp(2.3025850929940459*input_units)" # Forward function 1 + Inv1 = "input_units=log10(9.9999999999999988e+25*output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap +0 -> 1.0000000000000002e-26 -> 0 +2 -> 1.0000000000000007e-24 -> 2.0000000000000004 +-1.5 -> 3.1622776601683789e-28 -> -1.5000000000000002 +== units_there_and_back +CmpMap 1 1 + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=exp(2.3025850929940459*input_units)" # Forward function 1 + Inv1 = "input_units=log10(output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=log10(input_units)" # Forward function 1 + Inv1 = "input_units=exp(2.3025850929940459*output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + End CmpMap +== units_with_inverse +UnitMap 1 1 + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +== flux_log_conversion +CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000002e-26 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=exp(2.3025850929940459*input_units)" # Forward function 1 + Inv1 = "input_units=log10(output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + End CmpMap +1 -> -26 -> 0.99999999999999245 +1000 -> -23 -> 999.99999999999216 +0.5 -> -26.301029995663981 -> 0.49999999999999528 +== end status 0 diff --git a/src/test/resources/probes/pcdmap_probe.c b/src/test/resources/probes/pcdmap_probe.c new file mode 100644 index 0000000..b1f8099 --- /dev/null +++ b/src/test/resources/probes/pcdmap_probe.c @@ -0,0 +1,456 @@ +/* pcdmap_probe -- PcdMap behaviour of the pinned C library that no + * fixture or oracle holds: attribute values, tests, clears and settings + * (PcdCen with and without an axis, an axis out of range, a bad value, a + * PcdMap shared by a CmpMap); native dumps with each attribute set and + * unset, read back through a Channel; transformations, rates, a split and + * astEqual; and simplification of a PcdMap alone, beside a UnitMap, its own + * inverse, ZoomMaps and PermMaps (swapped past them by PcdZoom and + * PcdPerm, with the ZoomMap or the PcdMap inverted, before or after the + * CmpMap is made), and in parallel. + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * Built against the C library at 3d3f255f with its static libraries: + * cc -std=c11 -I -o pcdmap_probe pcdmap_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 ./pcdmap_probe > pcdmap_probe.out 2>&1, then trailing white + * space removed from every line (the tests compare lines without it). */ +#include +#include +#include +#include "ast.h" + +/* The lines a Channel writes, which a second Channel reads back. */ +#define MAXLINES 400 +static char *lines[ MAXLINES ]; +static int nline = 0; +static int iline = 0; + +static void sink( const char *line ) { + if( nline < MAXLINES ) lines[ nline++ ] = strcpy( malloc( strlen( line ) + 1 ), line ); +} + +static const char *source( void ) { + return ( iline < nline ) ? lines[ iline++ ] : NULL; +} + +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 const char *attrs[] = { "Disco", "PcdCen", "PcdCen(1)", "PcdCen(2)" }; + +/* Each attribute: whether it is set and its value as astGetC gives it. */ +static void attributes( AstMapping *m ) { + for( int i = 0; i < 4; i++ ) { + int t = astTest( m, attrs[ i ] ); + const char *v = astGetC( m, attrs[ i ] ); + if( failed() ) return; + printf( "%s %d %s\n", attrs[ i ], t, v ); + } +} + +/* The points every transformation is given. */ +#define NPT 6 +static const double xs[ NPT ] = { 0.1, 0.35, -0.25, 1.5, 0.3, AST__BAD }; +static const double ys[ NPT ] = { 0.2, -0.45, 0.05, -2.0, -0.2, 0.7 }; + +/* The forward and inverse transformations of the points, given to every + pair of coordinates (a Mapping of four inputs is given each point on + both pairs). */ +static void tran( AstMapping *m ) { + double in[ 4 ][ NPT ], out[ 4 ][ NPT ]; + int n = astGetI( m, "Nin" ); + for( int k = 0; k < n; k++ ) { + for( int i = 0; i < NPT; i++ ) in[ k ][ i ] = ( k % 2 ) ? ys[ i ] : xs[ i ]; + } + for( int dir = 1; dir >= 0; dir-- ) { + astTranN( m, NPT, n, NPT, (const double *) in, dir, n, NPT, (double *) out ); + if( failed() ) return; + for( int i = 0; i < NPT; i++ ) { + printf( "%s", dir ? "fwd" : "inv" ); + for( int k = 0; k < n; k++ ) printf( " %.17g", in[ k ][ i ] ); + printf( " ->" ); + for( int k = 0; k < n; k++ ) printf( " %.17g", out[ k ][ i ] ); + printf( "\n" ); + } + } +} + +static double cen[ 2 ] = { 0.3, -0.2 }; + +/* The PcdMap most cases use. */ +static AstPcdMap *typical( void ) { + return astPcdMap( 0.01, cen, " " ); +} + +static AstPcdMap *pcd( double disco, double x, double y ) { + double c[ 2 ] = { x, y }; + return astPcdMap( disco, c, " " ); +} + +static AstMapping *inv( void *m ) { + astInvert( m ); + return m; +} + +/* The dump, the Object read back from it through a Channel and that + Object's dump, then the transformations of both. */ +static void roundtrip( const char *name, AstMapping *m ) { + head( name ); + astShow( m ); + for( int i = 0; i < nline; i++ ) free( lines[ i ] ); + nline = iline = 0; + AstChannel *ch = astChannel( source, sink, " " ); + astWrite( ch, m ); + AstMapping *back = astRead( ch ); + if( failed() ) return; + printf( "-- read back\n" ); + astShow( back ); + printf( "-- equal %d\n", astEqual( m, back ) ); + printf( "-- transformations\n" ); + tran( m ); + printf( "-- transformations read back\n" ); + tran( back ); + ch = astAnnul( ch ); +} + +/* The class of the simplified Mapping, its dump, and the transformations + of the original and the simplified Mapping. */ +static void simp( const char *name, AstMapping *m ) { + head( name ); + AstMapping *s = astSimplify( m ); + if( failed() ) return; + printf( "class %s\n", astGetC( s, "Class" ) ); + astShow( s ); + printf( "-- transformations\n" ); + tran( m ); + printf( "-- transformations simplified\n" ); + tran( s ); +} + +static AstZoomMap *zoom( double f ) { + return astZoomMap( 2, f, " " ); +} + +/* A PermMap exchanging the two axes. */ +static AstPermMap *swap( void ) { + int perm[ 2 ] = { 2, 1 }; + return astPermMap( 2, perm, 2, perm, NULL, " " ); +} + +static AstCmpMap *series( void *a, void *b ) { + return astCmpMap( a, b, 1, " " ); +} + +static AstCmpMap *series3( void *a, void *b, void *c ) { + return series( series( a, b ), c ); +} + +static AstCmpMap *parallel( void *a, void *b ) { + return astCmpMap( a, b, 0, " " ); +} + +int main( void ) { + int status = 0; + setvbuf( stdout, NULL, _IONBF, 0 ); + astWatch( &status ); + astBegin; + + /* Attributes. */ + head( "attributes_constructed" ); + attributes( (AstMapping *) typical() ); + head( "attributes_constructed_bad" ); + { + double c[ 2 ] = { AST__BAD, 5.0 }; + attributes( (AstMapping *) astPcdMap( AST__BAD, c, " " ) ); + } + head( "attributes_cleared" ); + { + AstPcdMap *p = typical(); + astClear( p, "Disco,PcdCen" ); + attributes( (AstMapping *) p ); + } + head( "attributes_cleared_axis_2" ); + { + AstPcdMap *p = typical(); + astClear( p, "PcdCen(2)" ); + attributes( (AstMapping *) p ); + } + head( "attributes_set" ); + { + AstPcdMap *p = pcd( AST__BAD, AST__BAD, AST__BAD ); + astSet( p, "Disco=-2.5E-3,PcdCen(1)=1.25,PcdCen(2)= -7 " ); + attributes( (AstMapping *) p ); + } + head( "attributes_set_both_axes" ); + { + AstPcdMap *p = typical(); + astSet( p, "PcdCen=3.5" ); + attributes( (AstMapping *) p ); + } + head( "set_bad_unsets" ); + { + AstPcdMap *p = typical(); + astSetD( p, "Disco", AST__BAD ); + astSetD( p, "PcdCen(1)", AST__BAD ); + attributes( (AstMapping *) p ); + } + head( "axis_out_of_range" ); + { + AstPcdMap *p = typical(); + printf( "get 3\n" ); + astGetD( p, "PcdCen(3)" ); + failed(); + printf( "get 0\n" ); + astGetD( p, "PcdCen(0)" ); + failed(); + printf( "set 3\n" ); + astSetD( p, "PcdCen(3)", 1.0 ); + failed(); + printf( "set 0\n" ); + astSet( p, "PcdCen(0)=1.0" ); + failed(); + printf( "test 3\n" ); + astTest( p, "PcdCen(3)" ); + failed(); + printf( "clear 3\n" ); + astClear( p, "PcdCen(3)" ); + failed(); + attributes( (AstMapping *) p ); + } + head( "set_not_a_number" ); + { + AstPcdMap *p = typical(); + astSet( p, "Disco=abc" ); + failed(); + astSet( p, "PcdCen(1)=abc" ); + failed(); + attributes( (AstMapping *) p ); + } + head( "shared_set" ); + { + AstPcdMap *p = typical(); + AstCmpMap *c = series( p, zoom( 2.0 ) ); + astSetD( p, "Disco", 2.0 ); + failed(); + astSetD( p, "PcdCen(2)", 2.0 ); + failed(); + astSet( p, "PcdCen=2.0" ); + failed(); + astClear( p, "Disco" ); + failed(); + astClear( p, "PcdCen(1)" ); + failed(); + astClear( p, "PcdCen" ); + failed(); + printf( "set 3\n" ); + astSetD( p, "PcdCen(3)", 2.0 ); + failed(); + attributes( (AstMapping *) p ); + astInvert( p ); + failed(); + printf( "Invert %d\n", astGetI( p, "Invert" ) ); + AstPcdMap *copy = astCopy( p ); + astSetD( copy, "Disco", 2.0 ); + astClear( copy, "PcdCen(1)" ); + failed(); + printf( "-- copy\n" ); + attributes( (AstMapping *) copy ); + c = astAnnul( c ); + } + + /* Native dumps. */ + roundtrip( "dump_set", (AstMapping *) typical() ); + roundtrip( "dump_inverted", inv( typical() ) ); + roundtrip( "dump_unset", (AstMapping *) pcd( AST__BAD, AST__BAD, AST__BAD ) ); + roundtrip( "dump_zero", (AstMapping *) pcd( 0.0, 0.0, 0.0 ) ); + { + const char *clr[] = { "Disco", "PcdCen(1)", "PcdCen(2)" }; + const char *names[] = { "dump_without_Disco", "dump_without_PcdCen1", "dump_without_PcdCen2" }; + for( int i = 0; i < 3; i++ ) { + AstPcdMap *p = typical(); + astClear( p, clr[ i ] ); + roundtrip( names[ i ], (AstMapping *) p ); + } + } + roundtrip( "dump_simplified", (AstMapping *) astSimplify( typical() ) ); + + /* Transformations, rates, split and equality. */ + head( "transformations" ); + tran( (AstMapping *) typical() ); + head( "transformations_inverted" ); + tran( inv( typical() ) ); + head( "transformations_barrel" ); + tran( (AstMapping *) pcd( -0.3, 0.1, 0.1 ) ); + head( "transformations_large" ); + { + AstPcdMap *p = pcd( 5.0, 0.0, 0.0 ); + double x[ 3 ] = { 1.0, 10.0, 100.0 }, y[ 3 ] = { 0.0, 10.0, -100.0 }; + double xo[ 3 ], yo[ 3 ], xb[ 3 ], yb[ 3 ]; + astTran2( p, 3, x, y, 1, xo, yo ); + astTran2( p, 3, xo, yo, 0, xb, yb ); + failed(); + for( int i = 0; i < 3; i++ ) { + printf( "%.17g %.17g -> %.17g %.17g -> %.17g %.17g\n", x[ i ], y[ i ], xo[ i ], yo[ i ], + xb[ i ], yb[ i ] ); + } + } + head( "rate" ); + { + AstPcdMap *p = typical(); + double at[ 2 ] = { 0.1, 0.2 }; + for( int i = 1; i <= 2; i++ ) { + for( int j = 1; j <= 2; j++ ) { + printf( "fwd %d %d %.17g\n", i, j, astRate( p, at, i, j ) ); + } + } + astInvert( p ); + for( int i = 1; i <= 2; i++ ) { + for( int j = 1; j <= 2; j++ ) { + printf( "inv %d %d %.17g\n", i, j, astRate( p, at, i, j ) ); + } + } + failed(); + } + head( "split" ); + { + int in1[ 1 ] = { 1 }, in2[ 2 ] = { 2, 1 }, out[ 2 ]; + AstMapping *s = NULL; + astMapSplit( inv( typical() ), 1, in1, out, &s ); + failed(); + printf( "one input %s\n", s ? astGetC( s, "Class" ) : "null" ); + s = NULL; + astMapSplit( inv( typical() ), 2, in2, out, &s ); + failed(); + if( s ) { + printf( "outputs %d %d\n", out[ 0 ], out[ 1 ] ); + astShow( s ); + } else { + printf( "two inputs null\n" ); + } + } + head( "equal" ); + { + AstPcdMap *a = typical(); + AstPcdMap *cleared = pcd( 0.01, 0.0, 0.0 ); + astClear( cleared, "PcdCen" ); + AstPcdMap *zero = pcd( 0.01, 0.0, 0.0 ); + printf( "same %d\n", astEqual( a, typical() ) ); + printf( "copy %d\n", astEqual( a, astCopy( a ) ) ); + printf( "different_disco %d\n", astEqual( a, pcd( 0.02, 0.3, -0.2 ) ) ); + printf( "different_centre %d\n", astEqual( a, pcd( 0.01, 0.3, -0.3 ) ) ); + printf( "near_disco %d\n", astEqual( a, pcd( 0.01 * ( 1.0 + 1.0E-12 ), 0.3, -0.2 ) ) ); + printf( "inverted %d\n", astEqual( a, inv( typical() ) ) ); + printf( "both_inverted %d\n", astEqual( inv( typical() ), inv( typical() ) ) ); + printf( "zero_vs_unset %d\n", astEqual( zero, cleared ) ); + printf( "small_vs_unset_disco %d\n", astEqual( pcd( 1.0E-13, 0.0, 0.0 ), pcd( AST__BAD, 0.0, 0.0 ) ) ); + printf( "small_vs_zero_disco %d\n", astEqual( pcd( 1.0E-13, 0.0, 0.0 ), pcd( 0.0, 0.0, 0.0 ) ) ); + printf( "not_a_pcdmap %d\n", astEqual( a, zoom( 2.0 ) ) ); + failed(); + } + + /* Simplification of a PcdMap alone, and replacement of one with no + distortion by a UnitMap. */ + simp( "alone", (AstMapping *) typical() ); + simp( "alone_inverted", inv( typical() ) ); + simp( "zero_disco", (AstMapping *) pcd( 0.0, 0.3, -0.2 ) ); + simp( "unset_disco", (AstMapping *) pcd( AST__BAD, 0.3, -0.2 ) ); + simp( "zero_disco_inverted", inv( pcd( 0.0, 0.3, -0.2 ) ) ); + simp( "small_disco", (AstMapping *) pcd( 1.0E-13, 0.3, -0.2 ) ); + simp( "tiny_disco", (AstMapping *) pcd( 1.0E-310, 0.3, -0.2 ) ); + simp( "zero_disco_parallel", (AstMapping *) parallel( pcd( 0.0, 0.3, -0.2 ), zoom( 2.0 ) ) ); + simp( "zero_disco_series", (AstMapping *) series3( zoom( 2.0 ), pcd( 0.0, 0.3, -0.2 ), zoom( 3.0 ) ) ); + + /* Neighbours a PcdMap merges with: a UnitMap and its own inverse. */ + simp( "unit_after", (AstMapping *) series( typical(), astUnitMap( 2, " " ) ) ); + simp( "unit_before_inverted", (AstMapping *) series( astUnitMap( 2, " " ), inv( typical() ) ) ); + simp( "inverse_after", (AstMapping *) series( typical(), inv( typical() ) ) ); + simp( "inverse_before", (AstMapping *) series( inv( typical() ), typical() ) ); + { + AstPcdMap *p = pcd( 0.01, 0.0, 0.0 ); + astClear( p, "PcdCen" ); + simp( "inverse_unset_centre", (AstMapping *) series( pcd( 0.01, 0.0, 0.0 ), inv( p ) ) ); + } + simp( "inverse_near_disco", + (AstMapping *) series( typical(), inv( pcd( 0.01 * ( 1.0 + 1.0E-12 ), 0.3, -0.2 ) ) ) ); + simp( "inverse_different_disco", + (AstMapping *) series( typical(), inv( pcd( 0.01 * ( 1.0 + 1.0E-9 ), 0.3, -0.2 ) ) ) ); + simp( "inverse_different_centre", (AstMapping *) series( typical(), inv( pcd( 0.01, 0.3, -0.3 ) ) ) ); + simp( "inverse_small_centre_offset", + (AstMapping *) series( pcd( 0.01, 0.0, 0.0 ), inv( pcd( 0.01, 1.0E-13, 0.0 ) ) ) ); + simp( "same_direction", (AstMapping *) series( typical(), typical() ) ); + { + AstPcdMap *p = typical(); + simp( "shared_pair", (AstMapping *) series( p, inv( astCopy( p ) ) ) ); + } + simp( "parallel_inverse", (AstMapping *) parallel( typical(), inv( typical() ) ) ); + + /* Swaps past a ZoomMap (PcdZoom) towards a PcdMap to merge with. */ + simp( "zoom_then_inverse", + (AstMapping *) series3( typical(), zoom( 2.0 ), inv( pcd( 0.0025, 0.6, -0.4 ) ) ) ); + simp( "inverted_zoom_then_inverse", + (AstMapping *) series3( typical(), inv( zoom( 2.0 ) ), inv( pcd( 0.04, 0.15, -0.1 ) ) ) ); + simp( "inverted_pcd_zoom_then_pcd", + (AstMapping *) series3( inv( typical() ), zoom( 2.0 ), pcd( 0.0025, 0.6, -0.4 ) ) ); + simp( "inverted_pcd_inverted_zoom_then_pcd", + (AstMapping *) series3( inv( typical() ), inv( zoom( 0.5 ) ), pcd( 0.0025, 0.6, -0.4 ) ) ); + simp( "zoom_then_inverse_not_matching", + (AstMapping *) series3( typical(), zoom( 2.0 ), inv( typical() ) ) ); + { + AstZoomMap *z = zoom( 2.0 ); + AstCmpMap *c = series3( typical(), z, inv( pcd( 0.04, 0.15, -0.1 ) ) ); + astInvert( z ); + simp( "zoom_inverted_after_combining", (AstMapping *) c ); + } + { + AstPcdMap *p = typical(); + AstCmpMap *c = series3( p, zoom( 2.0 ), pcd( 0.0025, 0.6, -0.4 ) ); + astInvert( p ); + simp( "pcd_inverted_after_combining", (AstMapping *) c ); + } + simp( "two_zooms_then_inverse", + (AstMapping *) series( series3( typical(), zoom( 2.0 ), zoom( 3.0 ) ), inv( pcd( 0.01 / 36.0, 1.8, -1.2 ) ) ) ); + simp( "zoom_inverse_both_sides", + (AstMapping *) series( series3( inv( pcd( 0.04, 0.15, -0.1 ) ), zoom( 2.0 ), typical() ), + series( zoom( 2.0 ), inv( pcd( 0.0025, 0.6, -0.4 ) ) ) ) ); + + /* Swaps past a PermMap exchanging the axes (PcdPerm). */ + simp( "perm_then_inverse", + (AstMapping *) series3( typical(), swap(), inv( pcd( 0.01, -0.2, 0.3 ) ) ) ); + simp( "inverted_pcd_perm_then_pcd", + (AstMapping *) series3( inv( typical() ), swap(), pcd( 0.01, -0.2, 0.3 ) ) ); + simp( "inverted_perm_then_inverse", + (AstMapping *) series3( typical(), inv( swap() ), inv( pcd( 0.01, -0.2, 0.3 ) ) ) ); + simp( "perm_zoom_then_inverse", + (AstMapping *) series( series3( typical(), swap(), zoom( 2.0 ) ), inv( pcd( 0.0025, -0.4, 0.6 ) ) ) ); + { + int inperm[ 2 ] = { 1, 2 }, outperm[ 2 ] = { 1, -1 }; + double con[ 1 ] = { 4.0 }; + AstPermMap *pm = astPermMap( 2, inperm, 2, outperm, con, " " ); + simp( "perm_not_a_swap", (AstMapping *) series3( typical(), pm, inv( typical() ) ) ); + } + simp( "perm_alone_after", (AstMapping *) series( typical(), swap() ) ); + + /* Swaps with no PcdMap to merge with, kept only when a swapped Mapping + then simplifies. */ + simp( "zoom_after_no_target", (AstMapping *) series( typical(), zoom( 2.0 ) ) ); + simp( "zoom_before_no_target", (AstMapping *) series( zoom( 2.0 ), typical() ) ); + simp( "unit_zoom_after", (AstMapping *) series( typical(), zoom( 1.0 ) ) ); + simp( "shift_between", (AstMapping *) series3( typical(), astShiftMap( 2, cen, " " ), inv( typical() ) ) ); + + astEnd; + return 0; +} diff --git a/src/test/resources/probes/pcdmap_probe.out b/src/test/resources/probes/pcdmap_probe.out new file mode 100644 index 0000000..6627e32 --- /dev/null +++ b/src/test/resources/probes/pcdmap_probe.out @@ -0,0 +1,2228 @@ +== attributes_constructed +Disco 1 0.01 +PcdCen 1 0.29999999999999999 +PcdCen(1) 1 0.29999999999999999 +PcdCen(2) 1 -0.20000000000000001 +== attributes_constructed_bad +Disco 0 0 +PcdCen 0 0 +PcdCen(1) 0 0 +PcdCen(2) 1 5 +== attributes_cleared +Disco 0 0 +PcdCen 0 0 +PcdCen(1) 0 0 +PcdCen(2) 0 0 +== attributes_cleared_axis_2 +Disco 1 0.01 +PcdCen 1 0.29999999999999999 +PcdCen(1) 1 0.29999999999999999 +PcdCen(2) 0 0 +== attributes_set +Disco 1 -0.0025000000000000001 +PcdCen 1 1.25 +PcdCen(1) 1 1.25 +PcdCen(2) 1 -7 +== attributes_set_both_axes +Disco 1 0.01 +PcdCen 1 3.5 +PcdCen(1) 1 3.5 +PcdCen(2) 1 3.5 +== set_bad_unsets +Disco 0 0 +PcdCen 0 0 +PcdCen(1) 0 0 +PcdCen(2) 1 -0.20000000000000001 +== axis_out_of_range +get 3 +!! AST: Error in routine main at line 215 in file src/test/resources/probes/pcdmap_probe.c. +! astGetPcdCen(PcdMap): Index (3) is invalid for attribute PcdCen - it should be in the range 1 to 2. +status 233933178 +get 0 +!! AST: Error in routine main at line 218 in file src/test/resources/probes/pcdmap_probe.c. +! astGetPcdCen(PcdMap): Index (0) is invalid for attribute PcdCen - it should be in the range 1 to 2. +status 233933178 +set 3 +!! AST: Error in routine main at line 221 in file src/test/resources/probes/pcdmap_probe.c. +! astSetPcdCen(PcdMap): Index (3) is invalid for attribute PcdCen - it should be in the range 1 to 2. +status 233933178 +set 0 +!! AST: Error in routine main at line 224 in file src/test/resources/probes/pcdmap_probe.c. +! astSetPcdCen(PcdMap): Index (0) is invalid for attribute PcdCen - it should be in the range 1 to 2. +status 233933178 +test 3 +!! AST: Error in routine main at line 227 in file src/test/resources/probes/pcdmap_probe.c. +! astTestPcdCen(PcdMap): Index (3) is invalid for attribute PcdCen - it should be in the range 1 to 2. +status 233933178 +clear 3 +!! AST: Error in routine main at line 230 in file src/test/resources/probes/pcdmap_probe.c. +! astClearPcdCen(PcdMap): Index (3) is invalid for attribute PcdCen - it should be in the range 1 to 2. +status 233933178 +Disco 1 0.01 +PcdCen 1 0.29999999999999999 +PcdCen(1) 1 0.29999999999999999 +PcdCen(2) 1 -0.20000000000000001 +== set_not_a_number +!! AST: Error in routine main at line 237 in file src/test/resources/probes/pcdmap_probe.c. +! astSet: The attribute setting "disco=abc" is invalid for a PcdMap. +status 233933186 +!! AST: Error in routine main at line 239 in file src/test/resources/probes/pcdmap_probe.c. +! astSet: The attribute setting "pcdcen(1)=abc" is invalid for a PcdMap. +status 233933186 +Disco 1 0.01 +PcdCen 1 0.29999999999999999 +PcdCen(1) 1 0.29999999999999999 +PcdCen(2) 1 -0.20000000000000001 +== shared_set +!! AST: Error in routine main at line 247 in file src/test/resources/probes/pcdmap_probe.c. +! astSet(PcdMap): The Discoattribute of the supplied PcdMap cannot be changed because the PcdMap has been cloned (programming error). +status 233934418 +!! AST: Error in routine main at line 249 in file src/test/resources/probes/pcdmap_probe.c. +! astSet(PcdMap): The PcdCenattribute of the supplied PcdMap cannot be changed because the PcdMap has been cloned (programming error). +status 233934418 +!! AST: Error in routine main at line 251 in file src/test/resources/probes/pcdmap_probe.c. +! astSet(PcdMap): The PcdCenattribute of the supplied PcdMap cannot be changed because the PcdMap has been cloned (programming error). +status 233934418 +!! AST: Error in routine main at line 253 in file src/test/resources/probes/pcdmap_probe.c. +! astClear(PcdMap): The Discoattribute of the supplied PcdMap cannot be cleared because the PcdMap has been cloned (programming error). +status 233934418 +!! AST: Error in routine main at line 255 in file src/test/resources/probes/pcdmap_probe.c. +! astClear(PcdMap): The PcdCenattribute of the supplied PcdMap cannot be cleared because the PcdMap has been cloned (programming error). +status 233934418 +!! AST: Error in routine main at line 257 in file src/test/resources/probes/pcdmap_probe.c. +! astClear(PcdMap): The PcdCenattribute of the supplied PcdMap cannot be cleared because the PcdMap has been cloned (programming error). +status 233934418 +set 3 +!! AST: Error in routine main at line 260 in file src/test/resources/probes/pcdmap_probe.c. +! astSetPcdCen(PcdMap): Index (3) is invalid for attribute PcdCen - it should be in the range 1 to 2. +status 233933178 +Disco 1 0.01 +PcdCen 1 0.29999999999999999 +PcdCen(1) 1 0.29999999999999999 +PcdCen(2) 1 -0.20000000000000001 +Invert 1 +-- copy +Disco 1 2 +PcdCen 0 0 +PcdCen(1) 0 0 +PcdCen(2) 1 -0.20000000000000001 +== dump_set + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- read back + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- equal 1 +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +fwd -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +fwd 1.5 -2 -> 1.55616 -2.0842399999999999 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +inv -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +inv 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations read back +fwd 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +fwd -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +fwd 1.5 -2 -> 1.55616 -2.0842399999999999 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +inv -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +inv 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== dump_inverted + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- read back + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- equal 1 +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +fwd -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +fwd 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +inv 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +inv -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +inv 1.5 -2 -> 1.55616 -2.0842399999999999 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations read back +fwd 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +fwd -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +fwd 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +inv 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +inv -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +inv 1.5 -2 -> 1.55616 -2.0842399999999999 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== dump_unset + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems +# PcdCn0 = 0 # Distortion centre on first axis +# PcdCn1 = 0 # Distortion centre on second axis +# Disco = 0 # Distortion coefficient + End PcdMap +-- read back + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems +# PcdCn0 = 0 # Distortion centre on first axis +# PcdCn1 = 0 # Distortion centre on second axis +# Disco = 0 # Distortion coefficient + End PcdMap +-- equal 1 +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations read back +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== dump_zero + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0 # Distortion centre on first axis + PcdCn1 = 0 # Distortion centre on second axis + Disco = 0 # Distortion coefficient + End PcdMap +-- read back + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0 # Distortion centre on first axis + PcdCn1 = 0 # Distortion centre on second axis + Disco = 0 # Distortion coefficient + End PcdMap +-- equal 1 +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations read back +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== dump_without_Disco + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis +# Disco = 0 # Distortion coefficient + End PcdMap +-- read back + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis +# Disco = 0 # Distortion coefficient + End PcdMap +-- equal 1 +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25000000000000006 0.049999999999999989 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25000000000000006 0.049999999999999989 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations read back +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25000000000000006 0.049999999999999989 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25000000000000006 0.049999999999999989 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== dump_without_PcdCen1 + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems +# PcdCn0 = 0 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- read back + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems +# PcdCn0 = 0 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- equal 1 +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10017000000000001 0.20068000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35064749999999995 -0.45046249999999999 +fwd -0.25 0.050000000000000003 -> -0.25031249999999999 0.050312499999999982 +fwd 1.5 -2 -> 1.5823499999999999 -2.0988199999999999 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.30026999999999998 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099830861149952363 0.19932344459980944 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34935606725560925 -0.44954004803972092 +inv -0.25 0.050000000000000003 -> -0.2496886660489874 0.04968866604898739 +inv 1.5 -2 -> 1.4288250954198569 -1.9145901145038282 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29973072638637749 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations read back +fwd 0.10000000000000001 0.20000000000000001 -> 0.10017000000000001 0.20068000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35064749999999995 -0.45046249999999999 +fwd -0.25 0.050000000000000003 -> -0.25031249999999999 0.050312499999999982 +fwd 1.5 -2 -> 1.5823499999999999 -2.0988199999999999 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.30026999999999998 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099830861149952363 0.19932344459980944 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34935606725560925 -0.44954004803972092 +inv -0.25 0.050000000000000003 -> -0.2496886660489874 0.04968866604898739 +inv 1.5 -2 -> 1.4288250954198569 -1.9145901145038282 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29973072638637749 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== dump_without_PcdCen2 + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis +# PcdCn1 = 0 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- read back + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis +# PcdCn1 = 0 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- equal 1 +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.099840000000000012 0.20016 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35010249999999998 -0.45092250000000006 +fwd -0.25 0.050000000000000003 -> -0.25167750000000005 0.050152500000000003 +fwd 1.5 -2 -> 1.56528 -2.1088 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20008000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10015961722431221 0.1998403827756878 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34989812525400377 -0.44908312728603422 +inv -0.25 0.050000000000000003 -> -0.24833766444439637 0.049848878585854212 +inv 1.5 -2 -> 1.4435117446564179 -1.9058529077606963 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.19992009584668108 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations read back +fwd 0.10000000000000001 0.20000000000000001 -> 0.099840000000000012 0.20016 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35010249999999998 -0.45092250000000006 +fwd -0.25 0.050000000000000003 -> -0.25167750000000005 0.050152500000000003 +fwd 1.5 -2 -> 1.56528 -2.1088 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20008000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10015961722431221 0.1998403827756878 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34989812525400377 -0.44908312728603422 +inv -0.25 0.050000000000000003 -> -0.24833766444439637 0.049848878585854212 +inv 1.5 -2 -> 1.4435117446564179 -1.9058529077606963 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.19992009584668108 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== dump_simplified + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- read back + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- equal 1 +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +fwd -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +fwd 1.5 -2 -> 1.55616 -2.0842399999999999 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +inv -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +inv 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations read back +fwd 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +fwd -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +fwd 1.5 -2 -> 1.55616 -2.0842399999999999 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +inv -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +inv 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +fwd -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +fwd 1.5 -2 -> 1.55616 -2.0842399999999999 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +inv -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +inv 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== transformations_inverted +fwd 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +fwd -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +fwd 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +inv 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +inv -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +inv 1.5 -2 -> 1.55616 -2.0842399999999999 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== transformations_barrel +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.19970000000000002 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.32262499999999994 -0.38977499999999998 +fwd -0.25 0.050000000000000003 -> -0.23687499999999997 0.051875000000000004 +fwd 1.5 -2 -> -1.1753999999999998 2.0131000000000001 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29220000000000002 -0.18830000000000005 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20030273285223973 +inv 0.34999999999999998 -0.45000000000000001 -> 0.39491088181763634 -0.54880393999880006 +inv -0.25 0.050000000000000003 -> -0.26486994601196256 0.047875721998291057 +inv 1.5 -2 -> -0.15607130638081027 0.48410695957121541 +inv 0.29999999999999999 -0.20000000000000001 -> 0.30888661506655735 -0.2133299225998361 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== transformations_large +1 0 -> 6 0 -> 2.6829268644950917 0 +10 10 -> 10010 10010 -> 4448.8888937913944 4448.8888937913944 +100 -100 -> 10000100 -10000100 -> 4444488.8888888936 -4444488.8888888936 +== rate +fwd 1 1 1.0027999999999999 +fwd 1 2 -0.0016000000000000001 +fwd 2 1 -0.0016000000000000001 +fwd 2 2 1.0052000000000001 +inv 1 1 0.99722139099999996 +inv 1 2 0.0015810275 +inv 2 1 0.0015810277500000001 +inv 2 2 0.99484984949999999 +== split +one input null +outputs 1 2 + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + End CmpMap +== equal +same 1 +copy 1 +different_disco 0 +different_centre 0 +near_disco 1 +inverted 0 +both_inverted 1 +zero_vs_unset 0 +small_vs_unset_disco 0 +small_vs_zero_disco 1 +not_a_pcdmap 0 +== alone +class PcdMap + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +fwd -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +fwd 1.5 -2 -> 1.55616 -2.0842399999999999 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +inv -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +inv 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +fwd -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +fwd 1.5 -2 -> 1.55616 -2.0842399999999999 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +inv -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +inv 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== alone_inverted +class PcdMap + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +fwd -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +fwd 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +inv 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +inv -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +inv 1.5 -2 -> 1.55616 -2.0842399999999999 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +fwd -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +fwd 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +inv 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +inv -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +inv 1.5 -2 -> 1.55616 -2.0842399999999999 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== zero_disco +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25000000000000006 0.049999999999999989 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25000000000000006 0.049999999999999989 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +== unset_disco +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25000000000000006 0.049999999999999989 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25000000000000006 0.049999999999999989 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +== zero_disco_inverted +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25000000000000006 0.049999999999999989 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25000000000000006 0.049999999999999989 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +== small_disco +class PcdMap + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 1e-13 # Distortion coefficient + End PcdMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.099999999999996009 0.200000000000008 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35000000000000031 -0.45000000000000162 +fwd -0.25 0.050000000000000003 -> -0.25000000000002004 0.050000000000009093 +fwd 1.5 -2 -> 1.5000000000005618 -2.0000000000008424 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.100000000000004 0.19999999999999202 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999964 -0.4499999999999984 +inv -0.25 0.050000000000000003 -> -0.24999999999998007 0.049999999999990885 +inv 1.5 -2 -> 1.4999999999994382 -1.9999999999991576 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.099999999999996009 0.200000000000008 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35000000000000031 -0.45000000000000162 +fwd -0.25 0.050000000000000003 -> -0.25000000000002004 0.050000000000009093 +fwd 1.5 -2 -> 1.5000000000005618 -2.0000000000008424 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.100000000000004 0.19999999999999202 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999964 -0.4499999999999984 +inv -0.25 0.050000000000000003 -> -0.24999999999998007 0.049999999999990885 +inv 1.5 -2 -> 1.4999999999994382 -1.9999999999991576 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== tiny_disco +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25000000000000006 0.049999999999999989 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25000000000000006 0.049999999999999989 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +== zero_disco_parallel +class MatrixMap + Begin MatrixMap # Matrix transformation + Nin = 4 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1 # Forward matrix value + M1 = 1 # Forward matrix value + M2 = 2 # Forward matrix value + M3 = 2 # Forward matrix value + IM0 = 1 # Inverse matrix value + IM1 = 1 # Inverse matrix value + IM2 = 0.5 # Inverse matrix value + IM3 = 0.5 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 0.20000000000000001 0.40000000000000002 +fwd 0.34999999999999998 -0.45000000000000001 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 0.69999999999999996 -0.90000000000000002 +fwd -0.25 0.050000000000000003 -0.25 0.050000000000000003 -> -0.25000000000000006 0.049999999999999989 -0.5 0.10000000000000001 +fwd 1.5 -2 1.5 -2 -> 1.5 -2 3 -4 +fwd 0.29999999999999999 -0.20000000000000001 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 0.59999999999999998 -0.40000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 1.3999999999999999 +inv 0.10000000000000001 0.20000000000000001 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 0.050000000000000003 0.10000000000000001 +inv 0.34999999999999998 -0.45000000000000001 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 0.17499999999999999 -0.22500000000000001 +inv -0.25 0.050000000000000003 -0.25 0.050000000000000003 -> -0.25000000000000006 0.049999999999999989 -0.125 0.025000000000000001 +inv 1.5 -2 1.5 -2 -> 1.5 -2 0.75 -1 +inv 0.29999999999999999 -0.20000000000000001 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 0.14999999999999999 -0.10000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 0.34999999999999998 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 0.20000000000000001 0.40000000000000002 +fwd 0.34999999999999998 -0.45000000000000001 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 0.69999999999999996 -0.90000000000000002 +fwd -0.25 0.050000000000000003 -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 -0.5 0.10000000000000001 +fwd 1.5 -2 1.5 -2 -> 1.5 -2 3 -4 +fwd 0.29999999999999999 -0.20000000000000001 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 0.59999999999999998 -0.40000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 -1.7976931348623157e+308 1.3999999999999999 +inv 0.10000000000000001 0.20000000000000001 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 0.050000000000000003 0.10000000000000001 +inv 0.34999999999999998 -0.45000000000000001 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 0.17499999999999999 -0.22500000000000001 +inv -0.25 0.050000000000000003 -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 -0.125 0.025000000000000001 +inv 1.5 -2 1.5 -2 -> 1.5 -2 0.75 -1 +inv 0.29999999999999999 -0.20000000000000001 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 0.14999999999999999 -0.10000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 -1.7976931348623157e+308 0.34999999999999998 +== zero_disco_series +class ZoomMap + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 6 # Zoom factor + End ZoomMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.60000000000000009 1.2000000000000002 +fwd 0.34999999999999998 -0.45000000000000001 -> 2.0999999999999996 -2.6999999999999997 +fwd -0.25 0.050000000000000003 -> -1.5 0.3000000000000001 +fwd 1.5 -2 -> 9 -12 +fwd 0.29999999999999999 -0.20000000000000001 -> 1.7999999999999998 -1.2000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.016666666666666663 0.033333333333333326 +inv 0.34999999999999998 -0.45000000000000001 -> 0.05833333333333332 -0.074999999999999997 +inv -0.25 0.050000000000000003 -> -0.041666666666666657 0.0083333333333333315 +inv 1.5 -2 -> 0.25 -0.33333333333333331 +inv 0.29999999999999999 -0.20000000000000001 -> 0.049999999999999989 -0.033333333333333326 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.60000000000000009 1.2000000000000002 +fwd 0.34999999999999998 -0.45000000000000001 -> 2.0999999999999996 -2.7000000000000002 +fwd -0.25 0.050000000000000003 -> -1.5 0.30000000000000004 +fwd 1.5 -2 -> 9 -12 +fwd 0.29999999999999999 -0.20000000000000001 -> 1.7999999999999998 -1.2000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 4.1999999999999993 +inv 0.10000000000000001 0.20000000000000001 -> 0.016666666666666666 0.033333333333333333 +inv 0.34999999999999998 -0.45000000000000001 -> 0.058333333333333327 -0.074999999999999997 +inv -0.25 0.050000000000000003 -> -0.041666666666666664 0.0083333333333333332 +inv 1.5 -2 -> 0.25 -0.33333333333333331 +inv 0.29999999999999999 -0.20000000000000001 -> 0.049999999999999996 -0.033333333333333333 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.11666666666666665 +== unit_after +class PcdMap + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +fwd -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +fwd 1.5 -2 -> 1.55616 -2.0842399999999999 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +inv -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +inv 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +fwd -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +fwd 1.5 -2 -> 1.55616 -2.0842399999999999 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +inv -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +inv 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== unit_before_inverted +class PcdMap + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +fwd -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +fwd 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +inv 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +inv -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +inv 1.5 -2 -> 1.55616 -2.0842399999999999 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +fwd -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +fwd 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +inv 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +inv -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +inv 1.5 -2 -> 1.55616 -2.0842399999999999 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== inverse_after +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.099999999999999978 0.20000000000000007 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25000000000000017 0.050000000000000044 +fwd 1.5 -2 -> 1.5000000111595537 -2.0000000167393308 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099999999999999978 0.20000000000000007 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25000000000000017 0.050000000000000044 +inv 1.5 -2 -> 1.5000000111595537 -2.0000000167393308 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +== inverse_before +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000003 0.19999999999999996 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.44999999999999996 +fwd -0.25 0.050000000000000003 -> -0.25000000000000028 0.0500000000000001 +fwd 1.5 -2 -> 1.500000006892372 -2.000000010338558 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000003 0.19999999999999996 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.44999999999999996 +inv -0.25 0.050000000000000003 -> -0.25000000000000028 0.0500000000000001 +inv 1.5 -2 -> 1.500000006892372 -2.000000010338558 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +== inverse_unset_centre +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35000000000000003 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25 0.05000000000000001 +fwd 1.5 -2 -> 1.5000000939217768 -2.0000001252290356 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000004 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.35000000000000003 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25 0.05000000000000001 +inv 1.5 -2 -> 1.5000000939217768 -2.0000001252290356 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000004 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +== inverse_near_disco +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000039 0.19999999999999923 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999992 -0.44999999999999984 +fwd -0.25 0.050000000000000003 -> -0.24999999999999806 0.049999999999999101 +fwd 1.5 -2 -> 1.5000000111595047 -2.0000000167392571 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099999999999999589 0.20000000000000084 +inv 0.34999999999999998 -0.45000000000000001 -> 0.35000000000000003 -0.45000000000000018 +inv -0.25 0.050000000000000003 -> -0.25000000000000228 0.050000000000000988 +inv 1.5 -2 -> 1.5000000111596032 -2.000000016739405 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +== inverse_different_disco +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + MapB = # Second component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.010000000010000001 # Distortion coefficient + End PcdMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.1000000000003976 0.19999999999920481 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999996756 -0.44999999999983786 +fwd -0.25 0.050000000000000003 -> -0.24999999999801442 0.049999999999097461 +fwd 1.5 -2 -> 1.500000011110308 -2.0000000166654619 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099999999999602407 0.20000000000079521 +inv 0.34999999999999998 -0.45000000000000001 -> 0.35000000000003245 -0.45000000000016221 +inv -0.25 0.050000000000000003 -> -0.25000000000198591 0.050000000000902656 +inv 1.5 -2 -> 1.5000000112087999 -2.0000000168131997 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.1000000000003976 0.19999999999920481 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999996756 -0.44999999999983786 +fwd -0.25 0.050000000000000003 -> -0.24999999999801442 0.049999999999097461 +fwd 1.5 -2 -> 1.500000011110308 -2.0000000166654619 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099999999999602407 0.20000000000079521 +inv 0.34999999999999998 -0.45000000000000001 -> 0.35000000000003245 -0.45000000000016221 +inv -0.25 0.050000000000000003 -> -0.25000000000198591 0.050000000000902656 +inv 1.5 -2 -> 1.5000000112087999 -2.0000000168131997 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== inverse_different_centre +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + MapB = # Second component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.29999999999999999 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.1001780542498272 0.19935544127588095 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35001997525511119 -0.45012490949374184 +fwd -0.25 0.050000000000000003 -> -0.24967553147046878 0.04943006197765587 +fwd 1.5 -2 -> 1.503552850676432 -2.009517209822727 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000999700119948 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099821535806521394 0.20064634784361346 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34998004513710279 -0.44987524190888939 +inv -0.25 0.050000000000000003 -> -0.25032526933728999 0.0505713013736378 +inv 1.5 -2 -> 1.4964714726827526 -1.990569120365772 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.19999 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.1001780542498272 0.19935544127588095 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35001997525511119 -0.45012490949374184 +fwd -0.25 0.050000000000000003 -> -0.24967553147046878 0.04943006197765587 +fwd 1.5 -2 -> 1.503552850676432 -2.009517209822727 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000999700119948 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099821535806521394 0.20064634784361346 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34998004513710279 -0.44987524190888939 +inv -0.25 0.050000000000000003 -> -0.25032526933728999 0.0505713013736378 +inv 1.5 -2 -> 1.4964714726827526 -1.990569120365772 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.19999 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== inverse_small_centre_offset +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0 # Distortion centre on first axis + PcdCn1 = 0 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + MapB = # Second component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 1e-13 # Distortion centre on first axis + PcdCn1 = 0 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000005 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35000000000000059 -0.45000000000000029 +fwd -0.25 0.050000000000000003 -> -0.24999999999999981 0.049999999999999982 +fwd 1.5 -2 -> 1.5000000939217861 -2.00000012522904 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.30000000000000032 -0.20000000000000018 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099999999999999936 0.19999999999999996 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999948 -0.44999999999999973 +inv -0.25 0.050000000000000003 -> -0.25000000000000017 0.050000000000000031 +inv 1.5 -2 -> 1.5000000939217668 -2.0000001252290303 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999966 -0.1999999999999999 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000005 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35000000000000059 -0.45000000000000029 +fwd -0.25 0.050000000000000003 -> -0.24999999999999981 0.049999999999999982 +fwd 1.5 -2 -> 1.5000000939217861 -2.00000012522904 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.30000000000000032 -0.20000000000000018 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099999999999999936 0.19999999999999996 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999948 -0.44999999999999973 +inv -0.25 0.050000000000000003 -> -0.25000000000000017 0.050000000000000031 +inv 1.5 -2 -> 1.5000000939217668 -2.0000001252290303 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999966 -0.1999999999999999 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== same_direction +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + MapB = # Second component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.099197595196799992 0.20160480960640004 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35006506341620264 -0.45032531708101342 +fwd -0.25 0.050000000000000003 -> -0.25403706245737528 0.051835028389715987 +fwd 1.5 -2 -> 1.6205796322167092 -2.1808694483250637 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10079288057713204 0.19841423884573595 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34993518942758528 -0.44967594713792647 +inv -0.25 0.050000000000000003 -> -0.2460496132459517 0.048204369657250723 +inv 1.5 -2 -> 1.4064797989871707 -1.859719698480756 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.099197595196799992 0.20160480960640004 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35006506341620264 -0.45032531708101342 +fwd -0.25 0.050000000000000003 -> -0.25403706245737528 0.051835028389715987 +fwd 1.5 -2 -> 1.6205796322167092 -2.1808694483250637 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10079288057713204 0.19841423884573595 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34993518942758528 -0.44967594713792647 +inv -0.25 0.050000000000000003 -> -0.2460496132459517 0.048204369657250723 +inv 1.5 -2 -> 1.4064797989871707 -1.859719698480756 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== shared_pair +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.099999999999999978 0.20000000000000007 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25000000000000017 0.050000000000000044 +fwd 1.5 -2 -> 1.5000000111595537 -2.0000000167393308 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099999999999999978 0.20000000000000007 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25000000000000017 0.050000000000000044 +inv 1.5 -2 -> 1.5000000111595537 -2.0000000167393308 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +fwd -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +fwd 1.5 -2 -> 1.5 -2 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.20000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25 0.050000000000000003 +inv 1.5 -2 -> 1.5 -2 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.69999999999999996 +== parallel_inverse +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 4 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + MapB = # Second component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 0.10039761902572913 0.19920476194854175 +fwd 0.34999999999999998 -0.45000000000000001 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 0.34996756321071432 -0.44983781605357154 +fwd -0.25 0.050000000000000003 -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 -0.24801416645956637 0.049097348390711948 +fwd 1.5 -2 1.5 -2 -> 1.55616 -2.0842399999999999 1.4505062614062472 -1.9257593921093705 +fwd 0.29999999999999999 -0.20000000000000001 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 0.099599999999999994 0.20080000000000003 +inv 0.34999999999999998 -0.45000000000000001 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 0.35003249999999997 -0.45016250000000002 +inv -0.25 0.050000000000000003 -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 -0.2520075 0.050912499999999972 +inv 1.5 -2 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 1.55616 -2.0842399999999999 +inv 0.29999999999999999 -0.20000000000000001 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 0.10039761902572913 0.19920476194854175 +fwd 0.34999999999999998 -0.45000000000000001 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 0.34996756321071432 -0.44983781605357154 +fwd -0.25 0.050000000000000003 -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 -0.24801416645956637 0.049097348390711948 +fwd 1.5 -2 1.5 -2 -> 1.55616 -2.0842399999999999 1.4505062614062472 -1.9257593921093705 +fwd 0.29999999999999999 -0.20000000000000001 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 0.099599999999999994 0.20080000000000003 +inv 0.34999999999999998 -0.45000000000000001 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 0.35003249999999997 -0.45016250000000002 +inv -0.25 0.050000000000000003 -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 -0.2520075 0.050912499999999972 +inv 1.5 -2 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 1.55616 -2.0842399999999999 +inv 0.29999999999999999 -0.20000000000000001 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 -1.7976931348623157e+308 +== zoom_then_inverse +class ZoomMap + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.19999999999999996 0.40000000000000013 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.69999999999999996 -0.90000000000000002 +fwd -0.25 0.050000000000000003 -> -0.50000000000000033 0.10000000000000009 +fwd 1.5 -2 -> 3.0000000223191075 -4.0000000334786616 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59999999999999998 -0.40000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.049999999999999933 0.10000000000000009 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17499999999999999 -0.22500000000000001 +inv -0.25 0.050000000000000003 -> -0.125 0.024999999999999994 +inv 1.5 -2 -> 0.75000000000003431 -1.0000000000000611 +inv 0.29999999999999999 -0.20000000000000001 -> 0.14999999999999999 -0.10000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.20000000000000001 0.40000000000000002 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.69999999999999996 -0.90000000000000002 +fwd -0.25 0.050000000000000003 -> -0.5 0.10000000000000001 +fwd 1.5 -2 -> 3 -4 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59999999999999998 -0.40000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 1.3999999999999999 +inv 0.10000000000000001 0.20000000000000001 -> 0.050000000000000003 0.10000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17499999999999999 -0.22500000000000001 +inv -0.25 0.050000000000000003 -> -0.125 0.025000000000000001 +inv 1.5 -2 -> 0.75 -1 +inv 0.29999999999999999 -0.20000000000000001 -> 0.14999999999999999 -0.10000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.34999999999999998 +== inverted_zoom_then_inverse +class ZoomMap + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 0.5 # Zoom factor + End ZoomMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.049999999999999989 0.10000000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.17499999999999999 -0.22500000000000001 +fwd -0.25 0.050000000000000003 -> -0.12500000000000008 0.025000000000000022 +fwd 1.5 -2 -> 0.75000000557977686 -1.0000000083696654 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.14999999999999999 -0.10000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.19999999999999998 0.40000000000000019 +inv 0.34999999999999998 -0.45000000000000001 -> 0.70000000000000495 -0.90000000000000879 +inv -0.25 0.050000000000000003 -> -0.50000000000002265 0.10000000000000853 +inv 1.5 -2 -> 3.000341593068204 -4.0004807606145096 +inv 0.29999999999999999 -0.20000000000000001 -> 0.59999999999999998 -0.40000000000000008 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.050000000000000003 0.10000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.17499999999999999 -0.22500000000000001 +fwd -0.25 0.050000000000000003 -> -0.125 0.025000000000000001 +fwd 1.5 -2 -> 0.75 -1 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.14999999999999999 -0.10000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.34999999999999998 +inv 0.10000000000000001 0.20000000000000001 -> 0.20000000000000001 0.40000000000000002 +inv 0.34999999999999998 -0.45000000000000001 -> 0.69999999999999996 -0.90000000000000002 +inv -0.25 0.050000000000000003 -> -0.5 0.10000000000000001 +inv 1.5 -2 -> 3 -4 +inv 0.29999999999999999 -0.20000000000000001 -> 0.59999999999999998 -0.40000000000000002 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 1.3999999999999999 +== inverted_pcd_zoom_then_pcd +class ZoomMap + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.20000000000000007 0.39999999999999991 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.69999999999999996 -0.89999999999999991 +fwd -0.25 0.050000000000000003 -> -0.50000000000000056 0.1000000000000002 +fwd 1.5 -2 -> 3.000000013784744 -4.000000020677116 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59999999999999998 -0.40000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.049999999999999989 0.10000000000000003 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17500000000000002 -0.22499999999999998 +inv -0.25 0.050000000000000003 -> -0.125 0.025000000000000022 +inv 1.5 -2 -> 0.75000000000003098 -1.0000000000000553 +inv 0.29999999999999999 -0.20000000000000001 -> 0.14999999999999999 -0.099999999999999992 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.20000000000000001 0.40000000000000002 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.69999999999999996 -0.90000000000000002 +fwd -0.25 0.050000000000000003 -> -0.5 0.10000000000000001 +fwd 1.5 -2 -> 3 -4 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59999999999999998 -0.40000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 1.3999999999999999 +inv 0.10000000000000001 0.20000000000000001 -> 0.050000000000000003 0.10000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17499999999999999 -0.22500000000000001 +inv -0.25 0.050000000000000003 -> -0.125 0.025000000000000001 +inv 1.5 -2 -> 0.75 -1 +inv 0.29999999999999999 -0.20000000000000001 -> 0.14999999999999999 -0.10000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.34999999999999998 +== inverted_pcd_inverted_zoom_then_pcd +class ZoomMap + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.20000000000000007 0.39999999999999991 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.69999999999999996 -0.89999999999999991 +fwd -0.25 0.050000000000000003 -> -0.50000000000000056 0.1000000000000002 +fwd 1.5 -2 -> 3.000000013784744 -4.000000020677116 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59999999999999998 -0.40000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.049999999999999989 0.10000000000000003 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17500000000000002 -0.22499999999999998 +inv -0.25 0.050000000000000003 -> -0.125 0.025000000000000022 +inv 1.5 -2 -> 0.75000000000003098 -1.0000000000000553 +inv 0.29999999999999999 -0.20000000000000001 -> 0.14999999999999999 -0.099999999999999992 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.20000000000000001 0.40000000000000002 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.69999999999999996 -0.90000000000000002 +fwd -0.25 0.050000000000000003 -> -0.5 0.10000000000000001 +fwd 1.5 -2 -> 3 -4 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59999999999999998 -0.40000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 1.3999999999999999 +inv 0.10000000000000001 0.20000000000000001 -> 0.050000000000000003 0.10000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17499999999999999 -0.22500000000000001 +inv -0.25 0.050000000000000003 -> -0.125 0.025000000000000001 +inv 1.5 -2 -> 0.75 -1 +inv 0.29999999999999999 -0.20000000000000001 -> 0.14999999999999999 -0.10000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.34999999999999998 +== zoom_then_inverse_not_matching +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.59999999999999998 # Distortion centre on first axis + PcdCn1 = -0.40000000000000002 # Distortion centre on second axis + Disco = 0.0025000000000000001 # Distortion coefficient + End PcdMap + MapB = # Second component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + End CmpMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.1995709345285725 0.39938616852788494 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.69751205279030826 -0.89585599432685359 +fwd -0.25 0.050000000000000003 -> -0.49821254198672144 0.099646773362614072 +fwd 1.5 -2 -> 2.6992994743136092 -3.5856644968652467 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59961151313762362 -0.39974100875841578 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.050180663414427396 0.099942960472845732 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17503654997332202 -0.22507717628076945 +inv -0.25 0.050000000000000003 -> -0.12502093562933586 0.024936109878097162 +inv 1.5 -2 -> 0.77371849770721735 -1.0344373771946158 +inv 0.29999999999999999 -0.20000000000000001 -> 0.15004870253044872 -0.10003246835363248 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.1995709345285725 0.39938616852788494 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.69751205279030826 -0.89585599432685359 +fwd -0.25 0.050000000000000003 -> -0.49821254198672144 0.099646773362614072 +fwd 1.5 -2 -> 2.6992994743136092 -3.5856644968652467 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59961151313762362 -0.39974100875841578 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.050180663414427396 0.099942960472845732 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17503654997332202 -0.22507717628076945 +inv -0.25 0.050000000000000003 -> -0.12502093562933586 0.024936109878097162 +inv 1.5 -2 -> 0.77371849770721735 -1.0344373771946158 +inv 0.29999999999999999 -0.20000000000000001 -> 0.15004870253044872 -0.10003246835363248 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== zoom_inverted_after_combining +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.59999999999999998 # Distortion centre on first axis + PcdCn1 = -0.40000000000000002 # Distortion centre on second axis + Disco = 0.0025000000000000001 # Distortion coefficient + End PcdMap + MapB = # Second component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.14999999999999999 # Distortion centre on first axis + PcdCn1 = -0.10000000000000001 # Distortion centre on second axis + Disco = 0.040000000000000001 # Distortion coefficient + End PcdMap + End CmpMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.19871472932255443 0.3966526062640916 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.68136020679430276 -0.87311019152763847 +fwd -0.25 0.050000000000000003 -> -0.4924009444963684 0.098240974018913213 +fwd 1.5 -2 -> 2.1775244466945827 -2.8846224111129031 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59491159119303028 -0.39660772746202033 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.05028809741810536 0.1000976074072647 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17567006794566575 -0.22613328185822404 +inv -0.25 0.050000000000000003 -> -0.1254743241077908 0.025026192648084089 +inv 1.5 -2 -> 0.88882753052164576 -1.1931942057150684 +inv 0.29999999999999999 -0.20000000000000001 -> 0.15014610768372177 -0.10009740512248121 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.19871472932255443 0.3966526062640916 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.68136020679430276 -0.87311019152763847 +fwd -0.25 0.050000000000000003 -> -0.4924009444963684 0.098240974018913213 +fwd 1.5 -2 -> 2.1775244466945827 -2.8846224111129031 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59491159119303028 -0.39660772746202033 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.05028809741810536 0.1000976074072647 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17567006794566575 -0.22613328185822404 +inv -0.25 0.050000000000000003 -> -0.1254743241077908 0.025026192648084089 +inv 1.5 -2 -> 0.88882753052164576 -1.1931942057150684 +inv 0.29999999999999999 -0.20000000000000001 -> 0.15014610768372177 -0.10009740512248121 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== pcd_inverted_after_combining +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.59999999999999998 # Distortion centre on first axis + PcdCn1 = -0.40000000000000002 # Distortion centre on second axis + Disco = 0.0025000000000000001 # Distortion coefficient + End PcdMap + MapB = # Second component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.59999999999999998 # Distortion centre on first axis + PcdCn1 = -0.40000000000000002 # Distortion centre on second axis + Disco = 0.0025000000000000001 # Distortion coefficient + End PcdMap + End CmpMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.19839519039359998 0.40320961921280007 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.70013012683240528 -0.90065063416202684 +fwd -0.25 0.050000000000000003 -> -0.50807412491475057 0.10367005677943197 +fwd 1.5 -2 -> 3.2411592644334184 -4.3617388966501274 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59999999999999998 -0.40000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.050757312129033838 0.099091225445159414 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17504059532029576 -0.22499188093594083 +inv -0.25 0.050000000000000003 -> -0.12305456561905947 0.023970064151266762 +inv 1.5 -2 -> 0.74269194195466237 -0.98700789680828893 +inv 0.29999999999999999 -0.20000000000000001 -> 0.15009735766831911 -0.10006490511221275 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.19839519039359998 0.40320961921280007 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.70013012683240528 -0.90065063416202684 +fwd -0.25 0.050000000000000003 -> -0.50807412491475057 0.10367005677943197 +fwd 1.5 -2 -> 3.2411592644334184 -4.3617388966501274 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59999999999999998 -0.40000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.050757312129033838 0.099091225445159414 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17504059532029576 -0.22499188093594083 +inv -0.25 0.050000000000000003 -> -0.12305456561905947 0.023970064151266762 +inv 1.5 -2 -> 0.74269194195466237 -0.98700789680828893 +inv 0.29999999999999999 -0.20000000000000001 -> 0.15009735766831911 -0.10006490511221275 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== two_zooms_then_inverse +class ZoomMap + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 6 # Zoom factor + End ZoomMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.59999999999999987 1.2 +fwd 0.34999999999999998 -0.45000000000000001 -> 2.0999999999999996 -2.7000000000000002 +fwd -0.25 0.050000000000000003 -> -1.5000000000000011 0.30000000000000004 +fwd 1.5 -2 -> 9.000000066957325 -12.000000100435987 +fwd 0.29999999999999999 -0.20000000000000001 -> 1.7999999999999998 -1.2000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.016666666666666718 0.033333333333333298 +inv 0.34999999999999998 -0.45000000000000001 -> 0.058333333333333265 -0.074999999999999983 +inv -0.25 0.050000000000000003 -> -0.04166666666666663 0.0083333333333333315 +inv 1.5 -2 -> 0.25 -0.33333333333333331 +inv 0.29999999999999999 -0.20000000000000001 -> 0.049999999999999989 -0.033333333333333326 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.60000000000000009 1.2000000000000002 +fwd 0.34999999999999998 -0.45000000000000001 -> 2.0999999999999996 -2.7000000000000002 +fwd -0.25 0.050000000000000003 -> -1.5 0.30000000000000004 +fwd 1.5 -2 -> 9 -12 +fwd 0.29999999999999999 -0.20000000000000001 -> 1.7999999999999998 -1.2000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 4.1999999999999993 +inv 0.10000000000000001 0.20000000000000001 -> 0.016666666666666666 0.033333333333333333 +inv 0.34999999999999998 -0.45000000000000001 -> 0.058333333333333327 -0.074999999999999997 +inv -0.25 0.050000000000000003 -> -0.041666666666666664 0.0083333333333333332 +inv 1.5 -2 -> 0.25 -0.33333333333333331 +inv 0.29999999999999999 -0.20000000000000001 -> 0.049999999999999996 -0.033333333333333333 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 0.11666666666666665 +== zoom_inverse_both_sides +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 4 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.59999999999999998 # Distortion centre on first axis + PcdCn1 = -0.40000000000000002 # Distortion centre on second axis + Disco = 0.0025000000000000001 # Distortion coefficient + End PcdMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.40073190554276633 0.79560856674340263 +fwd 0.34999999999999998 -0.45000000000000001 -> 1.3948988396919182 -1.7910729694608571 +fwd -0.25 0.050000000000000003 -> -0.98856856405562776 0.1957132115208603 +fwd 1.5 -2 -> 5.2507154908887879 -6.9454514316212563 +fwd 0.29999999999999999 -0.20000000000000001 -> 1.1992230262752472 -0.79948201751683157 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.024809374999999967 0.050228750000000044 +inv 0.34999999999999998 -0.45000000000000001 -> 0.08748984374999999 -0.11250203125000001 +inv -0.25 0.050000000000000003 -> -0.062991406249999993 0.012760156249999988 +inv 1.5 -2 -> 0.37689562500001761 -0.50337000000003129 +inv 0.29999999999999999 -0.20000000000000001 -> 0.074975625000000004 -0.049983750000000007 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.40073190554276633 0.79560856674340241 +fwd 0.34999999999999998 -0.45000000000000001 -> 1.3948988396919091 -1.7910729694608412 +fwd -0.25 0.050000000000000003 -> -0.98856856405558691 0.19571321152084509 +fwd 1.5 -2 -> 5.2506080114064462 -6.9453001642016643 +fwd 0.29999999999999999 -0.20000000000000001 -> 1.1992230262752472 -0.79948201751683157 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.024809374999999995 0.050228750000000016 +inv 0.34999999999999998 -0.45000000000000001 -> 0.08748984374999999 -0.11250203125000001 +inv -0.25 0.050000000000000003 -> -0.062991406249999993 0.012760156249999988 +inv 1.5 -2 -> 0.37689562499999996 -0.50336999999999998 +inv 0.29999999999999999 -0.20000000000000001 -> 0.074975625000000004 -0.049983750000000007 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== perm_then_inverse +class PermMap + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.20000000000000007 0.099999999999999978 +fwd 0.34999999999999998 -0.45000000000000001 -> -0.45000000000000001 0.34999999999999998 +fwd -0.25 0.050000000000000003 -> 0.050000000000000044 -0.25000000000000017 +fwd 1.5 -2 -> -2.0000000167393308 1.5000000111595537 +fwd 0.29999999999999999 -0.20000000000000001 -> -0.20000000000000001 0.29999999999999999 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.20000000000000001 0.10000000000000003 +inv 0.34999999999999998 -0.45000000000000001 -> -0.45000000000006873 0.35000000000005055 +inv -0.25 0.050000000000000003 -> 0.049999999999999989 -0.25 +inv 1.5 -2 -> -2.0000008204469615 1.5000006064173195 +inv 0.29999999999999999 -0.20000000000000001 -> -0.20000000000000101 0.30000000000000099 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.20000000000000001 0.10000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> -0.45000000000000001 0.34999999999999998 +fwd -0.25 0.050000000000000003 -> 0.050000000000000003 -0.25 +fwd 1.5 -2 -> -2 1.5 +fwd 0.29999999999999999 -0.20000000000000001 -> -0.20000000000000001 0.29999999999999999 +fwd -1.7976931348623157e+308 0.69999999999999996 -> 0.69999999999999996 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.20000000000000001 0.10000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> -0.45000000000000001 0.34999999999999998 +inv -0.25 0.050000000000000003 -> 0.050000000000000003 -0.25 +inv 1.5 -2 -> -2 1.5 +inv 0.29999999999999999 -0.20000000000000001 -> -0.20000000000000001 0.29999999999999999 +inv -1.7976931348623157e+308 0.69999999999999996 -> 0.69999999999999996 -1.7976931348623157e+308 +== inverted_pcd_perm_then_pcd +class PermMap + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.19999999999999996 0.10000000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> -0.44999999999999996 0.34999999999999998 +fwd -0.25 0.050000000000000003 -> 0.0500000000000001 -0.25000000000000028 +fwd 1.5 -2 -> -2.000000010338558 1.500000006892372 +fwd 0.29999999999999999 -0.20000000000000001 -> -0.20000000000000001 0.29999999999999999 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.20000000000000001 0.10000000000000003 +inv 0.34999999999999998 -0.45000000000000001 -> -0.45000000000006218 0.35000000000004555 +inv -0.25 0.050000000000000003 -> 0.049999999999999989 -0.25 +inv 1.5 -2 -> -2.0000003834137168 1.5000002833927473 +inv 0.29999999999999999 -0.20000000000000001 -> -0.20000000000000101 0.30000000000000099 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.20000000000000001 0.10000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> -0.45000000000000001 0.34999999999999998 +fwd -0.25 0.050000000000000003 -> 0.050000000000000003 -0.25 +fwd 1.5 -2 -> -2 1.5 +fwd 0.29999999999999999 -0.20000000000000001 -> -0.20000000000000001 0.29999999999999999 +fwd -1.7976931348623157e+308 0.69999999999999996 -> 0.69999999999999996 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.20000000000000001 0.10000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> -0.45000000000000001 0.34999999999999998 +inv -0.25 0.050000000000000003 -> 0.050000000000000003 -0.25 +inv 1.5 -2 -> -2 1.5 +inv 0.29999999999999999 -0.20000000000000001 -> -0.20000000000000001 0.29999999999999999 +inv -1.7976931348623157e+308 0.69999999999999996 -> 0.69999999999999996 -1.7976931348623157e+308 +== inverted_perm_then_inverse +class PermMap + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.20000000000000007 0.099999999999999978 +fwd 0.34999999999999998 -0.45000000000000001 -> -0.45000000000000001 0.34999999999999998 +fwd -0.25 0.050000000000000003 -> 0.050000000000000044 -0.25000000000000017 +fwd 1.5 -2 -> -2.0000000167393308 1.5000000111595537 +fwd 0.29999999999999999 -0.20000000000000001 -> -0.20000000000000001 0.29999999999999999 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.20000000000000001 0.10000000000000003 +inv 0.34999999999999998 -0.45000000000000001 -> -0.45000000000006873 0.35000000000005055 +inv -0.25 0.050000000000000003 -> 0.049999999999999989 -0.25 +inv 1.5 -2 -> -2.0000008204469615 1.5000006064173195 +inv 0.29999999999999999 -0.20000000000000001 -> -0.20000000000000101 0.30000000000000099 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.20000000000000001 0.10000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> -0.45000000000000001 0.34999999999999998 +fwd -0.25 0.050000000000000003 -> 0.050000000000000003 -0.25 +fwd 1.5 -2 -> -2 1.5 +fwd 0.29999999999999999 -0.20000000000000001 -> -0.20000000000000001 0.29999999999999999 +fwd -1.7976931348623157e+308 0.69999999999999996 -> 0.69999999999999996 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.20000000000000001 0.10000000000000001 +inv 0.34999999999999998 -0.45000000000000001 -> -0.45000000000000001 0.34999999999999998 +inv -0.25 0.050000000000000003 -> 0.050000000000000003 -0.25 +inv 1.5 -2 -> -2 1.5 +inv 0.29999999999999999 -0.20000000000000001 -> -0.20000000000000001 0.29999999999999999 +inv -1.7976931348623157e+308 0.69999999999999996 -> 0.69999999999999996 -1.7976931348623157e+308 +== perm_zoom_then_inverse +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.40000000000000013 0.19999999999999996 +fwd 0.34999999999999998 -0.45000000000000001 -> -0.90000000000000002 0.69999999999999996 +fwd -0.25 0.050000000000000003 -> 0.10000000000000009 -0.50000000000000033 +fwd 1.5 -2 -> -4.0000000334786616 3.0000000223191075 +fwd 0.29999999999999999 -0.20000000000000001 -> -0.40000000000000002 0.59999999999999998 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.049999999999999989 +inv 0.34999999999999998 -0.45000000000000001 -> -0.22500000000000048 0.17500000000000021 +inv -0.25 0.050000000000000003 -> 0.024999999999999967 -0.12499999999999999 +inv 1.5 -2 -> -1.0000000002266538 0.75000000016563173 +inv 0.29999999999999999 -0.20000000000000001 -> -0.10000000000000014 0.15000000000000008 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.40000000000000002 0.20000000000000001 +fwd 0.34999999999999998 -0.45000000000000001 -> -0.90000000000000002 0.69999999999999996 +fwd -0.25 0.050000000000000003 -> 0.10000000000000001 -0.5 +fwd 1.5 -2 -> -4 3 +fwd 0.29999999999999999 -0.20000000000000001 -> -0.40000000000000002 0.59999999999999998 +fwd -1.7976931348623157e+308 0.69999999999999996 -> 1.3999999999999999 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10000000000000001 0.050000000000000003 +inv 0.34999999999999998 -0.45000000000000001 -> -0.22500000000000001 0.17499999999999999 +inv -0.25 0.050000000000000003 -> 0.025000000000000001 -0.125 +inv 1.5 -2 -> -1 0.75 +inv 0.29999999999999999 -0.20000000000000001 -> -0.10000000000000001 0.14999999999999999 +inv -1.7976931348623157e+308 0.69999999999999996 -> 0.34999999999999998 -1.7976931348623157e+308 +== perm_not_a_swap +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = -1 # Output coordinate 2 = constant no. 1 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + Nconst = 1 # Number of constants + Con1 = 4 # Constant number 1 + End PermMap + End CmpMap + MapB = # Second component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.12371541219452994 3.4945871695757194 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34402086342218058 3.4953505496059267 +fwd -0.25 0.050000000000000003 -> -0.18487921170932292 3.4892482243070182 +fwd 1.5 -2 -> 1.3958874705924968 3.4641250927337972 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 3.4954013258716246 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099999999999999978 0.20000000000000007 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25000000000000017 0.050000000000000044 +inv 1.5 -2 -> 1.5000000111595537 -2.0000000167393308 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.12371541219452994 3.4945871695757194 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.34402086342218058 3.4953505496059267 +fwd -0.25 0.050000000000000003 -> -0.18487921170932292 3.4892482243070182 +fwd 1.5 -2 -> 1.3958874705924968 3.4641250927337972 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 3.4954013258716246 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.099999999999999978 0.20000000000000007 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34999999999999998 -0.45000000000000001 +inv -0.25 0.050000000000000003 -> -0.25000000000000017 0.050000000000000044 +inv 1.5 -2 -> 1.5000000111595537 -2.0000000167393308 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== perm_alone_after +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.20080000000000003 0.099599999999999994 +fwd 0.34999999999999998 -0.45000000000000001 -> -0.45016250000000002 0.35003249999999997 +fwd -0.25 0.050000000000000003 -> 0.050912499999999972 -0.2520075 +fwd 1.5 -2 -> -2.0842399999999999 1.55616 +fwd 0.29999999999999999 -0.20000000000000001 -> -0.20000000000000001 0.29999999999999999 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.20009970119452719 0.09970089641641855 +inv 0.34999999999999998 -0.45000000000000001 -> -0.4436752471409669 0.34536184790337571 +inv -0.25 0.050000000000000003 -> 0.050162183946428435 -0.24996756321071431 +inv 1.5 -2 -> -1.8469706115624438 1.3868913215896326 +inv 0.29999999999999999 -0.20000000000000001 -> -0.1975367667718001 0.29753676677180008 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.20080000000000003 0.099599999999999994 +fwd 0.34999999999999998 -0.45000000000000001 -> -0.45016250000000002 0.35003249999999997 +fwd -0.25 0.050000000000000003 -> 0.050912499999999972 -0.2520075 +fwd 1.5 -2 -> -2.0842399999999999 1.55616 +fwd 0.29999999999999999 -0.20000000000000001 -> -0.20000000000000001 0.29999999999999999 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.20009970119452719 0.09970089641641855 +inv 0.34999999999999998 -0.45000000000000001 -> -0.4436752471409669 0.34536184790337571 +inv -0.25 0.050000000000000003 -> 0.050162183946428435 -0.24996756321071431 +inv 1.5 -2 -> -1.8469706115624438 1.3868913215896326 +inv 0.29999999999999999 -0.20000000000000001 -> -0.1975367667718001 0.29753676677180008 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== zoom_after_no_target +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.19919999999999999 0.40160000000000007 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.70006499999999994 -0.90032500000000004 +fwd -0.25 0.050000000000000003 -> -0.50401499999999999 0.10182499999999994 +fwd 1.5 -2 -> 3.11232 -4.1684799999999997 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59999999999999998 -0.40000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.050379516347175551 0.099544580383389369 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17502030260408799 -0.22499593947918239 +inv -0.25 0.050000000000000003 -> -0.12402394335368144 0.024483264128419585 +inv 1.5 -2 -> 0.74630146428203381 -0.99342482539028243 +inv 0.29999999999999999 -0.20000000000000001 -> 0.15004870253044872 -0.10003246835363248 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.19919999999999999 0.40160000000000007 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.70006499999999994 -0.90032500000000004 +fwd -0.25 0.050000000000000003 -> -0.50401499999999999 0.10182499999999994 +fwd 1.5 -2 -> 3.11232 -4.1684799999999997 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59999999999999998 -0.40000000000000002 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.050379516347175551 0.099544580383389369 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17502030260408799 -0.22499593947918239 +inv -0.25 0.050000000000000003 -> -0.12402394335368144 0.024483264128419585 +inv 1.5 -2 -> 0.74630146428203381 -0.99342482539028243 +inv 0.29999999999999999 -0.20000000000000001 -> 0.15004870253044872 -0.10003246835363248 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== zoom_before_no_target +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.19963 0.40222000000000008 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.70259999999999989 -0.90454999999999997 +fwd -0.25 0.050000000000000003 -> -0.50584000000000007 0.10219000000000006 +fwd 1.5 -2 -> 3.5867100000000001 -4.8257400000000006 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.60038999999999998 -0.40026000000000006 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.050198809512864567 0.099602380974270877 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17498378160535716 -0.22491890802678577 +inv -0.25 0.050000000000000003 -> -0.12400708322978318 0.024548674195355974 +inv 1.5 -2 -> 0.72525313070312358 -0.96287969605468526 +inv 0.29999999999999999 -0.20000000000000001 -> 0.14999999999999999 -0.10000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.19963 0.40222000000000008 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.70259999999999989 -0.90454999999999997 +fwd -0.25 0.050000000000000003 -> -0.50584000000000007 0.10219000000000006 +fwd 1.5 -2 -> 3.5867100000000001 -4.8257400000000006 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.60038999999999998 -0.40026000000000006 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.050198809512864567 0.099602380974270877 +inv 0.34999999999999998 -0.45000000000000001 -> 0.17498378160535716 -0.22491890802678577 +inv -0.25 0.050000000000000003 -> -0.12400708322978318 0.024548674195355974 +inv 1.5 -2 -> 0.72525313070312358 -0.96287969605468526 +inv 0.29999999999999999 -0.20000000000000001 -> 0.14999999999999999 -0.10000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== unit_zoom_after +class PcdMap + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +fwd -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +fwd 1.5 -2 -> 1.55616 -2.0842399999999999 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +inv -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +inv 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.099599999999999994 0.20080000000000003 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.35003249999999997 -0.45016250000000002 +fwd -0.25 0.050000000000000003 -> -0.2520075 0.050912499999999972 +fwd 1.5 -2 -> 1.55616 -2.0842399999999999 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> 0.10039761902572913 0.19920476194854175 +inv 0.34999999999999998 -0.45000000000000001 -> 0.34996756321071432 -0.44983781605357154 +inv -0.25 0.050000000000000003 -> -0.24801416645956637 0.049097348390711948 +inv 1.5 -2 -> 1.4505062614062472 -1.9257593921093705 +inv 0.29999999999999999 -0.20000000000000001 -> 0.29999999999999999 -0.20000000000000001 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== shift_between +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + MapB = # Second component Mapping + Begin ShiftMap # Shift each coordinate axis + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 0.29999999999999999 # Shift for axis 1 + Sft2 = -0.20000000000000001 # Shift for axis 2 + End ShiftMap + End CmpMap + MapB = # Second component Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 0.29999999999999999 # Distortion centre on first axis + PcdCn1 = -0.20000000000000001 # Distortion centre on second axis + Disco = 0.01 # Distortion coefficient + End PcdMap + End CmpMap +-- transformations +fwd 0.10000000000000001 0.20000000000000001 -> 0.39955003543322209 0.00069926822280136358 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.64890526362054768 -0.64871280733813219 +fwd -0.25 0.050000000000000003 -> 0.048158747161519522 -0.1491210865345709 +fwd 1.5 -2 -> 1.7678089358684654 -2.1659071666759782 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59961151313762362 -0.39974100875841578 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> -0.19739552491197104 0.39719270856737049 +inv 0.34999999999999998 -0.45000000000000001 -> 0.050194662930895972 -0.2501299577774268 +inv -0.25 0.050000000000000003 -> -0.54430315425224696 0.24683508776831919 +inv 1.5 -2 -> 1.2238134545222632 -1.827262772595148 +inv 0.29999999999999999 -0.20000000000000001 -> 0.00038848686237641372 -0.00025899124158426656 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +-- transformations simplified +fwd 0.10000000000000001 0.20000000000000001 -> 0.39955003543322209 0.00069926822280136358 +fwd 0.34999999999999998 -0.45000000000000001 -> 0.64890526362054768 -0.64871280733813219 +fwd -0.25 0.050000000000000003 -> 0.048158747161519522 -0.1491210865345709 +fwd 1.5 -2 -> 1.7678089358684654 -2.1659071666759782 +fwd 0.29999999999999999 -0.20000000000000001 -> 0.59961151313762362 -0.39974100875841578 +fwd -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv 0.10000000000000001 0.20000000000000001 -> -0.19739552491197104 0.39719270856737049 +inv 0.34999999999999998 -0.45000000000000001 -> 0.050194662930895972 -0.2501299577774268 +inv -0.25 0.050000000000000003 -> -0.54430315425224696 0.24683508776831919 +inv 1.5 -2 -> 1.2238134545222632 -1.827262772595148 +inv 0.29999999999999999 -0.20000000000000001 -> 0.00038848686237641372 -0.00025899124158426656 +inv -1.7976931348623157e+308 0.69999999999999996 -> -1.7976931348623157e+308 -1.7976931348623157e+308 diff --git a/src/test/resources/probes/polymap_cancel_probe.c b/src/test/resources/probes/polymap_cancel_probe.c new file mode 100644 index 0000000..69e4bc3 --- /dev/null +++ b/src/test/resources/probes/polymap_cancel_probe.c @@ -0,0 +1,60 @@ +/* polymap_cancel_probe -- what simplifying a series CmpMap of a PolyMap and + * an inverted copy of it does to the Invert attributes of the two PolyMaps, + * which the CmpMap shares, in the pinned C library (polymap.c MapMerge sets + * the Invert attribute of the PolyMap it nominates to the value the list + * applies it with, and of the neighbour it compares; it sets back the + * neighbour's and, unless the pair cancels, the nominee's). + * + * The PolyMap has one input and one output: forward 1.0*x*x + 3.0*x, inverse + * 0.5*x. For each case the probe writes the class of the simplified Mapping + * and, before and after simplifying, the value of the Invert attribute of + * the PolyMap and of its copy and whether each is set. + * + * Each case starts with a line "== ". + * Built against the C library at 3d3f255f with its static libraries: + * cc -std=c11 -I -o polymap_cancel_probe polymap_cancel_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 + * ./polymap_cancel_probe > polymap_cancel_probe.out 2>&1 */ +#include +#include "ast.h" + +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" ) ); +} + +/* Simplifies the series CmpMap of the PolyMap and an inverted copy of it, + itself inverted if "invert_cmp" is non-zero. */ +static void cancel( const char *name, int invert_cmp ) { + static const double fwd[] = { 1.0, 1.0, 2.0, 3.0, 1.0, 1.0 }; + static const double inv[] = { 0.5, 1.0, 1.0 }; + printf( "== %s\n", name ); + AstMapping *p = (AstMapping *) astPolyMap( 1, 1, 2, fwd, 1, inv, " " ); + AstMapping *q = astCopy( p ); + astInvert( q ); + AstMapping *c = (AstMapping *) astCmpMap( p, q, 1, " " ); + if( invert_cmp ) astInvert( c ); + invert_attrs( "before", p, q ); + AstMapping *s = astSimplify( c ); + printf( "class %s\n", astGetC( s, "Class" ) ); + invert_attrs( "after", p, q ); + if( !astOK ) { + printf( "status %d\n", astStatus ); + astClearStatus; + } + astAnnul( s ); + astAnnul( c ); + astAnnul( q ); + astAnnul( p ); +} + +int main( void ) { + setvbuf( stdout, NULL, _IONBF, 0 ); + cancel( "series", 0 ); + cancel( "inverted_series", 1 ); + return 0; +} diff --git a/src/test/resources/probes/polymap_cancel_probe.out b/src/test/resources/probes/polymap_cancel_probe.out new file mode 100644 index 0000000..236ac34 --- /dev/null +++ b/src/test/resources/probes/polymap_cancel_probe.out @@ -0,0 +1,8 @@ +== series +before p 0 set 0 q 1 set 1 +class UnitMap +after p 0 set 1 q 1 set 1 +== inverted_series +before p 0 set 0 q 1 set 1 +class UnitMap +after p 0 set 1 q 0 set 1 diff --git a/src/test/resources/probes/ratemap_probe.c b/src/test/resources/probes/ratemap_probe.c new file mode 100644 index 0000000..a3b6627 --- /dev/null +++ b/src/test/resources/probes/ratemap_probe.c @@ -0,0 +1,347 @@ +/* ratemap_probe -- RateMap behaviour of the pinned C library that no + * fixture or oracle holds: native dumps of RateMaps of ZoomMaps (with the + * encapsulated Mapping inverted when the RateMap is made or afterwards, and + * the RateMap itself inverted) and of a LutMap, a MathMap and a TranMap, + * each read back through a Channel and dumped again; simplification of a + * RateMap alone (of a simplifiable Mapping, a UnitMap, an inverted + * Mapping) and of RateMaps cancelling against their inverses in series; + * rates; astEqual; astMapSplit; and the constructor's errors. + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * Built against the C library at 3d3f255f with its static libraries: + * cc -std=c11 -I -o ratemap_probe ratemap_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 ./ratemap_probe > ratemap_probe.out 2>&1, then trailing white + * space removed from every line (RateMapTest compares lines without it). */ +#include +#include +#include +#include "ast.h" + +/* The lines a Channel writes, which a second Channel reads back. */ +#define MAXLINES 400 +static char *lines[ MAXLINES ]; +static int nline = 0; +static int iline = 0; + +static void sink( const char *line ) { + if( nline < MAXLINES ) lines[ nline++ ] = strcpy( malloc( strlen( line ) + 1 ), line ); +} + +static const char *source( void ) { + return ( iline < nline ) ? lines[ iline++ ] : NULL; +} + +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; +} + +/* The transformations of one point in each direction the Mapping defines: + input coordinate i is x + i. */ +static void tran( AstMapping *m, double x ) { + double in[ 8 ], out[ 8 ]; + int nin = astGetI( m, "Nin" ); + int nout = astGetI( m, "Nout" ); + if( astGetL( m, "TranForward" ) ) { + for( int i = 0; i < nin; i++ ) in[ i ] = x + i; + astTranN( m, 1, nin, 1, in, 1, nout, 1, out ); + if( failed() ) return; + printf( "fwd" ); + for( int i = 0; i < nin; i++ ) printf( " %.17g", in[ i ] ); + printf( " ->" ); + for( int i = 0; i < nout; i++ ) printf( " %.17g", out[ i ] ); + printf( "\n" ); + } + if( astGetL( m, "TranInverse" ) ) { + for( int i = 0; i < nout; i++ ) in[ i ] = x + i; + astTranN( m, 1, nout, 1, in, 0, nin, 1, out ); + if( failed() ) return; + printf( "inv" ); + for( int i = 0; i < nout; i++ ) printf( " %.17g", in[ i ] ); + printf( " ->" ); + for( int i = 0; i < nin; i++ ) printf( " %.17g", out[ i ] ); + printf( "\n" ); + } +} + +/* The dump, the Object read back from it through a Channel and that + Object's dump, then the transformations of both. */ +static void roundtrip( const char *name, AstMapping *m, double x ) { + head( name ); + astShow( m ); + for( int i = 0; i < nline; i++ ) free( lines[ i ] ); + nline = iline = 0; + AstChannel *ch = astChannel( source, sink, " " ); + astWrite( ch, m ); + AstMapping *back = astRead( ch ); + if( failed() ) return; + printf( "-- read back\n" ); + astShow( back ); + printf( "-- transformations\n" ); + tran( m, x ); + printf( "-- transformations read back\n" ); + tran( back, x ); + ch = astAnnul( ch ); +} + +/* The class of the simplified Mapping, its dump, and the transformations + of the original and the simplified Mapping. */ +static void simp( const char *name, AstMapping *m, double x ) { + head( name ); + AstMapping *s = astSimplify( m ); + if( failed() ) return; + printf( "class %s\n", astGetC( s, "Class" ) ); + astShow( s ); + printf( "-- transformations\n" ); + tran( m, x ); + printf( "-- transformations simplified\n" ); + tran( s, x ); +} + +static AstZoomMap *zoom( int n, double f ) { + return astZoomMap( n, f, " " ); +} + +static AstMapping *inv( AstMapping *m ) { + astInvert( m ); + return m; +} + +static AstRateMap *rate( void *m, int ax1, int ax2 ) { + return astRateMap( m, ax1, ax2, " " ); +} + +/* A series CmpMap of two n-dimensional ZoomMaps. */ +static AstMapping *zooms( int n, double f1, double f2 ) { + return (AstMapping *) astCmpMap( zoom( n, f1 ), zoom( n, f2 ), 1, " " ); +} + +static double table[] = { 0.0, 1.0, 4.0, 9.0, 16.0 }; + +/* A two-input, two-output MathMap with no inverse. */ +static AstMathMap *mathmap2( void ) { + const char *fwd[] = { "r = x * y", "s = x + y * y" }; + const char *invf[] = { "x", "y" }; + return astMathMap( 2, 2, 2, fwd, 2, invf, " " ); +} + +static AstMathMap *square( void ) { + const char *fwd[] = { "y = x * x" }; + const char *invf[] = { "x = sqrt( y )" }; + return astMathMap( 1, 1, 1, fwd, 1, invf, " " ); +} + +static void split( AstMapping *m, int nin, int *in ) { + int out[ 8 ]; + AstMapping *s; + astMapSplit( m, nin, in, out, &s ); + if( failed() ) return; + if( !s ) { + printf( "split none\n" ); + return; + } + printf( "outputs" ); + for( int i = 0; i < astGetI( s, "Nout" ); i++ ) printf( " %d", out[ i ] ); + printf( "\n" ); + astShow( s ); +} + +int main( void ) { + int status = 0; + setvbuf( stdout, NULL, _IONBF, 0 ); + astWatch( &status ); + astBegin; + + /* Native dumps and read back. */ + roundtrip( "dump_plain", (AstMapping *) rate( zoom( 2, 3.0 ), 2, 1 ), 1.5 ); + roundtrip( "dump_first_axes", (AstMapping *) rate( zoom( 1, 2.0 ), 1, 1 ), 1.5 ); + roundtrip( "dump_inverted_mapping", (AstMapping *) rate( inv( (AstMapping *) zoom( 1, 2.0 ) ), 1, 1 ), 1.5 ); + { + AstZoomMap *z = zoom( 1, 2.0 ); + AstRateMap *r = rate( z, 1, 1 ); + astInvert( z ); + roundtrip( "dump_mapping_inverted_after", (AstMapping *) r, 1.5 ); + } + roundtrip( "dump_ratemap_inverted", inv( (AstMapping *) rate( zoom( 2, 3.0 ), 1, 2 ) ), 1.5 ); + roundtrip( "dump_lutmap", (AstMapping *) rate( astLutMap( 5, table, 1.0, 1.0, " " ), 1, 1 ), 2.5 ); + roundtrip( "dump_mathmap", (AstMapping *) rate( mathmap2(), 2, 2 ), 1.5 ); + roundtrip( "dump_tranmap", + (AstMapping *) rate( astTranMap( square(), zoom( 1, 3.0 ), " " ), 1, 1 ), 1.5 ); + roundtrip( "dump_inverted_tranmap", + (AstMapping *) rate( inv( (AstMapping *) astTranMap( zoom( 1, 3.0 ), square(), " " ) ), 1, 1 ), 1.5 ); + + /* Simplification of a RateMap alone. */ + simp( "simp_plain", (AstMapping *) rate( zoom( 1, 2.0 ), 1, 1 ), 1.5 ); + simp( "simp_unitmap", (AstMapping *) rate( astUnitMap( 2, " " ), 1, 2 ), 1.5 ); + simp( "simp_interior", (AstMapping *) rate( zooms( 2, 2.0, 3.0 ), 1, 1 ), 1.5 ); + simp( "simp_interior_inverted_mapping", (AstMapping *) rate( inv( zooms( 1, 2.0, 4.0 ) ), 1, 1 ), 1.5 ); + { + AstMapping *c = zooms( 1, 2.0, 4.0 ); + AstRateMap *r = rate( c, 1, 1 ); + astInvert( c ); + simp( "simp_interior_mapping_inverted_after", (AstMapping *) r, 1.5 ); + } + simp( "simp_interior_ratemap_inverted", inv( (AstMapping *) rate( zooms( 1, 2.0, 4.0 ), 1, 1 ) ), 1.5 ); + simp( "simp_interior_in_series", + (AstMapping *) astCmpMap( zoom( 1, 5.0 ), rate( zooms( 1, 2.0, 4.0 ), 1, 1 ), 1, " " ), 1.5 ); + + /* RateMaps cancelling against their inverses in series. */ + simp( "cancel_upper", + (AstMapping *) astCmpMap( rate( zoom( 1, 2.0 ), 1, 1 ), inv( (AstMapping *) rate( zoom( 1, 2.0 ), 1, 1 ) ), + 1, " " ), 1.5 ); + simp( "cancel_lower", + (AstMapping *) astCmpMap( inv( (AstMapping *) rate( zoom( 1, 2.0 ), 1, 1 ) ), rate( zoom( 1, 2.0 ), 1, 1 ), + 1, " " ), 1.5 ); + simp( "cancel_two_inputs_upper", + (AstMapping *) astCmpMap( rate( zoom( 2, 2.0 ), 1, 1 ), inv( (AstMapping *) rate( zoom( 2, 2.0 ), 1, 1 ) ), + 1, " " ), 1.5 ); + simp( "cancel_two_inputs_lower", + (AstMapping *) astCmpMap( inv( (AstMapping *) rate( zoom( 2, 2.0 ), 1, 1 ) ), rate( zoom( 2, 2.0 ), 1, 1 ), + 1, " " ), 1.5 ); + simp( "cancel_equivalent_mappings", + (AstMapping *) astCmpMap( rate( zoom( 1, 2.0 ), 1, 1 ), + inv( (AstMapping *) rate( inv( (AstMapping *) zoom( 1, 0.5 ) ), 1, 1 ) ), + 1, " " ), 1.5 ); + { + AstZoomMap *z = zoom( 1, 2.0 ); + AstRateMap *r = rate( z, 1, 1 ); + astInvert( z ); + simp( "cancel_mapping_inverted_after", + (AstMapping *) astCmpMap( r, inv( (AstMapping *) rate( zoom( 1, 2.0 ), 1, 1 ) ), 1, " " ), 1.5 ); + } + simp( "no_cancel_axes", + (AstMapping *) astCmpMap( rate( zoom( 2, 2.0 ), 1, 1 ), inv( (AstMapping *) rate( zoom( 2, 2.0 ), 1, 2 ) ), + 1, " " ), 1.5 ); + simp( "no_cancel_mappings", + (AstMapping *) astCmpMap( rate( zoom( 1, 2.0 ), 1, 1 ), inv( (AstMapping *) rate( zoom( 1, 3.0 ), 1, 1 ) ), + 1, " " ), 1.5 ); + simp( "no_cancel_same_invert", + (AstMapping *) astCmpMap( rate( zoom( 1, 2.0 ), 1, 1 ), rate( zoom( 1, 2.0 ), 1, 1 ), 1, " " ), 1.5 ); + simp( "no_cancel_parallel", + (AstMapping *) astCmpMap( rate( zoom( 1, 2.0 ), 1, 1 ), inv( (AstMapping *) rate( zoom( 1, 2.0 ), 1, 1 ) ), + 0, " " ), 1.5 ); + { + AstRateMap *r = rate( zoom( 1, 2.0 ), 1, 1 ); + simp( "no_cancel_shared", (AstMapping *) astCmpMap( r, r, 1, " " ), 1.5 ); + } + head( "simp_error" ); + { + int perm_out[] = { 0, 0 }; + int perm_in[] = { -1, -2 }; + double con[] = { 0.1, 0.2 }; + AstPermMap *p = astPermMap( 2, perm_out, 2, perm_in, con, " " ); + AstWcsMap *w = astWcsMap( 2, AST__COE, 1, 2, " " ); + AstRateMap *r = rate( astCmpMap( p, w, 1, " " ), 1, 1 ); + astSimplify( r ); + failed(); + } + + /* Rates. */ + head( "rates" ); + { + double at[] = { 2.0 }; + double bad = AST__BAD; + const char *fwd[] = { "y = x * x * x" }; + const char *invf[] = { "x" }; + AstRateMap *r = rate( astMathMap( 1, 1, 1, fwd, 1, invf, " " ), 1, 1 ); + double out; + printf( "rate of ratemap %.17g\n", astRate( r, at, 1, 1 ) ); + astTran1( r, 1, at, 1, &out ); + printf( "ratemap of cube at 2 %.17g\n", out ); + astTran1( r, 1, &bad, 1, &out ); + printf( "ratemap of cube at bad %.17g\n", out ); + failed(); + } + + /* Equality. */ + head( "equal" ); + { + AstRateMap *a = rate( zoom( 2, 2.0 ), 1, 2 ); + AstRateMap *b = rate( zoom( 2, 2.0 ), 1, 2 ); + AstRateMap *c = rate( zoom( 2, 2.0 ), 1, 1 ); + AstRateMap *d = rate( zoom( 2, 3.0 ), 1, 2 ); + AstRateMap *e = rate( inv( (AstMapping *) zoom( 2, 0.5 ) ), 1, 2 ); + AstRateMap *ainv = astCopy( a ); + astInvert( ainv ); + AstRateMap *binv = astCopy( b ); + astInvert( binv ); + AstZoomMap *z = zoom( 2, 2.0 ); + AstRateMap *f = rate( z, 1, 2 ); + astInvert( z ); + printf( "same %d\n", astEqual( a, b ) ); + printf( "different_axes %d\n", astEqual( a, c ) ); + printf( "different_mappings %d\n", astEqual( a, d ) ); + printf( "equivalent_mappings %d\n", astEqual( a, e ) ); + printf( "inverted_vs_plain %d\n", astEqual( ainv, a ) ); + printf( "both_inverted %d\n", astEqual( ainv, binv ) ); + printf( "mapping_inverted_after %d\n", astEqual( f, a ) ); + printf( "not_a_ratemap %d\n", astEqual( a, zoom( 2, 2.0 ) ) ); + printf( "mapping_still_inverted %d\n", astGetI( z, "Invert" ) ); + failed(); + } + + /* Splits. */ + { + double s3[] = { 10.0, 20.0, 30.0 }; + head( "split_output_dropped" ); + int in1[] = { 1 }; + split( (AstMapping *) rate( astShiftMap( 3, s3, " " ), 2, 1 ), 1, in1 ); + head( "split_picks_varied_input" ); + split( (AstMapping *) rate( astShiftMap( 3, s3, " " ), 1, 1 ), 1, in1 ); + head( "split_other_input" ); + int in2[] = { 2 }; + split( (AstMapping *) rate( astShiftMap( 3, s3, " " ), 1, 1 ), 1, in2 ); + head( "split_two_inputs" ); + int in31[] = { 3, 1 }; + split( (AstMapping *) rate( astShiftMap( 3, s3, " " ), 1, 1 ), 2, in31 ); + head( "split_inverted" ); + split( inv( (AstMapping *) rate( astShiftMap( 3, s3, " " ), 1, 1 ) ), 1, in1 ); + head( "split_inverted_mapping" ); + split( (AstMapping *) rate( inv( (AstMapping *) astShiftMap( 3, s3, " " ) ), 1, 1 ), 1, in1 ); + } + + /* Constructor and transformation errors. */ + head( "error_no_forward" ); + rate( inv( (AstMapping *) rate( zoom( 1, 2.0 ), 1, 1 ) ), 1, 1 ); + failed(); + head( "error_output_axis" ); + rate( zoom( 2, 2.0 ), 3, 1 ); + failed(); + head( "error_input_axis" ); + rate( zoom( 2, 2.0 ), 1, 3 ); + failed(); + head( "error_output_axis_zero" ); + rate( zoom( 2, 2.0 ), 0, 1 ); + failed(); + head( "error_input_axis_zero" ); + rate( zoom( 2, 2.0 ), 1, 0 ); + failed(); + head( "error_inverse" ); + { + double x = 1.0, y; + astTran1( rate( zoom( 1, 2.0 ), 1, 1 ), 1, &x, 0, &y ); + failed(); + } + head( "error_inverted_forward" ); + { + double x = 1.0, y; + astTran1( inv( (AstMapping *) rate( zoom( 1, 2.0 ), 1, 1 ) ), 1, &x, 1, &y ); + failed(); + } + + astEnd; + return 0; +} diff --git a/src/test/resources/probes/ratemap_probe.out b/src/test/resources/probes/ratemap_probe.out new file mode 100644 index 0000000..7318ab7 --- /dev/null +++ b/src/test/resources/probes/ratemap_probe.out @@ -0,0 +1,873 @@ +== dump_plain + Begin RateMap # Differential Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + IOut = 1 # Index of Mapping output + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End RateMap +-- read back + Begin RateMap # Differential Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + IOut = 1 # Index of Mapping output + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End RateMap +-- transformations +fwd 1.5 2.5 -> 0 +-- transformations read back +fwd 1.5 2.5 -> 0 +== dump_first_axes + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap +-- read back + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap +-- transformations +fwd 1.5 -> 2 +-- transformations read back +fwd 1.5 -> 2 +== dump_inverted_mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Inv = 1 # Mapping used in inverse direction + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap +-- read back + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Inv = 1 # Mapping used in inverse direction + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap +-- transformations +fwd 1.5 -> 0.5 +-- transformations read back +fwd 1.5 -> 0.5 +== dump_mapping_inverted_after + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap +-- read back + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap +-- transformations +fwd 1.5 -> 2 +-- transformations read back +fwd 1.5 -> 2 +== dump_ratemap_inverted + Begin RateMap # Differential Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Invert = 1 # Mapping inverted + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + IIn = 1 # Index of Mapping input + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End RateMap +-- read back + Begin RateMap # Differential Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Invert = 1 # Mapping inverted + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + IIn = 1 # Index of Mapping input + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End RateMap +-- transformations +inv 1.5 2.5 -> 0 +-- transformations read back +inv 1.5 2.5 -> 0 +== dump_lutmap + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements + Start = 1 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + End RateMap +-- read back + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements + Start = 1 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + End RateMap +-- transformations +fwd 2.5 -> 3 +-- transformations read back +fwd 2.5 -> 3 +== dump_mathmap + Begin RateMap # Differential Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + IIn = 1 # Index of Mapping input + IOut = 1 # Index of Mapping output + Map = # Mapping to be differentiated + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "r=x*y" # Forward function 1 + Fwd2 = "s=x+y*y" # Forward function 2 + Inv1 = "x" # Inverse function 1 + Inv2 = "y" # Inverse function 2 + End MathMap + End RateMap +-- read back + Begin RateMap # Differential Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + IIn = 1 # Index of Mapping input + IOut = 1 # Index of Mapping output + Map = # Mapping to be differentiated + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "r=x*y" # Forward function 1 + Fwd2 = "s=x+y*y" # Forward function 2 + Inv1 = "x" # Inverse function 1 + Inv2 = "y" # Inverse function 2 + End MathMap + End RateMap +-- transformations +fwd 1.5 2.5 -> 5 +-- transformations read back +fwd 1.5 2.5 -> 5 +== dump_tranmap + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*x" # Forward function 1 + Inv1 = "x=sqrt(y)" # Inverse function 1 + End MathMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap + End RateMap +-- read back + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*x" # Forward function 1 + Inv1 = "x=sqrt(y)" # Inverse function 1 + End MathMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap + End RateMap +-- transformations +fwd 1.5 -> 3 +-- transformations read back +fwd 1.5 -> 3 +== dump_inverted_tranmap + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Inv = 1 # Mapping used in inverse direction + Map = # Mapping to be differentiated + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*x" # Forward function 1 + Inv1 = "x=sqrt(y)" # Inverse function 1 + End MathMap + End TranMap + End RateMap +-- read back + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Inv = 1 # Mapping used in inverse direction + Map = # Mapping to be differentiated + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*x" # Forward function 1 + Inv1 = "x=sqrt(y)" # Inverse function 1 + End MathMap + End TranMap + End RateMap +-- transformations +fwd 1.5 -> 0.40824829013333336 +-- transformations read back +fwd 1.5 -> 0.40824829013333336 +== simp_plain +class RateMap + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap +-- transformations +fwd 1.5 -> 2 +-- transformations simplified +fwd 1.5 -> 2 +== simp_unitmap +class RateMap + Begin RateMap # Differential Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + IIn = 1 # Index of Mapping input + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap +-- transformations +fwd 1.5 2.5 -> 0 +-- transformations simplified +fwd 1.5 2.5 -> 0 +== simp_interior +class RateMap + Begin RateMap # Differential Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 6 # Zoom factor + End ZoomMap + End RateMap +-- transformations +fwd 1.5 2.5 -> 6 +-- transformations simplified +fwd 1.5 2.5 -> 6 +== simp_interior_inverted_mapping +class RateMap + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 0.125 # Zoom factor + End ZoomMap + End RateMap +-- transformations +fwd 1.5 -> 0.125 +-- transformations simplified +fwd 1.5 -> 0.125 +== simp_interior_mapping_inverted_after +class RateMap + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 8 # Zoom factor + End ZoomMap + End RateMap +-- transformations +fwd 1.5 -> 8 +-- transformations simplified +fwd 1.5 -> 8 +== simp_interior_ratemap_inverted +class RateMap + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Invert = 1 # Mapping inverted + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 8 # Zoom factor + End ZoomMap + End RateMap +-- transformations +inv 1.5 -> 8 +-- transformations simplified +inv 1.5 -> 8 +== simp_interior_in_series +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 5 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 8 # Zoom factor + End ZoomMap + End RateMap + End CmpMap +-- transformations +fwd 1.5 -> 8 +-- transformations simplified +fwd 1.5 -> 8 +== cancel_upper +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +-- transformations simplified +fwd 1.5 -> 1.5 +inv 1.5 -> 1.5 +== cancel_lower +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +-- transformations simplified +fwd 1.5 -> 1.5 +inv 1.5 -> 1.5 +== cancel_two_inputs_upper +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +-- transformations simplified +fwd 1.5 2.5 -> 1.5 2.5 +inv 1.5 2.5 -> 1.5 2.5 +== cancel_two_inputs_lower +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +-- transformations simplified +fwd 1.5 -> 1.5 +inv 1.5 -> 1.5 +== cancel_equivalent_mappings +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +-- transformations simplified +fwd 1.5 -> 1.5 +inv 1.5 -> 1.5 +== cancel_mapping_inverted_after +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +-- transformations simplified +fwd 1.5 -> 1.5 +inv 1.5 -> 1.5 +== no_cancel_axes +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin RateMap # Differential Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Invert = 1 # Mapping inverted + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + IIn = 1 # Index of Mapping input + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap + End CmpMap +-- transformations +-- transformations simplified +== no_cancel_mappings +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End RateMap + End CmpMap +-- transformations +-- transformations simplified +== no_cancel_same_invert +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap + End CmpMap +-- transformations +fwd 1.5 -> 2 +-- transformations simplified +fwd 1.5 -> 2 +== no_cancel_parallel +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap + End CmpMap +-- transformations +-- transformations simplified +== no_cancel_shared +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End RateMap + End CmpMap +-- transformations +fwd 1.5 -> 2 +-- transformations simplified +fwd 1.5 -> 2 +== simp_error +! AST: Error in routine main at line 248 in file ratemap_probe.c. +! astTransform(WcsMap): Required projection parameter PV2_1 was not supplied for a conical equal area projection. +status 233933738 +== rates +rate of ratemap 12.001192284 +ratemap of cube at 2 12 +ratemap of cube at bad -1.7976931348623157e+308 +== equal +same 1 +different_axes 0 +different_mappings 0 +equivalent_mappings 1 +inverted_vs_plain 0 +both_inverted 1 +mapping_inverted_after 1 +not_a_ratemap 0 +mapping_still_inverted 1 +== split_output_dropped +split none +== split_picks_varied_input +outputs 1 + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ShiftMap # Shift each coordinate axis + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 10 # Shift for axis 1 + End ShiftMap + End RateMap +== split_other_input +split none +== split_two_inputs +outputs 1 + Begin RateMap # Differential Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + IIn = 1 # Index of Mapping input + IOut = 1 # Index of Mapping output + Map = # Mapping to be differentiated + Begin ShiftMap # Shift each coordinate axis + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 30 # Shift for axis 1 + Sft2 = 10 # Shift for axis 2 + End ShiftMap + End RateMap +== split_inverted +outputs 1 2 3 + Begin RateMap # Differential Mapping + Nin = 3 # Number of input coordinates + Nout = 1 # Number of output coordinates + Invert = 1 # Mapping inverted + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin ShiftMap # Shift each coordinate axis + Nin = 3 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 10 # Shift for axis 1 + Sft2 = 20 # Shift for axis 2 + Sft3 = 30 # Shift for axis 3 + End ShiftMap + End RateMap +== split_inverted_mapping +outputs 1 + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Inv = 1 # Mapping used in inverse direction + Map = # Mapping to be differentiated + Begin ShiftMap # Shift each coordinate axis + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Sft1 = 10 # Shift for axis 1 + End ShiftMap + End RateMap +== error_no_forward +!! AST: Error in routine rate at line 124 in file ratemap_probe.c. +! astInitRateMap(RateMap): The supplied Mapping is not able to transform coordinates in the forward direction. +status 233933418 +== error_output_axis +!! AST: Error in routine rate at line 124 in file ratemap_probe.c. +! astInitRateMap(RateMap): The output axis 3 is out of range - it should be in the range 1 to 2. +status 233933402 +== error_input_axis +!! AST: Error in routine rate at line 124 in file ratemap_probe.c. +! astInitRateMap(RateMap): The input axis 3 is out of range - it should be in the range 1 to 2. +status 233933402 +== error_output_axis_zero +!! AST: Error in routine rate at line 124 in file ratemap_probe.c. +! astInitRateMap(RateMap): The output axis 0 is out of range - it should be in the range 1 to 2. +status 233933402 +== error_input_axis_zero +!! AST: Error in routine rate at line 124 in file ratemap_probe.c. +! astInitRateMap(RateMap): The input axis 0 is out of range - it should be in the range 1 to 2. +status 233933402 +== error_inverse +!! AST: Error in routine rate at line 124 in file ratemap_probe.c. +! astTran1(RateMap): An inverse coordinate transformation is not defined by the RateMap supplied. +status 233933698 +== error_inverted_forward +!! AST: Error in routine inv at line 119 in file ratemap_probe.c. +! astTran1(RateMap): A forward coordinate transformation is not defined by the RateMap supplied. +status 233933698 diff --git a/src/test/resources/probes/simplify_input_probe.c b/src/test/resources/probes/simplify_input_probe.c new file mode 100644 index 0000000..d5e6a8c --- /dev/null +++ b/src/test/resources/probes/simplify_input_probe.c @@ -0,0 +1,51 @@ +/* simplify_input_probe -- what simplifying a Mapping read from a file does + * to it in the pinned C library: the dump of the Mapping read, of its + * simplification, and of the Mapping read after it was simplified. Run on + * ast_tester/fixtures/simplify/brad.map, whose simplification compares + * CmpMaps that share a WcsMap (cmpmap.c Equal sets the WcsMap's Invert + * attribute to the value the first CmpMap records). + * + * Each case starts with a line "== /", being the name the + * file's row of ast_tester/fixtures/simplify/cases.txt gives it. Built against the C library at + * 3d3f255f with its static libraries: + * cc -I -o simplify_input_probe simplify_input_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 ./simplify_input_probe brad /simplify/brad.map > + * simplify_input_probe.out 2>&1, then trailing white space removed from + * every line. */ +#include +#include +#include +#include "ast.h" + +static FILE *in = NULL; + +static const char *source( void ) { + static char line[ 1000 ]; + if( !fgets( line, sizeof( line ), in ) ) return NULL; + line[ strcspn( line, "\n" ) ] = '\0'; + return line; +} + +int main( int argc, char **argv ) { + int status = 0; + if( argc != 3 || !( in = fopen( argv[ 2 ], "r" ) ) ) return 1; + setvbuf( stdout, NULL, _IONBF, 0 ); + astWatch( &status ); + astBegin; + AstChannel *ch = astChannel( source, NULL, " " ); + AstMapping *m = astRead( ch ); + printf( "== %s/input_before\n", argv[ 1 ] ); + astShow( m ); + AstMapping *s = astSimplify( m ); + printf( "== %s/simplified\n", argv[ 1 ] ); + astShow( s ); + printf( "== %s/input_after\n", argv[ 1 ] ); + astShow( m ); + astEnd; + fclose( in ); + return 0; +} diff --git a/src/test/resources/probes/simplify_input_probe.out b/src/test/resources/probes/simplify_input_probe.out new file mode 100644 index 0000000..6fc5e19 --- /dev/null +++ b/src/test/resources/probes/simplify_input_probe.out @@ -0,0 +1,161 @@ +== brad/input_before + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Sft1 = 0.215698 # Shift for axis 1 + End WinMap + MapB = # Second component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 11 # Number of lookup table elements + Start = 1 # Input value at first element + Incr = 100 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 1.39532005786896 # Lookup table elements... + L2 = 1.5043200254440301 + L3 = 1.61332011222839 + L4 = 1.7223200798034699 + L5 = 1.83132004737854 + L6 = 1.94032001495361 + L7 = 2.0493202209472701 + L8 = 2.1583199501037602 + L9 = 2.2673201560974099 + L10 = 2.3763201236724898 + L11 = 2.4853200912475599 + End LutMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 5.2359877559829903e-06 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin WcsMap # FITS-WCS sky projection + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Type = "TAN" # Gnomonic projection + End WcsMap + End CmpMap + End CmpMap +== brad/simplified + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin WinMap # Map one window on to another + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = -0.215698 # Shift for axis 1 + Scl2 = 5.2359877559829903e-06 # Scale factor for axis 2 + Scl3 = 5.2359877559829903e-06 # Scale factor for axis 3 + End WinMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 11 # Number of lookup table elements + Start = 1 # Input value at first element + Incr = 100 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 1.39532005786896 # Lookup table elements... + L2 = 1.5043200254440301 + L3 = 1.61332011222839 + L4 = 1.7223200798034699 + L5 = 1.83132004737854 + L6 = 1.94032001495361 + L7 = 2.0493202209472701 + L8 = 2.1583199501037602 + L9 = 2.2673201560974099 + L10 = 2.3763201236724898 + L11 = 2.4853200912475599 + End LutMap + MapB = # Second component Mapping + Begin WcsMap # FITS-WCS sky projection + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Type = "TAN" # Gnomonic projection + End WcsMap + End CmpMap + End CmpMap +== brad/input_after + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Sft1 = 0.215698 # Shift for axis 1 + End WinMap + MapB = # Second component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 11 # Number of lookup table elements + Start = 1 # Input value at first element + Incr = 100 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 1.39532005786896 # Lookup table elements... + L2 = 1.5043200254440301 + L3 = 1.61332011222839 + L4 = 1.7223200798034699 + L5 = 1.83132004737854 + L6 = 1.94032001495361 + L7 = 2.0493202209472701 + L8 = 2.1583199501037602 + L9 = 2.2673201560974099 + L10 = 2.3763201236724898 + L11 = 2.4853200912475599 + End LutMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 5.2359877559829903e-06 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin WcsMap # FITS-WCS sky projection + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Type = "TAN" # Gnomonic projection + End WcsMap + End CmpMap + End CmpMap diff --git a/src/test/resources/probes/specflux_probe.c b/src/test/resources/probes/specflux_probe.c new file mode 100644 index 0000000..6237fd7 --- /dev/null +++ b/src/test/resources/probes/specflux_probe.c @@ -0,0 +1,190 @@ +/* specflux_probe -- conversions between SpecFluxFrames in the pinned C + * library: for each pair, the class of the simplified Mapping astConvert + * gives, that Mapping's dump, and the transformation of a point forwards + * and of the result back; astEqual of the SpecFluxFrames of testspecflux.c; + * and conversions between FrameSets whose current Frames are SpecFluxFrames, + * as SPLAT makes them for spectra, in both directions. + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * Built against the C library at 3d3f255f with its static libraries: + * cc -std=c11 -I -o specflux_probe specflux_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 ./specflux_probe > specflux_probe.out 2>&1, then trailing white + * space removed from every line (SpecFluxFrameTest compares lines without + * it). */ +#include +#include +#include +#include "ast.h" + +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; +} + +/* The transformation of the point "in" forwards by "m", and of the result + back. */ +static void tran( AstMapping *m, const double *in ) { + double out[ 4 ], back[ 4 ]; + int nin = astGetI( m, "Nin" ); + int nout = astGetI( m, "Nout" ); + astTranN( m, 1, nin, 1, in, 1, nout, 1, out ); + if( failed() ) return; + printf( "fwd" ); + for( int i = 0; i < nin; i++ ) printf( " %.17g", in[ i ] ); + printf( " ->" ); + for( int i = 0; i < nout; i++ ) printf( " %.17g", out[ i ] ); + printf( "\n" ); + astTranN( m, 1, nout, 1, out, 0, nin, 1, back ); + if( failed() ) return; + printf( "inv" ); + for( int i = 0; i < nout; i++ ) printf( " %.17g", out[ i ] ); + printf( " ->" ); + for( int i = 0; i < nin; i++ ) printf( " %.17g", back[ i ] ); + printf( "\n" ); +} + +/* The conversion from "from" to "to": the class and dump of the simplified + Mapping, then the transformations of the point (x, y) (x alone for a + one-dimensional "from") by the FrameSet astConvert gives, searching + "domains". */ +static void convd( const char *name, void *from, void *to, const char *domains, double x, double y ) { + head( name ); + AstFrameSet *fs = astConvert( from, to, domains ); + if( failed() ) return; + if( !fs ) { + printf( "no conversion\n" ); + return; + } + AstMapping *map = astGetMapping( fs, AST__BASE, AST__CURRENT ); + AstMapping *s = astSimplify( map ); + if( failed() ) return; + printf( "class %s\n", astGetC( s, "Class" ) ); + astShow( s ); + printf( "-- transformations\n" ); + double in[ 2 ] = { x, y }; + tran( (AstMapping *) fs, in ); +} + +static void conv( const char *name, void *from, void *to, double x, double y ) { + convd( name, from, to, " ", x, y ); +} + +static AstSpecFrame *spec( const char *settings ) { + return astSpecFrame( "%s", settings ); +} + +static AstFluxFrame *flux( double specval, AstSpecFrame *sf, const char *settings ) { + return astFluxFrame( specval, sf, "%s", settings ); +} + +/* The probe's SpecFluxFrame: a new SpecFrame and a FluxFrame without one. */ +static AstSpecFluxFrame *sff( const char *sfset, double dsv, const char *ffset ) { + return astSpecFluxFrame( spec( sfset ), flux( dsv, NULL, ffset ), " " ); +} + +/* A FrameSet of a spectrum: a two-dimensional GRID Frame joined to a + SpecFluxFrame by a UnitMap. Converting between two such FrameSets + searches the SPECTRUM-FLUX Domain, which the GRID Frames would otherwise + match first. */ +static AstFrameSet *spectrum( AstSpecFluxFrame *s ) { + AstFrameSet *fs = astFrameSet( astFrame( 2, "Domain=GRID" ), " " ); + astAddFrame( fs, AST__BASE, astUnitMap( 2, " " ), s ); + return fs; +} + +int main( void ) { + setvbuf( stdout, NULL, _IONBF, 0 ); + astBegin; + int perm[ 2 ] = { 2, 1 }; + + /* testspecflux.c. */ + AstSpecFrame *sf = spec( "system=freq,unit=GHz" ); + AstSpecFluxFrame *jy = astSpecFluxFrame( sf, flux( 123.0, sf, "Unit=Jy" ), " " ); + AstSpecFluxFrame *csff = astCopy( jy ); + AstSpecFluxFrame *dnw = astSpecFluxFrame( sf, flux( 123.1, sf, "System=flxdnw" ), " " ); + conv( "error8", jy, dnw, 2.0, 1.0 ); + astPermAxes( dnw, perm ); + conv( "error11", jy, dnw, 2.0, 1.0 ); + astPermAxes( jy, perm ); + conv( "error14", jy, dnw, 1.0, 2.0 ); + AstSpecFluxFrame *logw = astSpecFluxFrame( sf, flux( AST__BAD, NULL, "Unit=log(W/m2/nm)" ), " " ); + conv( "error18", csff, logw, 2.0, 1.0 ); + AstSpecFluxFrame *logsr = astSpecFluxFrame( sf, flux( AST__BAD, NULL, "Unit=log(W/m2/nm/sr)" ), " " ); + AstSpecFrame *sf2 = spec( "system=freq,unit=GHz" ); + AstSpecFluxFrame *jydeg = astSpecFluxFrame( sf2, flux( 123.0, sf2, "Unit=Jy/deg**2" ), " " ); + conv( "error25", jydeg, logsr, 2.0, 1.0 ); + + AstSpecFrame *esf = spec( "system=freq" ); + AstFluxFrame *eff = flux( AST__BAD, NULL, "system=flxdn" ); + AstFluxFrame *eff2 = flux( AST__BAD, NULL, "system=flxdnw" ); + AstSpecFluxFrame *ea = astSpecFluxFrame( esf, eff, " " ); + AstSpecFluxFrame *eb = astSpecFluxFrame( esf, eff, " " ); + AstSpecFluxFrame *ec = astCopy( ea ); + AstSpecFluxFrame *ed = astSpecFluxFrame( esf, eff2, " " ); + head( "equal" ); + printf( "%d %d %d\n", astEqual( ea, eb ), astEqual( ea, ec ), astEqual( ea, ed ) ); + conv( "error32", ed, ea, 1.4e9, 1.0e-26 ); + + /* Rust's test_fluxframe.rs SpecFluxFrame tests. */ + conv( "freq_to_wave", sff( "System=FREQ", AST__BAD, "System=FLXDN" ), + sff( "System=WAVE", AST__BAD, "System=FLXDN" ), 1.4e9, 1.0e-26 ); + AstSpecFrame *g = spec( "system=freq,unit=GHz" ); + conv( "jy_to_fluxdenw", + astSpecFluxFrame( g, flux( AST__BAD, g, "System=FLXDN,Unit=Jy,SpecVal=123.0" ), " " ), + astSpecFluxFrame( g, flux( AST__BAD, g, "System=FLXDNW,SpecVal=123.1" ), " " ), 2.0, 1.0 ); + conv( "log_units", + astSpecFluxFrame( g, flux( AST__BAD, g, "System=FLXDN,Unit=Jy,SpecVal=123.0" ), " " ), + astSpecFluxFrame( g, flux( AST__BAD, g, "System=FLXDNW,Unit=log(W/m2/nm)" ), " " ), 2.0, 1.0 ); + conv( "surface_brightness", + astSpecFluxFrame( g, flux( AST__BAD, g, "System=SFCBR,Unit=Jy/deg**2,SpecVal=123.0" ), " " ), + astSpecFluxFrame( g, flux( AST__BAD, g, "System=SFCBRW,Unit=log(W/m2/nm/sr)" ), " " ), 2.0, 1.0 ); + + /* Other changes of one component. */ + AstSpecFluxFrame *s = sff( "System=FREQ,Unit=GHz", 1.4e9, "System=FLXDN,Unit=Jy" ); + conv( "jy_to_mjy", s, sff( "System=FREQ,Unit=GHz", 1.4e9, "System=FLXDN,Unit=mJy" ), 2.0, 1.0 ); + conv( "ghz_to_mhz", s, sff( "System=FREQ,Unit=MHz", 1.4e9, "System=FLXDN,Unit=Jy" ), 2.0, 1.0 ); + conv( "flux_domains", sff( "System=FREQ", AST__BAD, "System=FLXDN,Domain=A" ), + sff( "System=FREQ", AST__BAD, "System=FLXDN,Domain=B" ), 1.4e9, 1.0e-26 ); + AstSpecFluxFrame *lg = sff( "System=FREQ,Unit=GHz", 1.4e9, "System=FLXDN,Unit=log(Jy)" ); + conv( "jy_to_log_jy", s, lg, 2.0, 1.0 ); + conv( "log_jy_to_jy", lg, s, 2.0, 0.0 ); + + /* A FluxFrame in another System and a SpecFluxFrame. */ + AstFluxFrame *fw = flux( AST__BAD, spec( "" ), "System=FLXDNW" ); + AstSpecFluxFrame *sd = astSpecFluxFrame( spec( "" ), flux( AST__BAD, spec( "" ), "" ), " " ); + conv( "fluxframe_to_specfluxframe", fw, sd, 2.0, 0.0 ); + conv( "specfluxframe_to_fluxframe", sd, fw, 5000.0, 2.0 ); + + /* Spectra as SPLAT holds them: frequency in GHz and Jy, wavelength in nm + and mJy, radio velocity and W/m^2/Hz. */ + AstSpecFluxFrame *fa = sff( "System=FREQ,Unit=GHz,RestFreq=1.4GHz", AST__BAD, "System=FLXDN,Unit=Jy" ); + AstSpecFluxFrame *fb = sff( "System=WAVE,Unit=nm,RestFreq=1.4GHz", AST__BAD, "System=FLXDN,Unit=mJy" ); + AstSpecFluxFrame *fc = sff( "System=VRAD,RestFreq=1.4GHz", AST__BAD, "System=FLXDN,Unit=W/m^2/Hz" ); + AstSpecFluxFrame *fd = sff( "System=WAVE,Unit=nm,RestFreq=1.4GHz", AST__BAD, "System=FLXDNW,Unit=W/m^2/nm" ); + AstFrameSet *sa = spectrum( fa ); + AstFrameSet *sb = spectrum( fb ); + AstFrameSet *sc = spectrum( fc ); + AstFrameSet *sd2 = spectrum( fd ); + convd( "splat_freq_jy_to_wave_mjy", sa, sb, "SPECTRUM-FLUX", 1.3, 2.0 ); + convd( "splat_wave_mjy_to_freq_jy", sb, sa, "SPECTRUM-FLUX", 2.3e8, 2000.0 ); + convd( "splat_freq_jy_to_vrad", sa, sc, "SPECTRUM-FLUX", 1.3, 2.0 ); + convd( "splat_vrad_to_freq_jy", sc, sa, "SPECTRUM-FLUX", 1500.0, 2.0e-26 ); + convd( "splat_freq_jy_to_wave_flxdnw", sa, sd2, "SPECTRUM-FLUX", 1.3, 2.0 ); + convd( "splat_wave_flxdnw_to_freq_jy", sd2, sa, "SPECTRUM-FLUX", 2.3e8, 1.0e-30 ); + + astEnd; + return 0; +} diff --git a/src/test/resources/probes/specflux_probe.out b/src/test/resources/probes/specflux_probe.out new file mode 100644 index 0000000..5ed987c --- /dev/null +++ b/src/test/resources/probes/specflux_probe.out @@ -0,0 +1,7236 @@ +== error8 +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1.0000000000000002e-26 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 9.9999999999999988e+25 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-09 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 2 1 -> 2 1.3342563766379042e-26 +inv 2 1.3342563766379042e-26 -> 2 1 +== error11 +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1.0000000000000002e-26 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 9.9999999999999988e+25 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-09 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 2 1 -> 1.3342563766379042e-26 2 +inv 1.3342563766379042e-26 2 -> 2 1 +== error14 +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1.0000000000000002e-26 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 9.9999999999999988e+25 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-09 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 1 2 -> 1.3342563766379042e-26 2 +inv 1.3342563766379042e-26 2 -> 1 2 +== error18 +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1.0000000000000002e-26 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 9.9999999999999988e+25 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=0.099999999999999992*exp(2.3025850929940459*input_units)" # Forward function 1 + Inv1 = "input_units=log10(10*output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-09 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 2 1 -> 2 -24.874760712952302 +inv 2 -24.874760712952302 -> 2 0.999999999999994 +== error25 +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 2.7777777777777779e-30 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 3.5999999999999998e+29 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=8.4615949940752377e-09*exp(2.3025850929940459*input_units)" # Forward function 1 + Inv1 = "input_units=log10(118181028.6004228*output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-09 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 2 1 -> 2 -21.358515448133957 +inv 2 -21.358515448133957 -> 2 0.99999999999999634 +== equal +1 1 0 +== error32 +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 999999999.99999988 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + End CmpMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + End CmpMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + End TranMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1 # Forward matrix value + M1 = 1.0000000000000001e-09 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 1 # Inverse matrix value + IM1 = 999999999.99999988 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 1400000000 1e-26 -> 1400000000 1.5295533546339402e-44 +inv 1400000000 1.5295533546339402e-44 -> 1400000000 1e-26 +== freq_to_wave +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 1 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 999999999.99999988 # Zoom factor + End ZoomMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + End CmpMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 1400000000 1e-26 -> 2.1413747000000005 1e-26 +inv 2.1413747000000005 1e-26 -> 1399999999.9999998 1e-26 +== jy_to_fluxdenw +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1.0000000000000002e-26 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 9.9999999999999988e+25 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-09 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 2 1 -> 2 1.3342563766379042e-26 +inv 2 1.3342563766379042e-26 -> 2 1 +== log_units +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1.0000000000000002e-26 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 9.9999999999999988e+25 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=0.099999999999999992*exp(2.3025850929940459*input_units)" # Forward function 1 + Inv1 = "input_units=log10(10*output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-09 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 2 1 -> 2 -24.874760712952302 +inv 2 -24.874760712952302 -> 2 0.999999999999994 +== surface_brightness +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 2.7777777777777779e-30 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 3.5999999999999998e+29 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=8.4615949940752377e-09*exp(2.3025850929940459*input_units)" # Forward function 1 + Inv1 = "input_units=log10(118181028.6004228*output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-09 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 2 1 -> 2 -21.358515448133957 +inv 2 -21.358515448133957 -> 2 0.99999999999999634 +== jy_to_mjy +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1.0000000000000002e-26 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 9.9999999999999988e+25 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 9.9999999999999991e+28 # Forward matrix value + M1 = 1.0000000000000001e-09 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 1.0000000000000001e-29 # Inverse matrix value + IM1 = 999999999.99999988 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 2 1 -> 2 1000.0000000000001 +inv 2 1000.0000000000001 -> 2 1 +== ghz_to_mhz +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1.0000000000000002e-26 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 9.9999999999999988e+25 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 999.99999999999989 # Zoom factor + End ZoomMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 9.9999999999999988e+25 # Forward matrix value + M1 = 9.9999999999999995e-07 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 1.0000000000000002e-26 # Inverse matrix value + IM1 = 1000000 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 2 1 -> 1999.9999999999998 1 +inv 1999.9999999999998 1 -> 1.9999999999999998 1 +== flux_domains +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 1 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1 # Forward matrix value + M1 = 1.0000000000000001e-09 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 1 # Inverse matrix value + IM1 = 999999999.99999988 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 1400000000 1e-26 -> 1400000000 1e-26 +inv 1400000000 1e-26 -> 1400000000 1e-26 +== jy_to_log_jy +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1.0000000000000002e-26 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 9.9999999999999988e+25 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=1.0000000000000002e-26*exp(2.3025850929940459*input_units)" # Forward function 1 + Inv1 = "input_units=log10(9.9999999999999988e+25*output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin MatrixMap # Matrix transformation + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + M0 = 1.0000000000000001e-09 # Forward matrix value + M1 = 1 # Forward matrix value + IM0 = 999999999.99999988 # Inverse matrix value + IM1 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 2 1 -> 2 0 +inv 2 0 -> 2 1 +== log_jy_to_jy +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "output_units=1.0000000000000002e-26*exp(2.3025850929940459*input_units)" # Forward function 1 + Inv1 = "input_units=log10(9.9999999999999988e+25*output_units)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap + MapB = # Second component Mapping + Begin MatrixMap # Matrix transformation + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + M0 = 999999999.99999988 # Forward matrix value + M1 = 1 # Forward matrix value + IM0 = 1.0000000000000001e-09 # Inverse matrix value + IM1 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 9.9999999999999988e+25 # Forward matrix value + M1 = 1.0000000000000001e-09 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 1.0000000000000002e-26 # Inverse matrix value + IM1 = 999999999.99999988 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 2 0 -> 2 1 +inv 2 1 -> 2 0 +== fluxframe_to_specfluxframe +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 1 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + OutCpy = 1 # Output coordinates = input coordinates + InCpy = 1 # Input coordinates = output coordinates + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Invert = 1 # Mapping inverted + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap +-- transformations +fwd 2 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv -1.7976931348623157e+308 -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== specfluxframe_to_fluxframe +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + End TranMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + OutCpy = 1 # Output coordinates = input coordinates + InCpy = 1 # Input coordinates = output coordinates + End PermMap + End CmpMap + End CmpMap +-- transformations +fwd 5000 2 -> 239833965686.78632 +inv 239833965686.78632 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +== splat_freq_jy_to_wave_mjy +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1.0000000000000002e-26 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 9.9999999999999988e+25 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 999999999.99999988 # Zoom factor + End ZoomMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 9.9999999999999991e+28 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + End CmpMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 999999999.99999988 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 1.3 2 -> 230609583.07692307 2000.0000000000002 +inv 230609583.07692307 2000.0000000000002 -> 1.3 2 +== splat_wave_mjy_to_freq_jy +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-29 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-09 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + End CmpMap + End TranMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-09 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-09 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 9.9999999999999988e+25 # Forward matrix value + M1 = 1.0000000000000001e-09 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 1.0000000000000002e-26 # Inverse matrix value + IM1 = 999999999.99999988 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 230000000 2000 -> 1.3034454695652173 1.9999999999999998 +inv 1.3034454695652173 1.9999999999999998 -> 229999999.99999997 2000 +== splat_freq_jy_to_vrad +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1.0000000000000002e-26 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 9.9999999999999988e+25 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 999999999.99999988 # Zoom factor + End ZoomMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 2 # Number of conversion steps + Spec1 = "FRTOVL" # Convert frequency to rel. velocity + Spec1a = 1399999999.9999998 # Rest frequency (Hz) + Spec2 = "VLTOVR" # Convert relativistic to radio velocity + End SpecMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 2 # Number of conversion steps + Spec1 = "FRTOVL" # Convert frequency to rel. velocity + Spec1a = 1399999999.9999998 # Rest frequency (Hz) + Spec2 = "VLTOVR" # Convert relativistic to radio velocity + End SpecMap + End CmpMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 0.001 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 1.3 2 -> 21413.746999999927 2.0000000000000004e-26 +inv 21413.746999999927 2.0000000000000004e-26 -> 1.3000000000000003 2 +== splat_vrad_to_freq_jy +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1000 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 2 # Number of conversion steps + Spec1 = "VRTOVL" # Convert radio to rel. velocity + Spec2 = "VLTOFR" # Convert rel. velocity to frequency + Spec2a = 1399999999.9999998 # Rest frequency (Hz) + End SpecMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + End UnitMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + End CmpMap + End TranMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1000 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 2 # Number of conversion steps + Spec1 = "VRTOVL" # Convert radio to rel. velocity + Spec2 = "VLTOFR" # Convert rel. velocity to frequency + Spec2a = 1399999999.9999998 # Rest frequency (Hz) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-09 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 9.9999999999999988e+25 # Forward matrix value + M1 = 1.0000000000000001e-09 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 1.0000000000000002e-26 # Inverse matrix value + IM1 = 999999999.99999988 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 1500 2.0000000000000001e-26 -> 1.3929951540008385 1.9999999999999998 +inv 1.3929951540008385 1.9999999999999998 -> 1500.0000000000589 2.0000000000000001e-26 +== splat_freq_jy_to_wave_flxdnw +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 1.0000000000000002e-26 # Forward matrix value + M1 = 999999999.99999988 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 9.9999999999999988e+25 # Inverse matrix value + IM1 = 1.0000000000000001e-09 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 10000000000 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 999999999.99999988 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "FRTOWV" # Convert frequency to wavelength (vacuum) + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 999999999.99999988 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 10.000000000000002 # Forward matrix value + M1 = 0.10000000000000001 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 0.099999999999999978 # Inverse matrix value + IM1 = 10 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 1.3 2 -> 230609583.07692307 1.1274466432273262e-25 +inv 230609583.07692307 1.1274466432273262e-25 -> 1.3 2 +== splat_wave_flxdnw_to_freq_jy +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + Out3 = 1 # Output coordinate 3 = input coordinate 1 + In1 = 3 # Input coordinate 1 = output coordinate 3 + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 0.099999999999999978 # Forward matrix value + M1 = 10 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 10.000000000000002 # Inverse matrix value + IM1 = 0.10000000000000001 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 2 # Output coordinate 2 = input coordinate 2 + Out3 = 2 # Output coordinate 3 = input coordinate 2 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 3 # Input coordinate 2 = output coordinate 3 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + End CmpMap + End RateMap + End CmpMap + MapB = # Second component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0/abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Mapping for inverse transformation + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 3 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "out=in0*abs(in1)" # Forward function 1 + Inv1 = "in0" # Inverse function 1 + Inv2 = "in1" # Inverse function 2 + End MathMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin RateMap # Differential Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + Map = # Mapping to be differentiated + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + End CmpMap + End RateMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = 3 # Output coordinate 2 = input coordinate 3 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = 2 # Input coordinate 2 = output coordinate 2 + In3 = 2 # Input coordinate 3 = output coordinate 2 + End PermMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1e-10 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap + End TranMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-09 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SpecMap # Conversion between spectral coordinate systems + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nspec = 1 # Number of conversion steps + Spec1 = "WVTOFR" # Convert wavelength (vacuum) to frequency + End SpecMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 1.0000000000000001e-09 # Zoom factor + End ZoomMap + End CmpMap + End CmpMap + End CmpMap + MapB = # Second component Mapping + Begin CmpMap # Compound Mapping + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin MatrixMap # Matrix transformation + Nin = 3 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + M0 = 9.9999999999999988e+25 # Forward matrix value + M1 = 1.0000000000000001e-09 # Forward matrix value + M2 = 1 # Forward matrix value + IM0 = 1.0000000000000002e-26 # Inverse matrix value + IM1 = 999999999.99999988 # Inverse matrix value + IM2 = 1 # Inverse matrix value + Form = "Diagonal" # Matrix storage form + End MatrixMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 3 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 3 # Output coordinate 1 = input coordinate 3 + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + In2 = 1 # Input coordinate 2 = output coordinate 1 + In3 = 1 # Input coordinate 3 = output coordinate 1 + End PermMap + End CmpMap + End CmpMap + End CmpMap + End CmpMap +-- transformations +fwd 230000000 1.0000000000000001e-30 -> 1.3034454695652173 1.7645540521508111e-05 +inv 1.3034454695652173 1.7645540521508111e-05 -> 229999999.99999997 1.0000000000000001e-30 diff --git a/src/test/resources/probes/switchmap_probe.c b/src/test/resources/probes/switchmap_probe.c new file mode 100644 index 0000000..d86601f --- /dev/null +++ b/src/test/resources/probes/switchmap_probe.c @@ -0,0 +1,551 @@ +/* switchmap_probe -- SwitchMap behaviour of the pinned C library that no + * fixture or oracle holds: the route a selector value picks, in range, + * at the halfway points and beyond the range of int; transformations and + * rates of the SwitchMaps of testswitchmap.c sections 1 and 2 at full + * precision; native dumps with selectors and routes inverted at + * construction and afterwards, one Mapping as both selectors, LutMap, + * MathMap and PcdMap components, a SwitchMap inside a CmpMap and a + * TranMap, and one whose inverse selector changes on the way (C writes + * ISInv only when set and reads its absence as FSInv), each read back + * through a Channel; astEqual; simplification of a SwitchMap alone, + * inverted, with route and selector Mappings that simplify, beside its + * own inverse and other Mappings; and the constructor's errors. + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * Built against the C library at 3d3f255f with its static libraries: + * cc -std=c11 -I -o switchmap_probe switchmap_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 ./switchmap_probe > switchmap_probe.out 2>&1, then trailing + * white space removed from every line (the tests compare lines without + * it). */ +#include +#include +#include +#include +#include +#include "ast.h" + +/* The lines a Channel writes, which a second Channel reads back. */ +#define MAXLINES 800 +static char *lines[ MAXLINES ]; +static int nline = 0; +static int iline = 0; + +static void sink( const char *line ) { + if( nline < MAXLINES ) lines[ nline++ ] = strcpy( malloc( strlen( line ) + 1 ), line ); +} + +static const char *source( void ) { + return ( iline < nline ) ? lines[ iline++ ] : NULL; +} + +static void clear_lines( void ) { + for( int i = 0; i < nline; i++ ) free( lines[ i ] ); + nline = iline = 0; +} + +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 *inv( void *m ) { + astInvert( m ); + return m; +} + +static AstWinMap *win( double x1, double x2, double l1, double l2 ) { + return astWinMap( 1, &x1, &x2, &l1, &l2, " " ); +} + +static AstMathMap *mathmap( const char *f, const char *i ) { + const char *fwd[] = { f }; + const char *invf[] = { i }; + return astMathMap( 1, 1, 1, fwd, 1, invf, " " ); +} + +/* The points every transformation is given, on each input. */ +#define NPT 5 +static const double pts1[ NPT ] = { 1.0, 37.5, 101.0, 140.0, AST__BAD }; +static const double pts2[ NPT ] = { 1.0, 2.0, 2.0, 1.0, 1.0 }; +static const double wave[ NPT ] = { 1000.0, 1700.0, 1900.0, 2700.0, AST__BAD }; + +/* The forward and inverse transformations of the points. Positions with + one coordinate are given pts1 forward and wave inverse; positions with + two are given pts1 and pts2. */ +static void tran( AstMapping *m ) { + double in[ 2 ][ NPT ], out[ 2 ][ NPT ]; + for( int dir = 1; dir >= 0; dir-- ) { + if( !astGetL( m, dir ? "TranForward" : "TranInverse" ) ) { + printf( "%s undefined\n", dir ? "fwd" : "inv" ); + continue; + } + int nin = astGetI( m, dir ? "Nin" : "Nout" ); + int nout = astGetI( m, dir ? "Nout" : "Nin" ); + for( int i = 0; i < NPT; i++ ) { + if( nin == 1 ) { + in[ 0 ][ i ] = dir ? pts1[ i ] : wave[ i ]; + } else { + in[ 0 ][ i ] = pts1[ i ]; + in[ 1 ][ i ] = pts2[ i ]; + } + } + astTranN( m, NPT, nin, NPT, (const double *) in, dir, nout, NPT, (double *) out ); + if( failed() ) return; + for( int i = 0; i < NPT; i++ ) { + printf( "%s", dir ? "fwd" : "inv" ); + for( int k = 0; k < nin; k++ ) printf( " %.17g", in[ k ][ i ] ); + printf( " ->" ); + for( int k = 0; k < nout; k++ ) printf( " %.17g", out[ k ][ i ] ); + printf( "\n" ); + } + } +} + +/* The dump, the Object read back from it through a Channel and that + Object's dump, whether the two are equal, then the transformations of + both. */ +static void roundtrip( const char *name, AstMapping *m ) { + head( name ); + astShow( m ); + clear_lines(); + AstChannel *ch = astChannel( source, sink, " " ); + astWrite( ch, m ); + AstMapping *back = astRead( ch ); + if( failed() ) return; + printf( "-- read back\n" ); + astShow( back ); + printf( "-- equal %d\n", astEqual( m, back ) ); + printf( "-- transformations\n" ); + tran( m ); + printf( "-- transformations read back\n" ); + tran( back ); + ch = astAnnul( ch ); +} + +/* The class of the simplified Mapping, its dump, and the transformations + of the original and the simplified Mapping. */ +static void simp( const char *name, AstMapping *m ) { + head( name ); + AstMapping *s = astSimplify( m ); + if( failed() ) return; + printf( "class %s\n", astGetC( s, "Class" ) ); + astShow( s ); + printf( "-- transformations\n" ); + tran( m ); + printf( "-- transformations simplified\n" ); + tran( s ); +} + +/* testswitchmap.c section 1: two rows of a 2-D grid, each a spectrum; a + PermMap forward selector reading the row number and a MathMap inverse + selector choosing a row by wavelength. */ +static AstSwitchMap *section1( void ) { + AstMapping *rm[ 2 ]; + int outperm[ 1 ] = { 1 }; + int inperm[ 2 ] = { 1, -1 }; + double con = 1.0; + AstPermMap *pm1 = astPermMap( 2, inperm, 1, outperm, &con, " " ); + rm[ 0 ] = (AstMapping *) astCmpMap( pm1, win( 1.0, 101.0, 1000.0, 2000.0 ), 1, " " ); + con = 2.0; + AstPermMap *pm2 = astPermMap( 2, inperm, 1, outperm, &con, " " ); + rm[ 1 ] = (AstMapping *) astCmpMap( pm2, win( 1.0, 101.0, 1600.0, 2700.0 ), 1, " " ); + int fsout[ 1 ] = { 2 }; + int fsin[ 2 ] = { 0, 1 }; + con = 0.0; + AstPermMap *fs = astPermMap( 2, fsin, 1, fsout, &con, " " ); + AstMathMap *is = mathmap( "y", "x=qif(y>1800,2,1)" ); + return astSwitchMap( fs, is, 2, (void **) rm, " " ); +} + +/* testswitchmap.c section 2: two halves of a 1-D grid, with one MathMap + as both selectors. */ +static AstSwitchMap *section2( AstMathMap **sel ) { + AstMapping *rm[ 2 ]; + rm[ 0 ] = (AstMapping *) win( 1.0, 101.0, 1000.0, 2000.0 ); + rm[ 1 ] = (AstMapping *) win( 102.0, 202.0, 1600.0, 2700.0 ); + AstMathMap *sm = mathmap( "y=qif(x>101.5,2,1)", "x=qif(y>1800,2,1)" ); + if( sel ) *sel = sm; + return astSwitchMap( sm, sm, 2, (void **) rm, " " ); +} + +/* A 1-D SwitchMap whose selectors are both the identity, so that the + value given picks the route, with routes multiplying by 2 and 3. */ +static AstSwitchMap *identity_selected( void ) { + AstMapping *rm[ 2 ]; + rm[ 0 ] = (AstMapping *) astZoomMap( 1, 2.0, " " ); + rm[ 1 ] = (AstMapping *) astZoomMap( 1, 3.0, " " ); + return astSwitchMap( astUnitMap( 1, " " ), astUnitMap( 1, " " ), 2, (void **) rm, " " ); +} + +/* A 1-D SwitchMap with the given selectors and routes. */ +static AstSwitchMap *switch2( void *fs, void *is, void *r1, void *r2 ) { + AstMapping *rm[ 2 ] = { r1, r2 }; + return astSwitchMap( fs, is, 2, (void **) rm, " " ); +} + +/* The MathMap selector of section 2. */ +static AstMathMap *halves( void ) { + return mathmap( "y=qif(x>101.5,2,1)", "x=qif(y>1800,2,1)" ); +} + +/* The plain 1-D SwitchMap many cases use. */ +static AstSwitchMap *plain( void ) { + return switch2( halves(), halves(), win( 1.0, 101.0, 1000.0, 2000.0 ), win( 102.0, 202.0, 1600.0, 2700.0 ) ); +} + +static double table[] = { 1000.0, 1100.0, 1300.0, 1600.0, 2000.0 }; + +int main( void ) { + int status = 0; + setvbuf( stdout, NULL, _IONBF, 0 ); + astWatch( &status ); + astBegin; + + /* The route each selector value picks: the input is the selector + value, and route 1 doubles it, route 2 triples it. */ + head( "selector_values" ); + { + AstSwitchMap *sw = identity_selected(); + double v[] = { -1.0e30, -2147483649.0, -0.5, 0.0, 0.49, 0.49999999999999994, 0.5, + 1.4999999999999998, 1.5, 2.25, 2.4999999999999996, 2.5, 3.0, + 2147483647.0, 2147483648.5, 4294967297.0, 4294967298.0, 1.0e30, + -DBL_MAX, DBL_MAX, AST__BAD }; + int n = sizeof( v ) / sizeof( v[ 0 ] ); + double f[ 32 ], i[ 32 ]; + astTran1( sw, n, v, 1, f ); + astTran1( sw, n, v, 0, i ); + for( int k = 0; k < n; k++ ) { + double r = astRate( sw, &v[ k ], 1, 1 ); + printf( "%.17g fwd %.17g inv %.17g rate %.17g\n", v[ k ], f[ k ], i[ k ], r ); + } + failed(); + } + + /* testswitchmap.c section 1 and 2, inverted as C's test inverts them, + then not inverted, with their rates. */ + head( "section1" ); + { + AstSwitchMap *sw = section1(); + tran( (AstMapping *) sw ); + astInvert( sw ); + printf( "-- inverted\n" ); + tran( (AstMapping *) sw ); + astInvert( sw ); + double at[ 2 ] = { 20.0, 1.0 }; + printf( "rate 20 1: %.17g\n", astRate( sw, at, 1, 1 ) ); + at[ 1 ] = 2.0; + printf( "rate 20 2: %.17g\n", astRate( sw, at, 1, 1 ) ); + printf( "rate 20 2 axis 2: %.17g\n", astRate( sw, at, 1, 2 ) ); + astInvert( sw ); + double w = 1700.0; + printf( "rate inverted 1700: %.17g\n", astRate( sw, &w, 1, 1 ) ); + w = 1900.0; + printf( "rate inverted 1900: %.17g\n", astRate( sw, &w, 1, 2 ) ); + failed(); + } + head( "section2" ); + { + AstMathMap *sm; + AstSwitchMap *sw = section2( &sm ); + astInvert( sm ); + tran( (AstMapping *) sw ); + astInvert( sw ); + printf( "-- inverted\n" ); + tran( (AstMapping *) sw ); + astInvert( sw ); + double x = 20.0; + printf( "rate 20: %.17g\n", astRate( sw, &x, 1, 1 ) ); + x = 120.0; + printf( "rate 120: %.17g\n", astRate( sw, &x, 1, 1 ) ); + x = 300.0; + printf( "rate 300: %.17g\n", astRate( sw, &x, 1, 1 ) ); + astInvert( sw ); + x = 1700.0; + printf( "rate inverted 1700: %.17g\n", astRate( sw, &x, 1, 1 ) ); + x = 1900.0; + printf( "rate inverted 1900: %.17g\n", astRate( sw, &x, 1, 1 ) ); + failed(); + } + head( "forward_only" ); + { + AstSwitchMap *sw = switch2( halves(), NULL, win( 1.0, 101.0, 1000.0, 2000.0 ), + win( 102.0, 202.0, 1600.0, 2700.0 ) ); + printf( "TranForward %d TranInverse %d\n", astGetI( sw, "TranForward" ), astGetI( sw, "TranInverse" ) ); + tran( (AstMapping *) sw ); + double x = 20.0; + printf( "rate 20: %.17g\n", astRate( sw, &x, 1, 1 ) ); + astInvert( sw ); + printf( "inverted TranForward %d TranInverse %d\n", astGetI( sw, "TranForward" ), + astGetI( sw, "TranInverse" ) ); + x = 1700.0; + printf( "rate inverted 1700: %.17g\n", astRate( sw, &x, 1, 1 ) ); + failed(); + } + head( "inverted_routes" ); + { + AstSwitchMap *sw = switch2( halves(), halves(), inv( win( 1000.0, 2000.0, 1.0, 101.0 ) ), + inv( win( 1600.0, 2700.0, 102.0, 202.0 ) ) ); + tran( (AstMapping *) sw ); + double x = 20.0; + printf( "rate 20: %.17g\n", astRate( sw, &x, 1, 1 ) ); + astInvert( sw ); + x = 1900.0; + printf( "rate inverted 1900: %.17g\n", astRate( sw, &x, 1, 1 ) ); + failed(); + } + head( "components_inverted_after" ); + { + AstMathMap *fs = halves(); + AstMathMap *is = halves(); + AstWinMap *r1 = win( 1.0, 101.0, 1000.0, 2000.0 ); + AstWinMap *r2 = win( 102.0, 202.0, 1600.0, 2700.0 ); + AstSwitchMap *sw = switch2( fs, is, r1, r2 ); + astInvert( fs ); + astInvert( is ); + astInvert( r1 ); + tran( (AstMapping *) sw ); + printf( "Invert fs %d is %d r1 %d r2 %d\n", astGetI( fs, "Invert" ), astGetI( is, "Invert" ), + astGetI( r1, "Invert" ), astGetI( r2, "Invert" ) ); + failed(); + } + + /* Native dumps and read back. */ + roundtrip( "dump_section1", (AstMapping *) section1() ); + { + AstMathMap *sm; + AstSwitchMap *sw = section2( &sm ); + astInvert( sm ); + roundtrip( "dump_section2", (AstMapping *) sw ); + } + roundtrip( "dump_inverted", inv( plain() ) ); + roundtrip( "dump_forward_only", + (AstMapping *) switch2( halves(), NULL, win( 1.0, 101.0, 1000.0, 2000.0 ), + win( 102.0, 202.0, 1600.0, 2700.0 ) ) ); + roundtrip( "dump_inverse_only", + (AstMapping *) switch2( NULL, halves(), win( 1.0, 101.0, 1000.0, 2000.0 ), + win( 102.0, 202.0, 1600.0, 2700.0 ) ) ); + roundtrip( "dump_inverted_at_construction", + (AstMapping *) switch2( inv( halves() ), inv( halves() ), inv( win( 1000.0, 2000.0, 1.0, 101.0 ) ), + win( 102.0, 202.0, 1600.0, 2700.0 ) ) ); + { + AstMathMap *fs = halves(); + AstWinMap *r2 = win( 102.0, 202.0, 1600.0, 2700.0 ); + AstSwitchMap *sw = switch2( fs, halves(), win( 1.0, 101.0, 1000.0, 2000.0 ), r2 ); + astInvert( fs ); + astInvert( r2 ); + roundtrip( "dump_inverted_after", (AstMapping *) sw ); + } + { + AstLutMap *lut = astLutMap( 5, table, 1.0, 25.0, " " ); + AstMathMap *mm = mathmap( "y = x * 10 + 990", "x = ( y - 990 ) / 10" ); + roundtrip( "dump_lutmap_mathmap", (AstMapping *) switch2( halves(), halves(), lut, mm ) ); + } + { + double cen[ 2 ] = { 1.0, 1.5 }; + int fsin[ 2 ] = { 0, 1 }, fsout[ 1 ] = { 2 }; + double con = 0.0; + AstPermMap *fs = astPermMap( 2, fsin, 1, fsout, &con, " " ); + AstPcdMap *pcd = astPcdMap( 1.0e-3, cen, " " ); + AstZoomMap *z = astZoomMap( 2, 2.0, " " ); + roundtrip( "dump_pcdmap", (AstMapping *) switch2( fs, NULL, pcd, z ) ); + } + roundtrip( "dump_in_cmpmap", + (AstMapping *) astCmpMap( astZoomMap( 1, 2.0, " " ), plain(), 1, " " ) ); + roundtrip( "dump_in_tranmap", + (AstMapping *) astTranMap( plain(), inv( plain() ), " " ) ); + { + AstMapping *rm[ 1 ] = { (AstMapping *) plain() }; + roundtrip( "dump_in_switchmap", (AstMapping *) astSwitchMap( astUnitMap( 1, " " ), NULL, 1, (void **) rm, " " ) ); + } + + /* A SwitchMap whose forward selector was inverted when it was made and + whose inverse selector was not: Dump writes ISInv only when it is + set, and the loader takes an absent ISInv to be FSInv, so the + SwitchMap read back applies its inverse selector inverted and its + inverse transformation changes. */ + roundtrip( "dump_fsinv_set_isinv_unset", + (AstMapping *) switch2( inv( halves() ), halves(), win( 1.0, 101.0, 1000.0, 2000.0 ), + win( 102.0, 202.0, 1600.0, 2700.0 ) ) ); + + /* Equality. */ + head( "equal" ); + { + AstSwitchMap *a = plain(); + AstSwitchMap *b = plain(); + printf( "same_contents %d\n", astEqual( a, b ) ); + AstSwitchMap *c = switch2( halves(), halves(), win( 1.0, 101.0, 1000.0, 2000.0 ), + win( 102.0, 202.0, 1600.0, 2800.0 ) ); + printf( "different_route %d\n", astEqual( a, c ) ); + AstSwitchMap *d = switch2( halves(), NULL, win( 1.0, 101.0, 1000.0, 2000.0 ), + win( 102.0, 202.0, 1600.0, 2700.0 ) ); + printf( "missing_inverse_selector %d\n", astEqual( a, d ) ); + printf( "missing_inverse_selector_reversed %d\n", astEqual( d, a ) ); + AstSwitchMap *e = switch2( halves(), NULL, win( 1.0, 101.0, 1000.0, 2000.0 ), + win( 102.0, 202.0, 1600.0, 2700.0 ) ); + printf( "both_forward_only %d\n", astEqual( d, e ) ); + AstMapping *rm3[ 3 ] = { (AstMapping *) win( 1.0, 101.0, 1000.0, 2000.0 ), + (AstMapping *) win( 102.0, 202.0, 1600.0, 2700.0 ), + (AstMapping *) win( 102.0, 202.0, 1600.0, 2700.0 ) }; + AstSwitchMap *f = astSwitchMap( halves(), halves(), 3, (void **) rm3, " " ); + printf( "three_routes %d\n", astEqual( a, f ) ); + AstSwitchMap *ainv = astCopy( a ); + astInvert( ainv ); + printf( "inverted_vs_plain %d\n", astEqual( ainv, a ) ); + AstSwitchMap *n = (AstSwitchMap *) astSimplify( ainv ); + printf( "inverted_vs_normalised %d\n", astEqual( ainv, n ) ); + printf( "normalised_vs_inverted %d\n", astEqual( n, ainv ) ); + AstSwitchMap *g = switch2( halves(), halves(), inv( win( 1000.0, 2000.0, 1.0, 101.0 ) ), + win( 102.0, 202.0, 1600.0, 2700.0 ) ); + printf( "route_inverted_equivalent %d\n", astEqual( a, g ) ); + AstMathMap *fs = halves(); + AstSwitchMap *h = switch2( fs, halves(), win( 1.0, 101.0, 1000.0, 2000.0 ), + win( 102.0, 202.0, 1600.0, 2700.0 ) ); + astInvert( fs ); + printf( "selector_inverted_after %d\n", astEqual( a, h ) ); + printf( "Invert fs after %d\n", astGetI( fs, "Invert" ) ); + AstMathMap *sm; + AstSwitchMap *s2a = section2( &sm ); + AstSwitchMap *s2b = section2( NULL ); + astInvert( sm ); + printf( "shared_selectors %d\n", astEqual( s2a, s2b ) ); + printf( "Invert shared after %d test %d\n", astGetI( sm, "Invert" ), astTest( sm, "Invert" ) ); + printf( "not_a_switchmap %d\n", astEqual( a, astZoomMap( 1, 2.0, " " ) ) ); + failed(); + } + + /* Simplification. */ + simp( "simp_plain", (AstMapping *) plain() ); + simp( "simp_inverted", inv( plain() ) ); + simp( "simp_routes_simplify", + (AstMapping *) switch2( halves(), halves(), + astCmpMap( astZoomMap( 1, 2.0, " " ), astZoomMap( 1, 5.0, " " ), 1, " " ), + astCmpMap( win( 102.0, 202.0, 1600.0, 2700.0 ), astUnitMap( 1, " " ), 1, " " ) ) ); + simp( "simp_inverted_route_simplifies", + (AstMapping *) switch2( halves(), halves(), inv( astZoomMap( 1, 0.1, " " ) ), + win( 102.0, 202.0, 1600.0, 2700.0 ) ) ); + simp( "simp_selector_simplifies", + (AstMapping *) switch2( astCmpMap( astZoomMap( 1, 2.0, " " ), astZoomMap( 1, 0.5, " " ), 1, " " ), NULL, + win( 0.0, 1.0, 0.0, 10.0 ), win( 0.0, 1.0, 0.0, 20.0 ) ) ); + simp( "simp_inverted_routes_simplify", + inv( switch2( halves(), halves(), + astCmpMap( astZoomMap( 1, 2.0, " " ), astZoomMap( 1, 5.0, " " ), 1, " " ), + win( 102.0, 202.0, 1600.0, 2700.0 ) ) ) ); + { + AstSwitchMap *sw = plain(); + AstSwitchMap *swi = astCopy( sw ); + astInvert( swi ); + simp( "simp_beside_inverse", (AstMapping *) astCmpMap( sw, swi, 1, " " ) ); + simp( "simp_inverse_beside", (AstMapping *) astCmpMap( swi, sw, 1, " " ) ); + simp( "simp_beside_inverse_parallel", (AstMapping *) astCmpMap( sw, swi, 0, " " ) ); + simp( "simp_beside_inverse_inverted_cmpmap", inv( astCmpMap( sw, swi, 1, " " ) ) ); + simp( "simp_beside_inverse_between", + (AstMapping *) astCmpMap( astCmpMap( astZoomMap( 1, 2.0, " " ), sw, 1, " " ), + astCmpMap( swi, astZoomMap( 1, 0.5, " " ), 1, " " ), 1, " " ) ); + AstSwitchMap *sw2 = plain(); + simp( "simp_beside_equal", (AstMapping *) astCmpMap( sw, sw2, 1, " " ) ); + AstSwitchMap *swc = switch2( halves(), halves(), win( 1.0, 101.0, 1000.0, 2000.0 ), + win( 102.0, 202.0, 1600.0, 2800.0 ) ); + astInvert( swc ); + simp( "simp_beside_unequal_inverse", (AstMapping *) astCmpMap( sw, swc, 1, " " ) ); + simp( "simp_beside_zoommap", (AstMapping *) astCmpMap( astZoomMap( 1, 2.0, " " ), sw, 1, " " ) ); + } + { + AstSwitchMap *s1 = section1(); + AstSwitchMap *s1i = astCopy( s1 ); + astInvert( s1i ); + simp( "simp_section1_beside_inverse", (AstMapping *) astCmpMap( s1, s1i, 1, " " ) ); + simp( "simp_section1_inverse_beside", (AstMapping *) astCmpMap( s1i, s1, 1, " " ) ); + simp( "simp_section1_inverted", inv( section1() ) ); + } + { + AstMathMap *sm; + AstSwitchMap *sw = section2( &sm ); + astInvert( sm ); + simp( "simp_section2_shared_selector", (AstMapping *) sw ); + printf( "-- Invert shared after %d test %d\n", astGetI( sm, "Invert" ), astTest( sm, "Invert" ) ); + AstMathMap *sm2; + AstSwitchMap *swb = section2( &sm2 ); + astInvert( sm2 ); + simp( "simp_section2_shared_selector_inverted", inv( swb ) ); + printf( "-- Invert shared after %d test %d\n", astGetI( sm2, "Invert" ), astTest( sm2, "Invert" ) ); + } + { + AstWinMap *r = win( 1.0, 101.0, 1000.0, 2000.0 ); + AstSwitchMap *sw = switch2( halves(), halves(), r, r ); + astInvert( r ); + simp( "simp_shared_route", (AstMapping *) sw ); + printf( "-- Invert shared after %d test %d\n", astGetI( r, "Invert" ), astTest( r, "Invert" ) ); + } + + /* Constructor errors. */ + head( "error_no_routes" ); + astSwitchMap( halves(), halves(), 0, NULL, " " ); + failed(); + head( "error_route_nin" ); + { + AstMapping *rm[ 2 ] = { (AstMapping *) astZoomMap( 1, 2.0, " " ), (AstMapping *) astZoomMap( 2, 2.0, " " ) }; + astSwitchMap( halves(), NULL, 2, (void **) rm, " " ); + failed(); + } + head( "error_route_nout" ); + { + int outperm[ 2 ] = { 1, 1 }; + int inperm[ 1 ] = { 1 }; + AstMapping *rm[ 2 ] = { (AstMapping *) astZoomMap( 1, 2.0, " " ), + (AstMapping *) astPermMap( 1, inperm, 2, outperm, NULL, " " ) }; + astSwitchMap( halves(), NULL, 2, (void **) rm, " " ); + failed(); + } + { + double coeff[] = { 1.0, 1.0, 1.0 }; + AstMapping *rm[ 1 ] = { (AstMapping *) astZoomMap( 1, 2.0, " " ) }; + head( "error_fsmap_no_forward" ); + AstPolyMap *p = astPolyMap( 1, 1, 1, coeff, 0, NULL, "IterInverse=0" ); + astSwitchMap( inv( p ), NULL, 1, (void **) rm, " " ); + failed(); + head( "error_ismap_no_inverse" ); + AstPolyMap *q = astPolyMap( 1, 1, 1, coeff, 0, NULL, "IterInverse=0" ); + astSwitchMap( NULL, q, 1, (void **) rm, " " ); + failed(); + head( "error_fsmap_nin" ); + astSwitchMap( astZoomMap( 2, 1.0, " " ), NULL, 1, (void **) rm, " " ); + failed(); + head( "error_fsmap_nout" ); + { + int outperm[ 2 ] = { 1, 1 }; + int inperm[ 1 ] = { 1 }; + astSwitchMap( astPermMap( 1, inperm, 2, outperm, NULL, " " ), NULL, 1, (void **) rm, " " ); + failed(); + } + head( "error_ismap_nout" ); + astSwitchMap( NULL, astZoomMap( 2, 1.0, " " ), 1, (void **) rm, " " ); + failed(); + head( "error_ismap_nin" ); + { + int outperm[ 1 ] = { 1 }; + int inperm[ 2 ] = { 1, 1 }; + astSwitchMap( NULL, astPermMap( 2, inperm, 1, outperm, NULL, " " ), 1, (void **) rm, " " ); + failed(); + } + head( "error_no_selectors" ); + astSwitchMap( NULL, NULL, 1, (void **) rm, " " ); + failed(); + } + + astEnd; + return 0; +} diff --git a/src/test/resources/probes/switchmap_probe.out b/src/test/resources/probes/switchmap_probe.out new file mode 100644 index 0000000..1a4c8c9 --- /dev/null +++ b/src/test/resources/probes/switchmap_probe.out @@ -0,0 +1,2696 @@ +== selector_values +-1e+30 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +-2147483649 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +-0.5 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +0 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +0.48999999999999999 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +0.49999999999999994 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +0.5 fwd 1 inv 0.25 rate 2 +1.4999999999999998 fwd 2.9999999999999996 inv 0.74999999999999989 rate 2 +1.5 fwd 4.5 inv 0.5 rate 3 +2.25 fwd 6.75 inv 0.75 rate 3 +2.4999999999999996 fwd 7.4999999999999982 inv 0.83333333333333315 rate 3 +2.5 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +3 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +2147483647 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +2147483648.5 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +4294967297 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +4294967298 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +1e+30 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +-1.7976931348623157e+308 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +1.7976931348623157e+308 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +-1.7976931348623157e+308 fwd -1.7976931348623157e+308 inv -1.7976931348623157e+308 rate -1.7976931348623157e+308 +== section1 +fwd 1 1 -> 1000 +fwd 37.5 2 -> 2001.5 +fwd 101 2 -> 2700 +fwd 140 1 -> 2390 +fwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 +inv 1000 -> 1 1 +inv 1700 -> 71 1 +inv 1900 -> 28.272727272727252 2 +inv 2700 -> 101 2 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 2 +-- inverted +fwd 1 -> -98.900000000000006 1 +fwd 37.5 -> -95.25 1 +fwd 101 -> -88.900000000000006 1 +fwd 140 -> -85 1 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 2 +inv 1 1 -> 1000 +inv 37.5 2 -> 2001.5 +inv 101 2 -> 2700 +inv 140 1 -> 2390 +inv -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 +rate 20 1: 10 +rate 20 2: 11.00000002048 +rate 20 2 axis 2: 0 +rate inverted 1700: 0.10000000000000001 +!! AST: Error in routine main at line 257 in file src/test/resources/probes/switchmap_probe.c. +! astRate(SwitchMap): Invalid input index (2) specified - should be in the range 1 to 1. +rate inverted 1900: -1.7976931348623157e+308 +status 233933178 +== section2 +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- inverted +fwd 1 -> -98.900000000000006 +fwd 37.5 -> -95.25 +fwd 101 -> -88.900000000000006 +fwd 140 -> -85 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 11478 +inv 1700 -> 19178 +inv 1900 -> 21378 +inv 2700 -> 30178 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +rate 20: 10 +rate 120: 11 +rate 300: 11 +rate inverted 1700: 0.10000000000000001 +rate inverted 1900: 0.090909090909090912 +== forward_only +TranForward 1 TranInverse 0 +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv undefined +rate 20: 10 +inverted TranForward 0 TranInverse 1 +rate inverted 1700: -1.7976931348623157e+308 +== inverted_routes +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +rate 20: 10 +rate inverted 1900: 0.090909090909090912 +== components_inverted_after +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +Invert fs 1 is 1 r1 1 r2 0 +== dump_section1 + Begin SwitchMap # Alternate regionalised Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + In1 = 0 # Input coordinate 1 is "bad" + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = -1 # Input coordinate 2 = constant no. 1 + Nconst = 1 # Number of constants + Con1 = 1 # Constant number 1 + End PermMap + MapB = # Second component Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + End CmpMap + RMap2 = # Route Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = -1 # Input coordinate 2 = constant no. 1 + Nconst = 1 # Number of constants + Con1 = 2 # Constant number 1 + End PermMap + MapB = # Second component Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 1589 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End CmpMap + End SwitchMap +-- read back + Begin SwitchMap # Alternate regionalised Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + In1 = 0 # Input coordinate 1 is "bad" + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = -1 # Input coordinate 2 = constant no. 1 + Nconst = 1 # Number of constants + Con1 = 1 # Constant number 1 + End PermMap + MapB = # Second component Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + End CmpMap + RMap2 = # Route Mapping + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + In1 = 1 # Input coordinate 1 = output coordinate 1 + In2 = -1 # Input coordinate 2 = constant no. 1 + Nconst = 1 # Number of constants + Con1 = 2 # Constant number 1 + End PermMap + MapB = # Second component Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 1589 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End CmpMap + End SwitchMap +-- equal 1 +-- transformations +fwd 1 1 -> 1000 +fwd 37.5 2 -> 2001.5 +fwd 101 2 -> 2700 +fwd 140 1 -> 2390 +fwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 +inv 1000 -> 1 1 +inv 1700 -> 71 1 +inv 1900 -> 28.272727272727252 2 +inv 2700 -> 101 2 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 2 +-- transformations read back +fwd 1 1 -> 1000 +fwd 37.5 2 -> 2001.5 +fwd 101 2 -> 2700 +fwd 140 1 -> 2390 +fwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 +inv 1000 -> 1 1 +inv 1700 -> 71 1 +inv 1900 -> 28.272727272727252 2 +inv 2700 -> 101 2 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 2 +== dump_section2 + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- read back + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- equal 1 +-- transformations +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations read back +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== dump_inverted + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- read back + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- equal 1 +-- transformations +fwd 1 -> -98.900000000000006 +fwd 37.5 -> -95.25 +fwd 101 -> -88.900000000000006 +fwd 140 -> -85 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 11478 +inv 1700 -> 19178 +inv 1900 -> 21378 +inv 2700 -> 30178 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations read back +fwd 1 -> -98.900000000000006 +fwd 37.5 -> -95.25 +fwd 101 -> -88.900000000000006 +fwd 140 -> -85 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 11478 +inv 1700 -> 19178 +inv 1900 -> 21378 +inv 2700 -> 30178 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== dump_forward_only + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- read back + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- equal 1 +-- transformations +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv undefined +-- transformations read back +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv undefined +== dump_inverse_only + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- read back + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- equal 1 +-- transformations +fwd undefined +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations read back +fwd undefined +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== dump_inverted_at_construction + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + FSInv = 1 # Fwd selector used in inverse direction + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISInv = 1 # Inv selector used in inverse direction + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Sft1 = -99 # Shift for axis 1 + Scl1 = 0.10000000000000001 # Scale factor for axis 1 + End WinMap + RInv1 = 1 # Route Mapping used in inverse direction + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- read back + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + FSInv = 1 # Fwd selector used in inverse direction + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISInv = 1 # Inv selector used in inverse direction + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Sft1 = -99 # Shift for axis 1 + Scl1 = 0.10000000000000001 # Scale factor for axis 1 + End WinMap + RInv1 = 1 # Route Mapping used in inverse direction + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- equal 1 +-- transformations +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2390 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 47.454545454545453 +inv 1700 -> 111.09090909090911 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations read back +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2390 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 47.454545454545453 +inv 1700 -> 111.09090909090911 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== dump_inverted_after + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- read back + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- equal 1 +-- transformations +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations read back +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== dump_lutmap_mathmap + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements + Start = 1 # Input value at first element + Incr = 25 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 1000 # Lookup table elements... + L2 = 1100 + L3 = 1300 + L4 = 1600 + L5 = 2000 + End LutMap + RMap2 = # Route Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*10+990" # Forward function 1 + Inv1 = "x=(y-990)/10" # Inverse function 1 + End MathMap + End SwitchMap +-- read back + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements + Start = 1 # Input value at first element + Incr = 25 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 1000 # Lookup table elements... + L2 = 1100 + L3 = 1300 + L4 = 1600 + L5 = 2000 + End LutMap + RMap2 = # Route Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*10+990" # Forward function 1 + Inv1 = "x=(y-990)/10" # Inverse function 1 + End MathMap + End SwitchMap +-- equal 1 +-- transformations +fwd 1 -> 1000 +fwd 37.5 -> 1192 +fwd 101 -> 2000 +fwd 140 -> 2390 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 82.25 +inv 1900 -> 91 +inv 2700 -> 171 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations read back +fwd 1 -> 1000 +fwd 37.5 -> 1192 +fwd 101 -> 2000 +fwd 140 -> 2390 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 82.25 +inv 1900 -> 91 +inv 2700 -> 171 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== dump_pcdmap + Begin SwitchMap # Alternate regionalised Mapping + Nin = 2 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + In1 = 0 # Input coordinate 1 is "bad" + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + RMap1 = # Route Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 1 # Distortion centre on first axis + PcdCn1 = 1.5 # Distortion centre on second axis + Disco = 0.001 # Distortion coefficient + End PcdMap + RMap2 = # Route Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End SwitchMap +-- read back + Begin SwitchMap # Alternate regionalised Mapping + Nin = 2 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin PermMap # Coordinate permutation + Nin = 2 # Number of input coordinates + Nout = 1 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 2 # Output coordinate 1 = input coordinate 2 + In1 = 0 # Input coordinate 1 is "bad" + In2 = 1 # Input coordinate 2 = output coordinate 1 + End PermMap + RMap1 = # Route Mapping + Begin PcdMap # Apply pincushion distortion + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + PcdCn0 = 1 # Distortion centre on first axis + PcdCn1 = 1.5 # Distortion centre on second axis + Disco = 0.001 # Distortion coefficient + End PcdMap + RMap2 = # Route Mapping + Begin ZoomMap # Zoom about the origin + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End SwitchMap +-- equal 1 +-- transformations +fwd 1 1 -> 1 0.99987499999999996 +fwd 37.5 2 -> 75 4 +fwd 101 2 -> 202 4 +fwd 140 1 -> 2825.6537499999999 -8.6606249999999996 +fwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv undefined +-- transformations read back +fwd 1 1 -> 1 0.99987499999999996 +fwd 37.5 2 -> 75 4 +fwd 101 2 -> 202 4 +fwd 140 1 -> 2825.6537499999999 -8.6606249999999996 +fwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 -1.7976931348623157e+308 +inv undefined +== dump_in_cmpmap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap + End CmpMap +-- read back + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap + End CmpMap +-- equal 1 +-- transformations +fwd 1 -> 1010 +fwd 37.5 -> 1740 +fwd 101 -> 2700 +fwd 140 -> 3558 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 0.5 +inv 1700 -> 35.5 +inv 1900 -> 64.636363636363626 +inv 2700 -> 101 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations read back +fwd 1 -> 1010 +fwd 37.5 -> 1740 +fwd 101 -> 2700 +fwd 140 -> 3558 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 0.5 +inv 1700 -> 35.5 +inv 1900 -> 64.636363636363626 +inv 2700 -> 101 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== dump_in_tranmap + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # Mapping for forward transformation + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap + MapB = # Mapping for inverse transformation + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap + End TranMap +-- read back + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # Mapping for forward transformation + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap + MapB = # Mapping for inverse transformation + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap + End TranMap +-- equal 1 +-- transformations +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 11478 +inv 1700 -> 19178 +inv 1900 -> 21378 +inv 2700 -> 30178 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations read back +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 11478 +inv 1700 -> 19178 +inv 1900 -> 21378 +inv 2700 -> 30178 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== dump_in_switchmap + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + RMap1 = # Route Mapping + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap + End SwitchMap +-- read back + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + End UnitMap + RMap1 = # Route Mapping + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap + End SwitchMap +-- equal 1 +-- transformations +fwd 1 -> 1000 +fwd 37.5 -> -1.7976931348623157e+308 +fwd 101 -> -1.7976931348623157e+308 +fwd 140 -> -1.7976931348623157e+308 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv undefined +-- transformations read back +fwd 1 -> 1000 +fwd 37.5 -> -1.7976931348623157e+308 +fwd 101 -> -1.7976931348623157e+308 +fwd 140 -> -1.7976931348623157e+308 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv undefined +== dump_fsinv_set_isinv_unset + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + FSInv = 1 # Fwd selector used in inverse direction + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- read back + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + FSInv = 1 # Fwd selector used in inverse direction + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISInv = 1 # Inv selector used in inverse direction + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- equal 0 +-- transformations +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2390 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations read back +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2390 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 47.454545454545453 +inv 1700 -> 111.09090909090911 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== equal +same_contents 1 +different_route 0 +missing_inverse_selector 0 +missing_inverse_selector_reversed 0 +both_forward_only 1 +three_routes 0 +inverted_vs_plain 0 +inverted_vs_normalised 1 +normalised_vs_inverted 1 +route_inverted_equivalent 1 +selector_inverted_after 1 +Invert fs after 1 +shared_selectors 1 +Invert shared after 1 test 1 +not_a_switchmap 0 +== simp_plain +class SwitchMap + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- transformations +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== simp_inverted +class SwitchMap + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + FSInv = 1 # Fwd selector used in inverse direction + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISInv = 1 # Inv selector used in inverse direction + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RInv1 = 1 # Route Mapping used in inverse direction + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + RInv2 = 1 # Route Mapping used in inverse direction + End SwitchMap +-- transformations +fwd 1 -> -98.900000000000006 +fwd 37.5 -> -95.25 +fwd 101 -> -88.900000000000006 +fwd 140 -> -85 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 11478 +inv 1700 -> 19178 +inv 1900 -> 21378 +inv 2700 -> 30178 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> -98.900000000000006 +fwd 37.5 -> -95.25 +fwd 101 -> -88.900000000000006 +fwd 140 -> -85 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 11478 +inv 1700 -> 19178 +inv 1900 -> 21378 +inv 2700 -> 30178 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== simp_routes_simplify +class SwitchMap + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 10 # Zoom factor + End ZoomMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- transformations +fwd 1 -> 10 +fwd 37.5 -> 375 +fwd 101 -> 1010 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 100 +inv 1700 -> 170 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> 10 +fwd 37.5 -> 375 +fwd 101 -> 1010 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 100 +inv 1700 -> 170 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== simp_inverted_route_simplifies +class SwitchMap + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 10 # Zoom factor + End ZoomMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- transformations +fwd 1 -> 10 +fwd 37.5 -> 375 +fwd 101 -> 1010 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 100 +inv 1700 -> 170 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> 10 +fwd 37.5 -> 375 +fwd 101 -> 1010 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 100 +inv 1700 -> 170 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== simp_selector_simplifies +class SwitchMap + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Inv = 0 # Inverse transformation not defined + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap + RMap1 = # Route Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 10 # Zoom factor + End ZoomMap + RMap2 = # Route Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 20 # Zoom factor + End ZoomMap + End SwitchMap +-- transformations +fwd 1 -> 10 +fwd 37.5 -> -1.7976931348623157e+308 +fwd 101 -> -1.7976931348623157e+308 +fwd 140 -> -1.7976931348623157e+308 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv undefined +-- transformations simplified +fwd 1 -> 10 +fwd 37.5 -> -1.7976931348623157e+308 +fwd 101 -> -1.7976931348623157e+308 +fwd 140 -> -1.7976931348623157e+308 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv undefined +== simp_inverted_routes_simplify +class SwitchMap + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + FSInv = 1 # Fwd selector used in inverse direction + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISInv = 1 # Inv selector used in inverse direction + RMap1 = # Route Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 0.10000000000000001 # Zoom factor + End ZoomMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + RInv2 = 1 # Route Mapping used in inverse direction + End SwitchMap +-- transformations +fwd 1 -> 0.10000000000000001 +fwd 37.5 -> 3.75 +fwd 101 -> 10.100000000000001 +fwd 140 -> 14 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 11478 +inv 1700 -> 19178 +inv 1900 -> 21378 +inv 2700 -> 30178 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> 0.10000000000000001 +fwd 37.5 -> 3.75 +fwd 101 -> 10.100000000000001 +fwd 140 -> 14 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 11478 +inv 1700 -> 19178 +inv 1900 -> 21378 +inv 2700 -> 30178 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== simp_beside_inverse +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 1 -> 1 +fwd 37.5 -> 37.5 +fwd 101 -> 138.36363636363637 +fwd 140 -> 140 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1000 +inv 1700 -> 1700 +inv 1900 -> 1900 +inv 2700 -> 2700 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> 1 +fwd 37.5 -> 37.5 +fwd 101 -> 101 +fwd 140 -> 140 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1000 +inv 1700 -> 1700 +inv 1900 -> 1900 +inv 2700 -> 2700 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== simp_inverse_beside +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 1 -> 1 +fwd 37.5 -> 37.5 +fwd 101 -> 101 +fwd 140 -> 140 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1000 +inv 1700 -> 1700 +inv 1900 -> 1899.9999999999998 +inv 2700 -> 2700 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> 1 +fwd 37.5 -> 37.5 +fwd 101 -> 101 +fwd 140 -> 140 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1000 +inv 1700 -> 1700 +inv 1900 -> 1900 +inv 2700 -> 2700 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== simp_beside_inverse_parallel +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap + MapB = # Second component Mapping + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + FSInv = 1 # Fwd selector used in inverse direction + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISInv = 1 # Inv selector used in inverse direction + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RInv1 = 1 # Route Mapping used in inverse direction + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + RInv2 = 1 # Route Mapping used in inverse direction + End SwitchMap + End CmpMap +-- transformations +fwd 1 1 -> 1000 -98.900000000000006 +fwd 37.5 2 -> 1365 -98.799999999999997 +fwd 101 2 -> 2000 -98.799999999999997 +fwd 140 1 -> 2018 -98.900000000000006 +fwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 -98.900000000000006 +inv 1 1 -> -98.900000000000006 1000 +inv 37.5 2 -> -95.25 1010 +inv 101 2 -> -88.900000000000006 1010 +inv 140 1 -> -85 1000 +inv -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 1000 +-- transformations simplified +fwd 1 1 -> 1000 -98.900000000000006 +fwd 37.5 2 -> 1365 -98.799999999999997 +fwd 101 2 -> 2000 -98.799999999999997 +fwd 140 1 -> 2018 -98.900000000000006 +fwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 -98.900000000000006 +inv 1 1 -> -98.900000000000006 1000 +inv 37.5 2 -> -95.25 1010 +inv 101 2 -> -88.900000000000006 1010 +inv 140 1 -> -85 1000 +inv -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 1000 +== simp_beside_inverse_inverted_cmpmap +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 1 -> 1 +fwd 37.5 -> 37.5 +fwd 101 -> 138.36363636363637 +fwd 140 -> 140 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1000 +inv 1700 -> 1700 +inv 1900 -> 1900 +inv 2700 -> 2700 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> 1 +fwd 37.5 -> 37.5 +fwd 101 -> 101 +fwd 140 -> 140 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1000 +inv 1700 -> 1700 +inv 1900 -> 1900 +inv 2700 -> 2700 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== simp_beside_inverse_between +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 1 -> 1 +fwd 37.5 -> 37.5 +fwd 101 -> 101 +fwd 140 -> 140 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1000 +inv 1700 -> 1700 +inv 1900 -> 1900 +inv 2700 -> 2700.0000000000005 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> 1 +fwd 37.5 -> 37.5 +fwd 101 -> 101 +fwd 140 -> 140 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1000 +inv 1700 -> 1700 +inv 1900 -> 1900 +inv 2700 -> 2700 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== simp_beside_equal +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap + MapB = # Second component Mapping + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap + End CmpMap +-- transformations +fwd 1 -> 11478 +fwd 37.5 -> 15493 +fwd 101 -> 22478 +fwd 140 -> 22676 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> -98.900000000000006 +inv 1700 -> -91.900000000000006 +inv 1900 -> -86.072727272727278 +inv 2700 -> -78.799999999999997 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> 11478 +fwd 37.5 -> 15493 +fwd 101 -> 22478 +fwd 140 -> 22676 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> -98.900000000000006 +inv 1700 -> -91.900000000000006 +inv 1900 -> -86.072727272727278 +inv 2700 -> -78.799999999999997 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== simp_beside_unequal_inverse +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap + MapB = # Second component Mapping + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + FSInv = 1 # Fwd selector used in inverse direction + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISInv = 1 # Inv selector used in inverse direction + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RInv1 = 1 # Route Mapping used in inverse direction + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 376 # Shift for axis 1 + Scl1 = 12 # Scale factor for axis 1 + End WinMap + RInv2 = 1 # Route Mapping used in inverse direction + End SwitchMap + End CmpMap +-- transformations +fwd 1 -> 1 +fwd 37.5 -> 37.5 +fwd 101 -> 135.33333333333331 +fwd 140 -> 136.83333333333331 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1081.6363636363637 +inv 1700 -> 1845.2727272727273 +inv 1900 -> 2063.4545454545455 +inv 2700 -> 2936.181818181818 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> 1 +fwd 37.5 -> 37.5 +fwd 101 -> 135.33333333333331 +fwd 140 -> 136.83333333333331 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1081.6363636363637 +inv 1700 -> 1845.2727272727273 +inv 1900 -> 2063.4545454545455 +inv 2700 -> 2936.181818181818 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== simp_beside_zoommap +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Second component Mapping + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap + End CmpMap +-- transformations +fwd 1 -> 1010 +fwd 37.5 -> 1740 +fwd 101 -> 2700 +fwd 140 -> 3558 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 0.5 +inv 1700 -> 35.5 +inv 1900 -> 64.636363636363626 +inv 2700 -> 101 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> 1010 +fwd 37.5 -> 1740 +fwd 101 -> 2700 +fwd 140 -> 3558 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 0.5 +inv 1700 -> 35.5 +inv 1900 -> 64.636363636363626 +inv 2700 -> 101 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== simp_section1_beside_inverse +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 1 1 -> 1 1 +fwd 37.5 2 -> 37.5 2 +fwd 101 2 -> 101 2 +fwd 140 1 -> 72.818181818181813 2 +fwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 2 +inv 1 1 -> 1 1 +inv 37.5 2 -> 37.5 2 +inv 101 2 -> 101 2 +inv 140 1 -> 72.818181818181813 2 +inv -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 2 +-- transformations simplified +fwd 1 1 -> 1 1 +fwd 37.5 2 -> 37.5 2 +fwd 101 2 -> 101 2 +fwd 140 1 -> 140 1 +fwd -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 1 +inv 1 1 -> 1 1 +inv 37.5 2 -> 37.5 2 +inv 101 2 -> 101 2 +inv 140 1 -> 140 1 +inv -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 1 +== simp_section1_inverse_beside +class UnitMap + Begin UnitMap # Unit (null) Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + End UnitMap +-- transformations +fwd 1 -> 1 +fwd 37.5 -> 37.5 +fwd 101 -> 101 +fwd 140 -> 140 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1000 +inv 1700 -> 1700 +inv 1900 -> 1899.9999999999998 +inv 2700 -> 2700 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> 1 +fwd 37.5 -> 37.5 +fwd 101 -> 101 +fwd 140 -> 140 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1000 +inv 1700 -> 1700 +inv 1900 -> 1900 +inv 2700 -> 2700 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +== simp_section1_inverted +class SwitchMap + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Fwd = 0 # Forward transformation not defined + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + FSInv = 1 # Fwd selector used in inverse direction + ISMap = # Inverse selector Mapping + Begin PermMap # Coordinate permutation + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Out1 = 0 # Output coordinate 1 is "bad" + Out2 = 1 # Output coordinate 2 = input coordinate 1 + In1 = 2 # Input coordinate 1 = output coordinate 2 + End PermMap + RMap1 = # Route Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = -1 # Output coordinate 2 = constant no. 1 + InCpy = 1 # Input coordinates = output coordinates + Nconst = 1 # Number of constants + Con1 = 1 # Constant number 1 + End PermMap + End CmpMap + RMap2 = # Route Mapping + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # First component Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 1589 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + MapB = # Second component Mapping + Begin PermMap # Coordinate permutation + Nin = 1 # Number of input coordinates + Nout = 2 # Number of output coordinates + IsA Mapping # Mapping between coordinate systems + Out1 = 1 # Output coordinate 1 = input coordinate 1 + Out2 = -1 # Output coordinate 2 = constant no. 1 + InCpy = 1 # Input coordinates = output coordinates + Nconst = 1 # Number of constants + Con1 = 2 # Constant number 1 + End PermMap + End CmpMap + End SwitchMap +-- transformations +fwd 1 -> -98.900000000000006 1 +fwd 37.5 -> -95.25 1 +fwd 101 -> -88.900000000000006 1 +fwd 140 -> -85 1 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 2 +inv 1 1 -> 1000 +inv 37.5 2 -> 2001.5 +inv 101 2 -> 2700 +inv 140 1 -> 2390 +inv -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> -98.900000000000006 1 +fwd 37.5 -> -95.25 1 +fwd 101 -> -88.900000000000006 1 +fwd 140 -> -85 1 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 2 +inv 1 1 -> 1000 +inv 37.5 2 -> 2001.5 +inv 101 2 -> 2700 +inv 140 1 -> 2390 +inv -1.7976931348623157e+308 1 -> -1.7976931348623157e+308 +== simp_section2_shared_selector +class SwitchMap + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- transformations +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2018 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 129.27272727272725 +inv 2700 -> 202 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- Invert shared after 0 test 1 +== simp_section2_shared_selector_inverted +class SwitchMap + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + FSInv = 1 # Fwd selector used in inverse direction + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISInv = 1 # Inv selector used in inverse direction + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RInv1 = 1 # Route Mapping used in inverse direction + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 478 # Shift for axis 1 + Scl1 = 11 # Scale factor for axis 1 + End WinMap + RInv2 = 1 # Route Mapping used in inverse direction + End SwitchMap +-- transformations +fwd 1 -> -98.900000000000006 +fwd 37.5 -> -95.25 +fwd 101 -> -88.900000000000006 +fwd 140 -> -85 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 11478 +inv 1700 -> 19178 +inv 1900 -> 21378 +inv 2700 -> 30178 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> -98.900000000000006 +fwd 37.5 -> -95.25 +fwd 101 -> -88.900000000000006 +fwd 140 -> -85 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 11478 +inv 1700 -> 19178 +inv 1900 -> 21378 +inv 2700 -> 30178 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- Invert shared after 1 test 1 +== simp_shared_route +class SwitchMap + Begin SwitchMap # Alternate regionalised Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + FSMap = # Forward selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + ISMap = # Inverse selector Mapping + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=qif(x>101.5,2,1)" # Forward function 1 + Inv1 = "x=qif(y>1800,2,1)" # Inverse function 1 + End MathMap + RMap1 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + RMap2 = # Route Mapping + Begin WinMap # Map one window on to another + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Sft1 = 990 # Shift for axis 1 + Scl1 = 10 # Scale factor for axis 1 + End WinMap + End SwitchMap +-- transformations +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2390 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 91 +inv 2700 -> 171 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- transformations simplified +fwd 1 -> 1000 +fwd 37.5 -> 1365 +fwd 101 -> 2000 +fwd 140 -> 2390 +fwd -1.7976931348623157e+308 -> -1.7976931348623157e+308 +inv 1000 -> 1 +inv 1700 -> 71 +inv 1900 -> 91 +inv 2700 -> 171 +inv -1.7976931348623157e+308 -> -1.7976931348623157e+308 +-- Invert shared after 0 test 1 +== error_no_routes +!! AST: Error in routine mathmap at line 77 in file src/test/resources/probes/switchmap_probe.c. +! astSwitchMap(SwitchMap): Bad number of route Mappings (0) specified. +status 233934170 +== error_route_nin +!! AST: Error in routine mathmap at line 77 in file src/test/resources/probes/switchmap_probe.c. +! astInitSwitchMap(SwitchMap): Route Mapping number 2 has 2 input(s) but the first route Mapping has 1 input(s). +status 233933210 +== error_route_nout +!! AST: Error in routine mathmap at line 77 in file src/test/resources/probes/switchmap_probe.c. +! astInitSwitchMap(SwitchMap): Route Mapping number 2 has 1 output(s) but the first route Mapping has 1 output(s). +status 233933218 +== error_fsmap_no_forward +!! AST: Error in routine inv at line 66 in file src/test/resources/probes/switchmap_probe.c. +! astInitSwitchMap(SwitchMap): The forward selector Mapping is not able to transform coordinates in the forward direction. +status 233933418 +== error_ismap_no_inverse +!! AST: Error in routine main at line 522 in file src/test/resources/probes/switchmap_probe.c. +! astInitSwitchMap(SwitchMap): The inverse selector Mapping is not able to transform coordinates in the inverse direction. +status 233933418 +== error_fsmap_nin +!! AST: Error in routine main at line 525 in file src/test/resources/probes/switchmap_probe.c. +! astInitSwitchMap(SwitchMap): The forward selector Mapping has 2 input(s) but the SwitchMap has 1 input(s). +status 233933210 +== error_fsmap_nout +!! AST: Error in routine main at line 531 in file src/test/resources/probes/switchmap_probe.c. +! astInitSwitchMap(SwitchMap): The forward selector Mapping has 2 outputs but should only have 1. +status 233933218 +== error_ismap_nout +!! AST: Error in routine main at line 535 in file src/test/resources/probes/switchmap_probe.c. +! astInitSwitchMap(SwitchMap): The inverse selector Mapping has 2 output(s) but the SwitchMap has 1 output(s). +status 233933218 +== error_ismap_nin +!! AST: Error in routine main at line 541 in file src/test/resources/probes/switchmap_probe.c. +! astInitSwitchMap(SwitchMap): The inverse selector Mapping has 2 inputs but should only have 1. +status 233933210 +== error_no_selectors +!! AST: Error in routine main at line 545 in file src/test/resources/probes/switchmap_probe.c. +! astInitSwitchMap(SwitchMap): No selector Mappings supplied. +status 233933418 diff --git a/src/test/resources/probes/tranmap_probe.c b/src/test/resources/probes/tranmap_probe.c new file mode 100644 index 0000000..e6fe2b1 --- /dev/null +++ b/src/test/resources/probes/tranmap_probe.c @@ -0,0 +1,354 @@ +/* tranmap_probe -- TranMap behaviour of the pinned C library that no + * fixture or oracle holds: native dumps with each component inverted, at + * construction and afterwards, with a LutMap and a MathMap inside, each + * read back through a Channel and dumped again; simplification of a + * TranMap alone, inverted, with equal components (one object or two, + * inverted or not), beside other Mappings and other TranMaps; rates; + * astEqual; astDecompose; astMapSplit; and the constructor's errors. + * + * Each case starts with a line "== "; error reports, which the error + * module writes to standard error, are merged in order (stdout unbuffered). + * Built against the C library at 3d3f255f with its static libraries: + * cc -I -o tranmap_probe tranmap_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 ./tranmap_probe > tranmap_probe.out 2>&1, then trailing white + * space removed from every line (TranMapTest compares lines without it). */ +#include +#include +#include +#include "ast.h" + +/* The lines a Channel writes, which a second Channel reads back. */ +#define MAXLINES 400 +static char *lines[ MAXLINES ]; +static int nline = 0; +static int iline = 0; + +static void sink( const char *line ) { + if( nline < MAXLINES ) lines[ nline++ ] = strcpy( malloc( strlen( line ) + 1 ), line ); +} + +static const char *source( void ) { + return ( iline < nline ) ? lines[ iline++ ] : NULL; +} + +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; +} + +/* The forward and inverse images of one value under a 1-D Mapping; + nothing for any other Mapping. */ +static void tran( AstMapping *m, double x ) { + double f, i; + if( astGetI( m, "Nin" ) != 1 ) return; + astTran1( m, 1, &x, 1, &f ); + astTran1( m, 1, &x, 0, &i ); + if( failed() ) return; + printf( "fwd %.17g -> %.17g\n", x, f ); + printf( "inv %.17g -> %.17g\n", x, i ); +} + +/* The dump, the Object read back from it through a Channel and that + Object's dump, then the transformations of both. */ +static void roundtrip( const char *name, AstMapping *m, double x ) { + head( name ); + astShow( m ); + for( int i = 0; i < nline; i++ ) free( lines[ i ] ); + nline = iline = 0; + AstChannel *ch = astChannel( source, sink, " " ); + astWrite( ch, m ); + AstMapping *back = astRead( ch ); + if( failed() ) return; + printf( "-- read back\n" ); + astShow( back ); + printf( "-- transformations\n" ); + tran( m, x ); + printf( "-- transformations read back\n" ); + tran( back, x ); + ch = astAnnul( ch ); +} + +/* The class of the simplified Mapping, its dump, and the transformations + of the original and the simplified Mapping. */ +static void simp( const char *name, AstMapping *m, double x ) { + head( name ); + AstMapping *s = astSimplify( m ); + if( failed() ) return; + printf( "class %s\n", astGetC( s, "Class" ) ); + astShow( s ); + printf( "-- transformations\n" ); + tran( m, x ); + printf( "-- transformations simplified\n" ); + tran( s, x ); +} + +/* As simp, with the transformations at two values. */ +static void simp2( const char *name, AstMapping *m, double x1, double x2 ) { + head( name ); + AstMapping *s = astSimplify( m ); + if( failed() ) return; + printf( "class %s\n", astGetC( s, "Class" ) ); + astShow( s ); + printf( "-- transformations\n" ); + tran( m, x1 ); + tran( m, x2 ); + printf( "-- transformations simplified\n" ); + tran( s, x1 ); + tran( s, x2 ); +} + +static AstZoomMap *zoom( int n, double f ) { + return astZoomMap( n, f, " " ); +} + +static AstMapping *inv( AstMapping *m ) { + astInvert( m ); + return m; +} + +static double table[] = { 0.0, 1.0, 4.0, 9.0, 16.0 }; + +static AstMathMap *mathmap( const char *f, const char *i, const char *settings ) { + const char *fwd[] = { f }; + const char *invf[] = { i }; + return astMathMap( 1, 1, 1, fwd, 1, invf, "%s", settings ); +} + +int main( void ) { + int status = 0; + setvbuf( stdout, NULL, _IONBF, 0 ); + astWatch( &status ); + astBegin; + + /* Native dumps and read back. */ + roundtrip( "dump_plain", (AstMapping *) astTranMap( zoom( 1, 2.0 ), zoom( 1, 3.0 ), " " ), 6.0 ); + roundtrip( "dump_inva", (AstMapping *) astTranMap( inv( (AstMapping *) zoom( 1, 2.0 ) ), zoom( 1, 3.0 ), " " ), 6.0 ); + roundtrip( "dump_invb", (AstMapping *) astTranMap( zoom( 1, 2.0 ), inv( (AstMapping *) zoom( 1, 3.0 ) ), " " ), 6.0 ); + roundtrip( "dump_both_inverted", + (AstMapping *) astTranMap( inv( (AstMapping *) zoom( 1, 2.0 ) ), + inv( (AstMapping *) zoom( 1, 3.0 ) ), " " ), 6.0 ); + roundtrip( "dump_tranmap_inverted", + inv( (AstMapping *) astTranMap( zoom( 1, 2.0 ), zoom( 1, 3.0 ), " " ) ), 6.0 ); + { + AstZoomMap *a = zoom( 1, 2.0 ); + AstZoomMap *b = zoom( 1, 3.0 ); + AstTranMap *t = astTranMap( a, b, " " ); + astInvert( a ); + astInvert( b ); + roundtrip( "dump_components_inverted_after", (AstMapping *) t, 6.0 ); + } + { + AstLutMap *lut = astLutMap( 5, table, 1.0, 1.0, " " ); + AstMathMap *mm = mathmap( "y = x * x", "x = sqrt( y )", " " ); + roundtrip( "dump_lutmap_mathmap", (AstMapping *) astTranMap( lut, mm, " " ), 2.5 ); + AstLutMap *lut2 = astLutMap( 5, table, 1.0, 1.0, " " ); + AstMathMap *mm2 = mathmap( "y = x * x", "x = sqrt( y )", " " ); + roundtrip( "dump_lutmap_mathmap_inverted", + (AstMapping *) astTranMap( inv( (AstMapping *) mm2 ), inv( (AstMapping *) lut2 ), " " ), 2.5 ); + } + + /* Simplification. */ + simp( "simp_plain", (AstMapping *) astTranMap( zoom( 1, 2.0 ), zoom( 1, 3.0 ), " " ), 6.0 ); + simp( "simp_inverted", inv( (AstMapping *) astTranMap( zoom( 1, 2.0 ), zoom( 1, 3.0 ), " " ) ), 6.0 ); + simp( "simp_equal", (AstMapping *) astTranMap( zoom( 1, 2.0 ), zoom( 1, 2.0 ), " " ), 6.0 ); + simp( "simp_equal_inverted_components", + (AstMapping *) astTranMap( inv( (AstMapping *) zoom( 1, 2.0 ) ), + inv( (AstMapping *) zoom( 1, 2.0 ) ), " " ), 6.0 ); + simp( "simp_equal_inverted_tranmap", + inv( (AstMapping *) astTranMap( zoom( 1, 2.0 ), zoom( 1, 2.0 ), " " ) ), 6.0 ); + { + AstZoomMap *z = zoom( 1, 2.0 ); + simp( "simp_same_object", (AstMapping *) astTranMap( z, z, " " ), 6.0 ); + } + simp( "simp_equal_lutmaps", + (AstMapping *) astTranMap( astLutMap( 5, table, 1.0, 1.0, " " ), + astLutMap( 5, table, 1.0, 1.0, " " ), " " ), 2.5 ); + simp( "simp_equal_mathmaps", + (AstMapping *) astTranMap( mathmap( "y = x * x", "x = sqrt( y )", "SimpFI=1,SimpIF=1" ), + mathmap( "y = x * x", "x = sqrt( y )", "SimpFI=1,SimpIF=1" ), " " ), 2.5 ); + simp( "simp_equal_inverted_mathmaps", + (AstMapping *) astTranMap( inv( (AstMapping *) mathmap( "y = x * x", "x = sqrt( y )", "SimpFI=1,SimpIF=1" ) ), + inv( (AstMapping *) mathmap( "y = x * x", "x = sqrt( y )", "SimpFI=1,SimpIF=1" ) ), + " " ), 2.5 ); + simp2( "simp_equal_inverted_lutmaps", + (AstMapping *) astTranMap( inv( (AstMapping *) astLutMap( 5, table, 1.0, 1.0, " " ) ), + inv( (AstMapping *) astLutMap( 5, table, 1.0, 1.0, " " ) ), " " ), 2.5, 3.0 ); + simp( "simp_unequal_mathmaps", + (AstMapping *) astTranMap( mathmap( "y = x * x", "x = sqrt( y )", " " ), + mathmap( "y = x * x", "x = sqrt( y )", " " ), " " ), 2.5 ); + simp( "simp_lutmap_beside_its_inverse", + (AstMapping *) astCmpMap( astTranMap( astLutMap( 5, table, 1.0, 1.0, " " ), zoom( 1, 3.0 ), " " ), + inv( (AstMapping *) astLutMap( 5, table, 1.0, 1.0, " " ) ), 1, " " ), 2.5 ); + simp( "simp_beside_zoommap", + (AstMapping *) astCmpMap( astTranMap( zoom( 1, 2.0 ), zoom( 1, 3.0 ), " " ), zoom( 1, 4.0 ), 1, " " ), 6.0 ); + simp( "simp_pair_second_inverted", + (AstMapping *) astCmpMap( astTranMap( zoom( 1, 2.0 ), zoom( 1, 3.0 ), " " ), + inv( (AstMapping *) astTranMap( zoom( 1, 5.0 ), zoom( 1, 7.0 ), " " ) ), 1, " " ), 6.0 ); + simp( "simp_pair_inverted_series", + inv( (AstMapping *) astCmpMap( astTranMap( zoom( 1, 2.0 ), zoom( 1, 3.0 ), " " ), + astTranMap( zoom( 1, 5.0 ), zoom( 1, 7.0 ), " " ), 1, " " ) ), 6.0 ); + simp( "simp_pair_parallel", + (AstMapping *) astCmpMap( astTranMap( zoom( 1, 2.0 ), zoom( 1, 3.0 ), " " ), + astTranMap( zoom( 1, 5.0 ), zoom( 1, 7.0 ), " " ), 0, " " ), 6.0 ); + { + AstZoomMap *z = zoom( 1, 2.0 ); + AstTranMap *t = astTranMap( z, zoom( 1, 3.0 ), " " ); + simp( "simp_pair_shared_tranmap", (AstMapping *) astCmpMap( t, t, 1, " " ), 6.0 ); + } + + /* Rates. */ + head( "rates" ); + { + double ina[] = { 0.0, 0.0 }, inb[] = { 1.0, 1.0 }; + double outa[] = { 1.0, 3.0 }, outb[] = { 3.0, 5.0 }; + AstWinMap *w = astWinMap( 2, ina, inb, outa, outb, " " ); + AstWinMap *wi = astCopy( w ); + astInvert( wi ); + AstTranMap *t = astTranMap( w, wi, " " ); + double at[] = { 1.0, 2.0 }; + for( int i = 1; i <= 2; i++ ) { + for( int j = 1; j <= 2; j++ ) printf( "fwd %d %d %.17g\n", i, j, astRate( t, at, i, j ) ); + } + astInvert( t ); + for( int i = 1; i <= 2; i++ ) { + for( int j = 1; j <= 2; j++ ) printf( "inv %d %d %.17g\n", i, j, astRate( t, at, i, j ) ); + } + AstTranMap *tz = astTranMap( zoom( 1, 2.0 ), zoom( 1, 3.0 ), " " ); + double one = 1.0; + printf( "zoom fwd %.17g\n", astRate( tz, &one, 1, 1 ) ); + astInvert( tz ); + printf( "zoom inv %.17g\n", astRate( tz, &one, 1, 1 ) ); + AstMathMap *m = mathmap( "y = x * x", "x = sqrt( y )", " " ); + AstTranMap *tm = astTranMap( m, zoom( 1, 3.0 ), " " ); + double three = 3.0; + printf( "mathmap fwd %.17g\n", astRate( tm, &three, 1, 1 ) ); + failed(); + } + + /* Equality. */ + head( "equal" ); + { + AstTranMap *a = astTranMap( zoom( 1, 2.0 ), zoom( 1, 3.0 ), " " ); + AstTranMap *b = astTranMap( zoom( 1, 2.0 ), zoom( 1, 3.0 ), " " ); + AstTranMap *c = astTranMap( zoom( 1, 2.0 ), zoom( 1, 4.0 ), " " ); + AstTranMap *d = astTranMap( inv( (AstMapping *) zoom( 1, 3.0 ) ), + inv( (AstMapping *) zoom( 1, 2.0 ) ), " " ); + AstTranMap *ainv = astCopy( a ); + astInvert( ainv ); + printf( "same_components %d\n", astEqual( a, b ) ); + printf( "different_components %d\n", astEqual( a, c ) ); + printf( "inverted_vs_swapped %d\n", astEqual( ainv, d ) ); + printf( "swapped_vs_inverted %d\n", astEqual( d, ainv ) ); + printf( "not_a_tranmap %d\n", astEqual( a, zoom( 1, 2.0 ) ) ); + printf( "inverted_vs_plain %d\n", astEqual( ainv, a ) ); + AstZoomMap *z2 = zoom( 1, 2.0 ); + AstZoomMap *z3 = zoom( 1, 3.0 ); + AstTranMap *e = astTranMap( z2, z3, " " ); + astInvert( z2 ); + printf( "component_inverted_after %d\n", astEqual( e, a ) ); + failed(); + } + + /* Decomposition: the series flag is left as the caller set it. */ + head( "decompose" ); + { + AstShiftMap *s; + double shift = 1.0; + s = astShiftMap( 1, &shift, " " ); + astInvert( s ); + AstTranMap *t = astTranMap( zoom( 1, 2.0 ), s, " " ); + AstMapping *m1, *m2; + int series = 7, i1 = 7, i2 = 7; + astDecompose( t, &m1, &m2, &series, &i1, &i2 ); + printf( "forward %s %s series %d inverts %d %d\n", astGetC( m1, "Class" ), astGetC( m2, "Class" ), + series, i1, i2 ); + astInvert( t ); + series = 7; + astDecompose( t, &m1, &m2, &series, &i1, &i2 ); + printf( "inverted %s %s series %d inverts %d %d\n", astGetC( m1, "Class" ), astGetC( m2, "Class" ), + series, i1, i2 ); + failed(); + } + + /* Splits. */ + { + double fs[] = { 10.0, 20.0, 30.0 }; + double is[] = { -10.0, -20.0, -30.0 }; + AstShiftMap *f = astShiftMap( 3, fs, " " ); + AstShiftMap *i = astShiftMap( 3, is, " " ); + astInvert( i ); + AstTranMap *t = astTranMap( f, i, " " ); + int in[] = { 2 }; + int out[ 3 ]; + AstMapping *split; + head( "split_shiftmaps" ); + astMapSplit( t, 1, in, out, &split ); + if( !failed() && split ) { + printf( "outputs %d\n", out[ 0 ] ); + astShow( split ); + } + head( "split_inverted" ); + astInvert( t ); + int in2[] = { 3, 1 }; + astMapSplit( t, 2, in2, out, &split ); + if( !failed() && split ) { + printf( "outputs %d %d\n", out[ 0 ], out[ 1 ] ); + astShow( split ); + } + head( "split_mismatched" ); + AstPermMap *p; + int perm[] = { 2, 1, 3 }; + p = astPermMap( 3, perm, 3, perm, NULL, " " ); + AstTranMap *tp = astTranMap( f, p, " " ); + int in3[] = { 1 }; + astMapSplit( tp, 1, in3, out, &split ); + if( !failed() ) printf( "split %s\n", split ? "made" : "none" ); + } + + /* Constructor errors. */ + head( "error_no_forward" ); + { + double coeff[] = { 1.0, 1.0, 1.0 }; + AstPolyMap *p = astPolyMap( 1, 1, 1, coeff, 0, NULL, "IterInverse=0" ); + astTranMap( inv( (AstMapping *) p ), zoom( 1, 2.0 ), " " ); + failed(); + head( "error_no_inverse" ); + AstPolyMap *q = astPolyMap( 1, 1, 1, coeff, 0, NULL, "IterInverse=0" ); + astTranMap( zoom( 1, 2.0 ), q, " " ); + failed(); + } + head( "error_nin" ); + astTranMap( zoom( 1, 2.0 ), zoom( 2, 3.0 ), " " ); + failed(); + head( "error_nout" ); + { + int outperm[] = { 1, 1 }; + int inperm[] = { 1 }; + AstPermMap *p = astPermMap( 1, inperm, 2, outperm, NULL, " " ); + astTranMap( zoom( 1, 2.0 ), p, " " ); + failed(); + } + head( "error_nin_equal_nout" ); + { + int outperm[] = { 1 }; + int inperm[] = { 1, 1 }; + AstPermMap *p = astPermMap( 2, inperm, 1, outperm, NULL, " " ); + astTranMap( p, zoom( 1, 2.0 ), " " ); + failed(); + } + + astEnd; + return 0; +} diff --git a/src/test/resources/probes/tranmap_probe.out b/src/test/resources/probes/tranmap_probe.out new file mode 100644 index 0000000..5a1d034 --- /dev/null +++ b/src/test/resources/probes/tranmap_probe.out @@ -0,0 +1,930 @@ +== dump_plain + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap +-- read back + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap +-- transformations +fwd 6 -> 12 +inv 6 -> 2 +-- transformations read back +fwd 6 -> 12 +inv 6 -> 2 +== dump_inva + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap +-- read back + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap +-- transformations +fwd 6 -> 3 +inv 6 -> 2 +-- transformations read back +fwd 6 -> 3 +inv 6 -> 2 +== dump_invb + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap +-- read back + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap +-- transformations +fwd 6 -> 12 +inv 6 -> 18 +-- transformations read back +fwd 6 -> 12 +inv 6 -> 18 +== dump_both_inverted + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + InvB = 1 # Second Mapping used in inverse direction + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap +-- read back + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + InvB = 1 # Second Mapping used in inverse direction + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap +-- transformations +fwd 6 -> 3 +inv 6 -> 18 +-- transformations read back +fwd 6 -> 3 +inv 6 -> 18 +== dump_tranmap_inverted + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap +-- read back + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap +-- transformations +fwd 6 -> 2 +inv 6 -> 12 +-- transformations read back +fwd 6 -> 2 +inv 6 -> 12 +== dump_components_inverted_after + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap +-- read back + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap +-- transformations +fwd 6 -> 12 +inv 6 -> 2 +-- transformations read back +fwd 6 -> 12 +inv 6 -> 2 +== dump_lutmap_mathmap + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements + Start = 1 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + MapB = # Mapping for inverse transformation + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*x" # Forward function 1 + Inv1 = "x=sqrt(y)" # Inverse function 1 + End MathMap + End TranMap +-- read back + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements + Start = 1 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + MapB = # Mapping for inverse transformation + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*x" # Forward function 1 + Inv1 = "x=sqrt(y)" # Inverse function 1 + End MathMap + End TranMap +-- transformations +fwd 2.5 -> 2.5 +inv 2.5 -> 1.5811388300841898 +-- transformations read back +fwd 2.5 -> 2.5 +inv 2.5 -> 1.5811388300841898 +== dump_lutmap_mathmap_inverted + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + InvB = 1 # Second Mapping used in inverse direction + MapA = # Mapping for forward transformation + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*x" # Forward function 1 + Inv1 = "x=sqrt(y)" # Inverse function 1 + End MathMap + MapB = # Mapping for inverse transformation + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements + Start = 1 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + End TranMap +-- read back + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvA = 1 # First Mapping used in inverse direction + InvB = 1 # Second Mapping used in inverse direction + MapA = # Mapping for forward transformation + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*x" # Forward function 1 + Inv1 = "x=sqrt(y)" # Inverse function 1 + End MathMap + MapB = # Mapping for inverse transformation + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements + Start = 1 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + End TranMap +-- transformations +fwd 2.5 -> 1.5811388300841898 +inv 2.5 -> 2.5 +-- transformations read back +fwd 2.5 -> 1.5811388300841898 +inv 2.5 -> 2.5 +== simp_plain +class TranMap + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap +-- transformations +fwd 6 -> 12 +inv 6 -> 2 +-- transformations simplified +fwd 6 -> 12 +inv 6 -> 2 +== simp_inverted +class TranMap + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 0.33333333333333331 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 0.5 # Zoom factor + End ZoomMap + End TranMap +-- transformations +fwd 6 -> 2 +inv 6 -> 12 +-- transformations simplified +fwd 6 -> 2 +inv 6 -> 12 +== simp_equal +class ZoomMap + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap +-- transformations +fwd 6 -> 12 +inv 6 -> 3 +-- transformations simplified +fwd 6 -> 12 +inv 6 -> 3 +== simp_equal_inverted_components +class ZoomMap + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 0.5 # Zoom factor + End ZoomMap +-- transformations +fwd 6 -> 3 +inv 6 -> 12 +-- transformations simplified +fwd 6 -> 3 +inv 6 -> 12 +== simp_equal_inverted_tranmap +class ZoomMap + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 0.5 # Zoom factor + End ZoomMap +-- transformations +fwd 6 -> 3 +inv 6 -> 12 +-- transformations simplified +fwd 6 -> 3 +inv 6 -> 12 +== simp_same_object +class TranMap + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + End TranMap +-- transformations +fwd 6 -> 12 +inv 6 -> 3 +-- transformations simplified +fwd 6 -> 12 +inv 6 -> 3 +== simp_equal_lutmaps +class LutMap + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements + Start = 1 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap +-- transformations +fwd 2.5 -> 2.5 +inv 2.5 -> 2.5 +-- transformations simplified +fwd 2.5 -> 2.5 +inv 2.5 -> 2.5 +== simp_equal_mathmaps +class MathMap + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*x" # Forward function 1 + Inv1 = "x=sqrt(y)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap +-- transformations +fwd 2.5 -> 6.25 +inv 2.5 -> 1.5811388300841898 +-- transformations simplified +fwd 2.5 -> 6.25 +inv 2.5 -> 1.5811388300841898 +== simp_equal_inverted_mathmaps +class MathMap + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*x" # Forward function 1 + Inv1 = "x=sqrt(y)" # Inverse function 1 + SimpFI = 1 # Forward-inverse pairs may simplify + SimpIF = 1 # Inverse-forward pairs may simplify + End MathMap +-- transformations +fwd 2.5 -> 1.5811388300841898 +inv 2.5 -> 6.25 +-- transformations simplified +fwd 2.5 -> 6.25 +inv 2.5 -> 1.5811388300841898 +== simp_equal_inverted_lutmaps +class LutMap + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements + Start = 1 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap +-- transformations +fwd 2.5 -> 2.5 +inv 2.5 -> 2.5 +fwd 3 -> 2.6666666666666665 +inv 3 -> 4 +-- transformations simplified +fwd 2.5 -> 2.5 +inv 2.5 -> 2.5 +fwd 3 -> 4 +inv 3 -> 2.6666666666666665 +== simp_unequal_mathmaps +class TranMap + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*x" # Forward function 1 + Inv1 = "x=sqrt(y)" # Inverse function 1 + End MathMap + MapB = # Mapping for inverse transformation + Begin MathMap # Transformation using mathematical functions + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Fwd1 = "y=x*x" # Forward function 1 + Inv1 = "x=sqrt(y)" # Inverse function 1 + End MathMap + End TranMap +-- transformations +fwd 2.5 -> 6.25 +inv 2.5 -> 1.5811388300841898 +-- transformations simplified +fwd 2.5 -> 6.25 +inv 2.5 -> 1.5811388300841898 +== simp_lutmap_beside_its_inverse +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements + Start = 1 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap + MapB = # Second component Mapping + Begin LutMap # Map 1-d coordinates using a lookup table + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Nlut = 5 # Number of lookup table elements + Start = 1 # Input value at first element +# Incr = 1 # Input value increment between elements + LutInt = 0 # Interpolation method + L1 = 0 # Lookup table elements... + L2 = 1 + L3 = 4 + L4 = 9 + L5 = 16 + End LutMap + End CmpMap +-- transformations +fwd 2.5 -> 2.5 +inv 2.5 -> 0.83333333333333326 +-- transformations simplified +fwd 2.5 -> 2.5 +inv 2.5 -> 0.83333333333333326 +== simp_beside_zoommap +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap + MapB = # Second component Mapping + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Zoom = 4 # Zoom factor + End ZoomMap + End CmpMap +-- transformations +fwd 6 -> 48 +inv 6 -> 0.5 +-- transformations simplified +fwd 6 -> 48 +inv 6 -> 0.5 +== simp_pair_second_inverted +class TranMap + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 0.2857142857142857 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 0.59999999999999998 # Zoom factor + End ZoomMap + End TranMap +-- transformations +fwd 6 -> 1.7142857142857142 +inv 6 -> 10 +-- transformations simplified +fwd 6 -> 1.7142857142857142 +inv 6 -> 10 +== simp_pair_inverted_series +class TranMap + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 0.047619047619047616 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 0.10000000000000001 # Zoom factor + End ZoomMap + End TranMap +-- transformations +fwd 6 -> 0.2857142857142857 +inv 6 -> 60 +-- transformations simplified +fwd 6 -> 0.2857142857142857 +inv 6 -> 60 +== simp_pair_parallel +class CmpMap + Begin CmpMap # Compound Mapping + Nin = 2 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Series = 0 # Component Mappings applied in parallel + MapA = # First component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 2 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 3 # Zoom factor + End ZoomMap + End TranMap + MapB = # Second component Mapping + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 5 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 7 # Zoom factor + End ZoomMap + End TranMap + End CmpMap +-- transformations +-- transformations simplified +== simp_pair_shared_tranmap +class TranMap + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + MapA = # Mapping for forward transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 4 # Zoom factor + End ZoomMap + MapB = # Mapping for inverse transformation + Begin ZoomMap # Zoom about the origin + Nin = 1 # Number of input coordinates + IsSimp = 1 # Mapping has been simplified + IsA Mapping # Mapping between coordinate systems + Zoom = 9 # Zoom factor + End ZoomMap + End TranMap +-- transformations +fwd 6 -> 24 +inv 6 -> 0.66666666666666663 +-- transformations simplified +fwd 6 -> 24 +inv 6 -> 0.66666666666666663 +== rates +fwd 1 1 2 +fwd 1 2 0 +fwd 2 1 0 +fwd 2 2 2 +inv 1 1 2 +inv 1 2 0 +inv 2 1 0 +inv 2 2 2 +zoom fwd 2 +zoom inv 0.33333333333333331 +mathmap fwd 6 +== equal +same_components 1 +different_components 0 +inverted_vs_swapped 1 +swapped_vs_inverted 1 +not_a_tranmap 0 +inverted_vs_plain 0 +component_inverted_after 1 +== decompose +forward ZoomMap ShiftMap series 7 inverts 0 1 +inverted ShiftMap ZoomMap series 7 inverts 0 1 +== split_shiftmaps +outputs 2 + Begin TranMap # Compound Transformation Mapping + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # Mapping for forward transformation + Begin ShiftMap # Shift each coordinate axis + Nin = 1 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = 20 # Shift for axis 1 + End ShiftMap + MapB = # Mapping for inverse transformation + Begin ShiftMap # Shift each coordinate axis + Nin = 1 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Sft1 = -20 # Shift for axis 1 + End ShiftMap + End TranMap +== split_inverted +outputs 3 1 + Begin TranMap # Compound Transformation Mapping + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + InvB = 1 # Second Mapping used in inverse direction + MapA = # Mapping for forward transformation + Begin ShiftMap # Shift each coordinate axis + Nin = 2 # Number of input coordinates + IsA Mapping # Mapping between coordinate systems + Sft1 = -30 # Shift for axis 1 + Sft2 = -10 # Shift for axis 2 + End ShiftMap + MapB = # Mapping for inverse transformation + Begin ShiftMap # Shift each coordinate axis + Nin = 2 # Number of input coordinates + Invert = 1 # Mapping inverted + IsA Mapping # Mapping between coordinate systems + Sft1 = 30 # Shift for axis 1 + Sft2 = 10 # Shift for axis 2 + End ShiftMap + End TranMap +== split_mismatched +split none +== error_no_forward +!! AST: Error in routine zoom at line 113 in file tranmap_probe.c. +! astInitTranMap(TranMap): The first supplied Mapping is not able to transform coordinates in the forward direction. +status 233933418 +== error_no_inverse +!! AST: Error in routine zoom at line 113 in file tranmap_probe.c. +! astInitTranMap(TranMap): The second supplied Mapping is not able to transform coordinates in the inverse direction. +status 233933418 +== error_nin +!! AST: Error in routine zoom at line 113 in file tranmap_probe.c. +! astInitTranMap(TranMap): The number of output coordinates per point (1) for the first Mapping supplied does not match the number of output coordinates (2) for the second Mapping. +status 233933402 +== error_nout +!! AST: Error in routine zoom at line 113 in file tranmap_probe.c. +! astInitTranMap(TranMap): The number of output coordinates per point (1) for the first Mapping supplied does not match the number of output coordinates (2) for the second Mapping. +status 233933402 +== error_nin_equal_nout +!! AST: Error in routine zoom at line 113 in file tranmap_probe.c. +! astInitTranMap(TranMap): The number of input coordinates per point (2) for the first Mapping supplied does not match the number of input coordinates (1) for the second Mapping. +status 233933402