root / trunk / libraries / libTopology / src / com / graphbuilder / math / func / SqrtFunction.java @ 22872
History | View | Annotate | Download (551 Bytes)
1 |
package com.graphbuilder.math.func; |
---|---|
2 |
|
3 |
/**
|
4 |
The square root function.
|
5 |
|
6 |
@see java.lang.Math#sqrt(double)
|
7 |
*/
|
8 |
public class SqrtFunction implements Function { |
9 |
|
10 |
public SqrtFunction() {}
|
11 |
|
12 |
/**
|
13 |
Returns the square root of the value at index location 0.
|
14 |
*/
|
15 |
public double of(double[] d, int numParam) { |
16 |
return java.lang.Math.sqrt(d[0]); |
17 |
} |
18 |
|
19 |
/**
|
20 |
Returns true only for 1 parameter, false otherwise.
|
21 |
*/
|
22 |
public boolean acceptNumParam(int numParam) { |
23 |
return numParam == 1; |
24 |
} |
25 |
|
26 |
public String toString() { |
27 |
return "sqrt(x)"; |
28 |
} |
29 |
} |