view src/samer/functions/LogGenExp2.java @ 5:b67a33c44de7

Remove some crap, etc
author samer
date Fri, 05 Apr 2019 21:34:25 +0100
parents bf79fb79ee13
children
line wrap: on
line source
/*
 *	Copyright (c) 2000, Samer Abdallah, King's College London.
 *	All rights reserved.
 *
 *	This software is provided AS iS and WITHOUT ANY WARRANTY; 
 *	without even the implied warranty of MERCHANTABILITY or 
 *	FITNESS FOR A PARTICULAR PURPOSE.
 */

package samer.functions;
import  samer.maths.*;
import  samer.core.types.*;

/** This version has a quadratic phase, a linear phase,
and finally, a power law phase. */

public class LogGenExp2 extends Function implements DoubleModel
{
	private double	alpha=1;
	private double e2=1e-6;	// quadratic scale
	private double e1=1e-1;	// linear scale
   
	public double get() { return alpha; }
	public void set(double t) { alpha=t; }
	public void dispose() { }

	public DoubleModel getAlphaModel() { return this; }
	public DoubleModel getQuadraticScale() { 
		return new DoubleModel() {
			public double get() { return e2; }
			public void set(double t) { e2=t; }
		};
   }
   
	public DoubleModel getLinearScale() { 
		return new DoubleModel() {
			public double get() { return e1; }
			public void set(double t) { e1=t; }
		};
	}
		
	public double apply(double t) {
		t=Math.abs(t);      
		return (t*t)/(e2 + t*(e1 + Math.pow(t,1-alpha)));
	}
	public String format(String arg) { return "|"+arg+"|^a"; }

	public Function derivative() {
		return new Function () {
         public double apply(double t) {
         	double at=Math.abs(t);
            double q=Math.pow(at,2-alpha);
            double r=e2+e1*at+q;
            return t*(2*e2+e1*at+alpha*q)/(r*r);
			}
			public String format(String arg) { return "a "+arg+"^(a-1)"; }
		};
	}
}