public class Vector
extends java.lang.Object
implements java.io.Serializable
Constructor and Description |
---|
Vector(int dimensions)
Creates a new vector with the requested number of dimensions.
|
Vector(java.lang.String key,
double[] values)
Creates a vector with the values and a key
|
Vector(Vector other)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
double |
dot(Vector other)
Calculates the dot product, or scalar product, of this vector with the
other vector.
|
double |
get(int dimension)
Returns the value at the requested dimension.
|
int |
getDimensions() |
java.lang.String |
getKey() |
void |
moveSlightly(double radius)
Moves the vector slightly, adds a value selected from -radius to +radius to each element.
|
void |
set(int dimension,
double value)
Set a value at a certain dimension d.
|
void |
setKey(java.lang.String key) |
java.lang.String |
toString() |
public Vector(int dimensions)
dimensions
- The number of dimensions.public Vector(Vector other)
other
- The other vector.public Vector(java.lang.String key, double[] values)
key
- The key of the vector.values
- The values of the vector.public void moveSlightly(double radius)
radius
- The radius determines the amount to change the vector.public void set(int dimension, double value)
dimension
- The dimension, index for the value.value
- The value to set.public double get(int dimension)
dimension
- The dimension, index for the value.public int getDimensions()
public double dot(Vector other)
other
- The other vector, should have the same number of dimensions.java.lang.ArrayIndexOutOfBoundsException
- when the two vectors do not have the same dimensions.public void setKey(java.lang.String key)
public java.lang.String getKey()
public java.lang.String toString()
toString
in class java.lang.Object