Introduce equality operator for complex numbers - 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>2011年11月09日 12:48:57 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2011年11月09日 12:48:57 +0100
commit83d2b733c281b8e041e3301f996ca04d16bfc09b (patch)
tree44431e65cd6f7cd5e503896d868ead8adcba7673 /matrix.lua
parent64d1aa5a940826b6c62db79549fa77878508ff07 (diff)
downloadgsl-shell-83d2b733c281b8e041e3301f996ca04d16bfc09b.tar.gz
Introduce equality operator for complex numbers
Diffstat (limited to 'matrix.lua')
-rw-r--r--matrix.lua 6
1 files changed, 6 insertions, 0 deletions
diff --git a/matrix.lua b/matrix.lua
index 9c8e6215..75e1d19b 100644
--- a/matrix.lua
+++ b/matrix.lua
@@ -538,6 +538,12 @@ local complex_mt = {
__mul = generic_mul,
__div = generic_div,
+ __eq = function(a, b)
+ local ar, ai = cartesian(a)
+ local br, bi = cartesian(b)
+ return (ar == br) and (ai == bi)
+ end,
+
__pow = function(z,n)
if is_real(n) then
return gsl.gsl_complex_pow_real (z, n)
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月11日 21:08:38 +0000

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