mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-09-10 07:06:34 -04:00
224 lines
8.0 KiB
C++
224 lines
8.0 KiB
C++
|
|
// phi0.c
|
|
//
|
|
// An approximation of the function
|
|
//
|
|
// This file is generated by the gen_phi0 scritps
|
|
// Any changes should be made to that file, not this one
|
|
|
|
#include <stdint.h>
|
|
|
|
#define SI16(f) ((int32_t)(f * (1<<16)))
|
|
|
|
namespace FreeDV
|
|
{
|
|
|
|
float phi0( float xf ) {
|
|
|
|
int32_t x = SI16(xf);
|
|
|
|
if (x >= SI16(10.0f)) return(0.0f);
|
|
else {
|
|
if (x >= SI16(5.0f)) {
|
|
int i = 19 - (x >> 15);
|
|
switch (i) {
|
|
case 0: return(0.000116589f); // (9.5)
|
|
case 1: return(0.000192223f); // (9.0)
|
|
case 2: return(0.000316923f); // (8.5)
|
|
case 3: return(0.000522517f); // (8.0)
|
|
case 4: return(0.000861485f); // (7.5)
|
|
case 5: return(0.001420349f); // (7.0)
|
|
case 6: return(0.002341760f); // (6.5)
|
|
case 7: return(0.003860913f); // (6.0)
|
|
case 8: return(0.006365583f); // (5.5)
|
|
case 9: return(0.010495133f); // (5.0)
|
|
}
|
|
}
|
|
else {
|
|
if (x >= SI16(1.0f)) {
|
|
int i = 79 - (x >> 12);
|
|
switch (i) {
|
|
case 0: return(0.013903889f); // (4.9375)
|
|
case 1: return(0.014800644f); // (4.8750)
|
|
case 2: return(0.015755242f); // (4.8125)
|
|
case 3: return(0.016771414f); // (4.7500)
|
|
case 4: return(0.017853133f); // (4.6875)
|
|
case 5: return(0.019004629f); // (4.6250)
|
|
case 6: return(0.020230403f); // (4.5625)
|
|
case 7: return(0.021535250f); // (4.5000)
|
|
case 8: return(0.022924272f); // (4.4375)
|
|
case 9: return(0.024402903f); // (4.3750)
|
|
case 10: return(0.025976926f); // (4.3125)
|
|
case 11: return(0.027652501f); // (4.2500)
|
|
case 12: return(0.029436184f); // (4.1875)
|
|
case 13: return(0.031334956f); // (4.1250)
|
|
case 14: return(0.033356250f); // (4.0625)
|
|
case 15: return(0.035507982f); // (4.0000)
|
|
case 16: return(0.037798579f); // (3.9375)
|
|
case 17: return(0.040237016f); // (3.8750)
|
|
case 18: return(0.042832850f); // (3.8125)
|
|
case 19: return(0.045596260f); // (3.7500)
|
|
case 20: return(0.048538086f); // (3.6875)
|
|
case 21: return(0.051669874f); // (3.6250)
|
|
case 22: return(0.055003924f); // (3.5625)
|
|
case 23: return(0.058553339f); // (3.5000)
|
|
case 24: return(0.062332076f); // (3.4375)
|
|
case 25: return(0.066355011f); // (3.3750)
|
|
case 26: return(0.070637993f); // (3.3125)
|
|
case 27: return(0.075197917f); // (3.2500)
|
|
case 28: return(0.080052790f); // (3.1875)
|
|
case 29: return(0.085221814f); // (3.1250)
|
|
case 30: return(0.090725463f); // (3.0625)
|
|
case 31: return(0.096585578f); // (3.0000)
|
|
case 32: return(0.102825462f); // (2.9375)
|
|
case 33: return(0.109469985f); // (2.8750)
|
|
case 34: return(0.116545700f); // (2.8125)
|
|
case 35: return(0.124080967f); // (2.7500)
|
|
case 36: return(0.132106091f); // (2.6875)
|
|
case 37: return(0.140653466f); // (2.6250)
|
|
case 38: return(0.149757747f); // (2.5625)
|
|
case 39: return(0.159456024f); // (2.5000)
|
|
case 40: return(0.169788027f); // (2.4375)
|
|
case 41: return(0.180796343f); // (2.3750)
|
|
case 42: return(0.192526667f); // (2.3125)
|
|
case 43: return(0.205028078f); // (2.2500)
|
|
case 44: return(0.218353351f); // (2.1875)
|
|
case 45: return(0.232559308f); // (2.1250)
|
|
case 46: return(0.247707218f); // (2.0625)
|
|
case 47: return(0.263863255f); // (2.0000)
|
|
case 48: return(0.281099022f); // (1.9375)
|
|
case 49: return(0.299492155f); // (1.8750)
|
|
case 50: return(0.319127030f); // (1.8125)
|
|
case 51: return(0.340095582f); // (1.7500)
|
|
case 52: return(0.362498271f); // (1.6875)
|
|
case 53: return(0.386445235f); // (1.6250)
|
|
case 54: return(0.412057648f); // (1.5625)
|
|
case 55: return(0.439469363f); // (1.5000)
|
|
case 56: return(0.468828902f); // (1.4375)
|
|
case 57: return(0.500301872f); // (1.3750)
|
|
case 58: return(0.534073947f); // (1.3125)
|
|
case 59: return(0.570354566f); // (1.2500)
|
|
case 60: return(0.609381573f); // (1.1875)
|
|
case 61: return(0.651427083f); // (1.1250)
|
|
case 62: return(0.696805010f); // (1.0625)
|
|
case 63: return(0.745880827f); // (1.0000)
|
|
}
|
|
}
|
|
else {
|
|
if (x > SI16(0.007812f)) {
|
|
if (x > SI16(0.088388f)) {
|
|
if (x > SI16(0.250000f)) {
|
|
if (x > SI16(0.500000f)) {
|
|
if (x > SI16(0.707107f)) {
|
|
return(0.922449644f);
|
|
} else {
|
|
return(1.241248638f);
|
|
}
|
|
} else {
|
|
if (x > SI16(0.353553f)) {
|
|
return(1.573515241f);
|
|
} else {
|
|
return(1.912825912f);
|
|
}
|
|
}
|
|
} else {
|
|
if (x > SI16(0.125000f)) {
|
|
if (x > SI16(0.176777f)) {
|
|
return(2.255740095f);
|
|
} else {
|
|
return(2.600476919f);
|
|
}
|
|
} else {
|
|
return(2.946130351f);
|
|
}
|
|
}
|
|
} else {
|
|
if (x > SI16(0.022097f)) {
|
|
if (x > SI16(0.044194f)) {
|
|
if (x > SI16(0.062500f)) {
|
|
return(3.292243417f);
|
|
} else {
|
|
return(3.638586634f);
|
|
}
|
|
} else {
|
|
if (x > SI16(0.031250f)) {
|
|
return(3.985045009f);
|
|
} else {
|
|
return(4.331560985f);
|
|
}
|
|
}
|
|
} else {
|
|
if (x > SI16(0.011049f)) {
|
|
if (x > SI16(0.015625f)) {
|
|
return(4.678105767f);
|
|
} else {
|
|
return(5.024664952f);
|
|
}
|
|
} else {
|
|
return(5.371231340f);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (x > SI16(0.000691f)) {
|
|
if (x > SI16(0.001953f)) {
|
|
if (x > SI16(0.003906f)) {
|
|
if (x > SI16(0.005524f)) {
|
|
return(5.717801329f);
|
|
} else {
|
|
return(6.064373119f);
|
|
}
|
|
} else {
|
|
if (x > SI16(0.002762f)) {
|
|
return(6.410945809f);
|
|
} else {
|
|
return(6.757518949f);
|
|
}
|
|
}
|
|
} else {
|
|
if (x > SI16(0.000977f)) {
|
|
if (x > SI16(0.001381f)) {
|
|
return(7.104092314f);
|
|
} else {
|
|
return(7.450665792f);
|
|
}
|
|
} else {
|
|
return(7.797239326f);
|
|
}
|
|
}
|
|
} else {
|
|
if (x > SI16(0.000173f)) {
|
|
if (x > SI16(0.000345f)) {
|
|
if (x > SI16(0.000488f)) {
|
|
return(8.143812888f);
|
|
} else {
|
|
return(8.490386464f);
|
|
}
|
|
} else {
|
|
if (x > SI16(0.000244f)) {
|
|
return(8.836960047f);
|
|
} else {
|
|
return(9.183533634f);
|
|
}
|
|
}
|
|
} else {
|
|
if (x > SI16(0.000086f)) {
|
|
if (x > SI16(0.000122f)) {
|
|
return(9.530107222f);
|
|
} else {
|
|
return(9.876680812f);
|
|
}
|
|
} else {
|
|
return(10.000000000f);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return(10.0f);
|
|
}
|
|
|
|
} // FreeDV
|