程序包 weka.core

类 AlgVector

java.lang.Object
weka.core.AlgVector
所有已实现的接口:
Serializable, Cloneable, RevisionHandler

public class AlgVector extends Object implements Cloneable, Serializable, RevisionHandler
Class for performing operations on an algebraic vector of floating-point values.
版本:
$Revision: 1.10 $
作者:
Gabi Schmidberger (gabi@cs.waikato.ac.nz)
另请参阅:
  • 构造器概要

    构造器
    构造器
    说明
    AlgVector(double[] array)
    Constructs a vector using a given array.
    AlgVector(int n)
    Constructs a vector and initializes it with default values.
    AlgVector(Instance instance)
    Constructs a vector using an instance.
    AlgVector(Instances format, Random random)
    Constructs a vector using a given data format.
  • 方法概要

    修饰符和类型
    方法
    说明
    final AlgVector
    add(AlgVector other)
    Returns the sum of this vector with another.
    void
    changeLength(double len)
    Changes the length of a vector.
    Creates and returns a clone of this object.
    final double
    Returns the inner (or dot) product of two vectors
    getAsInstance(Instances model, Random random)
    Gets the elements of the vector as an instance.
    final double
    getElement(int index)
    Returns the value of a cell in the matrix.
    double[]
    Gets the elements of the vector and returns them as double array.
    Returns the revision string.
    static void
    main(String[] args)
    Main method for testing this class, can take an ARFF file as first argument.
    double
    Returns the norm of the vector
    final void
    Norms this vector to length 1.0
    final int
    Returns the number of elements in the vector.
    final void
    scalarMultiply(double s)
    Computes the scalar product of this vector with a scalar
    final void
    setElement(int index, double value)
    Sets an element of the matrix to the given value.
    final void
    setElements(double[] elements)
    Sets the elements of the vector to values of the given array.
    final AlgVector
    Returns the difference of this vector minus another.
    Converts a vector to a string

    从类继承的方法 java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • 构造器详细资料

    • AlgVector

      public AlgVector(int n)
      Constructs a vector and initializes it with default values.
      参数:
      n - the number of elements
    • AlgVector

      public AlgVector(double[] array)
      Constructs a vector using a given array.
      参数:
      array - the values of the matrix
    • AlgVector

      public AlgVector(Instances format, Random random) throws 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.
      参数:
      format - the data format to use
      random - for initializing the attributes
      抛出:
      Exception - if something goes wrong
    • AlgVector

      public AlgVector(Instance instance) throws Exception
      Constructs a vector using an instance. The vector has an element for each numerical attribute. The other attributes (nominal, string) are ignored.
      参数:
      instance - with numeric attributes, that AlgVector gets build from
      抛出:
      Exception - if instance doesn't have access to the data format or no numeric attributes in the data
  • 方法详细资料

    • clone

      public Object clone() throws CloneNotSupportedException
      Creates and returns a clone of this object.
      返回:
      a clone of this instance.
      抛出:
      CloneNotSupportedException - if an error occurs
    • getElement

      public final double getElement(int index)
      Returns the value of a cell in the matrix.
      参数:
      index - the row's index
      返回:
      the value of the cell of the vector
    • numElements

      public final int numElements()
      Returns the number of elements in the vector.
      返回:
      the number of rows
    • setElement

      public final void setElement(int index, double value)
      Sets an element of the matrix to the given value.
      参数:
      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.
      参数:
      elements - an array of doubles
    • getElements

      public double[] getElements()
      Gets the elements of the vector and returns them as double array.
      返回:
      an array of doubles
    • getAsInstance

      public Instance getAsInstance(Instances model, Random random) throws Exception
      Gets the elements of the vector as an instance. !! NON-numeric data is ignored sofar
      参数:
      model - the dataset structure to fit the data to
      random - in case of nominal values a random label is taken
      返回:
      an array of doubles
      抛出:
      Exception - if length of vector is not number of numerical attributes
    • add

      public final AlgVector add(AlgVector other)
      Returns the sum of this vector with another.
      参数:
      other - the vector to add
      返回:
      a vector containing the sum.
    • substract

      public final AlgVector substract(AlgVector other)
      Returns the difference of this vector minus another.
      参数:
      other - the vector to subtract
      返回:
      a vector containing the difference vector.
    • dotMultiply

      public final double dotMultiply(AlgVector b)
      Returns the inner (or dot) product of two vectors
      参数:
      b - the multiplication matrix
      返回:
      the double representing the dot product
    • scalarMultiply

      public final void scalarMultiply(double s)
      Computes the scalar product of this vector with a scalar
      参数:
      s - the scalar
    • changeLength

      public void changeLength(double len)
      Changes the length of a vector.
      参数:
      len - the new length of the vector
    • norm

      public double norm()
      Returns the norm of the vector
      返回:
      the norm of the vector
    • normVector

      public final void normVector()
      Norms this vector to length 1.0
    • toString

      public String toString()
      Converts a vector to a string
      覆盖:
      toString 在类中 Object
      返回:
      the converted string
    • getRevision

      public String getRevision()
      Returns the revision string.
      指定者:
      getRevision 在接口中 RevisionHandler
      返回:
      the revision
    • main

      public static void main(String[] args) throws Exception
      Main method for testing this class, can take an ARFF file as first argument.
      参数:
      args - commandline options
      抛出:
      Exception - if something goes wrong in testing