diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/jit-test/tests/sunspider/check-math-spectral-norm.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/jit-test/tests/sunspider/check-math-spectral-norm.js')
-rw-r--r-- | js/src/jit-test/tests/sunspider/check-math-spectral-norm.js | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/sunspider/check-math-spectral-norm.js b/js/src/jit-test/tests/sunspider/check-math-spectral-norm.js new file mode 100644 index 000000000..824863c6a --- /dev/null +++ b/js/src/jit-test/tests/sunspider/check-math-spectral-norm.js @@ -0,0 +1,53 @@ +// The Great Computer Language Shootout +// http://shootout.alioth.debian.org/ +// +// contributed by Ian Osgood + +function A(i,j) { + return 1/((i+j)*(i+j+1)/2+i+1); +} + +function Au(u,v) { + for (var i=0; i<u.length; ++i) { + var t = 0; + for (var j=0; j<u.length; ++j) + t += A(i,j) * u[j]; + v[i] = t; + } +} + +function Atu(u,v) { + for (var i=0; i<u.length; ++i) { + var t = 0; + for (var j=0; j<u.length; ++j) + t += A(j,i) * u[j]; + v[i] = t; + } +} + +function AtAu(u,v,w) { + Au(u,w); + Atu(w,v); +} + +function spectralnorm(n) { + var i, u=[], v=[], w=[], vv=0, vBv=0; + for (i=0; i<n; ++i) { + u[i] = 1; v[i] = w[i] = 0; + } + for (i=0; i<10; ++i) { + AtAu(u,v,w); + AtAu(v,u,w); + } + for (i=0; i<n; ++i) { + vBv += u[i]*v[i]; + vv += v[i]*v[i]; + } + return Math.sqrt(vBv/vv); +} + +var actual = ''; +for (var i = 6; i <= 48; i *= 2) { + actual += spectralnorm(i) + ','; +} +assertEq(actual, "1.2657786149754053,1.2727355112619148,1.273989979775574,1.274190125290389,"); |