|
| SparseTensor () |
| no value is set, Indices default to -1 More...
|
|
template<class Topology > |
| SparseTensor (const Topology &grid) |
| Construct the unit tensor. More...
|
|
| SparseTensor (const container ©able) |
| Construct the unit tensor. More...
|
|
template<class Topology > |
void | construct (const Topology &grid) |
| Construct the unit tensor. More...
|
|
void | construct (const container ©able) |
| Construct the unit tensor. More...
|
|
template<class OtherContainer > |
| SparseTensor (const SparseTensor< OtherContainer > &src) |
| Type conversion from other value types. More...
|
|
int | idx (unsigned i, unsigned j) const |
| read index into the values array at the given position More...
|
|
int & | idx (unsigned i, unsigned j) |
| write index into the values array at the given position More...
|
|
const container & | value (size_t i, size_t j) const |
| Read access the underlying container. More...
|
|
std::vector< container > & | values () |
| Return write access to the values array. More...
|
|
const std::vector< container > & | values () const |
| Return read access to the values array. More...
|
|
SparseTensor | transpose () const |
| Return the transpose of the currrent tensor. More...
|
|
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(2,2) = 0;
metric.
idx(2,0) = 0, metric.
idx(2,1) = 0, metric.
idx(2,2) = 3;
std::vector<dg::HVec>
values( 4);
static DG_DEVICE double zero(double x)
Definition: functions.h:29
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
Evaluate a 1d function on grid coordinates.
Definition: evaluation.h:67
ContainerType determinant(const SparseTensor< ContainerType > &t)
Definition: multiply.h:349
thrust::host_vector< double > HVec
Host Vector.
Definition: typedefs.h:19
Class for 2x2 and 3x3 matrices sharing elements.
Definition: tensor.h:66
int idx(unsigned i, unsigned j) const
read index into the values array at the given position
Definition: tensor.h:134
std::vector< container > & values()
Return write access to the values array.
Definition: tensor.h:166
- Template Parameters
-
container | must be default constructible and copyable. |
- See also
- dg::tensor