#### File: MLS_getDeform_emxutil.c
        1   /*
        2    * MLS_getDeform_emxutil.c
        3    *
        4    * Code generation for function 'MLS_getDeform_emxutil'
        5    *
        6    */
        7
        8   /* Include files */
        9   #include "rt_nonfinite.h"
       10   #include "MLS_getDeform.h"
       11   #include "MLS_getDeform_emxutil.h"
       12
       13   /* Function Declarations */
       14   static void emxCopy_real_T(const emlrtStack *sp, emxArray_real_T **dst,
       15     emxArray_real_T * const *src, const emlrtRTEInfo *srcLocation);
       16   static void emxCopy_real_T1(const emlrtStack *sp, emxArray_real_T **dst,
       17     emxArray_real_T * const *src, const emlrtRTEInfo *srcLocation);
       18
       19   /* Function Definitions */
       20   static void emxCopy_real_T(const emlrtStack *sp, emxArray_real_T **dst,
       21     emxArray_real_T * const *src, const emlrtRTEInfo *srcLocation)
       22   {
       23     int32_T numElDst;
       24     int32_T numElSrc;
       25     int32_T i;
       26     numElDst = 1;
       27     numElSrc = 1;
       28     for (i = 0; i < (*dst)->numDimensions; i++) {
       29       numElDst *= (*dst)->size[i];
       30       numElSrc *= (*src)->size[i];
       31     }
       32
       33     for (i = 0; i < (*dst)->numDimensions; i++) {
       34       (*dst)->size[i] = (*src)->size[i];
       35     }
       36
       37     emxEnsureCapacity_real_T(sp, *dst, numElDst, srcLocation);
       38     for (i = 0; i < numElSrc; i++) {
       39       (*dst)->data[i] = (*src)->data[i];
       40     }
       41   }
       42
       43   static void emxCopy_real_T1(const emlrtStack *sp, emxArray_real_T **dst,
       44     emxArray_real_T * const *src, const emlrtRTEInfo *srcLocation)
       45   {
       46     int32_T numElDst;
       47     int32_T numElSrc;
       48     int32_T i;
       49     numElDst = 1;
       50     numElSrc = 1;
       51     for (i = 0; i < (*dst)->numDimensions; i++) {
       52       numElDst *= (*dst)->size[i];
       53       numElSrc *= (*src)->size[i];
       54     }
       55
       56     for (i = 0; i < (*dst)->numDimensions; i++) {
       57       (*dst)->size[i] = (*src)->size[i];
       58     }
       59
       60     emxEnsureCapacity_real_T1(sp, *dst, numElDst, srcLocation);
       61     for (i = 0; i < numElSrc; i++) {
       62       (*dst)->data[i] = (*src)->data[i];
       63     }
       64   }
       65
       66   void emxCopyStruct_struct0_T(const emlrtStack *sp, struct0_T *dst, const
       67     struct0_T *src, const emlrtRTEInfo *srcLocation)
       68   {
       69     emxCopy_real_T(sp, &dst->w_i, &src->w_i, srcLocation);
       70     emxCopy_real_T1(sp, &dst->sum_w_i, &src->sum_w_i, srcLocation);
       71     emxCopy_real_T(sp, &dst->p_ast, &src->p_ast, srcLocation);
       72     emxCopy_real_T(sp, &dst->Similarity, &src->Similarity, srcLocation);
       73     emxCopy_real_T(sp, &dst->Affine, &src->Affine, srcLocation);
       74     emxCopy_real_T(sp, &dst->Rigid, &src->Rigid, srcLocation);
       75   }
       76
       77   void emxEnsureCapacity_char_T(const emlrtStack *sp, emxArray_char_T *emxArray,
       78     int32_T oldNumel, const emlrtRTEInfo *srcLocation)
       79   {
       80     int32_T newNumel;
       81     int32_T i;
       82     void *newData;
       83     if (oldNumel < 0) {
       84       oldNumel = 0;
       85     }
       86
       87     newNumel = 1;
       88     for (i = 0; i < emxArray->numDimensions; i++) {
       89       newNumel = (int32_T)emlrtSizeMulR2012b((uint32_T)newNumel, (uint32_T)
       90         emxArray->size[i], srcLocation, sp);
       91     }
       92
       93     if (newNumel > emxArray->allocatedSize) {
       94       i = emxArray->allocatedSize;
       95       if (i < 16) {
       96         i = 16;
       97       }
       98
       99       while (i < newNumel) {
      100         if (i > 1073741823) {
      101           i = MAX_int32_T;
      102         } else {
      103           i <<= 1;
      104         }
      105       }
      106
      107       newData = emlrtCallocMex((uint32_T)i, sizeof(char_T));
      108       if (newData == NULL) {
      109         emlrtHeapAllocationErrorR2012b(srcLocation, sp);
      110       }
      111
      112       if (emxArray->data != NULL) {
      113         memcpy(newData, (void *)emxArray->data, sizeof(char_T) * oldNumel);
      114         if (emxArray->canFreeData) {
      115           emlrtFreeMex((void *)emxArray->data);
      116         }
      117       }
      118
      119       emxArray->data = (char_T *)newData;
      120       emxArray->allocatedSize = i;
      121       emxArray->canFreeData = true;
      122     }
      123   }
      124
      125   void emxEnsureCapacity_real_T(const emlrtStack *sp, emxArray_real_T *emxArray,
      126     int32_T oldNumel, const emlrtRTEInfo *srcLocation)
      127   {
      128     int32_T newNumel;
      129     int32_T i;
      130     void *newData;
      131     if (oldNumel < 0) {
      132       oldNumel = 0;
      133     }
      134
      135     newNumel = 1;
      136     for (i = 0; i < emxArray->numDimensions; i++) {
      137       newNumel = (int32_T)emlrtSizeMulR2012b((uint32_T)newNumel, (uint32_T)
      138         emxArray->size[i], srcLocation, sp);
      139     }
      140
      141     if (newNumel > emxArray->allocatedSize) {
      142       i = emxArray->allocatedSize;
      143       if (i < 16) {
      144         i = 16;
      145       }
      146
      147       while (i < newNumel) {
      148         if (i > 1073741823) {
      149           i = MAX_int32_T;
      150         } else {
      151           i <<= 1;
      152         }
      153       }
      154
      155       newData = emlrtCallocMex((uint32_T)i, sizeof(real_T));
      156       if (newData == NULL) {
      157         emlrtHeapAllocationErrorR2012b(srcLocation, sp);
      158       }
      159
      160       if (emxArray->data != NULL) {
      161         memcpy(newData, (void *)emxArray->data, sizeof(real_T) * oldNumel);
      162         if (emxArray->canFreeData) {
      163           emlrtFreeMex((void *)emxArray->data);
      164         }
      165       }
      166
      167       emxArray->data = (real_T *)newData;
      168       emxArray->allocatedSize = i;
      169       emxArray->canFreeData = true;
      170     }
      171   }
      172
      173   void emxEnsureCapacity_real_T1(const emlrtStack *sp, emxArray_real_T *emxArray,
      174     int32_T oldNumel, const emlrtRTEInfo *srcLocation)
      175   {
      176     int32_T newNumel;
      177     int32_T i;
      178     void *newData;
      179     if (oldNumel < 0) {
      180       oldNumel = 0;
      181     }
      182
      183     newNumel = 1;
      184     for (i = 0; i < emxArray->numDimensions; i++) {
      185       newNumel = (int32_T)emlrtSizeMulR2012b((uint32_T)newNumel, (uint32_T)
      186         emxArray->size[i], srcLocation, sp);
      187     }
      188
      189     if (newNumel > emxArray->allocatedSize) {
      190       i = emxArray->allocatedSize;
      191       if (i < 16) {
      192         i = 16;
      193       }
      194
      195       while (i < newNumel) {
      196         if (i > 1073741823) {
      197           i = MAX_int32_T;
      198         } else {
      199           i <<= 1;
      200         }
      201       }
      202
      203       newData = emlrtCallocMex((uint32_T)i, sizeof(real_T));
      204       if (newData == NULL) {
      205         emlrtHeapAllocationErrorR2012b(srcLocation, sp);
      206       }
      207
      208       if (emxArray->data != NULL) {
      209         memcpy(newData, (void *)emxArray->data, sizeof(real_T) * oldNumel);
      210         if (emxArray->canFreeData) {
      211           emlrtFreeMex((void *)emxArray->data);
      212         }
      213       }
      214
      215       emxArray->data = (real_T *)newData;
      216       emxArray->allocatedSize = i;
      217       emxArray->canFreeData = true;
      218     }
      219   }
      220
      221   void emxEnsureCapacity_real_T2(const emlrtStack *sp, emxArray_real_T *emxArray,
      222     int32_T oldNumel, const emlrtRTEInfo *srcLocation)
      223   {
      224     int32_T newNumel;
      225     int32_T i;
      226     void *newData;
      227     if (oldNumel < 0) {
      228       oldNumel = 0;
      229     }
      230
      231     newNumel = 1;
      232     for (i = 0; i < emxArray->numDimensions; i++) {
      233       newNumel = (int32_T)emlrtSizeMulR2012b((uint32_T)newNumel, (uint32_T)
      234         emxArray->size[i], srcLocation, sp);
      235     }
      236
      237     if (newNumel > emxArray->allocatedSize) {
      238       i = emxArray->allocatedSize;
      239       if (i < 16) {
      240         i = 16;
      241       }
      242
      243       while (i < newNumel) {
      244         if (i > 1073741823) {
      245           i = MAX_int32_T;
      246         } else {
      247           i <<= 1;
      248         }
      249       }
      250
      251       newData = emlrtCallocMex((uint32_T)i, sizeof(real_T));
      252       if (newData == NULL) {
      253         emlrtHeapAllocationErrorR2012b(srcLocation, sp);
      254       }
      255
      256       if (emxArray->data != NULL) {
      257         memcpy(newData, (void *)emxArray->data, sizeof(real_T) * oldNumel);
      258         if (emxArray->canFreeData) {
      259           emlrtFreeMex((void *)emxArray->data);
      260         }
      261       }
      262
      263       emxArray->data = (real_T *)newData;
      264       emxArray->allocatedSize = i;
      265       emxArray->canFreeData = true;
      266     }
      267   }
      268
      269   void emxFreeStruct_struct0_T(struct0_T *pStruct)
      270   {
      271     emxFree_real_T(&pStruct->w_i);
      272     emxFree_real_T(&pStruct->sum_w_i);
      273     emxFree_real_T(&pStruct->p_ast);
      274     emxFree_real_T(&pStruct->Similarity);
      275     emxFree_real_T(&pStruct->Affine);
      276     emxFree_real_T(&pStruct->Rigid);
      277   }
      278
      279   void emxFree_char_T(emxArray_char_T **pEmxArray)
      280   {
      281     if (*pEmxArray != (emxArray_char_T *)NULL) {
      282       if (((*pEmxArray)->data != (char_T *)NULL) && (*pEmxArray)->canFreeData) {
      283         emlrtFreeMex((void *)(*pEmxArray)->data);
      284       }
      285
      286       emlrtFreeMex((void *)(*pEmxArray)->size);
      287       emlrtFreeMex((void *)*pEmxArray);
      288       *pEmxArray = (emxArray_char_T *)NULL;
      289     }
      290   }
      291
      292   void emxFree_real_T(emxArray_real_T **pEmxArray)
      293   {
      294     if (*pEmxArray != (emxArray_real_T *)NULL) {
      295       if (((*pEmxArray)->data != (real_T *)NULL) && (*pEmxArray)->canFreeData) {
      296         emlrtFreeMex((void *)(*pEmxArray)->data);
      297       }
      298
      299       emlrtFreeMex((void *)(*pEmxArray)->size);
      300       emlrtFreeMex((void *)*pEmxArray);
      301       *pEmxArray = (emxArray_real_T *)NULL;
      302     }
      303   }
      304
      305   void emxInitStruct_struct0_T(const emlrtStack *sp, struct0_T *pStruct, const
      306     emlrtRTEInfo *srcLocation, boolean_T doPush)
      307   {
      308     emxInit_real_T1(sp, &pStruct->w_i, 2, srcLocation, doPush);
      309     emxInit_real_T2(sp, &pStruct->sum_w_i, 1, srcLocation, doPush);
      310     emxInit_real_T1(sp, &pStruct->p_ast, 2, srcLocation, doPush);
      311     emxInit_real_T1(sp, &pStruct->Similarity, 2, srcLocation, doPush);
      312     emxInit_real_T1(sp, &pStruct->Affine, 2, srcLocation, doPush);
      313     emxInit_real_T1(sp, &pStruct->Rigid, 2, srcLocation, doPush);
      314   }
      315
      316   void emxInit_char_T(const emlrtStack *sp, emxArray_char_T **pEmxArray, int32_T
      317                       numDimensions, const emlrtRTEInfo *srcLocation, boolean_T
      318                       doPush)
      319   {
      320     emxArray_char_T *emxArray;
      321     int32_T i;
      322     *pEmxArray = (emxArray_char_T *)emlrtMallocMex(sizeof(emxArray_char_T));
      323     if ((void *)*pEmxArray == NULL) {
      324       emlrtHeapAllocationErrorR2012b(srcLocation, sp);
      325     }
      326
      327     if (doPush) {
      328       emlrtPushHeapReferenceStackR2012b(sp, (void *)pEmxArray, (void (*)(void *))
      329         emxFree_char_T);
      330     }
      331
      332     emxArray = *pEmxArray;
      333     emxArray->data = (char_T *)NULL;
      334     emxArray->numDimensions = numDimensions;
      335     emxArray->size = (int32_T *)emlrtMallocMex((uint32_T)(sizeof(int32_T)
      336       * numDimensions));
      337     if ((void *)emxArray->size == NULL) {
      338       emlrtHeapAllocationErrorR2012b(srcLocation, sp);
      339     }
      340
      341     emxArray->allocatedSize = 0;
      342     emxArray->canFreeData = true;
      343     for (i = 0; i < numDimensions; i++) {
      344       emxArray->size[i] = 0;
      345     }
      346   }
      347
      348   void emxInit_real_T(const emlrtStack *sp, emxArray_real_T **pEmxArray, int32_T
      349                       numDimensions, const emlrtRTEInfo *srcLocation, boolean_T
      350                       doPush)
      351   {
      352     emxArray_real_T *emxArray;
      353     int32_T i;
      354     *pEmxArray = (emxArray_real_T *)emlrtMallocMex(sizeof(emxArray_real_T));
      355     if ((void *)*pEmxArray == NULL) {
      356       emlrtHeapAllocationErrorR2012b(srcLocation, sp);
      357     }
      358
      359     if (doPush) {
      360       emlrtPushHeapReferenceStackR2012b(sp, (void *)pEmxArray, (void (*)(void *))
      361         emxFree_real_T);
      362     }
      363
      364     emxArray = *pEmxArray;
      365     emxArray->data = (real_T *)NULL;
      366     emxArray->numDimensions = numDimensions;
      367     emxArray->size = (int32_T *)emlrtMallocMex((uint32_T)(sizeof(int32_T)
      368       * numDimensions));
      369     if ((void *)emxArray->size == NULL) {
      370       emlrtHeapAllocationErrorR2012b(srcLocation, sp);
      371     }
      372
      373     emxArray->allocatedSize = 0;
      374     emxArray->canFreeData = true;
      375     for (i = 0; i < numDimensions; i++) {
      376       emxArray->size[i] = 0;
      377     }
      378   }
      379
      380   void emxInit_real_T1(const emlrtStack *sp, emxArray_real_T **pEmxArray, int32_T
      381                        numDimensions, const emlrtRTEInfo *srcLocation, boolean_T
      382                        doPush)
      383   {
      384     emxArray_real_T *emxArray;
      385     int32_T i;
      386     *pEmxArray = (emxArray_real_T *)emlrtMallocMex(sizeof(emxArray_real_T));
      387     if ((void *)*pEmxArray == NULL) {
      388       emlrtHeapAllocationErrorR2012b(srcLocation, sp);
      389     }
      390
      391     if (doPush) {
      392       emlrtPushHeapReferenceStackR2012b(sp, (void *)pEmxArray, (void (*)(void *))
      393         emxFree_real_T);
      394     }
      395
      396     emxArray = *pEmxArray;
      397     emxArray->data = (real_T *)NULL;
      398     emxArray->numDimensions = numDimensions;
      399     emxArray->size = (int32_T *)emlrtMallocMex((uint32_T)(sizeof(int32_T)
      400       * numDimensions));
      401     if ((void *)emxArray->size == NULL) {
      402       emlrtHeapAllocationErrorR2012b(srcLocation, sp);
      403     }
      404
      405     emxArray->allocatedSize = 0;
      406     emxArray->canFreeData = true;
      407     for (i = 0; i < numDimensions; i++) {
      408       emxArray->size[i] = 0;
      409     }
      410   }
      411
      412   void emxInit_real_T2(const emlrtStack *sp, emxArray_real_T **pEmxArray, int32_T
      413                        numDimensions, const emlrtRTEInfo *srcLocation, boolean_T
      414                        doPush)
      415   {
      416     emxArray_real_T *emxArray;
      417     int32_T i;
      418     *pEmxArray = (emxArray_real_T *)emlrtMallocMex(sizeof(emxArray_real_T));
      419     if ((void *)*pEmxArray == NULL) {
      420       emlrtHeapAllocationErrorR2012b(srcLocation, sp);
      421     }
      422
      423     if (doPush) {
      424       emlrtPushHeapReferenceStackR2012b(sp, (void *)pEmxArray, (void (*)(void *))
      425         emxFree_real_T);
      426     }
      427
      428     emxArray = *pEmxArray;
      429     emxArray->data = (real_T *)NULL;
      430     emxArray->numDimensions = numDimensions;
      431     emxArray->size = (int32_T *)emlrtMallocMex((uint32_T)(sizeof(int32_T)
      432       * numDimensions));
      433     if ((void *)emxArray->size == NULL) {
      434       emlrtHeapAllocationErrorR2012b(srcLocation, sp);
      435     }
      436
      437     emxArray->allocatedSize = 0;
      438     emxArray->canFreeData = true;
      439     for (i = 0; i < numDimensions; i++) {
      440       emxArray->size[i] = 0;
      441     }
      442   }
      443
      444   /* End of code generation (MLS_getDeform_emxutil.c) */
      445