Open infogulch opened 3 years ago
For now the best solution is to use LinearAlgebraX.jl for this use case.
I'll leave this bug open; maybe we can depend on LinearAlgebraX and add implementations like det(a::AbstractMatrix{<:GaloisField}) = detx(a)
.
I did try the obvious defining abs:
abs(x::F) = x
But that didn't have any effect.
FWIW for adding methods to functions from Base
you have to qualify them:
Base.abs(x::F) = x
But in this case it will just complain about other methods next.
Wonderful, thank you for the direction and pointers!
maybe we can depend on LinearAlgebraX and add implementations
That sounds like it would be neat; though I might worry about adding a dependency for users that don't use that feature. I'm not sure I've ever encountered this in a software engineering context, multiple dispatch adds a lot of new capabilities to tie libraries together, but also brings some new problems to solve. I wonder if the community has a general strategy for this yet.
Perhaps a simple mention in the readme would be sufficient:
If you want to use GaloisFields with matrices look at the LinearAlgebraX ("Exact linear algebra functions") package.
So I tried to use LinearAlgebraX, but I ran into an issue where the result of the vector numeric equality binary operation results an array of GaloisField values instead of booleans:
using GaloisFields, LinearAlgebraX
const F = @GaloisField β€/257β€
print(F(10) == 0) # "false" -- ok
print([F(10) F(8)] .== 0) # π½ββ
β[0 0] -- ??? I expect [false false] instead
all([F(10) F(8)] .== 0) # TypeError: non-boolean (π½ββ
β) used in boolean context
This is used in LinearAlgebraX as part of the implementation of invx
.
Any ideas why that happens?
Oh interesting, using the extended GF form works fine:
const G = @GaloisField! 2^8 Ξ²
print([Ξ²^10 Ξ²^8] .== 0)
all([Ξ²^10 Ξ²^8] .== 0)
Bool[0 0] false
@infogulch Thanks for reporting the bug about broadcasting ==
. This is a bug in GaloisFields.jl and I'm opening #16 for you.
Great, thanks! If I find something else I'll put it in a new issue next time. π
This subject discussed here as well
Hi! I'm trying to use
GaloisFields
as an element type in matrices, but I'm running into MethodErrors when using some of the stdlib matrix functions, some examples:I did try the obvious defining abs:
But that didn't have any effect.
The stack trace of one of the abs errors is:
And for conj:
I must admit I'm new to both Julia and GF, so it's quite possible I'm doing something wrong. π
Thoughts?