881件ヒット
[1-100件を表示]
(0.165秒)
種類
- インスタンスメソッド (782)
- モジュール関数 (33)
- 特異メソッド (33)
- クラス (22)
- 定数 (11)
クラス
モジュール
- Enumerable (22)
- Kernel (33)
キーワード
- * (11)
- ** (11)
- + (11)
- - (11)
- -@ (22)
-
/ (21) - < (11)
- <= (11)
- <=> (5)
- == (11)
- > (11)
- >= (11)
- I (11)
- Numeric (11)
- Rational (11)
- abs (11)
- abs2 (11)
- angle (22)
- arg (22)
- between? (11)
- clamp (11)
- coerce (11)
- conj (22)
- conjugate (22)
- denominator (22)
- fdiv (50)
- finite? (8)
- i (11)
- imag (22)
- imaginary (22)
- infinite? (16)
- inspect (11)
- magnitude (11)
-
marshal
_ dump (11) - numerator (22)
- phase (22)
- polar (33)
- quo (22)
- rationalize (22)
- real (22)
- real? (22)
- rect (33)
- rectangular (33)
-
slice
_ before (22) -
to
_ c (44) -
to
_ f (11) -
to
_ i (11) -
to
_ r (11) -
to
_ s (11)
検索結果
先頭5件
-
Complex (52092.0)
-
複素数を扱うクラスです。
...
Complex オブジェクトを作成するには、Kernel.#Complex、
Complex.rect、Complex.polar、Numeric#to_c、
String#to_c のいずれかを使用します。
//emlist[Complex オブジェクトの作り方][ruby]{
Complex(1) # => (1+0i)
Complex(2, 3) # => (2+3i)
Complex.po......lar(2, 3) # => (-1.9799849932008908+0.2822400161197344i)
Complex(0.3) # => (0.3+0i)
Complex('0.3-0.5i') # => (0.3-0.5i)
Complex('2/3+3/4i') # => ((2/3)+(3/4)*i)
Complex('1@2') # => (-0.4161468365471424+0.9092974268256817i)
3.to_c # => (3+0i)
0.3.to_c # => (......# => ((2/3)+(3/4)*i)
'1@2'.to_c # => (-0.4161468365471424+0.9092974268256817i)
//}
Complex オブジェクトは有理数の形式も実数の形式も扱う事ができます。
//emlist[例][ruby]{
Complex(1, 1) / 2 # => ((1/2)+(1/2)*i)
Complex(1, 1) / 2.0 # => (0.5+0.5i)
//}... -
Complex
# coerce(other) -> [Complex , Complex] (35426.0) -
other を Complex に変換して [変換後の other, self] の配列を返します。
...other を Complex に変換して [変換後の other, self] の配列を返します。
@raise TypeError 変換できないオブジェクトを指定した場合に発生します。
//emlist[例][ruby]{
Complex(1).coerce(2) # => [(2+0i), (1+0i)]
//}... -
Complex
. rect(r , i = 0) -> Complex (35244.0) -
実部が r、虚部が i である Complex クラスのオブジェクトを生成します。
...る Complex クラスのオブジェクトを生成します。
@param r 生成する複素数の実部。
@param i 生成する複素数の虚部。省略した場合は 0 です。
//emlist[例][ruby]{
Complex.rect(1) # => (1+0i)
Complex.rect(1, 2) # => (1+2i)
Complex.rectangul......ar(1, 2) # => (1+2i)
//}
@see Kernel.#Complex... -
Complex
. rectangular(r , i = 0) -> Complex (35244.0) -
実部が r、虚部が i である Complex クラスのオブジェクトを生成します。
...る Complex クラスのオブジェクトを生成します。
@param r 生成する複素数の実部。
@param i 生成する複素数の虚部。省略した場合は 0 です。
//emlist[例][ruby]{
Complex.rect(1) # => (1+0i)
Complex.rect(1, 2) # => (1+2i)
Complex.rectangul......ar(1, 2) # => (1+2i)
//}
@see Kernel.#Complex... -
Complex
# numerator -> Complex (35221.0) -
分子を返します。
...分子を返します。
//emlist[例][ruby]{
Complex('1/2+2/3i').numerator # => (3+4i)
Complex(3).numerator # => (3+0i)
//}
@see Complex#denominator... -
Complex
# conjugate -> Complex (35210.0) -
自身の共役複素数を返します。
...自身の共役複素数を返します。
//emlist[例][ruby]{
Complex(1, 2).conj # => (1-2i)
//}... -
Complex
# angle -> Float (35150.0) -
自身の偏角を[-π,π]の範囲で返します。
...囲で返します。
//emlist[例][ruby]{
Complex.polar(3, Math::PI/2).arg # => 1.5707963267948966
//}
非正の実軸付近での挙動に注意してください。以下の例のように虚部が 0.0 と
-0.0 では値が変わります。
//emlist[例][ruby]{
Complex(-1, 0).arg......3.141592653589793
Complex(-1, -0).arg #=> 3.141592653589793
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
//}
@see Numeric#arg... -
Complex
# phase -> Float (35150.0) -
自身の偏角を[-π,π]の範囲で返します。
...囲で返します。
//emlist[例][ruby]{
Complex.polar(3, Math::PI/2).arg # => 1.5707963267948966
//}
非正の実軸付近での挙動に注意してください。以下の例のように虚部が 0.0 と
-0.0 では値が変わります。
//emlist[例][ruby]{
Complex(-1, 0).arg......3.141592653589793
Complex(-1, -0).arg #=> 3.141592653589793
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
//}
@see Numeric#arg... -
Complex
# inspect -> String (35132.0) -
自身を人間が読みやすい形の文字列表現にして返します。
...//emlist[例][ruby]{
Complex(2).inspect # => "(2+0i)"
Complex('-8/6').inspect # => "((-4/3)+0i)"
Complex('1/2i').inspect # => "(0+(1/2)*i)"
Complex(0, Float::INFINITY).inspect # => "(0+Infinity*i)"
Complex(Float::NAN, Float::NAN).inspect... -
Complex
# magnitude -> Numeric (35126.0) -
自身の絶対値を返します。
...す。
以下の計算の結果を Float オブジェクトで返します。
sqrt(self.real ** 2 + self.imag ** 2)
//emlist[例][ruby]{
Complex(1, 2).abs # => 2.23606797749979
Complex(3, 4).abs # => 5.0
Complex('1/2', '1/2').abs # => 0.7071067811865476
//}
@see Complex#abs2...