/*
 * File: intrp2d_fu32fla_pw.c
 *
 * Code generated for Simulink model 'BCMR_DChrgTiRem'.
 *
 * Model version                  : 1.535
 * Simulink Coder version         : 8.11 (R2016b) 25-Aug-2016
 * C/C++ source code generated on : Sat Aug 08 12:32:11 2020
 */

#include "rtwtypes.h"
#include "intrp2d_fu32fla_pw.h"

real32_T intrp2d_fu32fla_pw(const uint32_T bpIndex[], const real32_T frac[],
  const real32_T table[], uint32_T stride, const uint32_T maxIndex[])
{
  real32_T y;
  real32_T yR_1d;
  uint32_T offset_1d;

  /* Interpolation 2-D
     Interpolation method: 'Linear'
     Use last breakpoint for index at or above upper limit: 'on'
     Overflow mode: 'portable wrapping'
   */
  offset_1d = bpIndex[1U] * stride + bpIndex[0U];
  if (bpIndex[0U] == maxIndex[0U]) {
    y = table[offset_1d];
  } else {
    y = (table[offset_1d + 1U] - table[offset_1d]) * frac[0U] + table[offset_1d];
  }

  if (bpIndex[1U] == maxIndex[1U]) {
  } else {
    offset_1d += stride;
    if (bpIndex[0U] == maxIndex[0U]) {
      yR_1d = table[offset_1d];
    } else {
      yR_1d = (table[offset_1d + 1U] - table[offset_1d]) * frac[0U] +
        table[offset_1d];
    }

    y += (yR_1d - y) * frac[1U];
  }

  return y;
}

/*
 * File trailer for generated code.
 *
 * [EOF]
 */
