mirror of
https://github.com/aicodix/dsp.git
synced 2026-04-27 22:35:45 +00:00
added lerp function
This commit is contained in:
parent
7c19098c87
commit
61b3358cbf
2 changed files with 7 additions and 1 deletions
|
|
@ -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).
|
||||
|
||||
|
|
|
|||
6
utils.hh
6
utils.hh
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue