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:
Diffstat (limited to 'matrix.lua')
-rw-r--r--matrix.lua 19
1 files changed, 15 insertions, 4 deletions
diff --git a/matrix.lua b/matrix.lua
index b911812b..d7c5e75b 100644
--- a/matrix.lua
+++ b/matrix.lua
@@ -522,7 +522,7 @@ local function matrix_complex_unm(a)
return m
end
-local function matrix_norm(m)
+local function matrix_norm2(m)
local r, c = matrix_dim(m)
local tda = m.tda
local ssq, idx = 0, 0
@@ -533,10 +533,14 @@ local function matrix_norm(m)
end
idx = idx + tda
end
- return sqrt(ssq)
+ return ssq
end
-local function matrix_complex_norm(m)
+local function matrix_norm(m)
+ return sqrt(matrix_norm2(m))
+end
+
+local function matrix_complex_norm2(m)
local r, c = matrix_dim(m)
local tda = m.tda
local ssq, idx = 0, 0
@@ -547,7 +551,11 @@ local function matrix_complex_norm(m)
end
idx = idx + 2*tda
end
- return sqrt(ssq)
+ return ssq
+end
+
+local function matrix_complex_norm(m)
+ return sqrt(matrix_complex_norm2(m))
end
complex = {
@@ -556,6 +564,7 @@ complex = {
real = complex_real,
imag = complex_imag,
abs = complex_abs,
+ norm = complex_abs,
norm2 = complex_norm2,
rect = cartesian,
i = 1i,
@@ -675,6 +684,7 @@ local matrix_methods = {
set = matrix_set,
copy = matrix_copy,
norm = matrix_norm,
+ norm2 = matrix_norm2,
slice = matrix_slice,
show = matrix_display_gen(mat_real_get),
}
@@ -740,6 +750,7 @@ local matrix_complex_methods = {
set = matrix_complex_set,
copy = matrix_complex_copy,
norm = matrix_complex_norm,
+ norm2 = matrix_complex_norm2,
slice = matrix_complex_slice,
show = matrix_display_gen(mat_complex_get),
}
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月12日 00:05:26 +0000

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