[][src]Macro polynomials::poly

macro_rules! poly {
    ($($args:tt)*) => { ... };
}

Creates a Polynomial from a list of coefficients in ascending order.

This is a wrapper around the vec! macro, to instantiate a polynomial from a vector of coefficients.

poly! allows Polynomials to be defined with the same syntax as array expressions. There are two forms of this macro:

  • Create a Polynomial containing a given list of coefficients:
let p = poly![1, 2, 3]; // 3x^2 + 2x + 1
assert_eq!(p[0], 1);
assert_eq!(p[1], 2);
assert_eq!(p[2], 3);
  • Create a Polynomial from a given coefficient and size:
let p = poly![1; 3]; // x^2 + x + 1
assert_eq!(p, poly![1, 1, 1]);