gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/matrix.lua
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 /matrix.lua
parente693e320e7cf0d0fc30468ba352aea8aeb8c93c8 (diff)
downloadgsl-shell-92b25ce3d76f5352730045029ed40524e37e1f28.tar.gz
Remove no longer useful lua_index_style variable
Diffstat (limited to 'matrix.lua')
-rw-r--r--matrix.lua 21
1 files changed, 8 insertions, 13 deletions
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.25.1) at 2025年09月16日 15:52:16 +0000

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