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
Class AbstractVector

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

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

Direct Known Subclasses:
  DenseVector, DistVector, SparseVector

    public abstract class AbstractVector

extends java.lang.Object
implements Vector, java.io.Serializable

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)` and `set(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:
  Serialized Form

Nested Class Summary

Nested classes/interfaces inherited from interface no.uib.cipr.matrix.Vector
`Vector.Norm`

Field Summary
`protected int` | `size` Size of the vector

Constructor Summary
`protected` | `AbstractVector(int size)` Constructor for AbstractVector.
`protected` | `AbstractVector(Vector x)` Constructor for AbstractVector, same size as x

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`
`protected void` | `check(int index)` Checks the index
`protected void` | `checkSize(Vector y)` Checks for conformant sizes
`Vector` | `copy()` Creates a deep copy of the vector
`double` | `dot(Vector y)` `xT*y`
`double` | `get(int index)` Returns `x(index)`
`java.util.Iterator<VectorEntry>` | `iterator()`
`double` | `norm(Vector.Norm type)` Computes the given norm of the vector
`protected double` | `norm1()`
`protected double` | `norm2_robust()`
`protected double` | `norm2()`
`protected double` | `normInf()`
`Vector` | `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`
`int` | `size()` Size of the vector
`java.lang.String` | `toString()`
`Vector` | `zero()` Zeros all the entries in the vector, while preserving any underlying structure

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

Field Detail

### size

    protected int size

  Size of the vector

Constructor Detail

### AbstractVector

    protected AbstractVector(int size)

  Constructor for AbstractVector.

  Parameters:
    `size` - Size of the vector

### AbstractVector

    protected AbstractVector(Vector x)

  Constructor for AbstractVector, same size as x

  Parameters:
    `x` - Vector to get the size from

Method Detail

### size

    public int size()

  Description copied from interface: `Vector`
  Size of the vector

  Specified by:
    `size` in interface `Vector`

### set

    public void set(int index,
                    double value)

  Description copied from interface: `Vector`
  `x(index) = value`

  Specified by:
    `set` in interface `Vector`

### add

    public void add(int index,
                    double value)

  Description copied from interface: `Vector`
  `x(index) += value`

  Specified by:
    `add` in interface `Vector`

### get

    public double get(int index)

  Description copied from interface: `Vector`
  Returns `x(index)`

  Specified by:
    `get` in interface `Vector`

### copy

    public Vector copy()

  Description copied from interface: `Vector`
  Creates a deep copy of the vector

  Specified by:
    `copy` in interface `Vector`

### check

    protected void check(int index)

  Checks the index

### zero

    public Vector zero()

  Description copied from interface: `Vector`
  Zeros all the entries in the vector, while preserving any underlying structure

  Specified by:
    `zero` in interface `Vector`

### scale

    public Vector scale(double alpha)

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

  Specified by:
    `scale` in interface `Vector`
  Returns:
    x

### set

    public Vector set(Vector y)

  Description copied from interface: `Vector`
  `x=y`

  Specified by:
    `set` in interface `Vector`
  Returns:
    x

### set

    public Vector set(double alpha,
                      Vector y)

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

  Specified by:
    `set` in interface `Vector`
  Returns:
    x

### add

    public Vector add(Vector y)

  Description copied from interface: `Vector`
  `x = y + x`

  Specified by:
    `add` in interface `Vector`
  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`
  Returns:
    x

### dot

    public double dot(Vector y)

  Description copied from interface: `Vector`
  `xT*y`

  Specified by:
    `dot` in interface `Vector`

### checkSize

    protected void checkSize(Vector y)

  Checks for conformant sizes

### norm

    public double norm(Vector.Norm type)

  Description copied from interface: `Vector`
  Computes the given norm of the vector

  Specified by:
    `norm` in interface `Vector`
  Parameters:
    `type` - The type of norm to compute

### norm1

    protected double norm1()

### norm2

    protected double norm2()

### norm2_robust

    protected double norm2_robust()

### normInf

    protected double normInf()

### iterator

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

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

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD