2 # Copyright (C) 2006-2009, Parrot Foundation.
5 # ./parrot -R jit spectralnorm.pir N (N = 100 for shootout)
7 # modified by Karl Forner to accept shootout default value of N=100
13 # return 1.0/((i+j)*(i+j+1)/2+i+1);
34 unless i < N goto endfor_i
38 unless j < N goto endfor_j
39 # Au[i]+=eval_A(i,j)*u[j]
66 unless i < N goto endfor_i
70 unless j < N goto endfor_j
71 # Au[i]+=eval_A(j,i)*u[j]
95 v = new 'FixedFloatArray'
99 eval_At_times_u(N,v,AtAu)
109 if argc == 1 goto default
114 u = new 'FixedFloatArray'
116 v = new 'FixedFloatArray'
123 unless i < N goto endfor_init
132 unless i < 10 goto endfor_eval
133 eval_AtA_times_u(N,u,v)
134 eval_AtA_times_u(N,v,u)
145 unless i < N goto endfor_calc
146 # vBv+=u[i]*v[i]; vv+=v[i]*v[i];
158 # print "%0.9f" % (sqrt(vBv/vv))
162 spf = new 'FixedFloatArray'
165 $S0 = sprintf "%.9f\n", spf
174 # vim: expandtab shiftwidth=4 ft=pir: