Mercurial > hg > jslab
comparison src/samer/maths/Constant.java @ 0:bf79fb79ee13
Initial Mercurial check in.
author | samer |
---|---|
date | Tue, 17 Jan 2012 17:50:20 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bf79fb79ee13 |
---|---|
1 /* | |
2 * Copyright (c) 2000, Samer Abdallah, King's College London. | |
3 * All rights reserved. | |
4 * | |
5 * This software is provided AS iS and WITHOUT ANY WARRANTY; | |
6 * without even the implied warranty of MERCHANTABILITY or | |
7 * FITNESS FOR A PARTICULAR PURPOSE. | |
8 */ | |
9 | |
10 package samer.maths; | |
11 import samer.core.*; | |
12 | |
13 public class Constant extends Function implements Generator | |
14 { | |
15 double k; | |
16 | |
17 public Constant() { k=Shell.getInt("constant",1); } | |
18 public Constant(double k) { this.k=k; } | |
19 public void dispose() {} | |
20 | |
21 // Generator | |
22 public double next() { return k; } | |
23 public void next(double [] x) { for (int i=0; i<x.length; i++) x[i]=k; } | |
24 | |
25 // Function | |
26 public double apply(double t) { return k; } | |
27 public Function derivative() { return new Zero(); } | |
28 | |
29 public String toString() { return "Constant("+k+")"; } | |
30 public String format(String arg) { return X.string(k); } | |
31 } |