mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Gabriel Ravier <gabravier@gmail.com>
To: musl@lists.openwall.com,
	Nikolaos Chatzikonstantinou <nchatz314@gmail.com>
Subject: Re: [musl] Re: Implementing csqrtl()
Date: Wed, 29 May 2024 02:38:22 +0200	[thread overview]
Message-ID: <724090dc-83e7-4f40-9ff2-1a60196b9966@gmail.com> (raw)
In-Reply-To: <CAAQmekcAbUAWLPYNAwUa075hau_0_GHmOOgL2rkdYLJzL0x5rw@mail.gmail.com>

On 5/28/24 10:48 PM, Nikolaos Chatzikonstantinou wrote:
> On Mon, Jul 4, 2022 at 5:35 AM Nikolaos Chatzikonstantinou
> <nchatz314@gmail.com> wrote:
>> Hello list,
>>
>> I wanted to implement some function from
>> <https://wiki.musl-libc.org/open-issues.html#Complex-math>
>> which is an open issue in the wiki.
>>
>> One of the missing complex functions is csqrtl(), the long double
>> version of complex square root. I was able to find a 1987 article from
>> W. Kahan, titled "Branch cuts for complex elementary functions." that
>> contained an implementation for complex square root for arbitrary
>> floating-point numbers. In this e-mail you'll find an attached git
>> patch with the implementation.
>>
>> As a very basic test, I wrote a program that produces random
>> complex numbers in the square [0, N] x [0, N] for N=1,100 and
>> calculates csqrt{,f,l}() with my implementation, glibc and the
>> arbitrary precision mpc_sqrt() from MPC,
>> <https://www.multiprecision.org/mpc/>.
>>
>> Glibc stays almost within 1 ulp in float and double, but my
>> implementation wasn't so good with float. The double
>> implementation seems to get the exact same results as glibc does.
>>
>> I was not able to even test the long double version with this
>> method, because I did not write the code that produces random
>> long double complex numbers yet.
>>
>> There's a few things that I don't quite understand here. One is, I'm
>> not sure why Kahan's implementation is accurate. For another, I don't
>> know how to do any sort of speed tests; I've read online that
>> microbenchmarking is not reproducible for math functions, and so
>> google's benchmark <https://github.com/google/benchmark> does not seem
>> to help. Of course I'm aware that the C implementation would not be
>> the one used in most systems, as the assembly implementations are
>> usually better. Finally, I don't know what the right way to test an
>> implementation for accuracy is: whether by using automation or writing
>> proofs. It seems the state of the art has evolved quite a bit from
>> 1987, and yet I don't know where to look for information on this
>> topic, as it seems very specific to chips & the C std lib.
>>
>> Feel free to provide any sort of criticism. I'm e-mailing this
>> implementation for the purpose of starting a discussion, but I'm
>> hoping to be able to contribute something in the near future.
> Hello, I want to revive the discussion on this message. Last time I
> attached the patch I was ignored, apart from some nitpicks on the C
> source in the patch, which was a draft anyway. Missing complex math
> functions are still an open issue. I can't help but think that last
> time I was ignored apart from some nitpick on some signed/unsigned
> type, as if getting schooled on C is the purpose of the mailing list
> -- bizarre! the patch was a draft to start a discussion on resolving
> the complex math issue. What I concluded from the responses I received
> is that the musl project does not have a maintainer who is capable of
> understanding the underlying issues with the complex math algorithms
> in libc. Is that still the case and is there any interest in resolving
> it perhaps by finding a maintainer who can work on this issue?


I cannot read people's minds to determine exactly why it is that they 
did not thoroughly review the implementation but my guess would be that, 
unable to understand the mathematical details of how the code worked, 
they only reviewed the parts of it they were more familiar with (e.g. 
the "nitpick on some signed/unsigned type") - I guess it makes sense it 
would seem odd as the only thing to get reviewed at all, but normally 
those parts would also get reviewed regardless even if people were 
better able to understand the mathematics of the patch.


>
> Regards,
> Nikolaos Chatzikonstantinou



  reply	other threads:[~2024-05-29  0:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-04  9:35 [musl] " Nikolaos Chatzikonstantinou
2022-07-04 11:09 ` [musl] " Nikolaos Chatzikonstantinou
2022-07-05  9:37   ` Szabolcs Nagy
2022-07-05 14:28     ` Nikolaos Chatzikonstantinou
2022-07-05 15:35       ` Markus Wichmann
2022-07-05 16:14         ` Nikolaos Chatzikonstantinou
2024-05-29  1:38           ` Rich Felker
2024-05-28 20:48 ` Nikolaos Chatzikonstantinou
2024-05-29  0:38   ` Gabriel Ravier [this message]
2024-05-29  1:34     ` Rich Felker
     [not found]       ` <CAAQmekdsDO=KuJ4CuVjTnTU8Baz3++LdUr=TeKJ4bcLTfJ+1gA@mail.gmail.com>
2024-05-29 12:59         ` Rich Felker
2024-05-29 15:13           ` James Y Knight
2024-05-31 15:37             ` Szabolcs Nagy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=724090dc-83e7-4f40-9ff2-1a60196b9966@gmail.com \
    --to=gabravier@gmail.com \
    --cc=musl@lists.openwall.com \
    --cc=nchatz314@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).