Bug #1532 » c_matrix_trace.diff
lib/matrix.rb | ||
---|---|---|
# => 16
|
||
#
|
||
def trace
|
||
Matrix.Raise ErrDimensionMismatch unless square?
|
||
(0...column_size).inject(0) do |tr, i|
|
||
tr + @rows[i][i]
|
||
end
|