Class: Carbuncle::Matrix
Overview
A matrix is a table of numbers, in a 4x4 grid. Useful for doing some mathematical operations.
Defined Under Namespace
Classes: Column, Line, Row
Constant Summary
Constants included
from Enumerable
Enumerable::NONE
Instance Method Summary
collapse
Methods included from Enumerable
__update_hash, #all?, #any?, #chain, #collect, #count, #cycle, #detect, #drop, #drop_while, #each_cons, #each_slice, #each_with_index, #each_with_object, #entries, #filter_map, #find_all, #find_index, #first, #flat_map, #grep, #group_by, #hash, #include?, #inject, #lazy, #max, #max_by, #min, #min_by, #minmax, #minmax_by, #none?, #one?, #partition, #reject, #reverse_each, #sort, #sort_by, #sum, #take, #take_while, #tally, #to_h, #uniq, #zip
Constructor Details
#initialize ⇒ self
Creates a new matrix, the values are the values of an Identity matrix.
|
# File 'gems/carbuncle-math/mrblib/matrix.rb', line 63
|
Instance Method Details
#each(&block) ⇒ Object
76
77
78
|
# File 'gems/carbuncle-math/mrblib/matrix.rb', line 76
def each(&block)
rows.map(&:to_a).flatten.each(&block)
end
|
#initialize_copy(matrix) ⇒ self
Creates a new matrix, with the same values as the one given.
76
77
78
|
# File 'gems/carbuncle-math/mrblib/matrix.rb', line 76
def each(&block)
rows.map(&:to_a).flatten.each(&block)
end
|
102
103
104
105
106
107
108
109
110
111
|
# File 'gems/carbuncle-math/mrblib/matrix.rb', line 102
def inspect
result = <<-HEREDOC
Matrix:
#{rows[0].to_a.join(', ')},
#{rows[1].to_a.join(', ')},
#{rows[2].to_a.join(', ')},
#{rows[3].to_a.join(', ')},
HEREDOC
result.strip_heredoc
end
|
113
114
115
|
# File 'gems/carbuncle-math/mrblib/matrix.rb', line 113
def size
16
end
|
98
99
100
|
# File 'gems/carbuncle-math/mrblib/matrix.rb', line 98
def to_s
inspect
end
|