All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.finmath.time.TimeDiscretizationInterface Maven / Gradle / Ivy

Go to download

finmath lib is a Mathematical Finance Library in Java. It provides algorithms and methodologies related to mathematical finance.

There is a newer version: 6.0.19
Show newest version
/*
 * (c) Copyright Christian P. Fries, Germany. All rights reserved. Contact: [email protected].
 *
 * Created on 23.11.2012
 */
package net.finmath.time;

import java.util.ArrayList;

/**
 * @author Christian Fries
 */
public interface TimeDiscretizationInterface extends Iterable {

	/**
	 * @return Returns the number of time discretization points.
	 */
    int getNumberOfTimes();

	/**
	 * @return Returns the number of time steps (= number of discretization points-1).
	 */
    int getNumberOfTimeSteps();

	/**
	 * Returns the time for the given time index.
	 * 
	 * @param timeIndex Time index
	 * @return Returns the time for a given time index.
	 */
    double getTime(int timeIndex);

	/**
	 * Returns the time step from the given time index to the next one.
	 * 
	 * @param timeIndex Time index
	 * @return Returns the time step
	 */
    double getTimeStep(int timeIndex);

	/**
	 * 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).
	 * 
	 * @param time The time.
	 * @return Returns the time index for a given time.
	 */
    int getTimeIndex(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]).
	 * 
	 * @param time Given time.
	 * @return Returns a time index
	 */
    int getTimeIndexNearestLessOrEqual(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]).
	 * 
	 * @param time Given time.
	 * @return Returns a time index
	 */
    int getTimeIndexNearestGreaterOrEqual(double time);

	/**
	 * Return a clone of this time discretization as double[].
	 * @return The time discretization as double[]
	 */
    double[] getAsDoubleArray();

	/**
	 * Return a clone of this time discretization as ArrayList<Double>.
	 * Note that this method is costly in terms of performance.
	 * 
	 * @return The time discretization as ArrayList<Double>
	 */
    ArrayList getAsArrayList();

    
    /**
     * Return a new time discretization where all time points have been shifted by
     * a given time shift.
     * 
     * @param timeShift A time shift applied to all discretization points.
     * @return A new time discretization where all time points have been shifted by the given time shift.
     */
    TimeDiscretizationInterface getTimeShiftedTimeDiscretization(double timeShift);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy