]> git.kaiwu.me - klib.git/commitdiff
changed some comments
authorHeng Li <lh3@live.co.uk>
Thu, 7 Apr 2011 00:48:51 +0000 (20:48 -0400)
committerHeng Li <lh3@live.co.uk>
Thu, 7 Apr 2011 00:48:51 +0000 (20:48 -0400)
lua/klib.lua

index ecb8bafb06b75093ecd6a5922ea177f0e0e968bf..fc26b40495fb8617ad41a776b9fbc22aa8c3030a 100644 (file)
   matrix.solve()
 ]]--
 
--- Description: getopt() translated from the BSD getopt()
+-- Description: getopt() translated from the BSD getopt(); compatible with the default Unix getopt()
+--[[ Example:
+       for opt, optarg = os.getopt(arg, 'a:b') do
+               if opt == 'a' then print(opt .. '=' .. optarg)
+               elseif opt == 'b' then print(opt) end -- optarg is nil
+       end
+]]--
 function os.getopt(args, ostr)
        local arg, place = nil, 0;
        return function ()
@@ -127,7 +133,7 @@ function string:split(sep, n)
        return a;
 end
 
--- Description: intelligent file open
+-- Description: smart file open
 function io.xopen(fn, mode)
        mode = mode or 'r';
        if fn == nil then return io.stdin;
@@ -164,6 +170,7 @@ function table.ksmall(arr, k)
        end
 end
 
+-- Description: shuffle/permutate an array
 function table.shuffle(a)
        for i = #a, 1, -1 do
                local j = math.random(i)
@@ -247,7 +254,7 @@ end
 math.M_SQRT2   = 1.41421356237309504880  -- sqrt(2)
 math.M_SQRT1_2 = 0.70710678118654752440  -- 1/sqrt(2)
 
--- Description: erfc(x): \Phi(x) = 0.5 * erfc(-x/M_SQRT2)
+-- Description: complement error function erfc(x): \Phi(x) = 0.5 * erfc(-x/M_SQRT2)
 function math.erfc(x)
        local z = math.abs(x) * math.M_SQRT2
        if z > 37 then return (x > 0 and 0) or 2 end
@@ -378,7 +385,7 @@ end
 
      Busing et al. (1999) Delete-m Jackknife for unequal m. Statistics and Computing, 9:3-8.
 ]]--
-function math.jackknife(g, m, t, t0) -- FIXME: not tested yet
+function math.jackknife(g, m, t, t0)
        local h, n, sum = {}, 0, 0;
        for j = 1, g do n = n + m[j] end
        if t0 == nil then -- When t0 is absent, estimate it in a naive way