added lerp function

This commit is contained in:
Ahmet Inan 2018-09-11 08:09:29 +02:00
commit 61b3358cbf
2 changed files with 7 additions and 1 deletions

View file

@ -68,5 +68,5 @@ Mixed-radix [decimation-in-time](https://en.wikipedia.org/wiki/Cooley%E2%80%93Tu
### [utils.hh](utils.hh)
Some everyday helpers, like the [signum function](https://en.wikipedia.org/wiki/Sign_function).
Some everyday helpers, like the [signum function](https://en.wikipedia.org/wiki/Sign_function) or the [lerp function](https://en.wikipedia.org/wiki/Linear_interpolation).

View file

@ -15,6 +15,12 @@ int signum(TYPE v)
return (v > TYPE(0)) - (v < TYPE(0));
}
template <typename X, typename AB>
AB lerp(X x, AB a, AB b)
{
return (X(1) - x) * a + x * b;
}
}
#endif