mldivide.cpp
Go to the documentation of this file.
00001 /*
00002  * mldivide.cpp
00003  *
00004  * Code generation for function 'mldivide'
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 "mldivide.h"
00014 
00015 /* Type Definitions */
00016 
00017 /* Named Constants */
00018 
00019 /* Variable Declarations */
00020 
00021 /* Variable Definitions */
00022 
00023 /* Function Declarations */
00024 
00025 /* Function Definitions */
00026 void b_mldivide(const real_T A[9], const real_T B[9], real_T Y[9])
00027 {
00028   real_T b_A[9];
00029   int32_T r1;
00030   int32_T r2;
00031   int32_T r3;
00032   real_T maxval;
00033   real_T a21;
00034   int32_T rtemp;
00035   memcpy(&b_A[0], &A[0], 9U * sizeof(real_T));
00036   r1 = 0;
00037   r2 = 1;
00038   r3 = 2;
00039   maxval = fabs(A[0]);
00040   a21 = fabs(A[1]);
00041   if (a21 > maxval) {
00042     maxval = a21;
00043     r1 = 1;
00044     r2 = 0;
00045   }
00046 
00047   if (fabs(A[2]) > maxval) {
00048     r1 = 2;
00049     r2 = 1;
00050     r3 = 0;
00051   }
00052 
00053   b_A[r2] = A[r2] / A[r1];
00054   b_A[r3] /= b_A[r1];
00055   b_A[3 + r2] -= b_A[r2] * b_A[3 + r1];
00056   b_A[3 + r3] -= b_A[r3] * b_A[3 + r1];
00057   b_A[6 + r2] -= b_A[r2] * b_A[6 + r1];
00058   b_A[6 + r3] -= b_A[r3] * b_A[6 + r1];
00059   if (fabs(b_A[3 + r3]) > fabs(b_A[3 + r2])) {
00060     rtemp = r2;
00061     r2 = r3;
00062     r3 = rtemp;
00063   }
00064 
00065   b_A[3 + r3] /= b_A[3 + r2];
00066   b_A[6 + r3] -= b_A[3 + r3] * b_A[6 + r2];
00067   for (rtemp = 0; rtemp < 3; rtemp++) {
00068     Y[3 * rtemp] = B[r1 + 3 * rtemp];
00069     Y[1 + 3 * rtemp] = B[r2 + 3 * rtemp] - Y[3 * rtemp] * b_A[r2];
00070     Y[2 + 3 * rtemp] = (B[r3 + 3 * rtemp] - Y[3 * rtemp] * b_A[r3]) - Y[1 + 3 *
00071       rtemp] * b_A[3 + r3];
00072     Y[2 + 3 * rtemp] /= b_A[6 + r3];
00073     Y[3 * rtemp] -= Y[2 + 3 * rtemp] * b_A[6 + r1];
00074     Y[1 + 3 * rtemp] -= Y[2 + 3 * rtemp] * b_A[6 + r2];
00075     Y[1 + 3 * rtemp] /= b_A[3 + r2];
00076     Y[3 * rtemp] -= Y[1 + 3 * rtemp] * b_A[3 + r1];
00077     Y[3 * rtemp] /= b_A[r1];
00078   }
00079 }
00080 
00081 creal_T c_eml_div(const creal_T x, const creal_T y)
00082 {
00083   creal_T z;
00084   real_T brm;
00085   real_T bim;
00086   real_T d;
00087   if (y.im == 0.0) {
00088     if (x.im == 0.0) {
00089       z.re = x.re / y.re;
00090       z.im = 0.0;
00091     } else if (x.re == 0.0) {
00092       z.re = 0.0;
00093       z.im = x.im / y.re;
00094     } else {
00095       z.re = x.re / y.re;
00096       z.im = x.im / y.re;
00097     }
00098   } else if (y.re == 0.0) {
00099     if (x.re == 0.0) {
00100       z.re = x.im / y.im;
00101       z.im = 0.0;
00102     } else if (x.im == 0.0) {
00103       z.re = 0.0;
00104       z.im = -(x.re / y.im);
00105     } else {
00106       z.re = x.im / y.im;
00107       z.im = -(x.re / y.im);
00108     }
00109   } else {
00110     brm = fabs(y.re);
00111     bim = fabs(y.im);
00112     if (brm > bim) {
00113       bim = y.im / y.re;
00114       d = y.re + bim * y.im;
00115       z.re = (x.re + bim * x.im) / d;
00116       z.im = (x.im - bim * x.re) / d;
00117     } else if (bim == brm) {
00118       bim = y.re > 0.0 ? 0.5 : -0.5;
00119       d = y.im > 0.0 ? 0.5 : -0.5;
00120       z.re = (x.re * bim + x.im * d) / brm;
00121       z.im = (x.im * bim - x.re * d) / brm;
00122     } else {
00123       bim = y.re / y.im;
00124       d = y.im + bim * y.re;
00125       z.re = (bim * x.re + x.im) / d;
00126       z.im = (bim * x.im - x.re) / d;
00127     }
00128   }
00129 
00130   return z;
00131 }
00132 
00133 void c_mldivide(const real_T A[4], const real_T B[4], real_T Y[4])
00134 {
00135   int32_T r1;
00136   int32_T r2;
00137   real_T a21;
00138   real_T a22;
00139   int32_T k;
00140   if (fabs(A[1]) > fabs(A[0])) {
00141     r1 = 1;
00142     r2 = 0;
00143   } else {
00144     r1 = 0;
00145     r2 = 1;
00146   }
00147 
00148   a21 = A[r2] / A[r1];
00149   a22 = A[2 + r2] - a21 * A[2 + r1];
00150   for (k = 0; k < 2; k++) {
00151     Y[1 + (k << 1)] = (B[r2 + (k << 1)] - B[r1 + (k << 1)] * a21) / a22;
00152     Y[k << 1] = (B[r1 + (k << 1)] - Y[1 + (k << 1)] * A[2 + r1]) / A[r1];
00153   }
00154 }
00155 
00156 void mldivide(const creal_T A[9], const creal_T B[9], creal_T Y[9])
00157 {
00158   creal_T b_A[9];
00159   int32_T r1;
00160   int32_T r2;
00161   int32_T r3;
00162   real_T maxval;
00163   real_T a21;
00164   int32_T rtemp;
00165   memcpy(&b_A[0], &A[0], 9U * sizeof(creal_T));
00166   r1 = 0;
00167   r2 = 1;
00168   r3 = 2;
00169   maxval = fabs(A[0].re) + fabs(A[0].im);
00170   a21 = fabs(A[1].re) + fabs(A[1].im);
00171   if (a21 > maxval) {
00172     maxval = a21;
00173     r1 = 1;
00174     r2 = 0;
00175   }
00176 
00177   if (fabs(A[2].re) + fabs(A[2].im) > maxval) {
00178     r1 = 2;
00179     r2 = 1;
00180     r3 = 0;
00181   }
00182 
00183   b_A[r2] = c_eml_div(A[r2], A[r1]);
00184   b_A[r3] = c_eml_div(b_A[r3], b_A[r1]);
00185   maxval = b_A[r2].re * b_A[3 + r1].im + b_A[r2].im * b_A[3 + r1].re;
00186   b_A[3 + r2].re -= b_A[r2].re * b_A[3 + r1].re - b_A[r2].im * b_A[3 + r1].im;
00187   b_A[3 + r2].im -= maxval;
00188   maxval = b_A[r3].re * b_A[3 + r1].im + b_A[r3].im * b_A[3 + r1].re;
00189   b_A[3 + r3].re -= b_A[r3].re * b_A[3 + r1].re - b_A[r3].im * b_A[3 + r1].im;
00190   b_A[3 + r3].im -= maxval;
00191   maxval = b_A[r2].re * b_A[6 + r1].im + b_A[r2].im * b_A[6 + r1].re;
00192   b_A[6 + r2].re -= b_A[r2].re * b_A[6 + r1].re - b_A[r2].im * b_A[6 + r1].im;
00193   b_A[6 + r2].im -= maxval;
00194   maxval = b_A[r3].re * b_A[6 + r1].im + b_A[r3].im * b_A[6 + r1].re;
00195   b_A[6 + r3].re -= b_A[r3].re * b_A[6 + r1].re - b_A[r3].im * b_A[6 + r1].im;
00196   b_A[6 + r3].im -= maxval;
00197   if (fabs(b_A[3 + r3].re) + fabs(b_A[3 + r3].im) > fabs(b_A[3 + r2].re) + fabs
00198       (b_A[3 + r2].im)) {
00199     rtemp = r2;
00200     r2 = r3;
00201     r3 = rtemp;
00202   }
00203 
00204   b_A[3 + r3] = c_eml_div(b_A[3 + r3], b_A[3 + r2]);
00205   maxval = b_A[3 + r3].re * b_A[6 + r2].im + b_A[3 + r3].im * b_A[6 + r2].re;
00206   b_A[6 + r3].re -= b_A[3 + r3].re * b_A[6 + r2].re - b_A[3 + r3].im * b_A[6 +
00207     r2].im;
00208   b_A[6 + r3].im -= maxval;
00209   for (rtemp = 0; rtemp < 3; rtemp++) {
00210     Y[3 * rtemp] = B[r1 + 3 * rtemp];
00211     maxval = Y[3 * rtemp].re * b_A[r2].im + Y[3 * rtemp].im * b_A[r2].re;
00212     Y[1 + 3 * rtemp].re = B[r2 + 3 * rtemp].re - (Y[3 * rtemp].re * b_A[r2].re -
00213       Y[3 * rtemp].im * b_A[r2].im);
00214     Y[1 + 3 * rtemp].im = B[r2 + 3 * rtemp].im - maxval;
00215     maxval = Y[3 * rtemp].re * b_A[r3].im + Y[3 * rtemp].im * b_A[r3].re;
00216     a21 = Y[1 + 3 * rtemp].re * b_A[3 + r3].im + Y[1 + 3 * rtemp].im * b_A[3 +
00217       r3].re;
00218     Y[2 + 3 * rtemp].re = (B[r3 + 3 * rtemp].re - (Y[3 * rtemp].re * b_A[r3].re
00219       - Y[3 * rtemp].im * b_A[r3].im)) - (Y[1 + 3 * rtemp].re * b_A[3 + r3].re -
00220       Y[1 + 3 * rtemp].im * b_A[3 + r3].im);
00221     Y[2 + 3 * rtemp].im = (B[r3 + 3 * rtemp].im - maxval) - a21;
00222     Y[2 + 3 * rtemp] = c_eml_div(Y[2 + 3 * rtemp], b_A[6 + r3]);
00223     maxval = Y[2 + 3 * rtemp].re * b_A[6 + r1].im + Y[2 + 3 * rtemp].im * b_A[6
00224       + r1].re;
00225     Y[3 * rtemp].re -= Y[2 + 3 * rtemp].re * b_A[6 + r1].re - Y[2 + 3 * rtemp].
00226       im * b_A[6 + r1].im;
00227     Y[3 * rtemp].im -= maxval;
00228     maxval = Y[2 + 3 * rtemp].re * b_A[6 + r2].im + Y[2 + 3 * rtemp].im * b_A[6
00229       + r2].re;
00230     Y[1 + 3 * rtemp].re -= Y[2 + 3 * rtemp].re * b_A[6 + r2].re - Y[2 + 3 *
00231       rtemp].im * b_A[6 + r2].im;
00232     Y[1 + 3 * rtemp].im -= maxval;
00233     Y[1 + 3 * rtemp] = c_eml_div(Y[1 + 3 * rtemp], b_A[3 + r2]);
00234     maxval = Y[1 + 3 * rtemp].re * b_A[3 + r1].im + Y[1 + 3 * rtemp].im * b_A[3
00235       + r1].re;
00236     Y[3 * rtemp].re -= Y[1 + 3 * rtemp].re * b_A[3 + r1].re - Y[1 + 3 * rtemp].
00237       im * b_A[3 + r1].im;
00238     Y[3 * rtemp].im -= maxval;
00239     Y[3 * rtemp] = c_eml_div(Y[3 * rtemp], b_A[r1]);
00240   }
00241 }
00242 
00243 /* End of code generation (mldivide.cpp) */


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