Changeset 1018
Legend:
 Unmodified
 Added
 Removed

trunk/src/real.cpp
r1017 r1018 745 745 { 746 746 return sin(real::R_PI_2  x); 747 } 748 749 real tan(real const &x) 750 { 751 /* Constrain input to [π,π] */ 752 real y = fmod(x, real::R_PI); 753 754 /* Constrain input to [π/2,π/2] */ 755 if (y < real::R_PI_2) 756 y += real::R_PI; 757 else if (y > real::R_PI_2) 758 y = real::R_PI; 759 760 /* In [π/4,π/4] return sin/cos */ 761 if (fabs(y) <= real::R_PI_4) 762 return sin(y) / cos(y); 763 764 /* Otherwise, return cos/sin */ 765 if (y > real::R_0) 766 y = real::R_PI_2  y; 767 else 768 y = real::R_PI_2  y; 769 770 return cos(y) / sin(y); 747 771 } 748 772 
trunk/src/real.h
r1017 r1018 77 77 friend real sin(real const &x); 78 78 friend real cos(real const &x); 79 friend real tan(real const &x); 79 80 friend real asin(real const &x); 80 81 friend real acos(real const &x);
Note: See TracChangeset
for help on using the changeset viewer.