comparison src/samer/maths/Difference.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
12 public class Difference implements Generator
13 {
14 Generator g1, g2;
15
16 public Difference( Generator g1, Generator g2) { this.g1=g1; this.g2=g2; }
17
18 public void dispose() { g1.dispose(); g2.dispose(); }
19 public double next() { return g1.next()-g2.next(); }
20 public void next(double [] x) {
21 g1.next(x);
22 for (int i=0; i<x.length; i++) x[i]-=g2.next();
23 }
24
25 public String toString() { return g1.toString()+"-"+g2; }
26 }