public abstract class Vector extends Object
Modifier and Type | Class and Description |
---|---|
class |
Vector.Entry
An entry in a sparse vector
|
Constructor and Description |
---|
Vector() |
Modifier and Type | Method and Description |
---|---|
double |
add(int index,
double value)
Add the given value to the value at the given index
|
void |
applyCentering()
mean-center the vector
|
static Vector |
copy(double[] values,
int start,
int length)
Copy a range from an array into a vector.
|
static Vector |
dense(int size)
Create an empty dense vector
|
double |
density() |
double |
dot(Vector x)
Returns the dot/scalar product.
|
Iterable<Vector.Entry> |
entries()
Iterates over all entries.
|
abstract boolean |
equals(Vector v,
double epsilon)
Test for equality
|
static Vector |
from(double... values)
Construct a Vector from an array of values
|
abstract double |
get(int index)
Get the value at the given index
|
double |
mean() |
double |
norm()
Compute the L2 norm
|
abstract double |
put(int index,
double value)
Set the value at an index
|
void |
scaleAndAddTo(double a,
Vector y)
y = y + a*
this . |
abstract int |
size() |
static Vector |
sparse(int size)
Create an empty sparse vector
|
void |
storeOn(double[] array,
int start)
I/O
|
double |
sum() |
abstract Vector |
times(double scalar)
Multiply by a constant, creating a new vector
|
abstract Vector |
timesEquals(double scalar)
Multiply by a constant in-place
|
String |
toString() |
double[] |
unwrap() |
int |
used()
Returns number of non-zero-valued entries.
|
static Vector |
wrap(double... values)
Wrap an array in a vector
|
public Vector()
public double add(int index, double value)
index
- value
- public double density()
public Iterable<Vector.Entry> entries()
public abstract double get(int index)
index
- public double norm()
public abstract double put(int index, double value)
index
- value
- public abstract int size()
public double sum()
public int used()
public static Vector from(double... values)
values
- public static Vector copy(double[] values, int start, int length)
values
- start
- length
- public static Vector wrap(double... values)
values
- public static Vector dense(int size)
size
- public static Vector sparse(int size)
size
- public double dot(Vector x)
x
- public void scaleAndAddTo(double a, Vector y)
this
.a
- y
- public void storeOn(double[] array, int start)
array
- start
- public abstract Vector times(double scalar)
scalar
- public abstract Vector timesEquals(double scalar)
scalar
- public abstract boolean equals(Vector v, double epsilon)
v
- epsilon
- public double[] unwrap()
public void applyCentering()
public double mean()