Package no.uib.cipr.matrix
Class DenseVector
java.lang.Object
no.uib.cipr.matrix.AbstractVector
no.uib.cipr.matrix.DenseVector
- All Implemented Interfaces:
Serializable
,Iterable<VectorEntry>
,Vector
Dense vector. Stored by a
double[]
array of the same length as
the vector itself.- See Also:
-
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
ConstructorsConstructorDescriptionDenseVector
(double[] x) Constructor for DenseVectorDenseVector
(double[] x, boolean deep) Constructor for DenseVectorDenseVector
(int size) Constructor for DenseVectorConstructor for DenseVectorConstructor for DenseVectorDenseVector
(Vector x, boolean deep) Constructor for DenseVector -
Method Summary
Modifier and TypeMethodDescriptionx = alpha*y + x
void
add
(int index, double value) x(index) += value
x = y + x
copy()
Creates a deep copy of the vectordouble
xT*y
double
get
(int index) Returnsx(index)
double[]
getData()
Returns the internal vector contents.protected 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
zero()
Zeros all the entries in the vector, while preserving any underlying structureMethods inherited from class no.uib.cipr.matrix.AbstractVector
check, checkSize, iterator, norm, size, toString
Methods 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
-
Constructor Details
-
DenseVector
Constructor for DenseVector- Parameters:
r
- Reader to get vector from- Throws:
IOException
-
DenseVector
public DenseVector(int size) Constructor for DenseVector- Parameters:
size
- Size of the vector
-
DenseVector
Constructor for DenseVector- Parameters:
x
- Copies contents from this vector. A deep copy is made
-
DenseVector
Constructor for DenseVector- Parameters:
x
- Copies contents from this vectordeep
- True for a deep copy. For a shallow copy,x
must 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,x
is 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 Details
-
set
public void set(int index, double value) Description copied from interface:Vector
x(index) = value
- Specified by:
set
in interfaceVector
- Overrides:
set
in classAbstractVector
-
add
public void add(int index, double value) Description copied from interface:Vector
x(index) += value
- Specified by:
add
in interfaceVector
- Overrides:
add
in classAbstractVector
-
get
public double get(int index) Description copied from interface:Vector
Returnsx(index)
- Specified by:
get
in interfaceVector
- Overrides:
get
in classAbstractVector
-
copy
Description copied from interface:Vector
Creates a deep copy of the vector- Specified by:
copy
in interfaceVector
- Overrides:
copy
in classAbstractVector
-
zero
Description copied from interface:Vector
Zeros all the entries in the vector, while preserving any underlying structure- Specified by:
zero
in interfaceVector
- Overrides:
zero
in classAbstractVector
-
scale
Description copied from interface:Vector
x=alpha*x
- Specified by:
scale
in interfaceVector
- Overrides:
scale
in classAbstractVector
- Returns:
- x
-
set
Description copied from interface:Vector
x=y
- Specified by:
set
in interfaceVector
- Overrides:
set
in classAbstractVector
- Returns:
- x
-
set
Description copied from interface:Vector
x=alpha*y
- Specified by:
set
in interfaceVector
- Overrides:
set
in classAbstractVector
- Returns:
- x
-
add
Description copied from interface:Vector
x = y + x
- Specified by:
add
in interfaceVector
- Overrides:
add
in classAbstractVector
- Returns:
- x
-
add
Description copied from interface:Vector
x = alpha*y + x
- Specified by:
add
in interfaceVector
- Overrides:
add
in classAbstractVector
- Returns:
- x
-
dot
Description copied from interface:Vector
xT*y
- Specified by:
dot
in interfaceVector
- Overrides:
dot
in classAbstractVector
-
norm1
protected double norm1()- Overrides:
norm1
in classAbstractVector
-
norm2
protected double norm2()- Overrides:
norm2
in classAbstractVector
-
norm2_robust
protected double norm2_robust()- Overrides:
norm2_robust
in classAbstractVector
-
normInf
protected double normInf()- Overrides:
normInf
in classAbstractVector
-
getData
public double[] getData()Returns the internal vector contents. The array indices correspond to the vector indices
-