# Segment

An open segment. Defined in ]StartTime, EndTime[.

From unit structure defined in [BT08] Section 4.1

`public sealed class Segment : Element, IToCodeString, Unipi.Nancy.Utility.IStableHashCode, System.IEquatable<Segment>`

Inheritance Object → Element → Segment

Implements IToCodeString, IStableHashCode, IEquatable<Segment>

## Properties

**Type**

Type identification property for JSON (de)serialization.

`public string Type { get; }`

#### Property Value

**StartTime**

Exclusive left endpoint of the support of the segment.

Referred to as $x_i$ in [BT08] Section 4.1

`public Rational StartTime { get; }`

#### Property Value

**EndTime**

Exclusive rigth endpoint of the support of the segment.

Referred to as $x_i$ in [BT08] Section 4.1

`public Rational EndTime { get; }`

#### Property Value

**RightLimitAtStartTime**

Right limit of the segment at StartTime, $f(a+)$.

Referred to as $\rho_i$ in [BT08] Section 4.1

`public Rational RightLimitAtStartTime { get; }`

#### Property Value

**Slope**

Slope of the segment.

Referred to as $\rho_i$ in [BT08] Section 4.1

`public Rational Slope { get; }`

#### Property Value

**LeftLimitAtEndTime**

Left limit of the segment at EndTime, $f(b-)$.

`public Rational LeftLimitAtEndTime { get; }`

#### Property Value

**IsInfinite**

True if the segment has value plus/minus infinite.

`public bool IsInfinite { get; }`

#### Property Value

**IsPlusInfinite**

True if the segment has value plus infinite.

`public bool IsPlusInfinite { get; }`

#### Property Value

**IsMinusInfinite**

True if the segment has value minus infinite.

`public bool IsMinusInfinite { get; }`

#### Property Value

**IsZero**

True if the segment has value 0 over all of its support.

`public bool IsZero { get; }`

#### Property Value

**IsConstant**

True if the segment has a constant value

`public bool IsConstant { get; }`

#### Property Value

**StartSlope**

Slope, w.r.t. origin, of the left endpoint of the segment.

`public Rational StartSlope { get; }`

#### Property Value

**EndSlope**

Slope, w.r.t. origin, of the right endpoint of the segment.

`public Rational EndSlope { get; }`

#### Property Value

**Length**

Length in time of the element. If the element is a Segment, it is strictly greater than 0. If the element is a Point, it is equal to 0.

`public Rational Length { get; }`

#### Property Value

**IsFinite**

True if the element has finite value.

`public bool IsFinite { get; }`

#### Property Value

## Constructors

**Segment(Rational, Rational, Rational, Rational)**

Constructor.

`public Segment(Rational startTime, Rational endTime, Rational rightLimitAtStartTime, Rational slope)`

#### Parameters

`startTime`

Rational

Left endpoint of the support of the segment.

`endTime`

Rational

Right endpoint of the support of the segment.

`rightLimitAtStartTime`

Rational

Right limit of the segment at startTime, f(a+).

`slope`

Rational

Slope of the segment.

#### Exceptions

## Methods

**Constant(Rational, Rational, Rational)**

Constructs a segment with a constant value.

`public static Segment Constant(Rational startTime, Rational endTime, Rational value)`

#### Parameters

`startTime`

Rational

Left endpoint of the support of the segment.

`endTime`

Rational

Right endpoint of the support of the segment.

`value`

Rational

Value of the segment.

#### Returns

**Zero(Rational, Rational)**

Constructs a segment with constant value 0.

`public static Segment Zero(Rational startTime, Rational endTime)`

#### Parameters

`startTime`

Rational

Left endpoint of the support of the segment.

`endTime`

Rational

Right endpoint of the support of the segment.

#### Returns

**PlusInfinite(Rational, Rational)**

Constructs a segment with constant value $+\infty$.

`public static Segment PlusInfinite(Rational startTime, Rational endTime)`

#### Parameters

`startTime`

Rational

Left endpoint of the support of the segment.

`endTime`

Rational

Right endpoint of the support of the segment.

#### Returns

**MinusInfinite(Rational, Rational)**

Constructs a segment with constant value $-\infty$.

`public static Segment MinusInfinite(Rational startTime, Rational endTime)`

#### Parameters

`startTime`

Rational

Left endpoint of the support of the segment.

`endTime`

Rational

Right endpoint of the support of the segment.

#### Returns

**ValueAt(Rational)**

`public Rational ValueAt(Rational time)`

#### Parameters

`time`

Rational

#### Returns

**RightLimitAt(Rational)**

Computes the right limit of the segment at given `time`

`public Rational RightLimitAt(Rational time)`

#### Parameters

`time`

Rational

The target time of the limit

#### Returns

Rational

The value of $f(t^+)$

**LeftLimitAt(Rational)**

Computes the left limit of the segment at given `time`

`public Rational LeftLimitAt(Rational time)`

#### Parameters

`time`

Rational

The target time of the limit

#### Returns

Rational

The value of $f(t^-)$

**IsDefinedFor(Rational)**

`public bool IsDefinedFor(Rational time)`

#### Parameters

`time`

Rational

#### Returns

**Split(Rational)**

Splits the segment in a segment-point-segment set.

`public ValueTuple<Segment, Point, Segment> Split(Rational splitTime)`

#### Parameters

`splitTime`

Rational

The time of split.

#### Returns

ValueTuple<Segment, Point, Segment>

A tuple containing the segment-point-segment set resulting from the split.

#### Exceptions

ArgumentException

Thrown if the segment is not defined for the time of split.

**Sample(Rational)**

Returns a Point sampling of the segment.

`public Point Sample(Rational time)`

#### Parameters

`time`

Rational

Time of sampling.

#### Returns

Point

The sampled .

#### Exceptions

ArgumentException

Thrown if the segment is not defined for the time of sampling.

**Cut(Rational, Rational)**

Returns a cut of the segment for a smaller ]start, end[ support.

`public Segment Cut(Rational cutStart, Rational cutEnd)`

#### Parameters

`cutStart`

Rational

Left endpoint of the new support.

`cutEnd`

Rational

Right endpoint of the new support.

#### Returns

Segment

The resulting from the cut.

#### Exceptions

` Thrown if the new support is not a subset of the current one.`

**GetOverlap(Segment, Segment)**

Computes the overlap between two segments.

`public static Nullable<ValueTuple<Rational, Rational>> GetOverlap(Segment a, Segment b)`

#### Parameters

`a`

Segment

`b`

Segment

#### Returns

Nullable<ValueTuple<Rational, Rational>>

The endpoints of the overlap interval, or null if there is none.

**GetOverlap(Segment)**

Computes the overlap between two elements.

`public Nullable<ValueTuple<Rational, Rational>> GetOverlap(Segment secondOperand)`

#### Parameters

`secondOperand`

Segment

#### Returns

Nullable<ValueTuple<Rational, Rational>>

The endpoints of the overlap interval, or null if there is none.

**GetIntersection(Segment, Segment)**

Computes the Point of intersection between two Segments, if it exists.

The point is computed only if unique. If two segments coincide, even if in part, this method will return null.

`public static Point GetIntersection(Segment a, Segment b)`

#### Parameters

`a`

Segment

`b`

Segment

#### Returns

Point

The point of intersection, or null if it does not exist.

**TimeAt(Rational)**

Computes the first time the segment is at or above given `value`

.

`public Rational TimeAt(Rational value)`

#### Parameters

`value`

Rational

The value to reach.

#### Returns

Rational

The first time t at which f(t) = value, or + infinity if it is never reached.

**FromJson(String)**

Deserializes a Segment.

`public static Segment FromJson(string json)`

#### Parameters

`json`

String

#### Returns

**ToCodeString(Boolean, Int32)**

Returns a string containing C# code to create this Segment. Useful to copy and paste from a debugger into another test or notebook for further investigation.

`public string ToCodeString(bool formatted, int indentation)`

#### Parameters

`formatted`

Boolean

`indentation`

Int32

#### Returns

**GetStableHashCode()**

`public int GetStableHashCode()`

#### Returns

**Scale(Rational)**

Scales the segment by a multiplicative factor.

`public Element Scale(Rational scaling)`

#### Parameters

`scaling`

Rational

#### Returns

**Delay(Rational)**

`public Element Delay(Rational delay)`

#### Parameters

`delay`

Rational

#### Returns

**Anticipate(Rational)**

`public Element Anticipate(Rational time)`

#### Parameters

`time`

Rational

#### Returns

**VerticalShift(Rational)**

Shifts the segment vertically by an additive factor.

`public Element VerticalShift(Rational shift)`

#### Parameters

`shift`

Rational

#### Returns

**Negate()**

`public Element Negate()`

#### Returns

**Inverse()**

`public Element Inverse()`

#### Returns

**Equals(Object)**

`public bool Equals(object obj)`

#### Parameters

`obj`

Object

#### Returns

**GetHashCode()**

`public int GetHashCode()`

#### Returns

**Equals(Segment)**

`public bool Equals(Segment s)`

#### Parameters

`s`

Segment

#### Returns

**IsCertainlyAbove(Segment, Segment)**

Returns true if the first segment has always higher value than the second one. Does not consider time overlapping.

`public static bool IsCertainlyAbove(Segment a, Segment b)`

#### Parameters

`a`

Segment

`b`

Segment

#### Returns

**IsCertainlyAbove(Segment)**

Returns true if the first segment has always higher value than the second one. Does not consider time overlapping.

`public bool IsCertainlyAbove(Segment segment)`

#### Parameters

`segment`

Segment

#### Returns

**IsCertainlyBelow(Segment, Segment)**

Returns true if the first segment has always lower value than the second one. Does not consider time overlapping.

`public static bool IsCertainlyBelow(Segment a, Segment b)`

#### Parameters

`a`

Segment

`b`

Segment

#### Returns

**IsCertainlyBelow(Segment)**

Returns true if the first segment has always lower value than the second one. Does not consider time overlapping.

`public bool IsCertainlyBelow(Segment segment)`

#### Parameters

`segment`

Segment

#### Returns

**Addition(Element)**

Sums the Segment with an overlapping Element.

`public Element Addition(Element element)`

#### Parameters

`element`

Element

#### Returns

Element

The element resulting from the sum.

#### Exceptions

ArgumentException

Thrown if the segment and the element do not overlap.

**Addition(Segment, Point)**

Sums a Segment with an overlapping Point.

`public static Point Addition(Segment segment, Point point)`

#### Parameters

`segment`

Segment

`point`

Point

#### Returns

Point

The point resulting from the sum.

#### Exceptions

ArgumentException

Thrown if point and segment do not overlap.

**Addition(Point)**

Sums the Segment with an overlapping Point.

`public Point Addition(Point point)`

#### Parameters

`point`

Point

#### Returns

Point

The point resulting from the sum.

#### Exceptions

ArgumentException

Thrown if point and segment do not overlap.

**Addition(Segment, Segment)**

Sums two Segments over their overlapping part.

`public static Segment Addition(Segment a, Segment b)`

#### Parameters

`a`

Segment

`b`

Segment

#### Returns

Segment

A segment representing the sum.

#### Exceptions

ArgumentException

Thrown if there is no overlap between the segments.

**Addition(Segment)**

Sums two Segments over their overlapping part.

`public Segment Addition(Segment segment)`

#### Parameters

`segment`

Segment

#### Returns

Segment

A segment representing the sum.

#### Exceptions

ArgumentException

Thrown if there is no overlap between the segments.

**Subtraction(Element)**

Subtracts the Segment with an overlapping Element.

The operation does not enforce non-negative values.

`public Element Subtraction(Element element)`

#### Parameters

`element`

Element

#### Returns

Element

The element resulting from the subtraction.

#### Exceptions

ArgumentException

Thrown if the segment and the element do not overlap.

**Subtraction(Segment, Point)**

Subtracts a Segment with an overlapping Point.

The operation does not enforce non-negative values.

`public static Point Subtraction(Segment segment, Point point)`

#### Parameters

`segment`

Segment

`point`

Point

#### Returns

Point

The point resulting from the subtraction.

#### Exceptions

ArgumentException

Thrown if point and segment do not overlap.

**Subtraction(Point)**

Subtracts the Segment with an overlapping Point.

The operation does not enforce non-negative values.

`public Point Subtraction(Point point)`

#### Parameters

`point`

Point

#### Returns

Point

The point resulting from the subtraction.

#### Exceptions

ArgumentException

Thrown if point and segment do not overlap.

**Subtraction(Segment, Segment)**

Subtracts two Segments over their overlapping part.

The operation does not enforce non-negative values.

`public static Segment Subtraction(Segment a, Segment b)`

#### Parameters

`a`

Segment

`b`

Segment

#### Returns

Segment

A segment representing the subtraction.

#### Exceptions

ArgumentException

Thrown if there is no overlap between the segments.

**Subtraction(Segment)**

Subtracts two Segments over their overlapping part.

The operation does not enforce non-negative values.

`public Segment Subtraction(Segment segment)`

#### Parameters

`segment`

Segment

#### Returns

Segment

A segment representing the subtraction.

#### Exceptions

ArgumentException

Thrown if there is no overlap between the segments.

**Minimum(Element)**

Computes the minimum of the Segment and the given Element over their overlapping part. The result is either a point, a segment or a segment-point-segment sequence.

`public List<Element> Minimum(Element element)`

#### Parameters

`element`

Element

#### Returns

List<Element>

The set of s resulting from the minimum.

**Minimum(Segment, Point)**

Computes the minimum of a Segment and a Point over their overlapping part.

`public static Point Minimum(Segment segment, Point point)`

#### Parameters

`segment`

Segment

`point`

Point

#### Returns

Point

The point resulting from the minimum.

#### Exceptions

ArgumentException

Thrown if point and segment do not overlap.

**Minimum(Point)**

Computes the minimum of the Segment and a Point over their overlapping part.

`public Point Minimum(Point point)`

#### Parameters

`point`

Point

Second operand

#### Returns

Point

The point resulting from the minimum

#### Exceptions

ArgumentException

Thrown if point and segment do not overlap

**Minimum(Segment, Segment)**

Computes the minimum of two Segments over their overlapping part. The result is either a segment or, if the segments intersect, a segment-point-segment sequence.

`public static List<Element> Minimum(Segment a, Segment b)`

#### Parameters

`a`

Segment

`b`

Segment

#### Returns

List<Element>

The set of s resulting from the minimum.

#### Exceptions

ArgumentException

Thrown if the segments do not overlap.

**Minimum(Segment)**

Computes the minimum of two Segments over their overlapping part. The result is either a segment or, if the segments intersect, a segment-point-segment sequence.

`public List<Element> Minimum(Segment segment)`

#### Parameters

`segment`

Segment

#### Returns

List<Element>

The set of s resulting from the minimum

#### Exceptions

ArgumentException

Thrown if the segments do not overlap

**Minimum(IReadOnlyList<Segment>)**

Computes the minimum of a set of segments over their overlapping part.

`public static List<Element> Minimum(IReadOnlyList<Segment> segments)`

#### Parameters

`segments`

IReadOnlyList<Segment>

Segments of which the minimum has to be computed.

#### Returns

List<Element>

The result of the overall minimum.

#### Exceptions

ArgumentException

Thrown if the segments do not overlap.

InvalidOperationException

Thrown if the set of segments is empty.

**Maximum(Element)**

Computes the maximum of the Segment and the given Element over their overlapping part. The result is either a point, a segment or a segment-point-segment sequence.

`public List<Element> Maximum(Element element)`

#### Parameters

`element`

Element

#### Returns

List<Element>

The set of s resulting from the maximum.

**Maximum(Segment, Point)**

Computes the maximum of a Segment and a Point over their overlapping part.

`public static Point Maximum(Segment segment, Point point)`

#### Parameters

`segment`

Segment

`point`

Point

#### Returns

Point

The point resulting from the maximum.

#### Exceptions

ArgumentException

Thrown if point and segment do not overlap.

**Maximum(Point)**

Computes the maximum of the Segment and a Point over their overlapping part.

`public Point Maximum(Point point)`

#### Parameters

`point`

Point

Second operand

#### Returns

Point

The point resulting from the maximum

#### Exceptions

ArgumentException

Thrown if point and segment do not overlap

**Maximum(Segment, Segment)**

Computes the maximum of two Segments over their overlapping part. The result is either a segment or, if the segments intersect, a segment-point-segment sequence.

`public static List<Element> Maximum(Segment a, Segment b)`

#### Parameters

`a`

Segment

`b`

Segment

#### Returns

List<Element>

The set of s resulting from the maximum.

#### Exceptions

ArgumentException

Thrown if the segments do not overlap.

**Maximum(Segment)**

Computes the maximum of two Segments over their overlapping part. The result is either a segment or, if the segments intersect, a segment-point-segment sequence.

`public List<Element> Maximum(Segment segment)`

#### Parameters

`segment`

Segment

#### Returns

List<Element>

The set of s resulting from the maximum

#### Exceptions

ArgumentException

Thrown if the segments do not overlap

**Maximum(IReadOnlyList<Segment>)**

Computes the maximum of a set of segments over their overlapping part.

`public static List<Element> Maximum(IReadOnlyList<Segment> segments)`

#### Parameters

`segments`

IReadOnlyList<Segment>

Segments of which the maximum has to be computed.

#### Returns

List<Element>

The result of the overall maximum.

#### Exceptions

ArgumentException

Thrown if the segments do not overlap.

InvalidOperationException

Thrown if the set of segments is empty.

**Convolution(Element, Nullable<Rational>, Nullable<Rational>)**

Computes the convolution between the Segment and the given Element.

`public IEnumerable<Element> Convolution(Element element, Nullable<Rational> cutEnd, Nullable<Rational> cutCeiling)`

#### Parameters

`element`

Element

`cutEnd`

Nullable<Rational>

`cutCeiling`

Nullable<Rational>

#### Returns

IEnumerable<Element>

The set of s resulting from the convolution.

**Convolution(Segment, Point)**

Computes the convolution between a Segment and a Point.

Defined in [BT08] Section 3.2.1, Lemma 3

`public static Segment Convolution(Segment segment, Point point)`

#### Parameters

`segment`

Segment

`point`

Point

#### Returns

Segment

The resulting from the convolution.

**Convolution(Point)**

Computes the convolution between the Segment and a Point.

Defined in [BT08] Section 3.2.1, Lemma 3

`public Segment Convolution(Point point)`

#### Parameters

`point`

Point

#### Returns

Segment

The resulting from the convolution.

**Convolution(Segment, Segment)**

Computes the convolution between two Segments.

Defined in [BT08] Section 3.2.1, Lemma 4

`public static IEnumerable<Element> Convolution(Segment a, Segment b)`

#### Parameters

`a`

Segment

`b`

Segment

#### Returns

IEnumerable<Element>

The set of s resulting from the convolution.

**Convolution(Segment)**

Computes the convolution between two Segments.

Defined in [BT08] Section 3.2.1, Lemma 4

`public IEnumerable<Element> Convolution(Segment segment)`

#### Parameters

`segment`

Segment

#### Returns

IEnumerable<Element>

The set of s resulting from the convolution.

**Deconvolution(Element)**

Computes the deconvolution between the Segment and the given Element.

`public IEnumerable<Element> Deconvolution(Element element)`

#### Parameters

`element`

Element

#### Returns

IEnumerable<Element>

The set of s resulting from the deconvolution.

**Deconvolution(Segment, Point)**

Computes the deconvolution between a Segment and a Point.

Defined in [BT08] Section 3.2.2, Lemma 6

`public static Segment Deconvolution(Segment segment, Point point)`

#### Parameters

`segment`

Segment

`point`

Point

#### Returns

Segment

The resulting from the deconvolution.

**Deconvolution(Point)**

Computes the deconvolution between the Segment and a Point.

Defined in [BT08] Section 3.2.2, Lemma 6

`public Segment Deconvolution(Point point)`

#### Parameters

`point`

Point

#### Returns

Segment

The resulting from the deconvolution.

**Deconvolution(Segment, Segment)**

Computes the deconvolution between two Segments.

Defined in [BT08] Section 3.2.2, Lemma 8

`public static IEnumerable<Element> Deconvolution(Segment a, Segment b)`

#### Parameters

`a`

Segment

`b`

Segment

#### Returns

IEnumerable<Element>

The set of s resulting from the deconvolution.

**Deconvolution(Segment)**

Computes the deconvolution between two Segments.

Defined in [BT08] Section 3.2.2, Lemma 8

`public IEnumerable<Element> Deconvolution(Segment segment)`

#### Parameters

`segment`

Segment

#### Returns

IEnumerable<Element>

The set of s resulting from the deconvolution.

**MaxPlusConvolution(Element, Nullable<Rational>)**

Computes the max-plus convolution between the Segment and the given Element.

`public IEnumerable<Element> MaxPlusConvolution(Element element, Nullable<Rational> cutEnd)`

#### Parameters

`element`

Element

`cutEnd`

Nullable<Rational>

#### Returns

IEnumerable<Element>

The set of s resulting from the max-plus convolution.

**MaxPlusConvolution(Segment, Point)**

Computes the max-plus convolution between a Segment and a Point.

Adapted from the min-plus convolution algorithm described in [BT08] Section 3.2.1, Lemma 3

`public static Segment MaxPlusConvolution(Segment segment, Point point)`

#### Parameters

`segment`

Segment

`point`

Point

#### Returns

Segment

The resulting from the max-plus convolution.

**MaxPlusConvolution(Point)**

Computes the max-plus convolution between the Segment and a Point.

Adapted from the min-plus convolution algorithm described in [BT08] Section 3.2.1, Lemma 3

`public Segment MaxPlusConvolution(Point point)`

#### Parameters

`point`

Point

#### Returns

Segment

The resulting from the max-plus convolution.

**MaxPlusConvolution(Segment, Segment)**

Computes the max-plus convolution between two Segments.

Adapted from the min-plus convolution algorithm described in [BT08] Section 3.2.1, Lemma 4

`public static IEnumerable<Element> MaxPlusConvolution(Segment a, Segment b)`

#### Parameters

`a`

Segment

`b`

Segment

#### Returns

IEnumerable<Element>

The set of s resulting from the max-plus convolution.

**MaxPlusConvolution(Segment)**

Computes the max-plus convolution between two Segments.

Adapted from the min-plus convolution algorithm described in [BT08] Section 3.2.1, Lemma 4

`public IEnumerable<Element> MaxPlusConvolution(Segment segment)`

#### Parameters

`segment`

Segment

#### Returns

IEnumerable<Element>

The set of s resulting from the max-plus convolution.

**SubAdditiveClosure(ComputationSettings)**

Computes the sub-additive closure of the segment.

Described in [BT07] Section 4.6 as algorithm 10

`public SubAdditiveCurve SubAdditiveClosure(ComputationSettings settings)`

#### Parameters

`settings`

ComputationSettings

#### Returns

SubAdditiveCurve

The result of the sub-additive closure.

**SubAdditiveClosure(Rational, Rational, ComputationSettings)**

Computes the sub-additive closure of the pseudo-periodic segment.

Described in [BT07] Section 4.6 as algorithm 11

`public SubAdditiveCurve SubAdditiveClosure(Rational pseudoPeriodLength, Rational pseudoPeriodHeight, ComputationSettings settings)`

#### Parameters

`pseudoPeriodLength`

Rational

Length of the pseudo-period.

`pseudoPeriodHeight`

Rational

Step gained after each pseudo-period.

`settings`

ComputationSettings