look1_iflf_binlcapw.c 888 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "look1_iflf_binlcapw.h"
  2. #include "rtwtypes.h"
  3. real32_T look1_iflf_binlcapw(real32_T u0, const real32_T bp0[], const real32_T
  4. table[], uint32_T maxIndex)
  5. {
  6. real32_T frac;
  7. real32_T y;
  8. uint32_T iLeft;
  9. if (u0 <= bp0[0U]) {
  10. iLeft = 0U;
  11. frac = 0.0F;
  12. } else if (u0 < bp0[maxIndex]) {
  13. uint32_T bpIdx;
  14. uint32_T iRght;
  15. bpIdx = maxIndex >> 1U;
  16. iLeft = 0U;
  17. iRght = maxIndex;
  18. while (iRght - iLeft > 1U) {
  19. if (u0 < bp0[bpIdx]) {
  20. iRght = bpIdx;
  21. } else {
  22. iLeft = bpIdx;
  23. }
  24. bpIdx = (iRght + iLeft) >> 1U;
  25. }
  26. frac = (u0 - bp0[iLeft]) / (bp0[iLeft + 1U] - bp0[iLeft]);
  27. } else {
  28. iLeft = maxIndex;
  29. frac = 0.0F;
  30. }
  31. if (iLeft == maxIndex) {
  32. y = table[iLeft];
  33. } else {
  34. real32_T yL_0d0;
  35. yL_0d0 = table[iLeft];
  36. y = (table[iLeft + 1U] - yL_0d0) * frac + yL_0d0;
  37. }
  38. return y;
  39. }