/******************************************************************************** * File Name : tfr16.c * * * * Function : Frac16 tfr16ASinOverPI (Frac16 x) * * * * Description: * * This routine computes the Arcsin function of fractional input value x, and * * divides that result by pi i.e. Arcsin(x)/pi. * * * * Inputs : * * 1) x - input data value * * * * Outputs : * * 1) z - Arcsin(x)/pi * * * * Algorithm: * * if(x >= 0.70710678118655) * * z = 0.5 - ASinOverPI(sqrt(1-x^2)) * * else * * z = ASinOverPI(x) * * * * Where : * * ASinOverPI(x) = x(AsineCoefs(0)+x^2(AsineCoefs(1)+x^2(AsineCoefs(2)+ * * x^2(AsineCoefs(3)+x^2(AsineCoefs(4)+x^2(AsineCoefs(5)+ * * x^2(AsineCoefs(6)+AsineCoefs(7)x^2))))))) * * * ********************************************************************************/
Frac16 tfr16AsinOverPI (Frac16 x) { Frac16 z, temp16, sign_flag = 0, i, thres_flag = 0; Frac32 Acc = 0;
if (x < 0) { sign_flag = 1; x = negate(x); }
z = mult_r(x,x); if (x > Inv_Threshold) { thres_flag = 1; x = mfr16Sqrt(sub(CFF(1),add(z,1))); z = mult_r(x,x); }
temp16 = AsineCoefs[7];
for(i = 6; i >= 0; i--) { Acc = L_deposit_h(AsineCoefs); temp16 = mac_r(Acc,temp16,z); }
z = mult_r(temp16,x);
if (thres_flag == 1) { z = sub(CFF(0.5),z); }
if (sign_flag == 1) { z = negate(z); }
return z; } |