Celeritas
0.5.0-86+4a8eea4
|
Apply a rotation that remaps and possibly flips signs. More...
#include <SignedPermutation.hh>
Public Types | |
Type aliases | |
using | SignedAxis = std::pair< char, Axis > |
using | SignedAxes = EnumArray< Axis, SignedAxis > |
using | StorageSpan = Span< real_type const, 1 > |
using | DataArray = Array< real_type, 1 > |
using | UIntT = short unsigned int |
Public Member Functions | |
SignedPermutation () | |
Construct with an identity permutation. | |
SignedPermutation (SignedAxes permutation) | |
Construct with a permutation vector. | |
CELER_FUNCTION | SignedPermutation (StorageSpan s) |
Construct inline from storage. | |
UIntT | value () const |
Opaque type for hashing and comparison. | |
SignedAxes | permutation () const |
Reconstruct the permutation. | |
DataArray | data () const |
Get a view to the data for type-deleted storage. | |
CELER_FUNCTION Real3 | transform_up (Real3 const &pos) const |
Transform from daughter to parent. | |
CELER_FUNCTION Real3 | transform_down (Real3 const &parent_pos) const |
Transform from parent to daughter. | |
CELER_FUNCTION Real3 | rotate_up (Real3 const &dir) const |
Rotate from daughter to parent. | |
CELER_FUNCTION Real3 | rotate_down (Real3 const &parent_dir) const |
Rotate from parent to daughter. | |
Apply a rotation that remaps and possibly flips signs.
A signed permutation matrix is a special matrix that has only one entry with the value of \(\pm1\) in each row and each column. This is a specialized rotation matrix that, when applied to a vector, simply exchanges the locations and/or flips the signs of the vector entries.
This class stores a special version of the daughter-to-parent rotation matrix:
\[ \mathbf{R} = \begin{bmatrix} \mathbf{e}_x \\ \hline \mathbf{e}_y \\ \hline \mathbf{e}_z \end{bmatrix} \]
where \( \mathbf{e}_u \) has exactly one entry with a value \( \pm 1 \) and the other entries are zero.
The underlying storage are a compressed series of bits in little-endian form that indicate the positions of the nonzero entry followed by the sign:
[flip z'][z' axis][flip y'][y' axis][flip x'][x' axis] 8 7 6 5 4 3 2 1 0 bit position *
This allows the "rotate up" to simply copy one value at a time into a new position, and optionally flip the sign of the result.
Construction of this class takes a length 3 array of SignedAxis
values. The sign is a '+' or '-' character and the axis is the position of the nonzero component in that row.
Note that the unsigned integer type (UIntT) is at least 16 bits, which is sufficient accurately round-trip through a floating point value.