Waldek,
On Fri, Oct 9, 2009 at 8:55 PM, you wrote:
>> Bill Page wrote:
>> > ... so I modified 'FreeModuleCategory' as follows:
> <snip>
>> > to provide a default 'smaller?' operation inherited by the XPOLY domains.
>> >
>>
>> That looks like good change.
>>
>> > Testing revealed the 'constandOperator' problem. Then by changing:
>> >
>> > --- op.spad.pamphlet (revision 666)
>> > +++ op.spad.pamphlet (working copy)
>> > @@ -271,7 +271,7 @@
>> > derivative(op, [(l1: List(A)): A +-> f first l1]$List(List A -> A))
>> > error "Operator is not unary"
>> >
>> > - if A has OrderedSet then
>> > + if A has Comparable then
>> >
>> > I found the problem went away. We need at least Comparable in order to
>> > define 'ltconst?', 'opconst' and 'constOp'.
>> >
>>
>> Yes, at least without deeper changes we need Comparable to define
>> constOp, and constOp is needed in some versions of Expression.
>> So I think we should do the change you propose.
>>
>
> Bill, I am not sure if I was clear enough. I think that we should
> commit your patch from Septeber 12 with extra applyQuote chunk.
> The OrderedSet to Comparable change in op.spad.pamphlet should go
> in a separate patch together with patch to FreeModuleCategory.
>
> Can you do this?
>
Yes, I can do this. The applyQuote chunk is part the patch below. I
can separate it out and commit it.
Please also take a look at this patch. It removes the need for
Comparable when defining constOp.
wsp...@debian:~/my-fricas/src/algebra$ svn diff op.spad.pamphlet
Index: op.spad.pamphlet
===================================================================
--- op.spad.pamphlet (revision 675)
+++ op.spad.pamphlet (working copy)
@@ -234,11 +234,11 @@
++ derivative(op) returns the value of the "%diff" property of
++ op if it has one, and "failed" otherwise.
constantOperator: A -> OP
- ++ constantOperator(a) returns a nullary operator op
- ++ such that \spad{op()} always evaluate to \spad{a}.
+ ++ constantOperator(a) returns a nullary operator op
+ ++ such that \spad{op()} always evaluate to \spad{a}.
constantOpIfCan : OP -> Union(A, "failed")
- ++ constantOpIfCan(op) returns \spad{a} if op is the constant
- ++ nullary operator always returning \spad{a}, "failed" otherwise.
+ ++ constantOpIfCan(op) returns \spad{a} if op is the constant
+ ++ nullary operator always returning \spad{a}, "failed" otherwise.
Implementation ==> add
@@ -271,43 +271,46 @@
derivative(op, [(l1: List(A)): A +-> f first l1]$List(List A -> A))
error "Operator is not unary"
- if A has OrderedSet then
- cdisp : (OutputForm, List OutputForm) -> OutputForm
- csex : (InputForm, List InputForm) -> InputForm
- eqconst?: (OP, OP) -> Boolean
- ltconst?: (OP, OP) -> Boolean
- constOp : A -> OP
+ cdisp : (OutputForm, List OutputForm) -> OutputForm
+ csex : (InputForm, List InputForm) -> InputForm
+ eqconst?: (OP, OP) -> Boolean
+ constOp : A -> OP
- opconst:OP :=
- comparison(equality(operator('constant, 0), eqconst?),
- ltconst?)
+ cdisp(a, l) == a
+ csex(a, l) == a
- cdisp(a, l) == a
- csex(a, l) == a
-
- eqconst?(a, b) ==
- (va := property(a, CONST)) case "failed" => not has?(b, CONST)
- ((vb := property(b, CONST)) case None) and
- ((va::None) pretend A) = ((vb::None) pretend A)
-
+ eqconst?(a, b) ==
+ (va := property(a, CONST)) case "failed" => not has?(b, CONST)
+ ((vb := property(b, CONST)) case None) and
+ ((va::None) pretend A) = ((vb::None) pretend A)
+ if A has Comparable then
+ ltconst?: (OP, OP) -> Boolean
ltconst?(a, b) ==
(va := property(a, CONST)) case "failed" => has?(b, CONST)
((vb := property(b, CONST)) case None) and
- ((va::None) pretend A) < ((vb::None) pretend A)
-
+ smaller?((va::None) pretend A,(vb::None) pretend A)
+ opconst:OP :=
+ comparison(equality(operator('constant, 0), eqconst?), ltconst?)
constOp a ==
- setProperty(display(copy opconst, (l1: List(OutputForm)):
OutputForm +-> cdisp(a::OutputForm, l1)),
- CONST, a pretend None)
+ setProperty(display(copy opconst,
+ (l1: List(OutputForm)): OutputForm +-> cdisp(a::OutputForm, l1)),
+ CONST, a pretend None)
+ else
+ opconst:OP := equality(operator('constant, 0), eqconst?)
+ constOp a ==
+ setProperty(display(copy opconst,
+ (l1: List(OutputForm)): OutputForm +-> cdisp(a::OutputForm, l1)),
+ CONST, a pretend None)
- constantOpIfCan op ==
- is?(op, 'constant) and
- ((u := property(op, CONST)) case None) => (u::None) pretend A
- "failed"
+ constantOpIfCan op ==
+ is?(op, 'constant) and
+ ((u := property(op, CONST)) case None) => (u::None) pretend A
+ "failed"
- if A has ConvertibleTo InputForm then
- constantOperator a == input(constOp a, (l1:
List(InputForm)): InputForm +-> csex(convert a, l1))
- else
- constantOperator a == constOp a
+ if A has ConvertibleTo InputForm then
+ constantOperator a == input(constOp a, (l1: List(InputForm)):
InputForm +-> csex(convert a, l1))
+ else
+ constantOperator a == constOp a
@
\section{package COMMONOP CommonOperators}
@@ -380,7 +383,8 @@
opacsch := operator('acsch, 1)
opbox := operator('%box)$OP
oppren := operator('%paren)$OP
- opquote := operator('applyQuote)$OP
+ opquote := operator('%quote)$OP
+
opdiff := operator('%diff, 3)
opsi := operator('Si, 1)
opci := operator('Ci, 1)
wsp...@debian:~/my-fricas/src/algebra$
As you requested I will commit the last part above first. Then if you
agree I will commit the rest together with the patch below:
Index: poly.spad.pamphlet
===================================================================
--- poly.spad.pamphlet (revision 675)
+++ poly.spad.pamphlet (working copy)
@@ -80,6 +80,17 @@
++ \spad{coefficient(x,s)} returns the coefficient of the
basis element s
-- attributs
if R has CommutativeRing then Module(R)
+ if R has Comparable then Comparable
+ add
+ if R has Comparable then
+ smaller?(p:%,q:%):Boolean ==
+ if leadingMonomial(p)=leadingMonomial(q) then
+ if leadingCoefficient(p)=leadingCoefficient(q) then
+ smaller?(reductum p, reductum q)
+ else
+ smaller?(leadingCoefficient(p),leadingCoefficient(q))
+ leadingMonomial(p)<leadingMonomial(q)
+
@
\section{domain FM FreeModule}
wsp...@debian:~/my-fricas/src/algebra$
Regards,
Bill Page.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---