3 import org.apache.commons.math.linear.Array2DRowRealMatrix;
4 import org.apache.commons.math.linear.RealMatrix;
5 import org.apache.commons.math.util.FastMath;
28 public RealMatrix
evaluate(RealMatrix x, RealMatrix y) {
29 RealMatrix res =
new Array2DRowRealMatrix(x.getColumnDimension(), y.getColumnDimension());
30 for (
int i = 0; i < x.getColumnDimension(); i++) {
31 res.setColumn(i,
evaluate(x.getColumn(i), y));
40 public double[]
evaluate(
double[] x, RealMatrix y) {
41 double[] res =
new double[y.getColumnDimension()];
42 for (
int i = 0; i < y.getColumnDimension(); i++) {
43 res[i] = FastMath.exp(-(distance_sq(x, y.getColumn(i))) / (
gamma *
gamma));
52 public double[]
evaluate(
double t,
double[] ti) {
53 double[] res =
new double[ti.length];
54 for (
int i = 0; i < ti.length; i++) {
55 res[i] = FastMath.exp(-(t - ti[i]) * (t - ti[i]) / (
gamma *
gamma));
60 private double distance_sq(
double[] p1,
double[] p2) {
62 for (
int i = 0; i < p1.length; i++) {
63 sum += (p1[i] - p2[i]) * (p1[i] - p2[i]);
GaussKernel(double gamma)
Interface for kernel implementations in JKerMor.
Implementation of the Gaussian kernel .
double[] evaluate(double t, double[] ti)
double[] evaluate(double[] x, RealMatrix y)
RealMatrix evaluate(RealMatrix x, RealMatrix y)