public class Vector extends Object
Modifier and Type | Field and Description |
---|---|
private double[] |
data |
Constructor and Description |
---|
Vector(double[] data)
Copy constructor.
|
Vector(int dimension)
Create a vector of a given dimension.
|
Vector(Vector v)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
Vector |
add(Vector v)
Add a vector to this one.
|
double |
element(int i)
Get the element at the given index.
|
int |
length()
Obtain the length, i.e.
|
double |
multiply(Vector v)
Calculate the dot product of this vector with v.
|
double |
setEntry(int i,
double value)
Set the value of the vector at a given index.
|
Vector |
subtract(Vector v)
Subtract a vector from this one.
|
double[] |
toArray()
Return a copy of the vector as an array.
|
String |
toString() |
public Vector(int dimension)
dimension
- the dimension of the vector.public Vector(Vector v)
v
- the vector to be copied.public Vector(double[] data)
data
- an array that will be copied.public double element(int i)
i
- the vector element to be found.public double setEntry(int i, double value)
i
- the coordinate of the vector to be setvalue
- the value of the vector element.public double[] toArray()
public int length()
public Vector add(Vector v)
v
- the vector to be added to this one.public Vector subtract(Vector v)
v
- the vector to be subtracted from this one.public double multiply(Vector v)
v
- the vector to be dotted.Copyright © 2015 University of Glasgow. All rights reserved.