Table of Contents

Struct Expression

Namespace
Nalu.Cassowary
Assembly
Nalu.Maui.Layouts.dll

An expression that can be the left hand or right hand side of a constraint equation. It is a linear combination of variables, i.e. a sum of variables weighted by coefficients, plus an optional constant.

public readonly struct Expression : IEquatable<Expression>
Implements
Inherited Members

Constructors

Expression()

Initializes a new instance of the Expression struct.

public Expression()

Expression(ImmutableArray<Term>, double)

Initializes a new instance of the Expression struct.

public Expression(ImmutableArray<Term> terms, double constant)

Parameters

terms ImmutableArray<Term>

Terms of the expression.

constant double

Constant value.

Properties

Constant

Gets the constant value of the expression.

public double Constant { get; init; }

Property Value

double

Terms

Gets the terms of the expression.

public ImmutableArray<Term> Terms { get; init; }

Property Value

ImmutableArray<Term>

Methods

Deconstruct(out ImmutableArray<Term>, out double)

Deconstructs the expression into terms and constant.

public void Deconstruct(out ImmutableArray<Term> terms, out double constant)

Parameters

terms ImmutableArray<Term>
constant double

Equals(Expression)

Indicates whether the current object is equal to another object of the same type.

public bool Equals(Expression other)

Parameters

other Expression

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

From(Term)

Constructs an expression from a single term. Forms an expression of the form n x where n is the coefficient, and x is the variable.

public static Expression From(Term term)

Parameters

term Term

The Term.

Returns

Expression

New instance of Expression.

From(Variable)

Constructs an expression from a single variable. Forms an expression of the form x

public static Expression From(Variable variable)

Parameters

variable Variable

The Variable.

Returns

Expression

New instance of Expression.

From(double)

Constructs an expression of the form n, where n is a constant real number, not a variable.

public static Expression From(double constant)

Parameters

constant double

The constant value.

Returns

Expression

New instance of Expression.

GetHashCode()

Returns the hash code for this instance.

public override int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

ToString()

Returns the fully qualified type name of this instance.

public override string ToString()

Returns

string

The fully qualified type name.

Operators

operator +(Expression, Expression)

Sum two Expression.

public static Expression operator +(Expression expression, Expression other)

Parameters

expression Expression

The Expression.

other Expression

The Expression.

Returns

Expression

New Expression instance with a joins terms and constant sum.

operator +(Expression, Term)

Sum two Expression.

public static Expression operator +(Expression expression, Term other)

Parameters

expression Expression

The Expression.

other Term

The Term.

Returns

Expression

New Expression instance with a joins terms and constant sum.

operator +(Expression, Variable)

Sum Expression with a Variable.

public static Expression operator +(Expression expression, Variable variable)

Parameters

expression Expression

The Expression.

variable Variable

The Variable.

Returns

Expression

New Expression instance with a Term with a coefficient value as -1.

operator +(Expression, double)

Sum Expression with a float value.

public static Expression operator +(Expression expression, double value)

Parameters

expression Expression

The Expression.

value double

The value.

Returns

Expression

New Expression instance with a constant sum.

operator +(Expression, float)

Sum Expression with a float value.

public static Expression operator +(Expression expression, float value)

Parameters

expression Expression

The Expression.

value float

The value.

Returns

Expression

New Expression instance with a constant sum.

operator +(double, Expression)

Sum Expression with a float value.

public static Expression operator +(double value, Expression expression)

Parameters

value double

The value.

expression Expression

The Expression.

Returns

Expression

New Expression instance with a constant sum.

operator +(float, Expression)

Sum Expression with a float value.

public static Expression operator +(float value, Expression expression)

Parameters

value float

The value.

expression Expression

The Expression.

Returns

Expression

New Expression instance with a constant sum.

operator |(Expression, WeightedRelation)

public static PartialConstraint operator |(Expression expression, WeightedRelation relation)

Parameters

expression Expression

The Expression.

relation WeightedRelation

The WeightedRelation.

Returns

PartialConstraint

New PartialConstraint instance.

operator /(Expression, double)

Divide Expression by float value.

public static Expression operator /(Expression expression, double value)

Parameters

expression Expression

The Expression.

value double

The value

Returns

Expression

New Expression instance with Term and Constant dividing by value.

operator /(Expression, float)

Divide Expression by float value.

public static Expression operator /(Expression expression, float value)

Parameters

expression Expression

The Expression.

value float

The value

Returns

Expression

New Expression instance with Term and Constant dividing by value.

operator ==(Expression, Expression)

Checks if two Expression are equal.

public static bool operator ==(Expression left, Expression right)

Parameters

left Expression

Left Expression.

right Expression

Right Expression.

Returns

bool

operator !=(Expression, Expression)

Checks if two Expression are not equal.

public static bool operator !=(Expression left, Expression right)

Parameters

left Expression

Left Expression.

right Expression

Right Expression.

Returns

bool

operator *(Expression, double)

Multiply Expression by float value.

public static Expression operator *(Expression expression, double value)

Parameters

expression Expression

The Expression.

value double

The value

Returns

Expression

New Expression instance with Term and Constant multiply by value.

operator *(Expression, float)

Multiply Expression by float value.

public static Expression operator *(Expression expression, float value)

Parameters

expression Expression

The Expression.

value float

The value

Returns

Expression

New Expression instance with Term and Constant multiply by value.

operator *(double, Expression)

Multiply Expression by float value.

public static Expression operator *(double value, Expression expression)

Parameters

value double

The value

expression Expression

The Expression.

Returns

Expression

New Expression instance with Term and Constant multiply by value.

operator *(float, Expression)

Multiply Expression by float value.

public static Expression operator *(float value, Expression expression)

Parameters

value float

The value

expression Expression

The Expression.

Returns

Expression

New Expression instance with Term and Constant multiply by value.

operator -(Expression, Expression)

Subtract Expression from Expression.

public static Expression operator -(Expression expression, Expression other)

Parameters

expression Expression

The Expression.

other Expression

The Expression.

Returns

Expression

New Expression instance by negative of other and add terms and sum Constant.

operator -(Expression, Term)

Subtract Term from Expression.

public static Expression operator -(Expression expression, Term term)

Parameters

expression Expression

The Expression.

term Term

The Term.

Returns

Expression

New Expression with a negative Term.

operator -(Expression, Variable)

Subtract Variable from Expression.

public static Expression operator -(Expression expression, Variable variable)

Parameters

expression Expression

The Expression.

variable Variable

The Variable.

Returns

Expression

New Expression instance with a Term with a coefficient value as -1.

operator -(Expression, double)

Subtract float value from Expression.

public static Expression operator -(Expression expression, double value)

Parameters

expression Expression

The Expression.

value double

The float.

Returns

Expression

New Expression instance with a constant sub.

operator -(Expression, float)

Subtract float value from Expression.

public static Expression operator -(Expression expression, float value)

Parameters

expression Expression

The Expression.

value float

The float.

Returns

Expression

New Expression instance with a constant sub.

operator -(double, Expression)

Subtract float value from Expression.

public static Expression operator -(double value, Expression expression)

Parameters

value double

The float.

expression Expression

The Expression.

Returns

Expression

New Expression instance with a constant sub.

operator -(float, Expression)

Subtract float value from Expression.

public static Expression operator -(float value, Expression expression)

Parameters

value float

The float.

expression Expression

The Expression.

Returns

Expression

New Expression instance with a constant sub.

operator -(Expression)

Negate Expression.

public static Expression operator -(Expression expression)

Parameters

expression Expression

The Expression.

Returns

Expression

New instance of Expression with negative Term and constant.