We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Either allow compile time floats to be 64 bit also, or raise an error/warning telling the user about this.
proc interpolate*[T: static[int]](x, y: static[array[T, float32]], xi: static[float32]): static[float32] = var s: float #float64 doesnt work either t: float #float64 doesnt work either for i in 0..<T: s = 1'f t = 1'f for j in 0..<T: if j != i: s = s * (xi - x[j]) t = t * (x[i] - x[j]) result = result + ((s / t) * y[i]) var res = interpolate([5.float32, 7, 11, 13, 17], [150.float32, 392, 1452, 2366, 5202], 9) echo(res) proc interpolateCT*[T: static[int]](x, y: static[array[T, float32]], xi: static[float32]): static[float32] {.compileTime.} = var s: float #float64 doesnt work either t: float #float64 doesnt work either for i in 0..<T: s = 1'f t = 1'f for j in 0..<T: if j != i: s = s * (xi - x[j]) t = t * (x[i] - x[j]) result = result + ((s / t) * y[i]) const resCT = interpolateCT([5.float32, 7, 11, 13, 17], [150.float32, 392, 1452, 2366, 5202], 9) echo(resCT)
Output:
809.9999389648438 810.0
The text was updated successfully, but these errors were encountered:
duplicate of (closed but un-fixed) #12884
Sorry, something went wrong.
No branches or pull requests
Either allow compile time floats to be 64 bit also, or raise an error/warning telling the user about this.
Output:
The text was updated successfully, but these errors were encountered: