-
Notifications
You must be signed in to change notification settings - Fork 236
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
New options added and bugs fixed in ConwayPolynomials #1179
Changes from 1 commit
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 |
---|---|---|
|
@@ -10,24 +10,28 @@ newPackage( | |
Headline => "a database of Conway polynomials" | ||
) | ||
-- the data comes libflint | ||
export "conwayPolynomial" | ||
export { | ||
"conwayPolynomial", | ||
-- options to set the variable to use | ||
"Variable" | ||
} | ||
rawConwayPolynomial := value Core#"private dictionary"#"rawConwayPolynomial" | ||
getCP := (p,n) -> rawConwayPolynomial (p,n,false) | ||
Ap := memoize(p -> (ZZ/p)(monoid [getSymbol "a"])) | ||
Ap := memoize((p, a) -> (ZZ/p)(monoid [a])) | ||
fix := (p,n,co,a) -> sum(#co, i -> co#i * a^i) | ||
conwayPolynomial = method() | ||
conwayPolynomial(ZZ,ZZ) := (p,n) -> ( | ||
conwayPolynomial = method(Options=>{Variable=>getSymbol "a"}) | ||
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 think that if you run ' installPackage "ConwayPolynomials" ', this change will lead to a problem -- the error message will be something like " can't determine package of symbol a ". The solution will be to let the default value be the string "a", and run getSymbol later. 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 rewrite this part by following the code in |
||
conwayPolynomial(ZZ,ZZ) := opts -> (p,n) -> ( | ||
cp := getCP(p,n); | ||
if cp != {} then fix(p,n,cp,(Ap p)_0)) | ||
conwayPolynomial ZZ := q -> ( | ||
if cp != {} then fix(p,n,cp,(Ap(p, opts.Variable))_0)) | ||
conwayPolynomial ZZ := opts -> q -> ( | ||
factors := factor q; | ||
if #factors =!= 1 or factors#0#0 === -1 | ||
then error "expected a power of a prime"; | ||
conwayPolynomial(factors#0#0,factors#0#1)) | ||
conwayPolynomial(factors#0#0,factors#0#1,opts)) | ||
addHook(GaloisField,FindOne,(p,n,a) -> ( | ||
cp := getCP(p,n); | ||
if cp != {} then break fix(p,n,cp,a))) | ||
isConway := (F) -> (gens ideal ambient F)_(0,0) == sub(conwayPolynomial(F.char,F.degree),ambient ambient F) | ||
isConway := (F) -> (gens ideal ambient F)_(0,0) == sub(conwayPolynomial(F.char,F.degree, Variable=>F_0),ambient ambient F) | ||
map(GaloisField,GaloisField) := RingMap => o -> (K,F) -> ( | ||
p := char F; | ||
n := K.degree; | ||
|
@@ -71,9 +75,10 @@ document { | |
Key => {conwayPolynomial, (conwayPolynomial,ZZ,ZZ), (conwayPolynomial,ZZ)}, | ||
Headline => "provide a Conway polynomial", | ||
SYNOPSIS ( | ||
Usage => "conwayPolynomial q", | ||
Usage => "conwayPolynomial(q,Variable=>a)", | ||
Inputs => { | ||
"q" => ZZ => {"a power of a prime number"} | ||
"q" => ZZ => {"a power of a prime number"}, | ||
"a" => Symbol => {"an optional input, the symbol served as variable, default a"} | ||
}, | ||
Outputs => { | ||
{"a Conway polynomial whose roots generate a field with q elements"} | ||
|
@@ -83,16 +88,17 @@ document { | |
/// | ||
), | ||
SYNOPSIS ( | ||
Usage => "conwayPolynomial(p,n)", | ||
Usage => "conwayPolynomial(p,n,Variable=>a)", | ||
Inputs => { | ||
"p" => ZZ => {"a prime number"}, | ||
"n" => ZZ | ||
"n" => ZZ, | ||
"a" => Symbol => {"an optional input, the symbol served as variable, default a"} | ||
}, | ||
Outputs => { | ||
{"a Conway polynomial whose roots generate a field with p^n elements"} | ||
{"a Conway polynomial whose roots generate a field with ", TEX "p^n", " elements"} | ||
}, | ||
EXAMPLE lines /// | ||
conwayPolynomial(2,20) | ||
conwayPolynomial(2,20,Variable=>"b") | ||
/// | ||
) | ||
} | ||
|
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.
"Variable" is a symbol in the Core package, so just use it -- don't export a new one with the same name.
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.
Gotcha! Just changed!