chakravala / AbstractTensors.jl

Tensor algebra abstract type interoperability setup

Home Page:https://grassmann.crucialflow.com/dev/design

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

isapprox broken

UlrikBuchholtz opened this issue · comments

This lead to some head-scratching until I figured out the problem was not in my code.
When comparing TensorGraded or TensorAlgebra elements, the current code only compares the norms.
This leads to puzzling results, for instance you can have two vectors of equal norm (hence approximately equal in the current library), but different as MultiVectors (say, after adding the zero scalar).

Alright, I found an example, I will look into it, but currently do not maintain Grassmann for free for people, so I may not immediately provide a fix for it, just whenever I feel like fixing it at some point.

julia> (v2 + v1)  (v3+v1)
true

Next time, provide an example when opening an issue like this, or your issue may be ignored.

Also, adding a zero scalar does not create a MultiVector as you can see here:

julia> v2 + 0
v₂

julia> dump(ans)
SubManifold{⟨×××⟩,1,0x0000000000000002} v₂

No, you seem to be mistaken, that's not how the code works. Did you test it or just read the code without testing?

Of course I tested:

julia> using Grassmann

julia> basis"3"
(⟨×××⟩, v, v₁, v₂, v₃, v₁₂, v₁₃, v₂₃, v₁₂₃)

julia> isapprox(1.0v1+0.0v2,0.0v1+1.0v2)
true

julia> isapprox(0.0v+1.0v1+0.0v2,0.0v+0.0v1+1.0v2)
false

If you are unable to supply an actual example demonstrating the problem, this issue will be ignored.

BTW I don't appreciate this attitude for a first reply. As you can see, I'm happy to provide an example, but the behavior is already clear from the quoted code.

Also, adding a zero scalar does not create a MultiVector as you can see here:

Try instead:

julia> typeof(1.0v1+0.0v2)
Chain{⟨×××⟩,1,Float64,3}

julia> typeof(0.0v+1.0v1+0.0v2)
MultiVector{⟨×××⟩,Float64,8}

Cheers,
Ulrik

Thanks for sharing the example,

1.0v1+0.0v2

Here you are not adding a zero scalar, but a zero vector. That is different than what you first described.

Here you are not adding a zero scalar, but a zero vector. That is different than what you first described.

That's just to get a vector (Chain) instead of a SubManifold. In the following lines I add 0.0v (a zero scalar) to this to get a MultiVector. But it's worth pointing out that the problematic isapprox also happens on SubManifolds:

julia> isapprox(v1,v2)
true

Thank you for pointing this issue out. The isapprox method has been problematic from the start, due to the large range of possible input values it can have.

Fixing the issue may require creating many special cases for different combinations, which I did not care about for my own use at the moment, but I will look into it when I have some time available.

BTW I don't appreciate this attitude for a first reply, As you can see, I'm happy to provide an example

Sorry about that, please be aware that in this software there are more possible types of inputs than I care to personally test and verify myself on my free time (and I have always been working for free on this project alone).

So if you wanted a more pleasant response from me, don't ask me to do extra work to figure out what problems you are personally experiencing with the software. It is not my job or responsibility to understand and fix the exact issues you are having, so providing full examples would be nicer of you. Be aware that when I wake up in the morning to an issue like this, it is annoying that I have to use my own free time to figure out what your problem is, instead you could have immediately showed exactly what you are talking about to fully minimize the time I spend figuring out in miscommunication.

Thanks for the feedback. I had tried to make it very easy for you by digging around a bit myself and then directly pointing you to the problematic line of code (which visibly does the wrong thing). Of course you're right that it would be even more helpful to have a triggering instance, so I'm sorry about that.

I would have proposed a fix myself in a PR, but I've just started playing with Julia, so I don't know the most idiomatic ways of doing things yet.

And let me also take this opportunity to thank you for making the library and making it available: I'm using it to make some visualizations of finite subgroups of orthogonal groups. This issue can easily be circumvented by coercing to MultiVectors before calling isapprox.

Best wishes,
Ulrik

If you share your work on visualization of groups with Grassmann, then I would be happy to get this fixed sooner. I will email you with my email address (which is not officially public), in case you want to discuss that privately.

@UlrikBuchholtz the issue has now been fixed with a more robust implementation

apologies for responding so late, I really needed a break from my computer

I am now returning to maintaining this project and will likely to respond faster next time

happy new year!