Bill Page wrote:
> 
> On Tue, Sep 30, 2008 at 3:21 PM, Waldek Hebisch wrote:
> >
> > Bill Page wrote:
> >>
> >> Waldek,
> >>
> >> Here is a follow up patch that further improves format.boot and
> >> unparse. It solves the problem demonstrated by your CliffordAlgebra
> >> example as illustrated below:
> >>
> 
> Here is version 2 of the patch addressing most of your comments below:
> 

I plan to include the following variant of this patch.  Compared to
Bill version this one fixes bootstrap problem, does not import
import List InputForm to QuadraticForm and handling of "OVER"
should be more robust.

diff -ru fricas.bb/src/algebra/clifford.spad.pamphlet 
fricas/src/algebra/clifford.spad.pamphlet
--- fricas.bb/src/algebra/clifford.spad.pamphlet        2008-10-25 
00:52:06.000000000 -0400
+++ fricas/src/algebra/clifford.spad.pamphlet   2008-10-25 00:53:40.000000000 
-0400
@@ -42,6 +42,8 @@
         elt: (%, V(n, K)) -> K
             ++ elt(qf,v) evaluates the quadratic form qf on the vector v, 
             ++ producing a scalar.
+        if SM(n, K) has ConvertibleTo InputForm then ConvertibleTo InputForm
+
 
     Impl ==> SM(n,K) add
         Rep := SM(n,K)
@@ -52,6 +54,11 @@
             m::%
         matrix q == q pretend SM(n,K)
         elt(q,v) == dot(v, (matrix q * v))
+ 
+        if SM(n, K) has ConvertibleTo InputForm then
+            convert(q:%):InputForm ==
+               convert(['quadraticForm,convert(matrix q)])$InputForm
+
 
 @
 \section{domain CLIF CliffordAlgebra\cite{7,12}}
Only in fricas/src/algebra: clifford.spad.pamphlet.orig
diff -ru fricas.bb/src/algebra/constant.spad.pamphlet 
fricas/src/algebra/constant.spad.pamphlet
--- fricas.bb/src/algebra/constant.spad.pamphlet        2008-10-25 
00:52:06.000000000 -0400
+++ fricas/src/algebra/constant.spad.pamphlet   2008-10-24 23:56:23.000000000 
-0400
@@ -30,7 +30,9 @@
                    LinearlyExplicitRingOver Z, RealConstant,
                    LinearlyExplicitRingOver Fraction Z,
                    CharacteristicZero,
-                   ConvertibleTo Complex Float, DifferentialRing) with
+                   ConvertibleTo Complex Float,
+                   ConvertibleTo InputForm,
+                   DifferentialRing) with
     coerce : P -> %
       ++ coerce(p) returns p viewed as an algebraic number.
     numer  : % -> P
@@ -135,6 +137,9 @@
        z
     belong? op           == belong?(op)$ExpressionSpace_&(%) or has?(op, ALGOP)
 
+    convert(x:%):InputForm ==
+      convert(x pretend Rep)$Rep
+
     convert(x:%):Float ==
       retract map(#1::Float, x pretend FE)$ExpressionFunctions2(Z,Float)
 
@@ -166,7 +171,8 @@
                    LinearlyExplicitRingOver Z, RealConstant,
                    LinearlyExplicitRingOver Fraction Z,
                    CharacteristicZero,
-                   ConvertibleTo Complex Float, DifferentialRing) with
+                   ConvertibleTo Complex Float,
+                   ConvertibleTo InputForm, DifferentialRing) with
     coerce : P -> %
       ++ coerce(p) returns p viewed as an algebraic number.
     numer  : % -> P
@@ -196,6 +202,9 @@
     zero? a == trueEqual(a::Rep,0::Rep)
     one? a == trueEqual(a::Rep,1::Rep)
     a=b == trueEqual((a-b)::Rep,0::Rep)
+    -- make sure the interpreter gets an AlgebraicNumber!
+    convert(x:%):InputForm ==
+      coerceToType(convert(x pretend Rep)$Rep)$InputFormFunctions1(%)
 
 @
 \section{License}
Only in fricas/src/algebra: constant.spad.pamphlet.orig
diff -ru fricas.bb/src/interp/format.boot fricas/src/interp/format.boot
--- fricas.bb/src/interp/format.boot    2008-10-25 00:52:06.000000000 -0400
+++ fricas/src/interp/format.boot       2008-10-25 17:28:35.000000000 -0400
@@ -319,7 +319,8 @@
   form2StringAsTeX form
 
 prefix2String form ==
-  form2String form
+  $formatSigAsTeX: local := 1
+  form2StringLocal form
 
 -- local version
 prefix2String0 form ==
@@ -353,6 +354,7 @@
 
 form2String u == 
   $formatSigAsTeX: local := 1
+  $InteractiveMode: local := false
   form2StringLocal u
 
 form2StringAsTeX u == 
@@ -428,18 +430,27 @@
     argl := rest argl
     (null argl) or null (first argl) => [lo, '".."]
     [lo, '"..", form2String1 first argl]
-  -- op = "MATRIX" => op
-  -- does no work
-  -- fortranCleanUp exp2Fort1 [op,:argl]
-  -- somewhat works, but causes regression
-  -- fortranCleanUp exp2Fort1 exp2FortOptimize [op,:argl]
+  op = "MATRIX" => matrix2String argl
+  u1 is ["ROOT", arg1] =>
+     concat("sqrt(", appOrParen(arg1),")")
+  u1 is ["ROOT", arg1, arg2] =>
+     concat("nthRoot(", appOrParen(arg1),",",appOrParen(arg2),")")
+     --concat(appOrParen(arg1), '"^", appOrParen(["OVER",1,arg2]))
   u1 is ["$elt", t, f] =>
      concat(form2String1 f, '"$", form2String1 t)
   #argl = 2 and (isBinaryInfix op or op = "::" or op = '"::"_
-     or op = "@" or op = '"@" or op = "pretend" or op = '"pretend") =>
+     or op = "@" or op = '"@" or op = "pretend" or op = '"pretend"_
+     or op = "OVER" or op = '"OVER") =>
           binop2String [op,:argl]
   application2String(op,[form2String1 x for x in argl], u1)
 
+matrix2String x ==
+  concat(lbrkSch(),
+    tuple2String [outtranRow x.i for i in 0..MAXINDEX x],rbrkSch()) where
+      outtranRow x ==
+        concat(lbrkSch(),
+          tuple2String [form2String1 x.i for i in 0..MAXINDEX x], rbrkSch())
+
 binop2String x ==
     $curExpr : local := x
     x is ["=", arg1, arg2] or x is ['"=", arg1, arg2] =>
@@ -453,7 +464,7 @@
           concat(sumOrParen(arg1), '"+", productOrParen(arg2))
        op = "-" or op = '"-" =>
            concat(sumOrParen(arg1), '"-", productOrParen(arg2))
-       op = "/" or op = '"/" =>
+       op = "/" or op = '"/" or op = "OVER" or op = '"OVER" =>
            concat(appOrParen(arg1), '"/", appOrParen(arg2))
        productOrParen(x)
    productOrParen(x)
Only in fricas/src/interp: format.boot.orig


-- 
                              Waldek Hebisch
[EMAIL PROTECTED] 

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to