/* * _CHABS: complex(kind=4) absolute value, returns real(kind=4) value * - pass by value */ _f_real4 #ifdef _CRAYMPP _CHABS(_f_comp4 z) { union hl_complx4 { _f_comp4 cpx4; struct { _f_real4 real; _f_real4 imag; } rlim4; } f; _f_real4 ret_val; _f_real8 _SQRT(_f_real8 x); _f_real8 real, imag; f.cpx4 = z; real = fabs((_f_real8) f.rlim4.real); imag = fabs((_f_real8) f.rlim4.imag); if (real == 0.0 && imag == 0.0) return((_f_real4) 0.0); if (real > imag) ret_val = (_f_real4) (real * _SQRT((_f_real8) 1.0 + (imag/real) * (imag/real))); else ret_val = (_f_real4) (imag * _SQRT((_f_real8) 1.0 + (real/imag) * (real/imag))); #else _CHABS(h_complex_t z) { _f_real8 __fabs(_f_real8 x); _f_real8 __sqrt(_f_real8 x); _f_real8 real = __fabs((_f_real8) z.real); _f_real8 imag = __fabs((_f_real8) z.imag); _f_real4 ret_val; if (real == 0.0 && imag == 0.0) return((_f_real4) 0.0); if (real > imag) ret_val = (_f_real4) (real * __sqrt((_f_real8) 1.0 + (imag/real) * (imag/real))); else ret_val = (_f_real4) (imag * __sqrt((_f_real8) 1.0 + (real/imag) * (real/imag))); #endif return (ret_val); }
/* * complex(kind=8) / complex(kind=8) * - pass by value */ void _CDIV(c_complex_t *retval, c_complex_t x, c_complex_t y) { _f_real8 a,b,c,d,e,f,g,q; _f_real8 __fabs(_f_real8 c); a = x.real; b = x.imag; c = y.real; d = y.imag; /* * special case d=0 so we have (a+b*i)/c */ if (d == 0.0) { f = a/c; g = b/c; retval->real = f; retval->imag = g; return; } /* * perform complex/complex with scaling * * if (|c| > |d|) then {|d/c| <= 1} * (a+b*i)/(c+d*i) = (a+b*(d/c))/(c+d*(d/c)) + * (b-a*(d/c))/(c+d*(d/c))*i * else {|c/d| < 1} * (a+b*i)/(c+d*i) = (a*(c/d)+b)/(c*(c/d)+d) + * (b*(c/d)-a)/(c*(c/d)+d)*i */ if (__fabs(c) > __fabs(d)) { q = d/c; e = c + d*q; f = (a + b*q)/e; g = (b - a*q)/e; } else { q = c/d; e = d + c*q; f = (b + a*q)/e; g = (-a + b*q)/e; } retval->real = f; retval->imag = g; return; }
double copysign ( double x, double y ) { double pos_x, neg_x; double pos_y, neg_y, t; pos_x = __fabs(x); neg_x = __fnabs(x); pos_y = __fabs(y); neg_y = __fnabs(y); if (unlikely(pos_y == neg_y)) return __copysign_MEM(x, y); if (unlikely(y != y)) return __copysign_MEM(x, y); t = __fsel(y, pos_x, neg_x); return t; }
float copysignf ( float x, float y ) { double pos_x, neg_x; double pos_y, neg_y; float t; pos_x = __fabs(x); neg_x = __fnabs(x); pos_y = __fabs(y); neg_y = __fnabs(y); if (unlikely(pos_y == neg_y)) return __copysignf_MEM(x, y); if (unlikely(y != y)) return __copysignf_MEM(x, y); t = __fsels(y, pos_x, neg_x); return t; }
/************************************************************* Func: 触摸屏监视任务 Date: 2014 端午节 Note: 测试 *************************************************************/ void Task_GetTouch(void *Tags) { uint32 Temp_ADC1,Temp_ADC2,Temp_ADC11; TGUI_TouchMsg TouchMsg; TOUCH_Tos_TaskID=Tos_TaskCurrent; ADC_WatchdogConfig(); while(1) { Tos_TaskDelay(30); Touch_ADCX_Config(); Tos_TaskDelay(10); Temp_ADC11=AvrFilter_ByWords((uint16 *)&TOUCH_ADC_Value[0][1],TOUCH_ADC_BUFSize,TOUCH_ADC_BUFSize); if(Temp_ADC11>100) { Tos_TaskDelay(10); Temp_ADC1=AvrFilter_ByWords((uint16 *)&TOUCH_ADC_Value[0][1],TOUCH_ADC_BUFSize,TOUCH_ADC_BUFSize); Touch_ADCY_Config(); Tos_TaskDelay(10); Temp_ADC2=AvrFilter_ByWords((uint16 *)&TOUCH_ADC_Value[0][0],TOUCH_ADC_BUFSize,TOUCH_ADC_BUFSize); if(__fabs(Temp_ADC11-Temp_ADC1)<20&Temp_ADC2>400)//消抖 { TOUCH_ADC_YValue=Temp_ADC2; TOUCH_ADC_XValue=Temp_ADC1; if(Touch_Update==TOUCH_DOWNING){Touch_Update=TOUCH_DOWN;} if(Touch_Update!=TOUCH_DOWN) { Touch_Update=TOUCH_DOWNING; Touch_Event.DownIng_Event=Touch_DownIngEvent;//事件测试 Touch_Event.Down_Event=Touch_DownDelayEvent;//事件测试 if(Touch_Event.DownIng_Event)Touch_Event.DownIng_Event();//当存在按下事件时触发 Touch_Event.UpIng_Event=Touch_UpIngEvent;//////事件测试 Touch_Event.DownDelay_Count=0; } if(Touch_Update==TOUCH_DOWN) { if(Touch_Event.DownDelay_Count<TOUCH_DOWNDELAYCOUNT) { Touch_Event.DownDelay_Count++; }else if(Touch_Event.Down_Event)Touch_Event.Down_Event();//当存在持续按下事件时触发 } TOUCH_XValue=Opera_WhithADC(TOUCH_ADC_XValue,TOUCH_CROSS_DATA[0][0],TOUCH_CROSS_ADDR[0][0],TOUCH_CROSS_DATA[1][0],TOUCH_CROSS_ADDR[1][0],LCD_XMAX); TOUCH_YValue=Opera_WhithADC(TOUCH_ADC_YValue,TOUCH_CROSS_DATA[0][1],TOUCH_CROSS_ADDR[0][1],TOUCH_CROSS_DATA[3][1],TOUCH_CROSS_ADDR[3][1],LCD_YMAX); #ifdef COMPILE_MODE_DEBUG DeBug("X=%d Y=%d",TOUCH_ADC_XValue,TOUCH_ADC_YValue,Infor_Infor); #endif TouchMsg.TouchValueX=TOUCH_XValue; TouchMsg.TouchValueY=TOUCH_YValue; TouchMsg.TouchType=Touch_Update; TouchMsg.TouchTime=0; if(Touch_Update==TOUCH_DOWN)TouchMsg.TouchTime=Touch_Event.DownDelay_Count; if(Touch_Update==TOUCH_UP)TouchMsg.TouchTime=Touch_Event.UpDelay_Count; Tos_TaskPutQmsg(Touch_Screen_UserTaskID,TGUI_MsgType_TouchScreen,sizeof(TGUI_TouchMsg),&TouchMsg); } }else { if(Touch_Update==TOUCH_UPING){Touch_Update=TOUCH_UP;} if(Touch_Update!=TOUCH_UP)//触摸屏第一次按下触发 { Touch_Update=TOUCH_UPING; if(Touch_Event.UpIng_Event)Touch_Event.UpIng_Event();//当存在放下动作时触发 Touch_Event.UpDelay_Count=0;//按下第一次时清除按下时间计数 Touch_Event.Up_Event=Touch_UpDelayEvent;//////事件测试 } if(Touch_Update==TOUCH_UP)//触摸屏一直按下 { if(Touch_Event.UpDelay_Count<TOUCH_UPDELAYCOUNT) { Touch_Event.UpDelay_Count++; }else if(Touch_Event.Up_Event)Touch_Event.Up_Event();//当存在持续未按下触发 } } } }
double jumpto__fabs(double x) { return __fabs(x); }
Err mathlib_fabs(UInt16 refnum, double x, double *result) { #pragma unused(refnum) *result = __fabs(x); return mlErrNone; }
double test(double f32a, double f32b, double f32c) { f32c = __fabs(f32a); return __fmadd(f32a, f32b, f32c); }