種類
- インスタンスメソッド (39)
- 特異メソッド (4)
- 定数 (1)
キーワード
- * (1)
- ** (1)
- + (1)
- - (1)
- -@ (1)
-
/ (1) - == (1)
- I (1)
- abs (1)
- abs2 (1)
- angle (1)
- arg (1)
- coerce (1)
- conj (1)
- conjugate (1)
- denominator (1)
- eql? (1)
- fdiv (1)
- generic? (1)
- hash (1)
- imag (1)
- image (1)
- imaginary (1)
- inspect (1)
- magnitude (1)
-
marshal
_ dump (1) -
marshal
_ load (1) - numerator (1)
- phase (1)
- polar (2)
- quo (1)
- rationalize (2)
- real (1)
- real? (1)
- rect (2)
- rectangular (2)
-
to
_ f (1) -
to
_ i (1) -
to
_ r (1) -
to
_ s (1)
検索結果
先頭5件
-
Complex
# *(other) -> Complex (2) -
積を計算します。
...積を計算します。
@param other 自身に掛ける数
例:
Complex(1, 2) * 2 # => (2+4i)
Complex(1, 2) * Complex(2, 3) # => (-4+4i)
Complex(1, 2) * Rational(1, 2) # => ((1/2)+(1/1)*i)... -
Complex
# **(other) -> Complex (2) -
冪(べき)乗を計算します。
...冪(べき)乗を計算します。
@param other 自身を other 乗する数
例:
Complex('i') ** 2 # => (-1+0i)... -
Complex
# +(other) -> Complex (2) -
和を計算します。
...和を計算します。
@param other 自身に足す数
例:
Complex(1, 2) + Complex(2, 3) # => (3+5i)... -
Complex
# -(other) -> Complex (2) -
差を計算します。
...差を計算します。
@param other 自身から引く数
例:
Complex(1, 2) - Complex(2, 3) # => (-1-1i)... -
Complex
# -@ -> Complex (2) -
自身の符号を反転させたものを返します。
...自身の符号を反転させたものを返します。
例:
-Complex(1) # => (-1+0i)
-Complex(-1, 1) # => (1-1i)... -
Complex
# / (other) -> Complex (2) -
商を計算します。
...商を計算します。
@param other 自身を割る数
例:
Complex(10.0) / 3 # => (3.3333333333333335+(0/1)*i)
Complex(10) / 3 # => ((10/3)+(0/1)*i)... -
Complex
# ==(other) -> bool (2) -
数値として等しいか判定します。
...数値として等しいか判定します。
@param other 自身と比較する数値
例:
Complex(2, 1) == Complex(1) # => false
Complex(1, 0) == Complex(1) # => true
Complex(1, 0) == 1 # => true... -
Complex
# abs -> Float (2) -
自身の絶対値を返します。
...値を返します。
以下の計算の結果を Float オブジェクトで返します。
sqrt(self.real ** 2 + self.imag **2)
例:
Complex(1, 2).abs # => 2.23606797749979
Complex(3, 4).abs # => 5.0
Complex('1/2', '1/2').abs # => 0.7071067811865476
@see Complex#abs2... -
Complex
# abs2 -> Numeric (2) -
自身の絶対値の 2 乗を返します。
...以下の計算の結果を返します。
self.real ** 2 + self.imag **2
例:
Complex(1, 1).abs2 # => 2
Complex(1.0, 1.0).abs2 # => 2.0
Complex('1/2', '1/2').abs2 # => (1/2)
@see Complex#abs... -
Complex
# angle -> Float (2) -
自身の偏角を[-π,π]の範囲で返します。
...ます。
例:
Complex.polar(3, Math::PI/2).arg # => 1.5707963267948966
非正の実軸付近での挙動に注意してください。以下の例のように虚部が 0.0 と
-0.0 では値が変わります。
Complex(-1, 0).arg #=> 3.141592653589793
Complex(-1, -0).arg......1592653589793
Complex(-1, -0.0).arg #=> -3.141592653589793
Complex(0, 0.0).arg #=> 0.0
Complex(0, -0.0).arg #=> -0.0
Complex(-0.0, 0).arg #=> 3.141592653589793
Complex(-0.0, -0.0).arg #=> -3.141592653589793
[注意] 1.9.2 以下では... -
Complex
# arg -> Float (2) -
自身の偏角を[-π,π]の範囲で返します。
...ます。
例:
Complex.polar(3, Math::PI/2).arg # => 1.5707963267948966
非正の実軸付近での挙動に注意してください。以下の例のように虚部が 0.0 と
-0.0 では値が変わります。
Complex(-1, 0).arg #=> 3.141592653589793
Complex(-1, -0).arg......1592653589793
Complex(-1, -0.0).arg #=> -3.141592653589793
Complex(0, 0.0).arg #=> 0.0
Complex(0, -0.0).arg #=> -0.0
Complex(-0.0, 0).arg #=> 3.141592653589793
Complex(-0.0, -0.0).arg #=> -3.141592653589793
[注意] 1.9.2 以下では... -
Complex
# coerce(other) -> [Complex , Complex] (2) -
other を Complex に変換して [self, 変換後の other] の配列を返します。
...other を Complex に変換して [self, 変換後の other] の配列を返します。
@raise TypeError 変換できないオブジェクトを指定した場合に発生します。
例:
Complex(1).coerce(2) # => [(2+0i), (1+0i)]... -
Complex
# conj -> Complex (2) -
自身の共役複素数を返します。
...自身の共役複素数を返します。
例:
Complex(1, 2).conj # => (1-2i)... -
Complex
# conjugate -> Complex (2) -
自身の共役複素数を返します。
...自身の共役複素数を返します。
例:
Complex(1, 2).conj # => (1-2i)... -
Complex
# denominator -> Integer (2) -
分母を返します。
...うに、実部と虚部の分母の最小公倍数を整数で返します。
1 2 3+4i <- numerator(分子)
- + -i -> ----
2 3 6 <- denominator(分母)
例:
Complex('1/2+2/3i').denominator # => 6
Complex(3).numerator # => 1
@see Complex#numerator... -
Complex
# eql?(other) -> bool (2) -
自身と other の実部と虚部のクラスが等しく、それぞれが数値として等しい場 合に true を返します。そうでない場合に false を返します。
自身と other の実部と虚部のクラスが等しく、それぞれが数値として等しい場
合に true を返します。そうでない場合に false を返します。
@param other 自身と比較する数値 -
Complex
# fdiv(other) -> Complex (2) -
自身の実部と虚部をそれぞれ実数として other で割った商を返します。
...て other で割った商を返します。
@param other 自身を割る数
例:
Complex(11, 22).fdiv(3) # => (3.6666666666666665+7.333333333333333i)
Complex(11, 22).quo(3) # => ((11/3)+(22/3)*i)
@see Complex#quo... -
Complex
# hash -> Integer (2) -
自身のハッシュ値を返します。
自身のハッシュ値を返します。 -
Complex
# imag -> Numeric (2) -
自身の虚部を返します。
...自身の虚部を返します。
例:
Complex(3, 2).imag # => 2... -
Complex
# image -> Numeric (2) -
自身の虚部を返します。Complex#imag のエイリアスです。
...自身の虚部を返します。Complex#imag のエイリアスです。
例:
require 'complex'
Complex(3, 2).image # => 2... -
Complex
# imaginary -> Numeric (2) -
自身の虚部を返します。
...自身の虚部を返します。
例:
Complex(3, 2).imag # => 2... -
Complex
# inspect -> String (2) -
自身を人間が読みやすい形の文字列表現にして返します。
自身を人間が読みやすい形の文字列表現にして返します。
"(1+1i)", "(1-1i)" のような文字列を返します。 -
Complex
# magnitude -> Float (2) -
自身の絶対値を返します。
...値を返します。
以下の計算の結果を Float オブジェクトで返します。
sqrt(self.real ** 2 + self.imag **2)
例:
Complex(1, 2).abs # => 2.23606797749979
Complex(3, 4).abs # => 5.0
Complex('1/2', '1/2').abs # => 0.7071067811865476
@see Complex#abs2... -
Complex
# marshal _ dump -> Array (2) -
Complex#marshal_load で復元可能な配列を返します。
...
Complex#marshal_load で復元可能な配列を返します。
@see Complex#marshal_load... -
Complex
# marshal _ load -> Complex (2) -
Complex#marshal_dump で得られた配列を基に、Complex オブジェ クトを復元します。
...
Complex#marshal_dump で得られた配列を基に、Complex オブジェ
クトを復元します。
@see Complex#marshal_dump... -
Complex
# numerator -> Complex (2) -
分子を返します。
...分子を返します。
例:
Complex('1/2+2/3i').numerator # => (3+4i)
Complex(3).numerator # => (3+0i)
@see Complex#denominator... -
Complex
# phase -> Float (2) -
自身の偏角を[-π,π]の範囲で返します。
...ます。
例:
Complex.polar(3, Math::PI/2).arg # => 1.5707963267948966
非正の実軸付近での挙動に注意してください。以下の例のように虚部が 0.0 と
-0.0 では値が変わります。
Complex(-1, 0).arg #=> 3.141592653589793
Complex(-1, -0).arg......1592653589793
Complex(-1, -0.0).arg #=> -3.141592653589793
Complex(0, 0.0).arg #=> 0.0
Complex(0, -0.0).arg #=> -0.0
Complex(-0.0, 0).arg #=> 3.141592653589793
Complex(-0.0, -0.0).arg #=> -3.141592653589793
[注意] 1.9.2 以下では... -
Complex
# polar -> [Numeric , Numeric] (2) -
自身の絶対値と偏角を配列にして返します。
...自身の絶対値と偏角を配列にして返します。
例:
Complex.polar(1, 2).polar # => [1, 2]... -
Complex
# quo(other) -> Complex (2) -
商を計算します。
...商を計算します。
@param other 自身を割る数
例:
Complex(10.0) / 3 # => (3.3333333333333335+(0/1)*i)
Complex(10) / 3 # => ((10/3)+(0/1)*i)... -
Complex
# rationalize -> Rational (2) -
自身を Rational に変換します。
...eps 許容する誤差。常に無視されます。
@raise RangeError 虚部が 0 ではない場合に発生します。
例:
Complex(3).to_r # => (3/1)
Complex(3, 2).to_r # => RangeError... -
Complex
# rationalize(eps) -> Rational (2) -
自身を Rational に変換します。
...eps 許容する誤差。常に無視されます。
@raise RangeError 虚部が 0 ではない場合に発生します。
例:
Complex(3).to_r # => (3/1)
Complex(3, 2).to_r # => RangeError... -
Complex
# real -> Numeric (2) -
自身の実部を返します。
...自身の実部を返します。
例:
Complex(3, 2).real # => 3... -
Complex
# real? -> false (2) -
常に false を返します。
常に false を返します。
@see Numeric#real? -
Complex
# rect -> [Numeric , Numeric] (2) -
実部と虚部を配列にして返します。
...実部と虚部を配列にして返します。
例:
Complex(3).rect # => [3, 0]
Complex(3.5).rect # => [3.5, 0]
Complex(3, 2).rect # => [3, 2]... -
Complex
# rectangular -> [Numeric , Numeric] (2) -
実部と虚部を配列にして返します。
...実部と虚部を配列にして返します。
例:
Complex(3).rect # => [3, 0]
Complex(3.5).rect # => [3.5, 0]
Complex(3, 2).rect # => [3, 2]... -
Complex
# to _ f -> Float (2) -
自身を Float に変換します。
...自身を Float に変換します。
@raise RangeError 虚部が 0 ではない場合に発生します。
例:
Complex(3).to_f # => 3.0
Complex(3.5).to_f # => 3.5
Complex(3, 2).to_f # => RangeError... -
Complex
# to _ i -> Integer (2) -
自身を整数に変換します。
...数に変換します。
@raise RangeError 虚部が 0 ではない場合に発生します。
例:
Complex(3).to_i # => 3
Complex(3).to_i # => 3
Complex(3.5).to_i # => 3
Complex(3, 2).to_i # => RangeError... -
Complex
# to _ r -> Rational (2) -
自身を Rational に変換します。
...eps 許容する誤差。常に無視されます。
@raise RangeError 虚部が 0 ではない場合に発生します。
例:
Complex(3).to_r # => (3/1)
Complex(3, 2).to_r # => RangeError... -
Complex
# to _ s -> String (2) -
自身を "実部 + 虚部i" 形式の文字列にして返します。
自身を "実部 + 虚部i" 形式の文字列にして返します。 -
Complex
. generic?(other) -> bool (2) -
other が Integer Float Rational クラスのオブジェクト かどうか判定します。
other が Integer Float Rational クラスのオブジェクト
かどうか判定します。
@param other 判定対象のオブジェクト
@return Integer Float Rational クラスのオブジェクトの
時 trueそれ以外の場合には false を返します。 -
Complex
. polar(r , theta = 0) -> Complex (2) -
絶対値が r、偏角が theta である Complex クラスのオブジェクトを生成します。
...である Complex クラスのオブジェクトを生成します。
@param r 生成する複素数の絶対値。
@param theta 生成する複素数の偏角。単位はラジアンです。省略した場合は 0 です。
例:
Complex.polar(2.0) # => (2.0+0.0i)
Complex.polar(2.......0, 0) # => (2.0+0.0i)
Complex.polar(2.0, Math::PI) # => (-2.0+2.4492127076447545e-16i)... -
Complex
. rect(r , i = 0) -> Complex (2) -
実部が r、虚部が i である Complex クラスのオブジェクトを生成します。
...i である Complex クラスのオブジェクトを生成します。
@param r 生成する複素数の実部。
@param i 生成する複素数の虚部。省略した場合は 0 です。
例:
Complex.rect(1) # => (1+0i)
Complex.rect(1, 2) # => (1+2i)
Complex.rectangula......r(1, 2) # => (1+2i)
@see Kernel.#Complex... -
Complex
. rectangular(r , i = 0) -> Complex (2) -
実部が r、虚部が i である Complex クラスのオブジェクトを生成します。
...i である Complex クラスのオブジェクトを生成します。
@param r 生成する複素数の実部。
@param i 生成する複素数の虚部。省略した場合は 0 です。
例:
Complex.rect(1) # => (1+0i)
Complex.rect(1, 2) # => (1+2i)
Complex.rectangula......r(1, 2) # => (1+2i)
@see Kernel.#Complex... -
Complex
:: I -> Complex (2) -
虚数単位です。(0+1i) を返します。
虚数単位です。(0+1i) を返します。
