Struct xxcalc::linear_solver::LinearSolver
[−]
[src]
pub struct LinearSolver;
LinearSolver
is a calculator using a LinearSolverParser
and a LinearSolverEvaluator
,
to provide multiple arithmetic operations and basic linear solver capability.
The solver support the same operators as a PolynomialCalculator
, but it adds
=
operator which tries to solve value of x
and returns it.
While usage of the solver is the easiest way of embedding solving engine into
your program, please note that a Tokenizer
, LinearSolverParser
and LinearSolverEvaluator
is created with each call, which requires reallocation of memory.
Examples
assert_eq!(LinearSolver.process("2 * x + 0.5 = 1"), Ok(Polynomial::constant(0.25))); assert_eq!(LinearSolver.process("2x + 1 = 2(1-x)"), Ok(Polynomial::constant(0.25))); assert_eq!(LinearSolver.process("x^2-x^2+x=2"), Ok(Polynomial::constant(2.0))); assert_eq!(LinearSolver.process("1-x=x"), Ok(Polynomial::constant(0.5)));Run
Trait Implementations
impl Calculator<Tokenizer, LinearSolverParser, LinearSolverEvaluator> for LinearSolver
[src]
fn process(&self, line: &str) -> Result<Polynomial, CalculationError>
Takes string and evaluates it into a Polynomial. Read more