Mike Hansen wrote:
> >> * Given a domain like "Polynomial Integer", how do I get the base ring
> >> "Integer" programatically? This would be like the base_ring method in
> >> Sage.
> >
> > You cannot, currently. One possibility (I never tried in SPAD, but it
> > works in
> > Aldor), is to make Polynomial export it's argument. Could you give a use
> > case?
> > Maybe there is a workaround.
>
> When trying to construct an object corresponding to 'Polynomial
> Fraction Integer' in Sage, you first want to construct the argument in
> Sage, and then make the polynomial ring over that. Currently, I'm
> just doing some simple string processing to extract the argument. It
> seems that all the data need to reconstruct a domain within FriCAS is
> present in its string representation; is this generally true?
>
Unfortynatly no. For example:
K := Fraction Integer
g := matrix [[1,0,0,0], [0,-1,0,0], [0,0,-1,0], [0,0,0,-1]]
D := CliffordAlgebra(4,K, quadraticForm g)
gives:
CliffordAlgebra(4,Fraction Integer,MATRIX)
As Martion wrote you can _not_ get arguments from Spad level functions.
But there is low level devalueate functon which may help:
(11) -> devaluate(D)$Lisp
(11)
(CliffordAlgebra 4 (Fraction (Integer))
[[1(),0(),0(),0()], [0(),- 1(),0(),0()], [0(),0(),- 1(),0()],
[0(),0(),0(),- 1()]]
)
Type: SExpression
NTH(2, devaluate(D)$Lisp)$Lisp
(16) (Fraction (Integer))
Type: SExpression
Note1: Such use of 'devaluate' gives you just Lisp representation of
type, in particular you see (mangled) internal representation of the
third argument.
Note2: Constructors may take functions as arguments and there is no way
to reliably reconstruct function from printed representation. For
example, you may get:
Type: LinearOrdinaryDifferentialOperator(Expression Integer,theMap
LAMBDA-CLOSURE(NIL,NIL,NIL,G1520 envArg,SPADCALL(G1520,QUOTE
x,ELT(*1;anonymousFunction;0;initial;internal;MV,0))))
or (the same thing, but using different Lisp implementation):
Type: LinearOrdinaryDifferentialOperator(Expression Integer,theMap
*1;anonymousFunction;0;initial;internal)
Note3: AFAIK on same types devaluate just gives you emtpy list. This
should happen only for types that you can not construct.
> > In Aldor, Polynomial would be just any function, i.e., a first class object.
> > In FriCAS it's not, and it's on top of my whishlist to change that.
> > Unfortunately, I have no idea how to do it.
> >
> > Again, do you have a use case? Maybe there is a workaround.
>
> It'd be nice to be able to test given a random type if the "outermost"
> constructor is Polynomial. I'm just doing string stuff to work around
> it now, but perhaps there is another way to do this.
>
NTH(0, devaluate(Polynomial Integer)$Lisp)$Lisp
gives:
(1) Polynomial
Type: SExpression
> --Mike
>
> >
>
--
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
-~----------~----~----~----~------~----~------~--~---