public abstract class AbstractVector extends Object implements Vector, Serializable
Vector. The following methods throw
UnsupportedOperationException, and should be overridden by a
subclass:
get(int)set(int,double)copyFor the rest of the methods, simple default implementations using a vector iterator has been provided. There are some kernel operations which the simpler operations forward to, and they are:
add(double,Vector) and set(double,Vector).scale(double).dot(Vector) and all the norms.
Finally, a default iterator is provided by this class, which works by calling
the get function. A tailored replacement should be used by
subclasses.
Vector.Norm| Modifier and Type | Field and Description |
|---|---|
protected int |
size
Size of the vector
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractVector(int size)
Constructor for AbstractVector.
|
protected |
AbstractVector(Vector x)
Constructor for AbstractVector, same size as x
|
| Modifier and Type | Method and Description |
|---|---|
Vector |
add(double alpha,
Vector y)
x = alpha*y + x |
void |
add(int index,
double value)
x(index) += value |
Vector |
add(Vector y)
x = y + x |
protected void |
check(int index)
Checks the index
|
protected void |
checkSize(Vector y)
Checks for conformant sizes
|
Vector |
copy()
Creates a deep copy of the vector
|
double |
dot(Vector y)
xT*y |
double |
get(int index)
Returns
x(index) |
Iterator<VectorEntry> |
iterator() |
double |
norm(Vector.Norm type)
Computes the given norm of the vector
|
protected double |
norm1() |
protected double |
norm2_robust() |
protected double |
norm2() |
protected double |
normInf() |
Vector |
scale(double alpha)
x=alpha*x |
Vector |
set(double alpha,
Vector y)
x=alpha*y |
void |
set(int index,
double value)
x(index) = value |
Vector |
set(Vector y)
x=y |
int |
size()
Size of the vector
|
String |
toString() |
Vector |
zero()
Zeros all the entries in the vector, while preserving any underlying
structure
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorprotected AbstractVector(int size)
size - Size of the vectorprotected AbstractVector(Vector x)
x - Vector to get the size frompublic int size()
Vectorpublic void set(int index,
double value)
Vectorx(index) = valuepublic void add(int index,
double value)
Vectorx(index) += valuepublic double get(int index)
Vectorx(index)public Vector copy()
Vectorprotected void check(int index)
public Vector zero()
Vectorpublic Vector add(double alpha, Vector y)
Vectorx = alpha*y + xprotected void checkSize(Vector y)
public double norm(Vector.Norm type)
Vectorprotected double norm1()
protected double norm2()
protected double norm2_robust()
protected double normInf()
public Iterator<VectorEntry> iterator()
iterator in interface Iterable<VectorEntry>Copyright © 2015. All Rights Reserved.