Module: Algebra::PolynomialConvertTo

Defined in:
lib/algebra/polynomial-converter.rb

Instance Method Summary collapse

Instance Method Details

#convert_to(other) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/algebra/polynomial-converter.rb', line 13

def convert_to(other)
  if other <= MPolynomial
    g = self
    vs = []
    while g <= Polynomial
      vs.push g.variable
      # vs.push g.var
      g = g.ground
    end
    MPolynomial.create(g, *vs)
  else
    raise "unkown self.class (#{other})"
  end
end