るりまサーチ (Ruby 2.3.0)

最速Rubyリファレンスマニュアル検索!
82件ヒット [1-82件を表示] (0.122秒)

別のキーワード

  1. _builtin complex
  2. complex rect
  3. complex polar
  4. kernel complex
  5. complex rationalize

ライブラリ

クラス

モジュール

キーワード

検索結果

Complex#-(other) -> Complex (117679.0)

差を計算します。

差を計算します。

@param other 自身から引く数

//emlist[例][ruby]{
Complex(1, 2) - Complex(2, 3) # => (-1-1i)
//}

Complex#-@ -> Complex (81697.0)

自身の符号を反転させたものを返します。

自身の符号を反転させたものを返します。

//emlist[例][ruby]{
-Complex(1) # => (-1+0i)
-Complex(-1, 1) # => (1-1i)
//}

Complex#coerce(other) -> [Complex, Complex] (63976.0)

other を Complex に変換して [変換後の other, self] の配列を返します。

other を Complex に変換して [変換後の other, self] の配列を返します。

@raise TypeError 変換できないオブジェクトを指定した場合に発生します。

//emlist[例][ruby]{
Complex(1).coerce(2) # => [(2+0i), (1+0i)]
//}

Complex#*(other) -> Complex (63679.0)

積を計算します。

積を計算します。

@param other 自身に掛ける数

//emlist[例][ruby]{
Complex(1, 2) * 2 # => (2+4i)
Complex(1, 2) * Complex(2, 3) # => (-4+7i)
Complex(1, 2) * Rational(1, 2) # => ((1/2)+(1/1)*i)
//}

Complex#fdiv(other) -> Complex (63661.0)

self を other で割った商を返します。 実部と虚部が共に Float の値になります。

self を other で割った商を返します。
実部と虚部が共に Float の値になります。

@param other 自身を割る数

//emlist[例][ruby]{
Complex(11, 22).fdiv(3) # => (3.6666666666666665+7.333333333333333i)
Complex(11, 22).quo(3) # => ((11/3)+(22/3)*i)
//}

@see Complex#quo

絞り込み条件を変える

Complex#numerator -> Complex (63661.0)

分子を返します。

分子を返します。

//emlist[例][ruby]{
Complex('1/2+2/3i').numerator # => (3+4i)
Complex(3).numerator # => (3+0i)
//}

@see Complex#denominator

Complex#/(other) -> Complex (63646.0)

商を計算します。

商を計算します。

@param other 自身を割る数

//emlist[例][ruby]{
Complex(10.0) / 3 # => (3.3333333333333335+(0/1)*i)
Complex(10) / 3 # => ((10/3)+(0/1)*i)
//}

@see Numeric#quo

Complex#conj -> Complex (63646.0)

自身の共役複素数を返します。

自身の共役複素数を返します。

//emlist[例][ruby]{
Complex(1, 2).conj # => (1-2i)
//}

Complex#conjugate -> Complex (63646.0)

自身の共役複素数を返します。

自身の共役複素数を返します。

//emlist[例][ruby]{
Complex(1, 2).conj # => (1-2i)
//}

Complex#quo(other) -> Complex (63646.0)

商を計算します。

商を計算します。

@param other 自身を割る数

//emlist[例][ruby]{
Complex(10.0) / 3 # => (3.3333333333333335+(0/1)*i)
Complex(10) / 3 # => ((10/3)+(0/1)*i)
//}

@see Numeric#quo

絞り込み条件を変える

Complex#+(other) -> Complex (63643.0)

和を計算します。

和を計算します。

@param other 自身に足す数

//emlist[例][ruby]{
Complex(1, 2) + Complex(2, 3) # => (3+5i)
//}

Complex#**(other) -> Complex (63625.0)

冪(べき)乗を計算します。

冪(べき)乗を計算します。

@param other 自身を other 乗する数

//emlist[例][ruby]{
Complex('i') ** 2 # => (-1+0i)
//}

Complex#angle -> Float (63592.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...

Complex#arg -> Float (63592.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...

Complex#phase -> Float (63592.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...

絞り込み条件を変える

Complex#==(other) -> bool (63394.0)

数値として等しいか判定します。

数値として等しいか判定します。

@param other 自身と比較する数値

//emlist[例][ruby]{
Complex(2, 1) == Complex(1) # => false
Complex(1, 0) == Complex(1) # => true
Complex(1, 0) == 1 # => true
//}

Complex#denominator -> Integer (63394.0)

分母を返します。

分母を返します。

以下のように、実部と虚部の分母の最小公倍数を整数で返します。

1 2 3+4i <- numerator(分子)
- + -i -> ----
2 3 6 <- denominator(分母)

//emlist[例][ruby]{
Complex('1/2+2/3i').denominator # => 6
Complex(3).numerator # => 1
//}

@see Complex#numerator

Complex#inspect -> String (63394.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:...

Complex#to_s -> String (63394.0)

自身を "実部 + 虚部i" 形式の文字列にして返します。

自身を "実部 + 虚部i" 形式の文字列にして返します。

//emlist[例][ruby]{
Complex(2).to_s # => "2+0i"
Complex('-8/6').to_s # => "-4/3+0i"
Complex('1/2i').to_s # => "0+1/2i"
Complex(0, Float::INFINITY).to_s # => "0+Infinity*i"
Complex(Float::NAN, Float::NAN).to_s...

Complex#marshal_dump -> Array (63388.0)

Marshal.#load のためのメソッドです。 Complex::compatible#marshal_load で復元可能な配列を返します。

Marshal.#load のためのメソッドです。
Complex::compatible#marshal_load で復元可能な配列を返します。

2.0 以降では Marshal.#load で 1.8 系の Complex オブジェクト
を保存した文字列も復元できます。

[注意] Complex::compatible は通常の方法では参照する事ができません。

絞り込み条件を変える

Complex#abs -> Numeric (63376.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

Complex#abs2 -> Numeric (63376.0)

自身の絶対値の 2 乗を返します。

自身の絶対値の 2 乗を返します。

以下の計算の結果を返します。

self.real ** 2 + self.imag ** 2

//emlist[例][ruby]{
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#magnitude -> Numeric (63376.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

Complex#rect -> [Numeric, Numeric] (63358.0)

実部と虚部を配列にして返します。

実部と虚部を配列にして返します。

//emlist[例][ruby]{
Complex(3).rect # => [3, 0]
Complex(3.5).rect # => [3.5, 0]
Complex(3, 2).rect # => [3, 2]
//}

@see Numeric#rect

Complex#rectangular -> [Numeric, Numeric] (63358.0)

実部と虚部を配列にして返します。

実部と虚部を配列にして返します。

//emlist[例][ruby]{
Complex(3).rect # => [3, 0]
Complex(3.5).rect # => [3.5, 0]
Complex(3, 2).rect # => [3, 2]
//}

@see Numeric#rect

絞り込み条件を変える

Complex#to_f -> Float (63358.0)

自身を Float に変換します。

自身を Float に変換します。

@raise RangeError 虚部が実数か、0 ではない場合に発生します。

//emlist[例][ruby]{
Complex(3).to_f # => 3.0
Complex(3.5).to_f # => 3.5
Complex(3, 2).to_f # => RangeError
//}

Complex#to_i -> Integer (63358.0)

自身を整数に変換します。

自身を整数に変換します。

@raise RangeError 虚部が実数か、0 ではない場合に発生します。

//emlist[例][ruby]{
Complex(3).to_i # => 3
Complex(3.5).to_i # => 3
Complex(3, 2).to_i # => RangeError
//}

Complex#to_json(*args) -> String (63358.0)

自身を JSON 形式の文字列に変換して返します。

自身を JSON 形式の文字列に変換して返します。

内部的にはハッシュにデータをセットしてから JSON::Generator::GeneratorMethods::Hash#to_json を呼び出しています。

@param args 使用しません。

//emlist[例][ruby]{
require 'json/add/complex'
Complex(2, 3).to_json # => "{\"json_class\":\"Complex\",\"r\":2,\"i\":3}"
//}

@see JSON::Generator::GeneratorMethods::Hash...

Complex#rationalize -> Rational (63340.0)

自身を Rational に変換します。

自身を Rational に変換します。

@param eps 許容する誤差。常に無視されます。

@raise RangeError 虚部が実数か、0 ではない場合に発生します。

//emlist[例][ruby]{
Complex(3).to_r # => (3/1)
Complex(3, 2).to_r # => RangeError
//}

Complex#rationalize(eps) -> Rational (63340.0)

自身を Rational に変換します。

自身を Rational に変換します。

@param eps 許容する誤差。常に無視されます。

@raise RangeError 虚部が実数か、0 ではない場合に発生します。

//emlist[例][ruby]{
Complex(3).to_r # => (3/1)
Complex(3, 2).to_r # => RangeError
//}

絞り込み条件を変える

Complex#to_c -> self (63340.0)

self を返します。

self を返します。

//emlist[例][ruby]{
Complex(2).to_c # => (2+0i)
Complex(-8, 6).to_c # => (-8+6i)
//}

Complex#to_r -> Rational (63340.0)

自身を Rational に変換します。

自身を Rational に変換します。

@param eps 許容する誤差。常に無視されます。

@raise RangeError 虚部が実数か、0 ではない場合に発生します。

//emlist[例][ruby]{
Complex(3).to_r # => (3/1)
Complex(3, 2).to_r # => RangeError
//}

Complex#imag -> Numeric (63322.0)

自身の虚部を返します。

自身の虚部を返します。

//emlist[例][ruby]{
Complex(3, 2).imag # => 2
//}

@see Numeric#imag

Complex#imaginary -> Numeric (63322.0)

自身の虚部を返します。

自身の虚部を返します。

//emlist[例][ruby]{
Complex(3, 2).imag # => 2
//}

@see Numeric#imag

Complex#polar -> [Numeric, Numeric] (63322.0)

自身の絶対値と偏角を配列にして返します。

自身の絶対値と偏角を配列にして返します。

//emlist[例][ruby]{
Complex.polar(1, 2).polar # => [1, 2]
//}

@see Numeric#polar

絞り込み条件を変える

Complex#real -> Numeric (63322.0)

自身の実部を返します。

自身の実部を返します。

//emlist[例][ruby]{
Complex(3, 2).real # => 3
//}

Complex#<(other) -> bool (63304.0)

@undef

@undef

Complex#<=(other) -> bool (63304.0)

@undef

@undef

Complex#>(other) -> bool (63304.0)

@undef

@undef

Complex#>=(other) -> bool (63304.0)

@undef

@undef

絞り込み条件を変える

Complex#between?(min, max) -> bool (63304.0)

@undef

@undef

Complex#clamp(range) -> object (63304.0)

@undef

@undef

Complex#real? -> false (63304.0)

常に false を返します。

常に false を返します。

//emlist[例][ruby]{
(2+3i).real? # => false
(2+0i).real? # => false
//}

@see Numeric#real?

Numeric#-@ -> Numeric (18406.0)

単項演算子の - です。 self の符号を反転させたものを返します。

単項演算子の - です。
self の符号を反転させたものを返します。

このメソッドは、二項演算子 - で 0 - self によって定義されています。


@see Integer#-@、Float#-@、Rational#-@、Complex#-@

String#to_c -> Complex (817.0)

自身を複素数 (Complex) に変換した結果を返します。

自身を複素数 (Complex) に変換した結果を返します。

以下の形式を解析できます。i、j は大文字、小文字のどちらでも解析できます。

* 実部+虚部i
* 実部+虚部j
* 絶対値@偏角

それぞれの数値は以下のいずれかの形式で指定します。先頭の空白文字や複素
数値の後にある文字列は無視されます。また、数値オブジェクトと同様に各桁
の間に「_」を入れる事ができます。

* "1/3" のような分数の形式
* "0.3" のような10進数の形式
* "0.3E0" のような x.xEn の形式

自身が解析できない値であった場合は 0+0i を返します。

//emlis...

絞り込み条件を変える

Numeric#to_c -> Complex (721.0)

自身を複素数 (Complex) に変換します。Complex(self, 0) を返します。

自身を複素数 (Complex) に変換します。Complex(self, 0) を返します。

//emlist[例][ruby]{
1.to_c # => (1+0i)
-1.to_c # => (-1+0i)
1.0.to_c # => (1.0+0i)
Rational(1, 2).to_c # => ((1/2)+0i)
//}

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。

Numeric#fdiv(other) -> Float | Complex (709.0)

self を other で割った商を Float で返します。 ただし Complex が関わる場合は例外です。 その場合も成分は Float になります。

self を other で割った商を Float で返します。
ただし Complex が関わる場合は例外です。
その場合も成分は Float になります。

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。

@param other 自身を割る数を指定します。

//emlist[例][ruby]{
1.fdiv(3) #=> 0.3333333333333333
Complex(1, 1).fdiv 1 #=> (1.0+1.0i)
1.fdiv Complex(1, 1) #=> (0.5-0.5i)
//}

@see Num...

Numeric#i -> Complex (709.0)

Complex(0, self) を返します。

Complex(0, self) を返します。

ただし、Complex オブジェクトでは利用できません。

//emlist[例][ruby]{
10.i # => (0+10i)
-10.i # => (0-10i)
(0.1).i # => (0+0.1i)
Rational(1, 2).i # => (0+(1/2)*i)
//}

Numeric#quo(other) -> Rational | Float | Complex (661.0)

self を other で割った商を返します。 整商を得たい場合は Numeric#div を使ってください。

self を other で割った商を返します。
整商を得たい場合は Numeric#div を使ってください。

Numeric#fdiv が結果を Float で返すメソッドなのに対して quo はなるべく正確な数値を返すことを意図しています。
具体的には有理数の範囲に収まる計算では Rational の値を返します。
Float や Complex が関わるときはそれらのクラスになります。

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。


@param other 自身を割る数を指定します。

//emlist[例][ruby]{
1.quo(3)...

Bignum#fdiv(other) -> Float | Complex (655.0)

self を other で割った商を Float で返します。 ただし Complex が関わる場合は例外です。 その場合も成分は Float になります。

self を other で割った商を Float で返します。
ただし Complex が関わる場合は例外です。
その場合も成分は Float になります。

@param other self を割る数を指定します。

@see Numeric#quo

絞り込み条件を変える

Fixnum#fdiv(other) -> Float | Complex (655.0)

self を other で割った商を Float で返します。 ただし Complex が関わる場合は例外です。 その場合も成分は Float になります。

self を other で割った商を Float で返します。
ただし Complex が関わる場合は例外です。
その場合も成分は Float になります。

@param other self を割る数を指定します。

@see Numeric#quo

Matrix#tr -> Integer | Float | Rational | Complex (610.0)

トレース (trace) を返します。

トレース (trace) を返します。

行列のトレース (trace) とは、対角要素の和です。

//emlist[例][ruby]{
require 'matrix'
Matrix[[7,6], [3,9]].trace # => 16
//}

trace は正方行列でのみ定義されます。

@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方行列でない場合に発生します

Matrix#trace -> Integer | Float | Rational | Complex (610.0)

トレース (trace) を返します。

トレース (trace) を返します。

行列のトレース (trace) とは、対角要素の和です。

//emlist[例][ruby]{
require 'matrix'
Matrix[[7,6], [3,9]].trace # => 16
//}

trace は正方行列でのみ定義されます。

@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方行列でない場合に発生します

NilClass#to_c -> Complex (607.0)

0+0i を返します。

0+0i を返します。

//emlist[例][ruby]{
nil.to_c # => (0+0i)
//}

Enumerable#slice_before {|elt| bool } -> Enumerator (430.0)

パターンがマッチした要素、もしくはブロックが真を返した要素から 次にマッチする手前までを チャンク化(グループ化)したものを繰り返す Enumerator を 返します。

パターンがマッチした要素、もしくはブロックが真を返した要素から
次にマッチする手前までを
チャンク化(グループ化)したものを繰り返す Enumerator を
返します。

パターンを渡した場合は各要素に対し === が呼び出され、
それが真になったところをチャンクの先頭と見なします。
ブロックを渡した場合は、各要素に対しブロックを適用し
返り値が真であった要素をチャンクの先頭と見なします。

より厳密にいうと、「先頭要素」の手前で分割していきます。
最初の要素の評価は無視されます。

各チャンクは配列として表現されます。

Enumerable#to_a や Enumerable#map ...

絞り込み条件を変える

Enumerable#slice_before(pattern) -> Enumerator (430.0)

パターンがマッチした要素、もしくはブロックが真を返した要素から 次にマッチする手前までを チャンク化(グループ化)したものを繰り返す Enumerator を 返します。

パターンがマッチした要素、もしくはブロックが真を返した要素から
次にマッチする手前までを
チャンク化(グループ化)したものを繰り返す Enumerator を
返します。

パターンを渡した場合は各要素に対し === が呼び出され、
それが真になったところをチャンクの先頭と見なします。
ブロックを渡した場合は、各要素に対しブロックを適用し
返り値が真であった要素をチャンクの先頭と見なします。

より厳密にいうと、「先頭要素」の手前で分割していきます。
最初の要素の評価は無視されます。

各チャンクは配列として表現されます。

Enumerable#to_a や Enumerable#map ...

Integer#fdiv(other) -> Numeric (424.0)

self を other で割った商を Float で返します。 ただし Complex が関わる場合は例外です。 その場合も成分は Float になります。

self を other で割った商を Float で返します。
ただし Complex が関わる場合は例外です。
その場合も成分は Float になります。

@param other self を割る数を指定します。

例:

654321.fdiv(13731) # => 47.652829364212366
654321.fdiv(13731.24) # => 47.65199646936475

-1234567890987654321.fdiv(13731) # => -89910996357705.52
-1234567890987654...

Matrix#conj -> Matrix (412.0)

複素共役を取った行列を返します。

複素共役を取った行列を返します。

//emlist[例][ruby]{
require 'matrix'
Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]]
# => 1+2i i 0
# 1 2 3
Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].conjugate
# => 1-2i -i 0
# 1 2 3
//}

Matrix#conjugate -> Matrix (412.0)

複素共役を取った行列を返します。

複素共役を取った行列を返します。

//emlist[例][ruby]{
require 'matrix'
Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]]
# => 1+2i i 0
# 1 2 3
Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].conjugate
# => 1-2i -i 0
# 1 2 3
//}

Numeric#real? -> bool (388.0)

常に true を返します。(Complex またはそのサブクラスではないことを意味します。)

常に true を返します。(Complex またはそのサブクラスではないことを意味します。)

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。

//emlist[例][ruby]{
10.real? # => true
-10.real? # => true
0.1.real? # => true
Rational(2, 3).real? # => true
//}

@see Numeric#integer?、Complex#real?

絞り込み条件を変える

Integer#/(other) -> Numeric (376.0)

除算の算術演算子。

除算の算術演算子。

other が Integer の場合、整商(整数の商)を Integer で返します。
普通の商(剰余を考えない商)を越えない最大の整数をもって整商とします。

other が Float、Rational、Complex の場合、普通の商を other と
同じクラスのインスタンスで返します。

@param other 二項演算の右側の引数(対象)
@return 計算結果

//emlist[例][ruby]{
7 / 2 # => 3
7 / -2 # => -4
7 / 2.0 # => 3.5
7 / Rational(2, 1) # => (7/2)
7...

Matrix#imag -> Matrix (376.0)

行列の虚部を返します。

行列の虚部を返します。

//emlist[例][ruby]{
require 'matrix'
Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]]
# => 1+2i i 0
# 1 2 3
Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].imaginary
# => 2i i 0
# 0 0 0
//}

Matrix#imaginary -> Matrix (376.0)

行列の虚部を返します。

行列の虚部を返します。

//emlist[例][ruby]{
require 'matrix'
Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]]
# => 1+2i i 0
# 1 2 3
Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].imaginary
# => 2i i 0
# 0 0 0
//}

Matrix#real -> Matrix (376.0)

行列の実部を返します。

行列の実部を返します。

//emlist[例][ruby]{
require 'matrix'
Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]]
# => 1+2i i 0
# 1 2 3
Matrix[[Complex(1,2), Complex(0,1), 0], [1, 2, 3]].real
# => 1 0 0
# 1 2 3
//}

Matrix#real? -> bool (376.0)

行列の全要素が実(Numeric#real?)であれば true を返します。

行列の全要素が実(Numeric#real?)であれば true を返します。

Complexオブジェクトを要素に持つ場合は虚部が0でも偽を返します。

//emlist[例][ruby]{
require 'matrix'
Matrix[[1, 0], [0, 1]].real? # => true
Matrix[[Complex(0, 1), 0], [0, 1]].real? # => false
# 要素が実数であっても Complex オブジェクトなら偽を返す。
Matrix[[Complex(1, 0), 0], [0, 1]].real? # => false
//}

絞り込み条件を変える

Numeric#imag -> 0 (358.0)

常に 0 を返します。

常に 0 を返します。

//emlist[例][ruby]{
12.imag # => 0
-12.imag # => 0
1.2.imag # => 0
-1.2.imag # => 0
//}

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。

@see Numeric#real、Complex#imag

Numeric#imaginary -> 0 (358.0)

常に 0 を返します。

常に 0 を返します。

//emlist[例][ruby]{
12.imag # => 0
-12.imag # => 0
1.2.imag # => 0
-1.2.imag # => 0
//}

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。

@see Numeric#real、Complex#imag

Numeric#polar -> [Numeric, Numeric] (358.0)

自身の絶対値と偏角を配列にして返します。正の数なら [self, 0]、負の数な ら [-self, Math::PI] を返します。

自身の絶対値と偏角を配列にして返します。正の数なら [self, 0]、負の数な
ら [-self, Math::PI] を返します。

//emlist[例][ruby]{
1.0.polar # => [1.0, 0]
2.0.polar # => [2.0, 0]
-1.0.polar # => [1.0, 3.141592653589793]
-2.0.polar # => [2.0, 3.141592653589793]
//}

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。

@see Complex#polar

Numeric#real -> Numeric (358.0)

自身を返します。

自身を返します。

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。

//emlist[例][ruby]{
10.real # => 10
-10.real # => -10
0.1.real # => 0.1
Rational(2, 3).real # => (2/3)
//}

@see Numeric#imag、Complex#real

Numeric#rect -> [Numeric, Numeric] (358.0)

[self, 0] を返します。

[self, 0] を返します。

//emlist[例][ruby]{
1.rect # => [1, 0]
-1.rect # => [-1, 0]
1.0.rect # => [1.0, 0]
-1.0.rect # => [-1.0, 0]
//}

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。

@see Complex#rect

絞り込み条件を変える

Numeric#rectangular -> [Numeric, Numeric] (358.0)

[self, 0] を返します。

[self, 0] を返します。

//emlist[例][ruby]{
1.rect # => [1, 0]
-1.rect # => [-1, 0]
1.0.rect # => [1.0, 0]
-1.0.rect # => [-1.0, 0]
//}

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。

@see Complex#rect

Numeric#angle -> 0 | Math::PI (340.0)

自身の偏角(正の数なら 0、負の数なら Math::PI)を返します。

自身の偏角(正の数なら 0、負の数なら Math::PI)を返します。

//emlist[例][ruby]{
1.arg # => 0
-1.arg # => 3.141592653589793
//}

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。

@see Complex#arg

Numeric#arg -> 0 | Math::PI (340.0)

自身の偏角(正の数なら 0、負の数なら Math::PI)を返します。

自身の偏角(正の数なら 0、負の数なら Math::PI)を返します。

//emlist[例][ruby]{
1.arg # => 0
-1.arg # => 3.141592653589793
//}

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。

@see Complex#arg

Numeric#conj -> Numeric (340.0)

常に self を返します。

常に self を返します。

自身が Complex かそのサブクラスのインスタンスの場合は、自身の共役複素数(実数の場合は常に自身)を返します。

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。


//emlist[例][ruby]{
10.conj # => 10
0.1.conj # => 0.1
(2/3r).conj # => (2/3)
//}

@see Complex#conj

Numeric#conjugate -> Numeric (340.0)

常に self を返します。

常に self を返します。

自身が Complex かそのサブクラスのインスタンスの場合は、自身の共役複素数(実数の場合は常に自身)を返します。

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。


//emlist[例][ruby]{
10.conj # => 10
0.1.conj # => 0.1
(2/3r).conj # => (2/3)
//}

@see Complex#conj

絞り込み条件を変える

Numeric#phase -> 0 | Math::PI (340.0)

自身の偏角(正の数なら 0、負の数なら Math::PI)を返します。

自身の偏角(正の数なら 0、負の数なら Math::PI)を返します。

//emlist[例][ruby]{
1.arg # => 0
-1.arg # => 3.141592653589793
//}

Numeric のサブクラスは、このメソッドを適切に再定義しなければなりません。

@see Complex#arg

Rational#fdiv(other) -> Float (340.0)

self を other で割った商を Float で返します。 other に虚数を指定することは出来ません。

self を other で割った商を Float で返します。
other に虚数を指定することは出来ません。

@param other 自身を割る数

//emlist[例][ruby]{
Rational(2, 3).fdiv(1) # => 0.6666666666666666
Rational(2, 3).fdiv(0.5) # => 1.3333333333333333
Rational(2).fdiv(3) # => 0.6666666666666666

Rational(1).fdiv(Complex(1, 0)) # => 1.0
Rational(1)...

Numeric#denominator -> Integer (322.0)

自身を Rational に変換した時の分母を返します。

自身を Rational に変換した時の分母を返します。

@return 分母を返します。


@see Numeric#numerator、Integer#denominator、Float#denominator、Rational#denominator、Complex#denominator

Numeric#numerator -> Integer (322.0)

自身を Rational に変換した時の分子を返します。

自身を Rational に変換した時の分子を返します。

@return 分子を返します。


@see Numeric#denominator、Integer#numerator、Float#numerator、Rational#numerator、Complex#numerator

Vector#magnitude -> Float (322.0)

ベクトルの大きさ(ノルム)を返します。

ベクトルの大きさ(ノルム)を返します。

//emlist[例][ruby]{
require 'matrix'
Vector[3, 4].norm # => 5.0
Vector[Complex(0, 1), 0].norm # => 1.0
//}

@see Vector#normalize

絞り込み条件を変える

Vector#norm -> Float (322.0)

ベクトルの大きさ(ノルム)を返します。

ベクトルの大きさ(ノルム)を返します。

//emlist[例][ruby]{
require 'matrix'
Vector[3, 4].norm # => 5.0
Vector[Complex(0, 1), 0].norm # => 1.0
//}

@see Vector#normalize

Vector#r -> Float (322.0)

ベクトルの大きさ(ノルム)を返します。

ベクトルの大きさ(ノルム)を返します。

//emlist[例][ruby]{
require 'matrix'
Vector[3, 4].norm # => 5.0
Vector[Complex(0, 1), 0].norm # => 1.0
//}

@see Vector#normalize