Bill Page wrote:
> 
> On 29 October 2015 at 05:17, Ralf Hemmecke <[email protected]> wrote:
> 
> > (7) -> PRETTYPRINT(r)$Lisp
> > #(2.0 3.0 17)
> > it looks as if a record is internally stored as a lisp vector, no?
> 
> No not quite.  That is a literal vector in Lisp.  But you are right
> that this is the actual internal representation of something of type
> Record. E.g.
> 
> (1) -> VECTOR(1.0::DF,2.0::DF,3)$Lisp pretend Record(a:DF,b:DF,c:Integer)
> 
>    (1)  [a= 1.0,b= 2.0,c= 3]
>                        Type: Record(a: DoubleFloat,b: DoubleFloat,c: Integer)

Note: this is for records of length > 2.  Records of lennght 2 are
represented as Lisp pairs, the same as unions.  In fact, without
knowing Spad type it is impossible to distinguish record from
union:

(11) -> U ==> Union(DoubleFloat, Integer)              
                                                                   Type: Void
(12) -> u := 2::U                        

   (12)  2.0
                                                 Type: Union(DoubleFloat,...)
(13) -> PRETTYPRINT(u)$Lisp              
(0 . 2.0)

   (13)  ()
                                                            Type: SExpression
(14) -> R ==> Record(ii : Integer, dd : DoubleFloat)
                                                                   Type: Void
(15) -> r := [0, 2.0]$R                             

   (15)  [ii= 0,dd= 2.0]
                                    Type: Record(ii: Integer,dd: DoubleFloat)
(16) -> PRETTYPRINT(r)$Lisp
(0 . 2.0)

   (16)  ()
                                                            Type: SExpression
(17) -> EQUAL(u, r)$Lisp

   (17)  T
                                                            Type: SExpression

> But you had the right idea.  This works:
> 
> ; gsl.lisp
> ...
> ; Return multiple values as a vector (can be interpreted as Axiom Record)
> (defun integration-qng-vector (f a b)
>   (apply #'vector (multiple-value-list (integration-qng f a b))))
> 

Yes.  Let me just remark that the code above is fine for
experimantation.  In long term we should not sprinkle
assumptions about representation of vectors all around.
So probably we should create something to create
records.  Note that currently representation of record
only depends on its lenght (number of fields), but in
principle could depend on type.  So one possibility
is to add real 'construct' function to Record and
get it if needed via lookup.  Another it to
provide function that given type and values would
create record of given type.

Maybe extra remark why I am making fuss here: in the past
FriCAS used quite different representation of two dimensional
arrays.  We could change representation because it was only
used via small number of functions and macros.

-- 
                              Waldek Hebisch

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to