/*
 * Academic License - for use in teaching, academic research, and meeting
 * course requirements at degree granting institutions only.  Not for
 * government, commercial, or other organizational use.
 *
 * exp.c
 *
 * Code generation for function 'exp'
 *
 */

/* Include files */
#include "exp.h"
#include "digital_option_price_cg_data.h"
#include "digital_option_price_cg_types.h"
#include "eml_int_forloop_overflow_check.h"
#include "rt_nonfinite.h"
#include "mwmathutil.h"

/* Function Definitions */
void b_exp(const emlrtStack *sp, emxArray_creal_T *x)
{
  emlrtStack b_st;
  emlrtStack c_st;
  emlrtStack st;
  creal_T *x_data;
  int32_T k;
  int32_T nx_tmp;
  st.prev = sp;
  st.tls = sp->tls;
  b_st.prev = &st;
  b_st.tls = st.tls;
  c_st.prev = &b_st;
  c_st.tls = b_st.tls;
  x_data = x->data;
  st.site = &lc_emlrtRSI;
  nx_tmp = x->size[0] * x->size[1];
  b_st.site = &gc_emlrtRSI;
  if (nx_tmp > 2147483646) {
    c_st.site = &hc_emlrtRSI;
    check_forloop_overflow_error(&c_st);
  }
  for (k = 0; k < nx_tmp; k++) {
    if (x_data[k].re == 0.0) {
      real_T d;
      d = x_data[k].im;
      x_data[k].re = muDoubleScalarCos(d);
      x_data[k].im = muDoubleScalarSin(d);
    } else if (x_data[k].im == 0.0) {
      x_data[k].re = muDoubleScalarExp(x_data[k].re);
      x_data[k].im = 0.0;
    } else if (muDoubleScalarIsInf(x_data[k].im) &&
               muDoubleScalarIsInf(x_data[k].re) && (x_data[k].re < 0.0)) {
      x_data[k].re = 0.0;
      x_data[k].im = 0.0;
    } else {
      real_T d;
      real_T r;
      r = muDoubleScalarExp(x_data[k].re / 2.0);
      d = x_data[k].im;
      x_data[k].re = r * (r * muDoubleScalarCos(d));
      x_data[k].im = r * (r * muDoubleScalarSin(d));
    }
  }
}

/* End of code generation (exp.c) */
