symtensor namespace
Namespace for types and free functions directly related to symmetric tensors.
Classes
-
template<std::size_t Order, typename ... Tensors>class Multipole
- Generic multipole type.
-
template<class Implementation, typename ... Tensors>class MultipoleBase
- Multipole base-type for use with CRTP implementations.
-
template<typename Implementation, typename Tuple>class MultipoleBaseFromTuple
- Helper class for defining a multipole based on an std::tuple of tensors.
-
template<std::size_t Order, typename ... Tensors>class MultipoleMoment
- Generic multipole type.
-
template<typename S, std::size_t D, std::size_t R, typename I = Index<D>>class SymmetricTensor
- Generic symmetric tensor type.
-
template<class Implementation, typename S, std::size_t D, std::size_t R, typename I = Index<D>>class SymmetricTensorBase
- Symmetric tensor base-type for use with CRTP implementations.
Typedefs
-
template<std::size_t D>using Index = typename IndexTypeForDimension<D>::type
- Enum-class index type for a given dimension.
- using Quadrupole2f = Multipole2f<2>
- 2d quadrupole with floating point elements
- using Quadrupole3f = Multipole3f<2>
- 3d quadrupole with floating point elements
- using Octupole2f = Multipole2f<3>
- 2d octupole with floating point elements
- using Octupole3f = Multipole3f<3>
- 3d octupole with floating point elements
- using Hexadecupole2f = Multipole2f<4>
- 2d hexadecupole with floating point elements
- using Hexadecupole3f = Multipole3f<4>
- 3d hexadecupole with floating point elements
- using Triacontadyupole2f = Multipole2f<5>
- 2d triacontadyupole with floating point elements
- using Triacontadyupole3f = Multipole3f<5>
- 3d triacontadyupole with floating point elements
-
template<std::size_t Order, typename ... PrefixTensors>using TensorSequence = typename TensorSequenceHelper<Order, PrefixTensors...>::type
- Produces an std::tuple of tensors based on a "prefix" and a desired order.
- using QuadrupoleMoment2f = MultipoleMoment2f<2>
- 2d quadrupole moment with floating point elements
- using QuadrupoleMoment3f = MultipoleMoment3f<2>
- 3d quadrupole moment with floating point elements
- using OctupoleMoment2f = MultipoleMoment2f<3>
- 2d octupole moment with floating point elements
- using OctupoleMoment3f = MultipoleMoment3f<3>
- 3d octupole moment with floating point elements
- using HexadecupoleMoment2f = MultipoleMoment2f<4>
- 2d hexadecupole moment with floating point elements
- using HexadecupoleMoment3f = MultipoleMoment3f<4>
- 3d hexadecupole moment with floating point elements
- using TriacontadyupoleMoment2f = MultipoleMoment2f<5>
- 2d triacontadyupole moment with floating point elements
- using TriacontadyupoleMoment3f = MultipoleMoment3f<5>
- 3d triacontadyupole moment with floating point elements
-
template<class ST, std::size_t R>using ReplaceRank = typename ReplaceRankHelper<R, ST>::type
- Produces a type which modifies the rank of a symmetric tensor.
-
template<class ST>using NextHigherRank = ReplaceRank<ST, ST::Rank+1>
- Given a symmetric tensor type, finds the symmetric tensor of the next higher rank.
-
template<class ST>using NextLowerRank = ReplaceRank<ST, ST::Rank - 1>
- Given a symmetric tensor type, finds the symmetric tensor of the next lower rank.
Functions
- auto numValuesInTensor(std::size_t D, std::size_t R) -> std::size_t constexpr
- Determines the number of indices in a square tensor of rank R and size D.
- auto numUniqueValuesInSymmetricTensor(std::size_t D, std::size_t R) -> std::size_t constexpr
- Determines the number of unique values in a symmetric tensor of rank R and size D.
-
template<std::size_t R, typename I>auto dimensionalIndices(const std::size_t& flatIndex, std::size_t D) -> std::array<I, R> constexpr
- converts a flat index to an equivalent multi-dimensional index.
-
template<std::size_t R, typename I>auto flatIndex(std::array<I, R> dimensionalIndices, std::size_t D, std::size_t lowestIndex = 0) -> std::size_t constexpr
- Converts a multi-dimensional index in a symmetric tensor into a flat index.
Typedef documentation
#include <symtensor/Index.h>
template<std::size_t D>
using symtensor:: Index = typename IndexTypeForDimension<D>::type
Enum-class index type for a given dimension.
For 2d, this contains elements X, Y
, for 3d X, Y, Z
, for 4d W, X, Y, Z
.
using symtensor:: Quadrupole2f = Multipole2f<2>
#include <symtensor/Multipole.h>
2d quadrupole with floating point elements
using symtensor:: Quadrupole3f = Multipole3f<2>
#include <symtensor/Multipole.h>
3d quadrupole with floating point elements
using symtensor:: Octupole2f = Multipole2f<3>
#include <symtensor/Multipole.h>
2d octupole with floating point elements
using symtensor:: Octupole3f = Multipole3f<3>
#include <symtensor/Multipole.h>
3d octupole with floating point elements
using symtensor:: Hexadecupole2f = Multipole2f<4>
#include <symtensor/Multipole.h>
2d hexadecupole with floating point elements
using symtensor:: Hexadecupole3f = Multipole3f<4>
#include <symtensor/Multipole.h>
3d hexadecupole with floating point elements
using symtensor:: Triacontadyupole2f = Multipole2f<5>
#include <symtensor/Multipole.h>
2d triacontadyupole with floating point elements
using symtensor:: Triacontadyupole3f = Multipole3f<5>
#include <symtensor/Multipole.h>
3d triacontadyupole with floating point elements
#include <symtensor/MultipoleBase.h>
template<std::size_t Order, typename ... PrefixTensors>
using symtensor:: TensorSequence = typename TensorSequenceHelper<Order, PrefixTensors...>::type
Produces an std::tuple of tensors based on a "prefix" and a desired order.
Template parameters | |
---|---|
Order | rank of the highest tensor of the sequence, which appears last in the std::tuple |
PrefixTensors | at least one low-order tensor which will be used to define higher order tensors. The last tensor of PrefixTensors is used to produce higher order tensors through repeated use of NextHigherRank. |
The prefix determines the types of the tensors which make up the sequence. For example, the following TensorSequence<3, SymmetricTensor3f<1>>
produces the type:
std::tuple< SymmetricTensor3f<1>, SymmetricTensor3f<2>, SymmetricTensor3f<3> >
The prefix may also contain types which are not symmetric tensors, so long as the final type of the prefix implements SymmetricTensorBase. For example, TensorSequence<3, float, glm::vec3, SymmetricTensor3f<2>>
uses a float
scalar component and a vector from GLM, this produces the type:
std::tuple< float, glm::vec3, SymmetricTensor3f<2>, SymmetricTensor3f<3> >
using symtensor:: QuadrupoleMoment2f = MultipoleMoment2f<2>
#include <symtensor/MultipoleMoment.h>
2d quadrupole moment with floating point elements
using symtensor:: QuadrupoleMoment3f = MultipoleMoment3f<2>
#include <symtensor/MultipoleMoment.h>
3d quadrupole moment with floating point elements
using symtensor:: OctupoleMoment2f = MultipoleMoment2f<3>
#include <symtensor/MultipoleMoment.h>
2d octupole moment with floating point elements
using symtensor:: OctupoleMoment3f = MultipoleMoment3f<3>
#include <symtensor/MultipoleMoment.h>
3d octupole moment with floating point elements
using symtensor:: HexadecupoleMoment2f = MultipoleMoment2f<4>
#include <symtensor/MultipoleMoment.h>
2d hexadecupole moment with floating point elements
using symtensor:: HexadecupoleMoment3f = MultipoleMoment3f<4>
#include <symtensor/MultipoleMoment.h>
3d hexadecupole moment with floating point elements
using symtensor:: TriacontadyupoleMoment2f = MultipoleMoment2f<5>
#include <symtensor/MultipoleMoment.h>
2d triacontadyupole moment with floating point elements
using symtensor:: TriacontadyupoleMoment3f = MultipoleMoment3f<5>
#include <symtensor/MultipoleMoment.h>
3d triacontadyupole moment with floating point elements
#include <symtensor/SymmetricTensorBase.h>
template<class ST, std::size_t R>
using symtensor:: ReplaceRank = typename ReplaceRankHelper<R, ST>::type
Produces a type which modifies the rank of a symmetric tensor.
Template parameters | |
---|---|
ST | symmetric tensor type to replace the rank of |
R | the new rank |
All properties of the symmetric tensor ST are preserved aside from the rank. The type of ReplaceRank<SymmetricTensor3f<3>, 5>
is equivalent to SymmetricTensor3f<5>
.
#include <symtensor/SymmetricTensorBase.h>
template<class ST>
using symtensor:: NextHigherRank = ReplaceRank<ST, ST::Rank+1>
Given a symmetric tensor type, finds the symmetric tensor of the next higher rank.
Template parameters | |
---|---|
ST | a symmetric tensor |
All properties of the symmetric tensor ST are preserved aside from the rank. The type of NextHigherRank<SymmetricTensor3f<3>>
is equivalent to SymmetricTensor3f<4>
.
#include <symtensor/SymmetricTensorBase.h>
template<class ST>
using symtensor:: NextLowerRank = ReplaceRank<ST, ST::Rank - 1>
Given a symmetric tensor type, finds the symmetric tensor of the next lower rank.
Template parameters | |
---|---|
ST | a symmetric tensor |
All properties of the symmetric tensor ST are preserved aside from the rank. The type of NextHigherRank<SymmetricTensor3f<3>>
is equivalent to SymmetricTensor3f<2>
.
Function documentation
std::size_t symtensor:: numValuesInTensor(std::size_t D,
std::size_t R) constexpr
#include <symtensor/Index.h>
Determines the number of indices in a square tensor of rank R and size D.
Parameters | |
---|---|
D | size of the tensor along all axes |
R | rank of the tensor |
Returns | the number of values the the tensor |
Equivalent to .
std::size_t symtensor:: numUniqueValuesInSymmetricTensor(std::size_t D,
std::size_t R) constexpr
#include <symtensor/Index.h>
Determines the number of unique values in a symmetric tensor of rank R and size D.
Parameters | |
---|---|
D | size of the symmetric tensor along all axes |
R | rank of the symmetric tensor |
Returns | the number of unique values in the symmetric tensor (indices xxy, xyx, and yxx are not counted separately). |
Equivalent to Pascal's triangle evaluated at D-1, R.
#include <symtensor/Index.h>
template<std::size_t R, typename I>
std::array<I, R> symtensor:: dimensionalIndices(const std::size_t& flatIndex,
std::size_t D) constexpr
converts a flat index to an equivalent multi-dimensional index.
Template parameters | |
---|---|
R | Rank of the tensor |
I | Index type |
Parameters | |
flatIndex | 1-dimensional index, in the range [0, N) where N can be found using numUniqueValuesInSymmetricTensor |
D | size of the tensor |
Returns | std::array of indices, with type I and size R |
The index is in "canonical" form. For a symmetric tensor, this means the following mapping:
1 --> X, X, Y
2 --> X, X, Z
3 --> X, Y, Y
4 --> X, Y, Z
5 --> X, Z, Z
6 --> Y, Y, Y
7 --> Y, Y, Z
8 --> Y, Z, Z
9 --> Z, Z, Z
#include <symtensor/Index.h>
template<std::size_t R, typename I>
std::size_t symtensor:: flatIndex(std::array<I, R> dimensionalIndices,
std::size_t D,
std::size_t lowestIndex = 0) constexpr
Converts a multi-dimensional index in a symmetric tensor into a flat index.
Template parameters | |
---|---|
R | Rank of the tensor |
I | Index type |
Parameters | |
dimensionalIndices | array of R Index types which specifies a value in the tensor |
D | size of the tensor |
lowestIndex | (implementation detail) |
Returns | the corresponding index in a flat array with no redundant values |
First puts the index in "canonical" form, where indices are sorted as follows:
Next, converts the indices to a flat index using the reverse process of dimensionalIndices()
X, X, Y --> 1
X, X, Z --> 2
X, Y, Y --> 3
X, Y, Z --> 4
X, Z, Z --> 5
Y, Y, Y --> 6
Y, Y, Z --> 7
Y, Z, Z --> 8
Z, Z, Z --> 9