#### File: MLS_emxutil.c
        1   /*
        2    * File: MLS_emxutil.c
        3    *
        4    * MATLAB Coder version            : 3.4
        5    * C/C++ source code generated on  : 27-Feb-2019 07:49:44
        6    */
        7
        8   /* Include Files */
        9   #include "rt_nonfinite.h"
       10   #include "MLS.h"
       11   #include "MLS_emxutil.h"
       12
       13   /* Function Definitions */
       14
       15   /*
       16    * Arguments    : emxArray_real_T *emxArray
       17    *                int oldNumel
       18    * Return Type  : void
       19    */
       20   void emxEnsureCapacity_real_T(emxArray_real_T *emxArray, int oldNumel)
       21   {
       22     int newNumel;
       23     int i;
       24     void *newData;
       25     if (oldNumel < 0) {
       26       oldNumel = 0;
       27     }
       28
       29     newNumel = 1;
       30     for (i = 0; i < emxArray->numDimensions; i++) {
       31       newNumel *= emxArray->size[i];
       32     }
       33
       34     if (newNumel > emxArray->allocatedSize) {
       35       i = emxArray->allocatedSize;
       36       if (i < 16) {
       37         i = 16;
       38       }
       39
       40       while (i < newNumel) {
       41         if (i > 1073741823) {
       42           i = MAX_int32_T;
       43         } else {
       44           i <<= 1;
       45         }
       46       }
       47
       48       newData = calloc((unsigned int)i, sizeof(double));
       49       if (emxArray->data != NULL) {
       50         memcpy(newData, (void *)emxArray->data, sizeof(double) * oldNumel);
       51         if (emxArray->canFreeData) {
       52           free((void *)emxArray->data);
       53         }
       54       }
       55
       56       emxArray->data = (double *)newData;
       57       emxArray->allocatedSize = i;
       58       emxArray->canFreeData = true;
       59     }
       60   }
       61
       62   /*
       63    * Arguments    : emxArray_real_T *emxArray
       64    *                int oldNumel
       65    * Return Type  : void
       66    */
       67   void emxEnsureCapacity_real_T1(emxArray_real_T *emxArray, int oldNumel)
       68   {
       69     int newNumel;
       70     int i;
       71     void *newData;
       72     if (oldNumel < 0) {
       73       oldNumel = 0;
       74     }
       75
       76     newNumel = 1;
       77     for (i = 0; i < emxArray->numDimensions; i++) {
       78       newNumel *= emxArray->size[i];
       79     }
       80
       81     if (newNumel > emxArray->allocatedSize) {
       82       i = emxArray->allocatedSize;
       83       if (i < 16) {
       84         i = 16;
       85       }
       86
       87       while (i < newNumel) {
       88         if (i > 1073741823) {
       89           i = MAX_int32_T;
       90         } else {
       91           i <<= 1;
       92         }
       93       }
       94
       95       newData = calloc((unsigned int)i, sizeof(double));
       96       if (emxArray->data != NULL) {
       97         memcpy(newData, (void *)emxArray->data, sizeof(double) * oldNumel);
       98         if (emxArray->canFreeData) {
       99           free((void *)emxArray->data);
      100         }
      101       }
      102
      103       emxArray->data = (double *)newData;
      104       emxArray->allocatedSize = i;
      105       emxArray->canFreeData = true;
      106     }
      107   }
      108
      109   /*
      110    * Arguments    : emxArray_real_T *emxArray
      111    *                int oldNumel
      112    * Return Type  : void
      113    */
      114   void emxEnsureCapacity_real_T2(emxArray_real_T *emxArray, int oldNumel)
      115   {
      116     int newNumel;
      117     int i;
      118     void *newData;
      119     if (oldNumel < 0) {
      120       oldNumel = 0;
      121     }
      122
      123     newNumel = 1;
      124     for (i = 0; i < emxArray->numDimensions; i++) {
      125       newNumel *= emxArray->size[i];
      126     }
      127
      128     if (newNumel > emxArray->allocatedSize) {
      129       i = emxArray->allocatedSize;
      130       if (i < 16) {
      131         i = 16;
      132       }
      133
      134       while (i < newNumel) {
      135         if (i > 1073741823) {
      136           i = MAX_int32_T;
      137         } else {
      138           i <<= 1;
      139         }
      140       }
      141
      142       newData = calloc((unsigned int)i, sizeof(double));
      143       if (emxArray->data != NULL) {
      144         memcpy(newData, (void *)emxArray->data, sizeof(double) * oldNumel);
      145         if (emxArray->canFreeData) {
      146           free((void *)emxArray->data);
      147         }
      148       }
      149
      150       emxArray->data = (double *)newData;
      151       emxArray->allocatedSize = i;
      152       emxArray->canFreeData = true;
      153     }
      154   }
      155
      156   /*
      157    * Arguments    : struct0_T *pStruct
      158    * Return Type  : void
      159    */
      160   void emxFreeStruct_struct0_T(struct0_T *pStruct)
      161   {
      162     emxFree_real_T(&pStruct->w_i);
      163     emxFree_real_T(&pStruct->sum_w_i);
      164     emxFree_real_T(&pStruct->p_ast);
      165     emxFree_real_T(&pStruct->Similarity);
      166   }
      167
      168   /*
      169    * Arguments    : emxArray_char_T **pEmxArray
      170    * Return Type  : void
      171    */
      172   void emxFree_char_T(emxArray_char_T **pEmxArray)
      173   {
      174     if (*pEmxArray != (emxArray_char_T *)NULL) {
      175       if (((*pEmxArray)->data != (char *)NULL) && (*pEmxArray)->canFreeData) {
      176         free((void *)(*pEmxArray)->data);
      177       }
      178
      179       free((void *)(*pEmxArray)->size);
      180       free((void *)*pEmxArray);
      181       *pEmxArray = (emxArray_char_T *)NULL;
      182     }
      183   }
      184
      185   /*
      186    * Arguments    : emxArray_real_T **pEmxArray
      187    * Return Type  : void
      188    */
      189   void emxFree_real_T(emxArray_real_T **pEmxArray)
      190   {
      191     if (*pEmxArray != (emxArray_real_T *)NULL) {
      192       if (((*pEmxArray)->data != (double *)NULL) && (*pEmxArray)->canFreeData) {
      193         free((void *)(*pEmxArray)->data);
      194       }
      195
      196       free((void *)(*pEmxArray)->size);
      197       free((void *)*pEmxArray);
      198       *pEmxArray = (emxArray_real_T *)NULL;
      199     }
      200   }
      201
      202   /*
      203    * Arguments    : struct0_T *pStruct
      204    * Return Type  : void
      205    */
      206   void emxInitStruct_struct0_T(struct0_T *pStruct)
      207   {
      208     emxInit_real_T1(&pStruct->w_i, 2);
      209     emxInit_real_T(&pStruct->sum_w_i, 1);
      210     emxInit_real_T1(&pStruct->p_ast, 2);
      211     emxInit_real_T1(&pStruct->Similarity, 2);
      212   }
      213
      214   /*
      215    * Arguments    : emxArray_char_T **pEmxArray
      216    *                int numDimensions
      217    * Return Type  : void
      218    */
      219   void emxInit_char_T(emxArray_char_T **pEmxArray, int numDimensions)
      220   {
      221     emxArray_char_T *emxArray;
      222     int i;
      223     *pEmxArray = (emxArray_char_T *)malloc(sizeof(emxArray_char_T));
      224     emxArray = *pEmxArray;
      225     emxArray->data = (char *)NULL;
      226     emxArray->numDimensions = numDimensions;
      227     emxArray->size = (int *)malloc((unsigned int)(sizeof(int) * numDimensions));
      228     emxArray->allocatedSize = 0;
      229     emxArray->canFreeData = true;
      230     for (i = 0; i < numDimensions; i++) {
      231       emxArray->size[i] = 0;
      232     }
      233   }
      234
      235   /*
      236    * Arguments    : emxArray_real_T **pEmxArray
      237    *                int numDimensions
      238    * Return Type  : void
      239    */
      240   void emxInit_real_T(emxArray_real_T **pEmxArray, int numDimensions)
      241   {
      242     emxArray_real_T *emxArray;
      243     int i;
      244     *pEmxArray = (emxArray_real_T *)malloc(sizeof(emxArray_real_T));
      245     emxArray = *pEmxArray;
      246     emxArray->data = (double *)NULL;
      247     emxArray->numDimensions = numDimensions;
      248     emxArray->size = (int *)malloc((unsigned int)(sizeof(int) * numDimensions));
      249     emxArray->allocatedSize = 0;
      250     emxArray->canFreeData = true;
      251     for (i = 0; i < numDimensions; i++) {
      252       emxArray->size[i] = 0;
      253     }
      254   }
      255
      256   /*
      257    * Arguments    : emxArray_real_T **pEmxArray
      258    *                int numDimensions
      259    * Return Type  : void
      260    */
      261   void emxInit_real_T1(emxArray_real_T **pEmxArray, int numDimensions)
      262   {
      263     emxArray_real_T *emxArray;
      264     int i;
      265     *pEmxArray = (emxArray_real_T *)malloc(sizeof(emxArray_real_T));
      266     emxArray = *pEmxArray;
      267     emxArray->data = (double *)NULL;
      268     emxArray->numDimensions = numDimensions;
      269     emxArray->size = (int *)malloc((unsigned int)(sizeof(int) * numDimensions));
      270     emxArray->allocatedSize = 0;
      271     emxArray->canFreeData = true;
      272     for (i = 0; i < numDimensions; i++) {
      273       emxArray->size[i] = 0;
      274     }
      275   }
      276
      277   /*
      278    * Arguments    : emxArray_real_T **pEmxArray
      279    *                int numDimensions
      280    * Return Type  : void
      281    */
      282   void emxInit_real_T2(emxArray_real_T **pEmxArray, int numDimensions)
      283   {
      284     emxArray_real_T *emxArray;
      285     int i;
      286     *pEmxArray = (emxArray_real_T *)malloc(sizeof(emxArray_real_T));
      287     emxArray = *pEmxArray;
      288     emxArray->data = (double *)NULL;
      289     emxArray->numDimensions = numDimensions;
      290     emxArray->size = (int *)malloc((unsigned int)(sizeof(int) * numDimensions));
      291     emxArray->allocatedSize = 0;
      292     emxArray->canFreeData = true;
      293     for (i = 0; i < numDimensions; i++) {
      294       emxArray->size[i] = 0;
      295     }
      296   }
      297
      298   /*
      299    * File trailer for MLS_emxutil.c
      300    *
      301    * [EOF]
      302    */
      303