MCPcopy Index your code
hub / github.com/Aghajari/MathParser / LogFunction

Class LogFunction

MathParser/src/com/aghajari/math/custom/LogFunction.java:16–54  ·  view source on GitHub ↗

A MathFunction for Math#log(double) log2(x) log3(x) ... log[BASE](x)

Source from the content-addressed store, hash-verified

14 * log[BASE](x)
15 */
16public class LogFunction implements MathFunction {
17 int base;
18
19 @Override
20 public String name() {
21 return "log";
22 }
23
24 @Override
25 public boolean compareNames(String name) {
26 if (name.trim().toLowerCase().startsWith("log")) {
27 name = name.substring(3);
28 if (Utils.isUnsignedInteger(name)) {
29 base = Integer.parseInt(name);
30 return true;
31 }
32 }
33 return false;
34 }
35
36 @Override
37 public double calculate(Object... parameters) {
38 return Functions.log((double) parameters[0], base);
39 }
40
41 @Override
42 public int getParameterCount() {
43 return 1;
44 }
45
46 @Override
47 public boolean isSpecialParameter(int index) {
48 return false;
49 }
50
51 @Override
52 public void attachToParser(MathParser parser) {
53 }
54}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected