Aren’t the programs in Kristofer’s repo in good shape? I believe some or all of them should be submitted. I guess I could (but should I)? I don’t want to take anyone’s credit.
I decided to look into one of the programs that didn’t have a Julia implementation (I see however now it’s in Kristofer’s repo), and to translate this fastest [C++] non-multi-threaded version:
https://benchmarksgame-team.pages.debian.net/benchmarksgame/program/spectralnorm-gpp-2.html
It uses Eigen library, and since that’s allowed, I guess we could use similar [Julia] libraries, or even the Julia Eigen wrapper.
However, I just started with translating the commented out “EQUIVALENT MATLAB IMPLEMENTATION”. It’s trivial to do, but I opted to try the MATLAB to Julia translator | MATLAB to Julia converter translator anyway. I ended up with this (maybe it just isn’t “EQUIVALENT”, anyone know what’s wrong?) that’s fast on my very old laptop but wrong:
julia> function approximate(n)
A = zeros(n,n)
for i=1:n
for j=1:n
A[i,j] = 1.0/((i+j)*(i+j+1)/2.0 + i+1.0)
end
end
u = ones(n,1)
v = zeros(n,1)
for i=1:10
v = A'*(A*u)
u = A'*(A*v)
end
sqrt((u'*v)/(v'*v))
end
approximate (generic function with 1 method)
julia> @time approximate(5500)
5.461645 seconds (9.13 k allocations: 232.940 MB, 0.72% gc time)
1×1 Array{Float64,2}:
0.361967
The translator got this line wrong (anyone know why? and I should file a bug):
sqrt((u"*v)/(v"*v))
and I changed integers to floats here: A[i,j] = 1.0/((i+j)*(i+j+1)/2.0 + i+1.0)
I got the same result as expected and seems same speed (was just checking).
I opened um my MATLAB clone, Octave to just make sure, and I get the same number eventually. Probably after minutes, ten[s?]. At least Julia is way faster, can anyone compare real MATLAB to Julia for me?