[Index for tmp_for_tar/misc]
[Return to Master Index]
test_lbincoeff
(tmp_for_tar/misc/test_lbincoeff.m)
Help text
Last modified: April 2001
Cross-Reference Information
This calls
Listing of file tmp_for_tar/misc/test_lbincoeff.m
## Author: Etienne Grossmann <etienne@isr.ist.utl.pt>
## Last modified: April 2001
if ! exist ("verbose"), verbose = 0; end
if ! exist ("inspect"), inspect = 0; end
sayif (verbose, "\n test_lbincoeff\n\n");
cnt = 1;
ok = 1;
N = 100; # Check that all exp (lbincoeffs(N,K)) is
# bincoeffs(N,K) for 0 <= k <= n <= N
[nn,kk] = lotr (N+1); # n,k pairs
nn--; kk--;
L = length (nn);
sayif (verbose, "Going to compute %i bincoeffs ...", L);
bc = bincoeff (nn,kk);
sayif (verbose, "done\n");
sayif (verbose, "Going to compute %i log bincoeffs ...", L);
lbc = lbincoeff (nn,kk);
sayif (verbose, "done\n");
err = (bc - exp (lbc)) ./ bc ;
if max (abs (err)) > sqrt (eps)
ok = 0;
if verbose || inspect
printf ("not ok %i error is big\n",cnt);
end
if inspect, keyboard; end
elseif verbose
printf ("ok %i\n",cnt);
end
cnt++;
# Check that sum of exp (lbincoeffs(n,k))
# for n == 1000 and k = 0:n is 2^n
# (bigger values give problems to 2^n and exp)
N = 1000;
sayif (verbose, "Summing up exp (lbincoeff (%i,1:%i))\n",N,N);
err = (sum (exp (res = lbincoeff (N,1:N))) - 2^N)/2^N;
if abs (err) > sqrt (eps)
ok = 0;
if verbose || inspect
printf ("not ok %i error is big\n",columns (shs));
end
if inspect, keyboard; end
elseif verbose
printf ("ok %i\n",cnt);
end
cnt++;
cnt--;
sayif (verbose && ok, "All %i tests ok\n",cnt);
Produced by oct2html on Sat Apr 28 21:14:54 2001
Cross-Directory links are: ON