SparseVector

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## no.uib.cipr.matrix.sparse
Class SparseVector

    java.lang.Object
      no.uib.cipr.matrix.AbstractVector
          no.uib.cipr.matrix.sparse.SparseVector

All Implemented Interfaces:
  java.io.Serializable, java.lang.Iterable<VectorEntry>, ISparseVector, Vector

    public class SparseVector

extends AbstractVector
implements ISparseVector

Sparse vector

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
`SparseVector(int size)` Constructor for SparseVector.
`SparseVector(int size, int nz)` Constructor for SparseVector.
`SparseVector(int size, int[] index, double[] data)` Constructor for SparseVector
`SparseVector(int size, int[] index, double[] data, boolean deep)` Constructor for SparseVector
`SparseVector(Vector x)` Constructor for SparseVector, and copies the contents from the supplied vector.
`SparseVector(Vector x, boolean deep)` Constructor for SparseVector, and copies the contents from the supplied vector.

Method Summary
`void` | `add(int index, double value)` `x(index) += value`
`void` | `compact()` Compacts the vector
`SparseVector` | `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 data
`int[]` | `getIndex()` Returns the indices
`int` | `getUsed()` Number of entries used in the sparse structure
`java.util.Iterator<VectorEntry>` | `iterator()`
`protected double` | `norm1()`
`protected double` | `norm2_robust()`
`protected double` | `norm2()`
`protected double` | `normInf()`
`SparseVector` | `scale(double alpha)` `x=alpha*x`
`void` | `set(int index, double value)` `x(index) = value`
`Vector` | `set(Vector y)` `x=y`
`SparseVector` | `zero()` Zeros all the entries in the vector, while preserving any underlying structure

Methods inherited from class no.uib.cipr.matrix.AbstractVector
`add, add, check, checkSize, norm, set, size, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface no.uib.cipr.matrix.Vector
`add, add, norm, set, size`

Constructor Detail

### SparseVector

    public SparseVector(int size,
                        int nz)

  Constructor for SparseVector.

  Parameters:
    `size` - Size of the vector
    `nz` - Initial number of non-zeros

### SparseVector

    public SparseVector(Vector x,
                        boolean deep)

  Constructor for SparseVector, and copies the contents from the supplied vector.

  Parameters:
    `x` - Vector to copy from
    `deep` - True if a deep copy is to be made. If the copy is shallow, `x` must be a `SparseVector`

### SparseVector

    public SparseVector(Vector x)

  Constructor for SparseVector, and copies the contents from the supplied vector. Zero initial pre-allocation

  Parameters:
    `x` - Vector to copy from. A deep copy is made

### SparseVector

    public SparseVector(int size)

  Constructor for SparseVector. Zero initial pre-allocation

  Parameters:
    `size` - Size of the vector

### SparseVector

    public SparseVector(int size,
                        int[] index,
                        double[] data,
                        boolean deep)

  Constructor for SparseVector

  Parameters:
    `size` - Size of the vector
    `index` - Indices of the vector
    `data` - Entries of the vector
    `deep` - True for a deep copy. For shallow copies, the given indices will be used internally

### SparseVector

    public SparseVector(int size,
                        int[] index,
                        double[] data)

  Constructor for SparseVector

  Parameters:
    `size` - Size of the vector
    `index` - The vector indices are copies from this array
    `data` - The vector entries are copies from this array

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 SparseVector 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 SparseVector 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 SparseVector scale(double alpha)

  Description copied from interface: `Vector`
  `x=alpha*x`

  Specified by:
    `scale` in interface `Vector`
  Overrides:
    `scale` 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 data

### getIndex

    public int[] getIndex()

  Returns the indices

  Specified by:
    `getIndex` in interface `ISparseVector`

### getUsed

    public int getUsed()

  Number of entries used in the sparse structure

  Specified by:
    `getUsed` in interface `ISparseVector`

### compact

    public void compact()

  Compacts the vector

### iterator

    public java.util.Iterator<VectorEntry> iterator()

  Specified by:
    `iterator` in interface `java.lang.Iterable<VectorEntry>`
  Overrides:
    `iterator` in class `AbstractVector`

### 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

Overview | Package | Class | Use | Tree | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD