non/spire — pull request #159 by jamesthompson (2013-10-09 21:49:07+00:00)
Title: Multivariate Polynomials

Added:

Monomials - A class & companion object with associated Eq[Monomial] & Order[Monomial] traits
- monomials are a coefficient of type C (which must have a Ring[C] and Order[C] in scope) and its product with a list of variables (symbol given by a Char) to a power (Int). This is encoded as a Map[Char, Int].

Multivariate Polynomials - A class & companion object.
- multivariate polynomials are encoded by an Array[Monomial[C]]. A multivariate polynomial has the same algebraic properties as regular Polynomials. Although here they are not yet extending the Polynomial trait. The companion object has a value representing the Order[Monomial[C]] as lexicographic. There are also Glex and Grevlex Order[Monomial[C]] traits but these aren't yet being used.

MultivariatePolynomialTest - Tests for Monomial and MultivariatePolynomial with assertions on hard coded real solutions to arithmetic challenges. Also arbitrary term algebraic property tests for both Monomial and Multivariate Polynomial are tested.

At present the easiest way to make a MultivariatePolynomial is through it's companion object (which must be used) as follows:
MultivariatePolynomial(Monomial(r"2/3", 'x' -> 2, 'y' -> 3, 'z' -> 1), Monomial(r"3/4", 'y' -> 2, 'z' -> 3), Monomial(r"4/5", x -> 0))