This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Fritz Reese <fritzoreese at gmail dot com>
- Cc: fortran <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 28 Sep 2016 11:55:33 -0700
- Subject: Re: [PATCH, Fortran] Extension: COTAN and degree-valued trig intrinsics with -fdec-math
- Authentication-results: sourceware.org; auth=none
- References: <CAE4aFAmL5Shx7rKt1fuCF9vXZtTGy_8VNd38NfCYzuPp69tHXA@mail.gmail.com>
- Reply-to: kargl at uw dot edu
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