Running the following script I get a huge difference

         timerB =  0.010171000
         timerA =  0.22064500
          ratio =  21.693540

It does not matter if LOOP2 comes in place of LOOP1.

Also I get eigenvalues in descending order in LOOP2 instead of ascending as in eigensym but that's not the issue (I guess).

I hope the code has not any silly mistakes.

Thanks for your time anyway.

Yiannis


<\hansl>

clear
set verbose off
 
mynameisseed = randgen1(i,1000000,10000000)
set seed mynameisseed
set seed #8402212
 
reps = 1000
 
matrices AtA = array(reps)
loop i = 1..reps -q
    A = mrandgen(i,-5,5,4,4)
    AtA[i] = A'A
endloop
 
# LOOP 2
set stopwatch
loop i = 1..reps -q
    matrix V = {}
    matrix W = {}
    D = eiggen2(AtA[i],&V,&W)
    Tmp = mreverse(msortby(Re(D)~Re(V)',1))
    D = Tmp[,1]
    V = Tmp[,2:]'
#     print D
#     print V
endloop
timerB = $stopwatch
print timerB
 
# LOOP 1
set stopwatch
loop i = 1..reps -q
    matrix V = {}
    matrix W = {}
    D = eigensym(AtA[i],&V)
#     print D
#     print V
endloop
timerA = $stopwatch
print timerA
 
ratio = timerA/timerB
print ratio
 
</hansl>