author | Francesco Abbate <francesco.bbt@gmail.com> | 2012年12月23日 22:32:09 +0100 |
---|---|---|
committer | Francesco Abbate <francesco.bbt@gmail.com> | 2012年12月23日 22:32:09 +0100 |
commit | 07c0d50aebdc2e0c0d2daf40c47396cf8c2fa915 (patch) | |
tree | ccb5f4344924ebb9c4b95e12be384c1104b051e3 /gdt-plot.lua | |
parent | 9fc8b2eec436657cef9e69031e82714111657f89 (diff) | |
download | gsl-shell-07c0d50aebdc2e0c0d2daf40c47396cf8c2fa915.tar.gz |
-rw-r--r-- | gdt-plot.lua | 14 |
diff --git a/gdt-plot.lua b/gdt-plot.lua index 26cf8bbf..ecb09911 100644 --- a/gdt-plot.lua +++ b/gdt-plot.lua @@ -390,20 +390,12 @@ end local function gdt_table_linfit(t, f, jy) local N, M = t:dim() - local name = {} - for k = 1, M do - name[k] = t:get_header(k) - end - local row = {} - for k = 1, M do - row[name[k]] = t:get(1, k) - end + local row = t:cursor() local P = count_args(f(row)) local X, Y = matrix.alloc(N, P), matrix.alloc(N, 1) - for i = 1, N do - for k = 1, M do row[name[k]] = t:get(i, k) end - set_elements(X, P, i, f(row)) + for i, row in t:rows() do + set_elements(X, P, i, f(row, i)) Y:set(i, 1, t:get(i, jy)) end |