NAME

contextLinearRelation.pl - Implement linear relations.

DESCRIPTION

This macro library provides a context LinearRelation with a LinearRelation Math Object using =, <, >, <=, >=, or !=. Note that this file evolved from parserLinearInequality.pl, but it has several important differences.

Activate the context with:

Context("LinearRelation");

Use LinearRelation(formula), Formula(formula), or Compute(formula) to to create a LinearRelation object using a string formula. Alternatively, use LinearRelation(vector,point,sign where vector is the normal vector and point is a point on the plane. Either can be an array reference or a Math Object Vector or Point. And sign is one of the (in)equality symbols. Or use LinearRelation(vector,real,sign) where real is the dot product of any point in the plane with the normal vector.

Usage examples:

$LR = LinearRelation("x + y + 2z <= 5");
$LR = Formula("x + y + 2z <= 5");
$LR = Compute("x + y + 2z <= 5");
$LR = LinearRelation([1,1,2], [1,2,1], "<=");
$LR = LinearRelation([1,1,2], 5, "<=");
$LR = LinearRelation(Vector(1,1,2), Point(1,2,1), "<=");
$LR = LinearRelation(Vector(1,1,2), 5, "<=");

If $pg{specialPGEnvironmentVars}{parseAlternatives} is true in your configuration, then you may also work with sloppy inequality signs (=<, =>, <>) and with the characters ≤, ≥, and ≠.

By default, the context has three variables x, y, and z. You should explicitly set the variables if your situation should use something different. For example with

Context()->variables->are(m => 'Real', n =>'Real');

Note that things like LinearRelation("1 = 1") and <LinearRelation("1 < 5")> are allowed. These two examples are equivalent, but not equiivalent to <LinearRelation("1 < 1")> and <LinearRelation("1 5")>> which are equivalent to each other.

There is one special context flag.

standardForm

This determines whether something like <LinearRelation("x+2 < y+z")> will be displayed as <x+2 < y+z> or converted to standard form: <x-y-z < -2>. It is 0 by default.

There is one special method for LinearRelation objects.

$LR->check_at(point)

This returns true or false depending on if the point satisfies the relation. point must be a Math Object Point, Vector, or ColumnVector; or simply be an array reference. The number of entries in point must match the number of variables in the context.