|
finMath lib documentation | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.finmath.time.TimeDiscretization
public class TimeDiscretization
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.
Nested Class Summary | |
---|---|
static class |
TimeDiscretization.ShortPeriodLocation
|
Constructor Summary | |
---|---|
TimeDiscretization(ArrayList<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(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; |
Method Summary | |
---|---|
ArrayList<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. min(i : timeDiscretization[i] ≥ time where timeDiscretization[i] ≤ timeDiscretization[j]). |
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. max(i : timeDiscretization[i] ≤ time where timeDiscretization[i] ≤ timeDiscretization[j]). |
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. |
Iterator<Double> |
iterator()
|
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public TimeDiscretization(double... times)
times
- Given array or arguments list of discretization points.public TimeDiscretization(Double[] times)
times
- Given array or arguments list of discretization pointspublic TimeDiscretization(ArrayList<Double> timeDiscretization)
timeDiscretization
- Given ArrayList of discretization pointspublic TimeDiscretization(double initial, int numberOfTimeSteps, double deltaT)
for(i=0; i ≤ timeSteps; i++) timeDiscretization[i] = initial + i * deltaT;
initial
- First discretization point.numberOfTimeSteps
- Number of time steps.deltaT
- Time step size.public TimeDiscretization(double initial, double last, double deltaT, TimeDiscretization.ShortPeriodLocation shortPeriodLocation)
initial
- First discretization point.last
- Last time steps.deltaT
- Time step size.shortPeriodLocation
- Placement of the stub period.Method Detail |
---|
public int getNumberOfTimes()
getNumberOfTimes
in interface TimeDiscretizationInterface
public int getNumberOfTimeSteps()
getNumberOfTimeSteps
in interface TimeDiscretizationInterface
public double getTime(int timeIndex)
TimeDiscretizationInterface
getTime
in interface TimeDiscretizationInterface
timeIndex
- Time index
public double getTimeStep(int timeIndex)
TimeDiscretizationInterface
getTimeStep
in interface TimeDiscretizationInterface
timeIndex
- Time index
public int getTimeIndex(double time)
TimeDiscretizationInterface
getTimeIndex
in interface TimeDiscretizationInterface
time
- The time.
public int getTimeIndexNearestLessOrEqual(double time)
TimeDiscretizationInterface
getTimeIndexNearestLessOrEqual
in interface TimeDiscretizationInterface
time
- Given time.
public int getTimeIndexNearestGreaterOrEqual(double time)
TimeDiscretizationInterface
getTimeIndexNearestGreaterOrEqual
in interface TimeDiscretizationInterface
time
- Given time.
public double[] getAsDoubleArray()
TimeDiscretizationInterface
double[]
.
getAsDoubleArray
in interface TimeDiscretizationInterface
double[]
public ArrayList<Double> getAsArrayList()
TimeDiscretizationInterface
ArrayList<Double>
.
Note that this method is costly in terms of performance.
getAsArrayList
in interface TimeDiscretizationInterface
ArrayList<Double>
public TimeDiscretizationInterface getTimeShiftedTimeDiscretization(double timeShift)
TimeDiscretizationInterface
getTimeShiftedTimeDiscretization
in interface TimeDiscretizationInterface
timeShift
- A time shift applied to all discretization points.
public Iterator<Double> iterator()
iterator
in interface Iterable<Double>
public String toString()
toString
in class Object
|
Copyright © 2014 Christian P. Fries. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |