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

mikera.vectorz.ops.SoftPlus Maven / Gradle / Ivy

Go to download

Fast double-precision vector and matrix maths library for Java, supporting N-dimensional numeric arrays.

There is a newer version: 0.67.0
Show newest version
package mikera.vectorz.ops;

import java.io.ObjectStreamException;

import mikera.vectorz.Op;


public final class SoftPlus extends ABoundedOp {
	
	public static final SoftPlus INSTANCE=new SoftPlus();
	
	private static double softplus (double x) {
		if (x>100) return x;
		if (x<-100) return 0.0;
		return Math.log(1.0+Math.exp(x));
	}
	
	private static double inverseSoftplus (double y) {
		return Math.log(Math.exp(y)-1.0);
	}
	
	@Override
	public double apply(double x) {
		return softplus(x);
	}
	
	@Override
	public double applyInverse(double y) {
		return inverseSoftplus(y);
	}
	
	@Override
	public void applyTo(double[] data, int start,int length) {
		for (int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy