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

com.graphbuilder.math.func.MaxFunction 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 max function.
*/
public class MaxFunction implements Function {

	public MaxFunction() {}

	/**
	Returns the maximum value of the specified inputs.  Double.MAX_VALUE is returned for 0 parameters.
	*/
	public double of(double[] d, int numParam) {
		if (numParam == 0)
			return Double.MAX_VALUE;

		double max = -Double.MAX_VALUE;
		for (int i = 0; i < numParam; i++)
			if (d[i] > max)
				max = d[i];
		return max;
	}

	/**
	Returns true for 0 or more parameters, false otherwise.
	*/
	public boolean acceptNumParam(int numParam) {
		return numParam >= 0;
	}

	public String toString() {
		return "max(x1, x2, ..., xn)";
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy