mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-15 13:10:45 +00:00
916b91e8d0
solidcore's main at c0d3cc0124, rewritten to one commit per same-author run per PR (2,800 commits, author credit kept; tree identical). Full original history: tangency-labs/solidcore archive/full-history. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> git-subtree-dir: solidcore git-subtree-mainline:44525da669git-subtree-split:c440e5f892
19 lines
931 B
Python
Vendored
19 lines
931 B
Python
Vendored
# Same functions through Python's math module = the platform C libm (glibc in Docker).
|
|
import math, os, struct, sys
|
|
out = sys.argv[1]; os.makedirs(out, exist_ok=True)
|
|
def safe(f):
|
|
def g(*a):
|
|
try: return f(*a)
|
|
except (OverflowError, ValueError): return float("nan") # flagged separately
|
|
return g
|
|
fns = {"sin": math.sin, "cos": math.cos, "tan": math.tan, "asin": math.asin, "acos": math.acos,
|
|
"atan": math.atan, "sinh": math.sinh, "cosh": math.cosh, "ln": math.log, "log10": math.log10,
|
|
"cbrt": math.cbrt, "atan2": math.atan2, "powf": math.pow}
|
|
for name, f in fns.items():
|
|
b = open(f"inputs/{name}.bin", "rb").read()
|
|
v = struct.unpack(f"<{len(b)//8}d", b)
|
|
ar = 2 if name in ("atan2", "powf") else 1
|
|
r = [safe(f)(*v[i:i+ar]) for i in range(0, len(v), ar)]
|
|
open(f"{out}/{name}.bin", "wb").write(struct.pack(f"<{len(r)}d", *r))
|
|
import platform; print(out, platform.platform())
|