com.github.waikatodatamining.matrix.transformation.kernel.LinearKernel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of matrix-algorithms Show documentation
Show all versions of matrix-algorithms Show documentation
Java library of 2-dimensional matrix algorithms.
package com.github.waikatodatamining.matrix.transformation.kernel;
import com.github.waikatodatamining.matrix.core.Matrix;
/**
* Linear Kernel.
*
* K(x_i,y_j)=x_i^T*y_j
* or also
* K(X, Y)=X*Y^T
*
* @author Steven Lang
*/
public class LinearKernel extends AbstractKernel {
private static final long serialVersionUID = 841527107134287683L;
@Override
public double applyVector(Matrix x, Matrix y) {
return x.vectorDot(y);
}
@Override
public Matrix applyMatrix(Matrix X, Matrix Y) {
return X.mul(Y.transpose());
}
@Override
public Matrix applyMatrix(Matrix X) {
return this.applyMatrix(X, X);
}
@Override
public String toString() {
return "Linear Kernel: K(x,y)=x^T*y";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy