5#include "Eigen/SparseCore"
7 #include <thrust/sort.h>
8 #include <thrust/execution_policy.h>
18template<
typename RealType = Real_t>
39 __host__ __device__
TransSector(
int k = 0,
int systemSize = 0,
int dimLoc = 0)
41 debug_constructor_printf((Default));
46 __host__ __device__
int rep(
int j,
int trans = 0)
const {
48 assert(innerId < this->
basis().nonZeros() &&
"innerId < this->basis().nonZeros()");
52 __host__ __device__
int period(
int j)
const {
53 assert(j < this->
dim() &&
"j < this->dim()");
58template<
typename RealType>
62 debug_constructor_printf(1);
64 if(this->totalSpace().sysSize() == 0) {
return; }
66 this->totalSpace().computeTransEqClass();
67 debug_printf(
"%s:\n\t this->totalSpace().dim()=%d, this->totalSpace().transEqDim()=%d, "
68 "this->totalSpace().transPeriod().sum()=%d\n",
69 __PRETTY_FUNCTION__, this->totalSpace().dim(), this->totalSpace().transEqDim(),
70 this->totalSpace().transPeriod().sum());
71 assert(this->totalSpace().transPeriod().sum() == this->totalSpace().dim());
73 int L = this->totalSpace().sysSize();
75 for(
int eqClass = 0; eqClass < this->totalSpace().transEqDim(); ++eqClass) {
76 if((this->totalSpace().transPeriod(eqClass) * k) % L != 0)
continue;
81 this->basis().resize(this->totalSpace().dim(), dim, this->totalSpace().dim());
83 this->basis().resize(this->totalSpace().dim(), dim);
84 this->basis().reserve(Eigen::VectorXi::Constant(dim, L));
87 int numCompatible = 0, nonZeroId = 0;
88 for(
int eqClass = 0; eqClass != this->totalSpace().transEqDim(); ++eqClass) {
89 if((this->totalSpace().transPeriod(eqClass) * k) % L != 0)
continue;
91 assert(nonZeroId < this->basis().reserved());
92 this->basis().outerIndexPtr()[numCompatible] = nonZeroId;
93 for(
int trans = 0; trans != this->totalSpace().transPeriod(eqClass); ++trans) {
94 this->basis().innerIndexPtr()[nonZeroId]
95 = this->totalSpace().transEqClassRep(eqClass, trans);
96 this->basis().valuePtr()[nonZeroId]
97 = exp(-I * RealType(M_PI * 2 * k * trans / RealType(L)))
98 / RealType(sqrt(RealType(this->totalSpace().transPeriod(eqClass))));
102 for(
int trans = 0; trans != this->totalSpace().transPeriod(eqClass); ++trans) {
103 this->basis().insert(this->totalSpace().transEqClassRep(eqClass, trans), numCompatible)
104 = exp(-I * RealType(M_PI * 2 * k * trans / RealType(L)))
105 / RealType(sqrt(RealType(this->totalSpace().transPeriod(eqClass))));
109 assert(numCompatible <= dim);
111 assert(dim == numCompatible &&
"dim == numCompatible");
112 this->basis().outerIndexPtr()[dim] = nonZeroId;
115 this->basis().setNonZeros(this->basis().outerIndexPtr()[dim]);
116 for(
int eqClass = 0; eqClass != dim; ++eqClass) {
118 thrust::seq, this->basis().innerIndexPtr() + this->basis().outerIndexPtr()[eqClass],
119 this->basis().innerIndexPtr() + this->basis().outerIndexPtr()[eqClass + 1],
120 this->basis().valuePtr() + this->basis().outerIndexPtr()[eqClass]);
123 this->basis().makeCompressed();
Definition mytypes.hpp:147
__host__ __device__ int dim() const
Definition HilbertSpace.hpp:34
Definition HilbertSpace.hpp:423
__host__ __device__ int * innerIndexPtr() const
Definition MatrixUtils.cuh:421
__host__ __device__ int * outerIndexPtr() const
Definition MatrixUtils.cuh:420
Definition HilbertSpace.hpp:568
__host__ __device__ Matrix_t & basis()
Definition HilbertSpace.hpp:668
Translation invariant sector of a many-body Hilbert space.
Definition TransSector.hpp:19
__host__ __device__ TransSector(int k=0, int systemSize=0, int dimLoc=0)
Default constructor.
Definition TransSector.hpp:39
__host__ __device__ int period(int j) const
Definition TransSector.hpp:52
__host__ __device__ TransSector(int k, ManyBodySpinSpace const &mbHSpace)
Construct a TransSector object from a ManyBodySpinSpace object.
int m_momentum
Definition TransSector.hpp:21
__host__ __device__ int momentum() const
Definition TransSector.hpp:44
__host__ __device__ int rep(int j, int trans=0) const
Definition TransSector.hpp:46