class Pbw::Utils::Polynomial

Attributes

coefficients[R]

Public Class Methods

mkroll(n) click to toggle source
# File lib/pbw/utils/polynomial.rb, line 10
def self.mkroll (n)
            x = [0]

            (1..n).each do |i|
         x[i] = 1
            end

            ::Pbw::Utils::Polynomial.new(x)
end
new(yarr) click to toggle source
# File lib/pbw/utils/polynomial.rb, line 4
def initialize (yarr)
            @coefficients = yarr
end

Public Instance Methods

*(other) click to toggle source
# File lib/pbw/utils/polynomial.rb, line 20
def *(other)
            noob = []

            @coefficients.each_with_index do |xi, i|
         other.coefficients.each_with_index do |yj, j|
                            cell = i + j

                            if noob[cell].nil?
                                noob[cell] = 0
                            end

                            noob[cell] += xi * yj
         end
            end

            ::Pbw::Utils::Polynomial.new(noob)
end