resampling.cpp
Go to the documentation of this file.
00001 /*
00002  * resampling.cpp
00003  *
00004  * Code generation for function 'resampling'
00005  *
00006  * C source code generated on: Wed Jul 24 16:11:35 2013
00007  *
00008  */
00009 
00010 /* Include files */
00011 #include "rt_nonfinite.h"
00012 #include "Optimal_affine_tracking_3d16_fast_realtime.h"
00013 #include "resampling.h"
00014 #include "meshgrid.h"
00015 #include "cumulative_sum.h"
00016 #include "rand.h"
00017 
00018 /* Type Definitions */
00019 
00020 /* Named Constants */
00021 
00022 /* Variable Declarations */
00023 
00024 /* Variable Definitions */
00025 
00026 /* Function Declarations */
00027 
00028 /* Function Definitions */
00029 void resampling(const real_T w[25], real_T outindex[25])
00030 {
00031   real_T ndbl;
00032   real_T y;
00033   int32_T xtmp;
00034   real_T apnd;
00035   real_T absa;
00036   real_T U_data[26];
00037   int32_T nm1d2;
00038   int32_T k;
00039   real_T dv10[25];
00040   real_T cum[26];
00041   real_T dv11[25];
00042   real_T dv12[25];
00043   int32_T i;
00044   real_T jj[625];
00045   real_T ii[625];
00046   int32_T i19;
00047   boolean_T cond[625];
00048   int32_T ind;
00049   int32_T idx;
00050   int16_T ii_data[1];
00051   boolean_T exitg1;
00052   int16_T tmp_data[625];
00053   int32_T tmp_size_idx_0;
00054   int32_T loop_ub;
00055   int32_T i20;
00056   int16_T b_tmp_data[625];
00057   int16_T b_ii_data[1];
00058   int16_T j_data[1];
00059   ndbl = c_rand();
00060   y = ndbl / 25.0;
00061   if (rtIsNaN(y)) {
00062     xtmp = 1;
00063     y = rtNaN;
00064     apnd = 1.0;
00065   } else if (rtIsInf(y)) {
00066     xtmp = 1;
00067     y = rtNaN;
00068     apnd = 1.0;
00069   } else {
00070     ndbl = floor((1.0 - y) / 0.04 + 0.5);
00071     apnd = y + ndbl * 0.04;
00072     absa = fabs(y);
00073     if (absa > 1.0) {
00074     } else {
00075       absa = 1.0;
00076     }
00077 
00078     if (fabs(apnd - 1.0) < 4.4408920985006262E-16 * absa) {
00079       ndbl++;
00080       apnd = 1.0;
00081     } else if (apnd - 1.0 > 0.0) {
00082       apnd = y + (ndbl - 1.0) * 0.04;
00083     } else {
00084       ndbl++;
00085     }
00086 
00087     xtmp = (int32_T)ndbl;
00088   }
00089 
00090   U_data[0] = y;
00091   if (xtmp > 1) {
00092     U_data[xtmp - 1] = apnd;
00093     nm1d2 = (xtmp - 1) / 2;
00094     for (k = 1; k <= nm1d2 - 1; k++) {
00095       ndbl = (real_T)k * 0.04;
00096       U_data[k] = y + ndbl;
00097       U_data[(xtmp - k) - 1] = apnd - ndbl;
00098     }
00099 
00100     if (nm1d2 << 1 == xtmp - 1) {
00101       U_data[nm1d2] = (y + apnd) / 2.0;
00102     } else {
00103       ndbl = (real_T)nm1d2 * 0.04;
00104       U_data[nm1d2] = y + ndbl;
00105       U_data[nm1d2 + 1] = apnd - ndbl;
00106     }
00107   }
00108 
00109   cumulative_sum(w, dv10);
00110   cum[0] = 0.0;
00111   for (i = 0; i < 25; i++) {
00112     cum[i + 1] = dv10[i];
00113     outindex[i] = 0.0;
00114     dv11[i] = 1.0 + (real_T)i;
00115     dv12[i] = 2.0 + (real_T)i;
00116   }
00117 
00118   meshgrid(dv11, dv12, ii, jj);
00119   for (i19 = 0; i19 < 625; i19++) {
00120     cond[i19] = ((U_data[(int32_T)ii[i19] - 1] > cum[(int32_T)(jj[i19] - 1.0) -
00121                   1]) && (U_data[(int32_T)ii[i19] - 1] <= cum[(int32_T)jj[i19] -
00122                           1]));
00123   }
00124 
00125   i = 0;
00126   for (ind = 0; ind < 25; ind++) {
00127     nm1d2 = 1 + ind * 25;
00128     if (nm1d2 > nm1d2 + 24) {
00129       nm1d2 = 1;
00130       i19 = 0;
00131     } else {
00132       i19 = nm1d2 + 24;
00133     }
00134 
00135     xtmp = (i19 - nm1d2) + 1;
00136     if (1 <= xtmp) {
00137       k = 1;
00138     } else {
00139       k = xtmp;
00140     }
00141 
00142     idx = 0;
00143     exitg1 = FALSE;
00144     while ((exitg1 == 0U) && (xtmp > 0)) {
00145       tmp_size_idx_0 = (i19 - nm1d2) + 1;
00146       loop_ub = i19 - nm1d2;
00147       for (i20 = 0; i20 <= loop_ub; i20++) {
00148         tmp_data[i20] = (int16_T)(nm1d2 + i20);
00149       }
00150 
00151       loop_ub = tmp_size_idx_0 - 1;
00152       for (i20 = 0; i20 <= loop_ub; i20++) {
00153         b_tmp_data[i20] = tmp_data[i20];
00154       }
00155 
00156       if (cond[b_tmp_data[xtmp - 1] - 1]) {
00157         idx = 1;
00158         ii_data[0] = (int16_T)xtmp;
00159         exitg1 = TRUE;
00160       } else {
00161         xtmp--;
00162       }
00163     }
00164 
00165     if (k == 1) {
00166       if (idx == 0) {
00167         k = 0;
00168       }
00169     } else {
00170       if (1 > idx) {
00171         i19 = -1;
00172       } else {
00173         i19 = 0;
00174       }
00175 
00176       loop_ub = i19;
00177       i20 = 0;
00178       while (i20 <= loop_ub) {
00179         i20 = 0;
00180         while (i20 <= 0) {
00181           b_ii_data[0] = ii_data[0];
00182           i20 = 1;
00183         }
00184 
00185         i20 = 1;
00186       }
00187 
00188       k = i19 + 1;
00189       loop_ub = i19;
00190       i20 = 0;
00191       while (i20 <= loop_ub) {
00192         ii_data[0] = b_ii_data[0];
00193         i20 = 1;
00194       }
00195 
00196       nm1d2 = (i19 + 1) / 2;
00197       xtmp = 1;
00198       while (xtmp <= nm1d2) {
00199         xtmp = ii_data[0];
00200         ii_data[0] = ii_data[i19];
00201         ii_data[i19] = (int16_T)xtmp;
00202         xtmp = 2;
00203       }
00204     }
00205 
00206     loop_ub = k - 1;
00207     i19 = 0;
00208     while (i19 <= loop_ub) {
00209       j_data[0] = ii_data[0];
00210       i19 = 1;
00211     }
00212 
00213     outindex[i] = (real_T)j_data[0];
00214     i++;
00215   }
00216 }
00217 
00218 /* End of code generation (resampling.cpp) */


depth_tracker_ros_vr8
Author(s): shusain
autogenerated on Fri Dec 6 2013 20:45:47