package umontreal.iro.lecuyer.functions;
/**
* Represents a function computing
* the square root of another function
* f (x).
*
*/
public class SqrtMathFunction implements MathFunction {
private MathFunction func;
/**
* Computes and returns the square
* root of the function func.
*
* @param func the function to compute square root for.
*
*
*/
public SqrtMathFunction (MathFunction func) {
super ();
if (func == null)
throw new NullPointerException();
this.func = func;
}
/**
* Returns the function associated with
* this object.
*
* @return the associated function.
*
*/
public MathFunction getFunction() {
return func;
}
public double evaluate (double x) {
return Math.sqrt (func.evaluate (x));
}
}
Ads help maintain this website.