Package no.uib.cipr.matrix
Class DenseVector
- java.lang.Object
-
- no.uib.cipr.matrix.AbstractVector
-
- no.uib.cipr.matrix.DenseVector
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Iterable<VectorEntry>,Vector
public class DenseVector extends AbstractVector implements java.io.Serializable
Dense vector. Stored by adouble[]array of the same length as the vector itself.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface no.uib.cipr.matrix.Vector
Vector.Norm
-
-
Field Summary
-
Fields inherited from class no.uib.cipr.matrix.AbstractVector
size
-
-
Constructor Summary
Constructors Constructor Description DenseVector(double[] x)Constructor for DenseVectorDenseVector(double[] x, boolean deep)Constructor for DenseVectorDenseVector(int size)Constructor for DenseVectorDenseVector(MatrixVectorReader r)Constructor for DenseVectorDenseVector(Vector x)Constructor for DenseVectorDenseVector(Vector x, boolean deep)Constructor for DenseVector
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Vectoradd(double alpha, Vector y)x = alpha*y + xvoidadd(int index, double value)x(index) += valueVectoradd(Vector y)x = y + xDenseVectorcopy()Creates a deep copy of the vectordoubledot(Vector y)xT*ydoubleget(int index)Returnsx(index)double[]getData()Returns the internal vector contents.protected doublenorm1()protected doublenorm2()protected doublenorm2_robust()protected doublenormInf()DenseVectorscale(double alpha)x=alpha*xVectorset(double alpha, Vector y)x=alpha*yvoidset(int index, double value)x(index) = valueVectorset(Vector y)x=yDenseVectorzero()Zeros all the entries in the vector, while preserving any underlying structure-
Methods inherited from class no.uib.cipr.matrix.AbstractVector
check, checkSize, iterator, norm, size, toString
-
-
-
-
Constructor Detail
-
DenseVector
public DenseVector(MatrixVectorReader r) throws java.io.IOException
Constructor for DenseVector- Parameters:
r- Reader to get vector from- Throws:
java.io.IOException
-
DenseVector
public DenseVector(int size)
Constructor for DenseVector- Parameters:
size- Size of the vector
-
DenseVector
public DenseVector(Vector x)
Constructor for DenseVector- Parameters:
x- Copies contents from this vector. A deep copy is made
-
DenseVector
public DenseVector(Vector x, boolean deep)
Constructor for DenseVector- Parameters:
x- Copies contents from this vectordeep- True for a deep copy. For a shallow copy,xmust be aDenseVector
-
DenseVector
public DenseVector(double[] x, boolean deep)Constructor for DenseVector- Parameters:
x- Copies contents from this arraydeep- True for a deep copy. For a shallow copy,xis aliased with the internal storage
-
DenseVector
public DenseVector(double[] x)
Constructor for DenseVector- Parameters:
x- Copies contents from this array in a deep copy
-
-
Method Detail
-
set
public void set(int index, double value)Description copied from interface:Vectorx(index) = value- Specified by:
setin interfaceVector- Overrides:
setin classAbstractVector
-
add
public void add(int index, double value)Description copied from interface:Vectorx(index) += value- Specified by:
addin interfaceVector- Overrides:
addin classAbstractVector
-
get
public double get(int index)
Description copied from interface:VectorReturnsx(index)- Specified by:
getin interfaceVector- Overrides:
getin classAbstractVector
-
copy
public DenseVector copy()
Description copied from interface:VectorCreates a deep copy of the vector- Specified by:
copyin interfaceVector- Overrides:
copyin classAbstractVector
-
zero
public DenseVector zero()
Description copied from interface:VectorZeros all the entries in the vector, while preserving any underlying structure- Specified by:
zeroin interfaceVector- Overrides:
zeroin classAbstractVector
-
scale
public DenseVector scale(double alpha)
Description copied from interface:Vectorx=alpha*x- Specified by:
scalein interfaceVector- Overrides:
scalein classAbstractVector- Returns:
- x
-
set
public Vector set(Vector y)
Description copied from interface:Vectorx=y- Specified by:
setin interfaceVector- Overrides:
setin classAbstractVector- Returns:
- x
-
set
public Vector set(double alpha, Vector y)
Description copied from interface:Vectorx=alpha*y- Specified by:
setin interfaceVector- Overrides:
setin classAbstractVector- Returns:
- x
-
add
public Vector add(Vector y)
Description copied from interface:Vectorx = y + x- Specified by:
addin interfaceVector- Overrides:
addin classAbstractVector- Returns:
- x
-
add
public Vector add(double alpha, Vector y)
Description copied from interface:Vectorx = alpha*y + x- Specified by:
addin interfaceVector- Overrides:
addin classAbstractVector- Returns:
- x
-
dot
public double dot(Vector y)
Description copied from interface:VectorxT*y- Specified by:
dotin interfaceVector- Overrides:
dotin classAbstractVector
-
norm1
protected double norm1()
- Overrides:
norm1in classAbstractVector
-
norm2
protected double norm2()
- Overrides:
norm2in classAbstractVector
-
norm2_robust
protected double norm2_robust()
- Overrides:
norm2_robustin classAbstractVector
-
normInf
protected double normInf()
- Overrides:
normInfin classAbstractVector
-
getData
public double[] getData()
Returns the internal vector contents. The array indices correspond to the vector indices
-
-