るりまサーチ (Ruby 2.5.0)

最速Rubyリファレンスマニュアル検索!
187件ヒット [1-100件を表示] (0.075秒)
トップページ > クエリ:-[x] > クエリ:r[x] > ライブラリ:matrix[x] > バージョン:2.5.0[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

キーワード

検索結果

<< 1 2 > >>

Matrix#-(m) -> Matrix (63607.0)

self から行列mを減算した行列を返します。 self の column_size が 1 なら Vector オブジェクトも指定出来ます。

...した行列を返します。
self の column_size が 1 なら Vector オブジェクトも指定出来ます。

@param m 減算する行列。減算可能な行列やベクトルを指定します。

@raise ExceptionForMatrix::ErrDimensionMismatch 次元が合わない場合に発生します...

Vector#-(v) -> Vector | Matrix (63607.0)

self からベクトル v を減じたベクトルを返します。

...には column_size が 1 の Matrix オブジェクトも指定できます。
その場合は返り値も Matrix オブジェクトになります。

@param v 減算するベクトル。減算可能な行列やベクトルを指定します。

@raise ExceptionForMatrix::ErrDimensionMismatch 自...

Vector#r -> Float (54610.0)

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

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

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

@see Vector#normalize...

Vector#cross_product(*vs) -> Vector (27961.0)

self とベクトル vs とのクロス積を返します。

...vs は n-2 個の
n次元ベクトルでなければなりません。

@param vs クロス積を取るベクトルの集合
@raise ExceptionForMatrix::ErrOperationNotDefined self の
次元が1以下であるときに発生します。
@raise ArgumentError vs のベクトルの個数が n-...

Matrix#-@ -> Matrix (27607.0)

単項 -。各要素の符号を反転させた行列を返します。

単項 -。各要素の符号を反転させた行列を返します。

絞り込み条件を変える

Matrix#lower_triangular? -> bool (27607.0)

行列が下三角行列ならば true を返します。

行列が下三角行列ならば true を返します。

Matrix#symmetric? -> bool (27607.0)

行列が対称ならば true を返します。

...行列が対称ならば true を返します。

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

Matrix#upper_triangular? -> bool (27607.0)

行列が上三角行列ならば true を返します。

行列が上三角行列ならば true を返します。

Matrix::EigenvalueDecomposition#eigenvector_matrix -> Matrix (27607.0)

右固有ベクトルを横に並べた行列を返します。

右固有ベクトルを横に並べた行列を返します。

Matrix::EigenvalueDecomposition#eigenvector_matrix_inv -> Matrix (27607.0)

左固有ベクトルを縦に並べた行列を返します。

...左固有ベクトルを縦に並べた行列を返します。

これは Matrix::EigenvalueDecomposition#v の逆行列です...

絞り込み条件を変える

Vector#-@ -> self (27355.0)

単項演算子の - です。 各要素の符号を反転したベクトルを返します。

単項演算子の - です。 各要素の符号を反転したベクトルを返します。

Vector#elements_to_r -> Vector (18946.0)

ベクトルの各成分をRationalに変換したベクトルを返します。

...の各成分をRationalに変換したベクトルを返します。

このメソッドは deprecated です。 map(&:to_r) を使ってください。

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

v = Vector.elements([2.5, 3.0, 5.75, 7])
p v.elements_to_r
# => Vector[(5/2), (3/1), (23/4), (7/1)]
//}...

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

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

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

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

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

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

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

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

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

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

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

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

Matrix.row_vector(row) -> Matrix (18907.0)

要素がrowの(1,n)型の行列(行ベクトル)を生成します。

要素がrowの(1,n)型の行列(行ベクトル)を生成します。

@param row (1,n)型の行列として生成するVector Array オブジェクト

絞り込み条件を変える

Matrix.rows(rows, copy = true) -> Matrix (18907.0)

引数 rows を行ベクトルの列とする行列を生成します。

...せん。

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

a1 = [1, 2, 3]
a2 = [10, 15, 20]

m = Matrix.rows([a1, a2], false) # 配列を複製せずに行列を生成
p m # => Matrix[[1, 2, 3], [10, 15, 20]]
a2[1] = 1000 # 配列のデータを変更
p m # => Matrix[[1, 2, 3], [10, 1000, 20]]
//}

@param ro...

Matrix.zero(row, column) -> Matrix (18907.0)

row × column の零行列(要素が全て 0 の行列)を生成して返します。

...row × column の零行列(要素が全て 0 の行列)を生成して返します。

//emlist[例][ruby]{
require 'matrix'
p Matrix.zero(2, 3) #=> Matrix[[0, 0, 0], [0, 0, 0]]
//}

@param row 生成する行列の行数
@param column 生成する行列の列数...

Matrix::EigenvalueDecomposition#eigenvalue_matrix -> Matrix (18907.0)

固有値を対角成分に並べた行列を返します。

固有値を対角成分に並べた行列を返します。

Matrix#regular? -> bool (18679.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#column_vectors -> [Vector] (18661.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]]
//}...

絞り込み条件を変える

Vector#cross(*vs) -> Vector (18661.0)

self とベクトル vs とのクロス積を返します。

...vs は n-2 個の
n次元ベクトルでなければなりません。

@param vs クロス積を取るベクトルの集合
@raise ExceptionForMatrix::ErrOperationNotDefined self の
次元が1以下であるときに発生します。
@raise ArgumentError vs のベクトルの個数が n-...

Matrix#coerce(other) -> Array (18643.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#row(i) -> Vector | nil (18643.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 (18643.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_vectors -> [Vector] (18643.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.row_vectors # => [Vector[1, 2, 3], Vector[10, 15, 20], Vector[-1, -2, 1.5]]
//}...

絞り込み条件を変える

Matrix#elements_to_r -> Matrix (18628.0)

各要素を有理数 Rational に変換した行列を返します。

各要素を有理数 Rational に変換した行列を返します。

このメソッドは deprecated です。 map(&:to_r) を使ってください。

Matrix#cofactor_expansion(row: nil, column: nil) -> object | Integer | Rational | Float (18625.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#inverse -> Matrix (18625.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]]
//}...

Vector#norm -> Float (18610.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 (18607.0)

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

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

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

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

絞り込み条件を変える

Matrix#determinant -> Numeric (18607.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 (18607.0)

このメソッドは deprecated です。 Matrix#determinant を代わりに使ってください。

...このメソッドは deprecated です。
Matrix
#determinant を代わりに使ってください。...

Matrix#entrywise_product(m) -> Matrix (18607.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 (18607.0)

self から第 row 行と第 column 列を取り除いた行列を返します。

self から第 row 行と第 column 列を取り除いた行列を返します。

@param row 行
@param column 列
@raise ArgumentError row, column が行列の行数/列数を越えている場合に発生します。

Matrix#hadamard_product(m) -> Matrix (18607.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#hermitian? -> bool (18607.0)

行列がエルミートならば true を返します。

...行列がエルミートならば true を返します。

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

Matrix#imaginary -> Matrix (18607.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#minor(from_row, row_size, from_col, col_size) -> Matrix (18607.0)

selfの部分行列を返します。

...ram 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 (18607.0)

selfの部分行列を返します。

...ram 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#normal? -> bool (18607.0)

行列が正規行列ならば true を返します。

...行列が正規行列ならば true を返します。

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

絞り込み条件を変える

Matrix#orthogonal? -> bool (18607.0)

行列が直交行列ならば true を返します。

...行列が直交行列ならば true を返します。

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

Matrix#permutation? -> bool (18607.0)

行列が置換行列ならば true を返します。

...行列が置換行列ならば true を返します。

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

Matrix#rank -> Integer (18607.0)

階数 (rank) を返します。

...め、誤った結果が生じる可能性があることに注意してください。
代わりに、Rational や BigDecimal などの正確なオブジェクトを使用することを検討してください。

//emlist[][ruby]{
require 'matrix'
m = Matrix[[2, 6], [1, 3]]
m.rank # => 1
//}...

Matrix#rank_e -> Integer (18607.0)

階数 (rank) を返します。

...階数 (rank) を返します。

このメソッドは deprecated です。
代わりに Matrix#rank を使ってください。...

Matrix#real -> Matrix (18607.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 (18607.0)

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

...が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
//}...

Matrix#rect -> [Matrix, Matrix] (18607.0)

行列を実部と虚部に分解したものを返します。

...行列を実部と虚部に分解したものを返します。


//emlist[例][ruby]{
m.rect == [m.real, m.imag] # ==> true for all matrices m
//}

@see Matrix#imaginary, Matrix#real...

Matrix#rectangular -> [Matrix, Matrix] (18607.0)

行列を実部と虚部に分解したものを返します。

...行列を実部と虚部に分解したものを返します。


//emlist[例][ruby]{
m.rect == [m.real, m.imag] # ==> true for all matrices m
//}

@see Matrix#imaginary, Matrix#real...

Matrix#round(ndigits = 0) -> Matrix (18607.0)

行列の各要素を指定した桁数で丸めた行列を返します。

行列の各要素を指定した桁数で丸めた行列を返します。

@see Float#round

Matrix#row_count -> Integer (18607.0)

行列の行数を返します。

行列の行数を返します。

絞り込み条件を変える

Matrix#row_size -> Integer (18607.0)

行列の行数を返します。

行列の行数を返します。

Matrix#singular? -> bool (18607.0)

行列が正方で特異なら true を、正則なら false を返します。

...るとは、正則でないことです。
行列式が0であること同値です。

正方行列でない場合には例外 ExceptionForMatrix::ErrDimensionMismatch を
発生させます。

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

Matrix#square? -> bool (18607.0)

正方行列であるなら、 true を返します。

正方行列であるなら、 true を返します。

Matrix#transpose -> Matrix (18607.0)

転置行列 (transpose matrix) を返します。

...転置行列 (transpose matrix) を返します。

self を Matrix のオブジェクトで、(m,n) 型行列としたとき a(j,i) を (i,j) 要素とする (n,m) 型行列を返します。...

Matrix#unitary? -> bool (18607.0)

行列がユニタリならば true を返します。

...行列がユニタリならば true を返します。

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

絞り込み条件を変える

Matrix#zero? -> bool (18607.0)

行列が零行列ならば true を返します。

行列が零行列ならば true を返します。

Matrix.column_vector(column) -> Matrix (18607.0)

要素がcolumnの(n,1)型の行列(列ベクトル)を生成します。

要素がcolumnの(n,1)型の行列(列ベクトル)を生成します。

@param column (n,1)型の行列として生成するVector Array オブジェクト

Matrix.scalar(n, value) -> Matrix (18607.0)

対角要素が全てvalue(数)で、非対角要素が全て0であるようなn次の正方行列を生成します。

...角要素が全て0であるようなn次の正方行列を生成します。

@param n 生成する行列の次元
@param value 生成する行列の対角要素の値


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

m = Matrix.scalar(3, 2.5)
p m # => Matrix[[2.5, 0, 0], [0, 2.5, 0], [0, 0, 2.5]]
//}...

Matrix.zero(n) -> Matrix (18607.0)

n × n の零行列(要素が全て 0 の行列)を生成して返します。

...n × n の零行列(要素が全て 0 の行列)を生成して返します。

//emlist[例][ruby]{
require 'matrix'
p Matrix.zero(2) #=> Matrix[[0, 0], [0, 0]]
//}

@param n 生成する正方零行列の次数...

Matrix::EigenvalueDecomposition#eigenvectors -> [Vector] (18607.0)

右固有ベクトルを配列で返します。

右固有ベクトルを配列で返します。

絞り込み条件を変える

Matrix::EigenvalueDecomposition#to_ary -> [Matrix, Matrix, Matrix] (18607.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 (18607.0)

右固有ベクトルを横に並べた行列を返します。

右固有ベクトルを横に並べた行列を返します。

Matrix::EigenvalueDecomposition#v_inv -> Matrix (18607.0)

左固有ベクトルを縦に並べた行列を返します。

...左固有ベクトルを縦に並べた行列を返します。

これは Matrix::EigenvalueDecomposition#v の逆行列です...

Matrix::LUPDecomposition#determinant -> Numeric (18607.0)

元の行列の行列式の値を返します。 LUP 分解の結果を利用して計算します。

...元の行列の行列式の値を返します。
LUP 分解の結果を利用して計算します。

@see Matrix#determinant...

Matrix::LUPDecomposition#singular? -> bool (18607.0)

元の行列が正方で特異なら true を、正則なら false を返します。 LUP 分解の結果を利用して判定します。

...元の行列が正方で特異なら true を、正則なら false を返します。
LUP 分解の結果を利用して判定します。

@see Matrix#singular?...

絞り込み条件を変える

Matrix::LUPDecomposition#to_ary -> [Matrix, Matrix, Matrix] (18607.0)

分解した行列を [下半行列, 上半行列, 置換行列] という3要素の配列で 返します。

分解した行列を [下半行列, 上半行列, 置換行列] という3要素の配列で
返します。

Vector#covector -> Matrix (18607.0)

Matrix オブジェクトへ変換します。

...Matrix オブジェクトへ変換します。

列ベクトル (行列)、すなわち、(n, 1) 型の行列に変換します。
実際には Matrix.row_vector(self) を適用します。

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

v = Vector[2, 3, 5]
p v # => Vector[2, 3, 5]
m = v.covector
p m # => M...

Vector#inner_product(v) -> Float (18607.0)

ベクトル v との内積を返します。

...ベクトル v との内積を返します。

@param v 内積を求めるベクトル

@raise ExceptionForMatrix::ErrDimensionMismatch 自分自身と引数のベクト
ルの要素の数(次元)が異なっていたときに発生します。...

Vector#normalize -> Vector (18607.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#zero? -> bool (18607.0)

すべての要素がゼロであれば true を返します。

すべての要素がゼロであれば true を返します。

絞り込み条件を変える

Vector.zero(size) -> Vector (18607.0)

零ベクトルを返します。

...零ベクトルを返します。

//emlist[例][ruby]{
require 'matrix'
Vector.zero(3) # => Vector[0, 0, 0]
//}

@param size ベクトルの次元...

Matrix (18151.0)

数Numericを要素とする行列を扱うクラスです。

...a(m-1,n-1) ]

のように、縦横の表にあらわしたものを(m,n)型の行列といいます。
m=nの行列をm次の正方行列(square matrix)といいます。
インデックスは 0 から始まることに注意してください。

上からi番目の横の数の並びを第i行(t...

Matrix.build(row_size, column_size = row_size) {|row, col| ... } -> Matrix (10225.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::EigenvalueDecomposition#to_a -> [Matrix, Matrix, Matrix] (10207.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] (10207.0)

分解した行列を [下半行列, 上半行列, 置換行列] という3要素の配列で 返します。

分解した行列を [下半行列, 上半行列, 置換行列] という3要素の配列で
返します。

絞り込み条件を変える

Matrix.build(row_size, column_size = row_size) -> Enumerable (9925.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) {|*elements| ... } -> Matrix (9925.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 (9907.0)

要素ごとにブロックを呼び出した結果を組み合わせた Matrix を返します。

...要素ごとにブロックを呼び出した結果を組み合わせた Matrix を返します。

Matrix
.combine(self, *matrices) { ... } と同じです。

@see Matrix.combine...

Matrix#find_index(selector = :all) -> Enumerator (9907.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#hstack(*matrices) -> Matrix (9907.0)

行列 self と matrices を横に並べた行列を生成します。

...self と matrices を横に並べた行列を生成します。

Matrix
.hstack(self, *matrices) と同じです。

//emlist[例][ruby]{
require 'matrix'
x = Matrix[[1, 2], [3, 4]]
y = Matrix[[5, 6], [7, 8]]
x.hstack(y) # => Matrix[[1, 2, 5, 6], [3, 4, 7, 8]]
//}

@param matrices 並べる行列。...
...すべての行列の行数がselfの行数と一致していなければならない
@raise ExceptionForMatrix::ErrDimensionMismatch 行数の異なる行列がある場合に発生します

@see Matrix.hstack, Matrix#vstack...

絞り込み条件を変える

Matrix#index(selector = :all) -> Enumerator (9907.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.hstack(*matrices) -> Matrix (9907.0)

行列 matrices を横に並べた行列を生成します。

...[例][ruby]{
require 'matrix'
x = Matrix[[1, 2], [3, 4]]
y = Matrix[[5, 6], [7, 8]]
Matrix
.hstack(x, y) # => Matrix[[1, 2, 5, 6], [3, 4, 7, 8]]
//}

@param matrices 並べる行列。すべての行列の行数が一致していなければならない
@raise ExceptionForMatrix::ErrDimensionMismatch...
...行数の異なる行列がある場合に発生します
@see Matrix.vstack, Matrix#hstack...

Matrix.vstack(*matrices) -> Matrix (9907.0)

行列 matrices を縦に並べた行列を生成します。

...][ruby]{
require 'matrix'
x = Matrix[[1, 2], [3, 4]]
y = Matrix[[5, 6], [7, 8]]
Matrix
.vstack(x, y) # => Matrix[[1, 2], [3, 4], [5, 6], [7, 8]]
//}

@param matrices 並べる行列。すべての行列の列数が一致していなければならない
@raise ExceptionForMatrix::ErrDimensionMismatch...
...列数の異なる行列がある場合に発生します
@see Matrix.hstack, Matrix#vstack...

Matrix.columns(columns) -> Matrix (9823.0)

引数 columns を列ベクトルの集合とする行列を生成します。

...=== 注意

Matrix
.rows との違いは引数として渡す配列の配列を列ベクトルの配列とみなして行列を生成します。

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

a1 = [1, 2, 3]
a2 = [4, 5, 6]
a3 = [-1, -2, -3]

# 配列を行ベクトルとして生成
m = Matrix.rows([a1, a...
...ue)
p m # => Matrix[[1, 2, 3], [4, 5, 6], [-1, -2, -3]]
# 行列としてのイメージ => [ 1, 2, 3]
# [ 4, 5, 6]
# [-1, -2, -3]

# 配列を列ベクトルとして生成
m = Matrix.columns([a1, a2, a3])
p m # => Matrix[[1, 4, -1]...

Vector#collect -> Enumerator (9697.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#collect {|x| ... } -> Vector (9697.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#map -> Enumerator (9697.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#map {|x| ... } -> Vector (9697.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]
//}...

Matrix#column(j) -> Vector | nil (9661.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...

Vector#*(other) -> Vector (9661.0)

self の各要素に数 other を乗じたベクトルを返します。

...ルを返します。

@param other self の各要素に掛ける Numeric オブジェクトを指定します。

//emlist[例][ruby]{
require 'matrix'
a = [1, 2, 3.5, 100]
v1 = Vector.elements(a)
p v1.*(2) # => Vector[2, 4, 7.0, 200]
p v1.*(-1.5) # => Vector[-1.5, -3.0, -5.25, -150.0]
//}...

絞り込み条件を変える

Matrix#conj -> Matrix (9643.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 (9643.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#each(which = :all) -> Enumerator (9643.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#to_a -> Array (9643.0)

自分自身をArrayに変換したものを返します。

...します。

行ベクトルを配列(Array)としたものの配列(つまり配列の配列)として返します。

//emlist[例][ruby]{
require 'matrix'
a1 = [ 1, 2, 3]
a2 = [10, 15, 20]
a3 = [-1, -2, 1.5]
m = Matrix[a1, a2, a3]

p m.to_a # => [[1, 2, 3], [10, 15, 20], [-1, -2, 1.5]]
//}...

Matrix#adjugate -> Matrix (9625.0)

余因子行列を返します。

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

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

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

絞り込み条件を変える

Matrix#inv -> Matrix (9625.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#laplace_expansion(row: nil, column: nil) -> object | Integer | Rational | Float (9625.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.combine(*matrices) -> Enumerator (9625.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::LUPDecomposition#solve(b) -> Vector | Matrix (9625.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)]]
//}...

Vector.elements(a, copy = true) -> Vector (9625.0)

配列 a を要素とするベクトルを生成します。 ただし、オプション引数 copy が偽 (false) ならば、複製を行いません。

...orを生成する際の要素の配列
@param copy 引数の配列 a のコピーをするかどうかのフラグ

//emlist[例][ruby]{
require 'matrix'
a = [1, 2, 3, 4]
v1 = Vector.elements(a, true)
v2 = Vector.elements(a, false)
p v1 # => Vector[1, 2, 3, 4]
p v2 # => Vector[1, 2, 3...

絞り込み条件を変える

<< 1 2 > >>