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

Float64, Double64 and BigFloat behave differently in dot products #161

Open
andreasvarga opened this issue Jan 24, 2023 · 1 comment
Open

Comments

@andreasvarga
Copy link

The following results are occasionally obtained for randomly generated vectors:

julia> using DoubleFloats
julia> n = 10;
julia> Ty = Double64; c = rand(Ty,n)+im*rand(Ty,n); d = rand(Ty,n)+im*rand(Ty,n); c'*d-conj(d'*c)      
0.0 - 1.5407439555097887e-33im
julia> Ty = Double64; c = rand(Ty,n)+im*rand(Ty,n); d = rand(Ty,n)+im*rand(Ty,n); c'*d-conj(d'*c)
-4.930380657631324e-32 + 3.0814879110195774e-33im
julia> Ty = Double64; c = rand(Ty,n); d = rand(Ty,n); c'*d-d'*c
-2.465190328815662e-32

The discrepancies never occur for other type of floating point data:

julia> Ty = Float64; c = rand(Ty,n)+im*rand(Ty,n); d = rand(Ty,n)+im*rand(Ty,n); c'*d-conj(d'*c)       
0.0 + 0.0im
julia> Ty = BigFloat; c = rand(Ty,n)+im*rand(Ty,n); d = rand(Ty,n)+im*rand(Ty,n); c'*d-conj(d'*c)      
0.0 + 0.0im
julia> Ty = BigFloat; c = rand(Ty,n); d = rand(Ty,n); c'*d-d'*c
0.0

I wonder if this behaviour is the expected one for DoubleFloat data ?

@andreasvarga
Copy link
Author

And even

julia> Ty = Double64; c = rand(Ty,1) ; d =rand(Ty,1); c[1]*d[1]-d[1]*c[1]
1.5407439555097887e-33

Thus, the multiplication is not commutative?

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

1 participant