Пример #1
0
/* finds the desired result, given y, the primes to be killed, the denominators,
   the full set of initial primes, and the density of relative primes */
extern BigNum find_M(BigNum * guess, BigNum * y, struct BIGNUM_ARRAY_TYPE left_to_kill,
		     struct BIGNUM_ARRAY_TYPE denom, struct BIGNUM_ARRAY_TYPE initial_primes,
		     BigRat *magic)
{
  BigNum temp, temp2, current_mu;

#if 0
  Mu(&current_mu, guess, left_to_kill, denom); 
  temp = y - current_mu;
  temp2 = b_abs(temp);

  while (b_cmp(temp2, LINEAR_SEARCH_LIMIT) > 0) {
    temp2 = guess_mu_inverse(&temp, magic);
    (*guess) = (*guess) + temp2;

    Mu(&current_mu, guess, left_to_kill, denom);

    temp = y - current_mu;
    temp2 = b_abs(temp);
  }

  temp = b_clear();
  temp2 = b_clear();

#else

  *guess = "11";
  current_mu = "1";
#endif
  return(linear_find(y, &current_mu, guess, initial_primes));
} 
Пример #2
0
/* This function merges two arrays */
extern struct BIGNUM_ARRAY_TYPE join(struct BIGNUM_ARRAY_TYPE first, struct BIGNUM_ARRAY_TYPE second)
{
  struct BIGNUM_ARRAY_TYPE result;
  long count1 = 0; 
  long count2 = 0;
  BigNum absfirst, abssecond;

  result.size = first.size + second.size;
  //  result.list = static_cast<BigNum *>(malloc(result.size * sizeof(BigNum)));
  result.list = new BigNum[result.size];

  if ((count1 < first.size) && (count2 < second.size)) {
    absfirst = b_abs(first.list[count1]);
    abssecond = b_abs(second.list[count2]);
  }

  while ((count1 < first.size) && (count2 < second.size)) {
    if (b_cmp(absfirst, abssecond) > 0) {
      result.list[count1+count2] = second.list[count2];
      ++count2;

      if (count2 < second.size) 
	abssecond = b_abs(second.list[count2]);
    }
    else {
      result.list[count1+count2] = first.list[count1];
      ++count1;

      if (count1 < first.size)
	absfirst = b_abs(first.list[count1]);
    }
  }

  absfirst.b_clear();
  abssecond.b_clear();

  for (;count1<first.size;count1++) 
    result.list[count1+count2] = first.list[count1];

  for (;count2<second.size;count2++) 
    result.list[count1+count2] = second.list[count2];

  return(result);
}
Пример #3
0
/* This function multiplies and reduces an array */
extern struct BIGNUM_ARRAY_TYPE mult_reduce(BigNum * number, struct BIGNUM_ARRAY_TYPE set, BigNum * limit)
{
  struct BIGNUM_ARRAY_TYPE result;
  long count, count2;
  BigNum plussed/*, temp*/;
  
#if 0
  number = b_neg(number);       /* multiply by -number, except with 1 */
  temp = b_abs(number);
#endif

  //  result.list = static_cast<BigNum *>(malloc(set.size * sizeof(BigNum)));
  result.list = new BigNum[set.size];
  count2 = 0;

  if (set.size > 0) {
    result.list[count2] = "0";

    for (count=0;count<set.size;count++) 
      {
	/*if(mpz_cmp_ui(set.list[count],1U) != 0)*/
	  result.list[count2] = set.list[count] * (*number);
	/*else
	  result.list[count2]) = set.list[count] * temp; */
      	  plussed = b_abs(result.list[count2]);

	  if (b_cmp(plussed, *limit) < 0) {
	    ++count2;
	    
	    if (count2 < set.size)
	      result.list[count2] = "0";
	  }
      }
  }

  result.size = count2;
  plussed.b_clear();
  /* temp.b_clear(); */

  return(result);
}
Пример #4
0
void AGC_stepImpl(const emlrtStack *sp, comm_AGC *obj, const creal_T x[1408],
                  creal_T y[1408])
{
  real_T g;
  real_T K;
  real_T dv1[1408];
  real_T dv2[1408];
  real_T dv3[99];
  real_T logAbsX2[1408];
  int32_T p;
  emlrtStack st;
  st.prev = sp;
  st.tls = sp->tls;
  g = obj->Gain;
  K = obj->pCastedStepSize;
  b_abs(x, dv1);
  st.site = &kb_emlrtRSI;
  power(&st, dv1, dv2);
  filter(dv2, obj->FilterState, logAbsX2, dv3);
  for (p = 0; p < 99; p++) {
    obj->FilterState[p] = dv3[p];
  }

  st.site = &lb_emlrtRSI;
  b_log(&st, logAbsX2);
  for (p = 0; p < 1408; p++) {
    y[p].re = g;
    y[p].im = 0.0;
    g = muDoubleScalarMin(g + K * (0.0 - (logAbsX2[p] + 2.0 * g)),
                          3.4538776394910684);
  }

  b_exp(y);
  for (p = 0; p < 1408; p++) {
    K = y[p].re;
    y[p].re = x[p].re * y[p].re - x[p].im * y[p].im;
    y[p].im = x[p].re * y[p].im + x[p].im * K;
  }

  obj->Gain = g;
}
Пример #5
0
/* Function Definitions */
real_T signalPower(const emxArray_creal_T *input)
{
  real_T out;
  emxArray_real_T *a;
  emxArray_real_T *b;
  int32_T i2;
  int32_T i;
  const mxArray *y;
  static const int32_T iv11[2] = { 1, 45 };

  const mxArray *m1;
  char_T cv17[45];
  static const char_T cv18[45] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o',
    'l', 'b', 'o', 'x', ':', 'm', 't', 'i', 'm', 'e', 's', '_', 'n', 'o', 'D',
    'y', 'n', 'a', 'm', 'i', 'c', 'S', 'c', 'a', 'l', 'a', 'r', 'E', 'x', 'p',
    'a', 'n', 's', 'i', 'o', 'n' };

  const mxArray *b_y;
  static const int32_T iv12[2] = { 1, 21 };

  char_T cv19[21];
  static const char_T cv20[21] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T',
    'L', 'A', 'B', ':', 'i', 'n', 'n', 'e', 'r', 'd', 'i', 'm' };

  real_T c_y;
  ptrdiff_t n_t;
  ptrdiff_t incx_t;
  ptrdiff_t incy_t;
  double * xix0_t;
  double * yiy0_t;
  emlrtHeapReferenceStackEnterFcnR2012b(emlrtRootTLSGlobal);
  b_emxInit_real_T(&a, 2, &f_emlrtRTEI, TRUE);
  emxInit_real_T(&b, 1, &f_emlrtRTEI, TRUE);

  /* out=input'*input/sentBitsSize; */
  /* out=abs(out); */
  emlrtPushRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal);
  b_abs(input, b);
  i2 = a->size[0] * a->size[1];
  a->size[0] = 1;
  emxEnsureCapacity((emxArray__common *)a, i2, (int32_T)sizeof(real_T),
                    &f_emlrtRTEI);
  i = b->size[0];
  i2 = a->size[0] * a->size[1];
  a->size[1] = i;
  emxEnsureCapacity((emxArray__common *)a, i2, (int32_T)sizeof(real_T),
                    &f_emlrtRTEI);
  i = b->size[0];
  for (i2 = 0; i2 < i; i2++) {
    a->data[i2] = b->data[i2];
  }

  b_abs(input, b);
  emlrtPushRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal);
  if (!(a->size[1] == b->size[0])) {
    if ((a->size[1] == 1) || (b->size[0] == 1)) {
      emlrtPushRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal);
      emlrt_synchGlobalsToML();
      y = NULL;
      m1 = mxCreateCharArray(2, iv11);
      for (i = 0; i < 45; i++) {
        cv17[i] = cv18[i];
      }

      emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 45, m1, cv17);
      emlrtAssign(&y, m1);
      error(message(y, &i_emlrtMCI), &j_emlrtMCI);
      emlrt_synchGlobalsFromML();
      emlrtPopRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal);
    } else {
      emlrtPushRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal);
      emlrt_synchGlobalsToML();
      b_y = NULL;
      m1 = mxCreateCharArray(2, iv12);
      for (i = 0; i < 21; i++) {
        cv19[i] = cv20[i];
      }

      emlrtInitCharArrayR2013a(emlrtRootTLSGlobal, 21, m1, cv19);
      emlrtAssign(&b_y, m1);
      error(message(b_y, &k_emlrtMCI), &l_emlrtMCI);
      emlrt_synchGlobalsFromML();
      emlrtPopRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal);
    }
  }

  emlrtPopRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal);
  if ((a->size[1] == 1) || (b->size[0] == 1)) {
    c_y = 0.0;
    for (i2 = 0; i2 < a->size[1]; i2++) {
      c_y += a->data[a->size[0] * i2] * b->data[i2];
    }
  } else {
    emlrtPushRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&q_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&r_emlrtRSI, emlrtRootTLSGlobal);
    if (a->size[1] < 1) {
      c_y = 0.0;
    } else {
      emlrtPushRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal);
      emlrtPushRtStackR2012b(&y_emlrtRSI, emlrtRootTLSGlobal);
      emlrtPushRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal);
      emlrt_checkEscapedGlobals();
      n_t = (ptrdiff_t)(a->size[1]);
      emlrtPopRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal);
      emlrtPopRtStackR2012b(&y_emlrtRSI, emlrtRootTLSGlobal);
      emlrtPushRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal);
      emlrtPushRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal);
      emlrt_checkEscapedGlobals();
      incx_t = (ptrdiff_t)(1);
      emlrtPopRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal);
      emlrtPopRtStackR2012b(&ab_emlrtRSI, emlrtRootTLSGlobal);
      emlrtPushRtStackR2012b(&bb_emlrtRSI, emlrtRootTLSGlobal);
      emlrtPushRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal);
      emlrt_checkEscapedGlobals();
      incy_t = (ptrdiff_t)(1);
      emlrtPopRtStackR2012b(&eb_emlrtRSI, emlrtRootTLSGlobal);
      emlrtPopRtStackR2012b(&bb_emlrtRSI, emlrtRootTLSGlobal);
      emlrtPushRtStackR2012b(&cb_emlrtRSI, emlrtRootTLSGlobal);
      emlrt_checkEscapedGlobals();
      xix0_t = (double *)(&a->data[0]);
      emlrtPopRtStackR2012b(&cb_emlrtRSI, emlrtRootTLSGlobal);
      emlrtPushRtStackR2012b(&db_emlrtRSI, emlrtRootTLSGlobal);
      emlrt_checkEscapedGlobals();
      yiy0_t = (double *)(&b->data[0]);
      emlrtPopRtStackR2012b(&db_emlrtRSI, emlrtRootTLSGlobal);
      emlrt_checkEscapedGlobals();
      c_y = ddot(&n_t, xix0_t, &incx_t, yiy0_t, &incy_t);
      emlrtPopRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal);
    }

    emlrtPopRtStackR2012b(&r_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&q_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal);
  }

  emxFree_real_T(&b);
  emxFree_real_T(&a);
  out = c_y / (real_T)input->size[0];
  emlrtPopRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal);
  emlrtHeapReferenceStackLeaveFcnR2012b(emlrtRootTLSGlobal);
  return out;
}
Пример #6
0
/* Function Definitions */
void features_bta(const emxArray_real_T *tap, double ft[2])
{
  int i12;
  emxArray_real_T *t;
  int loop_ub;
  double tapdt;
  emxArray_real_T *tapx;
  emxArray_real_T *dx;
  emxArray_boolean_T *i;
  emxArray_int32_T *r12;
  double tapiqr;

  /*  Computes basic tapping test features. */
  /*  Inputs: */
  /*   tap - tapping data vector: tap(:,1) - time points, */
  /*         tap(:,2:3) - X,Y touch screen coordinates */
  /*  */
  /*  (CC BY-SA 3.0) Max Little, 2014 */
  /*  Output feature vector */
  for (i12 = 0; i12 < 2; i12++) {
    ft[i12] = rtNaN;
  }

  /*  Ignore zero-length inputs */
  if (tap->size[0] == 0) {
  } else {
    b_emxInit_real_T(&t, 1);

    /*  Calculate relative time */
    loop_ub = tap->size[0];
    tapdt = tap->data[0];
    i12 = t->size[0];
    t->size[0] = loop_ub;
    emxEnsureCapacity((emxArray__common *)t, i12, (int)sizeof(double));
    for (i12 = 0; i12 < loop_ub; i12++) {
      t->data[i12] = tap->data[i12] - tapdt;
    }

    b_emxInit_real_T(&tapx, 1);

    /*  X,Y offset */
    loop_ub = tap->size[0];
    i12 = tapx->size[0];
    tapx->size[0] = loop_ub;
    emxEnsureCapacity((emxArray__common *)tapx, i12, (int)sizeof(double));
    for (i12 = 0; i12 < loop_ub; i12++) {
      tapx->data[i12] = tap->data[i12 + tap->size[0]];
    }

    tapdt = mean(tapx);
    i12 = tapx->size[0];
    emxEnsureCapacity((emxArray__common *)tapx, i12, (int)sizeof(double));
    loop_ub = tapx->size[0];
    for (i12 = 0; i12 < loop_ub; i12++) {
      tapx->data[i12] -= tapdt;
    }

    b_emxInit_real_T(&dx, 1);
    emxInit_boolean_T(&i, 1);

    /*  Find left/right finger 'depress' events */
    diff(tapx, dx);
    b_abs(dx, tapx);
    i12 = i->size[0];
    i->size[0] = tapx->size[0];
    emxEnsureCapacity((emxArray__common *)i, i12, (int)sizeof(boolean_T));
    loop_ub = tapx->size[0];
    for (i12 = 0; i12 < loop_ub; i12++) {
      i->data[i12] = (tapx->data[i12] > 20.0);
    }

    emxInit_int32_T(&r12, 1);
    eml_li_find(i, r12);
    i12 = dx->size[0];
    dx->size[0] = r12->size[0];
    emxEnsureCapacity((emxArray__common *)dx, i12, (int)sizeof(double));
    loop_ub = r12->size[0];
    emxFree_boolean_T(&i);
    for (i12 = 0; i12 < loop_ub; i12++) {
      dx->data[i12] = t->data[r12->data[i12] - 1];
    }

    emxFree_int32_T(&r12);
    emxFree_real_T(&t);

    /*  Find depress event intervals */
    diff(dx, tapx);

    /*  Median and spread of tapping rate */
    emxFree_real_T(&dx);
    if (tapx->size[0] == 0) {
      tapdt = rtNaN;
    } else {
      tapdt = vectormedian(tapx);
    }

    tapiqr = iqr(tapx);

    /*  Output tapping test feature vector */
    ft[0] = tapdt;
    ft[1] = tapiqr;
    emxFree_real_T(&tapx);
  }
}
/*
 * fft_bandpower_calculate
 *    data: the signal of 1 dimension vector
 *    Fs: the frequency provide
 *    band: the band provided, should have upper and lower bound
 * Arguments    : const double data[256]
 *                double Fs
 *                double band[2]
 *                double *totalpower
 *                double *pband
 * Return Type  : void
 */
void fft_bandpower_calculate(const double data[256], double Fs, double band[2],
  double *totalpower, double *pband)
{
  creal_T A[256];
  double y;
  double f[129];
  int i;
  creal_T b_A[256];
  creal_T c_A[129];
  double c_power[129];
  boolean_T bv0[129];
  boolean_T bv1[129];
  double dv0[129];
  unsigned char tmp_data[129];
  int trueCount;
  int partialTrueCount;
  double power_data[129];
  int power_size[2];
  int tmp_size[2];
  double b_tmp_data[129];

  /*  get of the data */
  fft(data, A);
  y = Fs / 2.0;
  linspace(f);
  for (i = 0; i < 129; i++) {
    f[i] *= y;
  }

  for (i = 0; i < 256; i++) {
    if (A[i].im == 0.0) {
      b_A[i].re = A[i].re / 256.0;
      b_A[i].im = 0.0;
    } else if (A[i].re == 0.0) {
      b_A[i].re = 0.0;
      b_A[i].im = A[i].im / 256.0;
    } else {
      b_A[i].re = A[i].re / 256.0;
      b_A[i].im = A[i].im / 256.0;
    }
  }

  memcpy(&c_A[0], &b_A[0], 129U * sizeof(creal_T));
  b_abs(c_A, c_power);
  for (i = 0; i < 129; i++) {
    c_power[i] *= 2.0;
  }

  /*  see if band power is in side the frequency range */
  if (band[1] > f[128]) {
    band[1] = f[128];
  }

  if (band[0] < f[0]) {
    /*  if the band lower bound is less than f(1) */
    band[0] = f[0];
  }

  for (i = 0; i < 129; i++) {
    bv0[i] = (f[i] >= band[0]);
    bv1[i] = (f[i] <= band[1]);
  }

  power(c_power, dv0);
  *totalpower = sum(dv0);
  trueCount = 0;
  for (i = 0; i < 129; i++) {
    if (bv0[i] && bv1[i]) {
      trueCount++;
    }
  }

  partialTrueCount = 0;
  for (i = 0; i < 129; i++) {
    if (bv0[i] && bv1[i]) {
      tmp_data[partialTrueCount] = (unsigned char)(i + 1);
      partialTrueCount++;
    }
  }

  power_size[0] = 1;
  power_size[1] = trueCount;
  for (i = 0; i < trueCount; i++) {
    power_data[i] = c_power[tmp_data[i] - 1];
  }

  b_power(power_data, power_size, b_tmp_data, tmp_size);
  *pband = b_sum(b_tmp_data, tmp_size);
}
// 
// % Erased all parts not wanted for codegeneration /Martin %% 
// Arguments    : emxArray_real_T *s 
//                emxArray_boolean_T *outliers 
//                emxArray_boolean_T *outliers2 
// Return Type  : void 
//
void locateOutliers(emxArray_real_T *s, emxArray_boolean_T *outliers, emxArray_boolean_T *outliers2)
{
    int ia;
    int ic;
    emxArray_real_T *b_y1;
    int orderForDim;
    int iyLead;
    double work_data_idx_0;
    int m;
    double tmp1;
    double tmp2;
    emxArray_real_T *SigmaMat;
    emxArray_int32_T *r0;
    emxArray_int32_T *r1;
    emxArray_real_T *a;
    unsigned int s_idx_0;
    emxArray_real_T *C;
    int br;
    double mu;
    emxArray_real_T *b_s;
    /* locateOutliers: locates artifacts/outliers from data series */
    /*  */
    /*   Inputs:  s = array containg data series */
    /*            method = artifact removal method to use. */
    /*   methods: 'percent' = percentage filter: locates data > x percent diff than previous data point.                */
    /*            'sd' = standard deviation filter: locates data > x stdev away from mean. */
    /*            'above' = Threshold filter: locates data > threshold value */
    /*            'below' = Threshold filter: locates data < threshold value */
    /*            'median' = median filter. Outliers are located. */
    /* Outputs:   outliers = logical array of whether s is artifact/outlier or not */
    /*                        eg. - [0 0 0 1 0], 1=artifact, 0=normal */
    /*                         */
    /* Examples: */
    /*    Locate outliers with 20% percentage filter: */
    /*        outliers = locateOutlers(s,'percent',0.2) */
    /*    Locate outliers that are above a threshold of 0.5: */
    /*        outliers = locateOutlers(s,'thresh','above',0.5) */
    /*    Locate outliers with median filter: */
    /*        outliers = locateOutlers(s,'median',4,5) */
    /*  */
    /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
    /*  Copyright (C) 2010, John T. Ramshur, [email protected] */
    /*   */
    /*  This file is part of HRVAS */
    /*  */
    /*  HRVAS is free software: you can redistribute it and/or modify */
    /*  it under the terms of the GNU General Public License as published by */
    /*  the Free Software Foundation, either version 3 of the License, or */
    /*  (at your option) any later version. */
    /*   */
    /*  HRVAS is distributed in the hope that it will be useful, */
    /*  but WITHOUT ANY WARRANTY; without even the implied warranty of */
    /*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
    /*  GNU General Public License for more details. */
    /*   */
    /*  You should have received a copy of the GNU General Public License */
    /*  along with Foobar.  If not, see <http://www.gnu.org/licenses/>. */
    /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
    ia = outliers->size[0];
    outliers->size[0] = s->size[0];
    emxEnsureCapacity((emxArray__common *)outliers, ia, (int)sizeof(boolean_T));
    ic = s->size[0];
    for (ia = 0; ia < ic; ia++) {
        outliers->data[ia] = false;
    }
    /* preallocate         */
    if (1 > s->size[0] - 1) {
        ic = 0;
    } else {
        ic = s->size[0] - 1;
    }
    emxInit_real_T(&b_y1, 1);
    if (s->size[0] == 0) {
        ia = b_y1->size[0];
        b_y1->size[0] = 0;
        emxEnsureCapacity((emxArray__common *)b_y1, ia, (int)sizeof(double));
    } else {
        if (s->size[0] - 1 <= 1) {
            orderForDim = s->size[0] - 1;
        } else {
            orderForDim = 1;
        }
        if (orderForDim < 1) {
            ia = b_y1->size[0];
            b_y1->size[0] = 0;
            emxEnsureCapacity((emxArray__common *)b_y1, ia, (int)sizeof(double));
        } else {
            orderForDim = s->size[0] - 1;
            ia = b_y1->size[0];
            b_y1->size[0] = orderForDim;
            emxEnsureCapacity((emxArray__common *)b_y1, ia, (int)sizeof(double));
            if (!(b_y1->size[0] == 0)) {
                orderForDim = 1;
                iyLead = 0;
                work_data_idx_0 = s->data[0];
                for (m = 2; m <= s->size[0]; m++) {
                    tmp1 = s->data[orderForDim];
                    tmp2 = work_data_idx_0;
                    work_data_idx_0 = tmp1;
                    tmp1 -= tmp2;
                    orderForDim++;
                    b_y1->data[iyLead] = tmp1;
                    iyLead++;
                }
            }
        }
    }
    emxInit_real_T(&SigmaMat, 1);
    b_abs(b_y1, SigmaMat);
    /* percent chage from previous */
    /* find index of values where pChange > perLimit */
    orderForDim = s->size[0];
    if (2 > orderForDim) {
        ia = 0;
        orderForDim = 0;
    } else {
        ia = 1;
        orderForDim = s->size[0];
    }
    emxInit_int32_T(&r0, 2);
    iyLead = r0->size[0] * r0->size[1];
    r0->size[0] = 1;
    r0->size[1] = orderForDim - ia;
    emxEnsureCapacity((emxArray__common *)r0, iyLead, (int)sizeof(int));
    orderForDim -= ia;
    for (iyLead = 0; iyLead < orderForDim; iyLead++) {
        r0->data[r0->size[0] * iyLead] = ia + iyLead;
    }
    emxInit_int32_T1(&r1, 1);
    ia = r1->size[0];
    r1->size[0] = ic;
    emxEnsureCapacity((emxArray__common *)r1, ia, (int)sizeof(int));
    for (ia = 0; ia < ic; ia++) {
        r1->data[ia] = 1 + ia;
    }
    ic = r0->size[0] * r0->size[1];
    for (ia = 0; ia < ic; ia++) {
        outliers->data[r0->data[ia]] = (SigmaMat->data[ia] / s->data[r1->data[ia] - 1] > 0.2);
    }
    emxFree_int32_T(&r1);
    emxFree_int32_T(&r0);
    emxInit_real_T1(&a, 2);
    /*  Reference:  */
    /*  Clifford, G. (2002). "Characterizing Artefact in the Normal  */
    /*  Human 24-Hour RR Time Series to Aid Identification and Artificial  */
    /*  Replication of Circadian Variations in Human Beat to Beat Heart Rate  */
    /*  using a Simple Threshold." */
    /*  */
    /*  Aubert, A. E., D. Ramaekers, et al. (1999). "The analysis of heart  */
    /*  rate variability in unrestrained rats. Validation of method and  */
    /*  results." Comput Methods Programs Biomed 60(3): 197-213. */
    /* convert to logical array */
    /* preallocate   */
    iyLead = s->size[0];
    s_idx_0 = (unsigned int)s->size[0];
    ia = a->size[0] * a->size[1];
    a->size[0] = (int)s_idx_0;
    a->size[1] = 2;
    emxEnsureCapacity((emxArray__common *)a, ia, (int)sizeof(double));
    for (orderForDim = 1; orderForDim <= iyLead; orderForDim++) {
        a->data[orderForDim - 1] = (double)orderForDim / (double)iyLead;
        a->data[(orderForDim + a->size[0]) - 1] = 1.0;
    }
    mldivide(a, s, b_y1);
    emxInit_real_T(&C, 1);
    if (b_y1->size[0] == 1) {
        ia = C->size[0];
        C->size[0] = a->size[0];
        emxEnsureCapacity((emxArray__common *)C, ia, (int)sizeof(double));
        ic = a->size[0];
        for (ia = 0; ia < ic; ia++) {
            C->data[ia] = 0.0;
            for (iyLead = 0; iyLead < 2; iyLead++) {
                C->data[ia] += a->data[ia + a->size[0] * iyLead] * b_y1->data[iyLead];
            }
        }
    } else {
        s_idx_0 = (unsigned int)a->size[0];
        ia = C->size[0];
        C->size[0] = (int)s_idx_0;
        emxEnsureCapacity((emxArray__common *)C, ia, (int)sizeof(double));
        m = a->size[0];
        orderForDim = C->size[0];
        ia = C->size[0];
        C->size[0] = orderForDim;
        emxEnsureCapacity((emxArray__common *)C, ia, (int)sizeof(double));
        for (ia = 0; ia < orderForDim; ia++) {
            C->data[ia] = 0.0;
        }
        if (a->size[0] == 0) {
        } else {
            orderForDim = 0;
            while ((m > 0) && (orderForDim <= 0)) {
                for (ic = 1; ic <= m; ic++) {
                    C->data[ic - 1] = 0.0;
                }
                orderForDim = m;
            }
            br = 0;
            orderForDim = 0;
            while ((m > 0) && (orderForDim <= 0)) {
                orderForDim = 0;
                for (iyLead = br; iyLead + 1 <= br + 2; iyLead++) {
                    if (b_y1->data[iyLead] != 0.0) {
                        ia = orderForDim;
                        for (ic = 0; ic + 1 <= m; ic++) {
                            ia++;
                            C->data[ic] += b_y1->data[iyLead] * a->data[ia - 1];
                        }
                    }
                    orderForDim += m;
                }
                br += 2;
                orderForDim = m;
            }
        }
    }
    emxFree_real_T(&a);
    ia = s->size[0];
    emxEnsureCapacity((emxArray__common *)s, ia, (int)sizeof(double));
    ic = s->size[0];
    for (ia = 0; ia < ic; ia++) {
        s->data[ia] -= C->data[ia];
    }
    emxFree_real_T(&C);
    mu = mean(s);
    /* mean */
    orderForDim = s->size[0];
    if (s->size[0] > 1) {
        iyLead = s->size[0] - 1;
    } else {
        iyLead = s->size[0];
    }
    if (s->size[0] == 0) {
        tmp2 = 0.0;
    } else {
        ia = 0;
        work_data_idx_0 = s->data[0];
        for (ic = 2; ic <= orderForDim; ic++) {
            ia++;
            work_data_idx_0 += s->data[ia];
        }
        work_data_idx_0 /= (double)s->size[0];
        ia = 0;
        tmp1 = s->data[0] - work_data_idx_0;
        tmp2 = tmp1 * tmp1;
        for (ic = 2; ic <= orderForDim; ic++) {
            ia++;
            tmp1 = s->data[ia] - work_data_idx_0;
            tmp2 += tmp1 * tmp1;
        }
        tmp2 /= (double)iyLead;
    }
    emxInit_real_T(&b_s, 1);
    /* standard deviation */
    /*  Create a matrix of mean values by replicating the mu vector for n rows */
    repmat(mu, (double)s->size[0], b_y1);
    /*  Create a matrix of standard deviation values by replicating the sigma vector for n rows */
    repmat(std::sqrt(tmp2), (double)s->size[0], SigmaMat);
    /*  Create a matrix of zeros and ones, where ones indicate the location of outliers */
    ia = b_s->size[0];
    b_s->size[0] = s->size[0];
    emxEnsureCapacity((emxArray__common *)b_s, ia, (int)sizeof(double));
    ic = s->size[0];
    for (ia = 0; ia < ic; ia++) {
        b_s->data[ia] = s->data[ia] - b_y1->data[ia];
    }
    b_abs(b_s, b_y1);
    ia = outliers2->size[0];
    outliers2->size[0] = b_y1->size[0];
    emxEnsureCapacity((emxArray__common *)outliers2, ia, (int)sizeof(boolean_T));
    ic = b_y1->size[0];
    emxFree_real_T(&b_s);
    for (ia = 0; ia < ic; ia++) {
        outliers2->data[ia] = (b_y1->data[ia] > 3.0 * SigmaMat->data[ia]);
    }
    emxFree_real_T(&b_y1);
    emxFree_real_T(&SigmaMat);
    /*  Reference:  */
    /*  Aubert, A. E., D. Ramaekers, et al. (1999). "The analysis of heart  */
    /*  rate variability in unrestrained rats. Validation of method and  */
    /*  results." Comput Methods Programs Biomed 60(3): 197-213. */
    /* convert to logical array */
}
Пример #9
0
void sammon(sammonStackData *SD, const real_T x[1000000], real_T y[2000], real_T
            *E)
{
  real_T B;
  int32_T i;
  real_T dv0[1000];
  int32_T b_i;
  boolean_T exitg1;
  real_T alpha1;
  real_T beta1;
  char_T TRANSB;
  char_T TRANSA;
  ptrdiff_t m_t;
  ptrdiff_t n_t;
  ptrdiff_t k_t;
  ptrdiff_t lda_t;
  ptrdiff_t ldb_t;
  ptrdiff_t ldc_t;
  double * alpha1_t;
  double * Aia0_t;
  double * Bib0_t;
  double * beta1_t;
  double * Cic0_t;
  real_T g[2000];
  real_T y2[2000];
  real_T b_y[2000];
  real_T c_y[2000];
  real_T d_y[2000];
  real_T e_y[2000];
  real_T b_g[2000];
  int32_T j;
  int32_T b_j;
  boolean_T exitg2;
  real_T dv1[1000];
  real_T E_new;

  /* #codgen */
  /*  */
  /*  SAMMON - apply Sammon's nonlinear mapping  */
  /*  */
  /*     Y = SAMMON(X) applies Sammon's nonlinear mapping procedure on */
  /*     multivariate data X, where each row represents a pattern and each column */
  /*     represents a feature.  On completion, Y contains the corresponding */
  /*     co-ordinates of each point on the map.  By default, a two-dimensional */
  /*     map is created.  Note if X contains any duplicated rows, SAMMON will */
  /*     fail (ungracefully).  */
  /*  */
  /*     [Y,E] = SAMMON(X) also returns the value of the cost function in E (i.e. */
  /*     the stress of the mapping). */
  /*  */
  /*     An N-dimensional output map is generated by Y = SAMMON(X,N) . */
  /*  */
  /*     A set of optimisation options can also be specified using a third */
  /*     argument, Y = SAMMON(X,N,OPTS) , where OPTS is a structure with fields: */
  /*  */
  /*        MaxIter        - maximum number of iterations */
  /*        TolFun         - relative tolerance on objective function */
  /*        MaxHalves      - maximum number of step halvings */
  /*        Input          - {'raw','distance'} if set to 'distance', X is  */
  /*                         interpreted as a matrix of pairwise distances. */
  /*        Display        - {'off', 'on', 'iter'} */
  /*        Initialisation - {'pca', 'random'} */
  /*  */
  /*     The default options structure can be retrieved by calling SAMMON with */
  /*     no parameters. */
  /*  */
  /*     References : */
  /*  */
  /*        [1] Sammon, John W. Jr., "A Nonlinear Mapping for Data Structure */
  /*            Analysis", IEEE Transactions on Computers, vol. C-18, no. 5, */
  /*            pp 401-409, May 1969. */
  /*  */
  /*     See also : SAMMON_TEST */
  /*  */
  /*  File        : sammon.m */
  /*  */
  /*  Date        : Monday 12th November 2007. */
  /*  */
  /*  Author      : Gavin C. Cawley and Nicola L. C. Talbot */
  /*  */
  /*  Description : Simple vectorised MATLAB implementation of Sammon's non-linear */
  /*                mapping algorithm [1]. */
  /*  */
  /*  References  : [1] Sammon, John W. Jr., "A Nonlinear Mapping for Data */
  /*                    Structure Analysis", IEEE Transactions on Computers, */
  /*                    vol. C-18, no. 5, pp 401-409, May 1969. */
  /*  */
  /*  History     : 10/08/2004 - v1.00 */
  /*                11/08/2004 - v1.10 Hessian made positive semidefinite */
  /*                13/08/2004 - v1.11 minor optimisation */
  /*                12/11/2007 - v1.20 initialisation using the first n principal */
  /*                                   components. */
  /*  */
  /*  Thanks      : Dr Nick Hamilton ([email protected]) for supplying the */
  /*                code for implementing initialisation using the first n */
  /*                principal components (introduced in v1.20). */
  /*  */
  /*  To do       : The current version does not take advantage of the symmetry */
  /*                of the distance matrix in order to allow for easy */
  /*                vectorisation.  This may not be a good choice for very large */
  /*                datasets, so perhaps one day I'll get around to doing a MEX */
  /*                version using the BLAS library etc. for very large datasets. */
  /*  */
  /*  Copyright   : (c) Dr Gavin C. Cawley, November 2007. */
  /*  */
  /*     This program is free software; you can redistribute it and/or modify */
  /*     it under the terms of the GNU General Public License as published by */
  /*     the Free Software Foundation; either version 2 of the License, or */
  /*     (at your option) any later version. */
  /*  */
  /*     This program is distributed in the hope that it will be useful, */
  /*     but WITHOUT ANY WARRANTY; without even the implied warranty of */
  /*     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
  /*     GNU General Public License for more details. */
  /*  */
  /*     You should have received a copy of the GNU General Public License */
  /*     along with this program; if not, write to the Free Software */
  /*     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
  /*  */
  /*  use the default options structure */
  /*  create distance matrix unless given by parameters */
  emlrtPushRtStackR2012b(&emlrtRSI, emlrtRootTLSGlobal);
  euclid(SD, x, x, SD->f2.D);
  emlrtPopRtStackR2012b(&emlrtRSI, emlrtRootTLSGlobal);

  /*  remaining initialisation */
  B = b_sum(SD->f2.D);
  eye(SD->f2.delta);
  for (i = 0; i < 1000000; i++) {
    SD->f2.D[i] += SD->f2.delta[i];
  }

  rdivide(1.0, SD->f2.D, SD->f2.Dinv);
  emlrtPushRtStackR2012b(&b_emlrtRSI, emlrtRootTLSGlobal);
  randn(y);
  emlrtPopRtStackR2012b(&b_emlrtRSI, emlrtRootTLSGlobal);
  emlrtPushRtStackR2012b(&c_emlrtRSI, emlrtRootTLSGlobal);
  b_euclid(SD, y, y, SD->f2.d);
  eye(SD->f2.delta);
  for (i = 0; i < 1000000; i++) {
    SD->f2.d[i] += SD->f2.delta[i];
  }

  emlrtPopRtStackR2012b(&c_emlrtRSI, emlrtRootTLSGlobal);
  rdivide(1.0, SD->f2.d, SD->f2.dinv);
  for (i = 0; i < 1000000; i++) {
    SD->f2.b_D[i] = SD->f2.D[i] - SD->f2.d[i];
  }

  power(SD->f2.b_D, SD->f2.delta);
  for (i = 0; i < 1000000; i++) {
    SD->f2.d[i] = SD->f2.delta[i] * SD->f2.Dinv[i];
  }

  d_sum(SD->f2.d, dv0);
  *E = e_sum(dv0);

  /*  get on with it */
  b_i = 0;
  exitg1 = FALSE;
  while ((exitg1 == FALSE) && (b_i < 500)) {
    /*  compute gradient, Hessian and search direction (note it is actually */
    /*  1/4 of the gradient and Hessian, but the step size is just the ratio */
    /*  of the gradient and the diagonal of the Hessian so it doesn't matter). */
    for (i = 0; i < 1000000; i++) {
      SD->f2.delta[i] = SD->f2.dinv[i] - SD->f2.Dinv[i];
    }

    emlrtPushRtStackR2012b(&d_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&i_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&j_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&k_emlrtRSI, emlrtRootTLSGlobal);
    alpha1 = 1.0;
    beta1 = 0.0;
    TRANSB = 'N';
    TRANSA = 'N';
    for (i = 0; i < 2000; i++) {
      SD->f2.y_old[i] = 1.0;
      SD->f2.deltaone[i] = 0.0;
    }

    emlrtPushRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    m_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    n_t = (ptrdiff_t)(2);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    k_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    lda_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    ldb_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&q_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    ldc_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&q_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&r_emlrtRSI, emlrtRootTLSGlobal);
    alpha1_t = (double *)(&alpha1);
    emlrtPopRtStackR2012b(&r_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&s_emlrtRSI, emlrtRootTLSGlobal);
    Aia0_t = (double *)(&SD->f2.delta[0]);
    emlrtPopRtStackR2012b(&s_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal);
    Bib0_t = (double *)(&SD->f2.y_old[0]);
    emlrtPopRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&u_emlrtRSI, emlrtRootTLSGlobal);
    beta1_t = (double *)(&beta1);
    emlrtPopRtStackR2012b(&u_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&v_emlrtRSI, emlrtRootTLSGlobal);
    Cic0_t = (double *)(&SD->f2.deltaone[0]);
    emlrtPopRtStackR2012b(&v_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&w_emlrtRSI, emlrtRootTLSGlobal);
    dgemm(&TRANSA, &TRANSB, &m_t, &n_t, &k_t, alpha1_t, Aia0_t, &lda_t, Bib0_t,
          &ldb_t, beta1_t, Cic0_t, &ldc_t);
    emlrtPopRtStackR2012b(&w_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&k_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&j_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&i_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&d_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&e_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&i_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&j_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&k_emlrtRSI, emlrtRootTLSGlobal);
    alpha1 = 1.0;
    beta1 = 0.0;
    TRANSB = 'N';
    TRANSA = 'N';
    memset(&g[0], 0, 2000U * sizeof(real_T));
    emlrtPushRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    m_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    n_t = (ptrdiff_t)(2);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    k_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    lda_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    ldb_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&q_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    ldc_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&q_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&r_emlrtRSI, emlrtRootTLSGlobal);
    alpha1_t = (double *)(&alpha1);
    emlrtPopRtStackR2012b(&r_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&s_emlrtRSI, emlrtRootTLSGlobal);
    Aia0_t = (double *)(&SD->f2.delta[0]);
    emlrtPopRtStackR2012b(&s_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal);
    Bib0_t = (double *)(&y[0]);
    emlrtPopRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&u_emlrtRSI, emlrtRootTLSGlobal);
    beta1_t = (double *)(&beta1);
    emlrtPopRtStackR2012b(&u_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&v_emlrtRSI, emlrtRootTLSGlobal);
    Cic0_t = (double *)(&g[0]);
    emlrtPopRtStackR2012b(&v_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&w_emlrtRSI, emlrtRootTLSGlobal);
    dgemm(&TRANSA, &TRANSB, &m_t, &n_t, &k_t, alpha1_t, Aia0_t, &lda_t, Bib0_t,
          &ldb_t, beta1_t, Cic0_t, &ldc_t);
    emlrtPopRtStackR2012b(&w_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&k_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&j_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&i_emlrtRSI, emlrtRootTLSGlobal);
    for (i = 0; i < 2000; i++) {
      g[i] -= y[i] * SD->f2.deltaone[i];
    }

    emlrtPopRtStackR2012b(&e_emlrtRSI, emlrtRootTLSGlobal);
    c_power(SD->f2.dinv, SD->f2.delta);
    b_power(y, y2);
    emlrtPushRtStackR2012b(&f_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&i_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&j_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&k_emlrtRSI, emlrtRootTLSGlobal);
    alpha1 = 1.0;
    beta1 = 0.0;
    TRANSB = 'N';
    TRANSA = 'N';
    memset(&b_y[0], 0, 2000U * sizeof(real_T));
    emlrtPushRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    m_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    n_t = (ptrdiff_t)(2);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    k_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    lda_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    ldb_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&q_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    ldc_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&q_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&r_emlrtRSI, emlrtRootTLSGlobal);
    alpha1_t = (double *)(&alpha1);
    emlrtPopRtStackR2012b(&r_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&s_emlrtRSI, emlrtRootTLSGlobal);
    Aia0_t = (double *)(&SD->f2.delta[0]);
    emlrtPopRtStackR2012b(&s_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal);
    Bib0_t = (double *)(&y2[0]);
    emlrtPopRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&u_emlrtRSI, emlrtRootTLSGlobal);
    beta1_t = (double *)(&beta1);
    emlrtPopRtStackR2012b(&u_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&v_emlrtRSI, emlrtRootTLSGlobal);
    Cic0_t = (double *)(&b_y[0]);
    emlrtPopRtStackR2012b(&v_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&w_emlrtRSI, emlrtRootTLSGlobal);
    dgemm(&TRANSA, &TRANSB, &m_t, &n_t, &k_t, alpha1_t, Aia0_t, &lda_t, Bib0_t,
          &ldb_t, beta1_t, Cic0_t, &ldc_t);
    emlrtPopRtStackR2012b(&w_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&k_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&j_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&i_emlrtRSI, emlrtRootTLSGlobal);
    for (i = 0; i < 2000; i++) {
      c_y[i] = 2.0 * y[i];
    }

    emlrtPushRtStackR2012b(&i_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&j_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&k_emlrtRSI, emlrtRootTLSGlobal);
    alpha1 = 1.0;
    beta1 = 0.0;
    TRANSB = 'N';
    TRANSA = 'N';
    memset(&d_y[0], 0, 2000U * sizeof(real_T));
    emlrtPushRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    m_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    n_t = (ptrdiff_t)(2);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    k_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    lda_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    ldb_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&q_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    ldc_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&q_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&r_emlrtRSI, emlrtRootTLSGlobal);
    alpha1_t = (double *)(&alpha1);
    emlrtPopRtStackR2012b(&r_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&s_emlrtRSI, emlrtRootTLSGlobal);
    Aia0_t = (double *)(&SD->f2.delta[0]);
    emlrtPopRtStackR2012b(&s_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal);
    Bib0_t = (double *)(&y[0]);
    emlrtPopRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&u_emlrtRSI, emlrtRootTLSGlobal);
    beta1_t = (double *)(&beta1);
    emlrtPopRtStackR2012b(&u_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&v_emlrtRSI, emlrtRootTLSGlobal);
    Cic0_t = (double *)(&d_y[0]);
    emlrtPopRtStackR2012b(&v_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&w_emlrtRSI, emlrtRootTLSGlobal);
    dgemm(&TRANSA, &TRANSB, &m_t, &n_t, &k_t, alpha1_t, Aia0_t, &lda_t, Bib0_t,
          &ldb_t, beta1_t, Cic0_t, &ldc_t);
    emlrtPopRtStackR2012b(&w_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&k_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&j_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&i_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&i_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&j_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&k_emlrtRSI, emlrtRootTLSGlobal);
    alpha1 = 1.0;
    beta1 = 0.0;
    TRANSB = 'N';
    TRANSA = 'N';
    for (i = 0; i < 2000; i++) {
      SD->f2.y_old[i] = 1.0;
      e_y[i] = 0.0;
    }

    emlrtPushRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    m_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&l_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    n_t = (ptrdiff_t)(2);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&m_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    k_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&n_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    lda_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&o_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    ldb_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&p_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&q_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    ldc_t = (ptrdiff_t)(1000);
    emlrtPopRtStackR2012b(&x_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&q_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&r_emlrtRSI, emlrtRootTLSGlobal);
    alpha1_t = (double *)(&alpha1);
    emlrtPopRtStackR2012b(&r_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&s_emlrtRSI, emlrtRootTLSGlobal);
    Aia0_t = (double *)(&SD->f2.delta[0]);
    emlrtPopRtStackR2012b(&s_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal);
    Bib0_t = (double *)(&SD->f2.y_old[0]);
    emlrtPopRtStackR2012b(&t_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&u_emlrtRSI, emlrtRootTLSGlobal);
    beta1_t = (double *)(&beta1);
    emlrtPopRtStackR2012b(&u_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&v_emlrtRSI, emlrtRootTLSGlobal);
    Cic0_t = (double *)(&e_y[0]);
    emlrtPopRtStackR2012b(&v_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPushRtStackR2012b(&w_emlrtRSI, emlrtRootTLSGlobal);
    dgemm(&TRANSA, &TRANSB, &m_t, &n_t, &k_t, alpha1_t, Aia0_t, &lda_t, Bib0_t,
          &ldb_t, beta1_t, Cic0_t, &ldc_t);
    emlrtPopRtStackR2012b(&w_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&k_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&j_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&i_emlrtRSI, emlrtRootTLSGlobal);
    emlrtPopRtStackR2012b(&f_emlrtRSI, emlrtRootTLSGlobal);
    for (i = 0; i < 2000; i++) {
      SD->f2.y_old[i] = ((b_y[i] - SD->f2.deltaone[i]) - c_y[i] * d_y[i]) + y2[i]
        * e_y[i];
      b_g[i] = -g[i];
    }

    b_abs(SD->f2.y_old, y2);
    for (i = 0; i < 2000; i++) {
      SD->f2.deltaone[i] = y2[i];
      SD->f2.y_old[i] = y[i];
    }

    b_rdivide(b_g, SD->f2.deltaone, y2);

    /*  use step-halving procedure to ensure progress is made */
    j = 1;
    b_j = 0;
    exitg2 = FALSE;
    while ((exitg2 == FALSE) && (b_j < 20)) {
      j = b_j + 1;
      for (i = 0; i < 2000; i++) {
        y[i] = SD->f2.y_old[i] + y2[i];
      }

      emlrtPushRtStackR2012b(&g_emlrtRSI, emlrtRootTLSGlobal);
      b_euclid(SD, y, y, SD->f2.d);
      eye(SD->f2.delta);
      for (i = 0; i < 1000000; i++) {
        SD->f2.d[i] += SD->f2.delta[i];
      }

      emlrtPopRtStackR2012b(&g_emlrtRSI, emlrtRootTLSGlobal);
      rdivide(1.0, SD->f2.d, SD->f2.dinv);
      for (i = 0; i < 1000000; i++) {
        SD->f2.b_D[i] = SD->f2.D[i] - SD->f2.d[i];
      }

      power(SD->f2.b_D, SD->f2.delta);
      for (i = 0; i < 1000000; i++) {
        SD->f2.d[i] = SD->f2.delta[i] * SD->f2.Dinv[i];
      }

      d_sum(SD->f2.d, dv1);
      E_new = e_sum(dv1);
      if (E_new < *E) {
        exitg2 = TRUE;
      } else {
        for (i = 0; i < 2000; i++) {
          y2[i] *= 0.5;
        }

        b_j++;
        emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar,
          emlrtRootTLSGlobal);
      }
    }

    /*  bomb out if too many halving steps are required */
    if ((j == 20) || (muDoubleScalarAbs((*E - E_new) / *E) < 1.0E-9)) {
      exitg1 = TRUE;
    } else {
      /*  evaluate termination criterion */
      /*  report progress */
      *E = E_new;
      b_i++;
      emlrtBreakCheckFastR2012b(emlrtBreakCheckR2012bFlagVar, emlrtRootTLSGlobal);
    }
  }

  /*  fiddle stress to match the original Sammon paper */
  *E *= 0.5 / B;
}
Пример #10
0
/* Function Definitions */
static real_T rectifier(const creal_T x[5120])
{
  real_T dv6[5120];
  b_abs(x, dv6);
  return mean(dv6);
}
Пример #11
0
void b_Acoeff(const emlrtStack *sp, real_T ksi, real_T j, const emxArray_real_T *
              x, real_T t, const emxArray_real_T *gridT, emxArray_real_T *vals)
{
  emxArray_real_T *b;
  emxArray_real_T *r8;
  int32_T b_x;
  int32_T i;
  emxArray_boolean_T *b_t;
  real_T c_x;
  emxArray_boolean_T *c_t;
  emxArray_real_T *z0;
  emxArray_real_T *d_x;
  emxArray_real_T *e_x;
  emxArray_real_T *r9;
  int32_T b_b[2];
  int32_T f_x[2];
  emxArray_real_T *g_x;
  emxArray_real_T *r10;
  const mxArray *y;
  static const int32_T iv16[2] = { 1, 45 };

  const mxArray *m6;
  char_T cv18[45];
  static const char_T cv19[45] = { 'C', 'o', 'd', 'e', 'r', ':', 't', 'o', 'o',
    'l', 'b', 'o', 'x', ':', 'm', 't', 'i', 'm', 'e', 's', '_', 'n', 'o', 'D',
    'y', 'n', 'a', 'm', 'i', 'c', 'S', 'c', 'a', 'l', 'a', 'r', 'E', 'x', 'p',
    'a', 'n', 's', 'i', 'o', 'n' };

  const mxArray *b_y;
  static const int32_T iv17[2] = { 1, 21 };

  char_T cv20[21];
  static const char_T cv21[21] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T',
    'L', 'A', 'B', ':', 'i', 'n', 'n', 'e', 'r', 'd', 'i', 'm' };

  emxArray_boolean_T *d_t;
  real_T h_x;
  emxArray_boolean_T *e_t;
  emxArray_real_T *i_x;
  emxArray_real_T *r11;
  emxArray_real_T *j_x;
  emxArray_real_T *r12;
  emxArray_real_T *z1;
  int32_T b_z0[2];
  emxArray_real_T *c_z0;
  emxArray_real_T *k_x;
  const mxArray *c_y;
  static const int32_T iv18[2] = { 1, 45 };

  const mxArray *d_y;
  static const int32_T iv19[2] = { 1, 21 };

  emlrtStack st;
  emlrtStack b_st;
  emlrtStack c_st;
  emlrtStack d_st;
  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;
  d_st.prev = &b_st;
  d_st.tls = b_st.tls;
  emlrtHeapReferenceStackEnterFcnR2012b(sp);
  emxInit_real_T(sp, &b, 2, &bb_emlrtRTEI, true);
  emxInit_real_T(sp, &r8, 2, &bb_emlrtRTEI, true);

  /*  evaluate the coefficient A at the  boundary ksi=0 or ksi=1; */
  /*  for the index j which describes the time steps timePoints_j, at time t and space */
  /*  point x */
  /*  timePoints is a vector describing the time descritized domain */
  b_x = gridT->size[1];
  i = (int32_T)emlrtIntegerCheckFastR2012b(j, &emlrtDCI, sp);
  if (t <= gridT->data[emlrtDynamicBoundsCheckFastR2012b(i, 1, b_x, &d_emlrtBCI,
       sp) - 1]) {
    b_x = vals->size[0] * vals->size[1];
    vals->size[0] = 1;
    vals->size[1] = 1;
    emxEnsureCapacity(sp, (emxArray__common *)vals, b_x, (int32_T)sizeof(real_T),
                      &bb_emlrtRTEI);
    vals->data[0] = 0.0;
  } else {
    emxInit_boolean_T(sp, &b_t, 2, &bb_emlrtRTEI, true);
    b_x = b_t->size[0] * b_t->size[1];
    b_t->size[0] = 1;
    b_t->size[1] = 2 + x->size[1];
    emxEnsureCapacity(sp, (emxArray__common *)b_t, b_x, (int32_T)sizeof
                      (boolean_T), &bb_emlrtRTEI);
    b_x = gridT->size[1];
    i = (int32_T)j;
    b_t->data[0] = (t > gridT->data[emlrtDynamicBoundsCheckFastR2012b(i, 1, b_x,
      &e_emlrtBCI, sp) - 1]);
    b_x = gridT->size[1];
    i = (int32_T)((uint32_T)j + 1U);
    b_t->data[b_t->size[0]] = (t <= gridT->
      data[emlrtDynamicBoundsCheckFastR2012b(i, 1, b_x, &f_emlrtBCI, sp) - 1]);
    i = x->size[1];
    for (b_x = 0; b_x < i; b_x++) {
      b_t->data[b_t->size[0] * (b_x + 2)] = (x->data[x->size[0] * b_x] == ksi);
    }

    st.site = &pe_emlrtRSI;
    if (all(&st, b_t)) {
      b_x = gridT->size[1];
      i = (int32_T)j;
      emlrtDynamicBoundsCheckFastR2012b(i, 1, b_x, &c_emlrtBCI, sp);
      c_x = (t - gridT->data[(int32_T)j - 1]) / 3.1415926535897931;
      st.site = &emlrtRSI;
      if (c_x < 0.0) {
        b_st.site = &f_emlrtRSI;
        eml_error(&b_st);
      }

      b_x = vals->size[0] * vals->size[1];
      vals->size[0] = 1;
      vals->size[1] = 1;
      emxEnsureCapacity(sp, (emxArray__common *)vals, b_x, (int32_T)sizeof
                        (real_T), &bb_emlrtRTEI);
      vals->data[0] = muDoubleScalarSqrt(c_x);
    } else {
      emxInit_boolean_T(sp, &c_t, 2, &bb_emlrtRTEI, true);
      b_x = c_t->size[0] * c_t->size[1];
      c_t->size[0] = 1;
      c_t->size[1] = 2 + x->size[1];
      emxEnsureCapacity(sp, (emxArray__common *)c_t, b_x, (int32_T)sizeof
                        (boolean_T), &bb_emlrtRTEI);
      b_x = gridT->size[1];
      i = (int32_T)j;
      c_t->data[0] = (t > gridT->data[emlrtDynamicBoundsCheckFastR2012b(i, 1,
        b_x, &g_emlrtBCI, sp) - 1]);
      b_x = gridT->size[1];
      i = (int32_T)((uint32_T)j + 1U);
      c_t->data[c_t->size[0]] = (t <= gridT->
        data[emlrtDynamicBoundsCheckFastR2012b(i, 1, b_x, &h_emlrtBCI, sp) - 1]);
      i = x->size[1];
      for (b_x = 0; b_x < i; b_x++) {
        c_t->data[c_t->size[0] * (b_x + 2)] = (x->data[x->size[0] * b_x] != ksi);
      }

      emxInit_real_T(sp, &z0, 2, &cb_emlrtRTEI, true);
      emxInit_real_T(sp, &d_x, 2, &bb_emlrtRTEI, true);
      st.site = &qe_emlrtRSI;
      if (all(&st, c_t)) {
        st.site = &b_emlrtRSI;
        b_x = gridT->size[1];
        i = (int32_T)j;
        c_x = t - gridT->data[emlrtDynamicBoundsCheckFastR2012b(i, 1, b_x,
          &m_emlrtBCI, &st) - 1];
        if (c_x < 0.0) {
          b_st.site = &f_emlrtRSI;
          eml_error(&b_st);
        }

        emxInit_real_T(&st, &e_x, 2, &bb_emlrtRTEI, true);
        b_x = e_x->size[0] * e_x->size[1];
        e_x->size[0] = 1;
        e_x->size[1] = x->size[1];
        emxEnsureCapacity(sp, (emxArray__common *)e_x, b_x, (int32_T)sizeof
                          (real_T), &bb_emlrtRTEI);
        i = x->size[0] * x->size[1];
        for (b_x = 0; b_x < i; b_x++) {
          e_x->data[b_x] = x->data[b_x] - ksi;
        }

        emxInit_real_T(sp, &r9, 2, &bb_emlrtRTEI, true);
        b_abs(sp, e_x, r9);
        b_x = r8->size[0] * r8->size[1];
        r8->size[0] = 1;
        r8->size[1] = r9->size[1];
        emxEnsureCapacity(sp, (emxArray__common *)r8, b_x, (int32_T)sizeof
                          (real_T), &bb_emlrtRTEI);
        i = r9->size[0] * r9->size[1];
        emxFree_real_T(&e_x);
        for (b_x = 0; b_x < i; b_x++) {
          r8->data[b_x] = r9->data[b_x];
        }

        emxFree_real_T(&r9);
        rdivide(sp, r8, 2.0 * muDoubleScalarSqrt(c_x), z0);
        st.site = &re_emlrtRSI;
        mpower(&st, z0, d_x);
        b_x = d_x->size[0] * d_x->size[1];
        d_x->size[0] = 1;
        emxEnsureCapacity(sp, (emxArray__common *)d_x, b_x, (int32_T)sizeof
                          (real_T), &bb_emlrtRTEI);
        i = d_x->size[0];
        b_x = d_x->size[1];
        i *= b_x;
        for (b_x = 0; b_x < i; b_x++) {
          d_x->data[b_x] = -d_x->data[b_x];
        }

        b_x = b->size[0] * b->size[1];
        b->size[0] = 1;
        b->size[1] = d_x->size[1];
        emxEnsureCapacity(sp, (emxArray__common *)b, b_x, (int32_T)sizeof(real_T),
                          &bb_emlrtRTEI);
        i = d_x->size[0] * d_x->size[1];
        for (b_x = 0; b_x < i; b_x++) {
          b->data[b_x] = d_x->data[b_x];
        }

        for (i = 0; i < d_x->size[1]; i++) {
          b->data[i] = muDoubleScalarExp(b->data[i]);
        }

        st.site = &re_emlrtRSI;
        b_mrdivide(&st, b, z0);
        for (b_x = 0; b_x < 2; b_x++) {
          i = d_x->size[0] * d_x->size[1];
          d_x->size[b_x] = z0->size[b_x];
          emxEnsureCapacity(sp, (emxArray__common *)d_x, i, (int32_T)sizeof
                            (real_T), &ab_emlrtRTEI);
        }

        for (i = 0; i < z0->size[1]; i++) {
          d_x->data[i] = scalar_erf(z0->data[i]);
        }

        b_x = d_x->size[0] * d_x->size[1];
        d_x->size[0] = 1;
        emxEnsureCapacity(sp, (emxArray__common *)d_x, b_x, (int32_T)sizeof
                          (real_T), &bb_emlrtRTEI);
        i = d_x->size[0];
        b_x = d_x->size[1];
        i *= b_x;
        for (b_x = 0; b_x < i; b_x++) {
          d_x->data[b_x] *= 1.7724538509055159;
        }

        for (b_x = 0; b_x < 2; b_x++) {
          b_b[b_x] = b->size[b_x];
        }

        for (b_x = 0; b_x < 2; b_x++) {
          f_x[b_x] = d_x->size[b_x];
        }

        emxInit_real_T(sp, &g_x, 2, &bb_emlrtRTEI, true);
        emlrtSizeEqCheck2DFastR2012b(b_b, f_x, &o_emlrtECI, sp);
        b_x = g_x->size[0] * g_x->size[1];
        g_x->size[0] = 1;
        g_x->size[1] = x->size[1];
        emxEnsureCapacity(sp, (emxArray__common *)g_x, b_x, (int32_T)sizeof
                          (real_T), &bb_emlrtRTEI);
        i = x->size[0] * x->size[1];
        for (b_x = 0; b_x < i; b_x++) {
          g_x->data[b_x] = x->data[b_x] - ksi;
        }

        emxInit_real_T(sp, &r10, 2, &bb_emlrtRTEI, true);
        b_abs(sp, g_x, r10);
        b_x = r8->size[0] * r8->size[1];
        r8->size[0] = 1;
        r8->size[1] = r10->size[1];
        emxEnsureCapacity(sp, (emxArray__common *)r8, b_x, (int32_T)sizeof
                          (real_T), &bb_emlrtRTEI);
        i = r10->size[0] * r10->size[1];
        emxFree_real_T(&g_x);
        for (b_x = 0; b_x < i; b_x++) {
          r8->data[b_x] = r10->data[b_x];
        }

        emxFree_real_T(&r10);
        rdivide(sp, r8, 3.5449077018110318, vals);
        st.site = &re_emlrtRSI;
        b_x = b->size[0] * b->size[1];
        b->size[0] = 1;
        emxEnsureCapacity(&st, (emxArray__common *)b, b_x, (int32_T)sizeof
                          (real_T), &bb_emlrtRTEI);
        i = b->size[0];
        b_x = b->size[1];
        i *= b_x;
        for (b_x = 0; b_x < i; b_x++) {
          b->data[b_x] -= d_x->data[b_x];
        }

        b_st.site = &he_emlrtRSI;
        if (!(vals->size[1] == 1)) {
          if ((vals->size[1] == 1) || (b->size[1] == 1)) {
            y = NULL;
            m6 = emlrtCreateCharArray(2, iv16);
            for (i = 0; i < 45; i++) {
              cv18[i] = cv19[i];
            }

            emlrtInitCharArrayR2013a(&b_st, 45, m6, cv18);
            emlrtAssign(&y, m6);
            c_st.site = &fh_emlrtRSI;
            d_st.site = &vg_emlrtRSI;
            b_error(&c_st, message(&d_st, y, &j_emlrtMCI), &k_emlrtMCI);
          } else {
            b_y = NULL;
            m6 = emlrtCreateCharArray(2, iv17);
            for (i = 0; i < 21; i++) {
              cv20[i] = cv21[i];
            }

            emlrtInitCharArrayR2013a(&b_st, 21, m6, cv20);
            emlrtAssign(&b_y, m6);
            c_st.site = &gh_emlrtRSI;
            d_st.site = &wg_emlrtRSI;
            b_error(&c_st, message(&d_st, b_y, &l_emlrtMCI), &m_emlrtMCI);
          }
        }

        c_x = vals->data[0];
        b_x = vals->size[0] * vals->size[1];
        vals->size[0] = 1;
        vals->size[1] = b->size[1];
        emxEnsureCapacity(&st, (emxArray__common *)vals, b_x, (int32_T)sizeof
                          (real_T), &bb_emlrtRTEI);
        i = b->size[1];
        for (b_x = 0; b_x < i; b_x++) {
          vals->data[vals->size[0] * b_x] = c_x * b->data[b->size[0] * b_x];
        }
      } else {
        emxInit_boolean_T(sp, &d_t, 2, &bb_emlrtRTEI, true);
        b_x = d_t->size[0] * d_t->size[1];
        d_t->size[0] = 1;
        d_t->size[1] = 1 + x->size[1];
        emxEnsureCapacity(sp, (emxArray__common *)d_t, b_x, (int32_T)sizeof
                          (boolean_T), &bb_emlrtRTEI);
        b_x = gridT->size[1];
        i = (int32_T)((uint32_T)j + 1U);
        d_t->data[0] = (t > gridT->data[emlrtDynamicBoundsCheckFastR2012b(i, 1,
          b_x, &i_emlrtBCI, sp) - 1]);
        i = x->size[1];
        for (b_x = 0; b_x < i; b_x++) {
          d_t->data[d_t->size[0] * (b_x + 1)] = (x->data[x->size[0] * b_x] ==
            ksi);
        }

        st.site = &se_emlrtRSI;
        if (all(&st, d_t)) {
          b_x = gridT->size[1];
          i = (int32_T)j;
          emlrtDynamicBoundsCheckFastR2012b(i, 1, b_x, &b_emlrtBCI, sp);
          c_x = (t - gridT->data[(int32_T)j - 1]) / 3.1415926535897931;
          b_x = gridT->size[1];
          i = (int32_T)(j + 1.0);
          emlrtDynamicBoundsCheckFastR2012b(i, 1, b_x, &emlrtBCI, sp);
          h_x = (t - gridT->data[(int32_T)(j + 1.0) - 1]) / 3.1415926535897931;
          st.site = &c_emlrtRSI;
          if (c_x < 0.0) {
            b_st.site = &f_emlrtRSI;
            eml_error(&b_st);
          }

          st.site = &c_emlrtRSI;
          if (h_x < 0.0) {
            b_st.site = &f_emlrtRSI;
            eml_error(&b_st);
          }

          b_x = vals->size[0] * vals->size[1];
          vals->size[0] = 1;
          vals->size[1] = 1;
          emxEnsureCapacity(sp, (emxArray__common *)vals, b_x, (int32_T)sizeof
                            (real_T), &bb_emlrtRTEI);
          vals->data[0] = muDoubleScalarSqrt(c_x) - muDoubleScalarSqrt(h_x);
        } else {
          emxInit_boolean_T(sp, &e_t, 2, &bb_emlrtRTEI, true);
          b_x = e_t->size[0] * e_t->size[1];
          e_t->size[0] = 1;
          e_t->size[1] = 1 + x->size[1];
          emxEnsureCapacity(sp, (emxArray__common *)e_t, b_x, (int32_T)sizeof
                            (boolean_T), &bb_emlrtRTEI);
          b_x = gridT->size[1];
          i = (int32_T)((uint32_T)j + 1U);
          e_t->data[0] = (t > gridT->data[emlrtDynamicBoundsCheckFastR2012b(i, 1,
            b_x, &j_emlrtBCI, sp) - 1]);
          i = x->size[1];
          for (b_x = 0; b_x < i; b_x++) {
            e_t->data[e_t->size[0] * (b_x + 1)] = (x->data[x->size[0] * b_x] !=
              ksi);
          }

          st.site = &te_emlrtRSI;
          if (all(&st, e_t)) {
            st.site = &d_emlrtRSI;
            b_x = gridT->size[1];
            i = (int32_T)j;
            c_x = t - gridT->data[emlrtDynamicBoundsCheckFastR2012b(i, 1, b_x,
              &k_emlrtBCI, &st) - 1];
            if (c_x < 0.0) {
              b_st.site = &f_emlrtRSI;
              eml_error(&b_st);
            }

            emxInit_real_T(&st, &i_x, 2, &bb_emlrtRTEI, true);
            b_x = i_x->size[0] * i_x->size[1];
            i_x->size[0] = 1;
            i_x->size[1] = x->size[1];
            emxEnsureCapacity(sp, (emxArray__common *)i_x, b_x, (int32_T)sizeof
                              (real_T), &bb_emlrtRTEI);
            i = x->size[0] * x->size[1];
            for (b_x = 0; b_x < i; b_x++) {
              i_x->data[b_x] = x->data[b_x] - ksi;
            }

            emxInit_real_T(sp, &r11, 2, &bb_emlrtRTEI, true);
            b_abs(sp, i_x, r11);
            b_x = r8->size[0] * r8->size[1];
            r8->size[0] = 1;
            r8->size[1] = r11->size[1];
            emxEnsureCapacity(sp, (emxArray__common *)r8, b_x, (int32_T)sizeof
                              (real_T), &bb_emlrtRTEI);
            i = r11->size[0] * r11->size[1];
            emxFree_real_T(&i_x);
            for (b_x = 0; b_x < i; b_x++) {
              r8->data[b_x] = r11->data[b_x];
            }

            emxFree_real_T(&r11);
            rdivide(sp, r8, 2.0 * muDoubleScalarSqrt(c_x), z0);
            st.site = &e_emlrtRSI;
            b_x = gridT->size[1];
            i = (int32_T)((uint32_T)j + 1U);
            c_x = t - gridT->data[emlrtDynamicBoundsCheckFastR2012b(i, 1, b_x,
              &l_emlrtBCI, &st) - 1];
            if (c_x < 0.0) {
              b_st.site = &f_emlrtRSI;
              eml_error(&b_st);
            }

            emxInit_real_T(&st, &j_x, 2, &bb_emlrtRTEI, true);
            b_x = j_x->size[0] * j_x->size[1];
            j_x->size[0] = 1;
            j_x->size[1] = x->size[1];
            emxEnsureCapacity(sp, (emxArray__common *)j_x, b_x, (int32_T)sizeof
                              (real_T), &bb_emlrtRTEI);
            i = x->size[0] * x->size[1];
            for (b_x = 0; b_x < i; b_x++) {
              j_x->data[b_x] = x->data[b_x] - ksi;
            }

            emxInit_real_T(sp, &r12, 2, &bb_emlrtRTEI, true);
            b_abs(sp, j_x, r12);
            b_x = r8->size[0] * r8->size[1];
            r8->size[0] = 1;
            r8->size[1] = r12->size[1];
            emxEnsureCapacity(sp, (emxArray__common *)r8, b_x, (int32_T)sizeof
                              (real_T), &bb_emlrtRTEI);
            i = r12->size[0] * r12->size[1];
            emxFree_real_T(&j_x);
            for (b_x = 0; b_x < i; b_x++) {
              r8->data[b_x] = r12->data[b_x];
            }

            emxFree_real_T(&r12);
            emxInit_real_T(sp, &z1, 2, &db_emlrtRTEI, true);
            rdivide(sp, r8, 2.0 * muDoubleScalarSqrt(c_x), z1);
            st.site = &ue_emlrtRSI;
            mpower(&st, z0, d_x);
            b_x = d_x->size[0] * d_x->size[1];
            d_x->size[0] = 1;
            emxEnsureCapacity(sp, (emxArray__common *)d_x, b_x, (int32_T)sizeof
                              (real_T), &bb_emlrtRTEI);
            i = d_x->size[0];
            b_x = d_x->size[1];
            i *= b_x;
            for (b_x = 0; b_x < i; b_x++) {
              d_x->data[b_x] = -d_x->data[b_x];
            }

            b_x = b->size[0] * b->size[1];
            b->size[0] = 1;
            b->size[1] = d_x->size[1];
            emxEnsureCapacity(sp, (emxArray__common *)b, b_x, (int32_T)sizeof
                              (real_T), &bb_emlrtRTEI);
            i = d_x->size[0] * d_x->size[1];
            for (b_x = 0; b_x < i; b_x++) {
              b->data[b_x] = d_x->data[b_x];
            }

            for (i = 0; i < d_x->size[1]; i++) {
              b->data[i] = muDoubleScalarExp(b->data[i]);
            }

            st.site = &ue_emlrtRSI;
            b_mrdivide(&st, b, z0);
            st.site = &ue_emlrtRSI;
            mpower(&st, z1, d_x);
            b_x = d_x->size[0] * d_x->size[1];
            d_x->size[0] = 1;
            emxEnsureCapacity(sp, (emxArray__common *)d_x, b_x, (int32_T)sizeof
                              (real_T), &bb_emlrtRTEI);
            i = d_x->size[0];
            b_x = d_x->size[1];
            i *= b_x;
            for (b_x = 0; b_x < i; b_x++) {
              d_x->data[b_x] = -d_x->data[b_x];
            }

            b_x = r8->size[0] * r8->size[1];
            r8->size[0] = 1;
            r8->size[1] = d_x->size[1];
            emxEnsureCapacity(sp, (emxArray__common *)r8, b_x, (int32_T)sizeof
                              (real_T), &bb_emlrtRTEI);
            i = d_x->size[0] * d_x->size[1];
            for (b_x = 0; b_x < i; b_x++) {
              r8->data[b_x] = d_x->data[b_x];
            }

            for (i = 0; i < d_x->size[1]; i++) {
              r8->data[i] = muDoubleScalarExp(r8->data[i]);
            }

            st.site = &ue_emlrtRSI;
            b_mrdivide(&st, r8, z1);
            for (b_x = 0; b_x < 2; b_x++) {
              b_b[b_x] = b->size[b_x];
            }

            for (b_x = 0; b_x < 2; b_x++) {
              b_z0[b_x] = r8->size[b_x];
            }

            emxInit_real_T(sp, &c_z0, 2, &bb_emlrtRTEI, true);
            emlrtSizeEqCheck2DFastR2012b(b_b, b_z0, &m_emlrtECI, sp);
            b_x = c_z0->size[0] * c_z0->size[1];
            c_z0->size[0] = 1;
            c_z0->size[1] = z0->size[1];
            emxEnsureCapacity(sp, (emxArray__common *)c_z0, b_x, (int32_T)sizeof
                              (real_T), &bb_emlrtRTEI);
            i = z0->size[0] * z0->size[1];
            for (b_x = 0; b_x < i; b_x++) {
              c_z0->data[b_x] = z0->data[b_x];
            }

            b_erf(sp, c_z0, z0);
            b_erf(sp, z1, d_x);
            emxFree_real_T(&c_z0);
            emxFree_real_T(&z1);
            for (b_x = 0; b_x < 2; b_x++) {
              b_z0[b_x] = z0->size[b_x];
            }

            for (b_x = 0; b_x < 2; b_x++) {
              f_x[b_x] = d_x->size[b_x];
            }

            emlrtSizeEqCheck2DFastR2012b(b_z0, f_x, &n_emlrtECI, sp);
            b_x = z0->size[0] * z0->size[1];
            z0->size[0] = 1;
            emxEnsureCapacity(sp, (emxArray__common *)z0, b_x, (int32_T)sizeof
                              (real_T), &bb_emlrtRTEI);
            i = z0->size[0];
            b_x = z0->size[1];
            i *= b_x;
            for (b_x = 0; b_x < i; b_x++) {
              z0->data[b_x] = 1.7724538509055159 * (z0->data[b_x] - d_x->
                data[b_x]);
            }

            for (b_x = 0; b_x < 2; b_x++) {
              b_b[b_x] = b->size[b_x];
            }

            for (b_x = 0; b_x < 2; b_x++) {
              b_z0[b_x] = z0->size[b_x];
            }

            emxInit_real_T(sp, &k_x, 2, &bb_emlrtRTEI, true);
            emlrtSizeEqCheck2DFastR2012b(b_b, b_z0, &m_emlrtECI, sp);
            b_x = k_x->size[0] * k_x->size[1];
            k_x->size[0] = 1;
            k_x->size[1] = x->size[1];
            emxEnsureCapacity(sp, (emxArray__common *)k_x, b_x, (int32_T)sizeof
                              (real_T), &bb_emlrtRTEI);
            i = x->size[0] * x->size[1];
            for (b_x = 0; b_x < i; b_x++) {
              k_x->data[b_x] = x->data[b_x] - ksi;
            }

            b_abs(sp, k_x, d_x);
            rdivide(sp, d_x, 3.5449077018110318, vals);
            st.site = &ue_emlrtRSI;
            b_x = b->size[0] * b->size[1];
            b->size[0] = 1;
            emxEnsureCapacity(&st, (emxArray__common *)b, b_x, (int32_T)sizeof
                              (real_T), &bb_emlrtRTEI);
            i = b->size[0];
            b_x = b->size[1];
            i *= b_x;
            emxFree_real_T(&k_x);
            for (b_x = 0; b_x < i; b_x++) {
              b->data[b_x] = (b->data[b_x] - r8->data[b_x]) + z0->data[b_x];
            }

            b_st.site = &he_emlrtRSI;
            if (!(vals->size[1] == 1)) {
              if ((vals->size[1] == 1) || (b->size[1] == 1)) {
                c_y = NULL;
                m6 = emlrtCreateCharArray(2, iv18);
                for (i = 0; i < 45; i++) {
                  cv18[i] = cv19[i];
                }

                emlrtInitCharArrayR2013a(&b_st, 45, m6, cv18);
                emlrtAssign(&c_y, m6);
                c_st.site = &fh_emlrtRSI;
                d_st.site = &vg_emlrtRSI;
                b_error(&c_st, message(&d_st, c_y, &j_emlrtMCI), &k_emlrtMCI);
              } else {
                d_y = NULL;
                m6 = emlrtCreateCharArray(2, iv19);
                for (i = 0; i < 21; i++) {
                  cv20[i] = cv21[i];
                }

                emlrtInitCharArrayR2013a(&b_st, 21, m6, cv20);
                emlrtAssign(&d_y, m6);
                c_st.site = &gh_emlrtRSI;
                d_st.site = &wg_emlrtRSI;
                b_error(&c_st, message(&d_st, d_y, &l_emlrtMCI), &m_emlrtMCI);
              }
            }

            c_x = vals->data[0];
            b_x = vals->size[0] * vals->size[1];
            vals->size[0] = 1;
            vals->size[1] = b->size[1];
            emxEnsureCapacity(&st, (emxArray__common *)vals, b_x, (int32_T)
                              sizeof(real_T), &bb_emlrtRTEI);
            i = b->size[1];
            for (b_x = 0; b_x < i; b_x++) {
              vals->data[vals->size[0] * b_x] = c_x * b->data[b->size[0] * b_x];
            }
          } else {
            b_x = vals->size[0] * vals->size[1];
            vals->size[0] = 1;
            vals->size[1] = 1;
            emxEnsureCapacity(sp, (emxArray__common *)vals, b_x, (int32_T)sizeof
                              (real_T), &bb_emlrtRTEI);
            vals->data[0] = 0.0;
          }

          emxFree_boolean_T(&e_t);
        }

        emxFree_boolean_T(&d_t);
      }

      emxFree_boolean_T(&c_t);
      emxFree_real_T(&d_x);
      emxFree_real_T(&z0);
    }

    emxFree_boolean_T(&b_t);
  }

  emxFree_real_T(&r8);
  emxFree_real_T(&b);
  emlrtHeapReferenceStackLeaveFcnR2012b(sp);
}
Пример #12
0
void a_melcepst(const real_T s[512], real_T fs, int32_T nc, emxArray_real_T *c)
{
  real_T b_s[512];
  int32_T i;
  static const real_T dv0[512] = { 0.080000000000000016, 0.080034772851092173,
    0.080139086147189731, 0.080312924117550422, 0.0805562604802531,
    0.08086905844617126, 0.081251270724534919, 0.0817028395300804,
    0.082223696591786744, 0.082813763163197218, 0.083472950034324755,
    0.084201157545139238, 0.084998275600634943, 0.085864183687475115,
    0.086798750892212118, 0.0878018359210796, 0.0888732871213544,
    0.0900129425042841, 0.091220629769577732, 0.092496166331455187,
    0.093839359346251483, 0.095250005741572386, 0.09672789224699585,
    0.09827279542631584, 0.099884481711322914, 0.10156270743711604,
    0.10330721887894206, 0.10511775229055487, 0.10699403394409035,
    0.10893578017145067, 0.11094269740719032, 0.11301448223289995,
    0.11515082142307836, 0.11735139199248851, 0.11961586124498802,
    0.12194388682382867, 0.12433511676341558, 0.12678918954252011,
    0.12930573413893637, 0.1318843700855753, 0.13452470752798562,
    0.13722634728329447, 0.13998888090055894, 0.1428118907225176,
    0.14569494994873494, 0.14863762270012759, 0.1516394640848634,
    0.15470002026562302, 0.15781882852821355, 0.16099541735152506,
    0.16422930647881784, 0.16752000699033076, 0.17086702137719906,
    0.17426984361667108, 0.177727959248612, 0.181240845453283,
    0.18480797113038444, 0.18842879697935122, 0.19210277558088723,
    0.19582935147972808, 0.19960796126861807, 0.20343803367348967,
    0.20731898963983236, 0.211250242420238, 0.21523119766310839,
    0.2192612535025138, 0.2233398006491864, 0.22746622248263659,
    0.23163989514437766, 0.23586018763224437, 0.24012646189579223,
    0.24443807293276187, 0.24879436888659412, 0.25319469114498255,
    0.25763837443944609, 0.26212474694590859, 0.26665313038626953,
    0.27122284013095055, 0.27583318530240147, 0.28048346887955239,
    0.28517298780319289, 0.2899010330822655, 0.29466688990105527,
    0.29946983772726005, 0.30430915042092521, 0.30918409634422606,
    0.31409393847208128, 0.31903793450358153, 0.32401533697421447,
    0.32902539336887182, 0.33406734623561868, 0.33914043330021065,
    0.34424388758133867, 0.34937693750658638, 0.35453880702908114,
    0.35972871574482179, 0.36494587901066489, 0.3701895080629527,
    0.37545881013676219, 0.38075298858576168, 0.38607124300265128,
    0.39141276934017522, 0.39677676003268147, 0.40216240411821519,
    0.40756888736112512, 0.41299539237516436, 0.41844109874706864,
    0.42390518316059117, 0.4293868195209769, 0.43488517907985663,
    0.44039943056054276, 0.44592874028370622, 0.45147227229341824,
    0.45702918848353491, 0.46259864872440754, 0.46817981098989864,
    0.47377183148468471, 0.47937386477182686, 0.48498506390058893,
    0.490604580534485, 0.49623156507953636, 0.50186516681271842,
    0.50750453401057793, 0.51314881407800261, 0.51879715367712187,
    0.524448698856319, 0.53010259517933778, 0.53575798785446094,
    0.54141402186374354, 0.5470698420922796, 0.55272459345748381,
    0.55837742103836852, 0.5640274702047956, 0.56967388674668551,
    0.57531581700316159, 0.58095240799161241, 0.58658280753665026,
    0.59220616439894935, 0.59782162840394082, 0.60342835057034794,
    0.60902548323854022, 0.61461218019868813, 0.62018759681869828,
    0.62575089017190988, 0.63130121916453474, 0.63683774466281806,
    0.64235962961990467, 0.64786603920238861, 0.65335614091652849,
    0.65882910473410994, 0.66428410321793319, 0.6697203116469117,
    0.67513690814075755, 0.68053307378423888, 0.68590799275098879,
    0.69126085242684687, 0.69659084353271583, 0.70189716024691284,
    0.70717900032699887, 0.7124355652310671, 0.717666060238471,
    0.72286969456997574, 0.72804568150731275, 0.73319323851212115,
    0.73831158734425673, 0.74339995417945037, 0.74845756972630173,
    0.75348366934258248, 0.75847749315084323, 0.76343828615329357,
    0.7683652983459498, 0.77325778483202323, 0.77811500593454008,
    0.78293622730816892, 0.78772072005024552, 0.7924677608109707,
    0.79717663190277332, 0.80184662140881269, 0.80647702329061177,
    0.81106713749480042, 0.8156162700589541, 0.82012373321651044,
    0.82458884550075162, 0.82901093184783137, 0.83338932369883667,
    0.83772335910086348, 0.84201238280709623, 0.84625574637587087,
    0.85045280826871128, 0.8546029339473209, 0.85870549596951617,
    0.86275987408408694, 0.86676545532457061, 0.8707216341019236,
    0.87462781229607822, 0.87848339934637087, 0.88228781234082576,
    0.88604047610428438, 0.88974082328536275, 0.89338829444222823,
    0.89698233812717909, 0.90052241097001584, 0.90400797776019148,
    0.90743851152772792, 0.91081349362288644, 0.91413241379458121,
    0.91739477026752081, 0.92060006981807141, 0.92374782784882448,
    0.92683756846186127, 0.9298688245307023, 0.93284113777093092,
    0.93575405880947859, 0.938607147252565, 0.94139997175227874,
    0.94413211007179187, 0.94680314914919594, 0.94941268515995136,
    0.95196032357793992, 0.95444567923511281, 0.95686837637972111,
    0.9592280487331255, 0.96152433954517225, 0.96375690164812866,
    0.965925397509171, 0.96802949928141335, 0.970068888853475,
    0.97204325789757351, 0.97395230791614062, 0.97579575028695,
    0.97757330630675354, 0.97928470723341743, 0.98092969432655219,
    0.98250801888663064, 0.98401944229258809, 0.98546373603789827,
    0.98684068176512052, 0.98815007129891252, 0.98939170667750365,
    0.99056540018262351, 0.99167097436788332, 0.99270826208560237,
    0.99367710651207919, 0.99457736117130091, 0.99540888995708832,
    0.9961715671536735, 0.99686527745470577, 0.99748991598068559,
    0.99804538829481926, 0.9985316104172981, 0.99894850883799369,
    0.99929602052757294, 0.99957409294702582, 0.99978268405560977,
    0.99992176231720475, 0.99999130670508207, 0.99999130670508207,
    0.99992176231720475, 0.99978268405560977, 0.99957409294702582,
    0.99929602052757294, 0.99894850883799369, 0.9985316104172981,
    0.99804538829481926, 0.99748991598068559, 0.99686527745470577,
    0.9961715671536735, 0.99540888995708832, 0.99457736117130091,
    0.99367710651207919, 0.99270826208560237, 0.99167097436788332,
    0.99056540018262351, 0.98939170667750365, 0.98815007129891264,
    0.98684068176512052, 0.98546373603789827, 0.9840194422925882,
    0.98250801888663064, 0.98092969432655219, 0.97928470723341743,
    0.97757330630675365, 0.97579575028695009, 0.97395230791614062,
    0.97204325789757351, 0.970068888853475, 0.96802949928141335,
    0.96592539750917106, 0.96375690164812866, 0.96152433954517225,
    0.9592280487331255, 0.95686837637972122, 0.95444567923511281,
    0.95196032357794014, 0.94941268515995125, 0.94680314914919594,
    0.94413211007179187, 0.94139997175227885, 0.938607147252565,
    0.93575405880947871, 0.93284113777093114, 0.92986882453070241,
    0.92683756846186127, 0.92374782784882448, 0.92060006981807163,
    0.91739477026752092, 0.91413241379458121, 0.91081349362288655,
    0.90743851152772792, 0.90400797776019148, 0.900522410970016,
    0.89698233812717909, 0.89338829444222834, 0.88974082328536275,
    0.8860404761042846, 0.88228781234082587, 0.878483399346371,
    0.87462781229607822, 0.87072163410192371, 0.86676545532457072,
    0.86275987408408716, 0.85870549596951617, 0.854602933947321,
    0.85045280826871128, 0.84625574637587087, 0.84201238280709623,
    0.83772335910086393, 0.83338932369883678, 0.82901093184783159,
    0.82458884550075162, 0.82012373321651089, 0.81561627005895421,
    0.81106713749480042, 0.80647702329061177, 0.80184662140881269,
    0.79717663190277355, 0.79246776081097081, 0.78772072005024563,
    0.78293622730816925, 0.7781150059345403, 0.77325778483202334,
    0.76836529834594991, 0.7634382861532939, 0.75847749315084312,
    0.7534836693425826, 0.7484575697263014, 0.74339995417945093,
    0.73831158734425684, 0.73319323851212148, 0.72804568150731264,
    0.72286969456997607, 0.717666060238471, 0.71243556523106721,
    0.70717900032699887, 0.701897160246913, 0.696590843532716,
    0.69126085242684687, 0.68590799275098913, 0.680533073784239,
    0.67513690814075789, 0.66972031164691181, 0.66428410321793374,
    0.65882910473411, 0.65335614091652838, 0.6478660392023885,
    0.64235962961990478, 0.63683774466281828, 0.63130121916453463,
    0.62575089017190988, 0.62018759681869828, 0.61461218019868846,
    0.60902548323854022, 0.603428350570348, 0.597821628403941,
    0.59220616439894924, 0.58658280753665026, 0.58095240799161219,
    0.57531581700316192, 0.56967388674668551, 0.56402747020479571,
    0.55837742103836829, 0.55272459345748415, 0.54706984209227971,
    0.54141402186374377, 0.53575798785446127, 0.53010259517933778,
    0.52444869885631917, 0.51879715367712176, 0.51314881407800306,
    0.50750453401057793, 0.50186516681271853, 0.49623156507953631,
    0.49060458053448541, 0.48498506390058904, 0.47937386477182709,
    0.47377183148468466, 0.46817981098989869, 0.46259864872440776,
    0.45702918848353485, 0.45147227229341824, 0.44592874028370633,
    0.440399430560543, 0.43488517907985663, 0.429386819520977,
    0.42390518316059139, 0.41844109874706892, 0.41299539237516436,
    0.40756888736112484, 0.40216240411821547, 0.39677676003268147,
    0.39141276934017533, 0.3860712430026515, 0.3807529885857619,
    0.3754588101367623, 0.37018950806295287, 0.36494587901066522,
    0.35972871574482168, 0.35453880702908119, 0.34937693750658616,
    0.34424388758133895, 0.33914043330021071, 0.33406734623561879,
    0.3290253933688716, 0.32401533697421481, 0.31903793450358164,
    0.31409393847208145, 0.30918409634422594, 0.30430915042092521,
    0.29946983772726016, 0.29466688990105516, 0.2899010330822655,
    0.285172987803193, 0.28048346887955261, 0.27583318530240147,
    0.2712228401309506, 0.2666531303862697, 0.26212474694590882,
    0.25763837443944609, 0.25319469114498266, 0.24879436888659429,
    0.24443807293276176, 0.24012646189579229, 0.23586018763224448,
    0.23163989514437777, 0.22746622248263659, 0.22333980064918652,
    0.21926125350251396, 0.21523119766310861, 0.21125024242023804,
    0.20731898963983225, 0.20343803367348989, 0.19960796126861807,
    0.19582935147972819, 0.19210277558088712, 0.18842879697935144,
    0.1848079711303845, 0.18124084545328312, 0.17772795924861196,
    0.17426984361667136, 0.17086702137719911, 0.16752000699033065,
    0.16422930647881784, 0.16099541735152512, 0.15781882852821361,
    0.15470002026562296, 0.15163946408486367, 0.14863762270012765,
    0.14569494994873505, 0.1428118907225176, 0.13998888090055922,
    0.13722634728329458, 0.13452470752798557, 0.1318843700855753,
    0.12930573413893648, 0.12678918954252016, 0.12433511676341558,
    0.12194388682382873, 0.11961586124498813, 0.11735139199248862,
    0.11515082142307836, 0.1130144822329, 0.11094269740719043,
    0.10893578017145061, 0.10699403394409041, 0.10511775229055476,
    0.10330721887894218, 0.10156270743711604, 0.09988448171132297,
    0.09827279542631584, 0.0967278922469959, 0.095250005741572386,
    0.093839359346251427, 0.092496166331455243, 0.091220629769577788,
    0.0900129425042841, 0.088873287121354339, 0.087801835921079707,
    0.086798750892212118, 0.085864183687475171, 0.084998275600634943,
    0.084201157545139349, 0.083472950034324811, 0.082813763163197218,
    0.082223696591786744, 0.081702839530080451, 0.081251270724534919,
    0.08086905844617126, 0.0805562604802531, 0.080312924117550422,
    0.080139086147189731, 0.080034772851092173, 0.080000000000000016 };

  emxArray_creal_T *f;
  emxArray_real_T *m;
  int32_T ia;
  int32_T a;
  int32_T i0;
  int32_T i1;
  int32_T br;
  emxArray_creal_T *pw;
  int32_T b_f[2];
  int32_T c_f[2];
  int32_T ar;
  emxArray_creal_T d_f;
  emxArray_creal_T e_f;
  real_T b_a;
  real_T b;
  real_T f_re;
  real_T f_im;
  creal_T ath;
  boolean_T exitg1;
  creal_T b_pw;
  emxArray_creal_T *f_f;
  int32_T g_f[2];
  emxArray_real_T *b_b;
  emxArray_real_T *y;
  int32_T c_k;
  uint32_T unnamed_idx_0;
  int32_T b_m;
  int32_T ic;
  int64_T i2;
  emxArray_int32_T *r0;
  emxArray_int32_T *idx;
  emxArray_boolean_T *c_b;
  emxArray_real_T *b_c;
  emxArray_real_T *c_c;

  /* MELCEPST Calculate the mel cepstrum of a signal C=(S,FS,W,NC,P,N,INC,FL,FH) */
  /*  */
  /*  */
  /*  Simple use: c=melcepst(s,fs)	% calculate mel cepstrum with 12 coefs, 256 sample frames */
  /* 				  c=melcepst(s,fs,'e0dD') % include log energy, 0th cepstral coef, delta and delta-delta coefs */
  /*  */
  /*  Inputs: */
  /*      s	 speech signal */
  /*      fs  sample rate in Hz (default 11025) */
  /*      nc  number of cepstral coefficients excluding 0'th coefficient (default 12) */
  /*      n   length of frame in samples (default power of 2 < (0.03*fs)) */
  /*      p   number of filters in filterbank (default: floor(3*log(fs)) = approx 2.1 per ocatave) */
  /*      inc frame increment (default n/2) */
  /*      fl  low end of the lowest filter as a fraction of fs (default = 0) */
  /*      fh  high end of highest filter as a fraction of fs (default = 0.5) */
  /*  */
  /* 		w   any sensible combination of the following: */
  /*  */
  /* 				'R'  rectangular window in time domain */
  /* 				'N'	Hanning window in time domain */
  /* 				'M'	Hamming window in time domain (default) */
  /*  */
  /* 		      't'  triangular shaped filters in mel domain (default) */
  /* 		      'n'  hanning shaped filters in mel domain */
  /* 		      'm'  hamming shaped filters in mel domain */
  /*  */
  /* 				'p'	filters act in the power domain */
  /* 				'a'	filters act in the absolute magnitude domain (default) */
  /*  */
  /* 			   '0'  include 0'th order cepstral coefficient */
  /* 				'E'  include log energy */
  /* 				'd'	include delta coefficients (dc/dt) */
  /* 				'D'	include delta-delta coefficients (d^2c/dt^2) */
  /*  */
  /* 		      'z'  highest and lowest filters taper down to zero (default) */
  /* 		      'y'  lowest filter remains at 1 down to 0 frequency and */
  /* 			   	  highest filter remains at 1 up to nyquist freqency */
  /*  */
  /* 		       If 'ty' or 'ny' is specified, the total power in the fft is preserved. */
  /*  */
  /*  Outputs:	c     mel cepstrum output: one frame per row. Log energy, if requested, is the */
  /*                  first element of each row followed by the delta and then the delta-delta */
  /*                  coefficients. */
  /*  */
  /*  BUGS: (1) should have power limit as 1e-16 rather than 1e-6 (or possibly a better way of choosing this) */
  /*            and put into VOICEBOX */
  /*        (2) get rdct to change the data length (properly) instead of doing it explicitly (wrongly) */
  /*       Copyright (C) Mike Brookes 1997 */
  /*       Version: $Id: melcepst.m,v 1.8 2011/09/02 16:24:14 dmb Exp $ */
  /*  */
  /*    VOICEBOX is a MATLAB toolbox for speech processing. */
  /*    Home page: http://www.ee.ic.ac.uk/hp/staff/dmb/voicebox/voicebox.html */
  /*  */
  /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
  /*    This program is free software; you can redistribute it and/or modify */
  /*    it under the terms of the GNU General Public License as published by */
  /*    the Free Software Foundation; either version 2 of the License, or */
  /*    (at your option) any later version. */
  /*  */
  /*    This program is distributed in the hope that it will be useful, */
  /*    but WITHOUT ANY WARRANTY; without even the implied warranty of */
  /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
  /*    GNU General Public License for more details. */
  /*  */
  /*    You can obtain a copy of the GNU General Public License from */
  /*    http://www.gnu.org/copyleft/gpl.html or by writing to */
  /*    Free Software Foundation, Inc.,675 Mass Ave, Cambridge, MA 02139, USA. */
  /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */
  /* floor(3*log(fs)); */
  /* 256; %20 / 1000 * fs;  % 10 ms window */
  /* nc = 20; */
  /* z=a_enframe(s,a_hamming(n),inc); */
  /*  HAMMING.M */
  /*  */
  /*  COPYRIGHT : (c) NUHAG, Dept.Math., University of Vienna, AUSTRIA */
  /*              http://nuhag.eu/ */
  /*              Permission is granted to modify and re-distribute this */
  /*              code in any manner as long as this notice is preserved. */
  /*              All standard disclaimers apply. */
  /*  */
  /*  HAMMING.M	- returns the N-point Hamming window. */
  /*  */
  /*  Input		: n = number */
  /*  */
  /*  Output	: w = vector */
  /*  */
  /*  Usage		: w = hamming (n) */
  /*  */
  /*  Comments	: allows also the call:  hamming(xx), taking only format from signal xx */
  /*  */
  /*  See also	: HAMMING2 */
  /*  modification of original MATLAB (3.5)  file */
  /*  HGFei, 1990   */
  /* z=enframe(s,hamming(n),inc); */
  for (i = 0; i < 512; i++) {
    b_s[i] = s[i] * dv0[i];
  }

  emxInit_creal_T(&f, 1);
  emxInit_real_T(&m, 2);
  a_rfft(b_s, f);
  a_melbankm(m, &a, &ia);

  /* [m,a,b]=melbankm(p,n,fs,fl,fh, 'M'); */
  if (a > ia) {
    i0 = 0;
    i1 = 0;
  } else {
    i0 = a - 1;
    i1 = ia;
  }

  if (a > ia) {
    br = 0;
  } else {
    br = a - 1;
  }

  emxInit_creal_T(&pw, 1);
  b_f[0] = f->size[0];
  b_f[1] = 1;
  c_f[0] = f->size[0];
  c_f[1] = 1;
  i = pw->size[0];
  pw->size[0] = i1 - i0;
  emxEnsureCapacity((emxArray__common *)pw, i, (int32_T)sizeof(creal_T));
  ar = (i1 - i0) - 1;
  for (i1 = 0; i1 <= ar; i1++) {
    d_f = *f;
    d_f.size = (int32_T *)&b_f;
    d_f.numDimensions = 1;
    e_f = *f;
    e_f.size = (int32_T *)&c_f;
    e_f.numDimensions = 1;
    b_a = e_f.data[br + i1].re;
    b = -e_f.data[br + i1].im;
    f_re = d_f.data[i0 + i1].re;
    f_im = d_f.data[i0 + i1].im;
    pw->data[i1].re = f_re * b_a - f_im * b;
    pw->data[i1].im = f_re * b + f_im * b_a;
  }

  i = 1;
  br = pw->size[0];
  ath = pw->data[0];
  if (br > 1) {
    if (rtIsNaN(pw->data[0].re) || rtIsNaN(pw->data[0].im)) {
      ar = 1;
      exitg1 = 0U;
      while ((exitg1 == 0U) && (ar + 1 <= br)) {
        i = ar + 1;
        if (!(rtIsNaN(pw->data[ar].re) || rtIsNaN(pw->data[ar].im))) {
          ath = pw->data[ar];
          exitg1 = 1U;
        } else {
          ar++;
        }
      }
    }

    if (i < br) {
      while (i + 1 <= br) {
        b_pw = pw->data[i];
        if (eml_relop(b_pw, ath, TRUE)) {
          ath = pw->data[i];
        }

        i++;
      }
    }
  }

  ath.re *= 1.0E-20;
  ath.im *= 1.0E-20;
  b_sqrt(&ath);
  if (a > ia) {
    i0 = 0;
    ia = 0;
  } else {
    i0 = a - 1;
  }

  emxInit_creal_T(&f_f, 1);
  g_f[0] = f->size[0];
  g_f[1] = 1;
  i1 = f_f->size[0];
  f_f->size[0] = ia - i0;
  emxEnsureCapacity((emxArray__common *)f_f, i1, (int32_T)sizeof(creal_T));
  ar = (ia - i0) - 1;
  for (i1 = 0; i1 <= ar; i1++) {
    d_f = *f;
    d_f.size = (int32_T *)&g_f;
    d_f.numDimensions = 1;
    f_f->data[i1] = d_f.data[i0 + i1];
  }

  b_emxInit_real_T(&b_b, 1);
  b_abs(f_f, b_b);
  emxFree_creal_T(&f_f);
  b_emxInit_real_T(&y, 1);
  if ((m->size[1] == 1) || (b_b->size[0] == 1)) {
    i0 = y->size[0];
    y->size[0] = m->size[0];
    emxEnsureCapacity((emxArray__common *)y, i0, (int32_T)sizeof(real_T));
    ar = m->size[0] - 1;
    for (i0 = 0; i0 <= ar; i0++) {
      y->data[i0] = 0.0;
      i = b_b->size[0] - 1;
      for (i1 = 0; i1 <= i; i1++) {
        y->data[i0] += m->data[i0 + m->size[0] * i1] * b_b->data[i1];
      }
    }
  } else {
    c_k = m->size[1];
    unnamed_idx_0 = (uint32_T)m->size[0];
    i0 = y->size[0];
    y->size[0] = (int32_T)unnamed_idx_0;
    emxEnsureCapacity((emxArray__common *)y, i0, (int32_T)sizeof(real_T));
    b_m = m->size[0];
    i = y->size[0];
    i0 = y->size[0];
    y->size[0] = i;
    emxEnsureCapacity((emxArray__common *)y, i0, (int32_T)sizeof(real_T));
    ar = i - 1;
    for (i0 = 0; i0 <= ar; i0++) {
      y->data[i0] = 0.0;
    }

    if (b_m == 0) {
    } else {
      for (i = 0; i <= 0; i += b_m) {
        i0 = i + b_m;
        for (ic = i; ic + 1 <= i0; ic++) {
          y->data[ic] = 0.0;
        }
      }

      br = 0;
      for (i = 0; i <= 0; i += b_m) {
        ar = 0;
        i0 = br + c_k;
        for (a = br; a + 1 <= i0; a++) {
          if (b_b->data[a] != 0.0) {
            ia = ar;
            i1 = i + b_m;
            for (ic = i; ic + 1 <= i1; ic++) {
              ia++;
              y->data[ic] += b_b->data[a] * m->data[ia - 1];
            }
          }

          ar += b_m;
        }

        br += c_k;
      }
    }
  }

  emxFree_real_T(&m);
  unnamed_idx_0 = (uint32_T)y->size[0];
  i0 = f->size[0];
  f->size[0] = (int32_T)unnamed_idx_0;
  emxEnsureCapacity((emxArray__common *)f, i0, (int32_T)sizeof(creal_T));
  i0 = f->size[0];
  for (c_k = 0; c_k + 1 <= i0; c_k++) {
    if (b_eml_relop(y->data[c_k], ath, TRUE) || rtIsNaN(y->data[c_k])) {
      b_a = ath.re;
      b = ath.im;
    } else {
      b_a = y->data[c_k];
      b = 0.0;
    }

    f->data[c_k].re = b_a;
    f->data[c_k].im = b;
  }

  emxFree_real_T(&y);
  i0 = pw->size[0];
  pw->size[0] = f->size[0];
  emxEnsureCapacity((emxArray__common *)pw, i0, (int32_T)sizeof(creal_T));
  ar = f->size[0] - 1;
  for (i0 = 0; i0 <= ar; i0++) {
    pw->data[i0] = f->data[i0];
  }

  for (c_k = 0; c_k <= f->size[0] - 1; c_k++) {
    ath = pw->data[c_k];
    if ((pw->data[c_k].im == 0.0) && rtIsNaN(pw->data[c_k].re)) {
    } else if ((fabs(pw->data[c_k].re) > 8.9884656743115785E+307) || (fabs
                (pw->data[c_k].im) > 8.9884656743115785E+307)) {
      b_a = fabs(pw->data[c_k].re / 2.0);
      b = fabs(pw->data[c_k].im / 2.0);
      if (b_a < b) {
        b_a /= b;
        b *= sqrt(b_a * b_a + 1.0);
      } else if (b_a > b) {
        b /= b_a;
        b = sqrt(b * b + 1.0) * b_a;
      } else if (rtIsNaN(b)) {
      } else {
        b = b_a * 1.4142135623730951;
      }

      ath.re = log(b) + 0.69314718055994529;
      ath.im = rt_atan2d_snf(pw->data[c_k].im, pw->data[c_k].re);
    } else {
      b_a = fabs(pw->data[c_k].re);
      b = fabs(pw->data[c_k].im);
      if (b_a < b) {
        b_a /= b;
        b *= sqrt(b_a * b_a + 1.0);
      } else if (b_a > b) {
        b /= b_a;
        b = sqrt(b * b + 1.0) * b_a;
      } else if (rtIsNaN(b)) {
      } else {
        b = b_a * 1.4142135623730951;
      }

      ath.re = log(b);
      ath.im = rt_atan2d_snf(pw->data[c_k].im, pw->data[c_k].re);
    }

    pw->data[c_k] = ath;
  }

  emxFree_creal_T(&f);
  a_rdct(pw, b_b);
  i0 = c->size[0] * c->size[1];
  c->size[0] = 1;
  emxEnsureCapacity((emxArray__common *)c, i0, (int32_T)sizeof(real_T));
  i = b_b->size[0];
  i0 = c->size[0] * c->size[1];
  c->size[1] = i;
  emxEnsureCapacity((emxArray__common *)c, i0, (int32_T)sizeof(real_T));
  emxFree_creal_T(&pw);
  ar = b_b->size[0] - 1;
  for (i0 = 0; i0 <= ar; i0++) {
    c->data[i0] = b_b->data[i0];
  }

  emxFree_real_T(&b_b);
  i2 = (int64_T)nc + 1L;
  if (i2 > 2147483647L) {
    i2 = 2147483647L;
  } else {
    if (i2 < -2147483648L) {
      i2 = -2147483648L;
    }
  }

  nc = (int32_T)i2;
  if (32 > nc) {
    b_emxInit_int32_T(&r0, 1);
    i0 = c->size[1];
    i1 = r0->size[0];
    r0->size[0] = i0 - nc;
    emxEnsureCapacity((emxArray__common *)r0, i1, (int32_T)sizeof(int32_T));
    ar = (i0 - nc) - 1;
    for (i0 = 0; i0 <= ar; i0++) {
      r0->data[i0] = (nc + i0) + 1;
    }

    emxInit_int32_T(&idx, 2);
    i0 = idx->size[0] * idx->size[1];
    idx->size[0] = 1;
    emxEnsureCapacity((emxArray__common *)idx, i0, (int32_T)sizeof(int32_T));
    i = r0->size[0];
    i0 = idx->size[0] * idx->size[1];
    idx->size[1] = i;
    emxEnsureCapacity((emxArray__common *)idx, i0, (int32_T)sizeof(int32_T));
    ar = r0->size[0] - 1;
    for (i0 = 0; i0 <= ar; i0++) {
      idx->data[i0] = r0->data[i0];
    }

    emxFree_int32_T(&r0);
    if (idx->size[1] == 1) {
      i = c->size[1] - 1;
      for (ar = idx->data[0]; ar <= i; ar++) {
        c->data[c->size[0] * (ar - 1)] = c->data[c->size[0] * ar];
      }
    } else {
      emxInit_boolean_T(&c_b, 2);
      i0 = c_b->size[0] * c_b->size[1];
      c_b->size[0] = 1;
      emxEnsureCapacity((emxArray__common *)c_b, i0, (int32_T)sizeof(boolean_T));
      i = c->size[1];
      i0 = c_b->size[0] * c_b->size[1];
      c_b->size[1] = i;
      emxEnsureCapacity((emxArray__common *)c_b, i0, (int32_T)sizeof(boolean_T));
      ar = c->size[1] - 1;
      for (i0 = 0; i0 <= ar; i0++) {
        c_b->data[i0] = FALSE;
      }

      for (c_k = 1; c_k <= idx->size[1]; c_k++) {
        c_b->data[idx->data[c_k - 1] - 1] = TRUE;
      }

      i = 0;
      for (c_k = 1; c_k <= c_b->size[1]; c_k++) {
        ia = c_b->data[c_k - 1];
        i += ia;
      }

      i = c->size[1] - i;
      br = c_b->size[1];
      ar = 0;
      i0 = c->size[1];
      for (c_k = 1; c_k <= i0; c_k++) {
        if ((c_k > br) || (!c_b->data[c_k - 1])) {
          c->data[c->size[0] * ar] = c->data[c->size[0] * (c_k - 1)];
          ar++;
        }
      }

      emxFree_boolean_T(&c_b);
    }

    emxFree_int32_T(&idx);
    if (1 > i) {
      i = 0;
    }

    emxInit_real_T(&b_c, 2);
    i0 = b_c->size[0] * b_c->size[1];
    b_c->size[0] = 1;
    b_c->size[1] = i;
    emxEnsureCapacity((emxArray__common *)b_c, i0, (int32_T)sizeof(real_T));
    ar = i - 1;
    for (i0 = 0; i0 <= ar; i0++) {
      b_c->data[b_c->size[0] * i0] = c->data[c->size[0] * i0];
    }

    i0 = c->size[0] * c->size[1];
    c->size[0] = 1;
    c->size[1] = b_c->size[1];
    emxEnsureCapacity((emxArray__common *)c, i0, (int32_T)sizeof(real_T));
    ar = b_c->size[1] - 1;
    for (i0 = 0; i0 <= ar; i0++) {
      c->data[c->size[0] * i0] = b_c->data[b_c->size[0] * i0];
    }

    emxFree_real_T(&b_c);
  } else {
    if (32 < nc) {
      emxInit_real_T(&b_c, 2);
      i = nc - 32;
      i0 = b_c->size[0] * b_c->size[1];
      b_c->size[0] = 1;
      b_c->size[1] = c->size[1] + i;
      emxEnsureCapacity((emxArray__common *)b_c, i0, (int32_T)sizeof(real_T));
      ar = c->size[1] - 1;
      for (i0 = 0; i0 <= ar; i0++) {
        b_c->data[b_c->size[0] * i0] = c->data[c->size[0] * i0];
      }

      ar = i - 1;
      for (i0 = 0; i0 <= ar; i0++) {
        b_c->data[b_c->size[0] * (i0 + c->size[1])] = 0.0;
      }

      i0 = c->size[0] * c->size[1];
      c->size[0] = 1;
      c->size[1] = b_c->size[1];
      emxEnsureCapacity((emxArray__common *)c, i0, (int32_T)sizeof(real_T));
      ar = b_c->size[1] - 1;
      for (i0 = 0; i0 <= ar; i0++) {
        c->data[c->size[0] * i0] = b_c->data[b_c->size[0] * i0];
      }

      emxFree_real_T(&b_c);
    }
  }

  i = c->size[1] - 1;
  for (ar = 1; ar <= i; ar++) {
    c->data[c->size[0] * (ar - 1)] = c->data[c->size[0] * ar];
  }

  if (1 > i) {
    i = 0;
  }

  emxInit_real_T(&c_c, 2);
  i0 = c_c->size[0] * c_c->size[1];
  c_c->size[0] = 1;
  c_c->size[1] = i;
  emxEnsureCapacity((emxArray__common *)c_c, i0, (int32_T)sizeof(real_T));
  ar = i - 1;
  for (i0 = 0; i0 <= ar; i0++) {
    c_c->data[c_c->size[0] * i0] = c->data[c->size[0] * i0];
  }

  i0 = c->size[0] * c->size[1];
  c->size[0] = 1;
  c->size[1] = c_c->size[1];
  emxEnsureCapacity((emxArray__common *)c, i0, (int32_T)sizeof(real_T));
  ar = c_c->size[1] - 1;
  for (i0 = 0; i0 <= ar; i0++) {
    c->data[c->size[0] * i0] = c_c->data[c_c->size[0] * i0];
  }

  emxFree_real_T(&c_c);
}