Hello J fans, I am trying to implement this benchmark: http://shootout.alioth.debian.org/gp4/benchmark.php?test=spectralnorm&lang=all
Personally, I think the easiest to follow program is the Python one: http://shootout.alioth.debian.org/gp4/benchmark.php?test=spectralnorm&lang=python&id=2 and if you dont know Python, just understand that xrange(len(u)) is like i. $ u And yes, I have a funny feeling this could be done in 4 lines of J by some of you out there. But the specs say we must write 4 separate functions and I am just the one to try. However, I am having problems getting eval_A_times_u to work. I am getting a domain error and would appreciate some help. u = 3 $ 1 eval_A =: 4 : '% (x + 1 + (x+y) * (x+y+1) % 2)' eval_A_times_u =: 3 : 0 r =. '' for_i. y do. list =. 0 for_j. y do. list =: list , ( (i eval_A j) * j ) end. r =: r , (+/ list) end. r ) eval_A_times_u u |domain error: eval_A_times_u | list =:list;((i eval_A j)*j) When I traced this, it threw a value error on the input value of u... any idea why? ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
