Make function tonumber local in matrix functions module - 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年04月09日 21:39:22 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年04月09日 21:39:22 +0200
commit0d681c0fe2aa68b05e1a0266c86a82c1055a5f5c (patch)
tree624f4ab8cdc7a23b109c807dd434bbb516f05934 /matrix.lua
parent062a149787504d97ab756521dedad16a28035080 (diff)
downloadgsl-shell-0d681c0fe2aa68b05e1a0266c86a82c1055a5f5c.tar.gz
Make function tonumber local in matrix functions module
Diffstat (limited to 'matrix.lua')
-rw-r--r--matrix.lua 18
1 files changed, 10 insertions, 8 deletions
diff --git a/matrix.lua b/matrix.lua
index 956a8a50..ac570eba 100644
--- a/matrix.lua
+++ b/matrix.lua
@@ -1,4 +1,5 @@
+
local ffi = require 'ffi'
local gsl = require 'gsl'
@@ -13,6 +14,7 @@ local gsl_matrix_complex = ffi.typeof('gsl_matrix_complex')
local gsl_complex = ffi.typeof('complex')
local gsl_check = require 'gsl-check'
+local tonumber = tonumber
local function check_real(x)
if type(x) ~= 'number' then error('expected real number', 3) end
@@ -34,7 +36,7 @@ end
local function cartesian(x)
if is_real(x) then
- return x, 0
+ return x, 0
else
return x[0], x[1]
end
@@ -99,14 +101,14 @@ local function matrix_cnew(n1, n2, f)
end
local function matrix_free(m)
- if m.owner then
+ if m.owner then
local b = m.block
b.ref_count = b.ref_count - 1
if b.ref_count == 0 then
ffi.C.free(b.data)
ffi.C.free(b)
end
- end
+ end
end
local function matrix_dim(m)
@@ -213,13 +215,13 @@ local function recttostr(x, y, eps)
if x_sub and y_sub then
fmt, x_sub, y_sub = '%.0f', x==0, y==0
end
-
+
if not x_sub then
local sign = x+eps < 0 and '-' or ''
local ax = abs(x)
if y_sub then
return format('%s'..fmt, sign, ax)
- else
+ else
return format('%s'..fmt..'%s', sign, ax, itostr(y, eps, fmt, true))
end
else
@@ -395,7 +397,7 @@ local function real_get(x) return x, 0 end
local function complex_get(z) return z[0], z[1] end
local function mat_real_get(m,i,j) return m.data[i*m.tda+j], 0 end
-local function mat_complex_get(m,i,j)
+local function mat_complex_get(m,i,j)
local idx = 2*i*m.tda+2*j
return m.data[idx], m.data[idx+1]
end
@@ -568,7 +570,7 @@ local complex_mt = {
return (ar == br) and (ai == bi)
end,
- __pow = function(z,n)
+ __pow = function(z,n)
if is_real(n) then
return gsl.gsl_complex_pow_real (z, n)
else
@@ -705,7 +707,7 @@ end
local matrix_mt = {
__gc = matrix_free,
-
+
__add = generic_add,
__sub = generic_sub,
__mul = generic_mul,
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月14日 02:08:30 +0000

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