Documentation of 'net.finmath.time.TimeDiscretization' Java class
TimeDiscretization
net.finmath.time

Class TimeDiscretization

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<java.lang.Double>, TimeDiscretizationInterface
    Direct Known Subclasses:
    Tenor


    public class TimeDiscretization
    extends java.lang.Object
    implements java.io.Serializable, TimeDiscretizationInterface
    This class represents a set of discrete points in time.
    It handles the mapping from time indices to time points and back. It uses a time tick size ("quantum") of 1.0 / (365.0 * 24.0) (which corresponds to one hour if 1.0 is a non-leap-year): Times are rounded to the nearest multiple of 1.0 / (365.0 * 24.0). Objects of this class are immutable.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      TimeDiscretization(java.util.ArrayList<java.lang.Double> timeDiscretization)
      Constructs a time discretization from a given ArrayList of Doubles.
      TimeDiscretization(double... times)
      Constructs a time discretization from a given set of doubles.
      TimeDiscretization(java.lang.Double[] times)
      Constructs a time discretization from a given set of Doubles.
      TimeDiscretization(double initial, double last, double deltaT, TimeDiscretization.ShortPeriodLocation shortPeriodLocation)
      Constructs an equi-distant time discretization with stub periods at start or end.
      TimeDiscretization(double initial, int numberOfTimeSteps, double deltaT)
      Constructs an equi-distant time discretization with points timeDiscretization[i] being for(i=0; i ≤ timeSteps; i++) timeDiscretization[i] = initial + i * deltaT;
      TimeDiscretization(java.util.Set<java.lang.Double> times)
      Constructs a time discretization from a given Set of Doubles.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      boolean equals(java.lang.Object obj) 
      java.util.ArrayList<java.lang.Double> getAsArrayList()
      Return a clone of this time discretization as ArrayList<Double>.
      double[] getAsDoubleArray()
      Return a clone of this time discretization as double[].
      int getNumberOfTimes() 
      int getNumberOfTimeSteps() 
      double getTime(int timeIndex)
      Returns the time for the given time index.
      int getTimeIndex(double time)
      Returns the time index for the given time.
      int getTimeIndexNearestGreaterOrEqual(double time)
      Returns the time index for the time in the time discretization which is the nearest to the given time, being greater or equal (i.e.
      int getTimeIndexNearestLessOrEqual(double time)
      Returns the time index for the time in the time discretization which is the nearest to the given time, being less or equal (i.e.
      TimeDiscretizationInterface getTimeShiftedTimeDiscretization(double timeShift)
      Return a new time discretization where all time points have been shifted by a given time shift.
      double getTimeStep(int timeIndex)
      Returns the time step from the given time index to the next one.
      int hashCode() 
      java.util.Iterator<java.lang.Double> iterator() 
      java.lang.String toString() 
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • TimeDiscretization

        public TimeDiscretization(double... times)
        Constructs a time discretization from a given set of doubles. The given array does not need to be sorted.
        Parameters:
        times - Given array or arguments list of discretization points.
      • TimeDiscretization

        public TimeDiscretization(java.lang.Double[] times)
        Constructs a time discretization from a given set of Doubles. The given array does not need to be sorted.
        Parameters:
        times - Given array or arguments list of discretization points.
      • TimeDiscretization

        public TimeDiscretization(java.util.ArrayList<java.lang.Double> timeDiscretization)
        Constructs a time discretization from a given ArrayList of Doubles. The given list does not need to be sorted.
        Parameters:
        timeDiscretization - Given ArrayList of discretization points
      • TimeDiscretization

        public TimeDiscretization(java.util.Set<java.lang.Double> times)
        Constructs a time discretization from a given Set of Doubles.
        Parameters:
        times - Given Set of discretization points
      • TimeDiscretization

        public TimeDiscretization(double initial,
                                  int numberOfTimeSteps,
                                  double deltaT)
        Constructs an equi-distant time discretization with points timeDiscretization[i] being for(i=0; i ≤ timeSteps; i++) timeDiscretization[i] = initial + i * deltaT;
        Parameters:
        initial - First discretization point.
        numberOfTimeSteps - Number of time steps.
        deltaT - Time step size.
      • TimeDiscretization

        public TimeDiscretization(double initial,
                                  double last,
                                  double deltaT,
                                  TimeDiscretization.ShortPeriodLocation shortPeriodLocation)
        Constructs an equi-distant time discretization with stub periods at start or end.
        Parameters:
        initial - First discretization point.
        last - Last time steps.
        deltaT - Time step size.
        shortPeriodLocation - Placement of the stub period.
    • Method Detail

      • getTime

        public double getTime(int timeIndex)
        Description copied from interface: TimeDiscretizationInterface
        Returns the time for the given time index.
        Specified by:
        getTime in interface TimeDiscretizationInterface
        Parameters:
        timeIndex - Time index
        Returns:
        Returns the time for a given time index.
      • getTimeIndex

        public int getTimeIndex(double time)
        Description copied from interface: TimeDiscretizationInterface
        Returns the time index for the given time. If the given time is not in the time discretization the method returns a negative number being (-insertionPoint-1).
        Specified by:
        getTimeIndex in interface TimeDiscretizationInterface
        Parameters:
        time - The time.
        Returns:
        Returns the time index for a given time.
      • getTimeIndexNearestLessOrEqual

        public int getTimeIndexNearestLessOrEqual(double time)
        Description copied from interface: TimeDiscretizationInterface
        Returns the time index for the time in the time discretization which is the nearest to the given time, being less or equal (i.e. max(i : timeDiscretization[i] ≤ time where timeDiscretization[i] ≤ timeDiscretization[j]).
        Specified by:
        getTimeIndexNearestLessOrEqual in interface TimeDiscretizationInterface
        Parameters:
        time - Given time.
        Returns:
        Returns a time index
      • getTimeIndexNearestGreaterOrEqual

        public int getTimeIndexNearestGreaterOrEqual(double time)
        Description copied from interface: TimeDiscretizationInterface
        Returns the time index for the time in the time discretization which is the nearest to the given time, being greater or equal (i.e. min(i : timeDiscretization[i] ≥ time where timeDiscretization[i] ≤ timeDiscretization[j]).
        Specified by:
        getTimeIndexNearestGreaterOrEqual in interface TimeDiscretizationInterface
        Parameters:
        time - Given time.
        Returns:
        Returns a time index
      • getAsArrayList

        public java.util.ArrayList<java.lang.Double> getAsArrayList()
        Description copied from interface: TimeDiscretizationInterface
        Return a clone of this time discretization as ArrayList<Double>. Note that this method is costly in terms of performance.
        Specified by:
        getAsArrayList in interface TimeDiscretizationInterface
        Returns:
        The time discretization as ArrayList<Double>
      • iterator

        public java.util.Iterator<java.lang.Double> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<java.lang.Double>
      • toString

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

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

        public boolean equals(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object

DataMelt 3.0 © DataMelt by jWork.ORG

Ads help maintain this website.