Ruby 2.2.0 リファレンスマニュアル > ライブラリ一覧 > matrixライブラリ > Matrixクラス
クラス・モジュールの継承リスト: Matrix < Enumerable < Object < Kernel < BasicObject
数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)といいます。インデックスは 0 から始まることに注意してください。
上から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)といいます。
定義 | 説明 | |
---|---|---|
identity(n) -> Matrix
|
n次の単位行列を生成します。 |
|
self[*rows] -> Matrix
|
rows[i] を第 i 行とする行列を生成します。 |
|
build(row_size, column_size = row_size) {|row, col| ... } -> Matrix
|
row_size×column_sizeの行列をブロックの返り値から生成します。 |
|
column_vector(column) -> Matrix
|
要素がcolumnの(n,1)型の行列(列ベクトル)を生成します。 |
|
columns(columns) -> Matrix
|
引数 columns を列ベクトルの集合とする行列を生成します。 |
|
diagonal(*values) -> Matrix
|
対角要素がvaluesで、非対角要素が全て0であるような正方行列を生成します。 |
|
empty(row_size=0, column_size=0) -> Matrix
|
要素を持たない行列を返します。 |
|
hstack(*matrices) -> Matrix
|
行列 matrices を横に並べた行列を生成します。 |
|
row_vector(row) -> Matrix
|
要素がrowの(1,n)型の行列(行ベクトル)を生成します。 |
|
rows(rows, copy = true) -> Matrix
|
引数 rows を行ベクトルの列とする行列を生成します。 |
|
scalar(n, value) -> Matrix
|
対角要素が全てvalue(数)で、非対角要素が全て0であるようなn次の正方行列を生成します。 |
|
vstack(*matrices) -> Matrix
|
行列 matrices を縦に並べた行列を生成します。 |
|
zero(n) -> Matrix
|
n × n の零行列(要素が全て 0 の行列)を生成して返します。 |
|
zero(row, column) -> Matrix
|
row × column の零行列(要素が全て 0 の行列)を生成して返します。 |
!
!=
__id__
__send__
instance_eval
instance_exec
method_missing
singleton_method_added
singleton_method_removed
singleton_method_undefined
all?
any?
chunk
chunk_while
collect_concat
count
cycle
detect
drop
drop_while
each_cons
each_entry
each_slice
each_with_object
entries
find_all
first
grep
grep_v
group_by
include?
inject
lazy
max
max_by
min
min_by
minmax
minmax_by
none?
one?
partition
reject
reverse_each
slice_after
slice_before
slice_when
sort
sort_by
sum
take
take_while
to_h
to_set
uniq
zip
!~
<=>
===
=~
_dump
class
clone
define_singleton_method
display
enum_for
equal?
extend
freeze
frozen?
initialize
initialize_copy
instance_of?
instance_variable_defined?
instance_variable_get
instance_variable_set
instance_variables
is_a?
itself
marshal_dump
marshal_load
method
methods
nil?
object_id
pretty_inspect
pretty_print
pretty_print_cycle
pretty_print_inspect
pretty_print_instance_variables
private_methods
protected_methods
psych_to_yaml
public_method
public_methods
public_send
remove_instance_variable
respond_to?
respond_to_missing?
send
singleton_class
singleton_method
singleton_methods
taint
tainted?
tap
to_ary
to_hash
to_int
to_io
to_proc
to_regexp
to_str
trust
untaint
untrust
untrusted?
.new
.yaml_tag
::ARGF
::ARGV
::DATA
::ENV
::FALSE
::NIL
::RUBY_COPYRIGHT
::RUBY_DESCRIPTION
::RUBY_ENGINE
::RUBY_PATCHLEVEL
::RUBY_PLATFORM
::RUBY_RELEASE_DATE
::RUBY_REVISION
::RUBY_VERSION
::SCRIPT_LINES__
::STDERR
::STDIN
::STDOUT
::TOPLEVEL_BINDING
::TRUE