26 #include "MathUtilities.h" 
   40 inline std::string 
to_string(
const SpinVector& two_j)
 
   42     return std::accumulate(two_j.begin(), two_j.end(), std::string(
""),
 
   43                            [](
const std::string & s, 
const SpinVector::value_type & j)
 
   48 inline std::string 
to_string(
const SpinProjectionVector& two_m)
 
   50     return std::accumulate(two_m.begin(), two_m.end(), std::string(
""),
 
   51                            [](
const std::string & s, 
const SpinProjectionVector::value_type & m)
 
   60 constexpr 
bool triangle(
unsigned two_a, 
unsigned two_b, 
unsigned two_c)
 
   61 { 
return is_even(two_a + two_b + two_c) and 
std::abs((
int)two_a - (
int)two_b) <= (int)two_c and two_c <= (two_a + two_b); }
 
   68 constexpr 
bool conserves(
unsigned two_J, 
unsigned two_j1, 
unsigned two_j2, 
int l)
 
   71     return is_even(two_J + two_j1 + two_j2)
 
   72            and (std::min<int>(two_j1 + two_j2, two_J + 2 * l) >= std::max(
std::abs((
int)two_j1 - (
int)two_j2), 
std::abs((
int)two_J - 2 * l)));
 
   79     SpinProjectionVector spv;
 
   80     spv.reserve(two_j + 1);
 
   81     for (
int two_m = -two_j; two_m <= (int)two_j; two_m += 2)
 
   88 inline const std::vector<SpinProjectionVector> 
projections(
const SpinVector& two_J)
 
   91     std::vector<int> two_M;
 
   92     two_M.reserve(two_J.size());
 
   93     std::transform(two_J.begin(), two_J.end(), std::back_inserter(two_M),
 
   94     [](
const SpinVector::value_type & two_j) {
return -two_j;});
 
   96     std::vector<SpinProjectionVector> SPV;
 
   98     while (two_M.back() <= (int)two_J.back()) {
 
  101         for (
size_t i = 0; (i < two_M.size() - 1) and (two_M[i] > (
int)two_J[i]); ++i) {
 
  102             two_M[i] = -two_J[i];
 
const SpinProjectionVector projections(unsigned two_j)
Definition: Spin.h:77
constexpr bool conserves(unsigned two_J, unsigned two_j1, unsigned two_j2, int l)
Definition: Spin.h:68
constexpr T abs(const Vector< T, N > &A)
Definition: Vector.h:371
constexpr bool triangle(unsigned two_a, unsigned two_b, unsigned two_c)
Definition: Spin.h:60
constexpr bool is_even(int val)
Definition: MathUtilities.h:34
std::string to_string(const SpinProjectionVector &two_m)
convert SpinVector to string 
Definition: Spin.h:48
std::string spin_to_string(int twoJ)
convert 2*J to string (e.g. 1/2, 1, 3/2, etc.) 
Definition: Spin.h:36
std::string to_string(const CachedValue::Status &S)
streaming operator for CachedValue::Status 
Definition: CachedValue.cxx:27