public RandomVariableInterface accrue(RandomVariableInterface rate, double periodLength) {
		// Set time of this random variable to maximum of time with respect to which measurability is known.
		double newTime = Math.max(time, rate.getFiltrationTime());

		if(isDeterministic() && rate.isDeterministic()) {
			double newValueIfNonStochastic = valueIfNonStochastic * (1 + rate.get(0) * periodLength);
			return new RandomVariableLowMemory(newTime, newValueIfNonStochastic);
		}
		else if(isDeterministic() && !rate.isDeterministic()) {
			double[] rateRealizations = rate.getRealizations();
			double[] newRealizations = new double[Math.max(size(), rate.size())];
			for(int i=0; i<newRealizations.length; i++) {
				newRealizations[i]		 = valueIfNonStochastic * (1 + rateRealizations[i] * periodLength);
			}
			return new RandomVariableLowMemory(newTime, newRealizations);
		}
		else if(!isDeterministic() && rate.isDeterministic()) {
			double rateValue = rate.get(0);
			double[] newRealizations = new double[Math.max(size(), rate.size())];
			for(int i=0; i<newRealizations.length; i++) {
				newRealizations[i]		 = realizations[i] * (1 + rateValue * periodLength);
			}
			return new RandomVariableLowMemory(newTime, newRealizations);
		}
		else {
			double[] rateRealizations = rate.getRealizations();
			double[] newRealizations = new double[Math.max(size(), rate.size())];
			for(int i=0; i<newRealizations.length; i++) {
				newRealizations[i]		 = realizations[i] * (1 + rateRealizations[i] * periodLength);
			}
			return new RandomVariableLowMemory(newTime, newRealizations);
		}
	}
public RandomVariableInterface accrue ( RandomVariableInterface rate , double periodLength ) { double newTime = Math . max ( time , rate . getFiltrationTime ( ) ) ; if ( isDeterministic ( ) && rate . isDeterministic ( ) ) { double newValueIfNonStochastic = valueIfNonStochastic * ( 1 + rate . get ( 0 ) * periodLength ) ; return new RandomVariableLowMemory ( newTime , newValueIfNonStochastic ) ; } else if ( isDeterministic ( ) && ! rate . isDeterministic ( ) ) { double [ ] rateRealizations = rate . getRealizations ( ) ; double [ ] newRealizations = new double [ Math . max ( size ( ) , rate . size ( ) ) ] ; for ( int i = 0 ; i < newRealizations . length ; i ++ ) { newRealizations [ i ] = valueIfNonStochastic * ( 1 + rateRealizations [ i ] * periodLength ) ; } return new RandomVariableLowMemory ( newTime , newRealizations ) ; } else if ( ! isDeterministic ( ) && rate . isDeterministic ( ) ) { double rateValue = rate . get ( 0 ) ; double [ ] newRealizations = new double [ Math . max ( size ( ) , rate . size ( ) ) ] ; for ( int i = 0 ; i < newRealizations . length ; i ++ ) { newRealizations [ i ] = realizations [ i ] * ( 1 + rateValue * periodLength ) ; } return new RandomVariableLowMemory ( newTime , newRealizations ) ; } else { double [ ] rateRealizations = rate . getRealizations ( ) ; double [ ] newRealizations = new double [ Math . max ( size ( ) , rate . size ( ) ) ] ; for ( int i = 0 ; i < newRealizations . length ; i ++ ) { newRealizations [ i ] = realizations [ i ] * ( 1 + rateRealizations [ i ] * periodLength ) ; } return new RandomVariableLowMemory ( newTime , newRealizations ) ; } }
/* (non-Javadoc)
@see net.finmath.stochastic.RandomVariableInterface#accrue(net.finmath.stochastic.RandomVariableInterface, double)