mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
math: inf,nan,fmod for the JS backend (#11246)
This commit is contained in:
18
vlib/math/evaluate.v
Normal file
18
vlib/math/evaluate.v
Normal file
@ -0,0 +1,18 @@
|
||||
module math
|
||||
|
||||
// Provides functions that don't have a numerical solution and must
|
||||
// be solved computationally (e.g. evaluation of a polynomial)
|
||||
|
||||
pub fn polynomial(z f64, coeff []f64) f64 {
|
||||
n := coeff.len
|
||||
if n == 0 {
|
||||
return 0.0
|
||||
}
|
||||
|
||||
mut sum := coeff[n - 1]
|
||||
for i := n - 1; i >= 0; i-- {
|
||||
sum *= z
|
||||
sum += coeff[i]
|
||||
}
|
||||
return sum
|
||||
}
|
Reference in New Issue
Block a user