separate ( Generic_Elementary_Functions ) function KF_CosCy( X, Cycle : Float_Type ) return Float_Type is -- On input, X is a floating-point value in Float_Type; Cycle is a -- user specificed period. -- On output, the value of cos(X*2pi/Cycle) is returned. R, Y, Z, User_Period, P_Lead, P_Trail, K : Common_Float; Zero : Common_Float := 0.0; I_Flag, SC_Flag, PM_Flag : Quadrant_Flag; Two_Pi : constant := 6.28318_53071_79586_47692_52867_66559_00576_8394; begin -- Argument reduction by "rem" Y := abs( Common_Float( X ) ); User_Period := Common_Float( Cycle ); if User_Period <= 0.0 then raise Argument_Error; end if; R := Y rem User_Period; K := Round( 4.0*R / User_Period ); I_Flag := Quadrant_Flag( (Integer(K)+1) mod 4 ); SC_Flag := I_Flag mod 2; PM_Flag := (I_Flag - SC_Flag) / 2; P_Lead := Leading_Part( User_Period, 4 ); P_Trail := User_Period - P_Lead; K := K * 0.25; R := (R - K*P_Lead) - K*P_Trail; R := (R/User_Period) * Two_Pi; if (SC_Flag = 0) then Z := KF_Sin( R, Zero ); else Z := KF_Cos( R, Zero ); end if; if (PM_Flag = 1) then Z := -Z; end if; return( Float_Type( Z ) ); end KF_CosCy;