This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
implementation_unwrap_modulo [2018/09/19 16:45] supergnu |
implementation_unwrap_modulo [2018/09/19 17:11] (current) supergnu |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== C implementation of a modulo | + | ====== C implementation of the Octave/ |
| + | The unwrap function in Octave/ | ||
| It's an easy piece of code but handy to have it around off the shelf: | It's an easy piece of code but handy to have it around off the shelf: | ||
| - | <code C modulo.c> | + | <code C unwrap.c> |
| - | int modulo(int *values, int numberOfValues, | + | int unwrap(int *values, int numberOfValues, |
| { | { | ||
| - | for (int i = 0; i < numberOfValues; | + | |
| + | | ||
| { | { | ||
| - | while(values[i] | + | while(abs(values[i-1] - values[i]) > modulo/2) |
| { | { | ||
| - | (values[i] > modulo/2) ? values[i] | + | (values[i-1] > values[i]) ? add += modulo : add -= modulo; //could be faster if i kept the phase between samples |
| - | } | + | |
| + | } // issue, there' | ||
| + | add = 0; | ||
| } | } | ||
| } | } | ||
| </ | </ | ||