 Container Concepts
Container ConceptsA 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) | vis mutable. | void | 
| Erase | v.erase_element (i) | vis mutable. | void | 
| Clear | v.clear () | vis mutable. | void | 
| Resize | v.resize (n)v.resize (n, p) | vis mutable. | void | 
| Storage | v.data() | vis mutable and Dense. | array_type&ifvis 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 of nelements. | v.size () == n. | 
| Element access [2] | v[n] | 0<n>v.size() | returns the n-th element in v | |
| Insert | v.insert_element (i, t) | 0 <= i < v.size (). | Inserts an element at v (i)with valuet.
The storage requirement of the Vector may be increased. | v (i)is equal tot. | 
| Erase | v.erase_element (i) | 0 <= i < v.size () | Destroys the element as v (i)and replaces it with the defaultvalue_type ().
The storage requirement of the Vector may be decreased. | v (i)is equal tovalue_type (). | 
| Clear | v.clear () | Equivalent to for (i = 0; i < v.size (); ++ i)v.erase_element (i); | ||
| Resize | v.resize (n)
 | Reallocates the vector so that it can hold nelements.Erases or appends elements in order to bring the vector to the prescribed size. Appended elements copies of value_type().When p == falsethen 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 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 model and it depends on increases/decreases in storage requirements.
The run-time complexity of resize is linear in the vector's size.
vector, bounded_vector, c_vectorunit_vector, zero_vector, scalar_vectormapped_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 template-expression 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) | mis mutable. | void | 
| Erase | m.erase_element (i, j) | mis mutable. | void | 
| Clear | m.clear () | mis mutable. | void | 
| Resize | m.resize (n1, n2)m.resize (n1, n2, p) | mis mutable. | void | 
| Storage | m.data() | mis mutable and Dense. | array_type&ifmis 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 >= 0andn2 >= 0 | Allocates a matrix of n1rows andn2columns. | m.size1 () == n1andm.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 valuet.
The storage requirement of the Matrix may be increased. | m (i, j)is equal tot. | 
| Erase | m.erase_element (i, j) | 0 <= i < m.size1 ()and | Destroys the element as m (i, j)and replaces it with the defaultvalue_type ().
The storage requirement of the Matrix may be decreased. | m (i, j)is equal tovalue_type (). | 
| Clear | m.clear () | Equivalent to for (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 n1rows
andn2columns.Erases or appends elements in order to bring the matrix to the prescribed size. Appended elements are value_type()copies.When p == falsethen 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 () == n1andm.size2 () == n2. | |
| Storage | m.data() | Returns a reference to the underlying dense storage. | 
The run-time complexity of the sizing constructor is quadratic in the matrix's size.
The run-time complexity of insert_element and erase_element is specific for the Matrix model and it depends on increases/decreases in storage requirements.
The run-time complexity of resize is quadratic in the matrix's size.
matrix, bounded_matrix, c_matrixidentity_matrix , zero_matrix , scalar_matrixtriangular_matrix , symmetric_matrix , banded_matrixmapped_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 template-expression engine but not the user.
A Tensor describes common aspects of dense multidimensional arrays.
DefaultConstructible, Tensor Expression [1] .
In addition to the types defined by Tensor Expression
| Public base | tensor_container<tensor_t> | tensor_tmust be derived from this public base type. | 
| Storage array | tensor_t::array_type | Dense tensor ONLY. The type of underlying storage array used to store the elements. The array_type must model the Storage concept. | 
| tensor_t | A type that is a model of Tensor | 
| t | Objects of type tensor_t | 
| n1, n2, np, m1, m2, mq  | Dimension objects of a type convertible to size_type | 
| i1, i2, ip, j, k  | Index objects of a type convertible to size_type | 
| v | Object of a type convertible to value_type | 
In addition to the expressions defined in Tensor Expression the following expressions must be valid.
| Name | Expression | Type requirements | Return type | 
|---|---|---|---|
| Sizing constructor | T t(n1, n2, ..., np) | T | |
| Write | t.at(i1, i2, ..., ip) | tis mutable. | void | 
| Read | t.at(i1, i2, ..., ip) | tis mutable. | v | 
| Clear | t.clear () | tis mutable. | void | 
| Resize | t.resize(m1, m2, ... , mq) | tis mutable. | void | 
| Storage | t.data() | tis mutable and dense. | pointeriftis mutable,const_pointerotherwise | 
Semantics of an expression is defined only where it differs from, or is not defined in Tensor Expression .
| Name | Expression | Precondition | Semantics | Postcondition | 
|---|---|---|---|---|
| Sizing constructor | T t(n1, n2, ..., np) | $n_r \geq 1$ for $1\leq 1 \leq p $ | Allocates a p-order tensor with dimension extents $n_1,n_2,\dots,n_p$. | t.size(r)==nrfor $1\leq r \leq p$. | 
| Write | t.at(i1,i2,...,ip)=v | $0 \leq i_r < n_r$ for $1 \leq r \leq p$. | Writes an element at multi-index position $i_1,i_2,\dots,i_p$ with value v. | t(i1,i2,...,ip)is equal tov. | 
| Read | v=t.at(i1,i2,...,ip) | $0 \leq i_r < n_r$ for $1 \leq r \leq p$. | Reads the element at multi-index position $(i_1,i2_,\dots,i_p)$ and returns a value v. | t(i1,i2,...,ip)is equal tov. | 
| Clear | t.clear() | Removes all elements from the container. | ||
| Resize | t.resize(m1, m2, ..., mq) | $m_r \geq 1$ for $1\leq 1 \leq q $ | Reallocate the matrix so that it can hold $m_1\times m_2\times \cdots \times m_q$ elements. Erases or appends elements in order to bring the matrix to the prescribed size. Appended elements are value_type()copies. | t.size(r) == mrfor $1\leq r \leq q$. | 
| Storage | m.data() | Returns a reference to the underlying dense storage. | 
The run-time complexity of contructor is linear in the tensor's size $n_1 \times n_2 \times \cdots \times n_p$.
The run-time complexity of write() and read() is linear in the order of the tensor.
The run-time complexity of resize is at most linear in the tensor's size $m_1 \times m_2 \times \cdots \times n_q$.
tensor[1] As a user you need not care about Tensor being a refinement of the TensorExpression. Being a refinement of the TensorExpression is only important for the template-expression engine but not the user.
Copyright (©) 2000-2002 Joerg Walter, Mathias Koch
Copyright (©) 2018 Cem Bassoy
   Use, modification and distribution are subject to the
   Boost Software License, Version 1.0.
   (See accompanying file LICENSE_1_0.txt
   or copy at 
      http://www.boost.org/LICENSE_1_0.txt
   ).