All Packages Class Hierarchy This Package Previous Next Index WEKA's home
Class weka.clusterers.AlgVector
java.lang.Object
|
+----weka.clusterers.AlgVector
- public class AlgVector
- extends java.lang.Object
- implements java.lang.Cloneable, java.io.Serializable
Class for performing operations on an algebraic vector
of floating-point values.
- Version:
- $Revision: 1.1 $
- Author:
- Gabi Schmidberger (gabi@cs.waikato.ac.nz)
AlgVector(double[])
- Constructs a vector using a given array.
AlgVector(Instance)
- Constructs a vector using an instance.
AlgVector(Instances, Random)
- Constructs a vector using a given data format.
AlgVector(int)
- Constructs a vector and initializes it with default values.
add(AlgVector)
- Returns the sum of this vector with another.
changeLength(double)
- Changes the length of a vector.
dotMultiply(AlgVector)
- Returns the inner (or dot) product of two vectors
getAsInstance(Instances)
- Gets the elements of the vector as an instance.
getElement(int)
- Returns the value of a cell in the matrix.
getElements(int)
- Gets the elements of the vector and returns them as double array.
main(String[])
- Main method for testing this class.
norm()
- Returns the norm of the vector
normVector()
- Norms this vector to length 1.0
numElements()
- Returns the number of elements in the vector.
scalarMultiply(double)
- Computes the scalar product of this vector with a scalar
setElement(int, double)
- Sets an element of the matrix to the given value.
setElements(double[])
- Sets the elements of the vector to values of the given array.
substract(AlgVector)
- Returns the difference of this vector minus another.
toString()
- Converts a vector to a string
AlgVector
public AlgVector(int n)
Constructs a vector and initializes it with default values.
- Parameters:
n - the number of elements
AlgVector
public AlgVector(double array[]) throws java.lang.Exception
Constructs a vector using a given array.
- Parameters:
array - the values of the matrix
AlgVector
public AlgVector(Instances format,
java.util.Random random) throws java.lang.Exception
Constructs a vector using a given data format.
The vector has an element for each numerical attribute.
The other attributes (nominal, string) are ignored.
Random is used to initialize the attributes.
- Parameters:
array - the values of the matrix
AlgVector
public AlgVector(Instance instance) throws java.lang.Exception
Constructs a vector using an instance.
The vector has an element for each numerical attribute.
The other attributes (nominal, string) are ignored.
- Parameters:
instance - with numeric attributes, that AlgVector gets build from
- Throws:
- if - instance doesn't have access to the data format
getElement
public final double getElement(int index)
Returns the value of a cell in the matrix.
- Parameters:
index - the row's index
- Returns:
- the value of the cell of the vector
numElements
public final int numElements()
Returns the number of elements in the vector.
- Returns:
- the number of rows
setElement
public final void setElement(int index,
double value)
Sets an element of the matrix to the given value.
- Parameters:
index - the elements index
value - the new value
setElements
public final void setElements(double elements[])
Sets the elements of the vector to values of the given array.
Performs a deep copy.
- Parameters:
elements - an array of doubles
getElements
public double[] getElements(int index)
Gets the elements of the vector and returns them as double array.
- Returns:
- an array of doubles
getAsInstance
public Instance getAsInstance(Instances model) throws java.lang.Exception
Gets the elements of the vector as an instance.
!! NON-numeric data is ignored sofar
- Returns:
- an array of doubles
- Throws:
- if - length of vector is not number of numerical attributes
toString
public java.lang.String toString()
Converts a vector to a string
- Returns:
- the converted string
- Overrides:
- toString in class java.lang.Object
add
public final AlgVector add(AlgVector other)
Returns the sum of this vector with another.
- Returns:
- a vector containing the sum.
substract
public final AlgVector substract(AlgVector other)
Returns the difference of this vector minus another.
- Returns:
- a vector containing the difference vector.
dotMultiply
public final double dotMultiply(AlgVector b)
Returns the inner (or dot) product of two vectors
- Parameters:
b - the multiplication matrix
- Returns:
- the double representing the dot product
scalarMultiply
public final void scalarMultiply(double s)
Computes the scalar product of this vector with a scalar
- Parameters:
s - the scalar
changeLength
public void changeLength(double len)
Changes the length of a vector.
- Parameters:
the - new length of the vector
- Returns:
- the norm of the vector
norm
public double norm()
Returns the norm of the vector
- Returns:
- the norm of the vector
normVector
public final void normVector()
Norms this vector to length 1.0
main
public static void main(java.lang.String ops[])
Main method for testing this class.
All Packages Class Hierarchy This Package Previous Next Index WEKA's home