sqrt.cpp
Go to the documentation of this file.
00001 /*
00002  * sqrt.cpp
00003  *
00004  * Code generation for function 'sqrt'
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 "sqrt.h"
00014 #include "expm.h"
00015 #include "Optimal_affine_tracking_3d16_fast_realtime_rtwutil.h"
00016 
00017 /* Type Definitions */
00018 
00019 /* Named Constants */
00020 
00021 /* Variable Declarations */
00022 
00023 /* Variable Definitions */
00024 
00025 /* Function Declarations */
00026 
00027 /* Function Definitions */
00028 void b_sqrt(creal_T *x)
00029 {
00030   real_T absxi;
00031   real_T absxr;
00032   if (x->im == 0.0) {
00033     if (x->re < 0.0) {
00034       absxi = 0.0;
00035       absxr = sqrt(fabs(x->re));
00036     } else {
00037       absxi = sqrt(x->re);
00038       absxr = 0.0;
00039     }
00040   } else if (x->re == 0.0) {
00041     if (x->im < 0.0) {
00042       absxi = sqrt(-x->im / 2.0);
00043       absxr = -absxi;
00044     } else {
00045       absxi = sqrt(x->im / 2.0);
00046       absxr = absxi;
00047     }
00048   } else if (rtIsNaN(x->re) || rtIsNaN(x->im)) {
00049     absxi = rtNaN;
00050     absxr = rtNaN;
00051   } else if (rtIsInf(x->im)) {
00052     absxi = rtInf;
00053     absxr = x->im;
00054   } else if (rtIsInf(x->re)) {
00055     if (x->re < 0.0) {
00056       absxi = 0.0;
00057       absxr = rtInf;
00058     } else {
00059       absxi = rtInf;
00060       absxr = 0.0;
00061     }
00062   } else {
00063     absxr = fabs(x->re);
00064     absxi = fabs(x->im);
00065     if ((absxr > 4.4942328371557893E+307) || (absxi > 4.4942328371557893E+307))
00066     {
00067       absxr *= 0.5;
00068       absxi *= 0.5;
00069       absxi = rt_hypotd_snf(absxr, absxi);
00070       if (absxi > absxr) {
00071         absxi = sqrt(absxi) * sqrt(1.0 + absxr / absxi);
00072       } else {
00073         absxi = sqrt(absxi) * 1.4142135623730951;
00074       }
00075     } else {
00076       absxi = sqrt((rt_hypotd_snf(absxr, absxi) + absxr) * 0.5);
00077     }
00078 
00079     if (x->re > 0.0) {
00080       absxr = 0.5 * (x->im / absxi);
00081     } else {
00082       if (x->im < 0.0) {
00083         absxr = -absxi;
00084       } else {
00085         absxr = absxi;
00086       }
00087 
00088       absxi = 0.5 * (x->im / absxr);
00089     }
00090   }
00091 
00092   x->re = absxi;
00093   x->im = absxr;
00094 }
00095 
00096 /* End of code generation (sqrt.cpp) */


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