author | Lesley De Cruz <lesley.decruz+git@gmail.com> | 2012年03月04日 00:46:27 +0100 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2012年03月04日 21:41:31 +0100 |
commit | 750b1a5619b6fc5bcf4e7af84896a8eaf01589d0 (patch) | |
tree | 1433a491abf52498e6926822af72d18030c8f5dd | |
parent | 9c0c6b43eccbb17963a49b74610badcfac5c7445 (diff) | |
download | gsl-shell-auto-test.tar.gz |
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | doc/user-manual/complex.rst | 4 | ||||
-rw-r--r-- | tests/complex.lua | 1 | ||||
-rw-r--r-- | tests/expected/ode.lua | 26 | ||||
-rw-r--r-- | tests/expected/rng.lua | 128 | ||||
-rw-r--r-- | tests/fft.lua | 5 | ||||
-rw-r--r-- | tests/ode.lua | 31 | ||||
-rw-r--r-- | tests/rng.lua | 23 | ||||
-rw-r--r-- | tests/tests.lua | 2 |
@@ -55,7 +55,7 @@ LUA_BASE_FILES = bspline.lua fft-init.lua integ-init.lua template.lua check.lua DEMOS_LIST = bspline fft plot wave-particle fractals ode nlinfit integ anim linfit contour svg graphics sf vegas LUA_TEMPLATES = gauss-kronrod-x-wgs qag rk8pd lmfit qng rkf45 ode-defs rk4 sf-defs vegas-defs -TESTS = demos matrix sf complex randist iter linalg fft +TESTS = demos matrix sf complex randist iter linalg fft rng ode LUA_BASE_FILES += $(DEMOS_LIST:%=demos/%.lua) LUA_BASE_FILES += $(LUA_TEMPLATES:%=templates/%.lua.in) diff --git a/doc/user-manual/complex.rst b/doc/user-manual/complex.rst index 66e7a9ab..3d9b99a4 100644 --- a/doc/user-manual/complex.rst +++ b/doc/user-manual/complex.rst @@ -196,10 +196,6 @@ Inverse Complex Hyperbolic Functions The branch cut is on the real axis, less than 1. Note that in this case we use the negative square root in formula 4.6.21 of Abramowitz & Stegun giving :math:`\textrm{acosh}(z)=\log(z-\sqrt{z^2-1})`. -.. function:: real(z) - - This function returns the complex hyperbolic arccosine of the real number z, :math:`\textrm{acosh}(z)`. - .. function:: atanh(z) This function returns the complex hyperbolic arctangent of the complex number z, :math:`\textrm{atanh}(z)`. diff --git a/tests/complex.lua b/tests/complex.lua index 7dcb5076..31b41a5d 100644 --- a/tests/complex.lua +++ b/tests/complex.lua @@ -37,7 +37,6 @@ t.csch = function(test) test{csch(z)} end t.coth = function(test) test{coth(z)} end t.asinh = function(test) test{asinh(z)} end t.acosh = function(test) test{acosh(z)} end -t.real = function(test) test{real(z)} end t.atanh = function(test) test{atanh(z)} end t.asech = function(test) test{asech(z)} end t.acsch = function(test) test{acsch(z)} end diff --git a/tests/expected/ode.lua b/tests/expected/ode.lua new file mode 100644 index 00000000..db5dbc74 --- /dev/null +++ b/tests/expected/ode.lua @@ -0,0 +1,26 @@ +return { + ["rk8pd"]={{{-3.6698956800288252e-01,-4.5614108081406113e-01 + },{-7.5942642138572642e+00,-2.4397243805341735e+00 + },{-4.4089375643850566e+01,-4.4397243806736268e+00 + },{-1.3386117963313430e+02,-6.4397243809258331e+00 + },{-3.0090967618177899e+02,-8.4397243807884355e+00 + },{-5.6923486528973797e+02,-1.0439724380609288e+01 + },{-9.6283674695702223e+02,-1.2439724380272683e+01 + },{-1.5057153211835991e+03,-1.4439724380832530e+01 + },{-2.2218705879694085e+03,-1.6439724380846307e+01 + },{-3.1353025473146768e+03,-1.8439724380446513e+01 + } + }}, + ["rkf45"]={{{-3.6698956751491923e-01,-4.5614109261093766e-01 + },{-7.5942642782595575e+00,-2.4397243929400609e+00 + },{-4.4089375861847842e+01,-4.4397243917697873e+00 + },{-1.3386118009270336e+02,-6.4397243932104571e+00 + },{-3.0090967697200534e+02,-8.4397243895726994e+00 + },{-5.6923486649895517e+02,-1.0439724390724416e+01 + },{-9.6283674867421928e+02,-1.2439724390551461e+01 + },{-1.5057153234974494e+03,-1.4439724388879382e+01 + },{-2.2218705909686441e+03,-1.6439724388870673e+01 + },{-3.1353025510876573e+03,-1.8439724388894341e+01 + } + }} +}
\ No newline at end of file diff --git a/tests/expected/rng.lua b/tests/expected/rng.lua new file mode 100644 index 00000000..43d2656e --- /dev/null +++ b/tests/expected/rng.lua @@ -0,0 +1,128 @@ +return { + ["borosh13"]={9.8217003652825952e-01,"0ULL","5100982ULL","58821ULL","935ULL",7.8779347101226449e-01 + }, + ["cmrg"]={2.1863305485743706e-01,"0ULL","218634ULL","1547ULL","986ULL",8.1805478633290840e-01 + }, + ["coveyou"]={3.5824531828984618e-01,"0ULL","5459308ULL","11285ULL","914ULL",5.7493538549169898e-01 + }, + ["fishman18"]={3.1535736486099536e-01,"0ULL","12036205ULL","43638ULL","359ULL",6.6106650124353661e-01 + }, + ["fishman20"]={5.3803154292424749e-01,"0ULL","5378917ULL","6076ULL","40ULL",5.9400795707200094e-01 + }, + ["fishman2x"]={9.2194819400177722e-02,"0ULL","5545874ULL","1897ULL","878ULL",8.4401151530631424e-01 + }, + ["gfsr4"]={5.9811375569552183e-02,"2998464386ULL","1058302ULL","51064ULL","313ULL",6.3616260327398777e-01 + }, + ["knuthran"]={8.7470554932951927e-01,"0ULL","6362615ULL","65038ULL","426ULL",3.8713748566806316e-02 + }, + ["knuthran2"]={9.3864816890035208e-01,"0ULL","6959171ULL","32719ULL","680ULL",8.3525057455303642e-01 + }, + ["knuthran2002"]={3.5167178977280855e-01,"0ULL","6296351ULL","55528ULL","998ULL",2.0312856975942850e-01 + }, + ["lecuyer21"]={4.4583677501108354e-01,"0ULL","16741049ULL","4179ULL","185ULL",7.4999652837828523e-01 + }, + ["list"]={{"borosh13","cmrg","coveyou","fishman18","fishman20","fishman2x","gfsr4","knuthran","knuthran2","knuthran2002","lecuyer21","minstd","mrg","mt19937","mt19937_1999","mt19937_1998","r250","ran0","ran1","ran2","ran3","rand","rand48","random128-bsd","random128-glibc2","random128-libc5","random256-bsd","random256-glibc2","random256-libc5","random32-bsd","random32-glibc2","random32-libc5","random64-bsd","random64-glibc2","random64-libc5","random8-bsd","random8-glibc2","random8-libc5","random-bsd","random-glibc2","random-libc5","randu","ranf","ranlux","ranlux389","ranlxd1","ranlxd2","ranlxs0","ranlxs1","ranlxs2","ranmar","slatec","taus","taus2","taus113","transputer","tt800","uni","uni32","vax","waterman14","zuf" + }}, + ["minstd"]={1.8418296993904884e-01,"0ULL","9448521ULL","19339ULL","631ULL",1.5307081497882996e-01 + }, + ["mrg"]={2.7615032497614173e-01,"0ULL","9879106ULL","48796ULL","427ULL",7.9317694985921350e-01 + }, + ["mt19937"]={6.1879476951435208e-01,"1462474751ULL","9925797ULL","9766ULL","910ULL",2.3243803973309696e-01 + }, + ["mt19937_1998"]={3.3530109864659607e-01,"506459116ULL","3430011ULL","22318ULL","475ULL",7.0519184833392501e-01 + }, + ["mt19937_1999"]={3.0577570409514010e-01,"622043128ULL","4930810ULL","40788ULL","205ULL",5.3064916771836579e-01 + }, + ["r250"]={1.6162921302020550e-01,"1584804808ULL","14332284ULL","52589ULL","936ULL",7.6016347296535969e-01 + }, + ["ran0"]={3.5266445826397486e-01,"0ULL","3884765ULL","43356ULL","969ULL",5.6910771856508580e-01 + }, + ["ran1"]={1.3062815181910992e-02,"0ULL","14313333ULL","48736ULL","998ULL",4.3828997015953064e-01 + }, + ["ran2"]={4.2134284973144531e-01,"0ULL","9598063ULL","27241ULL","81ULL",2.8754398226737976e-01 + }, + ["ran3"]={2.5905030200000001e-01,"0ULL","2577776ULL","61960ULL","180ULL",2.7288792200000000e-01 + }, + ["rand"]={7.9326586332172155e-02,"0ULL","5894949ULL","29024ULL","909ULL",6.5058362437412143e-01 + }, + ["rand48"]={9.8723234383306036e-01,"2170351523ULL","2103446ULL","34544ULL","83ULL",1.3982964491877681e-01 + }, + ["random-bsd"]={8.5226014629006386e-01,"0ULL","3842434ULL","63592ULL","857ULL",3.5895416233688593e-01 + }, + ["random-glibc2"]={8.0438610818237066e-01,"0ULL","5135319ULL","63698ULL","158ULL",5.3433529566973448e-01 + }, + ["random-libc5"]={8.9557521976530552e-01,"0ULL","13901444ULL","11658ULL","667ULL",4.3594953510910273e-01 + }, + ["random128-bsd"]={8.5226014629006386e-01,"0ULL","3842434ULL","63592ULL","857ULL",3.5895416233688593e-01 + }, + ["random128-glibc2"]={8.0438610818237066e-01,"0ULL","5135319ULL","63698ULL","158ULL",5.3433529566973448e-01 + }, + ["random128-libc5"]={8.9557521976530552e-01,"0ULL","13901444ULL","11658ULL","667ULL",4.3594953510910273e-01 + }, + ["random256-bsd"]={6.6530651878565550e-01,"0ULL","10898306ULL","2095ULL","319ULL",8.1795374210923910e-01 + }, + ["random256-glibc2"]={5.2825186541303992e-01,"0ULL","402171ULL","24507ULL","633ULL",6.2887596199288964e-01 + }, + ["random256-libc5"]={1.1112885642796755e-01,"0ULL","6565902ULL","5178ULL","382ULL",4.1738912463188171e-01 + }, + ["random32-bsd"]={4.7222562367096543e-01,"0ULL","9908461ULL","56489ULL","362ULL",5.1012065494433045e-01 + }, + ["random32-glibc2"]={5.9743911027908325e-01,"0ULL","15630863ULL","35457ULL","860ULL",4.0219961665570736e-01 + }, + ["random32-libc5"]={7.5742310425266623e-01,"0ULL","1720985ULL","61547ULL","911ULL",3.9925651578232646e-01 + }, + ["random64-bsd"]={7.6792119909077883e-01,"0ULL","5773577ULL","59896ULL","806ULL",8.5370097495615482e-01 + }, + ["random64-glibc2"]={1.5038409736007452e-02,"0ULL","9967790ULL","53108ULL","167ULL",2.3746065795421600e-01 + }, + ["random64-libc5"]={7.2441559378057718e-01,"0ULL","7164401ULL","58067ULL","867ULL",8.5389534663408995e-01 + }, + ["random8-bsd"]={7.9326586332172155e-02,"0ULL","5894949ULL","29024ULL","909ULL",6.5058362437412143e-01 + }, + ["random8-glibc2"]={7.9326586332172155e-02,"0ULL","5894949ULL","29024ULL","909ULL",6.5058362437412143e-01 + }, + ["random8-libc5"]={7.9326586332172155e-02,"0ULL","5894949ULL","29024ULL","909ULL",6.5058362437412143e-01 + }, + ["randu"]={7.4670511018484831e-01,"0ULL","5137458ULL","7664ULL","968ULL",6.2202994059771299e-01 + }, + ["ranf"]={4.3860662337635858e-06,"3382143976ULL","3853333ULL","37843ULL","335ULL",2.1397055137935794e-01 + }, + ["ranlux"]={6.8169730901718140e-01,"0ULL","13560381ULL","22945ULL","764ULL",9.6982568502426147e-01 + }, + ["ranlux389"]={6.8169730901718140e-01,"0ULL","13560381ULL","22945ULL","764ULL",9.6982568502426147e-01 + }, + ["ranlxd1"]={6.6740859187818558e-01,"3325751671ULL","9156911ULL","24853ULL","660ULL",1.2386267976284060e-01 + }, + ["ranlxd2"]={5.0781103828237306e-01,"1205339008ULL","2444770ULL","37005ULL","899ULL",7.1673432384281455e-01 + }, + ["ranlxs0"]={3.5908359289169312e-01,"0ULL","9770506ULL","6028ULL","882ULL",3.5633486509323120e-01 + }, + ["ranlxs1"]={5.6821107864379883e-04,"0ULL","5579958ULL","43280ULL","231ULL",8.3751142024993896e-02 + }, + ["ranlxs2"]={4.0051305294036865e-01,"0ULL","8966701ULL","18462ULL","862ULL",9.3864053487777710e-01 + }, + ["ranmar"]={1.1795270442962646e-01,"0ULL","801367ULL","57301ULL","837ULL",9.9133616685867310e-01 + }, + ["slatec"]={2.5041270256042480e-01,"0ULL","0ULL","60626ULL","421ULL",1.5861988067626953e-01 + }, + ["taus"]={1.5250031510367990e-01,"2188305506ULL","14519765ULL","50165ULL","350ULL",7.7352471719495952e-01 + }, + ["taus113"]={5.5799769889563322e-01,"3387395447ULL","11344987ULL","38517ULL","849ULL",8.0397861450910568e-01 + }, + ["taus2"]={1.5250031510367990e-01,"2188305506ULL","14519765ULL","50165ULL","350ULL",7.7352471719495952e-01 + }, + ["transputer"]={7.8222374105826020e-01,"0ULL","16317268ULL","3149ULL","775ULL",6.0852946573868394e-01 + }, + ["tt800"]={8.2469086628407240e-01,"3586473199ULL","12884474ULL","8812ULL","387ULL",8.3610181510448456e-01 + }, + ["uni"]={3.0811487166966767e-01,"0ULL","0ULL","0ULL","389ULL",4.8387096774193550e-01 + }, + ["uni32"]={9.5518273858129177e-01,"0ULL","10725939ULL","36635ULL","131ULL",1.9727952042467869e-01 + }, + ["vax"]={5.5503727006725967e-01,"3733212528ULL","3494066ULL","32098ULL","532ULL",6.6306997742503881e-01 + }, + ["waterman14"]={7.4180810758844018e-01,"0ULL","10030366ULL","35879ULL","771ULL",9.3639810243621469e-01 + }, + ["zuf"]={3.3799916505813599e-01,"0ULL","4029666ULL","8992ULL","684ULL",2.7076494693756104e-01 + } +}
\ No newline at end of file diff --git a/tests/fft.lua b/tests/fft.lua index 46672196..880ebe94 100644 --- a/tests/fft.lua +++ b/tests/fft.lua @@ -1,13 +1,8 @@ use'num' local t = {} - local y = function(n) return matrix.new(n, 1, |i| i < n/3 and 0 or (i < 2*n/3 and 1 or 0)) end -local v=1 -local in_place=1 -local hc=1 - t.fft = function(test) test{fft(y(64))} end t.fft_id = function(test) test{tostring(fftinv(fft(y(1024))))==tostring(y(1024)) } end return t diff --git a/tests/ode.lua b/tests/ode.lua new file mode 100644 index 00000000..49daf2aa --- /dev/null +++ b/tests/ode.lua @@ -0,0 +1,31 @@ +-- tests for module ode +use'num' +local tt = {} + +local methods={'rk8pd','rkf45'} + +local function odef(t, x, y) + return -y^2, 2*x - y^3 +end + +-- we define initial values +local t0, t1, h0 = 0, 30, 0.04 +local x0, y0 = 1, 1 + +-- function tests +for i,method in ipairs(methods) do + tt[method] = function(test) + local s = ode{N= 2, eps_abs= 1e-8, method=method} + s:init(t0, h0, odef, x0, y0) + local function f(i) + local t = i*(t1-t0)/10 + while s.t < t do + s:evolve(odef,t) + end + return {s.y[1],s.y[2]} + end + test{iter.ilist(f,10)} + end +end + +return tt diff --git a/tests/rng.lua b/tests/rng.lua new file mode 100644 index 00000000..7864a142 --- /dev/null +++ b/tests/rng.lua @@ -0,0 +1,23 @@ +-- tests for module rng +use'rng' +local tt = {} + +local n=1 +local seed=1 +local instance = function(name) return new(name) end -- initialize instance! + +-- function tests + +tt.list = function(test) test{list()} end + + +-- method tests +for i,name in ipairs(list()) do + local r = instance(name) + tt[name] = function(test) + r:set(1234567890) + test{r:get(),r:getint(2^32-1),r:getint(2^24-1),r:getint(2^16-1),r:getint(1024),r:get()} + end +end + +return tt diff --git a/tests/tests.lua b/tests/tests.lua index 5037ef9c..06fee706 100644 --- a/tests/tests.lua +++ b/tests/tests.lua @@ -283,7 +283,7 @@ local function runtests(options,t) end else -- if none are given, run tests for all categories - for cat,fun in keysortedpairs(mytests) do + for cat in keysortedpairs(mytests) do testcategory(cat,options) end end |