This commit is contained in:
commit
568474d52f
1591 files changed
+528213
No files matched your search
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"tool": "godbolt",
|
||||
"compiler": "mojo_1_2_0",
|
||||
"mojoVersion": "1.2.0",
|
||||
"source_sha256": "37a9981a11db40badf3c1515fa7e52d8ddcf0e062131d08b253320ec3a0f8289",
|
||||
"stdin": "3 0 0 0 0 5 1 5 0 1 2 1 0 1 1 3 0 1 1 5 -1 0 0 1 0 1 0 3 0 1 1 end\n",
|
||||
"args": "--target-cpu x86-64-v3 --fp-mode contract=off",
|
||||
"asked": "2026-11-12",
|
||||
"result": {
|
||||
"compiled": true,
|
||||
"buildStderr": "",
|
||||
"executed": true,
|
||||
"exitCode": 0,
|
||||
"stdout": "2.0\n2.0\n5.0",
|
||||
"stderr": "",
|
||||
"timedOut": false,
|
||||
"asm": null
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
def linear_interp(x0: Float64, y0: Float64, x1: Float64, y1: Float64, x: Float64) -> Float64:
|
||||
return y0 + (y1 - y0) * (x - x0) / (x1 - x0)
|
||||
@@ -0,0 +1,2 @@
|
||||
def linear_interp(x0, y0, x1, y1, x):
|
||||
return y0 + (y1 - y0) * (x - x0) / (x1 - x0)
|
||||
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "LinearInterp",
|
||||
"summary": "The value at X on the straight line through (X0, Y0) and (X1, Y1).",
|
||||
"tags": [
|
||||
"interpolation"
|
||||
],
|
||||
"sources": [
|
||||
{
|
||||
"title": "NIST Digital Library of Mathematical Functions, section 3.3(ii), linear interpolation (equation 3.3.14)",
|
||||
"url": "https://dlmf.nist.gov/3.3.ii"
|
||||
}
|
||||
],
|
||||
"cases": [
|
||||
{
|
||||
"call": "LinearInterp(0.0, 0.0, 10.0, 5.0, 4.0)"
|
||||
},
|
||||
{
|
||||
"call": "LinearInterp(1.0, 2.0, 3.0, 2.0, 2.5)"
|
||||
},
|
||||
{
|
||||
"call": "LinearInterp(0.0, 1.0, 1.0, 3.0, 2.0)"
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"lang": "python",
|
||||
"level": "plain",
|
||||
"file": "ref/python/plain.py",
|
||||
"note": "The same formula."
|
||||
},
|
||||
{
|
||||
"lang": "mojo",
|
||||
"level": "plain",
|
||||
"file": "ref/mojo/plain.mojo",
|
||||
"note": "The same formula in Mojo."
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
// LinearInterp: the value at X on the straight line through (X0, Y0) and
|
||||
// (X1, Y1). X may lie outside [X0, X1]: that is extrapolation, and the line
|
||||
// carries on. The REQUIRE names the difference the division divides by.
|
||||
FUNCTION LinearInterp(X0 : FLOAT, Y0 : FLOAT, X1 : FLOAT, Y1 : FLOAT, X : FLOAT) RETURNS FLOAT
|
||||
REQUIRE X1 - X0 != 0.0
|
||||
RETURN Y0 + (Y1 - Y0) * (X - X0) / (X1 - X0)
|
||||
ENDFUNCTION
|
||||
Reference in new issue
Block a user