[][src]Type Definition free_algebra::FreeModule

type FreeModule<R, T> = ModuleString<R, T, !>;

A module over a ring constructed from free addition scalar-multiplication of elements of a set

Concretely, given a set T and ring R, we construct the free-module of T over R as the set of linear combination over elements in T where the scalars are in R. In practice, though, this construction is effectively just polynomials with variables from T but without multiplication.

Examples

use maths_traits::algebra::Zero;
use free_algebra::FreeModule;

let p = FreeModule::zero() + (3.5, 'x') + (2.0, 'y') + (1.0, 'x');
let q = FreeModule::zero() - (1.5, 'x') + (2.0, 'y');

assert_eq!([p[&'x'], p[&'y']], [4.5, 2.0]);
assert_eq!([q[&'x'], q[&'y']], [-1.5, 2.0]);

let r = &p + &q;
let s = (p - q) * 0.5;

assert_eq!([r[&'x'], r[&'y']], [3.0, 4.0]);
assert_eq!([s[&'x'], s.get(&'y')], [3.0, 0.0]);