...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
A Vector describes common aspects of dense, packed and sparse vectors.
DefaultConstructible, Vector Expression [1].
In addition to the types defined by Vector Expression
Public base  vector_container<V>  V must be derived from this public base type. 
Storage array  V::array_type  Dense Vector ONLY. The type of underlying storage array used to store the elements. The array_type must model the Storage concept. 
V 
A type that is a model of Vector 
v 
Objects of type V 
n, i 
Objects of a type convertible to size_type 
t 
Object of a type convertible to value_type 
p 
Object of a type convertible to bool 
In addition to the expressions defined in DefaultConstructible, Vector Expression the following expressions must be valid.
Name  Expression  Type requirements  Return type 

Sizing constructor  V v (n) 
V 

Insert  v.insert_element (i, t) 
v is mutable. 
void 
Erase  v.erase_element (i) 
v is mutable. 
void 
Clear  v.clear () 
v is mutable. 
void 
Resize  v.resize (n) v.resize (n, p) 
v is mutable. 
void 
Storage  v.data() 
v is mutable and Dense. 
array_type& if a is mutable, const array_type& otherwise 
Semantics of an expression is defined only where it differs from, or is not defined in Vector Expression .
Name  Expression  Precondition  Semantics  Postcondition 

Sizing constructor  V v (n) 
n >= 0 
Allocates a vector ofn elements. 
v.size () == n . 
Element access [2]  v[n] 
0<n>v.size() 
returns the nth element in v  
Insert  v.insert_element (i, t) 
0 <= i < v.size () . 
Inserts an element at v (i) with value t .
The storage requirement of the Vector may be increased. 
v (i) is equal to t . 
Erase  v.erase_element (i) 
0 <= i < v.size () 
Destroys the element as v (i) and replaces it with the default
value_type () .
The storage requirement of the Vector may be decreased. 
v (i) is equal to value_type () . 
Clear  v.clear () 
Equivalent tofor (i = 0; i < v.size (); ++ i) v.erase_element (i); 

Resize  v.resize (n)

Reallocates the vector so that it can hold n
elements.Erases or appends elements in order to bring the vector to the prescribed size. Appended elements copies of value_type() .
When p == false then existing elements are not preserved and elements will not appended as normal. Instead the vector is in the same state as that after an equivalent sizing constructor. 
v.size () == n . 

Storage  v.data() 
Returns a reference to the underlying dense storage. 
The runtime complexity of the sizing constructor is linear in the vector's size.
The runtime complexity of insert_element and erase_element is specific for the Vector model and it depends on increases/decreases in storage requirements.
The runtime complexity of resize is linear in the vector's size.
vector
, bounded_vector
, c_vector
unit_vector
, zero_vector
, scalar_vector
mapped_vector;
, compressed_vector
, coordinate_vector
[1] As a user you need not care about Vector being a refinement of the VectorExpression. Being a refinement of the VectorExpression is only important for the templateexpression engine but not the user.
[2]
The operator[]
is added purely for convenience
and compatibility with the std::vector
. In uBLAS however,
generally operator()
is used for indexing because this can be
used for both vectors and matrices.
A Matrix describes common aspects of dense, packed and sparse matrices.
DefaultConstructible, Matrix Expression [1] .
In addition to the types defined by Matrix Expression
Public base  matrix_container<M>  M must be derived from this public base type. 
Storage array  M::array_type  Dense Matrix ONLY. The type of underlying storage array used to store the elements. The array_type must model the Storage concept. 
M 
A type that is a model of Matrix 
m 
Objects of type M 
n1, n2, i, j 
Objects of a type convertible to size_type 
t 
Object of a type convertible to value_type 
p 
Object of a type convertible to bool 
In addition to the expressions defined in Matrix Expression the following expressions must be valid.
Name  Expression  Type requirements  Return type 

Sizing constructor  M m (n1, n2) 
M 

Insert  m.insert_element (i, j, t) 
m is mutable. 
void 
Erase  m.erase_element (i, j) 
m is mutable. 
void 
Clear  m.clear () 
m is mutable. 
void 
Resize  m.resize (n1, n2) m.resize (n1, n2, p) 
m is mutable. 
void 
Storage  m.data() 
m is mutable and Dense. 
array_type& if a is mutable, const array_type& otherwise 
Semantics of an expression is defined only where it differs from, or is not defined in Matrix Expression .
Name  Expression  Precondition  Semantics  Postcondition 

Sizing constructor  M m (n1, n2) 
n1 >= 0 and n2 >= 0 
Allocates a matrix of n1 rows and n2
columns. 
m.size1 () == n1 and m.size2 () ==
n2 . 
Insert  m.insert_element (i, j, t) 
0 <= i < m.size1 () ,0 <= j < m.size2 () . 
Inserts an element at m (i, j) with value t .
The storage requirement of the Matrix may be increased. 
m (i, j) is equal to t . 
Erase  m.erase_element (i, j) 
0 <= i < m.size1 () and

Destroys the element as m (i, j) and replaces it with the default
value_type () .
The storage requirement of the Matrix may be decreased. 
m (i, j) is equal to value_type () . 
Clear  m.clear () 
Equivalent tofor (i = 0; i < m.size1 (); ++ i) for (j = 0; j < m.size2 (); ++ j) m.erase_element (i, j); 

Resize  m.resize (n1, n2)

Reallocate the matrix so that it can hold n1 rows
and n2 columns.Erases or appends elements in order to bring the matrix to the prescribed size. Appended elements are value_type()
copies.When p == false then existing elements are not preserved and elements will not appended as normal. Instead the matrix is in the same state as that after an equivalent sizing constructor. 
m.size1 () == n1 and m.size2 () == n2 . 

Storage  m.data() 
Returns a reference to the underlying dense storage. 
The runtime complexity of the sizing constructor is quadratic in the matrix's size.
The runtime complexity of insert_element and erase_element is specific for the Matrix model and it depends on increases/decreases in storage requirements.
The runtime complexity of resize is quadratic in the matrix's size.
matrix
, bounded_matrix
, c_matrix
identity_matrix
, zero_matrix
, scalar_matrix
triangular_matrix
, symmetric_matrix
, banded_matrix
mapped_matrix
, compressed_matrix
, coordinate_matrix
[1] As a user you need not care about Matrix being a refinement of the MatrixExpression. Being a refinement of the MatrixExpression is only important for the templateexpression engine but not the user.
Copyright (©) 20002002 Joerg Walter, Mathias Koch
Permission to copy, use, modify, sell and distribute this document
is granted provided this copyright notice appears in all copies.
This document is provided ``as is'' without express or implied
warranty, and with no claim as to its suitability for any
purpose.