void features_ufb_api(const mxArray *prhs[7], const mxArray *plhs[1])
{
  emxArray_real_T *ftvec;
  emxArray_real_T *wvec;
  emxArray_real_T *ilog;
  emxArray_real_T *ftmin;
  emxArray_real_T *ftmax;
  real_T fbmin;
  real_T fbmax;
  emlrtStack st = { NULL, NULL, NULL };

  st.tls = emlrtRootTLSGlobal;
  emlrtHeapReferenceStackEnterFcnR2012b(&st);
  b_emxInit_real_T(&st, &ftvec, 2, true);
  emxInit_real_T(&st, &wvec, 1, true);
  b_emxInit_real_T(&st, &ilog, 2, true);
  b_emxInit_real_T(&st, &ftmin, 2, true);
  b_emxInit_real_T(&st, &ftmax, 2, true);
  prhs[0] = emlrtProtectR2012b(prhs[0], 0, false, -1);
  prhs[1] = emlrtProtectR2012b(prhs[1], 1, false, -1);
  prhs[2] = emlrtProtectR2012b(prhs[2], 2, false, -1);
  prhs[3] = emlrtProtectR2012b(prhs[3], 3, false, -1);
  prhs[4] = emlrtProtectR2012b(prhs[4], 4, false, -1);

  /* Marshall function inputs */
  i_emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "ftvec", ftvec);
  emlrt_marshallIn(&st, emlrtAlias(prhs[1]), "wvec", wvec);
  i_emlrt_marshallIn(&st, emlrtAlias(prhs[2]), "ilog", ilog);
  i_emlrt_marshallIn(&st, emlrtAlias(prhs[3]), "ftmin", ftmin);
  i_emlrt_marshallIn(&st, emlrtAlias(prhs[4]), "ftmax", ftmax);
  fbmin = g_emlrt_marshallIn(&st, emlrtAliasP(prhs[5]), "fbmin");
  fbmax = g_emlrt_marshallIn(&st, emlrtAliasP(prhs[6]), "fbmax");

  /* Invoke the target function */
  fbmin = features_ufb(ftvec, wvec, ilog, ftmin, ftmax, fbmin, fbmax);

  /* Marshall function outputs */
  plhs[0] = b_emlrt_marshallOut(fbmin);
  ftmax->canFreeData = false;
  emxFree_real_T(&ftmax);
  ftmin->canFreeData = false;
  emxFree_real_T(&ftmin);
  ilog->canFreeData = false;
  emxFree_real_T(&ilog);
  wvec->canFreeData = false;
  emxFree_real_T(&wvec);
  ftvec->canFreeData = false;
  emxFree_real_T(&ftvec);
  emlrtHeapReferenceStackLeaveFcnR2012b(&st);
}
void mfcc_api(const mxArray *prhs[1], const mxArray *plhs[1])
{
  emxArray_real_T *samples;
  emxArray_real_T *cepstra;
  emlrtStack st = { NULL, NULL, NULL };

  st.tls = emlrtRootTLSGlobal;
  emlrtHeapReferenceStackEnterFcnR2012b(&st);
  emxInit_real_T(&st, &samples, 1, true);
  b_emxInit_real_T(&st, &cepstra, 2, true);
  prhs[0] = emlrtProtectR2012b(prhs[0], 0, false, -1);

  /* Marshall function inputs */
  emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "samples", samples);

  /* Invoke the target function */
  mfcc(samples, cepstra);

  /* Marshall function outputs */
  plhs[0] = h_emlrt_marshallOut(cepstra);
  cepstra->canFreeData = false;
  emxFree_real_T(&cepstra);
  samples->canFreeData = false;
  emxFree_real_T(&samples);
  emlrtHeapReferenceStackLeaveFcnR2012b(&st);
}
void BWbetaNloop_api(const mxArray *prhs[2], const mxArray *plhs[1])
{
  emxArray_real_T *beta;
  emxArray_real_T *updater;
  emlrtHeapReferenceStackEnterFcnR2012b(emlrtRootTLSGlobal);
  emxInit_real_T(&beta, 2, TRUE);
  b_emxInit_real_T(&updater, 3, TRUE);
  prhs[0] = emlrtProtectR2012b(prhs[0], 0, TRUE, -1);

  /* Marshall function inputs */
  emlrt_marshallIn(emlrtAlias(prhs[0]), "beta", beta);
  c_emlrt_marshallIn(emlrtAlias(prhs[1]), "updater", updater);

  /* Invoke the target function */
  BWbetaNloop(beta, updater);

  /* Marshall function outputs */
  emlrt_marshallOut(beta, prhs[0]);
  plhs[0] = prhs[0];
  updater->canFreeData = FALSE;
  emxFree_real_T(&updater);
  beta->canFreeData = FALSE;
  emxFree_real_T(&beta);
  emlrtHeapReferenceStackLeaveFcnR2012b(emlrtRootTLSGlobal);
}
void PlotResults_api(const mxArray * const prhs[4])
{
  emxArray_real_T *t;
  emxArray_real_T *sigIn;
  emxArray_real_T *u;
  emxArray_real_T *r;
  emlrtStack st = { NULL, NULL, NULL };

  st.tls = emlrtRootTLSGlobal;
  emlrtHeapReferenceStackEnterFcnR2012b(&st);
  emxInit_real_T(&st, &t, 2, &ub_emlrtRTEI, true);
  emxInit_real_T(&st, &sigIn, 2, &ub_emlrtRTEI, true);
  emxInit_real_T(&st, &u, 2, &ub_emlrtRTEI, true);
  b_emxInit_real_T(&st, &r, 1, &ub_emlrtRTEI, true);

  /* Marshall function inputs */
  e_emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "t", t);
  e_emlrt_marshallIn(&st, emlrtAlias(prhs[1]), "sigIn", sigIn);
  g_emlrt_marshallIn(&st, emlrtAlias(prhs[2]), "u", u);
  i_emlrt_marshallIn(&st, emlrtAlias(prhs[3]), "r", r);

  /* Invoke the target function */
  PlotResults(&st, t, sigIn, u, r);
  r->canFreeData = false;
  emxFree_real_T(&r);
  u->canFreeData = false;
  emxFree_real_T(&u);
  sigIn->canFreeData = false;
  emxFree_real_T(&sigIn);
  t->canFreeData = false;
  emxFree_real_T(&t);
  emlrtHeapReferenceStackLeaveFcnR2012b(&st);
}
void emxInitStruct_struct0_T(const emlrtStack *sp, struct0_T *pStruct, const
  emlrtRTEInfo *srcLocation, boolean_T doPush)
{
  emxInit_char_T(sp, &pStruct->wd, 2, srcLocation, doPush);
  emxInit_real_T(sp, &pStruct->famil_diff_thresh_start, 1, srcLocation, doPush);
  emxInit_char_T(sp, &pStruct->nameOfFolder, 2, srcLocation, doPush);
  emxInit_char_T(sp, &pStruct->expt, 2, srcLocation, doPush);
  b_emxInit_real_T(sp, &pStruct->gridMat, 3, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->famil_diff_thresh, 2, srcLocation, doPush);
  b_emxInit_real_T(sp, &pStruct->stimuli_misMatch, 3, srcLocation, doPush);
  b_emxInit_real_T(sp, &pStruct->stimuli_match, 3, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->tType, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->stimOrder, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->numGrids, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->nInpDims, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->usePRC, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->meanSelectivity_caudal_new, 2, srcLocation,
                   doPush);
  c_emxInit_real_T(sp, &pStruct->meanSelectivity_PRC_new, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->meanSelectivity_caudal_prev, 2, srcLocation,
                   doPush);
  c_emxInit_real_T(sp, &pStruct->meanSelectivity_PRC_prev, 2, srcLocation,
                   doPush);
  c_emxInit_real_T(sp, &pStruct->familDiff_caudal, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->familDiff_PRC, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->prevStimInit_act_peak, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->prevStimInit_act_total, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->prevStimFin_act_peak, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->prevStimFin_act_total, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->newStimInit_act_peak, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->newStimInit_act_total, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->newStimFin_act_peak, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->newStimFin_act_total, 2, srcLocation, doPush);
  b_emxInit_real_T(sp, &pStruct->featsSampedByComparison, 3, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->sample_feat, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->fixations, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->peak_act, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->totalAct, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->comparedFeat, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->familDiff_withNoise, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->famil_difference, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->answer, 2, srcLocation, doPush);
  c_emxInit_real_T(sp, &pStruct->correct, 2, srcLocation, doPush);
}
Example #6
0
static void eml_xscal(int32_T n, real_T a, emxArray_real_T *x, int32_T ix0)
{
  emxArray_real_T *b_x;
  int32_T i18;
  int32_T k;
  b_emxInit_real_T(&b_x, 2);
  i18 = (ix0 + n) - 1;
  for (k = ix0; k <= i18; k++) {
    x->data[k - 1] *= a;
  }

  emxFree_real_T(&b_x);
}
Example #7
0
void b_polyfit(const emxArray_real_T *x, const emxArray_real_T *y, double p[3])
{
  emxArray_real_T *V;
  int n;
  unsigned int unnamed_idx_0;
  int i22;
  int k;
  emxArray_real_T *b_y;
  double rr;
  double p1[3];
  emxInit_real_T(&V, 2);
  n = x->size[0] - 1;
  unnamed_idx_0 = (unsigned int)x->size[0];
  i22 = V->size[0] * V->size[1];
  V->size[0] = (int)unnamed_idx_0;
  V->size[1] = 3;
  emxEnsureCapacity((emxArray__common *)V, i22, (int)sizeof(double));
  if ((int)unnamed_idx_0 == 0) {
  } else {
    for (k = 0; k <= n; k++) {
      V->data[k + (V->size[0] << 1)] = 1.0;
    }

    for (k = 0; k <= n; k++) {
      V->data[k + V->size[0]] = x->data[k];
    }

    for (k = 0; k <= n; k++) {
      V->data[k] = x->data[k] * V->data[k + V->size[0]];
    }
  }

  b_emxInit_real_T(&b_y, 1);
  i22 = b_y->size[0];
  b_y->size[0] = y->size[0];
  emxEnsureCapacity((emxArray__common *)b_y, i22, (int)sizeof(double));
  k = y->size[0];
  for (i22 = 0; i22 < k; i22++) {
    b_y->data[i22] = y->data[i22];
  }

  b_eml_qrsolve(V, b_y, p1, &rr);
  emxFree_real_T(&b_y);
  emxFree_real_T(&V);
  for (i22 = 0; i22 < 3; i22++) {
    p[i22] = p1[i22];
  }
}
Example #8
0
/* Function Definitions */
emxArray_real_T *emxCreateND_real_T(int numDimensions, int *size)
{
  emxArray_real_T *emx;
  int numEl;
  int i;
  b_emxInit_real_T(&emx, numDimensions);
  numEl = 1;
  for (i = 0; i < numDimensions; i++) {
    numEl *= size[i];
    emx->size[i] = size[i];
  }

  emx->data = (double *)calloc((unsigned int)numEl, sizeof(double));
  emx->numDimensions = numDimensions;
  emx->allocatedSize = numEl;
  return emx;
}
/* Function Definitions */
emxArray_real_T *emxCreateND_real_T(int32_T numDimensions, int32_T *size)
{
  emxArray_real_T *emx;
  int32_T numEl;
  int32_T loop_ub;
  int32_T i;
  b_emxInit_real_T(&emx, numDimensions);
  numEl = 1;
  loop_ub = numDimensions - 1;
  for (i = 0; i <= loop_ub; i++) {
    numEl *= size[i];
    emx->size[i] = size[i];
  }

  emx->data = (real_T *)calloc((uint32_T)numEl, sizeof(real_T));
  emx->numDimensions = numDimensions;
  emx->allocatedSize = numEl;
  return emx;
}
Example #10
0
emxArray_real_T *emxCreateWrapperND_real_T(double *data, int numDimensions, int *
  size)
{
  emxArray_real_T *emx;
  int numEl;
  int i;
  b_emxInit_real_T(&emx, numDimensions);
  numEl = 1;
  for (i = 0; i < numDimensions; i++) {
    numEl *= size[i];
    emx->size[i] = size[i];
  }

  emx->data = data;
  emx->numDimensions = numDimensions;
  emx->allocatedSize = numEl;
  emx->canFreeData = false;
  return emx;
}
emxArray_real_T *emxCreate_real_T(int32_T rows, int32_T cols)
{
  emxArray_real_T *emx;
  int32_T size[2];
  int32_T numEl;
  int32_T i;
  size[0] = rows;
  size[1] = cols;
  b_emxInit_real_T(&emx, 2);
  numEl = 1;
  for (i = 0; i < 2; i++) {
    numEl *= size[i];
    emx->size[i] = size[i];
  }

  emx->data = (real_T *)calloc((uint32_T)numEl, sizeof(real_T));
  emx->numDimensions = 2;
  emx->allocatedSize = numEl;
  return emx;
}
Example #12
0
emxArray_real_T *emxCreate_real_T(int rows, int cols)
{
  emxArray_real_T *emx;
  int size[2];
  int numEl;
  int i;
  size[0] = rows;
  size[1] = cols;
  b_emxInit_real_T(&emx, 2);
  numEl = 1;
  for (i = 0; i < 2; i++) {
    numEl *= size[i];
    emx->size[i] = size[i];
  }

  emx->data = (double *)calloc((unsigned int)numEl, sizeof(double));
  emx->numDimensions = 2;
  emx->allocatedSize = numEl;
  return emx;
}
emxArray_real_T *emxCreateWrapperND_real_T(real_T *data, int32_T numDimensions,
  int32_T *size)
{
  emxArray_real_T *emx;
  int32_T numEl;
  int32_T loop_ub;
  int32_T i;
  b_emxInit_real_T(&emx, numDimensions);
  numEl = 1;
  loop_ub = numDimensions - 1;
  for (i = 0; i <= loop_ub; i++) {
    numEl *= size[i];
    emx->size[i] = size[i];
  }

  emx->data = data;
  emx->numDimensions = numDimensions;
  emx->allocatedSize = numEl;
  emx->canFreeData = FALSE;
  return emx;
}
Example #14
0
/* Function Definitions */
static void b_eml_xaxpy(int32_T n, real_T a, const emxArray_real_T *x, int32_T
  ix0, emxArray_real_T *y, int32_T iy0)
{
  emxArray_real_T *b_y;
  int32_T ix;
  int32_T iy;
  int32_T k;
  b_emxInit_real_T(&b_y, 1);
  if ((n < 1) || (a == 0.0)) {
  } else {
    ix = ix0 - 1;
    iy = iy0 - 1;
    for (k = 0; k <= n - 1; k++) {
      y->data[iy] += a * x->data[ix];
      ix++;
      iy++;
    }
  }

  emxFree_real_T(&b_y);
}
Example #15
0
emxArray_real_T *emxCreateWrapper_real_T(double *data, int rows, int cols)
{
  emxArray_real_T *emx;
  int size[2];
  int numEl;
  int i;
  size[0] = rows;
  size[1] = cols;
  b_emxInit_real_T(&emx, 2);
  numEl = 1;
  for (i = 0; i < 2; i++) {
    numEl *= size[i];
    emx->size[i] = size[i];
  }

  emx->data = data;
  emx->numDimensions = 2;
  emx->allocatedSize = numEl;
  emx->canFreeData = false;
  return emx;
}
Example #16
0
static void eml_xswap(int32_T n, emxArray_real_T *x, int32_T ix0, int32_T incx,
                      int32_T iy0, int32_T incy)
{
  emxArray_real_T *b_x;
  int32_T ix;
  int32_T iy;
  int32_T k;
  real_T temp;
  b_emxInit_real_T(&b_x, 2);
  ix = ix0 - 1;
  iy = iy0 - 1;
  for (k = 1; k <= n; k++) {
    temp = x->data[ix];
    x->data[ix] = x->data[iy];
    x->data[iy] = temp;
    ix += incx;
    iy += incy;
  }

  emxFree_real_T(&b_x);
}
emxArray_real_T *emxCreateWrapper_real_T(real_T *data, int32_T rows, int32_T
  cols)
{
  emxArray_real_T *emx;
  int32_T size[2];
  int32_T numEl;
  int32_T i;
  size[0] = rows;
  size[1] = cols;
  b_emxInit_real_T(&emx, 2);
  numEl = 1;
  for (i = 0; i < 2; i++) {
    numEl *= size[i];
    emx->size[i] = size[i];
  }

  emx->data = data;
  emx->numDimensions = 2;
  emx->allocatedSize = numEl;
  emx->canFreeData = FALSE;
  return emx;
}
void TestBemHeatEq_optimized_api(const mxArray * const prhs[4], const mxArray
  *plhs[2])
{
  emxArray_real_T *sigIn;
  emxArray_real_T *u;
  emxArray_real_T *r;
  real_T regOrder;
  real_T lambda;
  boolean_T plotFlag;
  emlrtStack st = { NULL, NULL, NULL };

  st.tls = emlrtRootTLSGlobal;
  emlrtHeapReferenceStackEnterFcnR2012b(&st);
  emxInit_real_T(&st, &sigIn, 2, &ub_emlrtRTEI, true);
  emxInit_real_T(&st, &u, 2, &ub_emlrtRTEI, true);
  b_emxInit_real_T(&st, &r, 1, &ub_emlrtRTEI, true);

  /* Marshall function inputs */
  e_emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "sigIn", sigIn);
  regOrder = c_emlrt_marshallIn(&st, emlrtAliasP(prhs[1]), "regOrder");
  lambda = c_emlrt_marshallIn(&st, emlrtAliasP(prhs[2]), "lambda");
  plotFlag = k_emlrt_marshallIn(&st, emlrtAliasP(prhs[3]), "plotFlag");

  /* Invoke the target function */
  TestBemHeatEq_optimized(&st, sigIn, regOrder, lambda, plotFlag, u, r);

  /* Marshall function outputs */
  plhs[0] = f_emlrt_marshallOut(u);
  plhs[1] = g_emlrt_marshallOut(r);
  r->canFreeData = false;
  emxFree_real_T(&r);
  u->canFreeData = false;
  emxFree_real_T(&u);
  sigIn->canFreeData = false;
  emxFree_real_T(&sigIn);
  emlrtHeapReferenceStackLeaveFcnR2012b(&st);
}
void features_bta_api(const mxArray *prhs[1], const mxArray *plhs[1])
{
  real_T (*ft)[2];
  emxArray_real_T *tap;
  emlrtStack st = { NULL, NULL, NULL };

  st.tls = emlrtRootTLSGlobal;
  ft = (real_T (*)[2])mxMalloc(sizeof(real_T [2]));
  emlrtHeapReferenceStackEnterFcnR2012b(&st);
  b_emxInit_real_T(&st, &tap, 2, true);
  prhs[0] = emlrtProtectR2012b(prhs[0], 0, false, -1);

  /* Marshall function inputs */
  e_emlrt_marshallIn(&st, emlrtAlias(prhs[0]), "tap", tap);

  /* Invoke the target function */
  features_bta(tap, *ft);

  /* Marshall function outputs */
  plhs[0] = f_emlrt_marshallOut(*ft);
  tap->canFreeData = false;
  emxFree_real_T(&tap);
  emlrtHeapReferenceStackLeaveFcnR2012b(&st);
}
/*
 * function [sx,sy,ss] = builddetailedbf(scoefx,scoefy,si,gran)
 */
void builddetailedbf(const emxArray_real_T *scoefx, const emxArray_real_T
                     *scoefy, const emxArray_real_T *si, real_T gran,
                     emxArray_real_T *sx, emxArray_real_T *sy, emxArray_real_T
                     *ss)
{
  emxArray_real_T *b_ss;
  real_T distance;
  int32_T i6;
  int32_T loop_ub;
  b_emxInit_real_T(&b_ss, 2);

  /* 'builddetailedbf:3' distance = si(end) - si(1); */
  distance = si->data[si->size[0] - 1] - si->data[0];

  /* 'builddetailedbf:4' npoints = ceil(distance/gran); */
  /* round to next integer. Favoring increased granularity. */
  /* 'builddetailedbf:6' ss = linspace(si(1),si(end),npoints); */
  linspace(si->data[0], si->data[si->size[0] - 1], ceil(distance / gran), b_ss);

  /* 'builddetailedbf:8' ss = ss'; */
  i6 = ss->size[0];
  ss->size[0] = b_ss->size[1];
  emxEnsureCapacity((emxArray__common *)ss, i6, (int32_T)sizeof(real_T));
  loop_ub = b_ss->size[1] - 1;
  for (i6 = 0; i6 <= loop_ub; i6++) {
    ss->data[i6] = b_ss->data[i6];
  }

  emxFree_real_T(&b_ss);

  /* 'builddetailedbf:10' sx = parevalspline(scoefx,si,ss,0); */
  b_parevalspline(scoefx, si, ss, sx);

  /* 'builddetailedbf:11' sy = parevalspline(scoefy,si,ss,0); */
  b_parevalspline(scoefy, si, ss, sy);
}
Example #21
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);
  }
}
/*
 * Arguments    : const mxArray *prhs[15]
 *                const mxArray *plhs[7]
 * Return Type  : void
 */
void clcOptTrj_tmp_api(const mxArray *prhs[15], const mxArray *plhs[7])
{
  emxArray_real_T *engKinNumVec_wayInx;
  emxArray_real_T *engKinMat_engKinInx_wayInx;
  emxArray_real_T *engKinOptVec;
  emxArray_real_T *batEngDltOptVec;
  emxArray_real_T *fulEngDltOptVec;
  emxArray_real_T *staVec;
  emxArray_real_T *psiEngKinOptVec;
  real_T disFlg;
  real_T wayStp;
  real_T wayNum;
  real_T wayInxBeg;
  real_T wayInxEnd;
  real_T staEnd;
  real_T engKinNum;
  real_T engKinEndInxVal;
  real_T staNum;
  real_T (*optPreInxTn3)[52800];
  real_T (*batFrcOptTn3)[52800];
  real_T (*fulEngOptTn3)[52800];
  real_T (*cos2goActMat)[66];
  real_T engKinEndInx;
  real_T fulEngOpt;
  emlrtStack st = { NULL, NULL, NULL };

  st.tls = emlrtRootTLSGlobal;
  emlrtHeapReferenceStackEnterFcnR2012b(&st);
  emxInit_real_T(&st, &engKinNumVec_wayInx, 1, true);
  b_emxInit_real_T(&st, &engKinMat_engKinInx_wayInx, 2, true);
  emxInit_real_T(&st, &engKinOptVec, 1, true);
  emxInit_real_T(&st, &batEngDltOptVec, 1, true);
  emxInit_real_T(&st, &fulEngDltOptVec, 1, true);
  emxInit_real_T(&st, &staVec, 1, true);
  emxInit_real_T(&st, &psiEngKinOptVec, 1, true);
  prhs[9] = emlrtProtectR2012b(prhs[9], 9, false, -1);
  prhs[10] = emlrtProtectR2012b(prhs[10], 10, false, -1);
  prhs[11] = emlrtProtectR2012b(prhs[11], 11, false, -1);
  prhs[12] = emlrtProtectR2012b(prhs[12], 12, false, -1);
  prhs[13] = emlrtProtectR2012b(prhs[13], 13, false, -1);
  prhs[14] = emlrtProtectR2012b(prhs[14], 14, false, -1);

  /* Marshall function inputs */
  disFlg = emlrt_marshallIn(&st, emlrtAliasP(prhs[0]), "disFlg");
  wayStp = emlrt_marshallIn(&st, emlrtAliasP(prhs[1]), "wayStp");
  wayNum = emlrt_marshallIn(&st, emlrtAliasP(prhs[2]), "wayNum");
  wayInxBeg = emlrt_marshallIn(&st, emlrtAliasP(prhs[3]), "wayInxBeg");
  wayInxEnd = emlrt_marshallIn(&st, emlrtAliasP(prhs[4]), "wayInxEnd");
  staEnd = emlrt_marshallIn(&st, emlrtAliasP(prhs[5]), "staEnd");
  engKinNum = emlrt_marshallIn(&st, emlrtAliasP(prhs[6]), "engKinNum");
  engKinEndInxVal = emlrt_marshallIn(&st, emlrtAliasP(prhs[7]),
    "engKinEndInxVal");
  staNum = emlrt_marshallIn(&st, emlrtAliasP(prhs[8]), "staNum");
  c_emlrt_marshallIn(&st, emlrtAlias(prhs[9]), "engKinNumVec_wayInx",
                     engKinNumVec_wayInx);
  e_emlrt_marshallIn(&st, emlrtAlias(prhs[10]), "engKinMat_engKinInx_wayInx",
                     engKinMat_engKinInx_wayInx);
  optPreInxTn3 = g_emlrt_marshallIn(&st, emlrtAlias(prhs[11]), "optPreInxTn3");
  batFrcOptTn3 = g_emlrt_marshallIn(&st, emlrtAlias(prhs[12]), "batFrcOptTn3");
  fulEngOptTn3 = g_emlrt_marshallIn(&st, emlrtAlias(prhs[13]), "fulEngOptTn3");
  cos2goActMat = i_emlrt_marshallIn(&st, emlrtAlias(prhs[14]), "cos2goActMat");

  /* Invoke the target function */
  clcOptTrj_tmp(disFlg, wayStp, wayNum, wayInxBeg, wayInxEnd, staEnd, engKinNum,
                engKinEndInxVal, staNum, engKinNumVec_wayInx,
                engKinMat_engKinInx_wayInx, *optPreInxTn3, *batFrcOptTn3,
                *fulEngOptTn3, *cos2goActMat, engKinOptVec, batEngDltOptVec,
                fulEngDltOptVec, staVec, psiEngKinOptVec, &fulEngOpt,
                &engKinEndInx);

  /* Marshall function outputs */
  plhs[0] = emlrt_marshallOut(engKinOptVec);
  plhs[1] = emlrt_marshallOut(batEngDltOptVec);
  plhs[2] = emlrt_marshallOut(fulEngDltOptVec);
  plhs[3] = emlrt_marshallOut(staVec);
  plhs[4] = emlrt_marshallOut(psiEngKinOptVec);
  plhs[5] = b_emlrt_marshallOut(fulEngOpt);
  plhs[6] = b_emlrt_marshallOut(engKinEndInx);
  psiEngKinOptVec->canFreeData = false;
  emxFree_real_T(&psiEngKinOptVec);
  staVec->canFreeData = false;
  emxFree_real_T(&staVec);
  fulEngDltOptVec->canFreeData = false;
  emxFree_real_T(&fulEngDltOptVec);
  batEngDltOptVec->canFreeData = false;
  emxFree_real_T(&batEngDltOptVec);
  engKinOptVec->canFreeData = false;
  emxFree_real_T(&engKinOptVec);
  engKinMat_engKinInx_wayInx->canFreeData = false;
  emxFree_real_T(&engKinMat_engKinInx_wayInx);
  engKinNumVec_wayInx->canFreeData = false;
  emxFree_real_T(&engKinNumVec_wayInx);
  emlrtHeapReferenceStackLeaveFcnR2012b(&st);
}
Example #23
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;
}
/*
 * Arguments    : const mxArray *prhs[19]
 *                const mxArray *plhs[4]
 * Return Type  : void
 */
void clcDP_olyHyb_tmp_api(const mxArray *prhs[19], const mxArray *plhs[4])
{
  emxArray_real_T *engKinNumVec_wayInx;
  emxArray_real_T *slpVec_wayInx;
  emxArray_real_T *engKinMat_engKinInx_wayInx;
  static struct0_T FZG;
  emxArray_real_T *optPreInxTn3;
  emxArray_real_T *batFrcOptTn3;
  emxArray_real_T *fulEngOptTn3;
  emxArray_real_T *cos2goActMat;
  real_T disFlg;
  real_T wayStp;
  real_T batEngStp;
  real_T batEngBeg;
  real_T batPwrAux;
  real_T psiBatEng;
  real_T psiTim;
  real_T staChgPenCosVal;
  real_T wayInxBeg;
  real_T wayInxEnd;
  real_T engKinBegInx;
  real_T engKinNum;
  real_T staNum;
  real_T wayNum;
  real_T staBeg;
  emlrtStack st = { NULL, NULL, NULL };

  st.tls = emlrtRootTLSGlobal;
  emlrtHeapReferenceStackEnterFcnR2012b(&st);
  emxInit_real_T(&st, &engKinNumVec_wayInx, 1, true);
  emxInit_real_T(&st, &slpVec_wayInx, 1, true);
  b_emxInit_real_T(&st, &engKinMat_engKinInx_wayInx, 2, true);
  emxInitStruct_struct0_T(&st, &FZG, true);
  c_emxInit_real_T(&st, &optPreInxTn3, 3, true);
  c_emxInit_real_T(&st, &batFrcOptTn3, 3, true);
  c_emxInit_real_T(&st, &fulEngOptTn3, 3, true);
  b_emxInit_real_T(&st, &cos2goActMat, 2, true);
  prhs[15] = emlrtProtectR2012b(prhs[15], 15, false, -1);
  prhs[16] = emlrtProtectR2012b(prhs[16], 16, false, -1);
  prhs[17] = emlrtProtectR2012b(prhs[17], 17, false, -1);

  /* Marshall function inputs */
  disFlg = emlrt_marshallIn(&st, emlrtAliasP(prhs[0]), "disFlg");
  wayStp = emlrt_marshallIn(&st, emlrtAliasP(prhs[1]), "wayStp");
  batEngStp = emlrt_marshallIn(&st, emlrtAliasP(prhs[2]), "batEngStp");
  batEngBeg = emlrt_marshallIn(&st, emlrtAliasP(prhs[3]), "batEngBeg");
  batPwrAux = emlrt_marshallIn(&st, emlrtAliasP(prhs[4]), "batPwrAux");
  psiBatEng = emlrt_marshallIn(&st, emlrtAliasP(prhs[5]), "psiBatEng");
  psiTim = emlrt_marshallIn(&st, emlrtAliasP(prhs[6]), "psiTim");
  staChgPenCosVal = emlrt_marshallIn(&st, emlrtAliasP(prhs[7]),
    "staChgPenCosVal");
  wayInxBeg = emlrt_marshallIn(&st, emlrtAliasP(prhs[8]), "wayInxBeg");
  wayInxEnd = emlrt_marshallIn(&st, emlrtAliasP(prhs[9]), "wayInxEnd");
  engKinBegInx = emlrt_marshallIn(&st, emlrtAliasP(prhs[10]), "engKinBegInx");
  engKinNum = emlrt_marshallIn(&st, emlrtAliasP(prhs[11]), "engKinNum");
  staNum = emlrt_marshallIn(&st, emlrtAliasP(prhs[12]), "staNum");
  wayNum = emlrt_marshallIn(&st, emlrtAliasP(prhs[13]), "wayNum");
  staBeg = emlrt_marshallIn(&st, emlrtAliasP(prhs[14]), "staBeg");
  c_emlrt_marshallIn(&st, emlrtAlias(prhs[15]), "engKinNumVec_wayInx",
                     engKinNumVec_wayInx);
  c_emlrt_marshallIn(&st, emlrtAlias(prhs[16]), "slpVec_wayInx", slpVec_wayInx);
  e_emlrt_marshallIn(&st, emlrtAlias(prhs[17]), "engKinMat_engKinInx_wayInx",
                     engKinMat_engKinInx_wayInx);
  g_emlrt_marshallIn(&st, emlrtAliasP(prhs[18]), "FZG", &FZG);

  /* Invoke the target function */
  clcDP_olyHyb_tmp(disFlg, wayStp, batEngStp, batEngBeg, batPwrAux, psiBatEng,
                   psiTim, staChgPenCosVal, wayInxBeg, wayInxEnd, engKinBegInx,
                   engKinNum, staNum, wayNum, staBeg, engKinNumVec_wayInx,
                   slpVec_wayInx, engKinMat_engKinInx_wayInx, &FZG, optPreInxTn3,
                   batFrcOptTn3, fulEngOptTn3, cos2goActMat);

  /* Marshall function outputs */
  plhs[0] = emlrt_marshallOut(optPreInxTn3);
  plhs[1] = emlrt_marshallOut(batFrcOptTn3);
  plhs[2] = emlrt_marshallOut(fulEngOptTn3);
  plhs[3] = b_emlrt_marshallOut(cos2goActMat);
  cos2goActMat->canFreeData = false;
  emxFree_real_T(&cos2goActMat);
  fulEngOptTn3->canFreeData = false;
  emxFree_real_T(&fulEngOptTn3);
  batFrcOptTn3->canFreeData = false;
  emxFree_real_T(&batFrcOptTn3);
  optPreInxTn3->canFreeData = false;
  emxFree_real_T(&optPreInxTn3);
  emxFreeStruct_struct0_T(&FZG);
  engKinMat_engKinInx_wayInx->canFreeData = false;
  emxFree_real_T(&engKinMat_engKinInx_wayInx);
  slpVec_wayInx->canFreeData = false;
  emxFree_real_T(&slpVec_wayInx);
  engKinNumVec_wayInx->canFreeData = false;
  emxFree_real_T(&engKinNumVec_wayInx);
  emlrtHeapReferenceStackLeaveFcnR2012b(&st);
}
/*
 * Arguments    : const emlrtStack *sp
 *                struct0_T *pStruct
 *                boolean_T doPush
 * Return Type  : void
 */
static void emxInitStruct_struct0_T(const emlrtStack *sp, struct0_T *pStruct,
  boolean_T doPush)
{
  b_emxInit_real_T(sp, &pStruct->geaRat, 2, doPush);
}
/*
 * function offsetcost = equateoffsetcost(pathqi)
 */
void equateoffsetcost(const emxArray_real_T *pathqi, emxArray_real_T *offsetcost)
{
  emxArray_real_T *b_pathqi;
  int32_T n;
  int32_T c_pathqi;
  int32_T ixstart;
  uint32_T uv0[2];
  int32_T k;
  emxArray_int32_T *r75;
  int32_T exitg3;
  real_T mtmp;
  real_T b_mtmp;
  boolean_T exitg2;
  boolean_T exitg1;
  b_emxInit_real_T(&b_pathqi, 2);

  /* UNTITLED2 Summary of this function goes here */
  /*    Detailed explanation goes here */
  /* 'equateoffsetcost:6' pathoffsetcost = abs(pathqi(end,:)); */
  n = pathqi->size[1];
  c_pathqi = pathqi->size[0];
  ixstart = b_pathqi->size[0] * b_pathqi->size[1];
  b_pathqi->size[0] = 1;
  b_pathqi->size[1] = n;
  emxEnsureCapacity((emxArray__common *)b_pathqi, ixstart, (int32_T)sizeof
                    (real_T));
  ixstart = n - 1;
  for (n = 0; n <= ixstart; n++) {
    b_pathqi->data[b_pathqi->size[0] * n] = pathqi->data[(c_pathqi +
      pathqi->size[0] * n) - 1];
  }

  for (n = 0; n < 2; n++) {
    uv0[n] = (uint32_T)b_pathqi->size[n];
  }

  emxFree_real_T(&b_pathqi);
  n = offsetcost->size[0] * offsetcost->size[1];
  offsetcost->size[0] = 1;
  offsetcost->size[1] = (int32_T)uv0[1];
  emxEnsureCapacity((emxArray__common *)offsetcost, n, (int32_T)sizeof(real_T));
  k = 0;
  b_emxInit_int32_T(&r75, 1);
  do {
    exitg3 = 0;
    n = pathqi->size[1];
    ixstart = r75->size[0];
    r75->size[0] = n;
    emxEnsureCapacity((emxArray__common *)r75, ixstart, (int32_T)sizeof(int32_T));
    ixstart = n - 1;
    for (n = 0; n <= ixstart; n++) {
      r75->data[n] = 1 + n;
    }

    if (k <= r75->size[0] - 1) {
      c_pathqi = pathqi->size[0];
      mtmp = pathqi->data[(c_pathqi + pathqi->size[0] * k) - 1];
      offsetcost->data[k] = fabs(mtmp);
      k++;
    } else {
      exitg3 = 1;
    }
  } while (exitg3 == 0U);

  emxFree_int32_T(&r75);

  /* 'equateoffsetcost:8' minoffsetcost = min(pathoffsetcost); */
  ixstart = 1;
  n = offsetcost->size[1];
  b_mtmp = offsetcost->data[0];
  if (n > 1) {
    if (rtIsNaN(offsetcost->data[0])) {
      c_pathqi = 2;
      exitg2 = FALSE;
      while ((exitg2 == 0U) && (c_pathqi <= n)) {
        ixstart = c_pathqi;
        if (!rtIsNaN(offsetcost->data[c_pathqi - 1])) {
          b_mtmp = offsetcost->data[c_pathqi - 1];
          exitg2 = TRUE;
        } else {
          c_pathqi++;
        }
      }
    }

    if (ixstart < n) {
      while (ixstart + 1 <= n) {
        if (offsetcost->data[ixstart] < b_mtmp) {
          b_mtmp = offsetcost->data[ixstart];
        }

        ixstart++;
      }
    }
  }

  /* 'equateoffsetcost:9' maxoffsetcost = max(pathoffsetcost); */
  ixstart = 1;
  n = offsetcost->size[1];
  mtmp = offsetcost->data[0];
  if (n > 1) {
    if (rtIsNaN(offsetcost->data[0])) {
      c_pathqi = 2;
      exitg1 = FALSE;
      while ((exitg1 == 0U) && (c_pathqi <= n)) {
        ixstart = c_pathqi;
        if (!rtIsNaN(offsetcost->data[c_pathqi - 1])) {
          mtmp = offsetcost->data[c_pathqi - 1];
          exitg1 = TRUE;
        } else {
          c_pathqi++;
        }
      }
    }

    if (ixstart < n) {
      while (ixstart + 1 <= n) {
        if (offsetcost->data[ixstart] > mtmp) {
          mtmp = offsetcost->data[ixstart];
        }

        ixstart++;
      }
    }
  }

  /* 'equateoffsetcost:10' offsetcost = (pathoffsetcost-minoffsetcost)*(1/(maxoffsetcost - minoffsetcost)); */
  mtmp = 1.0 / (mtmp - b_mtmp);
  n = offsetcost->size[0] * offsetcost->size[1];
  offsetcost->size[0] = 1;
  offsetcost->size[1] = offsetcost->size[1];
  emxEnsureCapacity((emxArray__common *)offsetcost, n, (int32_T)sizeof(real_T));
  ixstart = offsetcost->size[0];
  n = offsetcost->size[1];
  ixstart = ixstart * n - 1;
  for (n = 0; n <= ixstart; n++) {
    offsetcost->data[n] = (offsetcost->data[n] - b_mtmp) * mtmp;
  }
}
Example #27
0
void mldivide(const emlrtStack *sp, const emxArray_real_T *A, const
              emxArray_real_T *B, emxArray_real_T *Y)
{
  const mxArray *y;
  static const int32_T iv77[2] = { 1, 21 };

  const mxArray *m13;
  char_T cv74[21];
  int32_T i;
  static const char_T cv75[21] = { 'C', 'o', 'd', 'e', 'r', ':', 'M', 'A', 'T',
    'L', 'A', 'B', ':', 'd', 'i', 'm', 'a', 'g', 'r', 'e', 'e' };

  emxArray_real_T *b_B;
  emxArray_real_T *r17;
  uint32_T unnamed_idx_0;
  int32_T loop_ub;
  emlrtStack st;
  st.prev = sp;
  st.tls = sp->tls;
  emlrtHeapReferenceStackEnterFcnR2012b(sp);
  if (B->size[0] == A->size[0]) {
  } else {
    y = NULL;
    m13 = emlrtCreateCharArray(2, iv77);
    for (i = 0; i < 21; i++) {
      cv74[i] = cv75[i];
    }

    emlrtInitCharArrayR2013a(sp, 21, m13, cv74);
    emlrtAssign(&y, m13);
    st.site = &xf_emlrtRSI;
    error(&st, message(&st, y, &bb_emlrtMCI), &bb_emlrtMCI);
  }

  b_emxInit_real_T(sp, &b_B, 1, &tb_emlrtRTEI, true);
  b_emxInit_real_T(sp, &r17, 1, &tb_emlrtRTEI, true);
  if ((A->size[0] == 0) || (A->size[1] == 0) || (B->size[0] == 0)) {
    unnamed_idx_0 = (uint32_T)A->size[1];
    i = Y->size[0];
    Y->size[0] = (int32_T)unnamed_idx_0;
    emxEnsureCapacity(sp, (emxArray__common *)Y, i, (int32_T)sizeof(real_T),
                      &tb_emlrtRTEI);
    loop_ub = (int32_T)unnamed_idx_0;
    for (i = 0; i < loop_ub; i++) {
      Y->data[i] = 0.0;
    }
  } else if (A->size[0] == A->size[1]) {
    i = Y->size[0];
    Y->size[0] = B->size[0];
    emxEnsureCapacity(sp, (emxArray__common *)Y, i, (int32_T)sizeof(real_T),
                      &tb_emlrtRTEI);
    loop_ub = B->size[0];
    for (i = 0; i < loop_ub; i++) {
      Y->data[i] = B->data[i];
    }

    st.site = &xf_emlrtRSI;
    b_eml_lusolve(&st, A, Y);
  } else {
    i = b_B->size[0];
    b_B->size[0] = B->size[0];
    emxEnsureCapacity(sp, (emxArray__common *)b_B, i, (int32_T)sizeof(real_T),
                      &tb_emlrtRTEI);
    loop_ub = B->size[0];
    for (i = 0; i < loop_ub; i++) {
      b_B->data[i] = B->data[i];
    }

    st.site = &xf_emlrtRSI;
    c_eml_qrsolve(&st, A, b_B, r17);
    i = Y->size[0];
    Y->size[0] = r17->size[0];
    emxEnsureCapacity(sp, (emxArray__common *)Y, i, (int32_T)sizeof(real_T),
                      &tb_emlrtRTEI);
    loop_ub = r17->size[0];
    for (i = 0; i < loop_ub; i++) {
      Y->data[i] = r17->data[i];
    }
  }

  emxFree_real_T(&r17);
  emxFree_real_T(&b_B);
  emlrtHeapReferenceStackLeaveFcnR2012b(sp);
}
Example #28
0
static void c_eml_qrsolve(const emlrtStack *sp, const emxArray_real_T *A,
  emxArray_real_T *B, emxArray_real_T *Y)
{
  emxArray_real_T *b_A;
  emxArray_real_T *work;
  int32_T mn;
  int32_T i51;
  int32_T ix;
  emxArray_real_T *tau;
  emxArray_int32_T *jpvt;
  int32_T m;
  int32_T n;
  int32_T b_mn;
  emxArray_real_T *vn1;
  emxArray_real_T *vn2;
  int32_T k;
  boolean_T overflow;
  boolean_T b12;
  int32_T i;
  int32_T i_i;
  int32_T nmi;
  int32_T mmi;
  int32_T pvt;
  int32_T iy;
  boolean_T b13;
  real_T xnorm;
  int32_T i52;
  real_T atmp;
  real_T d16;
  boolean_T b14;
  boolean_T b_i;
  ptrdiff_t n_t;
  ptrdiff_t incx_t;
  double * xix0_t;
  boolean_T exitg1;
  const mxArray *y;
  static const int32_T iv78[2] = { 1, 8 };

  const mxArray *m14;
  char_T cv76[8];
  static const char_T cv77[8] = { '%', '%', '%', 'd', '.', '%', 'd', 'e' };

  char_T cv78[14];
  uint32_T unnamed_idx_0;
  emlrtStack st;
  emlrtStack b_st;
  emlrtStack c_st;
  emlrtStack d_st;
  emlrtStack e_st;
  emlrtStack f_st;
  emlrtStack g_st;
  emlrtStack h_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 = &c_st;
  d_st.tls = c_st.tls;
  e_st.prev = &d_st;
  e_st.tls = d_st.tls;
  f_st.prev = &e_st;
  f_st.tls = e_st.tls;
  g_st.prev = &f_st;
  g_st.tls = f_st.tls;
  h_st.prev = &g_st;
  h_st.tls = g_st.tls;
  emlrtHeapReferenceStackEnterFcnR2012b(sp);
  emxInit_real_T(sp, &b_A, 2, &m_emlrtRTEI, true);
  b_emxInit_real_T(sp, &work, 1, &rb_emlrtRTEI, true);
  mn = (int32_T)muDoubleScalarMin(A->size[0], A->size[1]);
  st.site = &mc_emlrtRSI;
  b_st.site = &nc_emlrtRSI;
  c_st.site = &oc_emlrtRSI;
  i51 = b_A->size[0] * b_A->size[1];
  b_A->size[0] = A->size[0];
  b_A->size[1] = A->size[1];
  emxEnsureCapacity(&c_st, (emxArray__common *)b_A, i51, (int32_T)sizeof(real_T),
                    &m_emlrtRTEI);
  ix = A->size[0] * A->size[1];
  for (i51 = 0; i51 < ix; i51++) {
    b_A->data[i51] = A->data[i51];
  }

  b_emxInit_real_T(&c_st, &tau, 1, &m_emlrtRTEI, true);
  b_emxInit_int32_T(&c_st, &jpvt, 2, &m_emlrtRTEI, true);
  m = b_A->size[0];
  n = b_A->size[1];
  b_mn = muIntScalarMin_sint32(b_A->size[0], b_A->size[1]);
  i51 = tau->size[0];
  tau->size[0] = b_mn;
  emxEnsureCapacity(&c_st, (emxArray__common *)tau, i51, (int32_T)sizeof(real_T),
                    &n_emlrtRTEI);
  d_st.site = &mf_emlrtRSI;
  e_st.site = &rb_emlrtRSI;
  f_st.site = &sb_emlrtRSI;
  g_st.site = &tb_emlrtRSI;
  eml_signed_integer_colon(&g_st, b_A->size[1], jpvt);
  if ((b_A->size[0] == 0) || (b_A->size[1] == 0)) {
  } else {
    ix = b_A->size[1];
    i51 = work->size[0];
    work->size[0] = ix;
    emxEnsureCapacity(&c_st, (emxArray__common *)work, i51, (int32_T)sizeof
                      (real_T), &m_emlrtRTEI);
    for (i51 = 0; i51 < ix; i51++) {
      work->data[i51] = 0.0;
    }

    b_emxInit_real_T(&c_st, &vn1, 1, &pb_emlrtRTEI, true);
    b_emxInit_real_T(&c_st, &vn2, 1, &qb_emlrtRTEI, true);
    d_st.site = &tc_emlrtRSI;
    ix = b_A->size[1];
    i51 = vn1->size[0];
    vn1->size[0] = ix;
    emxEnsureCapacity(&c_st, (emxArray__common *)vn1, i51, (int32_T)sizeof
                      (real_T), &pb_emlrtRTEI);
    i51 = vn2->size[0];
    vn2->size[0] = ix;
    emxEnsureCapacity(&c_st, (emxArray__common *)vn2, i51, (int32_T)sizeof
                      (real_T), &qb_emlrtRTEI);
    k = 1;
    d_st.site = &nf_emlrtRSI;
    overflow = (b_A->size[1] > 2147483646);
    if (overflow) {
      e_st.site = &db_emlrtRSI;
      check_forloop_overflow_error(&e_st);
    }

    for (ix = 0; ix + 1 <= b_A->size[1]; ix++) {
      d_st.site = &sc_emlrtRSI;
      vn1->data[ix] = b_eml_xnrm2(&d_st, b_A->size[0], b_A, k);
      vn2->data[ix] = vn1->data[ix];
      k += b_A->size[0];
    }

    d_st.site = &rc_emlrtRSI;
    if (1 > b_mn) {
      b12 = false;
    } else {
      b12 = (b_mn > 2147483646);
    }

    if (b12) {
      e_st.site = &db_emlrtRSI;
      check_forloop_overflow_error(&e_st);
    }

    for (i = 1; i <= b_mn; i++) {
      i_i = (i + (i - 1) * m) - 1;
      nmi = n - i;
      mmi = m - i;
      d_st.site = &of_emlrtRSI;
      ix = eml_ixamax(&d_st, 1 + nmi, vn1, i);
      pvt = (i + ix) - 2;
      if (pvt + 1 != i) {
        d_st.site = &pf_emlrtRSI;
        e_st.site = &bc_emlrtRSI;
        f_st.site = &cc_emlrtRSI;
        ix = 1 + m * pvt;
        iy = 1 + m * (i - 1);
        g_st.site = &dc_emlrtRSI;
        if (1 > m) {
          b13 = false;
        } else {
          b13 = (m > 2147483646);
        }

        if (b13) {
          h_st.site = &db_emlrtRSI;
          check_forloop_overflow_error(&h_st);
        }

        for (k = 1; k <= m; k++) {
          i51 = b_A->size[0] * b_A->size[1];
          xnorm = b_A->data[emlrtDynamicBoundsCheckFastR2012b(ix, 1, i51,
            &le_emlrtBCI, &f_st) - 1];
          i51 = b_A->size[0] * b_A->size[1];
          i52 = b_A->size[0] * b_A->size[1];
          b_A->data[emlrtDynamicBoundsCheckFastR2012b(ix, 1, i51, &le_emlrtBCI,
            &f_st) - 1] = b_A->data[emlrtDynamicBoundsCheckFastR2012b(iy, 1, i52,
            &le_emlrtBCI, &f_st) - 1];
          i51 = b_A->size[0] * b_A->size[1];
          b_A->data[emlrtDynamicBoundsCheckFastR2012b(iy, 1, i51, &le_emlrtBCI,
            &f_st) - 1] = xnorm;
          ix++;
          iy++;
        }

        ix = jpvt->data[pvt];
        jpvt->data[pvt] = jpvt->data[i - 1];
        jpvt->data[i - 1] = ix;
        vn1->data[pvt] = vn1->data[i - 1];
        vn2->data[pvt] = vn2->data[i - 1];
      }

      if (i < m) {
        d_st.site = &qc_emlrtRSI;
        atmp = b_A->data[i_i];
        d16 = 0.0;
        if (1 + mmi <= 0) {
        } else {
          e_st.site = &wc_emlrtRSI;
          xnorm = b_eml_xnrm2(&e_st, mmi, b_A, i_i + 2);
          if (xnorm != 0.0) {
            xnorm = muDoubleScalarHypot(b_A->data[i_i], xnorm);
            if (b_A->data[i_i] >= 0.0) {
              xnorm = -xnorm;
            }

            if (muDoubleScalarAbs(xnorm) < 1.0020841800044864E-292) {
              ix = 0;
              do {
                ix++;
                e_st.site = &xc_emlrtRSI;
                b_eml_xscal(&e_st, mmi, 9.9792015476736E+291, b_A, i_i + 2);
                xnorm *= 9.9792015476736E+291;
                atmp *= 9.9792015476736E+291;
              } while (!(muDoubleScalarAbs(xnorm) >= 1.0020841800044864E-292));

              e_st.site = &yc_emlrtRSI;
              xnorm = b_eml_xnrm2(&e_st, mmi, b_A, i_i + 2);
              xnorm = muDoubleScalarHypot(atmp, xnorm);
              if (atmp >= 0.0) {
                xnorm = -xnorm;
              }

              d16 = (xnorm - atmp) / xnorm;
              e_st.site = &ad_emlrtRSI;
              b_eml_xscal(&e_st, mmi, 1.0 / (atmp - xnorm), b_A, i_i + 2);
              e_st.site = &bd_emlrtRSI;
              if (1 > ix) {
                b14 = false;
              } else {
                b14 = (ix > 2147483646);
              }

              if (b14) {
                f_st.site = &db_emlrtRSI;
                check_forloop_overflow_error(&f_st);
              }

              for (k = 1; k <= ix; k++) {
                xnorm *= 1.0020841800044864E-292;
              }

              atmp = xnorm;
            } else {
              d16 = (xnorm - b_A->data[i_i]) / xnorm;
              atmp = 1.0 / (b_A->data[i_i] - xnorm);
              e_st.site = &cd_emlrtRSI;
              b_eml_xscal(&e_st, mmi, atmp, b_A, i_i + 2);
              atmp = xnorm;
            }
          }
        }

        tau->data[i - 1] = d16;
      } else {
        atmp = b_A->data[i_i];
        d_st.site = &pc_emlrtRSI;
        tau->data[i - 1] = eml_matlab_zlarfg();
      }

      b_A->data[i_i] = atmp;
      if (i < n) {
        atmp = b_A->data[i_i];
        b_A->data[i_i] = 1.0;
        d_st.site = &qf_emlrtRSI;
        eml_matlab_zlarf(&d_st, mmi + 1, nmi, i_i + 1, tau->data[i - 1], b_A, i
                         + i * m, m, work);
        b_A->data[i_i] = atmp;
      }

      d_st.site = &rf_emlrtRSI;
      if (i + 1 > n) {
        b_i = false;
      } else {
        b_i = (n > 2147483646);
      }

      if (b_i) {
        e_st.site = &db_emlrtRSI;
        check_forloop_overflow_error(&e_st);
      }

      for (ix = i; ix + 1 <= n; ix++) {
        if (vn1->data[ix] != 0.0) {
          xnorm = muDoubleScalarAbs(b_A->data[(i + b_A->size[0] * ix) - 1]) /
            vn1->data[ix];
          xnorm = 1.0 - xnorm * xnorm;
          if (xnorm < 0.0) {
            xnorm = 0.0;
          }

          atmp = vn1->data[ix] / vn2->data[ix];
          atmp = xnorm * (atmp * atmp);
          if (atmp <= 1.4901161193847656E-8) {
            if (i < m) {
              d_st.site = &sf_emlrtRSI;
              e_st.site = &uc_emlrtRSI;
              if (mmi < 1) {
                xnorm = 0.0;
              } else {
                f_st.site = &vc_emlrtRSI;
                g_st.site = &vc_emlrtRSI;
                n_t = (ptrdiff_t)(mmi);
                g_st.site = &vc_emlrtRSI;
                incx_t = (ptrdiff_t)(1);
                i51 = b_A->size[0] * b_A->size[1];
                i52 = (i + m * ix) + 1;
                xix0_t = (double *)(&b_A->data[emlrtDynamicBoundsCheckFastR2012b
                                    (i52, 1, i51, &vb_emlrtBCI, &f_st) - 1]);
                xnorm = dnrm2(&n_t, xix0_t, &incx_t);
              }

              vn1->data[ix] = xnorm;
              vn2->data[ix] = vn1->data[ix];
            } else {
              vn1->data[ix] = 0.0;
              vn2->data[ix] = 0.0;
            }
          } else {
            d_st.site = &tf_emlrtRSI;
            vn1->data[ix] *= muDoubleScalarSqrt(xnorm);
          }
        }
      }
    }

    emxFree_real_T(&vn2);
    emxFree_real_T(&vn1);
  }

  atmp = 0.0;
  if (mn > 0) {
    xnorm = muDoubleScalarMax(A->size[0], A->size[1]) * muDoubleScalarAbs
      (b_A->data[0]) * 2.2204460492503131E-16;
    k = 0;
    exitg1 = false;
    while ((!exitg1) && (k <= mn - 1)) {
      if (muDoubleScalarAbs(b_A->data[k + b_A->size[0] * k]) <= xnorm) {
        st.site = &lc_emlrtRSI;
        y = NULL;
        m14 = emlrtCreateCharArray(2, iv78);
        for (i = 0; i < 8; i++) {
          cv76[i] = cv77[i];
        }

        emlrtInitCharArrayR2013a(&st, 8, m14, cv76);
        emlrtAssign(&y, m14);
        b_st.site = &tg_emlrtRSI;
        emlrt_marshallIn(&b_st, c_sprintf(&b_st, b_sprintf(&b_st, y,
          emlrt_marshallOut(14.0), emlrt_marshallOut(6.0), &o_emlrtMCI),
          emlrt_marshallOut(xnorm), &p_emlrtMCI), "sprintf", cv78);
        st.site = &kc_emlrtRSI;
        b_eml_warning(&st, atmp, cv78);
        exitg1 = true;
      } else {
        atmp++;
        k++;
      }
    }
  }

  unnamed_idx_0 = (uint32_T)A->size[1];
  i51 = Y->size[0];
  Y->size[0] = (int32_T)unnamed_idx_0;
  emxEnsureCapacity(sp, (emxArray__common *)Y, i51, (int32_T)sizeof(real_T),
                    &m_emlrtRTEI);
  ix = (int32_T)unnamed_idx_0;
  for (i51 = 0; i51 < ix; i51++) {
    Y->data[i51] = 0.0;
  }

  for (ix = 0; ix < mn; ix++) {
    if (tau->data[ix] != 0.0) {
      xnorm = B->data[ix];
      i51 = A->size[0] + (int32_T)(1.0 - ((1.0 + (real_T)ix) + 1.0));
      emlrtForLoopVectorCheckR2012b((1.0 + (real_T)ix) + 1.0, 1.0, A->size[0],
        mxDOUBLE_CLASS, i51, &ac_emlrtRTEI, sp);
      for (i = 0; i < i51; i++) {
        unnamed_idx_0 = ((uint32_T)ix + i) + 2U;
        xnorm += b_A->data[((int32_T)unnamed_idx_0 + b_A->size[0] * ix) - 1] *
          B->data[(int32_T)unnamed_idx_0 - 1];
      }

      xnorm *= tau->data[ix];
      if (xnorm != 0.0) {
        B->data[ix] -= xnorm;
        i51 = A->size[0] + (int32_T)(1.0 - ((1.0 + (real_T)ix) + 1.0));
        emlrtForLoopVectorCheckR2012b((1.0 + (real_T)ix) + 1.0, 1.0, A->size[0],
          mxDOUBLE_CLASS, i51, &yb_emlrtRTEI, sp);
        for (i = 0; i < i51; i++) {
          unnamed_idx_0 = ((uint32_T)ix + i) + 2U;
          B->data[(int32_T)unnamed_idx_0 - 1] -= b_A->data[((int32_T)
            unnamed_idx_0 + b_A->size[0] * ix) - 1] * xnorm;
        }
      }
    }
  }

  emxFree_real_T(&tau);
  emlrtForLoopVectorCheckR2012b(1.0, 1.0, atmp, mxDOUBLE_CLASS, (int32_T)atmp,
    &xb_emlrtRTEI, sp);
  for (i = 0; i < (int32_T)atmp; i++) {
    Y->data[jpvt->data[i] - 1] = B->data[i];
  }

  emlrtForLoopVectorCheckR2012b(atmp, -1.0, 1.0, mxDOUBLE_CLASS, (int32_T)-(1.0
    + (-1.0 - atmp)), &wb_emlrtRTEI, sp);
  for (ix = 0; ix < (int32_T)-(1.0 + (-1.0 - atmp)); ix++) {
    xnorm = atmp + -(real_T)ix;
    Y->data[jpvt->data[(int32_T)xnorm - 1] - 1] = eml_div(Y->data[jpvt->data
      [(int32_T)xnorm - 1] - 1], b_A->data[((int32_T)xnorm + b_A->size[0] *
      ((int32_T)xnorm - 1)) - 1]);
    for (i = 0; i < (int32_T)(xnorm - 1.0); i++) {
      Y->data[jpvt->data[i] - 1] -= Y->data[jpvt->data[(int32_T)xnorm - 1] - 1] *
        b_A->data[i + b_A->size[0] * ((int32_T)xnorm - 1)];
    }
  }

  emxFree_int32_T(&jpvt);
  emxFree_real_T(&work);
  emxFree_real_T(&b_A);
  emlrtHeapReferenceStackLeaveFcnR2012b(sp);
}
Example #29
0
/* Function Definitions */
void MechanicalPointForce(const emlrtStack *sp, const emxArray_real_T
  *particlePosition, const emxArray_real_T *pointSourcePosition, real_T
  forceDirection, real_T forceMagnitude, real_T cutoff, emxArray_real_T *force)
{
  uint32_T sz[2];
  int32_T ix;
  emxArray_real_T *forceTemp;
  int32_T loop_ub;
  emxArray_real_T *forceMag;
  int32_T vlen;
  int32_T sIdx;
  emxArray_real_T *forceDir;
  emxArray_real_T *distToSource;
  emxArray_int32_T *r0;
  emxArray_boolean_T *r1;
  emxArray_int32_T *r2;
  emxArray_real_T *x;
  emxArray_real_T *b_x;
  emxArray_real_T *r3;
  emxArray_real_T *r4;
  emxArray_real_T *b_pointSourcePosition;
  emxArray_real_T *b_forceDir;
  emxArray_real_T *c_forceDir;
  int32_T k;
  int32_T vstride;
  int32_T iy;
  int32_T ixstart;
  boolean_T overflow;
  real_T s;
  boolean_T b0;
  uint32_T varargin_2[2];
  boolean_T p;
  boolean_T exitg1;
  int32_T iv0[1];
  int32_T iv1[2];
  int32_T b_force[2];
  int32_T iv2[1];
  int32_T b_iy;
  int32_T c_iy;
  int32_T b_forceTemp[2];
  emlrtStack st;
  emlrtStack b_st;
  emlrtStack c_st;
  emlrtStack d_st;
  emlrtStack e_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 = &c_st;
  d_st.tls = c_st.tls;
  e_st.prev = &d_st;
  e_st.tls = d_st.tls;
  emlrtHeapReferenceStackEnterFcnR2012b(sp);

  /*  apply mechanical (push or pull) force on particles */
  /*  mechanicalForce is a logical flag  */
  /*  particlPosition is a N by 3 vector of particle position */
  /*  pointSourcePosition is the position of force sources  */
  /*  forceDirection is either  -1 for 'in' or 1 for 'out' */
  /*  forceMagnitude is a positive number between 0 and 1 */
  /*  cutoff is the maximal direction the force operates on particle relative */
  /*  to the pointSourcePosition  */
  /*  the output is a vector of N by 3 of delta position to th */
  for (ix = 0; ix < 2; ix++) {
    sz[ix] = (uint32_T)particlePosition->size[ix];
  }

  emxInit_real_T(sp, &forceTemp, 2, &c_emlrtRTEI, true);
  ix = forceTemp->size[0] * forceTemp->size[1];
  forceTemp->size[0] = (int32_T)sz[0];
  emxEnsureCapacity(sp, (emxArray__common *)forceTemp, ix, (int32_T)sizeof
                    (real_T), &emlrtRTEI);
  ix = forceTemp->size[0] * forceTemp->size[1];
  forceTemp->size[1] = (int32_T)sz[1];
  emxEnsureCapacity(sp, (emxArray__common *)forceTemp, ix, (int32_T)sizeof
                    (real_T), &emlrtRTEI);
  loop_ub = (int32_T)sz[0] * (int32_T)sz[1];
  for (ix = 0; ix < loop_ub; ix++) {
    forceTemp->data[ix] = 0.0;
  }

  for (ix = 0; ix < 2; ix++) {
    sz[ix] = (uint32_T)particlePosition->size[ix];
  }

  ix = force->size[0] * force->size[1];
  force->size[0] = (int32_T)sz[0];
  emxEnsureCapacity(sp, (emxArray__common *)force, ix, (int32_T)sizeof(real_T),
                    &emlrtRTEI);
  ix = force->size[0] * force->size[1];
  force->size[1] = (int32_T)sz[1];
  emxEnsureCapacity(sp, (emxArray__common *)force, ix, (int32_T)sizeof(real_T),
                    &emlrtRTEI);
  loop_ub = (int32_T)sz[0] * (int32_T)sz[1];
  for (ix = 0; ix < loop_ub; ix++) {
    force->data[ix] = 0.0;
  }

  emxInit_real_T(sp, &forceMag, 2, &d_emlrtRTEI, true);
  vlen = particlePosition->size[0];
  ix = forceMag->size[0] * forceMag->size[1];
  forceMag->size[0] = vlen;
  emxEnsureCapacity(sp, (emxArray__common *)forceMag, ix, (int32_T)sizeof(real_T),
                    &emlrtRTEI);
  vlen = particlePosition->size[0];
  ix = forceMag->size[0] * forceMag->size[1];
  forceMag->size[1] = vlen;
  emxEnsureCapacity(sp, (emxArray__common *)forceMag, ix, (int32_T)sizeof(real_T),
                    &emlrtRTEI);
  loop_ub = particlePosition->size[0] * particlePosition->size[0];
  for (ix = 0; ix < loop_ub; ix++) {
    forceMag->data[ix] = 0.0;
  }

  sIdx = 0;
  emxInit_real_T(sp, &forceDir, 2, &e_emlrtRTEI, true);
  b_emxInit_real_T(sp, &distToSource, 1, &f_emlrtRTEI, true);
  emxInit_int32_T(sp, &r0, 1, &emlrtRTEI, true);
  emxInit_boolean_T(sp, &r1, 2, &emlrtRTEI, true);
  emxInit_int32_T(sp, &r2, 1, &emlrtRTEI, true);
  emxInit_real_T(sp, &x, 2, &emlrtRTEI, true);
  b_emxInit_real_T(sp, &b_x, 1, &emlrtRTEI, true);
  b_emxInit_real_T(sp, &r3, 1, &emlrtRTEI, true);
  b_emxInit_real_T(sp, &r4, 1, &emlrtRTEI, true);
  emxInit_real_T(sp, &b_pointSourcePosition, 2, &emlrtRTEI, true);
  b_emxInit_real_T(sp, &b_forceDir, 1, &emlrtRTEI, true);
  emxInit_real_T(sp, &c_forceDir, 2, &emlrtRTEI, true);
  while (sIdx <= pointSourcePosition->size[0] - 1) {
    loop_ub = pointSourcePosition->size[1];
    ix = pointSourcePosition->size[0];
    if ((sIdx + 1 >= 1) && (sIdx + 1 < ix)) {
      vlen = sIdx + 1;
    } else {
      vlen = emlrtDynamicBoundsCheckR2012b(sIdx + 1, 1, ix, (emlrtBCInfo *)
        &e_emlrtBCI, sp);
    }

    ix = b_pointSourcePosition->size[0] * b_pointSourcePosition->size[1];
    b_pointSourcePosition->size[0] = 1;
    b_pointSourcePosition->size[1] = loop_ub;
    emxEnsureCapacity(sp, (emxArray__common *)b_pointSourcePosition, ix,
                      (int32_T)sizeof(real_T), &emlrtRTEI);
    for (ix = 0; ix < loop_ub; ix++) {
      b_pointSourcePosition->data[b_pointSourcePosition->size[0] * ix] =
        pointSourcePosition->data[(vlen + pointSourcePosition->size[0] * ix) - 1];
    }

    st.site = &emlrtRSI;
    bsxfun(&st, particlePosition, b_pointSourcePosition, forceDir);

    /*  Find the distance between the particles and the source */
    st.site = &b_emlrtRSI;
    b_st.site = &h_emlrtRSI;
    c_st.site = &i_emlrtRSI;
    d_st.site = &j_emlrtRSI;
    for (ix = 0; ix < 2; ix++) {
      sz[ix] = (uint32_T)forceDir->size[ix];
    }

    ix = x->size[0] * x->size[1];
    x->size[0] = (int32_T)sz[0];
    x->size[1] = (int32_T)sz[1];
    emxEnsureCapacity(&d_st, (emxArray__common *)x, ix, (int32_T)sizeof(real_T),
                      &b_emlrtRTEI);
    if (dimagree(x, forceDir)) {
    } else {
      emlrtErrorWithMessageIdR2012b(&d_st, &b_emlrtRTEI, "MATLAB:dimagree", 0);
    }

    ix = (int32_T)sz[0] * (int32_T)sz[1];
    for (k = 0; k < ix; k++) {
      x->data[k] = forceDir->data[k] * forceDir->data[k];
    }

    st.site = &b_emlrtRSI;
    b_st.site = &k_emlrtRSI;
    c_st.site = &l_emlrtRSI;
    for (ix = 0; ix < 2; ix++) {
      sz[ix] = (uint32_T)x->size[ix];
    }

    ix = b_x->size[0];
    b_x->size[0] = (int32_T)sz[0];
    emxEnsureCapacity(&c_st, (emxArray__common *)b_x, ix, (int32_T)sizeof(real_T),
                      &emlrtRTEI);
    if ((x->size[0] == 0) || (x->size[1] == 0)) {
      ix = b_x->size[0];
      b_x->size[0] = (int32_T)sz[0];
      emxEnsureCapacity(&c_st, (emxArray__common *)b_x, ix, (int32_T)sizeof
                        (real_T), &emlrtRTEI);
      loop_ub = (int32_T)sz[0];
      for (ix = 0; ix < loop_ub; ix++) {
        b_x->data[ix] = 0.0;
      }
    } else {
      vlen = x->size[1];
      vstride = x->size[0];
      iy = -1;
      ixstart = -1;
      d_st.site = &m_emlrtRSI;
      overflow = (x->size[0] > 2147483646);
      if (overflow) {
        e_st.site = &g_emlrtRSI;
        check_forloop_overflow_error(&e_st);
      }

      for (loop_ub = 1; loop_ub <= vstride; loop_ub++) {
        ixstart++;
        ix = ixstart;
        s = x->data[ixstart];
        d_st.site = &n_emlrtRSI;
        if (2 > vlen) {
          b0 = false;
        } else {
          b0 = (vlen > 2147483646);
        }

        if (b0) {
          e_st.site = &g_emlrtRSI;
          check_forloop_overflow_error(&e_st);
        }

        for (k = 2; k <= vlen; k++) {
          ix += vstride;
          s += x->data[ix];
        }

        iy++;
        b_x->data[iy] = s;
      }
    }

    st.site = &b_emlrtRSI;
    ix = distToSource->size[0];
    distToSource->size[0] = b_x->size[0];
    emxEnsureCapacity(&st, (emxArray__common *)distToSource, ix, (int32_T)sizeof
                      (real_T), &emlrtRTEI);
    loop_ub = b_x->size[0];
    for (ix = 0; ix < loop_ub; ix++) {
      distToSource->data[ix] = b_x->data[ix];
    }

    for (k = 0; k < b_x->size[0]; k++) {
      if (b_x->data[k] < 0.0) {
        b_st.site = &o_emlrtRSI;
        eml_error(&b_st);
      }
    }

    for (k = 0; k < b_x->size[0]; k++) {
      distToSource->data[k] = muDoubleScalarSqrt(distToSource->data[k]);
    }

    /*  Normalize the forceDirection */
    iy = 0;
    while (iy < 3) {
      loop_ub = forceDir->size[0];
      ix = r2->size[0];
      r2->size[0] = loop_ub;
      emxEnsureCapacity(sp, (emxArray__common *)r2, ix, (int32_T)sizeof(int32_T),
                        &emlrtRTEI);
      for (ix = 0; ix < loop_ub; ix++) {
        r2->data[ix] = ix;
      }

      ix = forceDir->size[1];
      ixstart = 1 + iy;
      emlrtDynamicBoundsCheckR2012b(ixstart, 1, ix, (emlrtBCInfo *)&c_emlrtBCI,
        sp);
      st.site = &c_emlrtRSI;
      ix = forceDir->size[1];
      ixstart = 1 + iy;
      emlrtDynamicBoundsCheckR2012b(ixstart, 1, ix, (emlrtBCInfo *)&d_emlrtBCI,
        &st);
      ix = forceDir->size[0];
      sz[0] = (uint32_T)ix;
      sz[1] = 1U;
      varargin_2[0] = (uint32_T)distToSource->size[0];
      varargin_2[1] = 1U;
      overflow = false;
      p = true;
      k = 0;
      exitg1 = false;
      while ((!exitg1) && (k < 2)) {
        if (!((int32_T)sz[k] == (int32_T)varargin_2[k])) {
          p = false;
          exitg1 = true;
        } else {
          k++;
        }
      }

      if (!p) {
      } else {
        overflow = true;
      }

      if (overflow) {
      } else {
        emlrtErrorWithMessageIdR2012b(&st, &l_emlrtRTEI, "MATLAB:dimagree", 0);
      }

      loop_ub = forceDir->size[0];
      ix = b_x->size[0];
      b_x->size[0] = loop_ub;
      emxEnsureCapacity(&st, (emxArray__common *)b_x, ix, (int32_T)sizeof(real_T),
                        &emlrtRTEI);
      for (ix = 0; ix < loop_ub; ix++) {
        b_x->data[ix] = forceDir->data[ix + forceDir->size[0] * iy] /
          distToSource->data[ix];
      }

      iv0[0] = r2->size[0];
      emlrtSubAssignSizeCheckR2012b(iv0, 1, *(int32_T (*)[1])b_x->size, 1,
        (emlrtECInfo *)&d_emlrtECI, sp);
      loop_ub = b_x->size[0];
      for (ix = 0; ix < loop_ub; ix++) {
        forceDir->data[r2->data[ix] + forceDir->size[0] * iy] = b_x->data[ix];
      }

      /*  bsxfun(@rdivide,forceDir,distToSource); */
      iy++;
      if (*emlrtBreakCheckR2012bFlagVar != 0) {
        emlrtBreakCheckR2012b(sp);
      }
    }

    /*  Multiply the */
    if (forceDirection == -1.0) {
      ix = r4->size[0];
      r4->size[0] = distToSource->size[0];
      emxEnsureCapacity(sp, (emxArray__common *)r4, ix, (int32_T)sizeof(real_T),
                        &emlrtRTEI);
      loop_ub = distToSource->size[0];
      for (ix = 0; ix < loop_ub; ix++) {
        r4->data[ix] = 1.0 + distToSource->data[ix];
      }

      rdivide(sp, forceMagnitude, r4, b_x);
      vlen = b_x->size[0];
      ix = forceMag->size[0] * forceMag->size[1];
      forceMag->size[0] = vlen;
      emxEnsureCapacity(sp, (emxArray__common *)forceMag, ix, (int32_T)sizeof
                        (real_T), &emlrtRTEI);
      ix = forceMag->size[0] * forceMag->size[1];
      forceMag->size[1] = 1;
      emxEnsureCapacity(sp, (emxArray__common *)forceMag, ix, (int32_T)sizeof
                        (real_T), &emlrtRTEI);
      loop_ub = b_x->size[0];
      for (ix = 0; ix < loop_ub; ix++) {
        forceMag->data[ix] = 1.0 - b_x->data[ix];
      }
    } else {
      if (forceDirection == 1.0) {
        ix = r3->size[0];
        r3->size[0] = distToSource->size[0];
        emxEnsureCapacity(sp, (emxArray__common *)r3, ix, (int32_T)sizeof(real_T),
                          &emlrtRTEI);
        loop_ub = distToSource->size[0];
        for (ix = 0; ix < loop_ub; ix++) {
          r3->data[ix] = 1.0 + distToSource->data[ix];
        }

        rdivide(sp, forceMagnitude, r3, b_x);
        vlen = b_x->size[0];
        ix = forceMag->size[0] * forceMag->size[1];
        forceMag->size[0] = vlen;
        emxEnsureCapacity(sp, (emxArray__common *)forceMag, ix, (int32_T)sizeof
                          (real_T), &emlrtRTEI);
        ix = forceMag->size[0] * forceMag->size[1];
        forceMag->size[1] = 1;
        emxEnsureCapacity(sp, (emxArray__common *)forceMag, ix, (int32_T)sizeof
                          (real_T), &emlrtRTEI);
        loop_ub = b_x->size[0];
        for (ix = 0; ix < loop_ub; ix++) {
          forceMag->data[ix] = b_x->data[ix];
        }
      }
    }

    iy = 0;
    while (iy < 3) {
      ix = forceDir->size[1];
      ixstart = 1 + iy;
      emlrtDynamicBoundsCheckR2012b(ixstart, 1, ix, (emlrtBCInfo *)&b_emlrtBCI,
        sp);
      ix = forceDir->size[0];
      iv1[0] = ix;
      iv1[1] = 1;
      for (ix = 0; ix < 2; ix++) {
        b_force[ix] = forceMag->size[ix];
      }

      if ((iv1[0] != b_force[0]) || (1 != b_force[1])) {
        emlrtSizeEqCheckNDR2012b(iv1, b_force, (emlrtECInfo *)&c_emlrtECI, sp);
      }

      loop_ub = forceTemp->size[0];
      ix = r2->size[0];
      r2->size[0] = loop_ub;
      emxEnsureCapacity(sp, (emxArray__common *)r2, ix, (int32_T)sizeof(int32_T),
                        &emlrtRTEI);
      for (ix = 0; ix < loop_ub; ix++) {
        r2->data[ix] = ix;
      }

      ix = forceTemp->size[1];
      ixstart = 1 + iy;
      emlrtDynamicBoundsCheckR2012b(ixstart, 1, ix, (emlrtBCInfo *)&emlrtBCI, sp);
      loop_ub = forceDir->size[0];
      vlen = forceDir->size[0];
      vstride = forceDir->size[0];
      ix = b_forceDir->size[0];
      b_forceDir->size[0] = vstride;
      emxEnsureCapacity(sp, (emxArray__common *)b_forceDir, ix, (int32_T)sizeof
                        (real_T), &emlrtRTEI);
      for (ix = 0; ix < vstride; ix++) {
        b_forceDir->data[ix] = forceDir->data[ix + forceDir->size[0] * iy];
      }

      ix = c_forceDir->size[0] * c_forceDir->size[1];
      c_forceDir->size[0] = loop_ub;
      c_forceDir->size[1] = 1;
      emxEnsureCapacity(sp, (emxArray__common *)c_forceDir, ix, (int32_T)sizeof
                        (real_T), &emlrtRTEI);
      for (ix = 0; ix < loop_ub; ix++) {
        c_forceDir->data[ix] = b_forceDir->data[ix];
      }

      ix = b_x->size[0];
      b_x->size[0] = vlen;
      emxEnsureCapacity(sp, (emxArray__common *)b_x, ix, (int32_T)sizeof(real_T),
                        &emlrtRTEI);
      for (ix = 0; ix < vlen; ix++) {
        b_x->data[ix] = c_forceDir->data[ix] * forceMag->data[ix];
      }

      iv2[0] = r2->size[0];
      emlrtSubAssignSizeCheckR2012b(iv2, 1, *(int32_T (*)[1])b_x->size, 1,
        (emlrtECInfo *)&b_emlrtECI, sp);
      loop_ub = b_x->size[0];
      for (ix = 0; ix < loop_ub; ix++) {
        forceTemp->data[r2->data[ix] + forceTemp->size[0] * iy] = b_x->data[ix];
      }

      /*  bsxfun(@times,forceDir,forceTemp); */
      iy++;
      if (*emlrtBreakCheckR2012bFlagVar != 0) {
        emlrtBreakCheckR2012b(sp);
      }
    }

    iy = distToSource->size[0] - 1;
    vlen = 0;
    for (vstride = 0; vstride <= iy; vstride++) {
      if (distToSource->data[vstride] > cutoff) {
        vlen++;
      }
    }

    ix = r2->size[0];
    r2->size[0] = vlen;
    emxEnsureCapacity(sp, (emxArray__common *)r2, ix, (int32_T)sizeof(int32_T),
                      &emlrtRTEI);
    vlen = 0;
    for (vstride = 0; vstride <= iy; vstride++) {
      if (distToSource->data[vstride] > cutoff) {
        r2->data[vlen] = vstride + 1;
        vlen++;
      }
    }

    loop_ub = forceTemp->size[1];
    vstride = forceTemp->size[0];
    vlen = r2->size[0];
    for (ix = 0; ix < loop_ub; ix++) {
      for (ixstart = 0; ixstart < vlen; ixstart++) {
        iy = r2->data[ixstart];
        if ((iy >= 1) && (iy < vstride)) {
          b_iy = iy;
        } else {
          b_iy = emlrtDynamicBoundsCheckR2012b(iy, 1, vstride, (emlrtBCInfo *)
            &f_emlrtBCI, sp);
        }

        forceTemp->data[(b_iy + forceTemp->size[0] * ix) - 1] = 0.0;
      }
    }

    ix = r1->size[0] * r1->size[1];
    r1->size[0] = forceTemp->size[0];
    r1->size[1] = forceTemp->size[1];
    emxEnsureCapacity(sp, (emxArray__common *)r1, ix, (int32_T)sizeof(boolean_T),
                      &emlrtRTEI);
    loop_ub = forceTemp->size[0] * forceTemp->size[1];
    for (ix = 0; ix < loop_ub; ix++) {
      r1->data[ix] = muDoubleScalarIsNaN(forceTemp->data[ix]);
    }

    iy = r1->size[0] * r1->size[1] - 1;
    vlen = 0;
    for (vstride = 0; vstride <= iy; vstride++) {
      if (r1->data[vstride]) {
        vlen++;
      }
    }

    ix = r0->size[0];
    r0->size[0] = vlen;
    emxEnsureCapacity(sp, (emxArray__common *)r0, ix, (int32_T)sizeof(int32_T),
                      &emlrtRTEI);
    vlen = 0;
    for (vstride = 0; vstride <= iy; vstride++) {
      if (r1->data[vstride]) {
        r0->data[vlen] = vstride + 1;
        vlen++;
      }
    }

    vstride = forceTemp->size[0];
    vlen = forceTemp->size[1];
    loop_ub = r0->size[0];
    for (ix = 0; ix < loop_ub; ix++) {
      ixstart = vstride * vlen;
      iy = r0->data[ix];
      if ((iy >= 1) && (iy < ixstart)) {
        c_iy = iy;
      } else {
        c_iy = emlrtDynamicBoundsCheckR2012b(iy, 1, ixstart, (emlrtBCInfo *)
          &g_emlrtBCI, sp);
      }

      forceTemp->data[c_iy - 1] = 0.0;
    }

    for (ix = 0; ix < 2; ix++) {
      b_force[ix] = force->size[ix];
    }

    for (ix = 0; ix < 2; ix++) {
      b_forceTemp[ix] = forceTemp->size[ix];
    }

    if ((b_force[0] != b_forceTemp[0]) || (b_force[1] != b_forceTemp[1])) {
      emlrtSizeEqCheckNDR2012b(b_force, b_forceTemp, (emlrtECInfo *)&emlrtECI,
        sp);
    }

    ix = force->size[0] * force->size[1];
    emxEnsureCapacity(sp, (emxArray__common *)force, ix, (int32_T)sizeof(real_T),
                      &emlrtRTEI);
    vlen = force->size[0];
    vstride = force->size[1];
    loop_ub = vlen * vstride;
    for (ix = 0; ix < loop_ub; ix++) {
      force->data[ix] += forceTemp->data[ix];
    }

    sIdx++;
    if (*emlrtBreakCheckR2012bFlagVar != 0) {
      emlrtBreakCheckR2012b(sp);
    }
  }

  emxFree_real_T(&c_forceDir);
  emxFree_real_T(&b_forceDir);
  emxFree_real_T(&b_pointSourcePosition);
  emxFree_real_T(&r4);
  emxFree_real_T(&r3);
  emxFree_real_T(&b_x);
  emxFree_real_T(&x);
  emxFree_int32_T(&r2);
  emxFree_boolean_T(&r1);
  emxFree_int32_T(&r0);
  emxFree_real_T(&distToSource);
  emxFree_real_T(&forceDir);
  emxFree_real_T(&forceMag);
  emxFree_real_T(&forceTemp);
  emlrtHeapReferenceStackLeaveFcnR2012b(sp);
}
Example #30
0
/*
 * % assign structure fields to variables
 *  inputparams - originally simulink inputs
 * Arguments    : const struct0_T *inputparams
 *                const struct1_T *testparams
 *                const struct2_T *fahrparams
 *                const struct3_T *tst_array_struct
 *                const struct4_T *fzg_array_struct
 *                emxArray_real_T *engKinOptVec
 *                emxArray_real_T *batEngDltOptVec
 *                emxArray_real_T *fulEngDltOptVec
 *                emxArray_real_T *staVec
 *                emxArray_real_T *psiEngKinOptVec
 *                double *fulEngOpt
 *                boolean_T *resVld
 * Return Type  : void
 */
void clcDP_port(const struct0_T *inputparams, const struct1_T *testparams, const
                struct2_T *fahrparams, const struct3_T *tst_array_struct, const
                struct4_T *fzg_array_struct, emxArray_real_T *engKinOptVec,
                emxArray_real_T *batEngDltOptVec, emxArray_real_T
                *fulEngDltOptVec, emxArray_real_T *staVec, emxArray_real_T
                *psiEngKinOptVec, double *fulEngOpt, boolean_T *resVld)
{
  emxArray_real_T *optPreInxTn3;
  emxArray_real_T *batFrcOptTn3;
  emxArray_real_T *fulEngOptTn3;
  emxArray_real_T *cos2goActMat;
  emxInit_real_T(&optPreInxTn3, 3);
  emxInit_real_T(&batFrcOptTn3, 3);
  emxInit_real_T(&fulEngOptTn3, 3);
  b_emxInit_real_T(&cos2goActMat, 2);

  /*             --- Ausgangsgrößen: */
  /*  Vektor - Trajektorie der optimalen kin. Energien */
  /*  Vektor - optimale Batterieenergieänderung */
  /*  Vektor - optimale Kraftstoffenergieänderung */
  /*  Vektor - Trajektorie des optimalen Antriebsstrangzustands */
  /*  Vektor - costate für kinetische Energie */
  /*  Skalar - optimale Kraftstoffenergie */
  /*  testparams - originally tstDat800 structure */
  /* % Calculating optimal predecessors with DP + PMP */
  b_fprintf();

  /*  --- Ausgangsgrößen: */
  /*   Tensor 3. Stufe für opt. Vorgängerkoordinaten */
  /*   Tensor 3. Stufe der Batteriekraft */
  /*   Tensor 3. Stufe für die Kraftstoffenergie */
  /*   Matrix der optimalen Kosten der Hamiltonfunktion */
  /*  FUNKTION */
  /*  --- Eingangsgrößen: */
  /*  Skalar - Flag für Ausgabe in das Commandwindow */
  /*  Skalar für die Wegschrittweite in m */
  /*  Skalar der Batteriediskretisierung in J */
  /*  Skalar für die Batterieenergie am Beginn in Ws */
  /*  Skalar für die Nebenverbrauchlast in W */
  /*  Skalar für den Co-State der Batterieenergie */
  /*  Skalar für den Co-State der Zeit */
  /*  Skalar für die Strafkosten beim Zustandswechsel */
  /*  Skalar für Anfangsindex in den Eingangsdaten */
  /*  Skalar für Endindex in den Eingangsdaten */
  /*  Skalar für den Index der Anfangsgeschwindigkeit */
  /*  Skalar für die max. Anz. an engKin-Stützstellen */
  /*  Skalar für die max. Anzahl an Zustandsstützstellen */
  /*  Skalar für die max. Anzahl an Wegstützstellen */
  /*  Skalar für den Startzustand des Antriebsstrangs */
  /*  Vektor der Anzahl der kinetischen Energien */
  /*  Vektor der Steigungen in rad */
  /*  Matrix der kinetischen Energien in J */
  /*  struct der Fahrzeugparameter - NUR SKALARS */
  /*  struct der Fahrzeugparameter - NUR ARRAYS */
  
  clcDP_olyHyb_port(inputparams->disFlg, inputparams->wayStp,
                    inputparams->batEngStp, inputparams->batEngBeg,
                    inputparams->batPwrAux, inputparams->psiBatEng,
                    inputparams->psiTim, inputparams->staChgPenCosVal,
                    inputparams->wayInxBeg, inputparams->wayInxEnd,
                    inputparams->engKinBegInx, testparams->engKinNum,
                    testparams->staNum, testparams->wayNum, inputparams->staBeg,
                    tst_array_struct->engKinNumVec_wayInx,
                    tst_array_struct->slpVec_wayInx,
                    tst_array_struct->engKinMat_engKinInx_wayInx, fahrparams,
                    fzg_array_struct, optPreInxTn3, batFrcOptTn3, fulEngOptTn3,
                    cos2goActMat);

// print out some outputs
int m;
// optPreInxTn3
for (m = 0; m < 52800; m++)
	printf("optPreInxTn3 data[%d]: %4.3f\n", m, optPreInxTn3->data[m]);
printf("\n\noptPreInxTn3 dims: %d\n", optPreInxTn3->numDimensions);
for (m = 0; m < optPreInxTn3->numDimensions; m++)
		printf("optPreInxTn3 size[%d]: %d\n", m, optPreInxTn3->size[m]);
printf("optPreInxTn3 allocatedSize: %d\n:", optPreInxTn3->allocatedSize);
printf("optPreInxTn3.canFreeData: %d\n", optPreInxTn3->canFreeData);


// batFrcOptTn3
//for (m = 0; m < 52800; m++)
//	printf("batFrcOptTn3 data[%d]: %4.3f\n", m, batFrcOptTn3->data[m]);
//printf("\n\batFrcOptTn3 dims: %d\n", batFrcOptTn3->numDimensions);
for (m = 0; m < batFrcOptTn3->numDimensions; m++)
		printf("batFrcOptTn3 size[%d]: %d\n", m, batFrcOptTn3->size[m]);
printf("batFrcOptTn3 allocatedSize: %d\n:", batFrcOptTn3->allocatedSize);
printf("batFrcOptTn3.canFreeData: %d\n", batFrcOptTn3->canFreeData);

	
//// fulEngOptTn3
//for (m = 0; m < fulEngOptTn3->allocatedSize; m++)
//		printf("fulEngOptTn3 data[%d]: %4.3f\n", m, fulEngOptTn3->data[m]);
//printf("\nfulEngOptTn3 dims: %d\n", fulEngOptTn3->numDimensions);
//for (m = 0; m < fulEngOptTn3->numDimensions; m++)
//		printf("fulEngOptTn3 size[%d]: %d\n", m, fulEngOptTn3->size[m]);
//printf("fulEngOptTn3 allocateSize: %d\n", fulEngOptTn3->allocatedSize);
//printf("fulEngOptTn3.canFreeData: %d\n", fulEngOptTn3->canFreeData);


//// cos2goActMat
//for (m = 0; m < cos2goActMat->allocatedSize; m++)
//		printf("cos2goActMat data[%d]: %4.3f\n", m, cos2goActMat->data[m]);
//printf("cos2goActMat dims: %d\n", cos2goActMat->numDimensions);
//for (m = 0; m < cos2goActMat->numDimensions; m++)
//		printf("cos2goActMat size[%d]: %d\n", m, cos2goActMat->size[m]);
//printf("cos2goActMat allocateSize: %d\n", cos2goActMat->allocatedSize);
//printf("cos2goActMat.canFreeData: %d\n", cos2goActMat->canFreeData);


  /* % Calculating optimal trajectories for result of DP + PMP */
  /*  Vektor - Trajektorie der optimalen kin. Energien */
  /*  Vektor - optimale Batterieenergieänderung */
  /*  Vektor - optimale Kraftstoffenergieänderung */
  /*  Vektor - Trajektorie des optimalen Antriebsstrangzustands */
  /*  Vektor - costate für kinetische Energie */
  /*  Skalar - optimale Kraftstoffenergie */
  /*  FUNKTION */
  /*  Flag, ob Zielzustand genutzt werden muss */
  /*  Skalar für die Wegschrittweite in m */
  /*  Skalar für die max. Anzahl an Wegstützstellen */
  /*  Skalar für Anfangsindex in den Eingangsdaten */
  /*  Skalar für Endindex in den Eingangsdaten */
  /*  Skalar für den finalen Zustand */
  /*  Skalar für die max. Anz. an engKin-Stützstellen */
  /*  Skalar für Zielindex der kinetischen Energie */
  /*  Skalar für die max. Anzahl an Zustandsstützstellen */
  /*  Vektor der Anzahl der kinetischen Energien */
  /*  Matrix der kinetischen Energien in J */
  /*  Tensor 3. Stufe für opt. Vorgängerkoordinaten */
  /*  Tensor 3. Stufe der Batteriekraft */
  /*  Tensor 3. Stufe für die Kraftstoffenergie */
  /*  Matrix der optimalen Kosten der Hamiltonfunktion */
  
  
  // note: some portion of clcOptTrj_port is causing a memory overflow and is currently
  // 		not working as a direct MATLAB port. Need to look into function to see what
  //		is going wrong
//  clcOptTrj_port(inputparams->wayStp, testparams->wayNum, inputparams->wayInxBeg,
//                 inputparams->wayInxEnd, testparams->engKinNum,
//                 tst_array_struct->engKinNumVec_wayInx,
//                 tst_array_struct->engKinMat_engKinInx_wayInx, optPreInxTn3,
//                 batFrcOptTn3, fulEngOptTn3, cos2goActMat, engKinOptVec,
//                 batEngDltOptVec, fulEngDltOptVec, staVec, psiEngKinOptVec,
//                 fulEngOpt);

  /*  engKinOptVec=0; */
  /*  batEngDltOptVec=0; */
  /*  fulEngDltOptVec=0; */
  /*  staVec=0; */
  /*  psiEngKinOptVec=0; */
  /*  fulEngOpt=0; */
  
//  *resVld = true;
  f_fprintf();
  emxFree_real_T(&cos2goActMat);
  emxFree_real_T(&fulEngOptTn3);
  emxFree_real_T(&batFrcOptTn3);
  emxFree_real_T(&optPreInxTn3);
}