public class MAVector extends Object
Constructor and Description |
---|
MAVector(Array a)
Create an MAVector using the given rank-1 array.
|
MAVector(double[] values)
Create an MAVector out of a double array
|
MAVector(int nelems)
Create an MAVector of the given length.
|
Modifier and Type | Method and Description |
---|---|
MAVector |
copy()
Create a new MAVector that is the same as this one, with a copy of the backing store.
|
double |
cos(MAVector v)
Cos between two vectors = dot(v) / norm() * norm(v)
|
double |
dot(MAVector v)
Dot product of 2 vectors
|
double |
getDouble(int i) |
int |
getNelems() |
double |
norm()
Get the L2 norm of this vector.
|
void |
normalize()
Normalize this vector, so it has norm = 1.0.
|
void |
setDouble(int i,
double val) |
public MAVector(Array a)
a
- rank-1 arrayIllegalArgumentException
- is a is not rank 1public MAVector(double[] values)
public MAVector(int nelems)
public MAVector copy()
public double cos(MAVector v)
v
- cosine with this vectorIllegalArgumentException
- if nelems != v.getNelems().public double dot(MAVector v)
v
- dot product with this vectorIllegalArgumentException
- if nelems != v.getNelems().public double getDouble(int i)
public int getNelems()
public double norm()
public void normalize()
public void setDouble(int i, double val)