On Mon, Sep 26, 2016 at 10:01:27AM -0400, Fritz Reese wrote:
> 
> Attached is a patch extending the GNU Fortran front-end to support
> some additional math intrinsics, enabled with a new compile flag
> -fdec-math. The flag adds the COTAN intrinsic (cotangent), as well as
> degree versions of all trigonometric intrinsics (SIND, TAND, ACOSD,
> etc...). This extension allows for further compatibility with legacy
> code that depends on the compiler to support such intrinsic functions.
> 

I plan to review this patch over the weekend.  Two things
to consider.

1) The documentation should note that these intrinsics are
   for compatibility with legacy code and should strongly
   discourage their use in new code.

2) In regards to Joseph and Tobias' comments, the documentation
   should give a hint to the quality of implementation.  Argument
   reduction can be a real pain and without a formal numerical
   analysis, I can imagine large ULP errors near zeros and 
   infinities.

I haven't looked at the implementation yet, but will suggest that
REAL(4) should probably be simply written in terms of REAL(8),
e.g., 

function sind(x) result(retval)
   real(4) retval
   real(4), intent(in) :: x
   retval = dsind(real(x, 8)) 
end function sind

Yes, the layer of indirection and computations in REAL(8) 
will be slower, but you should have much improved accuracy.

-- 
Steve

Reply via email to