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

nl.tno.bim.nmd.scaling.NmdLogarithmicScaler Maven / Gradle / Ivy

The newest version!
package nl.tno.bim.nmd.scaling;

import java.util.InputMismatchException;

public class NmdLogarithmicScaler extends NmdBaseScaler implements NmdScaler {

	public NmdLogarithmicScaler(String scaleUnit, Double[] coefficients, Double[] bounds, Double[] currentValues) throws InputMismatchException {
		super(scaleUnit, coefficients, bounds, currentValues);

		if (currentValues[0] == 1 || currentValues[1] == 1) {
			throw new InputMismatchException(
					"Cannot have a unit value for a logarithmic scaler as it creates a division by 0 error on scaling");
		}
	}

	@Override
	protected Double calculate(Double x) {
		if (x == 0.0) {
			return Double.NaN;
		}
		return coefficients[0] * Math.log(x) + coefficients[2];
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy