All Packages  Class Hierarchy  This Package  Previous  Next  Index  WEKA's home

Class weka.core.AlgVector

java.lang.Object
    |
    +----weka.core.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)

Constructor Index

 o AlgVector(double[])
Constructs a vector using a given array.
 o AlgVector(Instance)
Constructs a vector using an instance.
 o AlgVector(Instances, Random)
Constructs a vector using a given data format.
 o AlgVector(int)
Constructs a vector and initializes it with default values.

Method Index

 o add(AlgVector)
Returns the sum of this vector with another.
 o changeLength(double)
Changes the length of a vector.
 o clone()
Creates and returns a clone of this object.
 o dotMultiply(AlgVector)
Returns the inner (or dot) product of two vectors
 o getAsInstance(Instances, Random)
Gets the elements of the vector as an instance.
 o getElement(int)
Returns the value of a cell in the matrix.
 o getElements(int)
Gets the elements of the vector and returns them as double array.
 o main(String[])
Main method for testing this class.
 o norm()
Returns the norm of the vector
 o normVector()
Norms this vector to length 1.0
 o numElements()
Returns the number of elements in the vector.
 o scalarMultiply(double)
Computes the scalar product of this vector with a scalar
 o setElement(int, double)
Sets an element of the matrix to the given value.
 o setElements(double[])
Sets the elements of the vector to values of the given array.
 o substract(AlgVector)
Returns the difference of this vector minus another.
 o toString()
Converts a vector to a string

Constructor Detail

 o AlgVector
public AlgVector(int n)
          Constructs a vector and initializes it with default values.
Parameters:
n - the number of elements
 o AlgVector
public AlgVector(double array[]) throws java.lang.Exception
          Constructs a vector using a given array.
Parameters:
array - the values of the matrix
 o 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
 o 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

Method Detail

 o clone
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
          Creates and returns a clone of this object.
Returns:
a clone of this instance.
Throws:
java.lang.CloneNotSupportedException - if an error occurs
 o 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
 o numElements
public final int numElements()
          Returns the number of elements in the vector.
Returns:
the number of rows
 o 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
 o 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
 o getElements
public double[] getElements(int index)
          Gets the elements of the vector and returns them as double array.
Returns:
an array of doubles
 o getAsInstance
public Instance getAsInstance(Instances model,
                              java.util.Random random) 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
 o toString
public java.lang.String toString()
          Converts a vector to a string
Returns:
the converted string
Overrides:
toString in class java.lang.Object
 o add
public final AlgVector add(AlgVector other)
          Returns the sum of this vector with another.
Returns:
a vector containing the sum.
 o substract
public final AlgVector substract(AlgVector other)
          Returns the difference of this vector minus another.
Returns:
a vector containing the difference vector.
 o 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
 o scalarMultiply
public final void scalarMultiply(double s)
          Computes the scalar product of this vector with a scalar
Parameters:
s - the scalar
 o 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
 o norm
public double norm()
          Returns the norm of the vector
Returns:
the norm of the vector
 o normVector
public final void normVector()
          Norms this vector to length 1.0
 o 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