@CodeReview(reviewer="Kevin R. Dixon", date="2009-07-08", changesNeeded=false, comments={"Made clone call super.clone.","Looks fine otherwise."}) public class VectorFunctionKernel extends DefaultKernelContainer<Vector> implements Kernel<Vectorizable>
VectorFunctionKernel
implements a kernel that makes use of a
vector function plus a kernel that operates on vectors. If no kernel is
specified the linear kernel (dot product) is used.Modifier and Type | Field and Description |
---|---|
protected VectorFunction |
function
The vector function to use.
|
kernel
Constructor and Description |
---|
VectorFunctionKernel()
Creates a new instance of VectorFunctionKernel.
|
VectorFunctionKernel(VectorFunction function)
Creates a new VectorFunctionKernel from the given function.
|
VectorFunctionKernel(VectorFunction function,
Kernel<? super Vector> kernel)
Creates a new VectorFunctionKernel from the given function and kernel.
|
Modifier and Type | Method and Description |
---|---|
VectorFunctionKernel |
clone()
This makes public the clone method on the
Object class and
removes the exception that it throws. |
double |
evaluate(Vectorizable x,
Vectorizable y)
Evaluates the kernel on the given inputs by first applying the vector
function to each input vector and then evaluating the kernel on the
results of the vector function.
|
VectorFunction |
getFunction()
Gets the vector function the kernel is using.
|
void |
setFunction(VectorFunction function)
Sets the vector function for the kernel to use.
|
getKernel, setKernel
protected VectorFunction function
public VectorFunctionKernel()
public VectorFunctionKernel(VectorFunction function)
function
- The vector function to use.public VectorFunctionKernel(VectorFunction function, Kernel<? super Vector> kernel)
function
- The vector function to use.kernel
- The kernel to use.public VectorFunctionKernel clone()
AbstractCloneableSerializable
Object
class and
removes the exception that it throws. Its default behavior is to
automatically create a clone of the exact type of object that the
clone is called on and to copy all primitives but to keep all references,
which means it is a shallow copy.
Extensions of this class may want to override this method (but call
super.clone()
to implement a "smart copy". That is, to target
the most common use case for creating a copy of the object. Because of
the default behavior being a shallow copy, extending classes only need
to handle fields that need to have a deeper copy (or those that need to
be reset). Some of the methods in ObjectUtil
may be helpful in
implementing a custom clone method.
Note: The contract of this method is that you must use
super.clone()
as the basis for your implementation.clone
in interface CloneableSerializable
clone
in class DefaultKernelContainer<Vector>
public double evaluate(Vectorizable x, Vectorizable y)
evaluate
in interface Kernel<Vectorizable>
x
- The first item.y
- The second item.public VectorFunction getFunction()
public void setFunction(VectorFunction function)
function
- The vector function for the kernel to use.