cmucl vs. gcl



Here is the program as an attachment.

The file (which is a text file) is called "Esparse_test.mac"

It loads the program called "Esparse" which is described in the
beginning comments.

The offending 27x27 matrix "A" is also loaded so one can try "Esparse"
on that matrix.

Thanks for any comments.

-sen

On Mon, 11 Dec 2006, Daniel Lakeland wrote:

> On Mon, Dec 11, 2006 at 04:34:07PM -0500, sen1 at math.msu.edu wrote:
>> Hello,
>>
>>   I have a very simple sparse matrix routine (finds the largest
>>   eigenvalue of a non-negative square matrix), which runs just fine in
>>   maxima with gcl.  ( I wrote it because I could not find such a
>>   routine in the maxima files.  Is there one?)
>>
>>     For testing, I tried cmucl, and the thing would not
>>   run: stated something about being "out of heap space." There were
>>   some arcane remarks about how to dynamically allocate more heap space
>>   which I did not understand.
>>
>>   Question: Is cmucl a low end type of lisp for "teaching"?
>>
>>     Which of the freely available types of lisp are good for
>>     computation?
>
> No, in fact CMUCL is a rather high powered lisp, normally excellent
> for fast computation because it has very good type inference and
> specialization code.
>
> SBCL is a spinoff from CMUCL which has its aim to become more easily
> ported and more maintainable.
>
> both SBCL and CMUCL generate native code. CMUCL has an additional
> bytecode compiler which SBCL doesn't have (or didn't last I looked).
>
> The fact that you borked CMUCL is a bit surprising but you may simply
> need to increase the heap space from whatever the default is. I
> believe there is a command line switch. CMUCL may be generating
> bytecode for the maxima function, and that may be less space
> efficient, in which case, running the "compile" function on your
> maxima function might be helpful.
>
> Dunno beyond that.
>
>

-- 
  ---------------------------------------------------------------------------
  | Sheldon E. Newhouse            |    e-mail: sen1 at math.msu.edu           |
  | Mathematics Department         |       				   |
  | Michigan State University      | telephone: 517-355-9684                |
  | E. Lansing, MI 48824-1027 USA  |       FAX: 517-432-1562                |
  ---------------------------------------------------------------------------
-------------- next part --------------
/****************** File Esparse_test.mac *****************/

/* finds the largest eigenvalue of a sparse matrix A
  Typically, the matrix is entered as

   A: zeromatrix(SIZE,SIZE);

  Then, the entries can be modified by specifying the A[i,j] terms.

 The variables MAX and ERR are the number of iterations, and error
 desired.

Example: A: zeromatrix(4,4);
         A[1,1]:1.7;
         A[1,2]:2.8;
         A[3,2]:4;

 Esparse(A,4,30,1e-10);
*/


ratprint: false;

load("eigen")$

Norm(list):= flt(sqrt(inprod(list,list)))$

Esparse(A,SIZE,MAX,ERR):=
  block( [ran,nran, v_old, iter:0, nv_new, v_new, expan, s:SIZE,B],
      
   /* initialize the normalized random s-vector */

  ran: makelist(random(1.0),i,1,s),
  nran: ran/Norm(ran),
 
  v_old: nran,

   while  iter <  MAX do 
     ( v_new: makelist( sum(A[i,j]*v_old[j],j,1,s),i,1,s),
        expan: Norm(v_new),
        nv_new: v_new/expan,
      if Norm(nv_new - v_old) < ERR then 
           ( v_new: makelist( sum(A[i,j]*v_old[j],j,1,s),i,1,s),
             expan: Norm(v_new), return(expan))
        else
         (v_old: nv_new, iter: iter+1, 
          if iter=MAX -1 then 
               prt("MAX reached and ERR not achieved; try decreasing
                   ERR or increasing MAX ")
         )
     )  

    )$

/********** End of Esparse_test.mac ******************/

/******** 27x27 matrix which causes problems with default cmucl *****/



A: matrix([0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[1,0,1,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0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