view src/samer/maths/Function.java @ 8:5e3cbbf173aa tip

Reorganise some more
author samer
date Fri, 05 Apr 2019 22:41:58 +0100
parents bf79fb79ee13
children
line wrap: on
line source
/*
 *	Function.java	
 *
 *	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.maths;

/**
  *		Defines a real-valued function of a single real variable.
  *		
  */

public abstract class Function
{
	public abstract double apply(double in);

	/** apply function to each element of in, placing result in out */
	public void apply(double [] in, double [] out) {
		for (int i=0; i<in.length; i++) out[i]=apply(in[i]);
	}

	/** apply function in place, to each element of inout */
	public void apply(double [] inout) {
		for (int i=0; i<inout.length; i++) inout[i]=apply(inout[i]);
	}

	public void dispose() {}

	public Function inverse() { throw new Error("no inverse"); }
	public Function derivative() { throw new Error("no derivative"); }
	public abstract String format(String arg);
}