Complex 組込みオブジェクトこの章では組込み変数領域が初めから備えている
Complex 組込みオブジェクトを定義する。
Complex
オブジェクトは、スクリプトで扱われる整数を表すオブジェクトである。
Complex のメンバprototypeNumber.prototype
を準プロトタイプとするオブジェクト。name"Complex"zeroComplex オブジェクト。オブジェクトの re
プロパティの値と im プロパティの値はどちらも 0 を表す
Integer オブジェクトである。oneComplex オブジェクト。このオブジェクトの re
プロパティの値は 1 を表す Integer
オブジェクトであり、またこのオブジェクトの im プロパティの値は 0
を表す Integer
オブジェクトである。iComplex オブジェクト。このオブジェクトの re
プロパティの値は 0 を表す Integer
オブジェクトであり、またこのオブジェクトの im プロパティの値は 1
を表す Integer
オブジェクトである。conj メソッドComplex
オブジェクトを引数として関数として呼出されると、その引数の conj
プロパティを取得してその結果を返す。
上記以外の引数における関数としての呼び出しの動作は規定しない。Complex の内部メンバ$prototypeType.prototypeComplex の関数としての呼出しComplex は関数として呼出し可能であり、
関数として呼出されると次の処理を実行する:
Number オブジェクト x の場合x + 0i の結果を返す。Number オブジェクト x, y
の場合x + y * 1i の結果を返す。Complex オブジェクトを値とする正常終了の結果を返してもよい。
文字列オブジェクトの内容を数値として解釈しないまたはできない場合は、新しい ArgumentError のインスタンスを投げる。
文字列オブジェクトの内容の解釈の方法は実行環境に任せる。Complex オブジェクトのプロパティComplex オブジェクトは以下のプロパティを持つ。ただし、re・im プロパティ以外のプロパティについては、
Complex.prototype やその準プロトタイプのプロパティが
スクリプトの実行によって変更された場合は、この限りではない。
reReal
オブジェクト。この値は複素数の実部を表す。imReal
オブジェクト。この値は複素数の虚部を表す。$get$abs メソッドMath$abs メソッド@{ @this.abs2 ^ /2 }$get$abs2 メソッドMath$abs2 メソッド@{ @this.re * @this.re + @this.im * @this.im }$get$conj メソッドMath$conj メソッド@{ @this.re - 1i * @this.im }Math$re メソッド@{ @this.re }Math$im メソッド@{ @this.im }$get$arg メソッドMath$arg メソッド@{ Math.atan[@this.re, @this.im] }$get$sign メソッドMath$sign メソッド@{ @this == 0 ? 0 : @this / @this.abs }$get$exp メソッドMath$exp メソッド@{ @this.re.exp * (@this.im.cos + 1i * @this.im.sin) }$get$log メソッドMath$log メソッド@{ z == 0i ? @cinf : @this.abs.log + 1i * @this.arg } または
@{ z == 0i ? @cinf : @this.abs2.log / 2 + 1i * @this.arg }$get$sin メソッドMath$sin メソッド@{ (@this * 1i).sinh / 1i }$get$cos メソッドMath$cos メソッド@{ (@this * 1i).cosh }$get$tan メソッドMath$tan メソッド@{ (@this * 1i).tanh / 1i }$get$asin メソッドMath$asin メソッド@{ (@this * 1i).asinh / 1i }$get$acos メソッドMath$acos メソッドComplex オブジェクト z を @this
値として関数として呼びだされると、次の動作を行う:
z.asin の結果の値を
v とする。Float オブジェクトを p
とする。ただし、ap(p) > ap(v.re)
とする。p - v の結果を返す。$get$atan メソッドMath$atan メソッド@{ (@this * 1i).atanh / 1i }$get$sinh メソッドMath$sinh メソッド@{ (@this.exp - (-@this).exp) / 2 } または
@{ @this.re.sinh * @this.im.cos + 1i * @this.re.cosh * @this.im.sin
}$get$cosh メソッドMath$cosh メソッド@{ (@this.exp + (-@this).exp) / 2 } または
@{ @this.re.cosh * @this.im.cos + 1i * @this.re.sinh * @this.im.sin
}$get$tanh メソッドMath$tanh メソッド@{ (@this.exp - (-@this).exp) / (@this.exp + (-@this).exp) } または
@{ ((2 * @this.re).sinh + 1i * (2 * @this.im).sin) /
((2 * @this.re).cosh + (2 * @this.im).cos) }$get$asinh メソッドMath$asinh メソッド@{ (@this + (@this * @this + 1).sqrt).log }$get$acosh メソッドMath$acosh メソッド@{ (@this + (@this + 1).sqrt * (@this - 1).sqrt).log }$get$atanh メソッドMath$atanh メソッド@{ ((1 + @this).log - (1 - @this).log) / 2 }toString メソッドComplex オブジェクトを @this
値としてこのメソッドを呼出すと、渡された @this 値を文字列オブジェクトに変換したものを結果として返す。
文字列オブジェクトへの変換の方法は実行環境に任せる。上記各メソッドの呼出しにおける動作では、実行環境は次のことを仮定して 動作を効率化しても良い:
Complex オブジェクトである。実際のメソッドの呼出しにおいてこれらの仮定が満たされていない場合、 動作は未定義である。
上記計算における π や ap 等の定義は Math での定義に従う。