-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Removing requirement for promotions from 0,1 in lufact #22146
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -310,3 +310,33 @@ end | |
@test [[1, 2], [3, 4]] ≈ [[1.0-eps(), 2.0+eps()], [3.0+2eps(), 4.0-1e8eps()]] | ||
@test [[1, 2], [3, 4]] ≉ [[1.0-eps(), 2.0+eps()], [3.0+2eps(), 4.0-1e9eps()]] | ||
@test [[1,2, [3,4]], 5.0, [6im, [7.0, 8.0]]] ≈ [[1,2, [3,4]], 5.0, [6im, [7.0, 8.0]]] | ||
|
||
# Issue 22042 | ||
# Minimal modulo number type - but not subtyping Number | ||
struct ModInt{n} | ||
k | ||
ModInt{n}(k) where {n} = new(mod(k,n)) | ||
end | ||
|
||
Base.:+(a::ModInt{n}, b::ModInt{n}) where {n} = ModInt{n}(a.k + b.k) | ||
Base.:-(a::ModInt{n}, b::ModInt{n}) where {n} = ModInt{n}(a.k - b.k) | ||
Base.:*(a::ModInt{n}, b::ModInt{n}) where {n} = ModInt{n}(a.k * b.k) | ||
Base.:-(a::ModInt{n}) where {n} = ModInt{n}(-a.k) | ||
Base.inv(a::ModInt{n}) where {n} = ModInt{n}(invmod(a.k, n)) | ||
Base.:/(a::ModInt{n}, b::ModInt{n}) where {n} = a*inv(b) | ||
|
||
Base.zero(::Type{ModInt{n}}) where {n} = ModInt{n}(0) | ||
Base.zero(::ModInt{n}) where {n} = ModInt{n}(0) | ||
Base.one(::Type{ModInt{n}}) where {n} = ModInt{n}(1) | ||
Base.one(::ModInt{n}) where {n} = ModInt{n}(1) | ||
|
||
# Needed for pivoting: | ||
Base.abs(a::ModInt{n}) where {n} = a | ||
Base.:<(a::ModInt{n}, b::ModInt{n}) where {n} = a.k < b.k | ||
Base.transpose(a::ModInt{n}) where {n} = a # see Issue 20978 | ||
|
||
A = [ ModInt{2}(1) ModInt{2}(0) ; ModInt{2}(1) ModInt{2}(1) ] | ||
b = [ ModInt{2}(1), ModInt{2}(0) ] | ||
|
||
@test A*(A\b) == b | ||
@test_nowarn lufact( A, Val{true} ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This errored before this PR. Why test for warning? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't sure of the correct way to handle this. It seemed strange to call the function and then return true, since the real test was the function call compiled and returned something successfully. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not actually call
lufact
(sinceistril(A) == true
), wasn't that the purpose of this PR?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is true that I haven't succeed in my original goal, but we are closer. If you make my test matrix not lower triangular, it fails! I think there needs to be a third option for pivoting - where the pivot is chosen by !iszero(..) and not by magnitude. Ultimately I'd like to be able to delete
from my test, but this requires a bigger discussion. One suggestion has been to have a symbol as the parameter value instead of the Bool pivot = true or false.
I'm not sure how to proceed - do I open up a new issue or PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arghhhh see https://github.com/JuliaLang/julia/issues/22042#issuecomment-305790104