All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.graphbuilder.math.func.LogFunction Maven / Gradle / Ivy

Go to download

Implementation of various mathematical curves that define themselves over a set of control points. The API is written in Java. The curves supported are: Bezier, B-Spline, Cardinal Spline, Catmull-Rom Spline, Lagrange, Natural Cubic Spline, and NURBS.

There is a newer version: 1.08
Show newest version
package com.graphbuilder.math.func;

/**
The log function.
*/
public class LogFunction implements Function {

	public LogFunction() {}

	/**
	If the number of parameters specified is 1, then the log base 10 is taken of the
	value at index location 0.  If the number of parameters specified is 2, then the
	base value is at index location 1.
	*/
	public double of(double[] d, int numParam) {
		if (numParam == 1) {
			return java.lang.Math.log(d[0]) / java.lang.Math.log(10);
		}
		return java.lang.Math.log(d[0]) / java.lang.Math.log(d[1]);
	}

	/**
	Returns true only for 1 or 2 parameters, false otherwise.
	*/
	public boolean acceptNumParam(int numParam) {
		return numParam == 1 || numParam == 2;
	}

	public String toString() {
		return "log(x):log(x, y)";
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy