aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2011-03-10 18:14:47 +0000
committerdos-reis <gdr@axiomatics.org>2011-03-10 18:14:47 +0000
commit3018eca8731c1ebfc07487d6ba305c82090b4dca (patch)
tree2977f65419c43b201a65e63a8bcf55dfaa443639 /src
parentd39e317cd51e0f251d485df1948e2a85a4007048 (diff)
downloadopen-axiom-3018eca8731c1ebfc07487d6ba305c82090b4dca.tar.gz
* algebra/catdef.spad.pamphlet (CharacteristicNonZero)
[charthRoot]: Now return Maybe %. (PolynomialFactorizationExplicit) [charthRoot]: Likewise. * algebra/ffcat.spad.pamphlet (FiniteAlgebraicExtensionField): Propagate change. * algebra/fraction.spad.pamphlet (Fraction) [charthRoot]: Likewise. * algebra/poly.spad.pamphlet (UnivariatePolynomialSquareFree): Likewise. * algebra/polycat.spad.pamphlet (PolynomialCategory): Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog12
-rw-r--r--src/algebra/catdef.spad.pamphlet16
-rw-r--r--src/algebra/ffcat.spad.pamphlet8
-rw-r--r--src/algebra/fraction.spad.pamphlet10
-rw-r--r--src/algebra/poly.spad.pamphlet4
-rw-r--r--src/algebra/polycat.spad.pamphlet18
6 files changed, 41 insertions, 27 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index c29408c4..8379f759 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,17 @@
2011-03-10 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * algebra/catdef.spad.pamphlet (CharacteristicNonZero)
+ [charthRoot]: Now return Maybe %.
+ (PolynomialFactorizationExplicit) [charthRoot]: Likewise.
+ * algebra/ffcat.spad.pamphlet (FiniteAlgebraicExtensionField):
+ Propagate change.
+ * algebra/fraction.spad.pamphlet (Fraction) [charthRoot]: Likewise.
+ * algebra/poly.spad.pamphlet (UnivariatePolynomialSquareFree):
+ Likewise.
+ * algebra/polycat.spad.pamphlet (PolynomialCategory): Likewise.
+
+2011-03-10 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/c-util.boot (equalFormTemplate): Tidy comparison of value
argument to constructors.
diff --git a/src/algebra/catdef.spad.pamphlet b/src/algebra/catdef.spad.pamphlet
index 694d169f..7dfc10fc 100644
--- a/src/algebra/catdef.spad.pamphlet
+++ b/src/algebra/catdef.spad.pamphlet
@@ -377,7 +377,7 @@ CancellationAbelianMonoid(): Category == AbelianMonoid with
++ Description:
++ Rings of Characteristic Non Zero
CharacteristicNonZero():Category == Ring with
- charthRoot: % -> Union(%,"failed")
+ charthRoot: % -> Maybe %
++ charthRoot(x) returns the pth root of x
++ where p is the characteristic of the ring.
@@ -1706,9 +1706,9 @@ PolynomialFactorizationExplicit(): Category == Definition where
++ whose \spad{p}-th powers (p is the characteristic of the domain)
++ are a solution of the homogenous linear system represented
++ by m, or "failed" is there is no such vector.
- charthRoot: % -> Union(%,"failed")
- ++ charthRoot(r) returns the \spad{p}-th root of r, or "failed"
- ++ if none exists in the domain.
+ charthRoot: % -> Maybe %
+ ++ charthRoot(r) returns the \spad{p}-th root of r, or
+ ++ \spad{nothing} if none exists in the domain.
-- this is a special case of conditionP, but often the one we want
add
gcdPolynomial(f,g) ==
@@ -1725,11 +1725,13 @@ PolynomialFactorizationExplicit(): Category == Definition where
-- to take p'th root of f, solve the system X-fY=0,
-- so solution is [x,y]
-- with x^p=X and y^p=Y, then (x/y)^p = f
- zero? f => 0
+ zero? f => just 0
m:Matrix % := matrix [[1,-f]]
ans:= conditionP m
- ans case "failed" => "failed"
- (ans.1) exquo (ans.2)
+ ans case "failed" => nothing
+ r := (ans.1) exquo (ans.2)
+ r case "failed" => nothing
+ just r
if % has Field then
solveLinearPolynomialEquation(lf,g) ==
multiEuclidean(lf,g)$P
diff --git a/src/algebra/ffcat.spad.pamphlet b/src/algebra/ffcat.spad.pamphlet
index 78a1c6a3..621ea017 100644
--- a/src/algebra/ffcat.spad.pamphlet
+++ b/src/algebra/ffcat.spad.pamphlet
@@ -349,8 +349,8 @@ FiniteAlgebraicExtensionField(F : Field) : Category == _
v:=first nullSpace transpose matrix(l)$(Matrix F)
+/[monomial(v.(i+1),i::NNI) for i in 0..(#v-1)]
- charthRoot(x):Union($,"failed") ==
- (charthRoot(x)@$)::Union($,"failed")
+ charthRoot(x): Maybe % ==
+ just(charthRoot(x)@%)
-- norm(e) == norm(e,1) pretend F
-- trace(e) == trace(e,1) pretend F
minimalPolynomial(a,n) ==
@@ -597,8 +597,8 @@ FiniteFieldCategory() : Category ==_
empty? l or every?(zero?, first l) => "failed"
map(charthRoot,first l)
charthRoot(x:$):$ == x**(size()$% quo characteristic$%)
- charthRoot(x:%):Union($,"failed") ==
- (charthRoot(x)@$)::Union($,"failed")
+ charthRoot(x:%): Maybe % ==
+ just(charthRoot(x)@%)
createPrimitiveElement() ==
sm1 : PositiveInteger := (size()$%-1) pretend PositiveInteger
start : Integer :=
diff --git a/src/algebra/fraction.spad.pamphlet b/src/algebra/fraction.spad.pamphlet
index 1e691362..a6295219 100644
--- a/src/algebra/fraction.spad.pamphlet
+++ b/src/algebra/fraction.spad.pamphlet
@@ -551,18 +551,18 @@ Fraction(S: IntegralDomain): QuotientFieldCategory S with
if S has canonicalUnitNormal and S has GcdDomain then
charthRoot x ==
n:= charthRoot x.num
- n case "failed" => "failed"
+ n case nothing => nothing
d:=charthRoot x.den
- d case "failed" => "failed"
- n/d
+ d case nothing => nothing
+ just(n/d)
else
charthRoot x ==
-- to find x = p-th root of n/d
-- observe that xd is p-th root of n*d**(p-1)
ans:=charthRoot(x.num *
(x.den)**(characteristic$%-1)::NonNegativeInteger)
- ans case "failed" => "failed"
- ans / x.den
+ ans case nothing => nothing
+ just(ans / x.den)
clear: List % -> List S
clear l ==
d:="lcm"/[x.den for x in l]
diff --git a/src/algebra/poly.spad.pamphlet b/src/algebra/poly.spad.pamphlet
index e0688ad4..42c1eab2 100644
--- a/src/algebra/poly.spad.pamphlet
+++ b/src/algebra/poly.spad.pamphlet
@@ -881,7 +881,7 @@ UnivariatePolynomialSquareFree(RC:IntegralDomain,P):C == T
else if RC has CharacteristicNonZero then
BumInSepFFE(ffe:FF) ==
np := multiplyExponents(ffe.fctr,characteristic$P:NonNegativeInteger)
- (nthrp := charthRoot(np)) case "failed" =>
+ (nthrp := charthRoot(np)) case nothing =>
["nil", np, ffe.xpnt]
["sqfr", nthrp, characteristic$P*ffe.xpnt]
@@ -1010,7 +1010,7 @@ PolynomialSquareFree(VarSet:OrderedSet,E,RC:GcdDomain,P):C == T where
pthPower(f:P) : Factored P ==
proot : P := 0
isSq : Boolean := false
- if (g:=charthRoot f) case "failed" then proot:=pPolRoot(f)
+ if (g:=charthRoot f) case nothing then proot:=pPolRoot(f)
else
proot := g :: P
isSq := true
diff --git a/src/algebra/polycat.spad.pamphlet b/src/algebra/polycat.spad.pamphlet
index 499b3903..140fc069 100644
--- a/src/algebra/polycat.spad.pamphlet
+++ b/src/algebra/polycat.spad.pamphlet
@@ -520,36 +520,36 @@ PolynomialCategory(R:Ring, E:OrderedAbelianMonoidSup, VarSet:OrderedSet):
for mons in monslist]
if R has CharacteristicNonZero then
- charthRootlv: (%,List VarSet,NonNegativeInteger) -> Union(%,"failed")
+ charthRootlv: (%,List VarSet,NonNegativeInteger) -> Maybe %
charthRoot p ==
vars:= variables p
empty? vars =>
ans := charthRoot ground p
- ans case "failed" => "failed"
- ans::R::%
+ ans case nothing => nothing
+ just(ans::R::%)
ch:=characteristic$%
charthRootlv(p,vars,ch)
charthRootlv(p,vars,ch) ==
empty? vars =>
ans := charthRoot ground p
- ans case "failed" => "failed"
- ans::R::%
+ ans case nothing => nothing
+ just(ans::R::%)
v:=first vars
vars:=rest vars
d:=degree(p,v)
ans:% := 0
while (d>0) repeat
(dd:=(d::Integer exquo ch::Integer)) case "failed" =>
- return "failed"
+ return nothing
cp:=coefficient(p,v,d)
p:=p-monomial(cp,v,d)
ansx:=charthRootlv(cp,vars,ch)
- ansx case "failed" => return "failed"
+ ansx case nothing => return nothing
d:=degree(p,v)
ans:=ans+monomial(ansx,v,dd::Integer::NonNegativeInteger)
ansx:=charthRootlv(p,vars,ch)
- ansx case "failed" => return "failed"
- return ans+ansx
+ ansx case nothing => return nothing
+ return just(ans+ansx)
monicDivide(p1,p2,mvar) ==
result:=monicDivide(univariate(p1,mvar),univariate(p2,mvar))