#### File: MLS_getDeform.c
        1   /*
        2    * MLS_getDeform.c
        3    *
        4    * Code generation for function 'MLS_getDeform'
        5    *
        6    */
        7
        8   /* Include files */
        9   #include "rt_nonfinite.h"
       10   #include "MLS_getDeform.h"
       11   #include "MLS_getDeform_emxutil.h"
       12   #include "error.h"
       13   #include "eml_int_forloop_overflow_check.h"
       14   #include "MLS_getDeform_mexutil.h"
       15   #include "MLS_getDeform_data.h"
       16
       17   /* Variable Definitions */
       18   static emlrtRTEInfo emlrtRTEI = { 27,  /* lineNo */
       19     5,                                   /* colNo */
       20     "MLS_getDeform",                     /* fName */
       21     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pName */
       22   };
       23
       24   static emlrtRSInfo emlrtRSI = { 18,    /* lineNo */
       25     "MLS_getDeform",                     /* fcnName */
       26     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pathName */
       27   };
       28
       29   static emlrtRSInfo b_emlrtRSI = { 20,  /* lineNo */
       30     "MLS_getDeform",                     /* fcnName */
       31     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pathName */
       32   };
       33
       34   static emlrtRSInfo c_emlrtRSI = { 22,  /* lineNo */
       35     "MLS_getDeform",                     /* fcnName */
       36     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pathName */
       37   };
       38
       39   static emlrtRSInfo d_emlrtRSI = { 27,  /* lineNo */
       40     "MLS_getDeform",                     /* fcnName */
       41     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pathName */
       42   };
       43
       44   static emlrtRSInfo e_emlrtRSI = { 97,  /* lineNo */
       45     "MLS_getDeform",                     /* fcnName */
       46     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pathName */
       47   };
       48
       49   static emlrtRSInfo f_emlrtRSI = { 114, /* lineNo */
       50     "MLS_getDeform",                     /* fcnName */
       51     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pathName */
       52   };
       53
       54   static emlrtRSInfo g_emlrtRSI = { 115, /* lineNo */
       55     "MLS_getDeform",                     /* fcnName */
       56     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pathName */
       57   };
       58
       59   static emlrtRSInfo h_emlrtRSI = { 20,  /* lineNo */
       60     "cat",                               /* fcnName */
       61     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\eml\\+coder\\+internal\\cat.m"/* pathName */
       62   };
       63
       64   static emlrtRSInfo i_emlrtRSI = { 100, /* lineNo */
       65     "cat",                               /* fcnName */
       66     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\eml\\+coder\\+internal\\cat.m"/* pathName */
       67   };
       68
       69   static emlrtRSInfo j_emlrtRSI = { 9,   /* lineNo */
       70     "sum",                               /* fcnName */
       71     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\lib\\matlab\\datafun\\sum.m"/* pathName */
       72   };
       73
       74   static emlrtRSInfo k_emlrtRSI = { 58,  /* lineNo */
       75     "sumprod",                           /* fcnName */
       76     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\lib\\matlab\\datafun\\private\\sumprod.m"/* pathName */
       77   };
       78
       79   static emlrtRSInfo l_emlrtRSI = { 106, /* lineNo */
       80     "combineVectorElements",             /* fcnName */
       81     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\lib\\matlab\\datafun\\private\\combineVectorElements.m"/* pathName */
       82   };
       83
       84   static emlrtRSInfo m_emlrtRSI = { 166, /* lineNo */
       85     "combineVectorElements",             /* fcnName */
       86     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\lib\\matlab\\datafun\\private\\combineVectorElements.m"/* pathName */
       87   };
       88
       89   static emlrtRSInfo n_emlrtRSI = { 21,  /* lineNo */
       90     "eml_int_forloop_overflow_check",    /* fcnName */
       91     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\lib\\matlab\\eml\\eml_int_forloop_overflow_check.m"/* pathName */
       92   };
       93
       94   static emlrtRSInfo o_emlrtRSI = { 18,  /* lineNo */
       95     "repmat",                            /* fcnName */
       96     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\lib\\matlab\\elmat\\repmat.m"/* pathName */
       97   };
       98
       99   static emlrtRSInfo p_emlrtRSI = { 117, /* lineNo */
      100     "repmat",                            /* fcnName */
      101     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\lib\\matlab\\elmat\\repmat.m"/* pathName */
      102   };
      103
      104   static emlrtRSInfo q_emlrtRSI = { 71,  /* lineNo */
      105     "MLS_getDeform",                     /* fcnName */
      106     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pathName */
      107   };
      108
      109   static emlrtRSInfo r_emlrtRSI = { 43,  /* lineNo */
      110     "MLS_getDeform",                     /* fcnName */
      111     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pathName */
      112   };
      113
      114   static emlrtRSInfo s_emlrtRSI = { 51,  /* lineNo */
      115     "MLS_getDeform",                     /* fcnName */
      116     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pathName */
      117   };
      118
      119   static emlrtRSInfo t_emlrtRSI = { 53,  /* lineNo */
      120     "MLS_getDeform",                     /* fcnName */
      121     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pathName */
      122   };
      123
      124   static emlrtRSInfo u_emlrtRSI = { 12,  /* lineNo */
      125     "sqrt",                              /* fcnName */
      126     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\lib\\matlab\\elfun\\sqrt.m"/* pathName */
      127   };
      128
      129   static emlrtRSInfo v_emlrtRSI = { 36,  /* lineNo */
      130     "fprintf",                           /* fcnName */
      131     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\lib\\matlab\\iofun\\fprintf.m"/* pathName */
      132   };
      133
      134   static emlrtMCInfo emlrtMCI = { 37,    /* lineNo */
      135     5,                                   /* colNo */
      136     "repmat",                            /* fName */
      137     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\lib\\matlab\\elmat\\repmat.m"/* pName */
      138   };
      139
      140   static emlrtMCInfo b_emlrtMCI = { 79,  /* lineNo */
      141     18,                                  /* colNo */
      142     "fprintf",                           /* fName */
      143     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\lib\\matlab\\iofun\\fprintf.m"/* pName */
      144   };
      145
      146   static emlrtRTEInfo b_emlrtRTEI = { 14,/* lineNo */
      147     1,                                   /* colNo */
      148     "MLS_getDeform",                     /* fName */
      149     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pName */
      150   };
      151
      152   static emlrtRTEInfo c_emlrtRTEI = { 1, /* lineNo */
      153     20,                                  /* colNo */
      154     "MLS_getDeform",                     /* fName */
      155     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pName */
      156   };
      157
      158   static emlrtRTEInfo d_emlrtRTEI = { 41,/* lineNo */
      159     5,                                   /* colNo */
      160     "MLS_getDeform",                     /* fName */
      161     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pName */
      162   };
      163
      164   static emlrtRTEInfo e_emlrtRTEI = { 112,/* lineNo */
      165     28,                                  /* colNo */
      166     "MLS_getDeform",                     /* fName */
      167     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pName */
      168   };
      169
      170   static emlrtRTEInfo f_emlrtRTEI = { 115,/* lineNo */
      171     17,                                  /* colNo */
      172     "MLS_getDeform",                     /* fName */
      173     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pName */
      174   };
      175
      176   static emlrtBCInfo emlrtBCI = { -1,    /* iFirst */
      177     -1,                                  /* iLast */
      178     37,                                  /* lineNo */
      179     11,                                  /* colNo */
      180     "V",                                 /* aName */
      181     "MLS_getDeform",                     /* fName */
      182     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      183     0                                    /* checkKind */
      184   };
      185
      186   static emlrtBCInfo b_emlrtBCI = { -1,  /* iFirst */
      187     -1,                                  /* iLast */
      188     39,                                  /* lineNo */
      189     21,                                  /* colNo */
      190     "pre.w_i",                           /* aName */
      191     "MLS_getDeform",                     /* fName */
      192     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      193     0                                    /* checkKind */
      194   };
      195
      196   static emlrtBCInfo c_emlrtBCI = { -1,  /* iFirst */
      197     -1,                                  /* iLast */
      198     40,                                  /* lineNo */
      199     27,                                  /* colNo */
      200     "pre.sum_w_i",                       /* aName */
      201     "MLS_getDeform",                     /* fName */
      202     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      203     0                                    /* checkKind */
      204   };
      205
      206   static emlrtBCInfo d_emlrtBCI = { -1,  /* iFirst */
      207     -1,                                  /* iLast */
      208     42,                                  /* lineNo */
      209     23,                                  /* colNo */
      210     "pre.p_ast",                         /* aName */
      211     "MLS_getDeform",                     /* fName */
      212     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      213     0                                    /* checkKind */
      214   };
      215
      216   static emlrtBCInfo e_emlrtBCI = { -1,  /* iFirst */
      217     -1,                                  /* iLast */
      218     49,                                  /* lineNo */
      219     33,                                  /* colNo */
      220     "q_hat_i",                           /* aName */
      221     "MLS_getDeform",                     /* fName */
      222     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      223     0                                    /* checkKind */
      224   };
      225
      226   static emlrtDCInfo emlrtDCI = { 56,    /* lineNo */
      227     7,                                   /* colNo */
      228     "MLS_getDeform",                     /* fName */
      229     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      230     1                                    /* checkKind */
      231   };
      232
      233   static emlrtBCInfo f_emlrtBCI = { -1,  /* iFirst */
      234     -1,                                  /* iLast */
      235     56,                                  /* lineNo */
      236     7,                                   /* colNo */
      237     "f",                                 /* aName */
      238     "MLS_getDeform",                     /* fName */
      239     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      240     0                                    /* checkKind */
      241   };
      242
      243   static emlrtDCInfo b_emlrtDCI = { 56,  /* lineNo */
      244     12,                                  /* colNo */
      245     "MLS_getDeform",                     /* fName */
      246     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      247     1                                    /* checkKind */
      248   };
      249
      250   static emlrtBCInfo g_emlrtBCI = { -1,  /* iFirst */
      251     -1,                                  /* iLast */
      252     56,                                  /* lineNo */
      253     12,                                  /* colNo */
      254     "f",                                 /* aName */
      255     "MLS_getDeform",                     /* fName */
      256     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      257     0                                    /* checkKind */
      258   };
      259
      260   static emlrtBCInfo h_emlrtBCI = { -1,  /* iFirst */
      261     -1,                                  /* iLast */
      262     65,                                  /* lineNo */
      263     11,                                  /* colNo */
      264     "V",                                 /* aName */
      265     "MLS_getDeform",                     /* fName */
      266     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      267     0                                    /* checkKind */
      268   };
      269
      270   static emlrtBCInfo i_emlrtBCI = { -1,  /* iFirst */
      271     -1,                                  /* iLast */
      272     67,                                  /* lineNo */
      273     21,                                  /* colNo */
      274     "pre.w_i",                           /* aName */
      275     "MLS_getDeform",                     /* fName */
      276     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      277     0                                    /* checkKind */
      278   };
      279
      280   static emlrtBCInfo j_emlrtBCI = { -1,  /* iFirst */
      281     -1,                                  /* iLast */
      282     68,                                  /* lineNo */
      283     27,                                  /* colNo */
      284     "pre.sum_w_i",                       /* aName */
      285     "MLS_getDeform",                     /* fName */
      286     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      287     0                                    /* checkKind */
      288   };
      289
      290   static emlrtBCInfo k_emlrtBCI = { -1,  /* iFirst */
      291     -1,                                  /* iLast */
      292     76,                                  /* lineNo */
      293     33,                                  /* colNo */
      294     "q_hat_i",                           /* aName */
      295     "MLS_getDeform",                     /* fName */
      296     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      297     0                                    /* checkKind */
      298   };
      299
      300   static emlrtDCInfo c_emlrtDCI = { 82,  /* lineNo */
      301     7,                                   /* colNo */
      302     "MLS_getDeform",                     /* fName */
      303     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      304     1                                    /* checkKind */
      305   };
      306
      307   static emlrtBCInfo l_emlrtBCI = { -1,  /* iFirst */
      308     -1,                                  /* iLast */
      309     82,                                  /* lineNo */
      310     7,                                   /* colNo */
      311     "f",                                 /* aName */
      312     "MLS_getDeform",                     /* fName */
      313     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      314     0                                    /* checkKind */
      315   };
      316
      317   static emlrtDCInfo d_emlrtDCI = { 82,  /* lineNo */
      318     12,                                  /* colNo */
      319     "MLS_getDeform",                     /* fName */
      320     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      321     1                                    /* checkKind */
      322   };
      323
      324   static emlrtBCInfo m_emlrtBCI = { -1,  /* iFirst */
      325     -1,                                  /* iLast */
      326     82,                                  /* lineNo */
      327     12,                                  /* colNo */
      328     "f",                                 /* aName */
      329     "MLS_getDeform",                     /* fName */
      330     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      331     0                                    /* checkKind */
      332   };
      333
      334   static emlrtBCInfo n_emlrtBCI = { -1,  /* iFirst */
      335     -1,                                  /* iLast */
      336     91,                                  /* lineNo */
      337     11,                                  /* colNo */
      338     "V",                                 /* aName */
      339     "MLS_getDeform",                     /* fName */
      340     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      341     0                                    /* checkKind */
      342   };
      343
      344   static emlrtBCInfo o_emlrtBCI = { -1,  /* iFirst */
      345     -1,                                  /* iLast */
      346     93,                                  /* lineNo */
      347     21,                                  /* colNo */
      348     "pre.w_i",                           /* aName */
      349     "MLS_getDeform",                     /* fName */
      350     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      351     0                                    /* checkKind */
      352   };
      353
      354   static emlrtBCInfo p_emlrtBCI = { -1,  /* iFirst */
      355     -1,                                  /* iLast */
      356     94,                                  /* lineNo */
      357     27,                                  /* colNo */
      358     "pre.sum_w_i",                       /* aName */
      359     "MLS_getDeform",                     /* fName */
      360     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      361     0                                    /* checkKind */
      362   };
      363
      364   static emlrtBCInfo q_emlrtBCI = { -1,  /* iFirst */
      365     -1,                                  /* iLast */
      366     95,                                  /* lineNo */
      367     23,                                  /* colNo */
      368     "pre.Affine",                        /* aName */
      369     "MLS_getDeform",                     /* fName */
      370     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      371     0                                    /* checkKind */
      372   };
      373
      374   static emlrtBCInfo r_emlrtBCI = { -1,  /* iFirst */
      375     -1,                                  /* iLast */
      376     102,                                 /* lineNo */
      377     28,                                  /* colNo */
      378     "Aj",                                /* aName */
      379     "MLS_getDeform",                     /* fName */
      380     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      381     0                                    /* checkKind */
      382   };
      383
      384   static emlrtBCInfo s_emlrtBCI = { -1,  /* iFirst */
      385     -1,                                  /* iLast */
      386     102,                                 /* lineNo */
      387     39,                                  /* colNo */
      388     "q_hat_i",                           /* aName */
      389     "MLS_getDeform",                     /* fName */
      390     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      391     0                                    /* checkKind */
      392   };
      393
      394   static emlrtDCInfo e_emlrtDCI = { 107, /* lineNo */
      395     7,                                   /* colNo */
      396     "MLS_getDeform",                     /* fName */
      397     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      398     1                                    /* checkKind */
      399   };
      400
      401   static emlrtBCInfo t_emlrtBCI = { -1,  /* iFirst */
      402     -1,                                  /* iLast */
      403     107,                                 /* lineNo */
      404     7,                                   /* colNo */
      405     "f",                                 /* aName */
      406     "MLS_getDeform",                     /* fName */
      407     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      408     0                                    /* checkKind */
      409   };
      410
      411   static emlrtDCInfo f_emlrtDCI = { 107, /* lineNo */
      412     12,                                  /* colNo */
      413     "MLS_getDeform",                     /* fName */
      414     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      415     1                                    /* checkKind */
      416   };
      417
      418   static emlrtBCInfo u_emlrtBCI = { -1,  /* iFirst */
      419     -1,                                  /* iLast */
      420     107,                                 /* lineNo */
      421     12,                                  /* colNo */
      422     "f",                                 /* aName */
      423     "MLS_getDeform",                     /* fName */
      424     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      425     0                                    /* checkKind */
      426   };
      427
      428   static emlrtDCInfo g_emlrtDCI = { 33,  /* lineNo */
      429     11,                                  /* colNo */
      430     "MLS_getDeform",                     /* fName */
      431     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      432     4                                    /* checkKind */
      433   };
      434
      435   static emlrtDCInfo h_emlrtDCI = { 33,  /* lineNo */
      436     11,                                  /* colNo */
      437     "MLS_getDeform",                     /* fName */
      438     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      439     1                                    /* checkKind */
      440   };
      441
      442   static emlrtBCInfo v_emlrtBCI = { -1,  /* iFirst */
      443     -1,                                  /* iLast */
      444     41,                                  /* lineNo */
      445     21,                                  /* colNo */
      446     "pre.Rigid",                         /* aName */
      447     "MLS_getDeform",                     /* fName */
      448     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      449     0                                    /* checkKind */
      450   };
      451
      452   static emlrtBCInfo w_emlrtBCI = { -1,  /* iFirst */
      453     -1,                                  /* iLast */
      454     49,                                  /* lineNo */
      455     41,                                  /* colNo */
      456     "Ai",                                /* aName */
      457     "MLS_getDeform",                     /* fName */
      458     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      459     0                                    /* checkKind */
      460   };
      461
      462   static emlrtDCInfo i_emlrtDCI = { 61,  /* lineNo */
      463     11,                                  /* colNo */
      464     "MLS_getDeform",                     /* fName */
      465     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      466     4                                    /* checkKind */
      467   };
      468
      469   static emlrtDCInfo j_emlrtDCI = { 61,  /* lineNo */
      470     11,                                  /* colNo */
      471     "MLS_getDeform",                     /* fName */
      472     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      473     1                                    /* checkKind */
      474   };
      475
      476   static emlrtBCInfo x_emlrtBCI = { -1,  /* iFirst */
      477     -1,                                  /* iLast */
      478     69,                                  /* lineNo */
      479     29,                                  /* colNo */
      480     "pre.Similarity",                    /* aName */
      481     "MLS_getDeform",                     /* fName */
      482     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      483     0                                    /* checkKind */
      484   };
      485
      486   static emlrtBCInfo y_emlrtBCI = { -1,  /* iFirst */
      487     -1,                                  /* iLast */
      488     76,                                  /* lineNo */
      489     44,                                  /* colNo */
      490     "Ai_mu",                             /* aName */
      491     "MLS_getDeform",                     /* fName */
      492     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      493     0                                    /* checkKind */
      494   };
      495
      496   static emlrtDCInfo k_emlrtDCI = { 88,  /* lineNo */
      497     11,                                  /* colNo */
      498     "MLS_getDeform",                     /* fName */
      499     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      500     4                                    /* checkKind */
      501   };
      502
      503   static emlrtDCInfo l_emlrtDCI = { 88,  /* lineNo */
      504     11,                                  /* colNo */
      505     "MLS_getDeform",                     /* fName */
      506     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m",/* pName */
      507     1                                    /* checkKind */
      508   };
      509
      510   static emlrtECInfo emlrtECI = { 2,     /* nDims */
      511     114,                                 /* lineNo */
      512     13,                                  /* colNo */
      513     "MLS_getDeform",                     /* fName */
      514     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pName */
      515   };
      516
      517   static emlrtECInfo b_emlrtECI = { 2,   /* nDims */
      518     115,                                 /* lineNo */
      519     11,                                  /* colNo */
      520     "MLS_getDeform",                     /* fName */
      521     "C:\\Users\\tomas\\Documents\\BP Matlab\\gui\\MLS_getDeform.m"/* pName */
      522   };
      523
      524   static emlrtRSInfo w_emlrtRSI = { 37,  /* lineNo */
      525     "repmat",                            /* fcnName */
      526     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\lib\\matlab\\elmat\\repmat.m"/* pathName */
      527   };
      528
      529   static emlrtRSInfo x_emlrtRSI = { 79,  /* lineNo */
      530     "fprintf",                           /* fcnName */
      531     "C:\\Program Files\\MATLAB\\R2017b\\toolbox\\eml\\lib\\matlab\\iofun\\fprintf.m"/* pathName */
      532   };
      533
      534   /* Function Declarations */
      535   static void MLS_q(const emlrtStack *sp, const emxArray_real_T *w_i, real_T
      536                     sum_w_i, const emxArray_real_T *q_i, real_T q_ast[2],
      537                     emxArray_real_T *q_hat_i);
      538   static void b_error(const emlrtStack *sp, const mxArray *b, emlrtMCInfo
      539                       *location);
      540   static const mxArray *feval(const emlrtStack *sp, const mxArray *b, const
      541     mxArray *c, const mxArray *d, emlrtMCInfo *location);
      542
      543   /* Function Definitions */
      544   static void MLS_q(const emlrtStack *sp, const emxArray_real_T *w_i, real_T
      545                     sum_w_i, const emxArray_real_T *q_i, real_T q_ast[2],
      546                     emxArray_real_T *q_hat_i)
      547   {
      548     emxArray_real_T *x;
      549     int32_T vlen;
      550     int32_T outsize_idx_0;
      551     int32_T b_x[2];
      552     int32_T b_q_i[2];
      553     boolean_T overflow;
      554     int32_T xpageoffset;
      555     int32_T k;
      556     const mxArray *y;
      557     const mxArray *m1;
      558     static const int32_T iv2[2] = { 1, 15 };
      559
      560     static const char_T u[15] = { 'M', 'A', 'T', 'L', 'A', 'B', ':', 'p', 'm', 'a',
      561       'x', 's', 'i', 'z', 'e' };
      562
      563     emlrtStack st;
      564     emlrtStack b_st;
      565     emlrtStack c_st;
      566     emlrtStack d_st;
      567     emlrtStack e_st;
      568     emlrtStack f_st;
      569     emlrtStack g_st;
      570     st.prev = sp;
      571     st.tls = sp->tls;
      572     b_st.prev = &st;
      573     b_st.tls = st.tls;
      574     c_st.prev = &b_st;
      575     c_st.tls = b_st.tls;
      576     d_st.prev = &c_st;
      577     d_st.tls = c_st.tls;
      578     e_st.prev = &d_st;
      579     e_st.tls = d_st.tls;
      580     f_st.prev = &e_st;
      581     f_st.tls = e_st.tls;
      582     g_st.prev = &f_st;
      583     g_st.tls = f_st.tls;
      584     emlrtHeapReferenceStackEnterFcnR2012b(sp);
      585     emxInit_real_T1(sp, &x, 2, &e_emlrtRTEI, true);
      586
      587     /*  parameters for deformation function, q = deformed positions of the control points p */
      588     /*  [w_i,w_i] to make matlab coder happy */
      589     st.site = &f_emlrtRSI;
      590     b_st.site = &h_emlrtRSI;
      591     c_st.site = &i_emlrtRSI;
      592     vlen = x->size[0] * x->size[1];
      593     x->size[0] = w_i->size[0];
      594     x->size[1] = 2;
      595     emxEnsureCapacity_real_T(&b_st, x, vlen, &e_emlrtRTEI);
      596     outsize_idx_0 = w_i->size[0];
      597     for (vlen = 0; vlen < outsize_idx_0; vlen++) {
      598       x->data[vlen] = w_i->data[vlen];
      599     }
      600
      601     outsize_idx_0 = w_i->size[0];
      602     for (vlen = 0; vlen < outsize_idx_0; vlen++) {
      603       x->data[vlen + x->size[0]] = w_i->data[vlen];
      604     }
      605
      606     for (vlen = 0; vlen < 2; vlen++) {
      607       b_x[vlen] = x->size[vlen];
      608     }
      609
      610     for (vlen = 0; vlen < 2; vlen++) {
      611       b_q_i[vlen] = q_i->size[vlen];
      612     }
      613
      614     if ((b_x[0] != b_q_i[0]) || (b_x[1] != b_q_i[1])) {
      615       emlrtSizeEqCheckNDR2012b(&b_x[0], &b_q_i[0], &emlrtECI, sp);
      616     }
      617
      618     st.site = &f_emlrtRSI;
      619     vlen = x->size[0] * x->size[1];
      620     x->size[1] = 2;
      621     emxEnsureCapacity_real_T(&st, x, vlen, &e_emlrtRTEI);
      622     outsize_idx_0 = x->size[0];
      623     vlen = x->size[1];
      624     outsize_idx_0 *= vlen;
      625     for (vlen = 0; vlen < outsize_idx_0; vlen++) {
      626       x->data[vlen] *= q_i->data[vlen];
      627     }
      628
      629     b_st.site = &j_emlrtRSI;
      630     c_st.site = &k_emlrtRSI;
      631     vlen = x->size[0];
      632     if (x->size[0] == 0) {
      633       for (vlen = 0; vlen < 2; vlen++) {
      634         q_ast[vlen] = 0.0;
      635       }
      636     } else {
      637       d_st.site = &l_emlrtRSI;
      638       overflow = ((!(2 > vlen)) && (vlen > 2147483646));
      639       for (outsize_idx_0 = 0; outsize_idx_0 < 2; outsize_idx_0++) {
      640         xpageoffset = outsize_idx_0 * x->size[0];
      641         q_ast[outsize_idx_0] = x->data[xpageoffset];
      642         e_st.site = &m_emlrtRSI;
      643         if (overflow) {
      644           f_st.site = &n_emlrtRSI;
      645           g_st.site = &n_emlrtRSI;
      646           check_forloop_overflow_error(&g_st);
      647         }
      648
      649         for (k = 2; k <= vlen; k++) {
      650           q_ast[outsize_idx_0] += x->data[(xpageoffset + k) - 1];
      651         }
      652       }
      653     }
      654
      655     emxFree_real_T(&x);
      656     for (vlen = 0; vlen < 2; vlen++) {
      657       q_ast[vlen] /= sum_w_i;
      658     }
      659
      660     st.site = &g_emlrtRSI;
      661     b_st.site = &o_emlrtRSI;
      662     outsize_idx_0 = q_i->size[0];
      663     if (outsize_idx_0 != q_i->size[0]) {
      664       y = NULL;
      665       m1 = emlrtCreateCharArray(2, iv2);
      666       emlrtInitCharArrayR2013a(&st, 15, m1, &u[0]);
      667       emlrtAssign(&y, m1);
      668       b_st.site = &w_emlrtRSI;
      669       b_error(&b_st, y, &emlrtMCI);
      670     }
      671
      672     vlen = q_hat_i->size[0] * q_hat_i->size[1];
      673     q_hat_i->size[0] = outsize_idx_0;
      674     q_hat_i->size[1] = 2;
      675     emxEnsureCapacity_real_T(&st, q_hat_i, vlen, &f_emlrtRTEI);
      676     if (!(outsize_idx_0 == 0)) {
      677       outsize_idx_0 = q_i->size[0];
      678       overflow = ((!(1 > outsize_idx_0)) && (outsize_idx_0 > 2147483646));
      679       for (vlen = 0; vlen < 2; vlen++) {
      680         xpageoffset = vlen * outsize_idx_0;
      681         b_st.site = &p_emlrtRSI;
      682         if (overflow) {
      683           c_st.site = &n_emlrtRSI;
      684           d_st.site = &n_emlrtRSI;
      685           check_forloop_overflow_error(&d_st);
      686         }
      687
      688         for (k = 1; k <= outsize_idx_0; k++) {
      689           q_hat_i->data[(xpageoffset + k) - 1] = q_ast[vlen];
      690         }
      691       }
      692     }
      693
      694     for (vlen = 0; vlen < 2; vlen++) {
      695       b_q_i[vlen] = q_i->size[vlen];
      696     }
      697
      698     for (vlen = 0; vlen < 2; vlen++) {
      699       b_x[vlen] = q_hat_i->size[vlen];
      700     }
      701
      702     if ((b_q_i[0] != b_x[0]) || (b_q_i[1] != b_x[1])) {
      703       emlrtSizeEqCheckNDR2012b(&b_q_i[0], &b_x[0], &b_emlrtECI, sp);
      704     }
      705
      706     vlen = q_hat_i->size[0] * q_hat_i->size[1];
      707     q_hat_i->size[0] = q_i->size[0];
      708     q_hat_i->size[1] = 2;
      709     emxEnsureCapacity_real_T(sp, q_hat_i, vlen, &e_emlrtRTEI);
      710     outsize_idx_0 = q_i->size[0] * q_i->size[1];
      711     for (vlen = 0; vlen < outsize_idx_0; vlen++) {
      712       q_hat_i->data[vlen] = q_i->data[vlen] - q_hat_i->data[vlen];
      713     }
      714
      715     emlrtHeapReferenceStackLeaveFcnR2012b(sp);
      716   }
      717
      718   static void b_error(const emlrtStack *sp, const mxArray *b, emlrtMCInfo
      719                       *location)
      720   {
      721     const mxArray *pArray;
      722     pArray = b;
      723     emlrtCallMATLABR2012b(sp, 0, NULL, 1, &pArray, "error", true, location);
      724   }
      725
      726   static const mxArray *feval(const emlrtStack *sp, const mxArray *b, const
      727     mxArray *c, const mxArray *d, emlrtMCInfo *location)
      728   {
      729     const mxArray *pArrays[3];
      730     const mxArray *m5;
      731     pArrays[0] = b;
      732     pArrays[1] = c;
      733     pArrays[2] = d;
      734     return emlrtCallMATLABR2012b(sp, 1, &m5, 3, pArrays, "feval", true, location);
      735   }
      736
      737   void MLS_getDeform(const emlrtStack *sp, const emxArray_real_T *control_points,
      738                      const emxArray_real_T *c_deformed_position_of_control_, const
      739                      emxArray_real_T *points_of_evaluation, real_T alpha, const
      740                      emxArray_char_T *type, const struct0_T *precomputed, const
      741                      real_T size_of_img[2], emxArray_real_T *f, struct0_T *pre)
      742   {
      743     int32_T i0;
      744     boolean_T b_bool;
      745     int32_T kstr;
      746     emxArray_real_T *b_f;
      747     emxArray_real_T *q_hat_i;
      748     int32_T exitg1;
      749     emxArray_real_T *b_precomputed;
      750     static const char_T cv0[6] = { 'A', 'f', 'f', 'i', 'n', 'e' };
      751
      752     emxArray_real_T *Ai;
      753     real_T dv0[3];
      754     static const char_T cv1[10] = { 'S', 'i', 'm', 'i', 'l', 'a', 'r', 'i', 't',
      755       'y' };
      756
      757     static const char_T cv2[5] = { 'R', 'i', 'g', 'i', 'd' };
      758
      759     int32_T i;
      760     const mxArray *y;
      761     const mxArray *m0;
      762     static const int32_T iv0[2] = { 1, 7 };
      763
      764     static const char_T u[7] = { 'f', 'p', 'r', 'i', 'n', 't', 'f' };
      765
      766     int32_T b_points_of_evaluation;
      767     const mxArray *b_y;
      768     const mxArray *c_y;
      769     static const int32_T iv1[2] = { 1, 19 };
      770
      771     static const char_T formatSpec[19] = { 'P', 'a', 's', 's', 'e', 'd', 'W', 'r',
      772       'o', 'n', 'g', 'V', 'a', 'r', 'i', 'a', 'b', 'l', 'e' };
      773
      774     real_T nbytes;
      775     int32_T c_precomputed;
      776     real_T q_ast[2];
      777     real_T f_vec[2];
      778     int32_T i1;
      779     real_T x;
      780     real_T z1[2];
      781     real_T b[4];
      782     real_T len_f_vec;
      783     real_T a[2];
      784     emlrtStack st;
      785     emlrtStack b_st;
      786     emlrtStack c_st;
      787     emlrtStack d_st;
      788     (void)control_points;
      789     (void)alpha;
      790     st.prev = sp;
      791     st.tls = sp->tls;
      792     b_st.prev = &st;
      793     b_st.tls = st.tls;
      794     c_st.prev = &b_st;
      795     c_st.tls = b_st.tls;
      796     d_st.prev = &c_st;
      797     d_st.tls = c_st.tls;
      798     emlrtHeapReferenceStackEnterFcnR2012b(sp);
      799
      800     /* UNTITLED2 Summary of this function goes here */
      801     /*    type: */
      802     /*         Affine = translation, rotation, nonuniform scaling and shear */
      803     /*         Similarity = translation, rotation and uniform scaling */
      804     /*         Rigid = translation, rotation */
      805     /*    alpha: for weigth function (precompute) */
      806     /*    p_i,q_i,v_i are row vectros eg. [x,y] so p,q,v = [x1,y1;x2,y2;x3,y3;...] */
      807     /*    size_of_img = [height,width] */
      808     emxCopyStruct_struct0_T(sp, pre, precomputed, &b_emlrtRTEI);
      809     i0 = f->size[0] * f->size[1] * f->size[2];
      810     f->size[0] = 0;
      811     f->size[1] = 0;
      812     f->size[2] = 1;
      813     emxEnsureCapacity_real_T2(sp, f, i0, &c_emlrtRTEI);
      814
      815     /*  switch the MLS deformation type */
      816     b_bool = false;
      817     if (type->size[1] == 6) {
      818       kstr = 0;
      819       do {
      820         exitg1 = 0;
      821         if (kstr + 1 < 7) {
      822           if (type->data[kstr] != cv0[kstr]) {
      823             exitg1 = 1;
      824           } else {
      825             kstr++;
      826           }
      827         } else {
      828           b_bool = true;
      829           exitg1 = 1;
      830         }
      831       } while (exitg1 == 0);
      832     }
      833
      834     emxInit_real_T(sp, &b_f, 3, &c_emlrtRTEI, true);
      835     emxInit_real_T1(sp, &q_hat_i, 2, &c_emlrtRTEI, true);
      836     emxInit_real_T2(sp, &b_precomputed, 1, &c_emlrtRTEI, true);
      837     if (b_bool) {
      838       st.site = &emlrtRSI;
      839
      840       /*  %% affine deformation */
      841       for (i0 = 0; i0 < 2; i0++) {
      842         if (!(size_of_img[i0] >= 0.0)) {
      843           emlrtNonNegativeCheckR2012b(size_of_img[i0], &k_emlrtDCI, &st);
      844         }
      845
      846         if (size_of_img[i0] != (int32_T)muDoubleScalarFloor(size_of_img[i0])) {
      847           emlrtIntegerCheckR2012b(size_of_img[i0], &l_emlrtDCI, &st);
      848         }
      849
      850         dv0[i0] = size_of_img[i0];
      851       }
      852
      853       i0 = b_f->size[0] * b_f->size[1] * b_f->size[2];
      854       b_f->size[0] = (int32_T)dv0[0];
      855       b_f->size[1] = (int32_T)dv0[1];
      856       b_f->size[2] = 2;
      857       emxEnsureCapacity_real_T2(&st, b_f, i0, &c_emlrtRTEI);
      858       kstr = ((int32_T)dv0[0] * (int32_T)dv0[1]) << 1;
      859       for (i0 = 0; i0 < kstr; i0++) {
      860         b_f->data[i0] = 0.0;
      861       }
      862
      863       /*  loop through evaluation points v */
      864       i = 0;
      865       while (i <= points_of_evaluation->size[0] - 1) {
      866         i0 = points_of_evaluation->size[0];
      867         b_points_of_evaluation = i + 1;
      868         if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0))) {
      869           emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0, &n_emlrtBCI,
      870             &st);
      871         }
      872
      873         /*  get param for given evaluation point v */
      874         i0 = precomputed->w_i->size[1];
      875         b_points_of_evaluation = i + 1;
      876         if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0))) {
      877           emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0, &o_emlrtBCI,
      878             &st);
      879         }
      880
      881         i0 = precomputed->sum_w_i->size[0];
      882         b_points_of_evaluation = i + 1;
      883         if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0))) {
      884           emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0, &p_emlrtBCI,
      885             &st);
      886         }
      887
      888         i0 = precomputed->Affine->size[1];
      889         b_points_of_evaluation = i + 1;
      890         if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0))) {
      891           emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0, &q_emlrtBCI,
      892             &st);
      893         }
      894
      895         kstr = precomputed->w_i->size[0];
      896         i0 = b_precomputed->size[0];
      897         b_precomputed->size[0] = kstr;
      898         emxEnsureCapacity_real_T1(&st, b_precomputed, i0, &c_emlrtRTEI);
      899         for (i0 = 0; i0 < kstr; i0++) {
      900           b_precomputed->data[i0] = precomputed->w_i->data[i0 + precomputed->
      901             w_i->size[0] * i];
      902         }
      903
      904         b_st.site = &e_emlrtRSI;
      905         MLS_q(&b_st, b_precomputed, precomputed->sum_w_i->data[i],
      906               c_deformed_position_of_control_, q_ast, q_hat_i);
      907
      908         /*  loop through control points */
      909         for (i0 = 0; i0 < 2; i0++) {
      910           f_vec[i0] = 0.0;
      911         }
      912
      913         kstr = 0;
      914         while (kstr <= c_deformed_position_of_control_->size[0] - 1) {
      915           i0 = precomputed->Affine->size[0];
      916           b_points_of_evaluation = 1 + kstr;
      917           if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0)))
      918           {
      919             emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0,
      920               &r_emlrtBCI, &st);
      921           }
      922
      923           nbytes = precomputed->Affine->data[kstr + precomputed->Affine->size[0] *
      924             i];
      925           i0 = q_hat_i->size[0];
      926           b_points_of_evaluation = kstr + 1;
      927           if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0)))
      928           {
      929             emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0,
      930               &s_emlrtBCI, &st);
      931           }
      932
      933           for (i0 = 0; i0 < 2; i0++) {
      934             x = f_vec[i0] + nbytes * q_hat_i->data[kstr + q_hat_i->size[0] * i0];
      935             f_vec[i0] = x;
      936           }
      937
      938           kstr++;
      939           if (*emlrtBreakCheckR2012bFlagVar != 0) {
      940             emlrtBreakCheckR2012b(&st);
      941           }
      942         }
      943
      944         for (i0 = 0; i0 < 2; i0++) {
      945           f_vec[i0] += q_ast[i0];
      946         }
      947
      948         /*  save deformation for given control point */
      949         /* if isequal(v,p) */
      950         c_precomputed = b_f->size[0];
      951         kstr = b_f->size[1];
      952         nbytes = points_of_evaluation->data[i + points_of_evaluation->size[0]];
      953         if (nbytes != (int32_T)muDoubleScalarFloor(nbytes)) {
      954           emlrtIntegerCheckR2012b(nbytes, &f_emlrtDCI, &st);
      955         }
      956
      957         b_points_of_evaluation = (int32_T)nbytes;
      958         if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= kstr)))
      959         {
      960           emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, kstr,
      961             &u_emlrtBCI, &st);
      962         }
      963
      964         nbytes = points_of_evaluation->data[i];
      965         if (nbytes != (int32_T)muDoubleScalarFloor(nbytes)) {
      966           emlrtIntegerCheckR2012b(nbytes, &e_emlrtDCI, &st);
      967         }
      968
      969         kstr = (int32_T)nbytes;
      970         if (!((kstr >= 1) && (kstr <= c_precomputed))) {
      971           emlrtDynamicBoundsCheckR2012b(kstr, 1, c_precomputed, &t_emlrtBCI, &st);
      972         }
      973
      974         for (i0 = 0; i0 < 2; i0++) {
      975           b_f->data[((kstr + b_f->size[0] * (b_points_of_evaluation - 1)) +
      976                      b_f->size[0] * b_f->size[1] * i0) - 1] = f_vec[i0];
      977         }
      978
      979         i++;
      980         if (*emlrtBreakCheckR2012bFlagVar != 0) {
      981           emlrtBreakCheckR2012b(&st);
      982         }
      983       }
      984
      985       i0 = f->size[0] * f->size[1] * f->size[2];
      986       f->size[0] = b_f->size[0];
      987       f->size[1] = b_f->size[1];
      988       f->size[2] = 2;
      989       emxEnsureCapacity_real_T2(sp, f, i0, &c_emlrtRTEI);
      990       kstr = b_f->size[0] * b_f->size[1] * b_f->size[2];
      991       for (i0 = 0; i0 < kstr; i0++) {
      992         f->data[i0] = b_f->data[i0];
      993       }
      994     } else {
      995       b_bool = false;
      996       if (type->size[1] == 10) {
      997         kstr = 0;
      998         do {
      999           exitg1 = 0;
     1000           if (kstr + 1 < 11) {
     1001             if (type->data[kstr] != cv1[kstr]) {
     1002               exitg1 = 1;
     1003             } else {
     1004               kstr++;
     1005             }
     1006           } else {
     1007             b_bool = true;
     1008             exitg1 = 1;
     1009           }
     1010         } while (exitg1 == 0);
     1011       }
     1012
     1013       emxInit_real_T1(sp, &Ai, 2, &d_emlrtRTEI, true);
     1014       if (b_bool) {
     1015         st.site = &b_emlrtRSI;
     1016
     1017         /*  similatrity defromation */
     1018         for (i0 = 0; i0 < 2; i0++) {
     1019           if (!(size_of_img[i0] >= 0.0)) {
     1020             emlrtNonNegativeCheckR2012b(size_of_img[i0], &i_emlrtDCI, &st);
     1021           }
     1022
     1023           if (size_of_img[i0] != (int32_T)muDoubleScalarFloor(size_of_img[i0])) {
     1024             emlrtIntegerCheckR2012b(size_of_img[i0], &j_emlrtDCI, &st);
     1025           }
     1026
     1027           dv0[i0] = size_of_img[i0];
     1028         }
     1029
     1030         i0 = b_f->size[0] * b_f->size[1] * b_f->size[2];
     1031         b_f->size[0] = (int32_T)dv0[0];
     1032         b_f->size[1] = (int32_T)dv0[1];
     1033         b_f->size[2] = 2;
     1034         emxEnsureCapacity_real_T2(&st, b_f, i0, &c_emlrtRTEI);
     1035         kstr = ((int32_T)dv0[0] * (int32_T)dv0[1]) << 1;
     1036         for (i0 = 0; i0 < kstr; i0++) {
     1037           b_f->data[i0] = 0.0;
     1038         }
     1039
     1040         /*  loop through evaluation points v */
     1041         i = 0;
     1042         while (i <= points_of_evaluation->size[0] - 1) {
     1043           i0 = points_of_evaluation->size[0];
     1044           b_points_of_evaluation = i + 1;
     1045           if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0)))
     1046           {
     1047             emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0,
     1048               &h_emlrtBCI, &st);
     1049           }
     1050
     1051           /*  get param for given evaluation point v */
     1052           i0 = precomputed->w_i->size[1];
     1053           b_points_of_evaluation = i + 1;
     1054           if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0)))
     1055           {
     1056             emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0,
     1057               &i_emlrtBCI, &st);
     1058           }
     1059
     1060           i0 = precomputed->sum_w_i->size[0];
     1061           b_points_of_evaluation = i + 1;
     1062           if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0)))
     1063           {
     1064             emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0,
     1065               &j_emlrtBCI, &st);
     1066           }
     1067
     1068           kstr = precomputed->Similarity->size[0];
     1069           nbytes = 2.0 * (1.0 + (real_T)i);
     1070           c_precomputed = precomputed->Similarity->size[1];
     1071           i0 = Ai->size[0] * Ai->size[1];
     1072           Ai->size[0] = kstr;
     1073           Ai->size[1] = 2;
     1074           emxEnsureCapacity_real_T(&st, Ai, i0, &c_emlrtRTEI);
     1075           for (i0 = 0; i0 < 2; i0++) {
     1076             for (b_points_of_evaluation = 0; b_points_of_evaluation < kstr;
     1077                  b_points_of_evaluation++) {
     1078               i1 = (int32_T)(nbytes + (-1.0 + (real_T)i0));
     1079               if (!((i1 >= 1) && (i1 <= c_precomputed))) {
     1080                 emlrtDynamicBoundsCheckR2012b(i1, 1, c_precomputed, &x_emlrtBCI,
     1081                   &st);
     1082               }
     1083
     1084               Ai->data[b_points_of_evaluation + Ai->size[0] * i0] =
     1085                 precomputed->Similarity->data[b_points_of_evaluation +
     1086                 precomputed->Similarity->size[0] * (i1 - 1)];
     1087             }
     1088           }
     1089
     1090           kstr = precomputed->w_i->size[0];
     1091           i0 = b_precomputed->size[0];
     1092           b_precomputed->size[0] = kstr;
     1093           emxEnsureCapacity_real_T1(&st, b_precomputed, i0, &c_emlrtRTEI);
     1094           for (i0 = 0; i0 < kstr; i0++) {
     1095             b_precomputed->data[i0] = precomputed->w_i->data[i0 + precomputed->
     1096               w_i->size[0] * i];
     1097           }
     1098
     1099           b_st.site = &q_emlrtRSI;
     1100           MLS_q(&b_st, b_precomputed, precomputed->sum_w_i->data[i],
     1101                 c_deformed_position_of_control_, q_ast, q_hat_i);
     1102
     1103           /*  loop through control points */
     1104           for (i0 = 0; i0 < 2; i0++) {
     1105             f_vec[i0] = 0.0;
     1106           }
     1107
     1108           kstr = 0;
     1109           while (kstr <= c_deformed_position_of_control_->size[0] - 1) {
     1110             i0 = q_hat_i->size[0];
     1111             b_points_of_evaluation = kstr + 1;
     1112             if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0)))
     1113             {
     1114               emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0,
     1115                 &k_emlrtBCI, &st);
     1116             }
     1117
     1118             i0 = precomputed->Similarity->size[0];
     1119             nbytes = 2.0 * (1.0 + (real_T)kstr);
     1120             for (b_points_of_evaluation = 0; b_points_of_evaluation < 2;
     1121                  b_points_of_evaluation++) {
     1122               for (i1 = 0; i1 < 2; i1++) {
     1123                 c_precomputed = (int32_T)(nbytes + (-1.0 + (real_T)i1));
     1124                 if (!((c_precomputed >= 1) && (c_precomputed <= i0))) {
     1125                   emlrtDynamicBoundsCheckR2012b(c_precomputed, 1, i0, &y_emlrtBCI,
     1126                     &st);
     1127                 }
     1128
     1129                 b[i1 + (b_points_of_evaluation << 1)] = Ai->data[(c_precomputed +
     1130                   Ai->size[0] * b_points_of_evaluation) - 1];
     1131               }
     1132             }
     1133
     1134             for (i0 = 0; i0 < 2; i0++) {
     1135               nbytes = 0.0;
     1136               for (b_points_of_evaluation = 0; b_points_of_evaluation < 2;
     1137                    b_points_of_evaluation++) {
     1138                 nbytes += q_hat_i->data[kstr + q_hat_i->size[0] *
     1139                   b_points_of_evaluation] * b[b_points_of_evaluation + (i0 << 1)];
     1140               }
     1141
     1142               f_vec[i0] += nbytes;
     1143             }
     1144
     1145             kstr++;
     1146             if (*emlrtBreakCheckR2012bFlagVar != 0) {
     1147               emlrtBreakCheckR2012b(&st);
     1148             }
     1149           }
     1150
     1151           for (i0 = 0; i0 < 2; i0++) {
     1152             f_vec[i0] += q_ast[i0];
     1153           }
     1154
     1155           /*  save deformation for given control point */
     1156           c_precomputed = b_f->size[0];
     1157           kstr = b_f->size[1];
     1158           nbytes = points_of_evaluation->data[i + points_of_evaluation->size[0]];
     1159           if (nbytes != (int32_T)muDoubleScalarFloor(nbytes)) {
     1160             emlrtIntegerCheckR2012b(nbytes, &d_emlrtDCI, &st);
     1161           }
     1162
     1163           b_points_of_evaluation = (int32_T)nbytes;
     1164           if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= kstr)))
     1165           {
     1166             emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, kstr,
     1167               &m_emlrtBCI, &st);
     1168           }
     1169
     1170           nbytes = points_of_evaluation->data[i];
     1171           if (nbytes != (int32_T)muDoubleScalarFloor(nbytes)) {
     1172             emlrtIntegerCheckR2012b(nbytes, &c_emlrtDCI, &st);
     1173           }
     1174
     1175           kstr = (int32_T)nbytes;
     1176           if (!((kstr >= 1) && (kstr <= c_precomputed))) {
     1177             emlrtDynamicBoundsCheckR2012b(kstr, 1, c_precomputed, &l_emlrtBCI, &st);
     1178           }
     1179
     1180           for (i0 = 0; i0 < 2; i0++) {
     1181             b_f->data[((kstr + b_f->size[0] * (b_points_of_evaluation - 1)) +
     1182                        b_f->size[0] * b_f->size[1] * i0) - 1] = f_vec[i0];
     1183           }
     1184
     1185           i++;
     1186           if (*emlrtBreakCheckR2012bFlagVar != 0) {
     1187             emlrtBreakCheckR2012b(&st);
     1188           }
     1189         }
     1190
     1191         i0 = f->size[0] * f->size[1] * f->size[2];
     1192         f->size[0] = b_f->size[0];
     1193         f->size[1] = b_f->size[1];
     1194         f->size[2] = 2;
     1195         emxEnsureCapacity_real_T2(sp, f, i0, &c_emlrtRTEI);
     1196         kstr = b_f->size[0] * b_f->size[1] * b_f->size[2];
     1197         for (i0 = 0; i0 < kstr; i0++) {
     1198           f->data[i0] = b_f->data[i0];
     1199         }
     1200       } else {
     1201         b_bool = false;
     1202         if (type->size[1] == 5) {
     1203           kstr = 0;
     1204           do {
     1205             exitg1 = 0;
     1206             if (kstr + 1 < 6) {
     1207               if (type->data[kstr] != cv2[kstr]) {
     1208                 exitg1 = 1;
     1209               } else {
     1210                 kstr++;
     1211               }
     1212             } else {
     1213               b_bool = true;
     1214               exitg1 = 1;
     1215             }
     1216           } while (exitg1 == 0);
     1217         }
     1218
     1219         if (b_bool) {
     1220           st.site = &c_emlrtRSI;
     1221
     1222           /* MLS deformation */
     1223           /*  rigid deformation */
     1224           for (i0 = 0; i0 < 2; i0++) {
     1225             if (!(size_of_img[i0] >= 0.0)) {
     1226               emlrtNonNegativeCheckR2012b(size_of_img[i0], &g_emlrtDCI, &st);
     1227             }
     1228
     1229             if (size_of_img[i0] != (int32_T)muDoubleScalarFloor(size_of_img[i0]))
     1230             {
     1231               emlrtIntegerCheckR2012b(size_of_img[i0], &h_emlrtDCI, &st);
     1232             }
     1233
     1234             dv0[i0] = size_of_img[i0];
     1235           }
     1236
     1237           i0 = b_f->size[0] * b_f->size[1] * b_f->size[2];
     1238           b_f->size[0] = (int32_T)dv0[0];
     1239           b_f->size[1] = (int32_T)dv0[1];
     1240           b_f->size[2] = 2;
     1241           emxEnsureCapacity_real_T2(&st, b_f, i0, &c_emlrtRTEI);
     1242           kstr = ((int32_T)dv0[0] * (int32_T)dv0[1]) << 1;
     1243           for (i0 = 0; i0 < kstr; i0++) {
     1244             b_f->data[i0] = 0.0;
     1245           }
     1246
     1247           /*  loop through evaluation points v */
     1248           i = 0;
     1249           while (i <= points_of_evaluation->size[0] - 1) {
     1250             i0 = points_of_evaluation->size[0];
     1251             b_points_of_evaluation = i + 1;
     1252             if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0)))
     1253             {
     1254               emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0,
     1255                 &emlrtBCI, &st);
     1256             }
     1257
     1258             /*  get param for given evaluation point v */
     1259             i0 = precomputed->w_i->size[1];
     1260             b_points_of_evaluation = i + 1;
     1261             if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0)))
     1262             {
     1263               emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0,
     1264                 &b_emlrtBCI, &st);
     1265             }
     1266
     1267             i0 = precomputed->sum_w_i->size[0];
     1268             b_points_of_evaluation = i + 1;
     1269             if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0)))
     1270             {
     1271               emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0,
     1272                 &c_emlrtBCI, &st);
     1273             }
     1274
     1275             kstr = precomputed->Rigid->size[0];
     1276             nbytes = 2.0 * (1.0 + (real_T)i);
     1277             c_precomputed = precomputed->Rigid->size[1];
     1278             i0 = Ai->size[0] * Ai->size[1];
     1279             Ai->size[0] = kstr;
     1280             Ai->size[1] = 2;
     1281             emxEnsureCapacity_real_T(&st, Ai, i0, &c_emlrtRTEI);
     1282             for (i0 = 0; i0 < 2; i0++) {
     1283               for (b_points_of_evaluation = 0; b_points_of_evaluation < kstr;
     1284                    b_points_of_evaluation++) {
     1285                 i1 = (int32_T)(nbytes + (-1.0 + (real_T)i0));
     1286                 if (!((i1 >= 1) && (i1 <= c_precomputed))) {
     1287                   emlrtDynamicBoundsCheckR2012b(i1, 1, c_precomputed, &v_emlrtBCI,
     1288                     &st);
     1289                 }
     1290
     1291                 Ai->data[b_points_of_evaluation + Ai->size[0] * i0] =
     1292                   precomputed->Rigid->data[b_points_of_evaluation +
     1293                   precomputed->Rigid->size[0] * (i1 - 1)];
     1294               }
     1295             }
     1296
     1297             i0 = precomputed->p_ast->size[0];
     1298             b_points_of_evaluation = i + 1;
     1299             if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0)))
     1300             {
     1301               emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0,
     1302                 &d_emlrtBCI, &st);
     1303             }
     1304
     1305             kstr = precomputed->w_i->size[0];
     1306             i0 = b_precomputed->size[0];
     1307             b_precomputed->size[0] = kstr;
     1308             emxEnsureCapacity_real_T1(&st, b_precomputed, i0, &c_emlrtRTEI);
     1309             for (i0 = 0; i0 < kstr; i0++) {
     1310               b_precomputed->data[i0] = precomputed->w_i->data[i0 +
     1311                 precomputed->w_i->size[0] * i];
     1312             }
     1313
     1314             b_st.site = &r_emlrtRSI;
     1315             MLS_q(&b_st, b_precomputed, precomputed->sum_w_i->data[i],
     1316                   c_deformed_position_of_control_, q_ast, q_hat_i);
     1317
     1318             /*  loop through control points */
     1319             for (i0 = 0; i0 < 2; i0++) {
     1320               f_vec[i0] = 0.0;
     1321             }
     1322
     1323             kstr = 0;
     1324             while (kstr <= c_deformed_position_of_control_->size[0] - 1) {
     1325               i0 = q_hat_i->size[0];
     1326               b_points_of_evaluation = kstr + 1;
     1327               if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= i0)))
     1328               {
     1329                 emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, i0,
     1330                   &e_emlrtBCI, &st);
     1331               }
     1332
     1333               i0 = precomputed->Rigid->size[0];
     1334               nbytes = 2.0 * (1.0 + (real_T)kstr);
     1335               for (b_points_of_evaluation = 0; b_points_of_evaluation < 2;
     1336                    b_points_of_evaluation++) {
     1337                 for (i1 = 0; i1 < 2; i1++) {
     1338                   c_precomputed = (int32_T)(nbytes + (-1.0 + (real_T)i1));
     1339                   if (!((c_precomputed >= 1) && (c_precomputed <= i0))) {
     1340                     emlrtDynamicBoundsCheckR2012b(c_precomputed, 1, i0,
     1341                       &w_emlrtBCI, &st);
     1342                   }
     1343
     1344                   b[i1 + (b_points_of_evaluation << 1)] = Ai->data[(c_precomputed
     1345                     + Ai->size[0] * b_points_of_evaluation) - 1];
     1346                 }
     1347               }
     1348
     1349               for (i0 = 0; i0 < 2; i0++) {
     1350                 nbytes = 0.0;
     1351                 for (b_points_of_evaluation = 0; b_points_of_evaluation < 2;
     1352                      b_points_of_evaluation++) {
     1353                   nbytes += q_hat_i->data[kstr + q_hat_i->size[0] *
     1354                     b_points_of_evaluation] * b[b_points_of_evaluation + (i0 << 1)];
     1355                 }
     1356
     1357                 f_vec[i0] += nbytes;
     1358               }
     1359
     1360               kstr++;
     1361               if (*emlrtBreakCheckR2012bFlagVar != 0) {
     1362                 emlrtBreakCheckR2012b(&st);
     1363               }
     1364             }
     1365
     1366             for (kstr = 0; kstr < 2; kstr++) {
     1367               z1[kstr] = f_vec[kstr] * f_vec[kstr];
     1368             }
     1369
     1370             x = z1[0] + z1[1];
     1371             b_st.site = &s_emlrtRSI;
     1372             if (x < 0.0) {
     1373               c_st.site = &u_emlrtRSI;
     1374               d_st.site = &u_emlrtRSI;
     1375               error(&d_st);
     1376             }
     1377
     1378             len_f_vec = muDoubleScalarSqrt(x);
     1379             for (i0 = 0; i0 < 2; i0++) {
     1380               a[i0] = points_of_evaluation->data[i + points_of_evaluation->size[0]
     1381                 * i0] - precomputed->p_ast->data[i + precomputed->p_ast->size[0] *
     1382                 i0];
     1383             }
     1384
     1385             for (kstr = 0; kstr < 2; kstr++) {
     1386               z1[kstr] = a[kstr] * a[kstr];
     1387             }
     1388
     1389             x = z1[0] + z1[1];
     1390             b_st.site = &t_emlrtRSI;
     1391             if (x < 0.0) {
     1392               c_st.site = &u_emlrtRSI;
     1393               d_st.site = &u_emlrtRSI;
     1394               error(&d_st);
     1395             }
     1396
     1397             x = muDoubleScalarSqrt(x);
     1398
     1399             /*  save deformation for given control point */
     1400             c_precomputed = b_f->size[0];
     1401             kstr = b_f->size[1];
     1402             nbytes = points_of_evaluation->data[i + points_of_evaluation->size[0]];
     1403             if (nbytes != (int32_T)muDoubleScalarFloor(nbytes)) {
     1404               emlrtIntegerCheckR2012b(nbytes, &b_emlrtDCI, &st);
     1405             }
     1406
     1407             b_points_of_evaluation = (int32_T)nbytes;
     1408             if (!((b_points_of_evaluation >= 1) && (b_points_of_evaluation <= kstr)))
     1409             {
     1410               emlrtDynamicBoundsCheckR2012b(b_points_of_evaluation, 1, kstr,
     1411                 &g_emlrtBCI, &st);
     1412             }
     1413
     1414             nbytes = points_of_evaluation->data[i];
     1415             if (nbytes != (int32_T)muDoubleScalarFloor(nbytes)) {
     1416               emlrtIntegerCheckR2012b(nbytes, &emlrtDCI, &st);
     1417             }
     1418
     1419             kstr = (int32_T)nbytes;
     1420             if (!((kstr >= 1) && (kstr <= c_precomputed))) {
     1421               emlrtDynamicBoundsCheckR2012b(kstr, 1, c_precomputed, &f_emlrtBCI,
     1422                 &st);
     1423             }
     1424
     1425             for (i0 = 0; i0 < 2; i0++) {
     1426               b_f->data[((kstr + b_f->size[0] * (b_points_of_evaluation - 1)) +
     1427                          b_f->size[0] * b_f->size[1] * i0) - 1] = x * f_vec[i0] /
     1428                 len_f_vec + q_ast[i0];
     1429             }
     1430
     1431             i++;
     1432             if (*emlrtBreakCheckR2012bFlagVar != 0) {
     1433               emlrtBreakCheckR2012b(&st);
     1434             }
     1435           }
     1436
     1437           i0 = f->size[0] * f->size[1] * f->size[2];
     1438           f->size[0] = b_f->size[0];
     1439           f->size[1] = b_f->size[1];
     1440           f->size[2] = 2;
     1441           emxEnsureCapacity_real_T2(sp, f, i0, &c_emlrtRTEI);
     1442           kstr = b_f->size[0] * b_f->size[1] * b_f->size[2];
     1443           for (i0 = 0; i0 < kstr; i0++) {
     1444             f->data[i0] = b_f->data[i0];
     1445           }
     1446         } else {
     1447           /* ME = MException('type:PassedWrongVariable', ... */
     1448           /*     'Variable %s should be one of following: Affine, Similarity, Rigid',type); */
     1449           /* throw(ME) */
     1450           st.site = &d_emlrtRSI;
     1451           b_st.site = &v_emlrtRSI;
     1452           y = NULL;
     1453           m0 = emlrtCreateCharArray(2, iv0);
     1454           emlrtInitCharArrayR2013a(&b_st, 7, m0, &u[0]);
     1455           emlrtAssign(&y, m0);
     1456           b_y = NULL;
     1457           m0 = emlrtCreateDoubleScalar(1.0);
     1458           emlrtAssign(&b_y, m0);
     1459           c_y = NULL;
     1460           m0 = emlrtCreateCharArray(2, iv1);
     1461           emlrtInitCharArrayR2013a(&b_st, 19, m0, &formatSpec[0]);
     1462           emlrtAssign(&c_y, m0);
     1463           c_st.site = &x_emlrtRSI;
     1464           nbytes = emlrt_marshallIn(&c_st, feval(&c_st, y, b_y, c_y, &b_emlrtMCI),
     1465             "feval");
     1466           y = NULL;
     1467           m0 = emlrtCreateDoubleScalar(nbytes);
     1468           emlrtAssign(&y, m0);
     1469           emlrtDisplayR2012b(y, "ans", &emlrtRTEI, sp);
     1470         }
     1471       }
     1472
     1473       emxFree_real_T(&Ai);
     1474     }
     1475
     1476     emxFree_real_T(&b_precomputed);
     1477     emxFree_real_T(&q_hat_i);
     1478     emxFree_real_T(&b_f);
     1479     emlrtHeapReferenceStackLeaveFcnR2012b(sp);
     1480   }
     1481
     1482   /* End of code generation (MLS_getDeform.c) */
     1483