next up previous contents index
Next: Matrices with Integer Entries Up: Number Types and Linear Previous: Real-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/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(integer a, integer b) creates an instance v of type integer_vector. v is initialized to the two-dimensional vector (a, b).

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

integer_vector v(integer a, integer b, integer c, 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 += v1 Addition plus assignment.
Precondition v.dim() == v1.dim().

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

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

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

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

integer_vector integer r * v Componentwise multiplication with number r.

integer_vector v * integer r Componentwise multiplication with number r.

ostream& ostream& O << 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: Real-Valued Matrices ( matrix   Contents   Index
LEDA research project
2000-02-09