diff-grok 1.0.10 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +11 -0
- package/.claude/skills/license-updater/SKILL.md +149 -0
- package/.claude/skills/license-updater/references/compatibility.md +68 -0
- package/.claude/skills/license-updater/references/templates.md +151 -0
- package/.claude/skills/license-updater/scripts/generate_license_files.py +467 -0
- package/CLAUDE.md +104 -0
- package/LICENSE +1 -1
- package/README.MD +121 -27
- package/THIRD_PARTY_LICENSES +135 -0
- package/docs/assets/hierarchy.js +1 -1
- package/docs/assets/navigation.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/BasicModelPipelineCreator.html +4 -4
- package/docs/classes/Callback.html +5 -5
- package/docs/classes/CyclicModelPipelineCreator.html +4 -4
- package/docs/classes/IterCheckerCallback.html +5 -5
- package/docs/classes/PipelineCreator.html +4 -4
- package/docs/classes/TimeCheckerCallback.html +5 -5
- package/docs/classes/UpdatesModelPipelineCreator.html +4 -4
- package/docs/functions/ab4.html +8 -0
- package/docs/functions/ab5.html +8 -0
- package/docs/functions/applyPipeline.html +2 -2
- package/docs/functions/getCallback.html +2 -2
- package/docs/functions/getIVP.html +2 -2
- package/docs/functions/getInputVector.html +2 -2
- package/docs/functions/getIvp2WebWorker.html +2 -2
- package/docs/functions/getJScode.html +2 -2
- package/docs/functions/getOutputNames.html +2 -2
- package/docs/functions/getPipelineCreator.html +2 -2
- package/docs/functions/lsoda.html +8 -0
- package/docs/functions/mrt.html +2 -2
- package/docs/functions/printE5.html +2 -2
- package/docs/functions/printHires.html +2 -2
- package/docs/functions/printOrego.html +2 -2
- package/docs/functions/printPollution.html +2 -2
- package/docs/functions/printRobertson.html +2 -2
- package/docs/functions/printVdpol.html +2 -2
- package/docs/functions/rk3.html +8 -0
- package/docs/functions/rk4.html +8 -0
- package/docs/functions/rkdp.html +8 -0
- package/docs/functions/ros34prw.html +2 -2
- package/docs/functions/ros3prw.html +2 -2
- package/docs/functions/solveIvp.html +2 -2
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +100 -15
- package/docs/media/E5.png +0 -0
- package/docs/media/HIRES.png +0 -0
- package/docs/media/OREGO.png +0 -0
- package/docs/media/POLL-full.png +0 -0
- package/docs/media/ROBER.png +0 -0
- package/docs/media/VDP0L.png +0 -0
- package/docs/media/cyclic-model.js +3 -1
- package/docs/media/cyclic-model.js.map +1 -1
- package/docs/media/cyclic-model.ts +3 -1
- package/docs/modules.html +1 -1
- package/docs/types/Arg.html +7 -7
- package/docs/types/DifEqs.html +4 -4
- package/docs/types/Func.html +2 -2
- package/docs/types/IVP.html +20 -20
- package/docs/types/IVP2WebWorker.html +7 -7
- package/docs/types/Input.html +4 -4
- package/docs/types/Loop.html +4 -4
- package/docs/types/ODEs.html +8 -8
- package/docs/types/Output.html +4 -4
- package/docs/types/Pipeline.html +4 -4
- package/docs/types/SolverOptions.html +5 -5
- package/docs/types/Update.html +5 -5
- package/docs/types/Wrapper.html +5 -5
- package/images/E5.png +0 -0
- package/images/HIRES.png +0 -0
- package/images/OREGO.png +0 -0
- package/images/POLL-full.png +0 -0
- package/images/ROBER.png +0 -0
- package/images/VDP0L.png +0 -0
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/index.ts +2 -1
- package/jest.config.js +1 -0
- package/package.json +4 -2
- package/src/examples/check-methods.js +15 -3
- package/src/examples/check-methods.js.map +1 -1
- package/src/examples/check-methods.ts +18 -3
- package/src/examples/cyclic-model.js +3 -1
- package/src/examples/cyclic-model.js.map +1 -1
- package/src/examples/cyclic-model.ts +3 -1
- package/src/solver-tools/ab4-method.js +332 -0
- package/src/solver-tools/ab4-method.js.map +1 -0
- package/src/solver-tools/ab4-method.ts +395 -0
- package/src/solver-tools/ab5-method.js +334 -0
- package/src/solver-tools/ab5-method.js.map +1 -0
- package/src/solver-tools/ab5-method.ts +397 -0
- package/src/solver-tools/cvode/common.js +487 -0
- package/src/solver-tools/cvode/common.js.map +1 -0
- package/src/solver-tools/cvode/common.ts +549 -0
- package/src/solver-tools/cvode/cvode.js +1062 -0
- package/src/solver-tools/cvode/cvode.js.map +1 -0
- package/src/solver-tools/cvode/cvode.ts +1226 -0
- package/src/solver-tools/cvode/cvode_adams.js +124 -0
- package/src/solver-tools/cvode/cvode_adams.js.map +1 -0
- package/src/solver-tools/cvode/cvode_adams.ts +142 -0
- package/src/solver-tools/cvode/cvode_bdf.js +153 -0
- package/src/solver-tools/cvode/cvode_bdf.js.map +1 -0
- package/src/solver-tools/cvode/cvode_bdf.ts +164 -0
- package/src/solver-tools/cvode/cvode_class.js +158 -0
- package/src/solver-tools/cvode/cvode_class.js.map +1 -0
- package/src/solver-tools/cvode/cvode_class.ts +271 -0
- package/src/solver-tools/cvode/cvode_hin.js +119 -0
- package/src/solver-tools/cvode/cvode_hin.js.map +1 -0
- package/src/solver-tools/cvode/cvode_hin.ts +150 -0
- package/src/solver-tools/cvode/cvode_io.js +203 -0
- package/src/solver-tools/cvode/cvode_io.js.map +1 -0
- package/src/solver-tools/cvode/cvode_io.ts +258 -0
- package/src/solver-tools/cvode/cvode_ls.js +210 -0
- package/src/solver-tools/cvode/cvode_ls.js.map +1 -0
- package/src/solver-tools/cvode/cvode_ls.ts +249 -0
- package/src/solver-tools/cvode/cvode_nls.js +220 -0
- package/src/solver-tools/cvode/cvode_nls.js.map +1 -0
- package/src/solver-tools/cvode/cvode_nls.ts +259 -0
- package/src/solver-tools/cvode/cvode_root.js +415 -0
- package/src/solver-tools/cvode/cvode_root.js.map +1 -0
- package/src/solver-tools/cvode/cvode_root.ts +503 -0
- package/src/solver-tools/cvode/dense_linalg.js +131 -0
- package/src/solver-tools/cvode/dense_linalg.js.map +1 -0
- package/src/solver-tools/cvode/dense_linalg.ts +144 -0
- package/src/solver-tools/cvode/index.js +26 -0
- package/src/solver-tools/cvode/index.js.map +1 -0
- package/src/solver-tools/cvode/index.ts +64 -0
- package/src/solver-tools/cvode-method.js +114 -0
- package/src/solver-tools/cvode-method.js.map +1 -0
- package/src/solver-tools/cvode-method.ts +129 -0
- package/src/solver-tools/index.js +7 -0
- package/src/solver-tools/index.js.map +1 -1
- package/src/solver-tools/index.ts +7 -0
- package/src/solver-tools/lsoda/blas.js +257 -0
- package/src/solver-tools/lsoda/blas.js.map +1 -0
- package/src/solver-tools/lsoda/blas.ts +279 -0
- package/src/solver-tools/lsoda/cfode.js +84 -0
- package/src/solver-tools/lsoda/cfode.js.map +1 -0
- package/src/solver-tools/lsoda/cfode.ts +95 -0
- package/src/solver-tools/lsoda/common.js +94 -0
- package/src/solver-tools/lsoda/common.js.map +1 -0
- package/src/solver-tools/lsoda/common.ts +135 -0
- package/src/solver-tools/lsoda/corfailure.js +36 -0
- package/src/solver-tools/lsoda/corfailure.js.map +1 -0
- package/src/solver-tools/lsoda/corfailure.ts +42 -0
- package/src/solver-tools/lsoda/correction.js +112 -0
- package/src/solver-tools/lsoda/correction.js.map +1 -0
- package/src/solver-tools/lsoda/correction.ts +131 -0
- package/src/solver-tools/lsoda/dense.js +121 -0
- package/src/solver-tools/lsoda/dense.js.map +1 -0
- package/src/solver-tools/lsoda/dense.ts +141 -0
- package/src/solver-tools/lsoda/index.js +15 -0
- package/src/solver-tools/lsoda/index.js.map +1 -0
- package/src/solver-tools/lsoda/index.ts +17 -0
- package/src/solver-tools/lsoda/intdy.js +54 -0
- package/src/solver-tools/lsoda/intdy.js.map +1 -0
- package/src/solver-tools/lsoda/intdy.ts +62 -0
- package/src/solver-tools/lsoda/lsoda.js +578 -0
- package/src/solver-tools/lsoda/lsoda.js.map +1 -0
- package/src/solver-tools/lsoda/lsoda.ts +644 -0
- package/src/solver-tools/lsoda/methodswitch.js +108 -0
- package/src/solver-tools/lsoda/methodswitch.js.map +1 -0
- package/src/solver-tools/lsoda/methodswitch.ts +119 -0
- package/src/solver-tools/lsoda/orderswitch.js +97 -0
- package/src/solver-tools/lsoda/orderswitch.js.map +1 -0
- package/src/solver-tools/lsoda/orderswitch.ts +107 -0
- package/src/solver-tools/lsoda/prja.js +54 -0
- package/src/solver-tools/lsoda/prja.js.map +1 -0
- package/src/solver-tools/lsoda/prja.ts +61 -0
- package/src/solver-tools/lsoda/scaleh.js +41 -0
- package/src/solver-tools/lsoda/scaleh.js.map +1 -0
- package/src/solver-tools/lsoda/scaleh.ts +45 -0
- package/src/solver-tools/lsoda/solsy.js +25 -0
- package/src/solver-tools/lsoda/solsy.js.map +1 -0
- package/src/solver-tools/lsoda/solsy.ts +30 -0
- package/src/solver-tools/lsoda/stoda.js +270 -0
- package/src/solver-tools/lsoda/stoda.js.map +1 -0
- package/src/solver-tools/lsoda/stoda.ts +298 -0
- package/src/solver-tools/lsoda-method.js +134 -0
- package/src/solver-tools/lsoda-method.js.map +1 -0
- package/src/solver-tools/lsoda-method.ts +154 -0
- package/src/solver-tools/mrt-method.js +81 -18
- package/src/solver-tools/mrt-method.js.map +1 -1
- package/src/solver-tools/mrt-method.ts +111 -21
- package/src/solver-tools/rk3-method.js +210 -0
- package/src/solver-tools/rk3-method.js.map +1 -0
- package/src/solver-tools/rk3-method.ts +257 -0
- package/src/solver-tools/rk4-method.js +236 -0
- package/src/solver-tools/rk4-method.js.map +1 -0
- package/src/solver-tools/rk4-method.ts +286 -0
- package/src/solver-tools/rkdp-method.js +247 -0
- package/src/solver-tools/rkdp-method.js.map +1 -0
- package/src/solver-tools/rkdp-method.ts +300 -0
- package/src/solver-tools/ros34prw-method.js +1 -1
- package/src/solver-tools/ros34prw-method.js.map +1 -1
- package/src/solver-tools/ros34prw-method.ts +1 -1
- package/src/solver-tools/ros3prw-method.js +1 -1
- package/src/solver-tools/ros3prw-method.js.map +1 -1
- package/src/solver-tools/ros3prw-method.ts +1 -1
- package/src/solver-tools/solver-defs.js +7 -0
- package/src/solver-tools/solver-defs.js.map +1 -1
- package/src/solver-tools/solver-defs.ts +7 -0
- package/src/tests/correctness.test.js +6 -4
- package/src/tests/correctness.test.js.map +1 -1
- package/src/tests/correctness.test.ts +6 -4
- package/src/tests/cvode-lib-correctness.test.js +404 -0
- package/src/tests/cvode-lib-correctness.test.js.map +1 -0
- package/src/tests/cvode-lib-correctness.test.ts +505 -0
- package/src/tests/cvode-lib-performance.test.js +103 -0
- package/src/tests/cvode-lib-performance.test.js.map +1 -0
- package/src/tests/cvode-lib-performance.test.ts +128 -0
- package/src/tests/lsoda-lib-correctness.test.js +223 -0
- package/src/tests/lsoda-lib-correctness.test.js.map +1 -0
- package/src/tests/lsoda-lib-correctness.test.ts +283 -0
- package/src/tests/lsoda-lib-performance.test.js +95 -0
- package/src/tests/lsoda-lib-performance.test.js.map +1 -0
- package/src/tests/lsoda-lib-performance.test.ts +126 -0
- package/src/tests/performance.test.js +12 -8
- package/src/tests/performance.test.js.map +1 -1
- package/src/tests/performance.test.ts +12 -8
- package/src/tests/test-defs.js +20 -1
- package/src/tests/test-defs.js.map +1 -1
- package/src/tests/test-defs.ts +22 -1
- package/src/worker-tools/solving.js +15 -1
- package/src/worker-tools/solving.js.map +1 -1
- package/src/worker-tools/solving.ts +23 -1
|
@@ -0,0 +1,467 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Generate license attribution files for ported third-party code.
|
|
3
|
+
|
|
4
|
+
This script produces three files:
|
|
5
|
+
1. THIRD_PARTY_LICENSES — for the repo root
|
|
6
|
+
2. HEADER_TEMPLATE.txt — comment block to prepend to each ported file
|
|
7
|
+
3. LICENSE_GUIDE.md — human-readable instructions
|
|
8
|
+
|
|
9
|
+
Usage:
|
|
10
|
+
python3 generate_license_files.py \
|
|
11
|
+
--license-type "MIT" \
|
|
12
|
+
--copyright-holders "Copyright (c) 2011 Foo;Copyright (c) 2020 Bar" \
|
|
13
|
+
--project-name "liblsoda" \
|
|
14
|
+
--project-url "https://github.com/sdwfrost/liblsoda" \
|
|
15
|
+
--ported-files-path "src/solver-tools/lsoda" \
|
|
16
|
+
--target-copyright "Copyright (c) 2025 Datagrok" \
|
|
17
|
+
--output-dir "./license-output"
|
|
18
|
+
|
|
19
|
+
Optional:
|
|
20
|
+
--provenance Semicolon-separated provenance chain
|
|
21
|
+
--description Brief description of what the ported code does
|
|
22
|
+
--license-text Full license text (if not a well-known SPDX type)
|
|
23
|
+
--target-license Target project license type (default: MIT)
|
|
24
|
+
--file-ext File extension for header comment style (default: ts)
|
|
25
|
+
--append If set, append to existing THIRD_PARTY_LICENSES
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
import argparse
|
|
29
|
+
import os
|
|
30
|
+
import sys
|
|
31
|
+
import textwrap
|
|
32
|
+
|
|
33
|
+
# Well-known license texts keyed by SPDX identifier
|
|
34
|
+
KNOWN_LICENSES = {
|
|
35
|
+
"MIT": textwrap.dedent("""\
|
|
36
|
+
The MIT License
|
|
37
|
+
|
|
38
|
+
{COPYRIGHT}
|
|
39
|
+
|
|
40
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
41
|
+
a copy of this software and associated documentation files (the
|
|
42
|
+
"Software"), to deal in the Software without restriction, including
|
|
43
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
44
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
45
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
46
|
+
the following conditions:
|
|
47
|
+
|
|
48
|
+
The above copyright notice and this permission notice shall be
|
|
49
|
+
included in all copies or substantial portions of the Software.
|
|
50
|
+
|
|
51
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
52
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
53
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
54
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
55
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
56
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
57
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE."""),
|
|
58
|
+
|
|
59
|
+
"BSD-2-Clause": textwrap.dedent("""\
|
|
60
|
+
BSD 2-Clause License
|
|
61
|
+
|
|
62
|
+
{COPYRIGHT}
|
|
63
|
+
|
|
64
|
+
Redistribution and use in source and binary forms, with or without
|
|
65
|
+
modification, are permitted provided that the following conditions are met:
|
|
66
|
+
|
|
67
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
68
|
+
this list of conditions and the following disclaimer.
|
|
69
|
+
|
|
70
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
71
|
+
this list of conditions and the following disclaimer in the documentation
|
|
72
|
+
and/or other materials provided with the distribution.
|
|
73
|
+
|
|
74
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
75
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
76
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
77
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
78
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
79
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
80
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
81
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
82
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
83
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."""),
|
|
84
|
+
|
|
85
|
+
"BSD-3-Clause": textwrap.dedent("""\
|
|
86
|
+
BSD 3-Clause License
|
|
87
|
+
|
|
88
|
+
{COPYRIGHT}
|
|
89
|
+
|
|
90
|
+
Redistribution and use in source and binary forms, with or without
|
|
91
|
+
modification, are permitted provided that the following conditions are met:
|
|
92
|
+
|
|
93
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
94
|
+
this list of conditions and the following disclaimer.
|
|
95
|
+
|
|
96
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
97
|
+
this list of conditions and the following disclaimer in the documentation
|
|
98
|
+
and/or other materials provided with the distribution.
|
|
99
|
+
|
|
100
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
101
|
+
contributors may be used to endorse or promote products derived from
|
|
102
|
+
this software without specific prior written permission.
|
|
103
|
+
|
|
104
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
105
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
106
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
107
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
108
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
109
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
110
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
111
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
112
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
113
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."""),
|
|
114
|
+
|
|
115
|
+
"Apache-2.0": textwrap.dedent("""\
|
|
116
|
+
Apache License, Version 2.0
|
|
117
|
+
|
|
118
|
+
{COPYRIGHT}
|
|
119
|
+
|
|
120
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
121
|
+
you may not use this file except in compliance with the License.
|
|
122
|
+
You may obtain a copy of the License at
|
|
123
|
+
|
|
124
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
125
|
+
|
|
126
|
+
Unless required by applicable law or agreed to in writing, software
|
|
127
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
128
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
129
|
+
See the License for the specific language governing permissions and
|
|
130
|
+
limitations under the License."""),
|
|
131
|
+
|
|
132
|
+
"ISC": textwrap.dedent("""\
|
|
133
|
+
ISC License
|
|
134
|
+
|
|
135
|
+
{COPYRIGHT}
|
|
136
|
+
|
|
137
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
138
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
139
|
+
copyright notice and this permission notice appear in all copies.
|
|
140
|
+
|
|
141
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
142
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
143
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
144
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
145
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
146
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
147
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE."""),
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
# Compatibility matrix: (upstream, target) -> compatible?
|
|
151
|
+
# True = compatible, False = incompatible, None = conditional
|
|
152
|
+
COMPAT = {
|
|
153
|
+
("MIT", "MIT"): True,
|
|
154
|
+
("MIT", "BSD-2-Clause"): True,
|
|
155
|
+
("MIT", "BSD-3-Clause"): True,
|
|
156
|
+
("MIT", "Apache-2.0"): True,
|
|
157
|
+
("BSD-2-Clause", "MIT"): True,
|
|
158
|
+
("BSD-2-Clause", "BSD-2-Clause"): True,
|
|
159
|
+
("BSD-2-Clause", "BSD-3-Clause"): True,
|
|
160
|
+
("BSD-2-Clause", "Apache-2.0"): True,
|
|
161
|
+
("BSD-3-Clause", "MIT"): True,
|
|
162
|
+
("BSD-3-Clause", "BSD-2-Clause"): True,
|
|
163
|
+
("BSD-3-Clause", "BSD-3-Clause"): True,
|
|
164
|
+
("BSD-3-Clause", "Apache-2.0"): True,
|
|
165
|
+
("Apache-2.0", "MIT"): True,
|
|
166
|
+
("Apache-2.0", "BSD-2-Clause"): True,
|
|
167
|
+
("Apache-2.0", "BSD-3-Clause"): True,
|
|
168
|
+
("Apache-2.0", "Apache-2.0"): True,
|
|
169
|
+
("ISC", "MIT"): True,
|
|
170
|
+
("ISC", "BSD-2-Clause"): True,
|
|
171
|
+
("ISC", "BSD-3-Clause"): True,
|
|
172
|
+
("ISC", "Apache-2.0"): True,
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
COMMENT_STYLES = {
|
|
176
|
+
"ts": ("/**", " *", " */"),
|
|
177
|
+
"js": ("/**", " *", " */"),
|
|
178
|
+
"tsx": ("/**", " *", " */"),
|
|
179
|
+
"jsx": ("/**", " *", " */"),
|
|
180
|
+
"py": ("#", "#", "#"),
|
|
181
|
+
"c": ("/*", " *", " */"),
|
|
182
|
+
"cpp": ("/*", " *", " */"),
|
|
183
|
+
"h": ("/*", " *", " */"),
|
|
184
|
+
"rs": ("//!", "//!", "//!"),
|
|
185
|
+
"go": ("//", "//", "//"),
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def parse_list(value: str) -> list[str]:
|
|
190
|
+
"""Split a semicolon-separated string into a list of stripped items."""
|
|
191
|
+
if not value:
|
|
192
|
+
return []
|
|
193
|
+
return [item.strip() for item in value.split(";") if item.strip()]
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
def get_license_text(license_type: str, copyright_holders: list[str],
|
|
197
|
+
custom_text: str | None = None) -> str:
|
|
198
|
+
"""Return the full license text with copyright holders inserted."""
|
|
199
|
+
if custom_text:
|
|
200
|
+
return custom_text
|
|
201
|
+
|
|
202
|
+
template = KNOWN_LICENSES.get(license_type)
|
|
203
|
+
if not template:
|
|
204
|
+
return (f"[License text for {license_type} not available.\n"
|
|
205
|
+
f"Please paste the full license text here manually.]")
|
|
206
|
+
|
|
207
|
+
copyright_block = "\n".join(copyright_holders)
|
|
208
|
+
return template.replace("{COPYRIGHT}", copyright_block)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def check_compatibility(upstream: str, target: str) -> tuple[bool, str]:
|
|
212
|
+
"""Check license compatibility and return (ok, message)."""
|
|
213
|
+
key = (upstream, target)
|
|
214
|
+
if key in COMPAT:
|
|
215
|
+
if COMPAT[key]:
|
|
216
|
+
return True, f"{upstream} is compatible with {target}."
|
|
217
|
+
else:
|
|
218
|
+
return False, (f"⚠️ {upstream} is NOT compatible with {target}. "
|
|
219
|
+
f"The ported code cannot be included under {target}.")
|
|
220
|
+
|
|
221
|
+
# Assume copyleft is incompatible with permissive
|
|
222
|
+
copyleft = {"GPL-2.0-only", "GPL-3.0-only", "AGPL-3.0-only",
|
|
223
|
+
"GPL-2.0-or-later", "GPL-3.0-or-later", "AGPL-3.0-or-later"}
|
|
224
|
+
if upstream in copyleft:
|
|
225
|
+
return False, (f"⚠️ {upstream} is copyleft and cannot be included "
|
|
226
|
+
f"in a {target} project without the entire project "
|
|
227
|
+
f"adopting {upstream}.")
|
|
228
|
+
|
|
229
|
+
return True, (f"Compatibility between {upstream} and {target} is not in "
|
|
230
|
+
f"the built-in matrix. Manual review recommended.")
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
def generate_third_party(args, copyright_holders: list[str],
|
|
234
|
+
provenance: list[str]) -> str:
|
|
235
|
+
"""Generate the THIRD_PARTY_LICENSES content."""
|
|
236
|
+
lines = []
|
|
237
|
+
lines.append("Third-Party Licenses")
|
|
238
|
+
lines.append("=" * 20)
|
|
239
|
+
lines.append("")
|
|
240
|
+
lines.append("This file documents the licenses for third-party code included in or adapted")
|
|
241
|
+
lines.append("by this project.")
|
|
242
|
+
lines.append("")
|
|
243
|
+
lines.append("")
|
|
244
|
+
lines.append("=" * 80)
|
|
245
|
+
lines.append(f"{args.project_name}")
|
|
246
|
+
lines.append("=" * 80)
|
|
247
|
+
lines.append("")
|
|
248
|
+
lines.append(f"Source: {args.project_url}")
|
|
249
|
+
lines.append(f"License: {args.license_type}")
|
|
250
|
+
lines.append(f"Files: {args.ported_files_path}")
|
|
251
|
+
lines.append("")
|
|
252
|
+
|
|
253
|
+
if args.description:
|
|
254
|
+
lines.append(args.description)
|
|
255
|
+
lines.append("")
|
|
256
|
+
|
|
257
|
+
if provenance:
|
|
258
|
+
lines.append("Provenance chain:")
|
|
259
|
+
lines.append("")
|
|
260
|
+
for i, step in enumerate(provenance, 1):
|
|
261
|
+
lines.append(f" {i}. {step}")
|
|
262
|
+
lines.append("")
|
|
263
|
+
|
|
264
|
+
license_text = get_license_text(
|
|
265
|
+
args.license_type, copyright_holders, args.license_text
|
|
266
|
+
)
|
|
267
|
+
lines.append(license_text)
|
|
268
|
+
lines.append("")
|
|
269
|
+
|
|
270
|
+
return "\n".join(lines)
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def generate_header(args, copyright_holders: list[str]) -> str:
|
|
274
|
+
"""Generate the header template for ported files."""
|
|
275
|
+
ext = args.file_ext
|
|
276
|
+
start, mid, end = COMMENT_STYLES.get(ext, ("/**", " *", " */"))
|
|
277
|
+
|
|
278
|
+
lines = []
|
|
279
|
+
lines.append(start)
|
|
280
|
+
|
|
281
|
+
if args.description:
|
|
282
|
+
lines.append(f"{mid} {args.description}")
|
|
283
|
+
lines.append(f"{mid}")
|
|
284
|
+
|
|
285
|
+
lines.append(f"{mid} Port of {args.project_name} ({args.project_url})")
|
|
286
|
+
lines.append(f"{mid}")
|
|
287
|
+
|
|
288
|
+
for holder in copyright_holders:
|
|
289
|
+
lines.append(f"{mid} {holder}")
|
|
290
|
+
if args.target_copyright:
|
|
291
|
+
lines.append(f"{mid} {args.target_copyright}")
|
|
292
|
+
|
|
293
|
+
lines.append(f"{mid}")
|
|
294
|
+
lines.append(f"{mid} Licensed under the {args.license_type} License.")
|
|
295
|
+
lines.append(f"{mid} See THIRD_PARTY_LICENSES for the full license text and provenance.")
|
|
296
|
+
lines.append(end)
|
|
297
|
+
lines.append("")
|
|
298
|
+
|
|
299
|
+
return "\n".join(lines)
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def generate_guide(args, copyright_holders: list[str],
|
|
303
|
+
compat_ok: bool, compat_msg: str) -> str:
|
|
304
|
+
"""Generate the LICENSE_GUIDE.md content."""
|
|
305
|
+
status = "✅ Compatible" if compat_ok else "❌ Incompatible"
|
|
306
|
+
target_lic = args.target_license
|
|
307
|
+
|
|
308
|
+
lines = []
|
|
309
|
+
lines.append(f"# License Attribution Guide for {args.project_name}")
|
|
310
|
+
lines.append("")
|
|
311
|
+
lines.append("## File structure")
|
|
312
|
+
lines.append("")
|
|
313
|
+
lines.append("```")
|
|
314
|
+
lines.append("your-repo/")
|
|
315
|
+
lines.append("├── LICENSE ← do not modify")
|
|
316
|
+
lines.append("├── THIRD_PARTY_LICENSES ← add/update this file")
|
|
317
|
+
|
|
318
|
+
# Show the ported files path
|
|
319
|
+
parts = args.ported_files_path.split("/")
|
|
320
|
+
indent = "│ "
|
|
321
|
+
for i, part in enumerate(parts[:-1]):
|
|
322
|
+
lines.append(f"{indent}└── {part}/")
|
|
323
|
+
indent += " "
|
|
324
|
+
lines.append(f"{indent}└── {parts[-1]}/")
|
|
325
|
+
lines.append(f"{indent} └── *.{args.file_ext} ← add header to each file")
|
|
326
|
+
|
|
327
|
+
lines.append("```")
|
|
328
|
+
lines.append("")
|
|
329
|
+
lines.append("## Steps")
|
|
330
|
+
lines.append("")
|
|
331
|
+
lines.append("### 1. Add `THIRD_PARTY_LICENSES` to the repository root")
|
|
332
|
+
lines.append("")
|
|
333
|
+
|
|
334
|
+
if args.append:
|
|
335
|
+
lines.append("Append the provided section to your existing `THIRD_PARTY_LICENSES` file.")
|
|
336
|
+
else:
|
|
337
|
+
lines.append("Place the provided `THIRD_PARTY_LICENSES` file next to your existing `LICENSE`.")
|
|
338
|
+
|
|
339
|
+
lines.append("")
|
|
340
|
+
lines.append(f"### 2. Add header to each `.{args.file_ext}` file in `{args.ported_files_path}/`")
|
|
341
|
+
lines.append("")
|
|
342
|
+
lines.append("Prepend the content of `HEADER_TEMPLATE.txt` to the top of every")
|
|
343
|
+
lines.append(f"`.{args.file_ext}` file in the `{args.ported_files_path}/` directory.")
|
|
344
|
+
lines.append("")
|
|
345
|
+
lines.append("### 3. `LICENSE` — no changes needed")
|
|
346
|
+
lines.append("")
|
|
347
|
+
lines.append(f"Your project license ({target_lic}) stays as-is.")
|
|
348
|
+
lines.append("`THIRD_PARTY_LICENSES` handles attribution for ported code separately.")
|
|
349
|
+
lines.append("")
|
|
350
|
+
lines.append("### 4. README — optional")
|
|
351
|
+
lines.append("")
|
|
352
|
+
lines.append("Consider adding a note in your README's License section:")
|
|
353
|
+
lines.append("")
|
|
354
|
+
lines.append("```markdown")
|
|
355
|
+
lines.append("## License")
|
|
356
|
+
lines.append("")
|
|
357
|
+
lines.append(f"This project is licensed under the [{target_lic} License](LICENSE).")
|
|
358
|
+
lines.append("")
|
|
359
|
+
lines.append(f"Some components are ported from [{args.project_name}]({args.project_url}).")
|
|
360
|
+
lines.append("See [THIRD_PARTY_LICENSES](THIRD_PARTY_LICENSES) for details.")
|
|
361
|
+
lines.append("```")
|
|
362
|
+
lines.append("")
|
|
363
|
+
lines.append("## Compatibility check")
|
|
364
|
+
lines.append("")
|
|
365
|
+
lines.append(f"- Upstream license: **{args.license_type}**")
|
|
366
|
+
lines.append(f"- Target license: **{target_lic}**")
|
|
367
|
+
lines.append(f"- Status: {status}")
|
|
368
|
+
lines.append("")
|
|
369
|
+
lines.append(compat_msg)
|
|
370
|
+
|
|
371
|
+
# Special notes
|
|
372
|
+
if args.license_type == "BSD-3-Clause":
|
|
373
|
+
lines.append("")
|
|
374
|
+
lines.append("### BSD-3-Clause special condition")
|
|
375
|
+
lines.append("")
|
|
376
|
+
lines.append("You may NOT use the names of the original copyright holders")
|
|
377
|
+
lines.append("to endorse or promote your product without their written permission.")
|
|
378
|
+
|
|
379
|
+
if args.license_type == "Apache-2.0":
|
|
380
|
+
lines.append("")
|
|
381
|
+
lines.append("### Apache-2.0 special conditions")
|
|
382
|
+
lines.append("")
|
|
383
|
+
lines.append("- The patent grant from Apache-2.0 applies to the ported code")
|
|
384
|
+
lines.append("- If the upstream repo has a NOTICE file, its contents must be preserved")
|
|
385
|
+
lines.append("- You must state significant changes made to the ported files")
|
|
386
|
+
|
|
387
|
+
lines.append("")
|
|
388
|
+
return "\n".join(lines)
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
def main():
|
|
392
|
+
parser = argparse.ArgumentParser(
|
|
393
|
+
description="Generate license attribution files for ported code."
|
|
394
|
+
)
|
|
395
|
+
parser.add_argument("--license-type", required=True,
|
|
396
|
+
help="SPDX license identifier (e.g., MIT, BSD-3-Clause)")
|
|
397
|
+
parser.add_argument("--copyright-holders", required=True,
|
|
398
|
+
help="Semicolon-separated copyright lines")
|
|
399
|
+
parser.add_argument("--project-name", required=True,
|
|
400
|
+
help="Name of the upstream project")
|
|
401
|
+
parser.add_argument("--project-url", required=True,
|
|
402
|
+
help="URL to the upstream project")
|
|
403
|
+
parser.add_argument("--ported-files-path", required=True,
|
|
404
|
+
help="Relative path in target repo to ported files")
|
|
405
|
+
parser.add_argument("--target-copyright", default="",
|
|
406
|
+
help="Copyright line for the target project")
|
|
407
|
+
parser.add_argument("--target-license", default="MIT",
|
|
408
|
+
help="Target project license (default: MIT)")
|
|
409
|
+
parser.add_argument("--provenance", default="",
|
|
410
|
+
help="Semicolon-separated provenance chain")
|
|
411
|
+
parser.add_argument("--description", default="",
|
|
412
|
+
help="Brief description of the ported code")
|
|
413
|
+
parser.add_argument("--license-text", default=None,
|
|
414
|
+
help="Full custom license text (if not a known SPDX type)")
|
|
415
|
+
parser.add_argument("--file-ext", default="ts",
|
|
416
|
+
help="File extension for comment style (default: ts)")
|
|
417
|
+
parser.add_argument("--output-dir", default="./license-output",
|
|
418
|
+
help="Output directory for generated files")
|
|
419
|
+
parser.add_argument("--append", action="store_true",
|
|
420
|
+
help="Append to existing THIRD_PARTY_LICENSES")
|
|
421
|
+
|
|
422
|
+
args = parser.parse_args()
|
|
423
|
+
|
|
424
|
+
copyright_holders = parse_list(args.copyright_holders)
|
|
425
|
+
provenance = parse_list(args.provenance)
|
|
426
|
+
|
|
427
|
+
if not copyright_holders:
|
|
428
|
+
print("Error: at least one copyright holder is required.", file=sys.stderr)
|
|
429
|
+
sys.exit(1)
|
|
430
|
+
|
|
431
|
+
# Check compatibility
|
|
432
|
+
compat_ok, compat_msg = check_compatibility(args.license_type, args.target_license)
|
|
433
|
+
if not compat_ok:
|
|
434
|
+
print(f"\n⚠️ LICENSE COMPATIBILITY WARNING:\n{compat_msg}\n", file=sys.stderr)
|
|
435
|
+
print("Files will still be generated, but review carefully before using.",
|
|
436
|
+
file=sys.stderr)
|
|
437
|
+
|
|
438
|
+
# Create output directory
|
|
439
|
+
os.makedirs(args.output_dir, exist_ok=True)
|
|
440
|
+
|
|
441
|
+
# Generate files
|
|
442
|
+
third_party = generate_third_party(args, copyright_holders, provenance)
|
|
443
|
+
header = generate_header(args, copyright_holders)
|
|
444
|
+
guide = generate_guide(args, copyright_holders, compat_ok, compat_msg)
|
|
445
|
+
|
|
446
|
+
# Write files
|
|
447
|
+
tp_path = os.path.join(args.output_dir, "THIRD_PARTY_LICENSES")
|
|
448
|
+
with open(tp_path, "w") as f:
|
|
449
|
+
f.write(third_party)
|
|
450
|
+
print(f"✅ Created: {tp_path}")
|
|
451
|
+
|
|
452
|
+
header_path = os.path.join(args.output_dir, "HEADER_TEMPLATE.txt")
|
|
453
|
+
with open(header_path, "w") as f:
|
|
454
|
+
f.write(header)
|
|
455
|
+
print(f"✅ Created: {header_path}")
|
|
456
|
+
|
|
457
|
+
guide_path = os.path.join(args.output_dir, "LICENSE_GUIDE.md")
|
|
458
|
+
with open(guide_path, "w") as f:
|
|
459
|
+
f.write(guide)
|
|
460
|
+
print(f"✅ Created: {guide_path}")
|
|
461
|
+
|
|
462
|
+
print(f"\n{'✅' if compat_ok else '⚠️'} License compatibility: {compat_msg}")
|
|
463
|
+
print(f"\nAll files written to: {args.output_dir}/")
|
|
464
|
+
|
|
465
|
+
|
|
466
|
+
if __name__ == "__main__":
|
|
467
|
+
main()
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Overview
|
|
6
|
+
|
|
7
|
+
**diff-grok** is a zero-dependency TypeScript library for solving initial value problems (IVPs) for ordinary differential equations (ODEs), focused on stiff equations. It implements Rosenbrock-Wanner type numerical methods, a port of SUNDIALS CVODE, and includes a declarative model scripting system.
|
|
8
|
+
|
|
9
|
+
## Build & Development Commands
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install # Install dev dependencies
|
|
13
|
+
npm run build # Compile TypeScript (tsc)
|
|
14
|
+
npm run lint # ESLint check: eslint "./src/**/*.ts"
|
|
15
|
+
npm run lint-fix # Auto-fix lint issues
|
|
16
|
+
npm test # Run Jest test suite
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Run a single test file:
|
|
20
|
+
```bash
|
|
21
|
+
npx jest src/tests/correctness.test.ts
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Architecture
|
|
25
|
+
|
|
26
|
+
### Module Structure
|
|
27
|
+
|
|
28
|
+
- **`index.ts`** — Single entry point; re-exports everything from the four modules below.
|
|
29
|
+
|
|
30
|
+
- **`src/solver-tools/`** — Core numerical solvers
|
|
31
|
+
- **Implicit methods** (for stiff ODEs): `mrt` (Modified Rosenbrock Triple), `ros3prw`, `ros34prw`
|
|
32
|
+
- Require Jacobian computation and linear system solves
|
|
33
|
+
- Use LU decomposition for solving W*k = b at each stage
|
|
34
|
+
- **Automatic methods** (stiffness-detecting): `lsoda` (variable-order Nordsieck Adams/BDF with automatic switching), `cvode` (SUNDIALS CVODE variable-order Adams/BDF)
|
|
35
|
+
- Automatically switch between non-stiff (Adams) and stiff (BDF) modes
|
|
36
|
+
- `lsoda`: consecutive rejection counting (Adams→BDF) and periodic trial steps (BDF→Adams)
|
|
37
|
+
- `cvode`: TypeScript port of SUNDIALS CVODE v7.5.0; variable-order variable-step with Newton iteration + dense LU; supports rootfinding and dense output (`getDky`); wrapper uses BDF mode with warmup for extremely stiff problems
|
|
38
|
+
- CVODE module in `src/solver-tools/cvode/` (12 files): `cvode.ts` (main loop), `cvode_class.ts` (high-level `Cvode` class), `cvode_adams.ts`/`cvode_bdf.ts` (method coefficients), `cvode_nls.ts` (Newton solver), `cvode_ls.ts` (linear solver), `cvode_hin.ts` (initial step estimation), `cvode_root.ts` (rootfinding), `cvode_io.ts` (config/stats), `dense_linalg.ts` (LU), `common.ts` (types/constants)
|
|
39
|
+
- CVODE standard interface wrapper in `src/solver-tools/cvode-method.ts`
|
|
40
|
+
- **Explicit methods** (for non-stiff ODEs): `rk3` (Bogacki-Shampine 3(2)), `rk4` (Runge-Kutta-Fehlberg 4(5)), `ab5` (Adams-Bashforth-Moulton 5), `ab4` (Adams-Bashforth-Moulton 4), `rkdp` (Dormand-Prince 5(4))
|
|
41
|
+
- Only require function evaluations (no Jacobian)
|
|
42
|
+
- Include `hMax` constraint to prevent poor interpolation
|
|
43
|
+
- `ab5` and `ab4` are multistep predictor-corrector methods bootstrapped with RKF45
|
|
44
|
+
- Key types: `ODEs` (problem definition), `Func` (RHS function signature), `SolverMethod`
|
|
45
|
+
- `solver-defs.ts` — Type definitions, adaptive step constants, Jacobian/derivative computation
|
|
46
|
+
- `lin-alg-tools.ts` — Linear algebra routines (LU decomposition, matrix ops)
|
|
47
|
+
- `callbacks/` — Flow control during solving (iteration limits, time limits)
|
|
48
|
+
|
|
49
|
+
- **`src/scripting-tools/`** — Declarative model parsing and JS code generation
|
|
50
|
+
- `scripting-tools.ts` — Main parser: converts model DSL text → `IVP` object → JavaScript code
|
|
51
|
+
- Model DSL uses `#name`, `#equations`, `#argument`, `#inits`, `#parameters`, `#constants`, `#expressions` blocks
|
|
52
|
+
- Entry functions: `getIVP()` (parse model string), `getJScode()` (generate JS from IVP)
|
|
53
|
+
|
|
54
|
+
- **`src/pipeline/`** — Multi-stage simulation orchestration
|
|
55
|
+
- Three pipeline creators for different model types:
|
|
56
|
+
- `BasicModelPipelineCreator` — Single-stage models
|
|
57
|
+
- `CyclicModelPipelineCreator` — Loop/dosing models (PK-PD)
|
|
58
|
+
- `UpdatesModelPipelineCreator` — Multi-stage models with state transitions
|
|
59
|
+
- `applyPipeline()` runs the full computation pipeline
|
|
60
|
+
|
|
61
|
+
- **`src/worker-tools/`** — WebWorker integration for browser parallel computation
|
|
62
|
+
- `getIvp2WebWorker()` serializes IVP for worker transfer; `solveIvp()` runs in worker
|
|
63
|
+
|
|
64
|
+
### Data Flow
|
|
65
|
+
|
|
66
|
+
1. Define problem as `ODEs` object (programmatic) or parse model string via `getIVP()`
|
|
67
|
+
2. Call solver method (`mrt`/`ros3prw`/`ros34prw`/`rk3`/`rk4`/`ab5`/`ab4`/`rkdp`/`lsoda`/`cvode`) → returns `Float64Array[]` (argument values + solution columns)
|
|
68
|
+
3. For complex models: create pipeline via `getPipelineCreator()` → `applyPipeline()`
|
|
69
|
+
|
|
70
|
+
### Performance Patterns
|
|
71
|
+
|
|
72
|
+
- Uses `Float64Array` throughout for memory efficiency
|
|
73
|
+
- Pre-allocated buffers to minimize GC pressure
|
|
74
|
+
- RHS function signature `(t, y, output) => void` writes to pre-allocated output array
|
|
75
|
+
|
|
76
|
+
## Code Style
|
|
77
|
+
|
|
78
|
+
- **ESLint config**: Google style base, 2-space indent, 120 char max line length
|
|
79
|
+
- **Curly braces**: `"multi-or-nest"` — single-statement bodies don't need braces, multi-line do
|
|
80
|
+
- **TypeScript strict mode** enabled
|
|
81
|
+
- Commit messages: `feat:`, `fix:`, `docs:` prefixes (conventional style)
|
|
82
|
+
|
|
83
|
+
## Testing
|
|
84
|
+
|
|
85
|
+
Tests are in `src/tests/` using Jest with ts-jest:
|
|
86
|
+
- `correctness.test.ts` — Validates solver accuracy against reference solutions (threshold: MAX_MAD = 0.1)
|
|
87
|
+
- Tests all methods (implicit + explicit + automatic) against 6 problems with known exact solutions (11 methods total)
|
|
88
|
+
- 3 non-stiff problems (1D, 2D, 3D) + 3 stiff problems (1D, 2D, 3D)
|
|
89
|
+
- `performance.test.ts` — Benchmarks solver speed on stiff problems (timeout: 10,000ms)
|
|
90
|
+
- Tests implicit and automatic methods (MRT, ROS3PRw, ROS34PRw, LSODA)
|
|
91
|
+
- Test problems: Robertson, HIRES, VDPOL, OREGO, E5, Pollution
|
|
92
|
+
- `cvode-lib-correctness.test.ts` — CVODE-specific validation (low-level procedural API + high-level `Cvode` class)
|
|
93
|
+
- Robertson kinetics, non-stiff (Adams) and stiff (BDF) problems, rootfinding, dense output, error handling, re-initialization
|
|
94
|
+
- `cvode-lib-performance.test.ts` — CVODE benchmarks on stiff problems (Robertson, HIRES, VDPOL, OREGO, E5, Pollution)
|
|
95
|
+
- `pipeline.test.ts` — Pipeline integration tests (3 model types)
|
|
96
|
+
- Method definitions in `test-defs.ts`: `methods` map (all 11 solvers), `implicitMethods` map (stiff-capable only)
|
|
97
|
+
|
|
98
|
+
## Key Types
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
type Func = (t: number, y: Float64Array, output: Float64Array) => void;
|
|
102
|
+
type ODEs = { name, arg: {name, start, finish, step}, initial, func: Func, tolerance, solutionColNames };
|
|
103
|
+
type SolverMethod = (odes: ODEs, callback?: Callback) => Float64Array[];
|
|
104
|
+
```
|