複素数クラス
概要
複素数クラスは、実部と虚部の2つの実数をもつユーザーデータ型の変数である。
これを使用することで、複素数の計算を簡単に行うことができる。
C++の
std::complex
を使用しており、実装されている関数の一部もこれらに基づく。
complex
にある関数で使用できるほか、複素数クラス同士の四則演算や比較演算が可能。
また、複素数クラス自体にメタテーブルを設定しているため、
textmodule.complex.new(2, 1):cos()
のような呼び出しも可能である。
メタテーブル
table:_
パラメータ 型 概要
real function
complex.real
imag function
complex.imag
r function
complex.r
i function
complex.i
__tostring function tostring関数を使用した時を定義したメタメソッド。
complex:__tostring
__add function 複素数クラス同士の加算(+)を定義したメタメソッド。
complex:__add
__sub function 複素数クラス同士の減算(-)を定義したメタメソッド。
complex:__sub
__mul function 複素数クラス同士の乗算(*)を定義したメタメソッド。
complex:__mul
__div function 複素数クラス同士の除算(/)を定義したメタメソッド。
complex:__div
__pow function 複素数クラス同士の累乗(^)を定義したメタメソッド。
complex:__pow
__unm function 複素数クラスの符号の反転(単項の -)を定義したメタメソッド。
complex:__unm
__lt function 複素数クラス同士の比較(<)を定義したメタメソッド。
complex:__lt
__le function 複素数クラス同士の比較(<=)を定義したメタメソッド。
complex:__le
__newindex function 複素数クラスの添字代入を定義したメタメソッド。
complex:__newindex
__call function
complex:__call
__type function
complex:__type
__tonumber function
complex:__tonumber
__cos function
complex.cos
__sin function
complex.sin
__tan function
complex.tan
__cosh function
complex.cosh
__sinh function
complex.sinh
__tanh function
complex.tanh
__acos function
complex.acos
__asin function
complex.asin
__atan function
complex.atan
__acosh function
complex.acosh
__asinh function
complex.asinh
__atanh function
complex.atanh
__abs function
complex.abs
__exp function
complex.exp
__log function
complex.log
__pow function
complex.pow
__sqrt function
complex.sqrt
__norm function
complex.norm
__conj function
complex.conj
__table function
complex.table
vector2 function
complex.vector2
abs function
complex.abs
norm function
complex.norm
conj function
complex.conj
arg function
complex.arg
proj function
complex.proj
polar function
complex.polar