Use native GSL functions to set matrix to zero or identity - 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.abbate@gmail.com>2013年08月17日 19:31:45 +0200
committerFrancesco Abbate <francesco.abbate@gmail.com>2013年08月17日 19:44:08 +0200
commit903757db1d6224de0e37ad4c6002e1897f7b30f7 (patch)
treec934c4d6c7e7bd50eb3293ef415fb7f3fbcf6a86 /matrix.lua
parentf746cadb80a64ae34e2a00063eaf963e80c768a5 (diff)
downloadgsl-shell-903757db1d6224de0e37ad4c6002e1897f7b30f7.tar.gz
Use native GSL functions to set matrix to zero or identity
Diffstat (limited to 'matrix.lua')
-rw-r--r--matrix.lua 7
1 files changed, 3 insertions, 4 deletions
diff --git a/matrix.lua b/matrix.lua
index 1e7a86fc..42519243 100644
--- a/matrix.lua
+++ b/matrix.lua
@@ -93,7 +93,7 @@ local function matrix_new(n1, n2, f)
end
end
else
- ffi.fill(m.data, n1 * n2 * ffi.sizeof('double'), 0)
+ gsl.gsl_matrix_set_zero(m)
end
return m
end
@@ -110,7 +110,7 @@ local function matrix_cnew(n1, n2, f)
end
end
else
- ffi.fill(m.data, 2 * n1 * n2 * ffi.sizeof('double'), 0)
+ gsl.gsl_matrix_complex_set_zero(m)
end
return m
end
@@ -616,8 +616,7 @@ ffi.metatype(gsl_complex, complex_mt)
local function matrix_new_unit(n)
local m = matrix_alloc(n, n)
- for k = 0, n*n - 1 do m.data[k] = 0 end
- for k = 0, n-1 do m.data[k*(n+1)] = 1 end
+ gsl.gsl_matrix_set_identity(m)
return m
end
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月21日 06:37:30 +0000

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