no.uib.cipr.matrix
Class DenseVector

java.lang.Object
  extended by no.uib.cipr.matrix.AbstractVector
      extended by 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 a double[] 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
DenseVector(double[] x)
          Constructor for DenseVector
DenseVector(double[] x, boolean deep)
          Constructor for DenseVector
DenseVector(int size)
          Constructor for DenseVector
DenseVector(MatrixVectorReader r)
          Constructor for DenseVector
DenseVector(Vector x)
          Constructor for DenseVector
DenseVector(Vector x, boolean deep)
          Constructor for DenseVector
 
Method Summary
 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
 DenseVector copy()
          Creates a deep copy of the vector
 double dot(Vector y)
          xT*y
 double get(int index)
          Returns x(index)
 double[] getData()
          Returns the internal vector contents.
protected  double norm1()
           
protected  double norm2_robust()
           
protected  double norm2()
           
protected  double normInf()
           
 DenseVector 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
 DenseVector zero()
          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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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 vector
deep - True for a deep copy. For a shallow copy, x must be a DenseVector

DenseVector

public DenseVector(double[] x,
                   boolean deep)
Constructor for DenseVector

Parameters:
x - Copies contents from this array
deep - 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 Detail

set

public void set(int index,
                double value)
Description copied from interface: Vector
x(index) = value

Specified by:
set in interface Vector
Overrides:
set in class AbstractVector

add

public void add(int index,
                double value)
Description copied from interface: Vector
x(index) += value

Specified by:
add in interface Vector
Overrides:
add in class AbstractVector

get

public double get(int index)
Description copied from interface: Vector
Returns x(index)

Specified by:
get in interface Vector
Overrides:
get in class AbstractVector

copy

public DenseVector copy()
Description copied from interface: Vector
Creates a deep copy of the vector

Specified by:
copy in interface Vector
Overrides:
copy in class AbstractVector

zero

public DenseVector zero()
Description copied from interface: Vector
Zeros all the entries in the vector, while preserving any underlying structure

Specified by:
zero in interface Vector
Overrides:
zero in class AbstractVector

scale

public DenseVector scale(double alpha)
Description copied from interface: Vector
x=alpha*x

Specified by:
scale in interface Vector
Overrides:
scale in class AbstractVector
Returns:
x

set

public Vector set(Vector y)
Description copied from interface: Vector
x=y

Specified by:
set in interface Vector
Overrides:
set in class AbstractVector
Returns:
x

set

public Vector set(double alpha,
                  Vector y)
Description copied from interface: Vector
x=alpha*y

Specified by:
set in interface Vector
Overrides:
set in class AbstractVector
Returns:
x

add

public Vector add(Vector y)
Description copied from interface: Vector
x = y + x

Specified by:
add in interface Vector
Overrides:
add in class AbstractVector
Returns:
x

add

public Vector add(double alpha,
                  Vector y)
Description copied from interface: Vector
x = alpha*y + x

Specified by:
add in interface Vector
Overrides:
add in class AbstractVector
Returns:
x

dot

public double dot(Vector y)
Description copied from interface: Vector
xT*y

Specified by:
dot in interface Vector
Overrides:
dot in class AbstractVector

norm1

protected double norm1()
Overrides:
norm1 in class AbstractVector

norm2

protected double norm2()
Overrides:
norm2 in class AbstractVector

norm2_robust

protected double norm2_robust()
Overrides:
norm2_robust in class AbstractVector

normInf

protected double normInf()
Overrides:
normInf in class AbstractVector

getData

public double[] getData()
Returns the internal vector contents. The array indices correspond to the vector indices