gov.sandia.cognition.learning.function.vector
Class SubVectorEvaluator

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.math.matrix.DefaultVectorFactoryContainer
          extended by gov.sandia.cognition.learning.function.vector.SubVectorEvaluator
All Implemented Interfaces:
Evaluator<Vectorizable,Vector>, VectorFactoryContainer, VectorInputEvaluator<Vectorizable,Vector>, VectorOutputEvaluator<Vectorizable,Vector>, CloneableSerializable, Serializable, Cloneable

public class SubVectorEvaluator
extends DefaultVectorFactoryContainer
implements VectorInputEvaluator<Vectorizable,Vector>, VectorOutputEvaluator<Vectorizable,Vector>

Extracts the given set of indices from an input vector to create a new vector containing the input vector's elements at those indices.

Since:
3.0
Author:
Justin Basilico
See Also:
Serialized Form

Field Summary
protected  int inputDimensionality
          The expected dimensionality of the input.
protected  int[] subIndices
          The indices to pull out of an input vector to create a new vector from.
 
Fields inherited from class gov.sandia.cognition.math.matrix.DefaultVectorFactoryContainer
vectorFactory
 
Constructor Summary
SubVectorEvaluator()
          Creates a new SubVectorEvaluator.
SubVectorEvaluator(int inputDimensionality, int[] subIndices)
          Creates a new SubVectorEvaluator with the given parameters.
SubVectorEvaluator(int inputDimensionality, int[] subIndices, VectorFactory<? extends Vector> vectorFactory)
          Creates a new SubVectorEvaluator with the given parameters.
 
Method Summary
 Vector evaluate(Vectorizable input)
          Evaluates the function on the given input and returns the output.
 int getInputDimensionality()
          Gets the expected dimensionality of the input vector to the evaluator, if it is known.
 int getOutputDimensionality()
          Gets the expected dimensionality of the output vector of the evaluator, if it is known.
 int[] getSubIndices()
          Gets the array of indices used to create the sub-vector.
 void setInputDimensionality(int inputDimensionality)
          Sets the expected input dimensionality.
 void setSubIndices(int[] subIndices)
          Sets the array of sub-indices.
 
Methods inherited from class gov.sandia.cognition.math.matrix.DefaultVectorFactoryContainer
getVectorFactory, setVectorFactory
 
Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

inputDimensionality

protected int inputDimensionality
The expected dimensionality of the input. All the subIndices must be less than this value.


subIndices

protected int[] subIndices
The indices to pull out of an input vector to create a new vector from.

Constructor Detail

SubVectorEvaluator

public SubVectorEvaluator()
Creates a new SubVectorEvaluator. The dimensionality and indices are initialized to invalid values and must be set later before use.


SubVectorEvaluator

public SubVectorEvaluator(int inputDimensionality,
                          int[] subIndices)
Creates a new SubVectorEvaluator with the given parameters.

Parameters:
inputDimensionality - The dimensionality of the expected input vectors. This is checked against all the incoming vectors.
subIndices - The indices used to create the sub-vector. Must be between 0 (inclusive) and the input dimensionality (exclusive).

SubVectorEvaluator

public SubVectorEvaluator(int inputDimensionality,
                          int[] subIndices,
                          VectorFactory<? extends Vector> vectorFactory)
Creates a new SubVectorEvaluator with the given parameters.

Parameters:
inputDimensionality - The dimensionality of the expected input vectors. This is checked against all the incoming vectors.
subIndices - The indices used to create the sub-vector. Must be between 0 (inclusive) and the input dimensionality (exclusive).
vectorFactory - The vector factory used to create the new sub-vector.
Method Detail

evaluate

public Vector evaluate(Vectorizable input)
Description copied from interface: Evaluator
Evaluates the function on the given input and returns the output.

Specified by:
evaluate in interface Evaluator<Vectorizable,Vector>
Parameters:
input - The input to evaluate.
Returns:
The output produced by evaluating the input.

getInputDimensionality

public int getInputDimensionality()
Description copied from interface: VectorInputEvaluator
Gets the expected dimensionality of the input vector to the evaluator, if it is known. If it is not known, -1 is returned.

Specified by:
getInputDimensionality in interface VectorInputEvaluator<Vectorizable,Vector>
Returns:
The expected dimensionality of the input vector to the evaluator, or -1 if it is not known.

setInputDimensionality

public void setInputDimensionality(int inputDimensionality)
Sets the expected input dimensionality.

Parameters:
inputDimensionality - The expected input dimensionality.

getOutputDimensionality

public int getOutputDimensionality()
Description copied from interface: VectorOutputEvaluator
Gets the expected dimensionality of the output vector of the evaluator, if it is known. If it is not known, -1 is returned.

Specified by:
getOutputDimensionality in interface VectorOutputEvaluator<Vectorizable,Vector>
Returns:
The expected dimensionality of the output vector of the evaluator, or -1 if it is not known.

getSubIndices

public int[] getSubIndices()
Gets the array of indices used to create the sub-vector.

Returns:
The array of indices used to create the sub-vector.

setSubIndices

public void setSubIndices(int[] subIndices)
Sets the array of sub-indices. They should all be between 0 (inclusive) and the expected input dimensionality (exclusive). The size and ordering of the array itself is unconstrained as long as the indices are valid.

Parameters:
subIndices - The array of indices to use to create a sub-vector from an input vector.