MathEquationManager


Description:

public interface MathEquationManager : Object

Equation manager, holding a set of equations and variables.

Equations can depend on calculated expression from variables or values set to variables when they are a MathParameter

In the next code you create a parser, then use Parser.parse to add the parsed equation to an equation manager.

 var parser = new Parser ();
var eqman = new EquationManager ();
parser.parse ("3*5", eqman);
var eq = eqman.equations.get_item (0) as MathEquation;
var res = eq.solve ();
var c = (MathConstant) res;
// Result will be 15
stdout.printf ("%g", c.real ());

Is possible to create expressions, set to a variable, add to an equation manager create an expression using that variable to add to the manager; then solve the dependant equation and then the variable will be evalated too, in order to produce a result:

 var parser = new Parser ();
var eqman = new EquationManager ();
parser.parse ("x=3*5", eqman);
parser.parse ("2*x+7*x^2", eqman);
var eq = eqman.equations.get_item (1) as MathEquation;
var res = eq.solve ();
var c = (MathConstant) res;
// Result will be 1605
stdout.printf ("%g", c.real ());

Is possible to define parameters instead of MathVariable. To do so, fine them at parsing time, then you can get it to change its value, to evaluate the dependant equation.

 var parser = new Parser ();
var eqman = new EquationManager ();
parser.parse ("$param1*5", eqman);
var eq = eqman.equations.get_item (1) as MathEquation;
var p = eqman.variable.find_named ("param1");
p.set_value (5.0);
var res = eq.solve ();
var c = (MathConstant) res;
// Result will be 25
stdout.printf ("%g", c.real ());

All known implementing classes:

Namespace: GCalc
Package: GCalc-2

Content:

Properties:

Methods:

Inherited Members:

All known members inherited from class GLib.Object