> < ^ Date: Fri, 21 Jan 1994 11:09:00 +0100
> < ^ From: Alexander Hulpke <hulpke@math.colostate.edu >
^ Subject: Re: Diverse questions

Dear Forum,

in his message, Michael smith asked:

Subject: Calling functions, printing records and matrix calculations
 A couple of suggestions, and a question.

LISP 'apply function:

>Since LISP seems to have been an influence in the design of the GAP
>language, I wondering whether there might be a (hidden?) function
>equivalent to the LISP 'apply function. This function takes as arguments
>a function F and a list L and its evaluation is equivalent to a call to F
>with arguments given by the elements of L.

>i.e. ApplyFunction(F,[a,b,c]) is equivalent to F(a,b,c)

Supposing, that there always is an fixed upper limit to the number of arguments,
one could use a hack like :

ApplyFunction := function( func, list )
local l;
  if l=0 then
  if l=1 then
  elif l=2 then

He continues:
> I need to calculate a number of products of some matrices and add these
> products together. What is the best way of doing this? The simplest
> method, Sum([1..n], i -> A[i]*B[i]), uses much more space than necessary.
> It should be possible to do all this using only two extra matrices, one
> to accumulate the sum, the other to store each product. Can this be done?

When looking at the code of 'Sum', it seems, that indeed only two
intermediate matrices should be needed, as basically a loop evaluates
Are you sure, that GAP *needs* the additional memory, or that this memory
only gets allocated? (The memory manager tends to allocate more memory than
actually needed.) If this is the case, starting GAP with option -m limit,
where limit is a bound for the necessary memory should do the task.

Alexander Hulpke

> < [top]