7#include <unsupported/Eigen/CXX11/Tensor>
9#include "ClebschGordan.h"
12#include <gsl/gsl_sf_coupling.h>
14#include <boost/rational.hpp>
28template<std::
size_t N,
typename Scalar>
32 template<Index Rank>
using TensorType = Eigen::Tensor<Scalar,Rank,Eigen::ColMajor,Index>;
34 typedef std::array<int,1>
qType;
40 static constexpr std::size_t
Nq=1;
44 static std::string
name() { std::stringstream ss; ss <<
"SU(" <<
N <<
")";
return ss.str(); }
68 template<std::
size_t M>
69 static bool compare ( std::array<qType,M> q1, std::array<qType,M> q2 );
71 template<std::
size_t M>
72 static bool validate( std::array<qType,M> qs );
77template<std::
size_t N,
typename Scalar>
81 clebsch::weight wl(
N,ql[0]-1), wr(
N,qr[0]-1), W(
N,Q[0]-1);
82 clebsch::coefficients
cgc(W,wl,wr);
83 Index dimwl = wl.dimension(),
84 dimwr = wr.dimension(),
87 for (
Index i = 0; i < dimW; ++i) {
88 for (
Index j = 0; j < dimwl; ++j) {
89 for (
Index k = 0; k < dimwr; ++k)
91 double x = Scalar(
cgc(j, k, 0, i));
92 if (std::abs(x) > clebsch::EPS)
102template<std::
size_t N,
typename Scalar>
106 std::vector<typename SUN<N,Scalar>::qType> vout;
107 int qmin = std::abs(ql[0]-qr[0]) +1;
108 int qmax = std::abs(ql[0]+qr[0]) -1;
109 for (
int i=qmin; i<=qmax; i+=2 ) { vout.push_back({i}); }
113template<std::
size_t N,
typename Scalar>
117 std::vector<typename SUN<N,Scalar>::qType> vout;
118 for (std::size_t q=0; q<ql.size(); q++)
120 int qmin = std::abs(ql[q][0]-qr[0]) +1;
121 int qmax = std::abs(ql[q][0]+qr[0]) -1;
122 for (
int i=qmin; i<=qmax; i+=2 ) { vout.push_back({i}); }
127template<std::
size_t N,
typename Scalar>
128template<std::
size_t M>
130compare ( std::array<qType,M> q1, std::array<qType,M> q2 )
132 for (std::size_t m=0; m<
M; m++)
134 if (q1[m][0] < q2[m][0]) {
return false; }
135 else if (q1[m][0] > q2[m][0]) {
return true; }
140template<std::
size_t N,
typename Scalar>
141template<std::
size_t M>
145 if constexpr(
M > 1 )
148 for (std::size_t i=2; i<
M; i++)
152 for (std::size_t i=0; i<decomp.size(); i++)
158 else {
return true; }
161template<std::
size_t N,
typename Scalar>
167 for (
Index mInt=0; mInt<
dim; mInt++)
169 Tout(mInt,
dim-1-mInt) = std::pow(Scalar(-1),mInt)*pow(Scalar(-1),Scalar(
dim-1));
175template<std::
size_t N,
typename Scalar>
180 std::cout <<
dim << std::endl;
182 for (
Index mInt=0; mInt<
dim; mInt++)
184 Tout(mInt,
dim-1-mInt) = std::pow(Scalar(-1),mInt);
189template<std::
size_t N,
typename Scalar>
193 Scalar out = std::pow(
static_cast<Scalar
>(q1[0]),Scalar(0.5)) * std::pow(
static_cast<Scalar
>(q2[0]),Scalar(-0.5))*
194 std::pow(Scalar(-1.),Scalar(0.5)*
static_cast<Scalar
>(q3[0]+q1[0]-q2[0]-1));
198template<std::
size_t N,
typename Scalar>
203 Scalar out = gsl_sf_coupling_6j(q1[0]-1,q2[0]-1,q3[0]-1,
204 q4[0]-1,q5[0]-1,q6[0]-1)*
205 std::pow(
static_cast<Scalar
>(q3[0]*q6[0]),Scalar(0.5))*
206 std::pow(Scalar(-1.),Scalar(0.5)*
static_cast<Scalar
>(q1[0]+q5[0]+q6[0]-3));
210template<std::
size_t N,
typename Scalar>
216 Scalar out = gsl_sf_coupling_9j(q1[0]-1,q2[0]-1,q3[0]-1,
217 q4[0]-1,q5[0]-1,q6[0]-1,
218 q7[0]-1,q8[0]-1,q9[0]-1)*
219 std::pow(
static_cast<Scalar
>(q7[0]*q8[0]*q3[0]*q6[0]),Scalar(0.5));
227 boost::rational<int> s = boost::rational<int>(q[0]-1,2);
228 if (s.numerator() == 0) {os <<
" " << 0 <<
" ";}
229 else if (s.denominator() == 1) {os <<
" " << s.numerator() <<
" ";}
size_t dim(const PivotMatrix0< Symmetry, Scalar, MpoScalar > &H)
double cgc(int j1x2, int j2x2, int Jx2, int m1x2, int m2x2, int Mx2)
std::ostream & operator<<(std::ostream &os, const typename Sym::SUN< 2, double >::qType &q)
static std::vector< qType > reduceSilent(qType ql, qType qr)
static constexpr bool SPECIAL
static Eigen::Tensor< Scalar, 2 > calcCapTensor(qType q)
static TensorType< 3 > reduce(qType ql, qType qr, qType Q)
static std::string name()
std::array< int, 1 > qType
static Eigen::Tensor< Scalar, 2 > calcCupTensor(qType q)
Eigen::Tensor< Scalar, Rank, Eigen::ColMajor, Index > TensorType
static Scalar coeff_buildR(const qType &q1, const qType &q2, const qType &q3, const qType &q4, const qType &q5, const qType &q6, const qType &q7, const qType &q8, const qType &q9)
static constexpr bool HAS_CGC
static bool compare(std::array< qType, M > q1, std::array< qType, M > q2)
static constexpr std::size_t Nq
static bool validate(std::array< qType, M > qs)
static Scalar coeff_adjoint(const qType &q1, const qType &q2, const qType &q3)
static int degeneracy(const qType &q)
static qType flip(const qType &q)
static Scalar coeff_Apair(const qType &q1, const qType &q2, const qType &q3, const qType &q4, const qType &q5, const qType &q6)
bool operator==(const typename SUN< N, Scalar >::qType &lhs, const typename SUN< N, Scalar >::qType &rhs)