Class Concatenation

java.lang.Object
org.djutils.math.functions.Concatenation
All Implemented Interfaces:
Comparable<MathFunction>, Function<Double,Double>, MathFunction

public class Concatenation extends Object implements MathFunction
Concatenate FunctionInterface objects

Copyright (c) 2024-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.

Author:
Alexander Verbraeck, Peter Knoppers, Wouter Schakel
  • Constructor Details

    • Concatenation

      @SafeVarargs public Concatenation(Interval<MathFunction>... intervals)
      Construct the concatenation of one or more MathFunction objects.
      Parameters:
      intervals - the functions and the domains over which they should be active
    • Concatenation

      public Concatenation(SortedSet<Interval<MathFunction>> set)
      Construct a Concatenation from a sorted set of Interval<MathFunction>.
      Parameters:
      set - the sorted set of Interval with MathFunction payload
  • Method Details

    • apply

      public Double apply(Double x)
      Specified by:
      apply in interface Function<Double,Double>
    • getDerivative

      public Concatenation getDerivative()
      Description copied from interface: MathFunction
      Returns the derivative of the data with respect to fractional length.
      Specified by:
      getDerivative in interface MathFunction
      Returns:
      derivative of this MathFunction
    • scaleBy

      public MathFunction scaleBy(double factor)
      Description copied from interface: MathFunction
      Incorporate a multiplication factor to this MathFunction.
      Specified by:
      scaleBy in interface MathFunction
      Parameters:
      factor - the factor to incorporate
      Returns:
      a new MathFunction that yields the same result as the original function multiplied by the factor
    • sortPriority

      public int sortPriority()
      Description copied from interface: MathFunction
      Sorting priority of this type of MathFunction (low values shall sort before higher).
      Specified by:
      sortPriority in interface MathFunction
      Returns:
      sorting priority of this type of MathFunction
    • continuousPiecewiseLinear

      public static Concatenation continuousPiecewiseLinear(SortedMap<Double,Double> map)
      Construct a concatenation that is piecewise linear through a given set of points.
      Parameters:
      map - mapping from domain to value at the inflection points
      Returns:
      new Concatenation that is piecewise linear and connects the given points
      Throws:
      IllegalArgumentException - when map contains fewer than 2 entries
    • continuousPiecewiseLinear

      public static Concatenation continuousPiecewiseLinear(double... arguments)
      Construct a concatenation that is piecewise linear through a given set of input-output pairs.
      Parameters:
      arguments - the input-output pairs; these specify the inflection points
      Returns:
      new Concatenation that is piecewise linear and connects the given points
      Throws:
      IllegalArgumentException - when arguments contains an odd number of entries, or fewer than 2 domain values, or duplicate domain values with differing function values
    • compareWithinSubType

      public int compareWithinSubType(MathFunction other)
      Description copied from interface: MathFunction
      Determine sorting order among instances of a particular sub type of MathFunction. The sorting order should sort MathFunctions that may be combined next to one another. Because MathFunctions are also used in SortedSets, this comparator may return 0 if and only if this and other are entirely equal!
      Specified by:
      compareWithinSubType in interface MathFunction
      Parameters:
      other - the other MathFunction that must be of the same type
      Returns:
      int; < 0 when this sorts before other; > 0 when this sorts after other; 0 when this and other are identical
    • discontinuities

      public Iterator<Interval<Concatenation.Discontinuity>> discontinuities(Interval<?> interval)
      Report all non-continuities and all points where this function is non differentiable, or non-evaluable. If another MathFunction is chained, the transformation of that function, nor any discontinuities of that MathFunction are taken into account as there is (currently) no way to figure out what values of the domain of the chained function result in values that correspond to the discontinuities of this function.
      Parameters:
      interval - the interval on which to report the discontinuities
      Returns:
      iterator that will generate all discontinuities in the interval
    • getKnotReport

      public KnotReport getKnotReport(Interval<?> interval)
      Description copied from interface: MathFunction
      Report what is known about knots of this MathFunction in some Interval. The report does not take chained functions into account.
      Specified by:
      getKnotReport in interface MathFunction
      Parameters:
      interval - the Interval on which knowledge of knots is requested
      Returns:
      summary of what is known about knots in the Interval
    • getKnots

      public SortedSet<Double> getKnots(Interval<?> interval)
      Description copied from interface: MathFunction
      Report all knots of this MathFunction in some Interval. Throws IllegalStateException when the number of knots in the Interval is not known, or infinite.
      Specified by:
      getKnots in interface MathFunction
      Parameters:
      interval - the Interval over which the knots must be reported
      Returns:
      all the knots of this MathFunction in the requested Interval
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object