Ruby 1.8.7 リファレンスマニュアル > ライブラリ一覧 > matrixライブラリ > Matrixクラス
クラスの継承リスト: Matrix < Object < Kernel
数Numericを要素とする行列を扱うクラスです。
行列
m * n 個の数a(i,j)を
[ a(0,0) a(0,1) a(0,2) a(0,3) ... a(0,n-1) ] [ a(1,0) a(1,1) a(1,2) a(1,3) ... a(1,n-1) ] [ a(2,0) a(2,1) a(2,2) a(2,3) ... a(2,n-1) ] [ ] [ a(m-1,0) a(m-1,n-1) ]
のように、縦横の表にあらわしたものを(m,n)型の行列という。 m=nの行列をm次の正方行列(square matrix)という。
上からi番目の横の数の並びを第i行(the i-th row)、 左からj番目の縦の数の並びを第j列(the j-th column)という。
(m,n)型行列は、 大きさnの行(横)ベクトルをm個縦に並べたものとみなすこともできるし、 大きさmの列(縦)ベクトルをn個横に並べたものとみなすこともできる。
第i行、第j列にある数a(i,j)を(i,j)要素(the (i,j)-th element)という。
i=jの要素a(i,j)を対角要素(diagonal element)、 それ以外の要素を非対角要素(nondiagonal element)という。
require 'complex'することによって、 Matrixオブジェクトの要素はComplexクラスに拡張される。 多くのメソッドは、この拡張されたMatrixクラスでも、期待通りに動作する。
次の例は、各要素を共役複素数に置換するメソッド Matrix#conjugate である。
require 'matrix' require 'complex' class Matrix def conjugate collect{|e| e.conjugate } end end
定義 | 説明 | |
---|---|---|
identity(n) -> Matrix
|
n次の単位行列を生成します。 |
|
self[rows] -> Matrix
|
rowsを要素とする行列を生成します。 配列を行列の行成分として行列を生成します。 |
|
column_vector(column) -> Matrix
|
要素がcolumnの(n,1)型の行列(列ベクトル)を生成します。 |
|
columns(columns) -> Matrix
|
引数 columns を列ベクトルの集合とする行列を生成します。 |
|
diagonal(values) -> Matrix
|
対角要素がvalues(オブジェクトの並び)で、非対角要素が全て0であるような 正方行列を生成します。 |
|
row_vector(row) -> Matrix
|
要素がrowの(1,n)型の行列(行ベクトル)を生成します。 |
|
rows(rows, copy = true) -> Matrix
|
引数 rows を要素とする行列を生成します。 引数 copy が偽(false)ならば、rows の複製を行いません。 |
|
scalar(n, value) -> Matrix
|
対角要素が全てvalue(数)で、非対角要素が全て0であるようなn次の正方行列を生成します。 |
|
zero(n) -> Matrix
|
n次の零行列を生成します。 零行列とは、要素が全て0の行列です。 |
===
=~
__id__
__send__
_dump
class
clone
dclone
display
enum_for
equal?
extend
freeze
frozen?
initialize
initialize_copy
instance_eval
instance_exec
instance_of?
instance_variable_defined?
instance_variable_get
instance_variable_set
instance_variables
is_a?
marshal_dump
marshal_load
method
method_missing
methods
nil?
pretty_inspect
pretty_print
pretty_print_cycle
pretty_print_inspect
pretty_print_instance_variables
private_methods
protected_methods
public_methods
remove_instance_variable
respond_to?
singleton_method_added
singleton_method_removed
singleton_method_undefined
singleton_methods
taint
tainted?
tap
to_ary
to_hash
to_int
to_io
to_proc
to_regexp
to_str
to_yaml
to_yaml_properties
to_yaml_style
untaint
.new