Remove no longer useful lua_index_style variable - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2012年02月07日 22:55:22 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年02月07日 22:55:22 +0100
commit92b25ce3d76f5352730045029ed40524e37e1f28 (patch)
tree2e24671a3d969714bb657645b2cf686df3468a0c
parente693e320e7cf0d0fc30468ba352aea8aeb8c93c8 (diff)
downloadgsl-shell-92b25ce3d76f5352730045029ed40524e37e1f28.tar.gz
Remove no longer useful lua_index_style variable
Diffstat
-rw-r--r--graph-init.lua 4
-rw-r--r--iter.lua 2
-rw-r--r--matrix.lua 21
3 files changed, 9 insertions, 18 deletions
diff --git a/graph-init.lua b/graph-init.lua
index 752a24ea..48f0f828 100644
--- a/graph-init.lua
+++ b/graph-init.lua
@@ -5,8 +5,6 @@ local floor, pi = math.floor, math.pi
local bor, band, lshift, rshift = bit.bor, bit.band, bit.lshift, bit.rshift
-local lua_index_style = gslsh.lua_index_style
-
local n_sampling_max = 8192
local n_sampling_default = 256
@@ -61,7 +59,7 @@ function graph.filine(f, a, b)
end
function graph.xyline(x, y)
- local i0 = lua_index_style and 1 or 0
+ local i0 = 1
local n = matrix.dim(x)
local ln = graph.path(x[i0], y[i0])
for i=i0+1, i0+n-1 do ln:line_to(x[i], y[i]) end
diff --git a/iter.lua b/iter.lua
index c6173fbb..d28d9bd7 100644
--- a/iter.lua
+++ b/iter.lua
@@ -22,8 +22,6 @@ local cat = table.concat
local fmt = string.format
local gsl_type = gslsh.type
-gslsh.lua_index_style = true
-
function math.divmod(n, p)
local r = n % p
return (n-r)/p, r
diff --git a/matrix.lua b/matrix.lua
index 75e1d19b..583d2ed3 100644
--- a/matrix.lua
+++ b/matrix.lua
@@ -8,8 +8,6 @@ local format = string.format
local check = require 'check'
local is_integer, is_real = check.is_integer, check.is_real
-local lua_index_style = gslsh.lua_index_style
-
local gsl_matrix = ffi.typeof('gsl_matrix')
local gsl_matrix_complex = ffi.typeof('gsl_matrix_complex')
local gsl_complex = ffi.typeof('complex')
@@ -73,7 +71,7 @@ local function matrix_new(n1, n2, f)
if f then
for i=0, n1-1 do
for j=0, n2-1 do
- local x = check_real(lua_index_style and f(i+1, j+1) or f(i,j))
+ local x = check_real(f(i+1, j+1))
m.data[i*n2+j] = x
end
end
@@ -88,7 +86,7 @@ local function matrix_cnew(n1, n2, f)
if f then
for i=0, n1-1 do
for j=0, n2-1 do
- local z = lua_index_style and f(i+1, j+1) or f(i,j)
+ local z = f(i+1, j+1)
local x, y = cartesian(z)
m.data[2*i*n2+2*j ] = x
m.data[2*i*n2+2*j+1] = y
@@ -135,27 +133,24 @@ end
local function check_indices(m, i, j)
local r, c = matrix_dim(m)
- if lua_index_style then i, j = i-1, j-1 end
- if i < 0 or i >= r or j < 0 or j >= c then
+ if i < 1 or i > r or j < 1 or j > c then
error('matrix index out of bounds', 3)
end
- return i, j
+ return i-1, j-1
end
local function check_row_index(m, i)
- if lua_index_style then i = i-1 end
- if i < 0 or i >= matrix_len(m) then
+ if i < 1 or i > matrix_len(m) then
error('matrix index out of bounds', 3)
end
- return i
+ return i-1
end
local function check_col_index(m, j)
- if lua_index_style then j = j-1 end
- if j < 0 or j >= tonumber(m.size2) then
+ if j < 1 or j > tonumber(m.size2) then
error('matrix index out of bounds', 3)
end
- return j
+ return j-1
end
local function matrix_get(m, i, j)
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月18日 00:55:16 +0000

AltStyle によって変換されたページ (->オリジナル) /