DenseVector ConceptA dense-vector is a, exactly as the name says, a dense vector that is intended to behave well for linear algebra operations
DefaultConstructible, RandomAccessContainer and Vector Expression[1].
In addition to the types defined by RandomAccessContainer and Vector Expression
| StorageArray | array_type | The type of underlying storage used to store the elements |
V |
A type that is a model of Vector |
T |
The value_type of elements of V |
v |
Objects of type V |
n, i |
Objects of a type convertible to size_type |
t |
Object of a type convertible to T |
p |
Object of a type convertible to bool |
In addition to the expressions defined in DefaultConstructible and Vector Expression the following expressions must be valid.
| Name | Expression | Type requirements | Return type |
|---|---|---|---|
| Size-constructor | V v(n) |
T is DefaultConstructible | 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 | data() const |
const array_type& |
|
| Storage | data() |
v is mutable |
array_type& |
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 [1] | v[n] |
0<n>v.size() |
returns the n-th element in v | |
| Insert | v.insert_element (i, t) |
0 <= i < v.size () andv (i) is equal to value_type (0). |
A copy of t is inserted in v. |
v (i) is a copy of t. |
| Erase | v.erase_element (i) |
0 <= i < v.size () |
Destroys the element v (i) and replaces it with
value_type (). |
v (i) is a copy of value_type
(). |
| Clear | v.clear () |
Equivalent tofor (i = 0; i < v.size (); ++ i)v.erase (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() |
v is const |
Returns a reference to the underlying storage | |
| Storage | v.data() |
v is mutable |
Returns a reference to the underlying storage |
The run-time complexity of the sizing constructor is linear in the vector's size.
The run-time complexity of insert_element and erase_element is specific for the vector.
The run-time complexity of resize is linear in the vector's size.
vector<T> , bounded_vector<T, N>unit_vector<T> , zero_vector<T> , scalar_vector<T>mapped_vector<T> , compressed_vector , coordinate_vector[1]
As a user you should not care about DenseVector being a refinement of the VectorExpression. Being a refinement of the VectorExpression is only important for the template-expression engine but not the user.
[1]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.