Package no.uib.cipr.matrix
Class AbstractVector
java.lang.Object
no.uib.cipr.matrix.AbstractVector
- All Implemented Interfaces:
Serializable
,Iterable<VectorEntry>
,Vector
- Direct Known Subclasses:
DenseVector
,DistVector
,SparseVector
Partial implementation of
Vector
. The following methods throw
UnsupportedOperationException
, and should be overridden by a
subclass:
get(int)
set(int,double)
copy
For 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)
andset(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.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface no.uib.cipr.matrix.Vector
Vector.Norm
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractVector
(int size) Constructor for AbstractVector.protected
Constructor for AbstractVector, same size as x -
Method Summary
Modifier and TypeMethodDescriptionx = alpha*y + x
void
add
(int index, double value) x(index) += value
x = y + x
protected void
check
(int index) Checks the indexprotected void
Checks for conformant sizescopy()
Creates a deep copy of the vectordouble
xT*y
double
get
(int index) Returnsx(index)
iterator()
double
norm
(Vector.Norm type) Computes the given norm of the vectorprotected double
norm1()
protected double
norm2()
protected double
protected double
normInf()
scale
(double alpha) x=alpha*x
x=alpha*y
void
set
(int index, double value) x(index) = value
x=y
int
size()
Size of the vectortoString()
zero()
Zeros all the entries in the vector, while preserving any underlying structureMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
size
protected int sizeSize of the vector
-
-
Constructor Details
-
AbstractVector
protected AbstractVector(int size) Constructor for AbstractVector.- Parameters:
size
- Size of the vector
-
AbstractVector
Constructor for AbstractVector, same size as x- Parameters:
x
- Vector to get the size from
-
-
Method Details
-
size
public int size()Description copied from interface:Vector
Size of the vector -
set
public void set(int index, double value) Description copied from interface:Vector
x(index) = value
-
add
public void add(int index, double value) Description copied from interface:Vector
x(index) += value
-
get
public double get(int index) Description copied from interface:Vector
Returnsx(index)
-
copy
Description copied from interface:Vector
Creates a deep copy of the vector -
check
protected void check(int index) Checks the index -
zero
Description copied from interface:Vector
Zeros all the entries in the vector, while preserving any underlying structure -
scale
Description copied from interface:Vector
x=alpha*x
-
set
Description copied from interface:Vector
x=y
-
set
Description copied from interface:Vector
x=alpha*y
-
add
Description copied from interface:Vector
x = y + x
-
add
Description copied from interface:Vector
x = alpha*y + x
-
dot
Description copied from interface:Vector
xT*y
-
checkSize
Checks for conformant sizes -
norm
Description copied from interface:Vector
Computes the given norm of the vector -
norm1
protected double norm1() -
norm2
protected double norm2() -
norm2_robust
protected double norm2_robust() -
normInf
protected double normInf() -
iterator
- Specified by:
iterator
in interfaceIterable<VectorEntry>
-
toString
-