annotate 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
rev   line source
samer@0 1 /*
samer@0 2 * Function.java
samer@0 3 *
samer@0 4 * Copyright (c) 2000, Samer Abdallah, King's College London.
samer@0 5 * All rights reserved.
samer@0 6 *
samer@0 7 * This software is provided AS iS and WITHOUT ANY WARRANTY;
samer@0 8 * without even the implied warranty of MERCHANTABILITY or
samer@0 9 * FITNESS FOR A PARTICULAR PURPOSE.
samer@0 10 */
samer@0 11
samer@0 12 package samer.maths;
samer@0 13
samer@0 14 /**
samer@0 15 * Defines a real-valued function of a single real variable.
samer@0 16 *
samer@0 17 */
samer@0 18
samer@0 19 public abstract class Function
samer@0 20 {
samer@0 21 public abstract double apply(double in);
samer@0 22
samer@0 23 /** apply function to each element of in, placing result in out */
samer@0 24 public void apply(double [] in, double [] out) {
samer@0 25 for (int i=0; i<in.length; i++) out[i]=apply(in[i]);
samer@0 26 }
samer@0 27
samer@0 28 /** apply function in place, to each element of inout */
samer@0 29 public void apply(double [] inout) {
samer@0 30 for (int i=0; i<inout.length; i++) inout[i]=apply(inout[i]);
samer@0 31 }
samer@0 32
samer@0 33 public void dispose() {}
samer@0 34
samer@0 35 public Function inverse() { throw new Error("no inverse"); }
samer@0 36 public Function derivative() { throw new Error("no derivative"); }
samer@0 37 public abstract String format(String arg);
samer@0 38 }