種類
- インスタンスメソッド (144)
- 特異メソッド (22)
- クラス (6)
クラス
- Matrix (123)
-
Matrix
:: EigenvalueDecomposition (10) -
Matrix
:: LUPDecomposition (10) - Vector (23)
キーワード
- * (3)
- ** (1)
- + (2)
- +@ (1)
- - (2)
- -@ (1)
-
/ (2) - == (1)
- EigenvalueDecomposition (1)
- ErrDimensionMismatch (1)
- ErrNotRegular (1)
- ErrOperationNotDefined (1)
- LUPDecomposition (1)
- Matrix (1)
- [] (3)
- []= (2)
- adjugate (1)
-
angle
_ with (1) - antisymmetric? (1)
- basis (1)
- build (2)
- coerce (1)
- cofactor (1)
-
cofactor
_ expansion (1) - collect (2)
- collect! (2)
- column (2)
-
column
_ count (1) -
column
_ size (1) -
column
_ vector (1) -
column
_ vectors (1) - columns (1)
- combine (3)
- component (2)
- conj (1)
- conjugate (1)
- covector (1)
- d (1)
- det (2)
-
det
_ e (1) - determinant (2)
-
determinant
_ e (1) - diagonal (1)
- diagonal? (1)
- each (2)
-
each
_ with _ index (2) - eigen (1)
- eigensystem (1)
-
eigenvalue
_ matrix (1) - eigenvalues (1)
-
eigenvector
_ matrix (1) -
eigenvector
_ matrix _ inv (1) - eigenvectors (1)
- element (2)
-
elements
_ to _ f (1) -
elements
_ to _ i (2) -
elements
_ to _ r (1) - empty (1)
- empty? (1)
-
entrywise
_ product (1) - eql? (1)
-
find
_ index (3) -
first
_ minor (1) -
hadamard
_ product (1) - hash (2)
- hermitian? (1)
- hstack (2)
- identity (1)
- imag (1)
- imaginary (1)
- independent? (2)
- index (3)
-
inner
_ product (1) - inspect (2)
- inv (1)
- inverse (1)
- l (1)
-
laplace
_ expansion (1) -
lower
_ triangular? (1) - lup (1)
-
lup
_ decomposition (1) - magnitude (1)
- map (2)
- map! (2)
- minor (2)
- norm (1)
- normal? (1)
- normalize (1)
- orthogonal? (1)
- p (1)
- permutation? (1)
- pivots (1)
- r (1)
- rank (1)
-
rank
_ e (1) - real (1)
- real? (1)
- rect (1)
- rectangular (1)
- regular? (1)
- round (1)
- row (2)
-
row
_ count (1) -
row
_ size (1) -
row
_ vector (1) -
row
_ vectors (1) - rows (1)
- scalar (1)
- singular? (2)
- size (1)
-
skew
_ symmetric? (1) - solve (1)
- square? (1)
- symmetric? (1)
- t (1)
-
to
_ a (3) -
to
_ ary (2) -
to
_ s (2) - tr (1)
- trace (1)
- transpose (1)
- u (1)
- unit (1)
- unitary? (1)
-
upper
_ triangular? (1) - v (1)
-
v
_ inv (1) - vstack (2)
- zero (3)
- zero? (1)
検索結果
先頭5件
-
Matrix
. I(n) -> Matrix (54310.0) -
n次の単位行列を生成します。
n次の単位行列を生成します。
@param n 単位行列の次元
単位行列とは、対角要素が全て1で非対角要素が全て0であるような行列のことです。 -
Matrix
# find _ index(selector = :all) {|e| . . . } -> [Integer , Integer] | nil (28207.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 (28207.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(selector = :all) -> Enumerator (27607.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
:: EigenvalueDecomposition # eigenvector _ matrix -> Matrix (27307.0) -
右固有ベクトルを横に並べた行列を返します。
右固有ベクトルを横に並べた行列を返します。 -
Matrix
:: EigenvalueDecomposition # eigenvector _ matrix _ inv -> Matrix (27307.0) -
左固有ベクトルを縦に並べた行列を返します。
...左固有ベクトルを縦に並べた行列を返します。
これは Matrix::EigenvalueDecomposition#v の逆行列です... -
Matrix
:: EigenvalueDecomposition # v _ inv -> Matrix (27307.0) -
左固有ベクトルを縦に並べた行列を返します。
...左固有ベクトルを縦に並べた行列を返します。
これは Matrix::EigenvalueDecomposition#v の逆行列です... -
ExceptionForMatrix
:: ErrDimensionMismatch (27007.0) -
行列/ベクトル計算時に次元が合わない場合に発生する例外です。
行列/ベクトル計算時に次元が合わない場合に発生する例外です。 -
ExceptionForMatrix
:: ErrOperationNotDefined (27007.0) -
演算時にクラスが適切でない場合に発生する例外です。
演算時にクラスが適切でない場合に発生する例外です。 -
Matrix
# index(selector = :all) {|e| . . . } -> [Integer , Integer] | nil (18907.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 (18907.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
# cofactor _ expansion(row: nil , column: nil) -> object | Integer | Rational | Float (18607.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
# eigen -> Matrix :: EigenvalueDecomposition (18607.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 (18607.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
# inspect -> String (18607.0) -
自分自身を見やすい形式に文字列化し、その文字列を返します。
...自分自身を見やすい形式に文字列化し、その文字列を返します。
//emlist[例][ruby]{
require 'matrix'
a1 = [1, 2]
a2 = [3, 4.5]
m = Matrix[a1, a2]
p m.inspect # => "Matrix[[1, 2], [3, 4.5]]"
//}... -
Matrix
# laplace _ expansion(row: nil , column: nil) -> object | Integer | Rational | Float (18607.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
# lup _ decomposition -> Matrix :: LUPDecomposition (18607.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... -
Vector
# inspect -> String (18607.0) -
オブジェクトの内容を文字列化します。
オブジェクトの内容を文字列化します。 -
Matrix
# imag -> Matrix (18379.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 (18379.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
//}... -
Vector
# elements _ to _ i -> Vector (18346.0) -
ベクトルの各成分をIntegerに変換したベクトルを返します。
...ベクトルの各成分をIntegerに変換したベクトルを返します。
このメソッドは deprecated です。 map(&:to_i) を使ってください。
//emlist[例][ruby]{
require 'matrix'
v = Vector.elements([2.5, 3.0, 5.01, 7])
p v.elements_to_i
# => Vector[2, 3, 5, 7]
//}... -
Matrix
# elements _ to _ i -> Matrix (18328.0) -
各要素を整数 Integer に変換した行列を返します。
各要素を整数 Integer に変換した行列を返します。
このメソッドは deprecated です。 map(&:to_i) を使ってください。 -
Matrix
. identity(n) -> Matrix (18310.0) -
n次の単位行列を生成します。
n次の単位行列を生成します。
@param n 単位行列の次元
単位行列とは、対角要素が全て1で非対角要素が全て0であるような行列のことです。 -
Matrix
. unit(n) -> Matrix (18310.0) -
n次の単位行列を生成します。
n次の単位行列を生成します。
@param n 単位行列の次元
単位行列とは、対角要素が全て1で非対角要素が全て0であるような行列のことです。 -
Matrix
# antisymmetric? -> bool (18307.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
# column _ size -> Integer (18307.0) -
行列の列数を返します。
行列の列数を返します。 -
Matrix
# combine(*matrices) {|*elements| . . . } -> Matrix (18307.0) -
要素ごとにブロックを呼び出した結果を組み合わせた Matrix を返します。
...要素ごとにブロックを呼び出した結果を組み合わせた Matrix を返します。
Matrix.combine(self, *matrices) { ... } と同じです。
@see Matrix.combine... -
Matrix
# determinant -> Numeric (18307.0) -
行列式 (determinant) の値を返します。
...オブジェクトを使用することを検討してください。
@raise ExceptionForMatrix::ErrDimensionMismatch 正方行列でない場合に発生します
//emlist[例][ruby]{
require 'matrix'
p Matrix[[2, 1], [-1, 2]].det #=> 5
p Matrix[[2.0, 1.0], [-1.0, 2.0]].det #=> 5.0
//}... -
Matrix
# determinant _ e -> Rational | Float (18307.0) -
このメソッドは deprecated です。 Matrix#determinant を代わりに使ってください。
...このメソッドは deprecated です。
Matrix#determinant を代わりに使ってください。... -
Matrix
# diagonal? -> bool (18307.0) -
行列が対角行列ならば true を返します。
...行列が対角行列ならば true を返します。
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方行列でない場合に発生します... -
Matrix
# each _ with _ index(which = :all) -> Enumerator (18307.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
# each _ with _ index(which = :all) {|e , row , col| . . . } -> self (18307.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
# entrywise _ product(m) -> Matrix (18307.0) -
アダマール積(要素ごとの積)を返します。
...ダマール積(要素ごとの積)を返します。
@raise ExceptionForMatrix::ErrDimensionMismatch 行や列の要素数が一致しない時に発生します。
//emlist[例][ruby]{
require 'matrix'
Matrix[[1,2], [3,4]].hadamard_product(Matrix[[1,2], [3,2]]) # => Matrix[[1, 4], [9, 8]]
//}... -
Matrix
# first _ minor(row , column) -> Matrix (18307.0) -
self から第 row 行と第 column 列を取り除いた行列を返します。
self から第 row 行と第 column 列を取り除いた行列を返します。
@param row 行
@param column 列
@raise ArgumentError row, column が行列の行数/列数を越えている場合に発生します。 -
Matrix
# hermitian? -> bool (18307.0) -
行列がエルミートならば true を返します。
...行列がエルミートならば true を返します。
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方行列でない場合に発生します... -
Matrix
# index(selector = :all) -> Enumerator (18307.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
# inv -> Matrix (18307.0) -
逆行列を返します。
...逆行列を返します。
//emlist[例][ruby]{
require 'matrix'
p Matrix[[2, 1], [3, 2]].inv #=> Matrix[[(2/1), (-1/1)], [(-3/1), (2/1)]]
p Matrix[[2.0, 1.0], [3.0, 2.0]].inv #=> Matrix[[2.0000000000000004, -1.0000000000000002], [-3.000000000000001, 2.0000000000000004]]
//}... -
Matrix
# inverse -> Matrix (18307.0) -
逆行列を返します。
...逆行列を返します。
//emlist[例][ruby]{
require 'matrix'
p Matrix[[2, 1], [3, 2]].inv #=> Matrix[[(2/1), (-1/1)], [(-3/1), (2/1)]]
p Matrix[[2.0, 1.0], [3.0, 2.0]].inv #=> Matrix[[2.0000000000000004, -1.0000000000000002], [-3.000000000000001, 2.0000000000000004]]
//}... -
Matrix
# lower _ triangular? -> bool (18307.0) -
行列が下三角行列ならば true を返します。
行列が下三角行列ならば true を返します。 -
Matrix
# minor(from _ row , row _ size , from _ col , col _ size) -> Matrix (18307.0) -
selfの部分行列を返します。
...aram col_size 部分行列の列サイズ
//emlist[例][ruby]{
require 'matrix'
a1 = [ 1, 2, 3, 4, 5]
a2 = [11, 12, 13, 14, 15]
a3 = [21, 22, 23, 24, 25]
a4 = [31, 32, 33, 34, 35]
a5 = [51, 52, 53, 54, 55]
m = Matrix[a1, a2, a3, a4, a5]
p m.minor(0, 2, 1, 2) # => Matrix[[2, 3], [12, 13]]
//}... -
Matrix
# minor(from _ row . . to _ row , from _ col . . to _ col) -> Matrix (18307.0) -
selfの部分行列を返します。
...aram col_size 部分行列の列サイズ
//emlist[例][ruby]{
require 'matrix'
a1 = [ 1, 2, 3, 4, 5]
a2 = [11, 12, 13, 14, 15]
a3 = [21, 22, 23, 24, 25]
a4 = [31, 32, 33, 34, 35]
a5 = [51, 52, 53, 54, 55]
m = Matrix[a1, a2, a3, a4, a5]
p m.minor(0, 2, 1, 2) # => Matrix[[2, 3], [12, 13]]
//}... -
Matrix
# permutation? -> bool (18307.0) -
行列が置換行列ならば true を返します。
...行列が置換行列ならば true を返します。
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方行列でない場合に発生します... -
Matrix
# row _ size -> Integer (18307.0) -
行列の行数を返します。
行列の行数を返します。 -
Matrix
# singular? -> bool (18307.0) -
行列が正方で特異なら true を、正則なら false を返します。
...るとは、正則でないことです。
行列式が0であること同値です。
正方行列でない場合には例外 ExceptionForMatrix::ErrDimensionMismatch を
発生させます。
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方行列でない場合に発生します... -
Matrix
# skew _ symmetric? -> bool (18307.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
# symmetric? -> bool (18307.0) -
行列が対称ならば true を返します。
...行列が対称ならば true を返します。
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方行列でない場合に発生します... -
Matrix
# unitary? -> bool (18307.0) -
行列がユニタリならば true を返します。
...行列がユニタリならば true を返します。
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方行列でない場合に発生します... -
Matrix
# upper _ triangular? -> bool (18307.0) -
行列が上三角行列ならば true を返します。
行列が上三角行列ならば true を返します。 -
Matrix
. build(row _ size , column _ size = row _ size) -> Enumerable (18307.0) -
row_size×column_sizeの行列をブロックの返り値から生成します。
...した場合は Enumerator を返します。
//emlist[例][ruby]{
require 'matrix'
m = Matrix.build(2, 4) {|row, col| col - row }
# => Matrix[[0, 1, 2, 3], [-1, 0, 1, 2]]
m = Matrix.build(3) { rand }
# => a 3x3 matrix with random elements
//}
@param row_size 行列の行数
@param column_size... -
Matrix
. build(row _ size , column _ size = row _ size) {|row , col| . . . } -> Matrix (18307.0) -
row_size×column_sizeの行列をブロックの返り値から生成します。
...した場合は Enumerator を返します。
//emlist[例][ruby]{
require 'matrix'
m = Matrix.build(2, 4) {|row, col| col - row }
# => Matrix[[0, 1, 2, 3], [-1, 0, 1, 2]]
m = Matrix.build(3) { rand }
# => a 3x3 matrix with random elements
//}
@param row_size 行列の行数
@param column_size... -
Matrix
. combine(*matrices) -> Enumerator (18307.0) -
要素ごとにブロックを呼び出した結果を組み合わせた Matrix を返します。
...ごとにブロックを呼び出した結果を組み合わせた Matrix を返します。
//emlist[例][ruby]{
require 'matrix'
x = Matrix[[6, 6], [4, 4]]
y = Matrix[[1, 2], [3, 4]]
Matrix.combine(x, y) {|a, b| a - b} # => Matrix[[5, 4], [1, 0]]
//}
@param matrices 並べる行列。すべて......の行列の行数と列数が一致していなければならない
@raise ExceptionForMatrix::ErrDimensionMismatch 行や列の要素数が一致しない時に発生します
@see Matrix#combine... -
Matrix
. combine(*matrices) {|*elements| . . . } -> Matrix (18307.0) -
要素ごとにブロックを呼び出した結果を組み合わせた Matrix を返します。
...ごとにブロックを呼び出した結果を組み合わせた Matrix を返します。
//emlist[例][ruby]{
require 'matrix'
x = Matrix[[6, 6], [4, 4]]
y = Matrix[[1, 2], [3, 4]]
Matrix.combine(x, y) {|a, b| a - b} # => Matrix[[5, 4], [1, 0]]
//}
@param matrices 並べる行列。すべて......の行列の行数と列数が一致していなければならない
@raise ExceptionForMatrix::ErrDimensionMismatch 行や列の要素数が一致しない時に発生します
@see Matrix#combine... -
Matrix
. diagonal(*values) -> Matrix (18307.0) -
対角要素がvaluesで、非対角要素が全て0であるような 正方行列を生成します。
...次元Arrayを1個指定すると、そのArrayを唯一の要素とした1×1の行列が生成されます。
//emlist[例][ruby]{
require 'matrix'
m = Matrix.diagonal(1, 2, 3)
p m # => Matrix[[1, 0, 0], [0, 2, 0], [0, 0, 3]]
a = [1,2,3]
m = Matrix.diagonal(a)
p m # => Matrix[[[1, 2, 3]]]
//}... -
Matrix
:: EigenvalueDecomposition # eigenvalue _ matrix -> Matrix (18307.0) -
固有値を対角成分に並べた行列を返します。
固有値を対角成分に並べた行列を返します。 -
Matrix
:: EigenvalueDecomposition # eigenvalues -> [Float] (18307.0) -
固有値を配列で返します。
固有値を配列で返します。 -
Matrix
:: EigenvalueDecomposition # eigenvectors -> [Vector] (18307.0) -
右固有ベクトルを配列で返します。
右固有ベクトルを配列で返します。 -
Matrix
:: EigenvalueDecomposition # v -> Matrix (18307.0) -
右固有ベクトルを横に並べた行列を返します。
右固有ベクトルを横に並べた行列を返します。 -
Matrix
:: LUPDecomposition # determinant -> Numeric (18307.0) -
元の行列の行列式の値を返します。 LUP 分解の結果を利用して計算します。
...元の行列の行列式の値を返します。
LUP 分解の結果を利用して計算します。
@see Matrix#determinant... -
Matrix
:: LUPDecomposition # pivots -> [Integer] (18307.0) -
ピボッティングを表す配列を返します。
ピボッティングを表す配列を返します。 -
Matrix
:: LUPDecomposition # singular? -> bool (18307.0) -
元の行列が正方で特異なら true を、正則なら false を返します。 LUP 分解の結果を利用して判定します。
...元の行列が正方で特異なら true を、正則なら false を返します。
LUP 分解の結果を利用して判定します。
@see Matrix#singular?... -
Vector
# angle _ with(v) -> Float (18307.0) -
v と self がなす角度を返します。
...require 'matrix'
Vector[1, 0].angle_with(Vector[0, 1]) # => Math::PI/2
//}
@param v このベクトルと self とがなす角度を計算します
@raise ZeroVectorError self もしくは v のどちらかが零ベクトルである場合に
発生します
@raise ExceptionForMatrix::ErrDim... -
Vector
# independent?(*vectors) -> bool (18307.0) -
self とベクトルの列 vectors が線形独立であれば true を返します。
...self とベクトルの列 vectors が線形独立であれば true を返します。
require 'matrix'
Vector.independent?(self, *vectors)
と同じです。
@param vectors 線形独立性を判定するベクトル列... -
Vector
# magnitude -> Float (18307.0) -
ベクトルの大きさ(ノルム)を返します。
...ベクトルの大きさ(ノルム)を返します。
//emlist[例][ruby]{
require 'matrix'
Vector[3, 4].norm # => 5.0
Vector[Complex(0, 1), 0].norm # => 1.0
//}
@see Vector#normalize... -
Vector
# normalize -> Vector (18307.0) -
自身を Vector#norm で正規化したベクトルを返します。
...たベクトルを返します。
@raise Vector::ZeroVectorError ベクトルが0である場合に発生します。
//emlist[例][ruby]{
require 'matrix'
v = Vector[2, 6, 9].normalize
# => Vector[0.18181818181818182, 0.5454545454545454, 0.8181818181818182]
v.norm # => 1.0
//}
@see Vector#norm... -
Vector
# size -> Integer (18307.0) -
ベクトルの要素数(次元)を返します。
ベクトルの要素数(次元)を返します。 -
Vector
. basis(size: , index:) -> Vector (18307.0) -
size 次元ベクトル空間の index 番目の標準基底を返します。
...size 次元ベクトル空間の index 番目の標準基底を返します。
//emlist[例][ruby]{
require 'matrix'
Vector.basis(size: 3, index: 1) # => Vector[0, 1, 0]
//}
@param size ベクトルの次元
@param index 標準基底の何番目か。0 origin... -
Vector
. independent?(*vectors) -> bool (18307.0) -
ベクトルの列 vectors が線形独立であれば true を返します。
ベクトルの列 vectors が線形独立であれば true を返します。
@param vectors 線形独立性を判定するベクトル列 -
Matrix (18187.0)
-
数Numericを要素とする行列を扱うクラスです。
...a(m-1,n-1) ]
のように、縦横の表にあらわしたものを(m,n)型の行列といいます。
m=nの行列をm次の正方行列(square matrix)といいます。
インデックスは 0 から始まることに注意してください。
上からi番目の横の数の並びを第i行(t... -
Matrix
:: EigenvalueDecomposition (18007.0) -
行列の固有分解の情報を保持するクラスです。
...行列の固有分解の情報を保持するクラスです。
Matrix#eigensystem の返り値のクラスです。... -
Matrix
:: LUPDecomposition (18007.0) -
行列のLUP分解の情報を保持するクラスです。
...行列のLUP分解の情報を保持するクラスです。
Matrix#lup_decomposition の返り値のクラスです。... -
Matrix
:: EigenvalueDecomposition # to _ a -> [Matrix , Matrix , Matrix] (9907.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] (9907.0) -
Matrix::EigenvalueDecomposition#v, Matrix::EigenvalueDecomposition#d, Matrix::EigenvalueDecomposition#v_inv をこの順に並べた配列を返します。
...
Matrix::EigenvalueDecomposition#v,
Matrix::EigenvalueDecomposition#d,
Matrix::EigenvalueDecomposition#v_inv
をこの順に並べた配列を返します。... -
Matrix
:: LUPDecomposition # to _ a -> [Matrix , Matrix , Matrix] (9907.0) -
分解した行列を [下半行列, 上半行列, 置換行列] という3要素の配列で 返します。
分解した行列を [下半行列, 上半行列, 置換行列] という3要素の配列で
返します。 -
Matrix
:: LUPDecomposition # to _ ary -> [Matrix , Matrix , Matrix] (9907.0) -
分解した行列を [下半行列, 上半行列, 置換行列] という3要素の配列で 返します。
分解した行列を [下半行列, 上半行列, 置換行列] という3要素の配列で
返します。 -
Matrix
# rect -> [Matrix , Matrix] (9607.0) -
行列を実部と虚部に分解したものを返します。
...行列を実部と虚部に分解したものを返します。
//emlist[例][ruby]{
m.rect == [m.real, m.imag] # ==> true for all matrices m
//}
@see Matrix#imaginary, Matrix#real... -
Matrix
# rectangular -> [Matrix , Matrix] (9607.0) -
行列を実部と虚部に分解したものを返します。
...行列を実部と虚部に分解したものを返します。
//emlist[例][ruby]{
m.rect == [m.real, m.imag] # ==> true for all matrices m
//}
@see Matrix#imaginary, Matrix#real... -
Matrix
. empty(row _ size=0 , column _ size=0) -> Matrix (9607.0) -
要素を持たない行列を返します。
...一方は0である必要があります。
//emlist[例][ruby]{
require 'matrix'
m = Matrix.empty(2, 0)
m == Matrix[ [], [] ]
# => true
n = Matrix.empty(0, 3)
n == Matrix.columns([ [], [], [] ])
# => true
m * n
# => Matrix[[0, 0, 0], [0, 0, 0]]
//}
@param row_size 行列の行数
@param column_si... -
Matrix
# row(i) -> Vector | nil (9445.0) -
i 番目の行を Vector オブジェクトで返します。 i 番目の行が存在しない場合は nil を返します。 ブロックが与えられた場合はその行の各要素についてブロックを繰り返します。
...す。
ブロックが与えられた場合はその行の各要素についてブロックを繰り返します。
Vector オブジェクトは Matrix オブジェクトとの演算の際には列ベクトルとして扱われることに注意してください。
@param i 行の位置を指定......のインデックスと見倣します。末尾の行が -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.row(1) # => Vector[10, 15, 20]
cnt = 0
m.row(0) { |x|
cnt = cnt + x
}
p cnt # => 6
//}... -
Matrix
# row(i) {|x| . . . } -> self (9445.0) -
i 番目の行を Vector オブジェクトで返します。 i 番目の行が存在しない場合は nil を返します。 ブロックが与えられた場合はその行の各要素についてブロックを繰り返します。
...す。
ブロックが与えられた場合はその行の各要素についてブロックを繰り返します。
Vector オブジェクトは Matrix オブジェクトとの演算の際には列ベクトルとして扱われることに注意してください。
@param i 行の位置を指定......のインデックスと見倣します。末尾の行が -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.row(1) # => Vector[10, 15, 20]
cnt = 0
m.row(0) { |x|
cnt = cnt + x
}
p cnt # => 6
//}... -
Matrix
. [](*rows) -> Matrix (9403.0) -
rows[i] を第 i 行とする行列を生成します。
...rows[i] を第 i 行とする行列を生成します。
@param rows 行列の要素を数の配列の配列として渡します。
//emlist[例][ruby]{
require 'matrix'
m = Matrix[[11, 12], [21, 22]]
p m # => Matrix[[11, 12], [21, 22]]
# [11, 12]
# [21, 22]
//}... -
Matrix
# [](i , j) -> () (9382.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
# component(i , j) -> () (9382.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
# element(i , j) -> () (9382.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
# conj -> Matrix (9379.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 (9379.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
# real -> Matrix (9343.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
# t -> Matrix (9343.0) -
転置行列 (transpose matrix) を返します。
...転置行列 (transpose matrix) を返します。
self を Matrix のオブジェクトで、(m,n) 型行列としたとき a(j,i) を (i,j) 要素とする (n,m) 型行列を返します。... -
Matrix
# transpose -> Matrix (9343.0) -
転置行列 (transpose matrix) を返します。
...転置行列 (transpose matrix) を返します。
self を Matrix のオブジェクトで、(m,n) 型行列としたとき a(j,i) を (i,j) 要素とする (n,m) 型行列を返します。... -
Matrix
# *(m) -> Matrix | Vector (9307.0) -
self に行列またはベクトル m を右から乗じた行列を返します。
...を返します。
m が Vector オブジェクトなら返り値も Vector オブジェクトになります。
@param m 右からの乗算が定義可能な行列やベクトルを指定します。
@raise ExceptionForMatrix::ErrDimensionMismatch 次元が合わない場合に発生します... -
Matrix
# *(other) -> Matrix (9307.0) -
self の各成分に数 other を掛けた行列を返します。
self の各成分に数 other を掛けた行列を返します。
@param other self の各成分に掛ける Numeric オブジェクトを指定します。 -
Matrix
# **(n) -> Matrix (9307.0) -
self の n 乗を返します。
...self の n 乗を返します。
@param n べき数の指定
@raise ExceptionForMatrix::ErrNotRegular n が 0 以下で、行列が正則でない場合に発生します... -
Matrix
# +(m) -> Matrix (9307.0) -
self に行列 m を加算した行列を返します。 self の column_size が 1 なら Vector オブジェクトも指定出来ます。
...した行列を返します。
self の column_size が 1 なら Vector オブジェクトも指定出来ます。
@param m 加算する行列。加算可能な行列やベクトルを指定します。
@raise ExceptionForMatrix::ErrDimensionMismatch 次元が合わない場合に発生します... -
Matrix
# -(m) -> Matrix (9307.0) -
self から行列mを減算した行列を返します。 self の column_size が 1 なら Vector オブジェクトも指定出来ます。
...した行列を返します。
self の column_size が 1 なら Vector オブジェクトも指定出来ます。
@param m 減算する行列。減算可能な行列やベクトルを指定します。
@raise ExceptionForMatrix::ErrDimensionMismatch 次元が合わない場合に発生します... -
Matrix
# -@ -> Matrix (9307.0) -
単項 -。各要素の符号を反転させた行列を返します。
単項 -。各要素の符号を反転させた行列を返します。 -
Matrix
# / (m) -> Matrix (9307.0) -
self に行列 m の逆行列を右から乗じた行列を返します。
...@param m 逆行列を右から乗算する行列。可逆行列でselfと乗算可能な行列を指定します。
@raise ExceptionForMatrix::ErrDimensionMismatch 次元が合わない場合に発生します
@raise ExceptionForMatrix::ErrNotRegular m が正則でない場合に発生します... -
Matrix
# / (other) -> Matrix (9307.0) -
self の各成分を数 other で割った行列を返します。
self の各成分を数 other で割った行列を返します。
@param other self の各成分を割る Numeric オブジェクトを指定します。 -
Matrix
# adjugate -> Matrix (9307.0) -
余因子行列を返します。
...余因子行列を返します。
//emlist[例][ruby]{
require 'matrix'
Matrix[[7,6],[3,9]].adjugate # => Matrix[[9, -6], [-3, 7]]
//}
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方でない場合に発生します。
@see Matrix#cofactor... -
Matrix
# cofactor(row , column) -> Integer | Rational | Float (9307.0) -
(row, column)-余因子を返します。
...(row, column)-余因子を返します。
各要素の型によって返り値が変わります。
@param row 行
@param column 列
@raise ExceptionForMatrix::ErrDimensionMismatch 行列が正方でない場合に発生します。
@see Matrix#adjugate... -
Matrix
# collect!(which = :all) -> Enumerator (9307.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 (9307.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...