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

com.graphbuilder.math.func.CombinFunction 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;

import com.graphbuilder.math.PascalsTriangle;

/**
The combination function.

@see com.graphbuilder.math.PascalsTriangle
*/
public class CombinFunction implements Function {

	public CombinFunction() {}

	/**
	Returns the number of ways r items can be chosen from n items.  The value of
	n is (int) d[0] and the value of r is (int) d[1].
	*/
	public double of(double[] d, int numParam) {
		int n = (int) d[0];
		int r = (int) d[1];
		return PascalsTriangle.nCr(n, r);
	}

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

	public String toString() {
		return "combin(n, r)";
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy