inverse_from(src)
public
Not for public consumption?
Show source
def inverse_from(src)
size = row_size - 1
a = src.to_a
for k in 0..size
i = k
akk = a[k][k].abs
((k+1)..size).each do |j|
v = a[j][k].abs
if v > akk
i = j
akk = v
end
end
Matrix.Raise ErrNotRegular if akk == 0
if i != k
a[i], a[k] = a[k], a[i]
@rows[i], @rows[k] = @rows[k], @rows[i]
end
akk = a[k][k]
for i in 0 .. size
next if i == k
q = a[i][k].quo(akk)
a[i][k] = 0
for j in (k + 1).. size
a[i][j] -= a[k][j] * q
end
for j in 0..size
@rows[i][j] -= @rows[k][j] * q
end
end
for j in (k + 1).. size
a[k][j] = a[k][j].quo(akk)
end
for j in 0..size
@rows[k][j] = @rows[k][j].quo(akk)
end
end
self
end