Skip to main content

Sequence

A piecewise affine function with a limited support, defined between DefinedFrom and DefinedUntil. Both ends can be either inclusive or exclusive.

public sealed class Sequence : System.IEquatable<Sequence>, IToCodeString, Unipi.Nancy.Utility.IStableHashCode

Inheritance ObjectSequence
Implements IEquatable<Sequence>, IToCodeString, IStableHashCode

Properties

Elements

Set of elements composing the sequence.

public IReadOnlyList<Element> Elements { get; }

Property Value

IReadOnlyList<Element>

DefinedFrom

Left endpoint of the support of the sequence. Can be either inclusive or exclusive, see IsLeftClosed or IsLeftOpen.

public Rational DefinedFrom { get; }

Property Value

Rational

DefinedUntil

Right endpoint of the support of the sequence. Can be either inclusive or exclusive, see IsRightClosed or IsRightOpen.

public Rational DefinedUntil { get; }

Property Value

Rational

Length

Length of the support of the sequence.

public Rational Length { get; }

Property Value

Rational

Count

Number of points and segments composing the sequence.

public int Count { get; }

Property Value

Int32

IsFinite

True if all elements of the sequence are finite.

public bool IsFinite { get; }

Property Value

Boolean

IsInfinite

True if all elements of the sequence are infinite.

public bool IsInfinite { get; }

Property Value

Boolean

IsPlusInfinite

True if all elements of the sequence are plus infinite.

public bool IsPlusInfinite { get; }

Property Value

Boolean

IsMinusInfinite

True if all elements of the sequence are minus infinite.

public bool IsMinusInfinite { get; }

Property Value

Boolean

FirstFiniteTime

The first instant around which the sequence is not infinite. Does not specify whether it's inclusive or not, i.e. if f(t)f(t) is finite.

public Rational FirstFiniteTime { get; }

Property Value

Rational

FirstInfiniteTime

The first instant around which the sequence is not finite. Does not specify whether it's inclusive or not, i.e. if f(t)f(t) is infinite.

public Rational FirstInfiniteTime { get; }

Property Value

Rational

FirstNonZeroTime

The first instant around which the curve is not 0. Does not specify whether it's inclusive or not, i.e. if f(t)f(t) is 0.

public Rational FirstNonZeroTime { get; }

Property Value

Rational

IsZero

True if the sequence is 0 for all tt.

public bool IsZero { get; }

Property Value

Boolean

IsContinuous

True if there is no discontinuity within the sequence.

public bool IsContinuous { get; }

Property Value

Boolean

IsLeftContinuous

True if there is left-discontinuity within the sequence.

public bool IsLeftContinuous { get; }

Property Value

Boolean

IsRightContinuous

True if there is right-discontinuity within the sequence.

public bool IsRightContinuous { get; }

Property Value

Boolean

IsNonNegative

True if the sequence is non-negative, i.e. f(t)0f(t) \ge 0 for any tt.

public bool IsNonNegative { get; }

Property Value

Boolean

IsNonDecreasing

True if for any t>st > s, f(t)f(s)f(t) \ge f(s).

public bool IsNonDecreasing { get; }

Property Value

Boolean

IsLeftOpen

True if DefinedFrom is exclusive.

public bool IsLeftOpen { get; }

Property Value

Boolean

IsLeftClosed

True if DefinedFrom is inclusive.

public bool IsLeftClosed { get; }

Property Value

Boolean

IsRightOpen

True if DefinedUntil is exclusive.

public bool IsRightOpen { get; }

Property Value

Boolean

IsRightClosed

True if DefinedUntil is inclusive.

public bool IsRightClosed { get; }

Property Value

Boolean

IsPoint

True if the sequence consists of only a Point, meaning it is has 0 time length.

public bool IsPoint { get; }

Property Value

Boolean

StartsWithPlateau

True if the the sequence starts with a plateau.

public bool StartsWithPlateau { get; }

Property Value

Boolean

EndsWithPlateau

True if the sequence ends with a plateau.

public bool EndsWithPlateau { get; }

Property Value

Boolean

FirstPlateauEnd

Returns the end time of the plateau at the start of the sequence, or the sequence start if there is no such plateau.

public Rational FirstPlateauEnd { get; }

Property Value

Rational

LastPlateauStart

Returns the start time of the plateau at the end of the sequence, or the sequence end if there is no such plateau.

public Rational LastPlateauStart { get; }

Property Value

Rational

Constructors

Sequence(IReadOnlyList<Element>)

Constructor.

public Sequence(IReadOnlyList<Element> elements)

Parameters

elements IReadOnlyList<Element>
Set of elements composing the sequence. Must be in uninterrupted order.

Sequence(IEnumerable<Element>)

Constructor.

public Sequence(IEnumerable<Element> elements)

Parameters

elements IEnumerable<Element>
Set of elements composing the sequence. Must be in uninterrupted order.

Sequence(IEnumerable<Element>, Rational, Rational, Nullable<Rational>)

Constructor. Fills the gaps within [fillFrom, fillTo[ with the given value, defaults to ++\infty.

public Sequence(IEnumerable<Element> elements, Rational fillFrom, Rational fillTo, Nullable<Rational> fillWith)

Parameters

elements IEnumerable<Element>
Partial set of elements composing the sequence. Must be ordered, but can have gaps.

fillFrom Rational
Left inclusive endpoint of the filling interval.

fillTo Rational
Right exclusive endpoint of the filling interval.

fillWith Nullable<Rational>
The value filled in. Defaults to ++\infty

Methods

FirstFiniteTimeAfter(Rational)

The first instant after which the sequence is not infinite, starting from the right of time.

public Rational FirstFiniteTimeAfter(Rational time)

Parameters

time Rational

Returns

Rational

IsContinuousAt(Rational)

True if the sequence is continuous at time.

public bool IsContinuousAt(Rational time)

Parameters

time Rational

Returns

Boolean

IsLeftContinuousAt(Rational)

True if the sequence is continuous at time.

public bool IsLeftContinuousAt(Rational time)

Parameters

time Rational

Returns

Boolean

IsRightContinuousAt(Rational)

True if the sequence is continuous at time.

public bool IsRightContinuousAt(Rational time)

Parameters

time Rational

Returns

Boolean

Zero(Rational, Rational, Boolean, Boolean)

Constructs a sequence that is 0 between from and to.

public static Sequence Zero(Rational from, Rational to, bool isStartIncluded, bool isEndIncluded)

Parameters

from Rational
Left endpoint of the sequence

to Rational
Right endpoint of the sequence

isStartIncluded Boolean

isEndIncluded Boolean

Returns

Sequence

PlusInfinite(Rational, Rational, Boolean, Boolean)

Constructs a sequence that is ++\infty between from and to.

public static Sequence PlusInfinite(Rational from, Rational to, bool isStartIncluded, bool isEndIncluded)

Parameters

from Rational
Left endpoint of the sequence

to Rational
Right endpoint of the sequence

isStartIncluded Boolean

isEndIncluded Boolean

Returns

Sequence

MinusInfinite(Rational, Rational, Boolean, Boolean)

Constructs a sequence that is -\infty between from and to.

public static Sequence MinusInfinite(Rational from, Rational to, bool isStartIncluded, bool isEndIncluded)

Parameters

from Rational
Left endpoint of the sequence

to Rational
Right endpoint of the sequence

isStartIncluded Boolean

isEndIncluded Boolean

Returns

Sequence

Constant(Rational, Rational, Rational, Boolean, Boolean)

Constructs a sequence that is value> between from and to.

public static Sequence Constant(Rational value, Rational from, Rational to, bool isStartIncluded, bool isEndIncluded)

Parameters

value Rational
Constant value of the sequence

from Rational
Left endpoint of the sequence

to Rational
Right endpoint of the sequence

isStartIncluded Boolean

isEndIncluded Boolean

Returns

Sequence

Equals(Object)

public bool Equals(object obj)

Parameters

obj Object

Returns

Boolean

GetHashCode()

public int GetHashCode()

Returns

Int32

GetStableHashCode()

A stable hashcode.

public int GetStableHashCode()

Returns

Int32

GetHashString()

Returns the hash code as hex string .

public string GetHashString()

Returns

String

Equals(Sequence)

public bool Equals(Sequence other)

Parameters

other Sequence

Returns

Boolean

Equivalent(Sequence)

True if the sequences represent the same function.

public bool Equivalent(Sequence sequence)

Parameters

sequence Sequence

Returns

Boolean

Equivalent(Sequence, Sequence)

True if the sequences represent the same function.

public static bool Equivalent(Sequence a, Sequence b)

Parameters

a Sequence

b Sequence

Returns

Boolean

Equivalent(IEnumerable<Element>, IEnumerable<Element>)

True if the a and b are ordered sequences of elements representing the same function, over the same interval.

note

Optimized for minimal allocations

public static bool Equivalent(IEnumerable<Element> a, IEnumerable<Element> b)

Parameters

a IEnumerable<Element>

b IEnumerable<Element>

Returns

Boolean

FindFirstInequivalence(Sequence, Sequence)

Returns the first time around which the functions represented by the sequences differ. Returns null if the two sequences represent the same function. Mostly useful to debug sequences that should be equivalent.

public static Nullable<Rational> FindFirstInequivalence(Sequence a, Sequence b)

Parameters

a Sequence

b Sequence

Returns

Nullable<Rational>

LessOrEqual(Sequence, Sequence, ComputationSettings)

True if the first sequence is a lower bound for the second one, for their overlapping part.

public static bool LessOrEqual(Sequence a, Sequence b, ComputationSettings settings)

Parameters

a Sequence

b Sequence

settings ComputationSettings

Returns

Boolean

GreaterOrEqual(Sequence, Sequence, ComputationSettings)

True if the first sequence is an upper bound for the second one, for their overlapping part.

public static bool GreaterOrEqual(Sequence a, Sequence b, ComputationSettings settings)

Parameters

a Sequence

b Sequence

settings ComputationSettings

Returns

Boolean

Negate()

Returns the opposite function, g(t)=f(t)g(t) = -f(t).

public Sequence Negate()

Returns

Sequence

IsDefinedAt(Rational)

True if the sequence is defined at the given time.

public bool IsDefinedAt(Rational time)

Parameters

time Rational

Returns

Boolean

IsDefinedBefore(Rational)

True if the sequence is defined before the given time.

public bool IsDefinedBefore(Rational time)

Parameters

time Rational

Returns

Boolean

IsDefinedAfter(Rational)

True if the sequence is defined after the given time.

public bool IsDefinedAfter(Rational time)

Parameters

time Rational

Returns

Boolean

ValueAt(Rational)

Computes the value of the sequence at the given time.

public Rational ValueAt(Rational time)

Parameters

time Rational
The time of sampling.

Returns

Rational
Value of the segment at the given time or 0 if outside definition bounds.

RightLimitAt(Rational)

Computes the right limit of the sequence at given time

public Rational RightLimitAt(Rational time)

Parameters

time Rational
The target time of the limit

Returns

Rational
The value of f(t+)f(t^+)

LeftLimitAt(Rational)

Computes the left limit of the sequence at given time.

public Rational LeftLimitAt(Rational time)

Parameters

time Rational
The target time of the limit.

Returns

Rational
The value of f(t)f(t^-)

GetElementAt(Rational)

Returns the Element that describes the sequence in time.

note

This method is implemented using a binary search, O(log(n))O(\log(n))

public Element GetElementAt(Rational time)

Parameters

time Rational
Time of the sample.

Returns

Element
The describing the sequence at .

Exceptions

ArgumentException
Thrown if the given is out of sequence support.

GetSegmentBefore(Rational)

Returns the Segment that describes the sequence before time.

note

This method is implemented using a binary search, O(logn)O(\log n)

public Segment GetSegmentBefore(Rational time)

Parameters

time Rational
Time of the sample.

Returns

Segment
The describing the sequence before .

Exceptions

ArgumentException
Thrown if the given ϵ-\epsilon is out of sequence support.

GetSegmentAfter(Rational)

Returns the Segment that describes the sequence after time.

note

This method is implemented using a binary search, O(logn)O(\log n)

public Segment GetSegmentAfter(Rational time)

Parameters

time Rational
Time of the sample.

Returns

Segment
The describing the sequence after .

Exceptions

ArgumentException
Thrown if the given time +ϵ+\epsilon is out of sequence support.

GetElementAt_Linear(Rational, Int32)

Returns the Element that describes the sequence in time, and its index in the sequence.

note

This method is implemented using a linear search, O(n)O(n). It should be used in place of GetElementAt(Rational) only for consecutive queries which traverse the sequence linearly, caching the index between calls. Thus, the overall cost will be O(n)<O(nlogn)O(n) < O(n log n).

public ValueTuple<Element, int> GetElementAt_Linear(Rational time, int startingIndex)

Parameters

time Rational
Time of the sample.

startingIndex Int32
The index from which the search should start.

Returns

ValueTuple<Element, Int32>
The describing the sequence at .

Exceptions

ArgumentException
Thrown if the given time is out of sequence support.

GetOverlap(Sequence, Sequence)

Computes the overlap between two sequences.

public static Nullable<ValueTuple<Rational, Rational, bool, bool>> GetOverlap(Sequence a, Sequence b)

Parameters

a Sequence

b Sequence

Returns

Nullable<ValueTuple<Rational, Rational, Boolean, Boolean>>
The endpoints of the overlap interval, including whether its left/right closed, or null if there is none.

GetOverlap(Sequence)

Computes the overlap between two sequences.

public Nullable<ValueTuple<Rational, Rational, bool, bool>> GetOverlap(Sequence secondOperand)

Parameters

secondOperand Sequence

Returns

Nullable<ValueTuple<Rational, Rational, Boolean, Boolean>>
The endpoints of the overlap interval, or null if there is none.

Cut(Rational, Rational, Boolean, Boolean)

Returns a cut of the sequence for a smaller support.

public Sequence Cut(Rational cutStart, Rational cutEnd, bool isStartIncluded, bool isEndIncluded)

Parameters

cutStart Rational
Left endpoint of the new support.

cutEnd Rational
Right endpoint of the new support.

isStartIncluded Boolean
If true, the support is left-closed.

isEndIncluded Boolean
If true, the support is right-closed.

Returns

Sequence

Exceptions

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

CutAsEnumerable(Rational, Rational, Boolean, Boolean)

Returns a cut of the sequence for a smaller support.

note

Optimized for minimal allocations.

public IEnumerable<Element> CutAsEnumerable(Rational cutStart, Rational cutEnd, bool isStartIncluded, bool isEndIncluded)

Parameters

cutStart Rational
Left endpoint of the new support.

cutEnd Rational
Right endpoint of the new support.

isStartIncluded Boolean
If true, the support is left-closed.

isEndIncluded Boolean
If true, the support is right-closed.

Returns

IEnumerable<Element>

Exceptions

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

FindFirstIndex(Predicate<Element>, Nullable<Int32>, Nullable<Int32>)

Runs a binary search for the first element of the sequence that satisfies the predicate, and returns its index.

note

As it is based on a binary search, the predicate must divide the sequence in (up to) two parts: the first in which it is false, the second in which it is true.

public int FindFirstIndex(Predicate<Element> predicate, Nullable<int> start, Nullable<int> end)

Parameters

predicate Predicate<Element>
The predicate that the element is to be tested against.

start Nullable<Int32>
Inclusive zero-based index of the start of the range of elements to search within. If not set, defaults to 0.

end Nullable<Int32>
Non-inclusive zero-based index of the end of the range of elements to search within. If not set, defaults to Count.

Returns

Int32
The index of the first element that satisfies the predicate, or 1-1 if not found.

Exceptions

ArgumentException
and do not denote a valid range of elements in the Sequence.

FindLastIndex(Predicate<Element>, Nullable<Int32>, Nullable<Int32>)

Runs a binary search for the last element of the sequence that satisfies the predicate, and returns its index.

note

As it is based on a binary search, the predicate must divide the sequence in (up to) two parts: the first in which it is true, the second in which it is false.

public int FindLastIndex(Predicate<Element> predicate, Nullable<int> start, Nullable<int> end)

Parameters

predicate Predicate<Element>
The predicate that the element is to be tested against.

start Nullable<Int32>
Inclusive zero-based index of the start of the range of elements to search within. If not set, defaults to 0.

end Nullable<Int32>
Non-inclusive zero-based index of the end of the range of elements to search within. If not set, defaults to Count.

Returns

Int32
The index of the last element that satisfies the predicate, or -1 if not found

Exceptions

ArgumentException
and do not denote a valid range of elements in the Sequence.

GetRange(Int32, Int32)

Retrieves a range of elements from the sequence, via zero-based indexing.

public IEnumerable<Element> GetRange(int start, int end)

Parameters

start Int32
Zero-based index at which the range starts.

end Int32
Non-inclusive zero-based index at which the range ends.

Returns

IEnumerable<Element>
The range of elements

Exceptions

ArgumentException
and do not denote a valid range of elements in the Sequence.

Optimize()

Returns an equivalent sequence optimized to have the minimum amount of segments.

note

The result is a well-formed sequence [ZS23]

public Sequence Optimize()

Returns

Sequence

EnforceSplitAt(Rational)

Returns an equivalent sequence guaranteed to have a Point at the given time.

public Sequence EnforceSplitAt(Rational time)

Parameters

time Rational
Time of the split.

Returns

Sequence
A new sequence with the enforced split, or this if it's already enforced.

Exceptions

ArgumentException
Thrown if the time of split is outside the sequence support.

MaxValue()

If the sequence is upper-bounded, i.e. f(t)<=xf(t) <= x for any tt, returns xx. Otherwise, returns PlusInfinity

public Rational MaxValue()

Returns

Rational

MinValue()

If the sequence is lower-bounded, i.e. f(t)>=xf(t) >= x for any tt, returns xx. Otherwise, returns MinusInfinity

public Rational MinValue()

Returns

Rational

Fill(IEnumerable<Element>, Rational, Rational, Boolean, Boolean, Nullable<Rational>)

Fills the gaps of the set of elements within fillFrom and fillTo with the given value, defaults to ++\infty.

public static IEnumerable<Element> Fill(IEnumerable<Element> elements, Rational fillFrom, Rational fillTo, bool isFromIncluded, bool isToIncluded, Nullable<Rational> fillWith)

Parameters

elements IEnumerable<Element>
The set of elements. Must be in order.

fillFrom Rational
Left endpoint of the filling interval.

fillTo Rational
Right endpoint of the filling interval.

isFromIncluded Boolean
If true, left endpoint is inclusive.

isToIncluded Boolean
If true, right endpoint is inclusive.

fillWith Nullable<Rational>
The value filled in. Defaults to ++\infty

Returns

IEnumerable<Element>

ToString()

Returns string serialization in Json format.

public string ToString()

Returns

String

FromJson(String)

Deserializes a Sequence.

public static Sequence FromJson(string json)

Parameters

json String

Returns

Sequence

ToCodeString(Boolean, Int32)

Returns a string containing C# code to create this Sequence. 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

String

Scale(Rational)

Scales the sequence by a multiplicative factor.

public Sequence Scale(Rational scaling)

Parameters

scaling Rational

Returns

Sequence

Delay(Rational, Boolean)

Translates forward the support by the given time quantity.

public Sequence Delay(Rational delay, bool prependWithZero)

Parameters

delay Rational

prependWithZero Boolean

Returns

Sequence

Anticipate(Rational)

Translates backwards the support by the given time quantity.

public Sequence Anticipate(Rational time)

Parameters

time Rational

Returns

Sequence

VerticalShift(Rational, Boolean)

Shifts the sequence vertically by an additive factor.

public Sequence VerticalShift(Rational shift, bool exceptOrigin)

Parameters

shift Rational

exceptOrigin Boolean

Returns

Sequence

Concat(Sequence, Sequence, Boolean, Boolean)

Concatenates two sequences.

public static Sequence Concat(Sequence a, Sequence b, bool preserveDelay, bool preserveShift)

Parameters

a Sequence
The first sequence of the concatenation. It must be finite in its right end.

b Sequence
The second sequence of the concatenation. It must be finite in its left end.

preserveDelay Boolean

If bb starts later than t=0t = 0, and this option is true, this gap will be preserved in the concatenation with an infinite-valued segment. Otherwise, the gap is removed as if bb started from t=0t = 0.

preserveShift Boolean

Let b(0)b(0) be starting value of bb, if b(0)b(0) is not 00 and this option is true, this shift will be preserved in the concatenation. Otherwise, the shift is removed as if b(0)=0b(0) = 0.

Returns

Sequence
The sequence obtained from concatenating sequence at the end of sequence .

Exceptions

ArgumentException
If either sequence is infinite at the end where concatenation happens.

Concat(Sequence, Sequence, Rational)

Concatenates two sequences. Let tt be the right edge of a and xx its value. Then b is concatenated at tt, starting from value x+x + addedShift.

public static Sequence Concat(Sequence a, Sequence b, Rational addedShift)

Parameters

a Sequence
The first sequence of the concatenation. It must be finite in its right end.

b Sequence
The second sequence of the concatenation. It must be finite in its left end.

addedShift Rational

The concatenation will have an additional shift of this size.

Returns

Sequence
The sequence obtained from concatenating sequence at the end of sequence .

Exceptions

ArgumentException
If either sequence is infinite at the end where concatenation happens.

Concat(IEnumerable<Sequence>, Boolean, Boolean)

Concatenates a set of sequences, in the order they are provided.

public static Sequence Concat(IEnumerable<Sequence> sequences, bool preserveDelay, bool preserveShift)

Parameters

sequences IEnumerable<Sequence>

The sequences to be concatenated. They must be finite at each point of concatenation.

preserveDelay Boolean

For each concatenation, let bb be the second sequence. If bb starts later than t=0t = 0, and this option is true, this gap will be preserved in the concatenation with an infinite-valued segment. Otherwise, the gap is removed as if bb started from t=0t = 0.

preserveShift Boolean

For each concatenation, let bb be the second sequence. Let b(0)b(0) be starting value of bb, if b(0)b(0) is not 00 and this option is true, this shift will be preserved in the concatenation. Otherwise, the shift is removed as if b(0)=0b(0) = 0.

Returns

Sequence
The sequence obtained from concatenating all the sequences.

Exceptions

ArgumentException
If any sequence is infinite at an end where concatenation happens

ToNonNegative()

Computes a non-negative version of this sequence, i.e. a curve g(t)=f(t)g(t) = f(t) if f(t)>0f(t) > 0, g(t)=0g(t) = 0 otherwise.

public Sequence ToNonNegative()

Returns

Sequence

ToLeftContinuous()

Computes a left-continuous version of this sequence.

public Sequence ToLeftContinuous()

Returns

Sequence

ToRightContinuous()

Computes a right-continuous version of this sequence.

public Sequence ToRightContinuous()

Returns

Sequence

LowerPseudoInverse(Boolean)

Computes the lower pseudo-inverse function, f1(x)=inf{t:f(t)>=x}=sup{t:f(t)<x}f^{-1}_\downarrow(x) = \inf \left\{ t : f(t) >= x \right\} = \sup \left\{ t : f(t) < x \right\}.

note

The result of this operation is left-continuous, thus is revertible, i.e. (f1)1=f\left(f^{-1}_\downarrow\right)^{-1}_\downarrow = f, only if ff is left-continuous, see [DNC18] § 3.2.1 . Algorithmic properties discussed in [ZNS23b].

public Sequence LowerPseudoInverse(bool startFromZero)

Parameters

startFromZero Boolean
If true, it is assumed that f1(x)f^{-1}_\downarrow(x) be defined from x=0x = 0.

Returns

Sequence

Exceptions

ArgumentException
If the curve is not non-decreasing.

UpperPseudoInverse(Boolean)

Computes the upper pseudo-inverse function, f1(x)=inf{t:f(t)>x}=sup{t:f(t)<=x}f^{-1}_\uparrow(x) = \inf \left\{ t : f(t) > x \right\} = \sup \left\{ t : f(t) <= x \right\}.

note

The result of this operation is right-continuous, thus is revertible, i.e. (f1)1=f\left(f^{-1}_\uparrow\right)^{-1}_\uparrow = f, only if ff is right-continuous, see [DNC18] § 3.2.1 . Algorithmic properties discussed in [ZNS23b].

public Sequence UpperPseudoInverse(bool startFromZero)

Parameters

startFromZero Boolean
If true, it is assumed that f1(x)f^{-1}_\uparrow(x) be defined from x=0x = 0.

Returns

Sequence

Exceptions

ArgumentException
If the curve is not non-decreasing.

Addition(Sequence, Sequence)

Adds two sequences, over their overlapping parts.

public static Sequence Addition(Sequence a, Sequence b)

Parameters

a Sequence

b Sequence

Returns

Sequence
The sequence resulting from the sum.

Addition(Sequence)

Adds two sequences, over their overlapping parts.

public Sequence Addition(Sequence b)

Parameters

b Sequence

Returns

Sequence
The sequence resulting from the sum.

Subtraction(Sequence, Sequence, Boolean)

Subtracts two sequences, over their overlapping parts.

note

The operation does not enforce non-negative values.

public static Sequence Subtraction(Sequence a, Sequence b, bool nonNegative)

Parameters

a Sequence

b Sequence

nonNegative Boolean
If true, the result is non-negative.

Returns

Sequence
The sequence resulting from the sum.

Subtraction(Sequence, Boolean)

Subtracts two sequences, over their overlapping parts.

public Sequence Subtraction(Sequence b, bool nonNegative)

Parameters

b Sequence

nonNegative Boolean
If true, the result is non-negative.

Returns

Sequence
The sequence resulting from the sum.

Minimum(Sequence, Sequence, Boolean, ComputationSettings)

Computes minimum of two sequences.

public static Sequence Minimum(Sequence a, Sequence b, bool cutToOverlap, ComputationSettings settings)

Parameters

a Sequence
First operand.

b Sequence
Second operand.

cutToOverlap Boolean
If set, the minimum is performed over the overlapping part.

settings ComputationSettings

Returns

Sequence
The sequence resulting from the minimum.

Minimum(Sequence, Boolean, ComputationSettings)

Computes minimum of two sequences.

public Sequence Minimum(Sequence b, bool cutToOverlap, ComputationSettings settings)

Parameters

b Sequence
Second operand.

cutToOverlap Boolean
If set, the minimum is performed over the overlapping part.

settings ComputationSettings

Returns

Sequence
The sequence resulting from the minimum.

LowerEnvelope(Sequence, Sequence, ComputationSettings)

Computes the lower envelope of the pair of sequences given. O(n)O(n) complexity.

note

Used for minimum

public static List<Element> LowerEnvelope(Sequence a, Sequence b, ComputationSettings settings)

Parameters

a Sequence

b Sequence

settings ComputationSettings

Returns

List<Element>

Maximum(Sequence, Sequence, Boolean, ComputationSettings)

Computes maximum of two sequences, over their overlapping parts.

public static Sequence Maximum(Sequence a, Sequence b, bool cutToOverlap, ComputationSettings settings)

Parameters

a Sequence
First operand.

b Sequence
Second operand.

cutToOverlap Boolean
If set, the maximum is performed over the overlapping part.

settings ComputationSettings

Returns

Sequence
The sequence resulting from the maximum.

Maximum(Sequence, Boolean, ComputationSettings)

Computes maximum of two sequences, over their overlapping parts.

public Sequence Maximum(Sequence b, bool cutToOverlap, ComputationSettings settings)

Parameters

b Sequence
Second operand.

cutToOverlap Boolean
If set, the maximum is performed over the overlapping part.

settings ComputationSettings

Returns

Sequence
The sequence resulting from the maximum.

UpperEnvelope(Sequence, Sequence, ComputationSettings)

Computes the lower envelope of the pair of sequences given. O(n)O(n) complexity.

note

Used for maximum.

public static List<Element> UpperEnvelope(Sequence a, Sequence b, ComputationSettings settings)

Parameters

a Sequence

b Sequence

settings ComputationSettings

Returns

List<Element>

Convolution(Sequence, Sequence, ComputationSettings, Nullable<Rational>, Nullable<Rational>, Boolean, Boolean, Boolean)

Computes the convolution of two sequences, aba \otimes b.

note

Described in [BT08], Section 4.4 point 3

public static Sequence Convolution(Sequence f, Sequence g, ComputationSettings settings, Nullable<Rational> cutEnd, Nullable<Rational> cutCeiling, bool isEndIncluded, bool isCeilingIncluded, bool useIsomorphism)

Parameters

f Sequence

g Sequence

settings ComputationSettings

cutEnd Nullable<Rational>
If defined, computation of convolutions beyond the given limit will be omitted.

cutCeiling Nullable<Rational>
If defined, computation of convolutions beyond the given limit will be omitted.

isEndIncluded Boolean

isCeilingIncluded Boolean

useIsomorphism Boolean

Returns

Sequence
The result of the convolution.

Convolution(Sequence, ComputationSettings, Nullable<Rational>)

Computes the convolution of two sequences, fgf \otimes g.

note

Described in [BT08], Section 4.4 point 3

public Sequence Convolution(Sequence sequence, ComputationSettings settings, Nullable<Rational> cutEnd)

Parameters

sequence Sequence

settings ComputationSettings

cutEnd Nullable<Rational>
If defined, computation of convolutions beyond the given limit will be omitted.

Returns

Sequence
The result of the convolution.

EstimateConvolution(Sequence, Sequence, ComputationSettings, Nullable<Rational>, Nullable<Rational>, Boolean)

Computes the number of elementary convolutions involved in computing the convolution of the two sequences, avoiding allocations as much as possible.

public static long EstimateConvolution(Sequence a, Sequence b, ComputationSettings settings, Nullable<Rational> cutEnd, Nullable<Rational> cutCeiling, bool countElements)

Parameters

a Sequence

b Sequence

settings ComputationSettings

cutEnd Nullable<Rational>
If defined, computation of convolutions beyond the given limit will be omitted.

cutCeiling Nullable<Rational>
If defined, computation of convolutions beyond the given limit will be omitted.

countElements Boolean

If true, instead of counting only how many convolutions are done, it counts how many convolution elements are produced.

Returns

Int64
The number of elementary convolutions involved in computing the result of the convolution, or the number of elements resulting from these convolutions if is true.

Deconvolution(Sequence, Sequence, Nullable<Rational>, Nullable<Rational>, ComputationSettings)

Computes the deconvolution of two sequences, aba \oslash b.

note

Described in [BT08], Section 4.5

public static Sequence Deconvolution(Sequence a, Sequence b, Nullable<Rational> cutStart, Nullable<Rational> cutEnd, ComputationSettings settings)

Parameters

a Sequence

b Sequence

cutStart Nullable<Rational>
If not null, element deconvolutions whose result ends strictly before this time are skipped.

cutEnd Nullable<Rational>
If not null, the result is cut or filled with ++\infty up to this time, endpoint excluded.

settings ComputationSettings

Returns

Sequence
The result of the deconvolution.

Deconvolution(Sequence, Nullable<Rational>, Nullable<Rational>, ComputationSettings)

Computes the deconvolution of two sequences, fgf \oslash g.

note

Described in [BT08], Section 4.5

public Sequence Deconvolution(Sequence sequence, Nullable<Rational> cutStart, Nullable<Rational> cutEnd, ComputationSettings settings)

Parameters

sequence Sequence

cutStart Nullable<Rational>
If not null, element deconvolutions whose result ends strictly before this time are skipped.

cutEnd Nullable<Rational>
If not null, the result is cut or filled with ++\infty up to this time, endpoint excluded.

settings ComputationSettings

Returns

Sequence
The result of the deconvolution.

MaxPlusConvolution(Sequence, Sequence, ComputationSettings, Nullable<Rational>, Nullable<Rational>, Boolean, Boolean, Boolean)

Computes the max-plus convolution of two sequences.

note

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

public static Sequence MaxPlusConvolution(Sequence f, Sequence g, ComputationSettings settings, Nullable<Rational> cutEnd, Nullable<Rational> cutCeiling, bool isEndIncluded, bool isCeilingIncluded, bool useIsomorphism)

Parameters

f Sequence

g Sequence

settings ComputationSettings

cutEnd Nullable<Rational>
If defined, computation of convolutions beyond the given limit will be omitted.

cutCeiling Nullable<Rational>
If defined, computation of convolutions beyond the given limit will be omitted.

isEndIncluded Boolean

isCeilingIncluded Boolean

useIsomorphism Boolean

Returns

Sequence
The result of the convolution.

MaxPlusConvolution(Sequence, ComputationSettings, Nullable<Rational>)

Computes the max-plus convolution of two sequences.

note

Max-plus operators are defined through min-plus operators, see [DNC18] Section 2.4

public Sequence MaxPlusConvolution(Sequence sequence, ComputationSettings settings, Nullable<Rational> cutEnd)

Parameters

sequence Sequence

settings ComputationSettings

cutEnd Nullable<Rational>
If defined, computation of convolutions beyond the given limit will be omitted.

Returns

Sequence
The result of the convolution.

MaxPlusDeconvolution(Sequence, Sequence, ComputationSettings)

Computes the max-plus convolution of two sequences.

note

Max-plus operators are defined through min-plus operators, see [DNC18] Section 2.4

public static Sequence MaxPlusDeconvolution(Sequence a, Sequence b, ComputationSettings settings)

Parameters

a Sequence

b Sequence

settings ComputationSettings

Returns

Sequence
The result of the max-plus deconvolution.

MaxPlusDeconvolution(Sequence, ComputationSettings)

Computes the max-plus convolution of two sequences.

note

Max-plus operators are defined through min-plus operators, see [DNC18] Section 2.4

public Sequence MaxPlusDeconvolution(Sequence sequence, ComputationSettings settings)

Parameters

sequence Sequence

settings ComputationSettings

Returns

Sequence
The result of the max-plus deconvolution.

Composition(Sequence, Sequence)

Compute the composition f(g(t))f(g(t)), over a limited interval.

note

Algorithmic properties discussed in [ZNS23b].

public static Sequence Composition(Sequence f, Sequence g)

Parameters

f Sequence
Outer function, defined in [g(a),g(b)[[g(a), g(b^-)[ or [g(a),g(b)][g(a), g(b^-)].

g Sequence
Inner function, non-negative and non-decreasing, defined in [a,b[[a, b[.

Returns

Sequence
The result of the composition.

Exceptions

ArgumentException
If the operands are not defined as expected.

Composition(Sequence)

Compute the composition of this sequence, ff, and gg, i.e. f(g(t))f(g(t)), over a limited interval. This sequence must be defined in [g(a),g(b)[[g(a), g(b^-)[ or [g(a),g(b)][g(a), g(b^-)].

public Sequence Composition(Sequence g)

Parameters

g Sequence
Inner function, non-negative and non-decreasing, defined in [a,b[[a, b[.

Returns

Sequence
The result of the composition.

Exceptions

ArgumentException
If the operands are not defined as expected.