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

matrix<double> operator == performs false on identical matrices #1089

Open
Anatom70 opened this issue Aug 19, 2024 · 6 comments
Open

matrix<double> operator == performs false on identical matrices #1089

Anatom70 opened this issue Aug 19, 2024 · 6 comments

Comments

@Anatom70
Copy link

I create an int random symmetrical matrix and calculate the transposed matrix, which should be identical.
The matrix == operator compiles, but performs false on comparison,
An extended method, which compares the matrices element by element performs true

@jkalias
Copy link
Member

jkalias commented Sep 28, 2024

Can you please provide a code snippet which demonstrates this behavior?

@Anatom70
Copy link
Author

Anatom70 commented Sep 28, 2024 via email

@jkalias
Copy link
Member

jkalias commented Sep 28, 2024

What do you mean it's not reproducible?
Can you provide a code snippet for this 12x12 matrix? Or at bare minimum print out the matrix for which this happens, otherwise the bug can't be fixed.

@Anatom70
Copy link
Author

Anatom70 commented Sep 28, 2024 via email

@jkalias
Copy link
Member

jkalias commented Sep 28, 2024

Wow, this is a bit...difficult to read :)
Could you please repost it, but not from an email client? Perhaps directly in github.com?
Thank you for effort though

@wo80
Copy link

wo80 commented Nov 5, 2024

The == operator is defined for every .NET reference type, see https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/equality-operators#reference-types-equality

Since Math.NET doesn't overload this operator, the == test will fail (you are comparing two different objects), but the call to Equals succeeds since the method is overloaded indeed, see https://github.com/mathnet/mathnet-numerics/blob/master/src/Numerics/LinearAlgebra/Matrix.BCL.cs#L51

So the question is, whether the == operator should be implemented in Math.NET.

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

No branches or pull requests

3 participants