Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in SpecialFunctions.Hypotenuse #1071

Open
lellid opened this issue Mar 21, 2024 · 1 comment · May be fixed by #1072
Open

Bug in SpecialFunctions.Hypotenuse #1071

lellid opened this issue Mar 21, 2024 · 1 comment · May be fixed by #1072

Comments

@lellid
Copy link

lellid commented Mar 21, 2024

Hello, the implementation of Hypotenuse is buggy. The following test fails:

[Fact]
void TestHypotenuse()
{
  Assert.True(double.IsNaN(SpecialFunctions.Hypotenuse(double.NaN, 0)));
}

This has severe consequences, because e.g. the following test also fails:

 [Fact]
 void TestL2Norm()
 {
   var v = Vector<double>.Build.Dense([double.NaN, 0]);
   Assert.True(double.IsNaN(v.L2Norm()));
 }

Best regards, Dirk

@lellid
Copy link
Author

lellid commented Mar 22, 2024

Please have a look at the implementation of System.Numerics.Complex.Magnitude. If it not affects performance, you can it even call directly in Hypotenuse.

Dirk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant