|
| | SparseTensor () |
| | no value is set, Indices default to -1
|
| |
| template<class Topology > |
| | SparseTensor (const Topology &grid) |
| | Construct the unit tensor.
|
| |
| | SparseTensor (const container ©able) |
| | Construct the unit tensor.
|
| |
| template<class Topology > |
| void | construct (const Topology &grid) |
| | Construct the unit tensor.
|
| |
| void | construct (const container ©able) |
| | Construct the unit tensor.
|
| |
| template<class OtherContainer > |
| | SparseTensor (const SparseTensor< OtherContainer > &src) |
| | Type conversion from other value types.
|
| |
| int | idx (unsigned i, unsigned j) const |
| | read index into the values array at the given position
|
| |
| int & | idx (unsigned i, unsigned j) |
| | write index into the values array at the given position
|
| |
| const container & | value (size_t i, size_t j) const |
| | Read access the underlying container.
|
| |
| std::vector< container > & | values () |
| | Return write access to the values array.
|
| |
| const std::vector< container > & | values () const |
| | Return read access to the values array.
|
| |
| SparseTensor | transpose () const |
| | Return the transpose of the currrent tensor.
|
| |
template<class container>
struct dg::SparseTensor< container >
Class for 2x2 and 3x3 matrices sharing elements.
This class enables shared access to stored containers. It contains a (dense) 3x3 matrix of integers that is automatically allocated. The integers represent a gather index into a stored array of containers. In this way duplicate entries are stored only once, which helps to avoid unnecessary memory accesses. For example an orthogonal metric is represented as follows
\[
\begin{pmatrix}
g^{xx} & 0 & 0\\
0 & g^{yy} & 0 \\
0 & 0 & g^{zz}
\end{pmatrix}
\quad\rightarrow\quad
\text{idx} = \begin{pmatrix}
1 & 0 & 0 \\
0 & 2 & 0 \\
0 & 0 & 3
\end{pmatrix} \quad \text{values} = \begin{pmatrix}
0 & g^{xx} & g^{yy} & g^{zz}
\end{pmatrix}
\]
which in code can be assembled as
metric.
idx(0,0) = 1, metric.
idx(0,1) = 0, metric.
idx(0,2) = 0;
metric.
idx(1,0) = 0, metric.
idx(1,1) = 2, metric.
idx(1,2) = 0;
metric.
idx(2,0) = 0, metric.
idx(2,1) = 0, metric.
idx(2,2) = 3;
std::vector<dg::HVec> values( 4);
- Template Parameters
-
| container | must be default constructible and copyable. |
- See also
- dg::tensor