|
|
spectral norm
#{
-- The Computer Language Shootout -- http://shootout.alioth.debian.org/ -- contributed by Isaac Gouy, tuned by Mike Pall -- modified by Fu Limin for Dao language. #} function Av(n, x, y) { for( i = 0 : n-1 ){ a = 0.00; for( j = 0 : n-1){ ij = i + j; a += x[j] / ( (ij*(ij+1)) / 2 + i+1); } y[i] = a; } } function Atv(n, x, y) { for( i = 0 : n-1 ){ a = 0.00; for( j = 0 : n-1){ ij = i + j; a += x[j] / ( (ij*(ij+1)) / 2 + j+1); } y[i] = a; } } function AtAv(n, x, y, t) { Av(n, x, t); Atv(n, t, y); } function main( n = 100 ) { u = [ 1.00 : 0 : n ]; v = [ 1.00 : 0 : n ]; t = [ 1.00 : 0 : n ]; for( i = 1 : 10 ){ AtAv(n, u, v, t); AtAv(n, v, u, t); } vBv, vv = 0.00; for( i = 0 : n-1 ){ ui = u[i]; vi = v[i]; vBv = vBv + ui*vi; vv = vv + vi*vi; } stdio.printf("%0.9f\n", math.sqrt(vBv / vv)); }
view count 1375 times
created at 2009-02-20, 16:33 GMT modified at 2009-02-22, 23:29 GMT |
fu: ... I forgot to say something about the plan for the whole new year in my previous reply. Well, besides w ... (Jan.19,01:40) fu: ... Happy new dragon year (which will start from this sunday)! Actually, it was a busy month (I wish th ... (Jan.18,22:46) ybabel: What's the plan for the new year ? Hello 'vry budy :- ) happy new year (when is the new year for you Fu ?) I saw you come back and comm ... (Jan.18,18:59) |