ch.obermuhlner.math.big.internal.PowerIterator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of big-math Show documentation
Show all versions of big-math Show documentation
Math functions for BigDecimal.
package ch.obermuhlner.math.big.internal;
import java.math.BigDecimal;
/**
* Iterator over the powers of a value x.
*
* This API allows to efficiently calculate the various powers of x in a taylor series by storing intermediate results.
* For example xn can be calculated using one multiplication by storing the previously calculated xn-1 and x.
*
* {@link #getCurrentPower()} will be called first to retrieve the initial value.
*
* For later iterations {@link #calculateNextPower()} will be called before {@link #getCurrentPower()}.
*/
public interface PowerIterator {
/**
* Returns the current power.
*
* @return the current power.
*/
BigDecimal getCurrentPower();
/**
* Calculates the next power.
*/
void calculateNextPower();
}