クラス
- Matrix (29)
-
Matrix
:: EigenvalueDecomposition (10) -
Matrix
:: LUPDecomposition (10) - Vector (7)
キーワード
- cofactor (1)
-
cofactor
_ expansion (1) - collect (2)
- collect2 (1)
- column (2)
-
column
_ count (1) -
column
_ size (1) -
column
_ vectors (1) - d (1)
- det (1)
- determinant (1)
- each (1)
-
each
_ with _ index (1) - eigen (1)
- eigensystem (1)
-
eigenvalue
_ matrix (1) - eigenvalues (1)
-
eigenvector
_ matrix (1) -
eigenvector
_ matrix _ inv (1) - eigenvectors (1)
-
find
_ index (2) -
first
_ minor (1) - index (2)
-
inner
_ product (1) -
laplace
_ expansion (1) -
lower
_ triangular? (1) - lup (1)
-
lup
_ decomposition (1) - magnitude (1)
- map (2)
- norm (1)
- p (1)
- permutation? (1)
- pivots (1)
- r (1)
- rectangular (1)
- regular? (1)
- singular? (2)
- solve (1)
- square? (1)
-
to
_ a (2) -
to
_ ary (2) - unitary? (1)
-
upper
_ triangular? (1) - v (1)
-
v
_ inv (1)
検索結果
先頭5件
-
Matrix
:: LUPDecomposition # l -> Matrix (63613.0) -
LUP分解の下半行列部分を返します。
LUP分解の下半行列部分を返します。 -
Matrix
:: LUPDecomposition # u -> Matrix (63613.0) -
LUP分解の上半行列部分を返します。
LUP分解の上半行列部分を返します。 -
Matrix
:: EigenvalueDecomposition # eigenvalues -> [Float] (54910.0) -
固有値を配列で返します。
固有値を配列で返します。 -
Matrix
# lup -> Matrix :: LUPDecomposition (37690.0) -
行列の LUP 分解を保持したオブジェクトを返します。
...
Matrix::LUPDecomposition は to_ary を定義しているため、
多重代入によって3つの行列(下三角行列、上三角行列、置換行列)
を得ることができます。これを [L, U, P] と書くと、
L*U = P*self を満たします。
//emlist[例][ruby]{
require 'matrix'......a = Matrix[[1, 2], [3, 4]]
l, u, p = a.lup
l.lower_triangular? # => true
u.upper_triangular? # => true
p.permutation? # => true
l * u == p * a # => true
a.lup.solve([2, 5]) # => Vector[(1/1), (1/2)]
//}
@see Matrix::LUPDecomposition... -
Matrix
# lup _ decomposition -> Matrix :: LUPDecomposition (37690.0) -
行列の LUP 分解を保持したオブジェクトを返します。
...
Matrix::LUPDecomposition は to_ary を定義しているため、
多重代入によって3つの行列(下三角行列、上三角行列、置換行列)
を得ることができます。これを [L, U, P] と書くと、
L*U = P*self を満たします。
//emlist[例][ruby]{
require 'matrix'......a = Matrix[[1, 2], [3, 4]]
l, u, p = a.lup
l.lower_triangular? # => true
u.upper_triangular? # => true
p.permutation? # => true
l * u == p * a # => true
a.lup.solve([2, 5]) # => Vector[(1/1), (1/2)]
//}
@see Matrix::LUPDecomposition... -
Matrix
# column(j) -> Vector | nil (36910.0) -
j 番目の列を Vector オブジェクトで返します。 j 番目の列が存在しない場合は nil を返します。 ブロックが与えられた場合はその列の各要素についてブロックを繰り返します。
...ンデックスと見倣します。末尾の列が -1 番目になります。
//emlist[例][ruby]{
require 'matrix'
a1 = [ 1, 2, 3]
a2 = [10, 15, 20]
a3 = [-1, -2, 1.5]
m = Matrix[a1, a2, a3]
p m.column(1) # => Vector[2, 15, -2]
cnt = 0
m.column(-1) { |x|
cnt = cnt + x
}
p cnt # => 24.5... -
Matrix
# column(j) {|x| . . . } -> self (36910.0) -
j 番目の列を Vector オブジェクトで返します。 j 番目の列が存在しない場合は nil を返します。 ブロックが与えられた場合はその列の各要素についてブロックを繰り返します。
...ンデックスと見倣します。末尾の列が -1 番目になります。
//emlist[例][ruby]{
require 'matrix'
a1 = [ 1, 2, 3]
a2 = [10, 15, 20]
a3 = [-1, -2, 1.5]
m = Matrix[a1, a2, a3]
p m.column(1) # => Vector[2, 15, -2]
cnt = 0
m.column(-1) { |x|
cnt = cnt + x
}
p cnt # => 24.5... -
Matrix
# column _ count -> Integer (36910.0) -
行列の列数を返します。
行列の列数を返します。 -
Matrix
# column _ size -> Integer (36910.0) -
行列の列数を返します。
行列の列数を返します。 -
Matrix
# column _ vectors -> [Vector] (36910.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.column_vectors # => [Vector[1, 10, -1], Vector[2, 15, -2], Vector[3, 20, 1.5]]
//}... -
Matrix
# lower _ triangular? -> bool (36910.0) -
行列が下三角行列ならば true を返します。
行列が下三角行列ならば true を返します。 -
Matrix
# regular? -> bool (36910.0) -
行列が正方で正則なら true を、特異なら false を返します。
...例外 ExceptionForMatrix::ErrDimensionMismatch を
発生させます。
//emlist[例][ruby]{
require 'matrix'
a1 = [ 1, 2, 3]
a2 = [10, 15, 20]
a3 = [-1, -2, 1.5]
m = Matrix[a1, a2, a3]
p m.regular? # => true
a1 = [ 1, 2, 3]
a2 = [10, 15, 20]
a3 = [-1, -2, -3]
m = Matrix[a1, a2, a3]
p m.re......gular? # => false
a1 = [ 1, 2, 3]
a2 = [10, 15, 20]
a3 = [-1, -2, 1.5]
a4 = [1, 1, 1]
m = Matrix[a1, a2, a3, a4]
p m.regular? # => raise ExceptionForMatrix::ErrDimensionMismatch
//}
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方行列でない場合に発生します... -
Matrix
# singular? -> bool (36910.0) -
行列が正方で特異なら true を、正則なら false を返します。
...るとは、正則でないことです。
行列式が0であること同値です。
正方行列でない場合には例外 ExceptionForMatrix::ErrDimensionMismatch を
発生させます。
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方行列でない場合に発生します... -
Matrix
# upper _ triangular? -> bool (36910.0) -
行列が上三角行列ならば true を返します。
行列が上三角行列ならば true を返します。 -
Matrix
:: EigenvalueDecomposition # eigenvalue _ matrix -> Matrix (36910.0) -
固有値を対角成分に並べた行列を返します。
固有値を対角成分に並べた行列を返します。 -
Matrix
:: LUPDecomposition # singular? -> bool (36910.0) -
元の行列が正方で特異なら true を、正則なら false を返します。 LUP 分解の結果を利用して判定します。
...元の行列が正方で特異なら true を、正則なら false を返します。
LUP 分解の結果を利用して判定します。
@see Matrix#singular?... -
Matrix
:: LUPDecomposition # solve(b) -> Vector | Matrix (27610.0) -
self が正方行列 A の LUP 分解の時、一次方程式 Ax = b の解を返します。 b には Vector, Matrix, 数値の配列を指定出来ます。
...self が正方行列 A の LUP 分解の時、一次方程式 Ax = b の解を返します。
b には Vector, Matrix, 数値の配列を指定出来ます。
それぞれベクトルのサイズ、行列の行数、配列のサイズが A の列数と一致していなければなりません。......指定します。
//emlist[][ruby]{
require 'matrix'
lup = Matrix[[2, 1], [1, 2]].lup
lup.solve([1, -1]) #=> Vector[(1/1), (-1/1)]
lup.solve(Vector[3, 0]) #=> Vector[(2/1), (-1/1)]
lup.solve(Matrix[[1, 3], [-1, 0]]) #=> Matrix[[(1/1), (2/1)], [(-1/1), (-1/1)]]
//}... -
Matrix
# laplace _ expansion(row: nil , column: nil) -> object | Integer | Rational | Float (19210.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 (18910.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
# permutation? -> bool (18910.0) -
行列が置換行列ならば true を返します。
...行列が置換行列ならば true を返します。
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方行列でない場合に発生します... -
Matrix
# rectangular -> [Matrix , Matrix] (18910.0) -
行列を実部と虚部に分解したものを返します。
...行列を実部と虚部に分解したものを返します。
//emlist[例][ruby]{
m.rect == [m.real, m.imag] # ==> true for all matrices m
//}
@see Matrix#imaginary, Matrix#real... -
Matrix
# square? -> bool (18910.0) -
正方行列であるなら、 true を返します。
正方行列であるなら、 true を返します。 -
Matrix
# unitary? -> bool (18910.0) -
行列がユニタリならば true を返します。
...行列がユニタリならば true を返します。
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方行列でない場合に発生します... -
Vector
# collect -> Enumerator (18910.0) -
ベクトルの各要素に対してブロックを評価した結果を、要素として持つベクトルを生成します。
...して持つベクトルを生成します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
require 'matrix'
a = [1, 2, 3.5, -10]
v1 = Vector.elements(a)
p v1 # => Vector[1, 2, 3.5, -10]
v2 = v1.map{|x|
x * -1
}
p v2 # => Vector[-1, -2, -3.5, 10]
//}... -
Vector
# collect2(v) -> Enumerator (18910.0) -
ベクトルの各要素と引数 v の要素との組に対してブロックを評価し、その結果を要素として持つ配列を返します。
...クを省略した場合は Enumerator を返します。
@param v ブロック内で評価される(ベクトル or 配列)
@raise ExceptionForMatrix::ErrDimensionMismatch 自分自身と引数のベクト
ルの要素の数(次元)が異なっていたときに発生します。
@see Vec... -
Vector
# magnitude -> Float (18910.0) -
ベクトルの大きさ(ノルム)を返します。
...ベクトルの大きさ(ノルム)を返します。
//emlist[例][ruby]{
require 'matrix'
Vector[3, 4].norm # => 5.0
Vector[Complex(0, 1), 0].norm # => 1.0
//}
@see Vector#normalize... -
Matrix
:: LUPDecomposition # det -> Numeric (18610.0) -
元の行列の行列式の値を返します。 LUP 分解の結果を利用して計算します。
...元の行列の行列式の値を返します。
LUP 分解の結果を利用して計算します。
@see Matrix#determinant... -
Matrix
:: LUPDecomposition # determinant -> Numeric (18610.0) -
元の行列の行列式の値を返します。 LUP 分解の結果を利用して計算します。
...元の行列の行列式の値を返します。
LUP 分解の結果を利用して計算します。
@see Matrix#determinant... -
Matrix
:: EigenvalueDecomposition # d -> Matrix (18310.0) -
固有値を対角成分に並べた行列を返します。
固有値を対角成分に並べた行列を返します。 -
Matrix
:: EigenvalueDecomposition # eigenvector _ matrix -> Matrix (18310.0) -
右固有ベクトルを横に並べた行列を返します。
右固有ベクトルを横に並べた行列を返します。 -
Matrix
:: EigenvalueDecomposition # eigenvector _ matrix _ inv -> Matrix (18310.0) -
左固有ベクトルを縦に並べた行列を返します。
...左固有ベクトルを縦に並べた行列を返します。
これは Matrix::EigenvalueDecomposition#v の逆行列です... -
Matrix
:: EigenvalueDecomposition # eigenvectors -> [Vector] (18310.0) -
右固有ベクトルを配列で返します。
右固有ベクトルを配列で返します。 -
Matrix
:: EigenvalueDecomposition # to _ a -> [Matrix , Matrix , Matrix] (18310.0) -
Matrix::EigenvalueDecomposition#v, Matrix::EigenvalueDecomposition#d, Matrix::EigenvalueDecomposition#v_inv をこの順に並べた配列を返します。
...
Matrix::EigenvalueDecomposition#v,
Matrix::EigenvalueDecomposition#d,
Matrix::EigenvalueDecomposition#v_inv
をこの順に並べた配列を返します。... -
Matrix
:: EigenvalueDecomposition # to _ ary -> [Matrix , Matrix , Matrix] (18310.0) -
Matrix::EigenvalueDecomposition#v, Matrix::EigenvalueDecomposition#d, Matrix::EigenvalueDecomposition#v_inv をこの順に並べた配列を返します。
...
Matrix::EigenvalueDecomposition#v,
Matrix::EigenvalueDecomposition#d,
Matrix::EigenvalueDecomposition#v_inv
をこの順に並べた配列を返します。... -
Matrix
:: EigenvalueDecomposition # v -> Matrix (18310.0) -
右固有ベクトルを横に並べた行列を返します。
右固有ベクトルを横に並べた行列を返します。 -
Matrix
:: EigenvalueDecomposition # v _ inv -> Matrix (18310.0) -
左固有ベクトルを縦に並べた行列を返します。
...左固有ベクトルを縦に並べた行列を返します。
これは Matrix::EigenvalueDecomposition#v の逆行列です... -
Matrix
:: LUPDecomposition # p -> Matrix (18310.0) -
LUP分解の置換行列部分を返します。
LUP分解の置換行列部分を返します。 -
Matrix
:: LUPDecomposition # pivots -> [Integer] (18310.0) -
ピボッティングを表す配列を返します。
ピボッティングを表す配列を返します。 -
Matrix
:: LUPDecomposition # to _ a -> [Matrix , Matrix , Matrix] (18310.0) -
分解した行列を [下半行列, 上半行列, 置換行列] という3要素の配列で 返します。
分解した行列を [下半行列, 上半行列, 置換行列] という3要素の配列で
返します。 -
Matrix
:: LUPDecomposition # to _ ary -> [Matrix , Matrix , Matrix] (18310.0) -
分解した行列を [下半行列, 上半行列, 置換行列] という3要素の配列で 返します。
分解した行列を [下半行列, 上半行列, 置換行列] という3要素の配列で
返します。 -
Vector
# inner _ product(v) -> Float (9910.0) -
ベクトル v との内積を返します。
...ベクトル v との内積を返します。
@param v 内積を求めるベクトル
@raise ExceptionForMatrix::ErrDimensionMismatch 自分自身と引数のベクト
ルの要素の数(次元)が異なっていたときに発生します。... -
Matrix
# map -> Enumerator (9610.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... -
Vector
# map -> Enumerator (9610.0) -
ベクトルの各要素に対してブロックを評価した結果を、要素として持つベクトルを生成します。
...して持つベクトルを生成します。
ブロックを省略した場合は Enumerator を返します。
//emlist[例][ruby]{
require 'matrix'
a = [1, 2, 3.5, -10]
v1 = Vector.elements(a)
p v1 # => Vector[1, 2, 3.5, -10]
v2 = v1.map{|x|
x * -1
}
p v2 # => Vector[-1, -2, -3.5, 10]
//}... -
Vector
# norm -> Float (9610.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 (9610.0) -
ベクトルの大きさ(ノルム)を返します。
...ベクトルの大きさ(ノルム)を返します。
//emlist[例][ruby]{
require 'matrix'
Vector[3, 4].norm # => 5.0
Vector[Complex(0, 1), 0].norm # => 1.0
//}
@see Vector#normalize... -
Matrix
# cofactor(row , column) -> Integer | Rational | Float (910.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 (910.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
# each(which = :all) -> Enumerator (910.0) -
行列の各要素を引数としてブロックを呼び出します。
...uby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].each { |e| puts e }
# => prints the numbers 1 to 4
Matrix[ [1,2], [3,4] ].each(:strict_lower).to_a # => [3]
//}
@param which どの要素に対してブロックを呼び出すのかを Symbol で指定します
@see Matrix#each_with_index, Matrix#map... -
Matrix
# each _ with _ index(which = :all) -> Enumerator (910.0) -
行列の各要素をその位置とともに引数としてブロックを呼び出します。
...る要素の範囲を指定することができます。
Matrix#each と同じなのでそちらを参照してください。
ブロックを省略した場合、 Enumerator を返します。
//emlist[例][ruby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].each_with_index do |e, row, col|
puts "#......{e} at #{row}, #{col}"
end
# => 1 at 0, 0
# => 2 at 0, 1
# => 3 at 1, 0
# => 4 at 1, 1
//}
@param which どの要素に対してブロックを呼び出すのかを Symbol で指定します
@see Matrix#each... -
Matrix
# eigen -> Matrix :: EigenvalueDecomposition (910.0) -
行列の固有値と左右の固有ベクトルを保持したオブジェクトを返します。
...行列の固有値と左右の固有ベクトルを保持したオブジェクトを返します。
Matrix::EigenvalueDecomposition は to_ary を定義しているため、
多重代入によって3つの行列(右固有ベクトル、固有値行列、左固有ベクトル)
を得ることがで......ruby]{
require 'matrix'
m = Matrix[[1, 2], [3, 4]]
v, d, v_inv = m.eigensystem
d.diagonal? # => true
v.inv == v_inv # => true
(v * d * v_inv).round(5) == m # => true
//}
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方行列でない場合に発生します
@see Matrix::EigenvalueDec... -
Matrix
# eigensystem -> Matrix :: EigenvalueDecomposition (910.0) -
行列の固有値と左右の固有ベクトルを保持したオブジェクトを返します。
...行列の固有値と左右の固有ベクトルを保持したオブジェクトを返します。
Matrix::EigenvalueDecomposition は to_ary を定義しているため、
多重代入によって3つの行列(右固有ベクトル、固有値行列、左固有ベクトル)
を得ることがで......ruby]{
require 'matrix'
m = Matrix[[1, 2], [3, 4]]
v, d, v_inv = m.eigensystem
d.diagonal? # => true
v.inv == v_inv # => true
(v * d * v_inv).round(5) == m # => true
//}
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方行列でない場合に発生します
@see Matrix::EigenvalueDec... -
Matrix
# find _ index(selector = :all) -> Enumerator (910.0) -
指定した値と一致する要素の位置を [row, column] という配列で返します。 ブロックを与えた場合は各要素を引数としてブロックを呼び出し、 返り値が真であった要素の位置を返します。
...で行列のどの部分を探すかを指定します。この引数の意味は
Matrix#each を参照してください。
//emlist[例][ruby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].index(&:even?) # => [0, 1]
Matrix[ [1,1], [1,1] ].index(1, :strict_lower) # => [1, 0]
//}
value を指定せず... -
Matrix
# find _ index(value , selector = :all) -> [Integer , Integer] | nil (910.0) -
指定した値と一致する要素の位置を [row, column] という配列で返します。 ブロックを与えた場合は各要素を引数としてブロックを呼び出し、 返り値が真であった要素の位置を返します。
...で行列のどの部分を探すかを指定します。この引数の意味は
Matrix#each を参照してください。
//emlist[例][ruby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].index(&:even?) # => [0, 1]
Matrix[ [1,1], [1,1] ].index(1, :strict_lower) # => [1, 0]
//}
value を指定せず... -
Matrix
# first _ minor(row , column) -> Matrix (910.0) -
self から第 row 行と第 column 列を取り除いた行列を返します。
self から第 row 行と第 column 列を取り除いた行列を返します。
@param row 行
@param column 列
@raise ArgumentError row, column が行列の行数/列数を越えている場合に発生します。 -
Matrix
# index(selector = :all) -> Enumerator (910.0) -
指定した値と一致する要素の位置を [row, column] という配列で返します。 ブロックを与えた場合は各要素を引数としてブロックを呼び出し、 返り値が真であった要素の位置を返します。
...で行列のどの部分を探すかを指定します。この引数の意味は
Matrix#each を参照してください。
//emlist[例][ruby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].index(&:even?) # => [0, 1]
Matrix[ [1,1], [1,1] ].index(1, :strict_lower) # => [1, 0]
//}
value を指定せず... -
Matrix
# index(value , selector = :all) -> [Integer , Integer] | nil (910.0) -
指定した値と一致する要素の位置を [row, column] という配列で返します。 ブロックを与えた場合は各要素を引数としてブロックを呼び出し、 返り値が真であった要素の位置を返します。
...で行列のどの部分を探すかを指定します。この引数の意味は
Matrix#each を参照してください。
//emlist[例][ruby]{
require 'matrix'
Matrix[ [1,2], [3,4] ].index(&:even?) # => [0, 1]
Matrix[ [1,1], [1,1] ].index(1, :strict_lower) # => [1, 0]
//}
value を指定せず...