Mercurial > hg > jslab
view src/samer/maths/Function.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
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); }