Mercurial > hg > jslab
comparison examples/maths/GaussianForm.java @ 1:5df24c91468d
Oh my what a mess.
author | samer |
---|---|
date | Fri, 05 Apr 2019 16:26:00 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:bf79fb79ee13 | 1:5df24c91468d |
---|---|
1 package eg.maths; | |
2 import samer.core.*; | |
3 import samer.maths.*; | |
4 | |
5 public class GaussianForm extends QuadraticForm | |
6 { | |
7 public GaussianForm() { super(); } | |
8 public GaussianForm(int n) { super(n); } | |
9 | |
10 public double apply(double [] x) { | |
11 return -Math.exp(super.apply(x)); | |
12 } | |
13 | |
14 public VectorFunctionOfVector derivative() | |
15 { | |
16 return new VectorFunctionOfVector() { | |
17 public void apply(double [] x) { | |
18 double z=GaussianForm.this.apply(x); | |
19 Mathx.copy(y,x); | |
20 Mathx.mul(x,-z); | |
21 } | |
22 public void apply(double [] x, double [] v) { | |
23 double z=GaussianForm.this.apply(x); | |
24 Mathx.copy(y,v); | |
25 Mathx.mul(v,-z); | |
26 } | |
27 }; | |
28 } | |
29 } |