Method: Mathpack::SLE.solve
- Defined in:
- lib/mathpack/sle.rb
.solve(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/mathpack/sle.rb', line 7 def self.solve(params) type = params[:f].class @matrix = Marshal.load(Marshal.dump(params[:matrix])).to_a @f = params[:f].to_a.flatten fail 'Incorrect size of array or vector' unless @matrix.length == @matrix.first.length && @matrix.length == @f.length @number = @f.length @x = Array.new(@number) { |i| i + 1 } fail 'Matrix is singular' unless solve_direct type == Matrix ? Matrix.row_vector(solve_reverse) : solve_reverse end |