|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectweka.core.AlgVector
public class AlgVector
Class for performing operations on an algebraic vector of floating-point values.
Constructor Summary | |
---|---|
AlgVector(double[] array)
Constructs a vector using a given array. |
|
AlgVector(Instance instance)
Constructs a vector using an instance. |
|
AlgVector(Instances format,
java.util.Random random)
Constructs a vector using a given data format. |
|
AlgVector(int n)
Constructs a vector and initializes it with default values. |
Method Summary | |
---|---|
AlgVector |
add(AlgVector other)
Returns the sum of this vector with another. |
void |
changeLength(double len)
Changes the length of a vector. |
java.lang.Object |
clone()
Creates and returns a clone of this object. |
double |
dotMultiply(AlgVector b)
Returns the inner (or dot) product of two vectors |
Instance |
getAsInstance(Instances model,
java.util.Random random)
Gets the elements of the vector as an instance. |
double |
getElement(int index)
Returns the value of a cell in the matrix. |
double[] |
getElements()
Gets the elements of the vector and returns them as double array. |
static void |
main(java.lang.String[] args)
Main method for testing this class, can take an ARFF file as first argument. |
double |
norm()
Returns the norm of the vector |
void |
normVector()
Norms this vector to length 1.0 |
int |
numElements()
Returns the number of elements in the vector. |
void |
scalarMultiply(double s)
Computes the scalar product of this vector with a scalar |
void |
setElement(int index,
double value)
Sets an element of the matrix to the given value. |
void |
setElements(double[] elements)
Sets the elements of the vector to values of the given array. |
AlgVector |
substract(AlgVector other)
Returns the difference of this vector minus another. |
java.lang.String |
toString()
Converts a vector to a string |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public AlgVector(int n)
n
- the number of elementspublic AlgVector(double[] array)
array
- the values of the matrixpublic AlgVector(Instances format, java.util.Random random) throws java.lang.Exception
format
- the data format to userandom
- for initializing the attributes
java.lang.Exception
- if something goes wrongpublic AlgVector(Instance instance) throws java.lang.Exception
instance
- with numeric attributes, that AlgVector gets build from
java.lang.Exception
- if instance doesn't have access to the data format or
no numeric attributes in the dataMethod Detail |
---|
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
- if an error occurspublic final double getElement(int index)
index
- the row's index
public final int numElements()
public final void setElement(int index, double value)
index
- the elements indexvalue
- the new valuepublic final void setElements(double[] elements)
elements
- an array of doublespublic double[] getElements()
public Instance getAsInstance(Instances model, java.util.Random random) throws java.lang.Exception
model
- the dataset structure to fit the data torandom
- in case of nominal values a random label is taken
java.lang.Exception
- if length of vector is not number of numerical attributespublic final AlgVector add(AlgVector other)
other
- the vector to add
public final AlgVector substract(AlgVector other)
other
- the vector to subtract
public final double dotMultiply(AlgVector b)
b
- the multiplication matrix
public final void scalarMultiply(double s)
s
- the scalarpublic void changeLength(double len)
len
- the new length of the vectorpublic double norm()
public final void normVector()
public java.lang.String toString()
toString
in class java.lang.Object
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- commandline options
java.lang.Exception
- if something goes wrong in testing
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |