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
ConstructorsModifierConstructorDescriptionprotectedAbstractVector(int size) Constructor for AbstractVector.protectedConstructor for AbstractVector, same size as x -
Method Summary
Modifier and TypeMethodDescriptionx = alpha*y + xvoidadd(int index, double value) x(index) += valuex = y + xprotected voidcheck(int index) Checks the indexprotected voidChecks for conformant sizescopy()Creates a deep copy of the vectordoublexT*ydoubleget(int index) Returnsx(index)iterator()doublenorm(Vector.Norm type) Computes the given norm of the vectorprotected doublenorm1()protected doublenorm2()protected doubleprotected doublenormInf()scale(double alpha) x=alpha*xx=alpha*yvoidset(int index, double value) x(index) = valuex=yintsize()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, waitMethods 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:VectorSize of the vector -
set
public void set(int index, double value) Description copied from interface:Vectorx(index) = value -
add
public void add(int index, double value) Description copied from interface:Vectorx(index) += value -
get
public double get(int index) Description copied from interface:VectorReturnsx(index) -
copy
Description copied from interface:VectorCreates a deep copy of the vector -
check
protected void check(int index) Checks the index -
zero
Description copied from interface:VectorZeros all the entries in the vector, while preserving any underlying structure -
scale
Description copied from interface:Vectorx=alpha*x -
set
Description copied from interface:Vectorx=y -
set
Description copied from interface:Vectorx=alpha*y -
add
Description copied from interface:Vectorx = y + x -
add
Description copied from interface:Vectorx = alpha*y + x -
dot
Description copied from interface:VectorxT*y -
checkSize
Checks for conformant sizes -
norm
Description copied from interface:VectorComputes 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:
iteratorin interfaceIterable<VectorEntry>
-
toString
-