octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #59615] feature request for sinpi, cospi, yyax


From: Rik
Subject: [Octave-bug-tracker] [bug #59615] feature request for sinpi, cospi, yyaxis functions
Date: Fri, 4 Dec 2020 20:42:43 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36

Follow-up Comment #4, bug #59615 (project octave):

C11 (C language standard from 2011) added sinpi, cospi functions as an
extension.  However, there hasn't been uniform pickup by C libraries.  There
is no sinpi module in gnulib so we can't get it via that route.  One could
have some OS-specific tests in configure.ac to try and locate these functions,
but it is tedious because the functions will have different names on different
platforms and it will require a chain of #ifdef/#elif#elif#endif.

The code for sind is relatively simple and I quote it here:


  I = x / 180;
  y = sin (I .* pi);
  y(I == fix (I) & isfinite (I)) = 0;


In this case, you wouldn't need to divide by 180---that is for the conversion
to degrees---but you would have to add another test for half-integer multiples
which must return exactly 1 or -1.  It's possible that the sin() function
already has an optimization for that because I tried some multiples of pi and
didn't find any result other than 1 or -1.  But, otherwise, a test like this
might work.


I -= .5;
idx = I == fix (I) & isfinite (I);
y(idx) = sign (y(idx));


In C or C++ there is probably a fancy way to check for exact integers or half
integers with bit operations on the mantissa.  That sort of code, however, is
beyond me.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?59615>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]