-
Notifications
You must be signed in to change notification settings - Fork 40
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
linear diophantine equations #220
base: master
Are you sure you want to change the base?
Changes from 1 commit
ec47fb5
2817b60
4253b9a
90559ca
6a05d35
e6804a1
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
{-# LANGUAGE CPP #-} | ||
|
||
{-# LANGUAGE RecordWildCards, GADTs #-} | ||
{-# OPTIONS_GHC -fno-warn-type-defaults #-} | ||
|
||
module Math.NumberTheory.DiophantineTests | ||
|
@@ -33,8 +34,17 @@ cornacchiaBruteForce (Positive d) (Positive a) = gcd d m /= 1 || findSolutions [ | |
where x2 = m - d*y*y | ||
x = integerSquareRoot x2 | ||
|
||
linearTest :: (a ~ Integer) => a -> a -> a -> a -> Bool | ||
linearTest a b c k = | ||
case solveLinear Lin {..} of | ||
Nothing -> True -- Disproving this would require a counter example | ||
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. The problem is that 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. Yes! I think this is easier to see in terms of my Pogo problem |
||
Just ls | (x, y) <- runLinearSolution ls k | ||
-> a*x + b*y == c | ||
|
||
|
||
testSuite :: TestTree | ||
testSuite = testGroup "Diophantine" | ||
[ testSmallAndQuick "Cornacchia correct" cornacchiaTest | ||
, testSmallAndQuick "Cornacchia same solutions as brute force" cornacchiaBruteForce | ||
, testSmallAndQuick "Linear correct" linearTest | ||
] |
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.
Is it difficult to provide full type signatures?