Celeritas
0.5.0-56+6b053cd
|
Math functions using celeritas::Array. More...
#include <cmath>
#include "corecel/Assert.hh"
#include "corecel/Types.hh"
#include "corecel/cont/Array.hh"
#include "Algorithms.hh"
#include "ArraySoftUnit.hh"
#include "SoftEqual.hh"
#include "detail/ArrayUtilsImpl.hh"
Functions | |
template<class T , size_type N> | |
CELER_FUNCTION void | celeritas::axpy (T a, Array< T, N > const &x, Array< T, N > *y) |
Increment a vector by another vector multiplied by a scalar. More... | |
template<class T , size_type N> | |
CELER_FUNCTION T | celeritas::dot_product (Array< T, N > const &x, Array< T, N > const &y) |
Dot product of two vectors. More... | |
template<class T > | |
CELER_FUNCTION Array< T, 3 > | celeritas::cross_product (Array< T, 3 > const &x, Array< T, 3 > const &y) |
Cross product of two space vectors. | |
template<class T , size_type N> | |
CELER_FUNCTION T | celeritas::norm (Array< T, N > const &v) |
Calculate the Euclidian (2) norm of a vector. | |
template<class T , size_type N> | |
CELER_FUNCTION Array< T, N > | celeritas::make_unit_vector (Array< T, N > const &v) |
Construct a unit vector. More... | |
template<class T , size_type N> | |
CELER_FUNCTION T | celeritas::distance (Array< T, N > const &x, Array< T, N > const &y) |
Calculate the Euclidian (2) distance between two points. | |
template<class T > | |
CELER_FUNCTION Array< T, 3 > | celeritas::from_spherical (T costheta, T phi) |
Calculate a Cartesian vector from spherical coordinates. More... | |
template<class T > | |
CELER_FUNCTION Array< T, 3 > | celeritas::rotate (Array< T, 3 > const &dir, Array< T, 3 > const &rot) |
Rotate the direction about the given Z-based scatter direction. More... | |
Math functions using celeritas::Array.
|
inline |
Increment a vector by another vector multiplied by a scalar.
Note that this uses celeritas::fma
which supports types other than floating point.
|
inline |
Dot product of two vectors.
Note that this uses celeritas::fma
which supports types other than floating point.
|
inline |
Calculate a Cartesian vector from spherical coordinates.
Theta is the angle between the Z axis and the outgoing vector, and phi is the angle between the x axis and the projection of the vector onto the x-y plane.
|
inline |
Construct a unit vector.
Unit vectors have an Euclidian norm magnitude of 1.
|
inline |
Rotate the direction about the given Z-based scatter direction.
The equivalent to calling the Shift transport code's
is the call
This code effectively decomposes the given rotation vector rot
into two sequential transform matrices, one with an angle theta about the y axis and one about phi rotating around the z axis. These two angles are the spherical coordinate transform of the given rot
cartesian direction vector.
There is some extra code in here to deal with loss of precision when the incident direction is along the z axis. As rot
approaches z, the azimuthal angle phi must be calculated carefully from both the x and y components of the vector, not independently. If rot
actually equals z then the azimuthal angle is completely indeterminate so we arbitrarily choose phi
= 0.
This function is often used for calculating exiting scattering angles. In that case, dir
is the exiting angle from the scattering calculation, and rot
is the original direction of the particle. The direction vectors are defined as
\[ \Omega = \sin\theta\cos\phi\mathbf{i} + \sin\theta\sin\phi\mathbf{j} + \cos\theta\mathbf{k} \,. \]