るりまサーチ

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

キーワード

検索結果

<< < 1 2 3 4 ... > >>

Matrix#==(other) -> bool (3.0)

自分自身と other を比較し、同値であれば真(true)を返します。

自分自身と other を比較し、同値であれば真(true)を返します。

@param other 比較対象のオブジェクト

Matrix#[](i, j) -> () (3.0)

(i,j)要素を返します。 行列の範囲外の値を指定した場合には nil を返します。

...分を0オリジンで指定します。
@param j 要素の列成分を0オリジンで指定します。



//emlist[例][ruby]{
require 'matrix'

a1 = [1, 2, 3]
a2 = [10, 15, 20]
a3 = [-1, 2, 1.5]
m = Matrix[a1, a2, a3]

p m[0, 0] # => 1
p m[1, 1] # => 15
p m[1, 2] # => 20
p m[1, 3] # => nil
//}...

Matrix#[]=(row, col, v) (3.0)

行が row、列が col である範囲を v に変更する。

...す。
v が Matrix のとき、変更の対象範囲と行数・列数が同じである必要があります。
v が上記以外のとき、変更の対象範囲の全ての要素を v に変更します。

//emlist[][ruby]{
require 'matrix'

m = Matrix[[0, 0], [0, 0]]
m[0, 1...
...1] = 9
p m # => Matrix[[0, 6], [0, 9]]

m = Matrix[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
m[0, 0..-1] = 5
m[1, 0..1] = Vector[2, 4]
m[2, 0..2] = Matrix[[3, 6, 9]]
p m #=> Matrix[[5, 5, 5], [2, 4, 0], [3, 6, 9]]

m = Matrix[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
m[0..2, 0..1] = 9
p m # => Matrix[[9, 9, 0], [9,...
...9, 0], [9, 9, 0]]
m[1..-1, 0..1] = Matrix[[1, 2], [3, 4]]
p m # => Matrix[[9, 9, 0], [1, 2, 0], [3, 4, 0]]
//}...

Matrix#adjugate -> Matrix (3.0)

余因子行列を返します。

...余因子行列を返します。

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

@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方でない場合に発生します。
@see Matrix#cofactor...

Matrix#antisymmetric? -> bool (3.0)

行列が反対称行列 (交代行列、歪〔わい〕対称行列とも) ならば true を返します。

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

//emlist[][ruby]{
require 'matrix'

Matrix
[[0, -2, Complex(1, 3)], [2, 0, 5], [-Complex(1, 3), -5, 0]].antisymmetric? # => true
Matrix
.empty.antisymmetric? # => true

Matrix
[[1, 2, 3], [4, 5, 6]...
..., [7, 8, 9]].antisymmetric? # => false
# 対角要素が違う
Matrix
[[1, -2, 3], [2, 0, 6], [-3, -6, 0]].antisymmetric? # => false
# 符号が違う
Matrix
[[0, 2, -3], [2, 0, 6], [-3, 6, 0]].antisymmetric? # => false
//}...

絞り込み条件を変える

Matrix#clone -> Matrix (3.0)

自分自身のコピーを返します。

自分自身のコピーを返します。

Matrix#coerce(other) -> Array (3.0)

他の数値オブジェクトとの変換を行います。

...クトをMatrix::Scalarのオブジェクトに変換し、selfとの組を配列として返します。

@param other 変換する数値オブジェクト

//emlist[例][ruby]{
require 'matrix'
a1 = [1, 2]
a2 = [-1.25, 2.2]
m = Matrix[a1, a2]
r = Rational(1, 2)
p m.coerce(r) #=> [#<Matrix::Scalar:...
...0x832df18 @value=(1/2)>, Matrix[[1, 2], [-1.25, 2.2]]]
//}...

Matrix#cofactor(row, column) -> Integer | Rational | Float (3.0)

(row, column)-余因子を返します。

...(row, column)-余因子を返します。

各要素の型によって返り値が変わります。

@param row 行
@param column 列
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方でない場合に発生します。
@see Matrix#adjugate...

Matrix#cofactor_expansion(row: nil, column: nil) -> object | Integer | Rational | Float (3.0)

row 行、もしくは column 列に関するラプラス展開をする。

...けです。かわりにMatrix#determinant を
利用すべきです。

変則的な形状の行列に対してはそれ以上の意味を持ちます。例えば
row行/column列が行列やベクトルである場合には

//emlist[例][ruby]{
require 'matrix'
# Matrix[[7,6], [3,9]].laplace_expa...
...=> 45
Matrix
[[Vector[1, 0], Vector[0, 1]], [2, 3]].laplace_expansion(row: 0) # => Vector[3, -2]
//}

@param row 行
@param column 列
@raise ArgumentError row と column を両方指定した、もしくは両方とも指定していない、場合に発生します
@raise ExceptionForMatrix::ErrD...
...imensionMismatch 行列が正方でない場合に発生します
@see Matrix#cofactor...

Matrix#collect -> Enumerator (3.0)

行列の各要素に対してブロックの適用を繰り返した結果を、要素として持つ行列を生成します。

...適用を繰り返した結果を、要素として持つ行列を生成します。

ブロックがない場合、 Enumerator を返します。


//emlist[例][ruby]{
require 'matrix'

m = Matrix[[1, 2], [3, 4]]
p m.map { |x| x + 100 } # => Matrix[[101, 102], [103, 104]]
//}

@see Matrix#each...

絞り込み条件を変える

Matrix#collect {|x| ... } -> Matrix (3.0)

行列の各要素に対してブロックの適用を繰り返した結果を、要素として持つ行列を生成します。

...適用を繰り返した結果を、要素として持つ行列を生成します。

ブロックがない場合、 Enumerator を返します。


//emlist[例][ruby]{
require 'matrix'

m = Matrix[[1, 2], [3, 4]]
p m.map { |x| x + 100 } # => Matrix[[101, 102], [103, 104]]
//}

@see Matrix#each...

Matrix#collect!(which = :all) -> Enumerator (3.0)

行列の各要素に対してブロックの適用を繰り返した結果で要素を置き換えます。

...詳細は、 Matrix#each の項目を参照して下さい。


//emlist[例][ruby]{
require 'matrix'

m = Matrix[[1, 2], [3, 4]]

p m.map! { |element| element * 10 } #=> Matrix[[10, 20], [30, 40]]
p m #=> Matrix[[10, 20], [30, 40]]
//}

@see Matrix#each, Matrix#map...

Matrix#collect!(which = :all) {|element| ... } -> self (3.0)

行列の各要素に対してブロックの適用を繰り返した結果で要素を置き換えます。

...詳細は、 Matrix#each の項目を参照して下さい。


//emlist[例][ruby]{
require 'matrix'

m = Matrix[[1, 2], [3, 4]]

p m.map! { |element| element * 10 } #=> Matrix[[10, 20], [30, 40]]
p m #=> Matrix[[10, 20], [30, 40]]
//}

@see Matrix#each, Matrix#map...
<< < 1 2 3 4 ... > >>