next up previous contents index
Next: Matrices with Integer Entries Up: Number Types and Linear Previous: Double-Valued Matrices ( matrix   Contents   Index


Vectors with Integer Entries ( integer_vector )

Definition

An instance of data type integer_vector is a vector of variables of type integer, the so called ring type. Together with the type integer_matrix it realizes the basic operations of linear algebra. Internal correctness tests are executed if compiled with the flag LA_SELFTEST.

#include < LEDA/numbers/integer_vector.h >

Creation

integer_vector v creates an instance v of type integer_vector. v is initialized to the zero-dimensional vector.

integer_vector v(int d) creates an instance v of type integer_vector. v is initialized to a vector of dimension d.

integer_vector v(const integer& a, const integer& b)
    creates an instance v of type integer_vector. v is initialized to the two-dimensional vector (a, b).

integer_vector v(const integer& a, const integer& b, const integer& c)
    creates an instance v of type integer_vector. v is initialized to the three-dimensional vector (a, b, c).

integer_vector v(const integer& a, const integer& b, const integer& c, const integer& d)
    creates an instance v of type integer_vector; v is initialized to the four-dimensional vector (a, b, c, d ).

Operations

int v.dim() returns the dimension of v.

integer& v[int i] returns i-th component of v.
Precondition 0 < = i < = v.dim() - 1.

integer_vector& v += const integer_vector& v1
    Addition plus assignment.
Precondition v.dim() == v1.dim().

integer_vector& v -= const integer_vector& v1
    Subtraction plus assignment.
Precondition v.dim() == v1.dim().

integer_vector v + const integer_vector& v1
    Addition.
Precondition v.dim() == v1.dim().

integer_vector v - const integer_vector& v1
    Subtraction.
Precondition v.dim() == v1.dim().

integer v * const integer_vector& v1
    Inner Product.
Precondition v.dim() == v1.dim().

integer_vector const integer& r * const integer_vector& v
    Componentwise multiplication with number r.

integer_vector const integer_vector& v * const integer& r
    Componentwise multiplication with number r.

ostream& ostream& O « const integer_vector& v
    writes v componentwise to the output stream O.

istream& istream& I » integer_vector& v
    reads v componentwise from the input stream I.

Implementation

Vectors are implemented by arrays of type integer. All operations on a vector v take time O(v.dim()), except for dimension and [ ] which take constant time. The space requirement is O(v.dim()).


next up previous contents index
Next: Matrices with Integer Entries Up: Number Types and Linear Previous: Double-Valued Matrices ( matrix   Contents   Index
root 2008-01-09