9#include "Eigen/SparseCore"
17 #include <thrust/host_vector.h>
18 #include <thrust/device_vector.h>
19 #include <thrust/execution_policy.h>
25template<
class Derived =
int>
31template<
class Derived>
34 __host__ __device__
int dim()
const {
35 return static_cast<Derived const*
>(
this)->dim_impl();
41 return this->
dim() == other.
dim();
104 return this->
dim() == other.
dim();
108 __host__ __device__
int dim()
const {
return m_dim; };
113template<
typename Derived>
115template<
typename Derived>
117template<
typename Derived>
119 int* srcTransPeriod);
129template<
class Derived>
134 mutable struct cudaFuncAttributes
attr;
159 debug_constructor_printf(1);
160 debug_printf(
"\tlocSpace.dim() = %d\n\n",
locSpace.dim());
171 debug_constructor_printf(2);
172 debug_printf(
"\tlocSpace.dim() = %d\n\n",
locSpace.dim());
182 template<
typename... Args>
185 debug_constructor_printf(3);
205 debug_constructor_printf((Copy));
220 debug_constructor_printf((Move));
244 debug_printf(
"%s:\n\tMove assignment operator.\n\n", __PRETTY_FUNCTION__);
251 return *
static_cast<Derived*
>(
this);
267 __host__ __device__
int locState(
int state,
int pos)
const {
268 return static_cast<Derived const*
>(
this)->locState_impl(state, pos);
279 for(
int l = 0; l != this->
sysSize(); ++l) std::cout <<
" " << config(l);
280 std::cout << std::endl;
281 return static_cast<Derived const&
>(*this);
284 return static_cast<Derived const*
>(
this)->ordinalToConfig_impl(basisNum);
286 template<
class EigenDerived>
287 __host__ __device__
int configToOrdinal(Eigen::DenseBase<EigenDerived>& config)
const {
288 return static_cast<Derived const*
>(
this)->configToOrdinal_impl(config);
300 __host__ __device__
int translate(
int state,
int trans)
const {
301 return static_cast<Derived const*
>(
this)->translate_impl(state, trans);
303 template<
class EigenDerived>
305 Eigen::DenseBase<EigenDerived>& work)
const {
306 return static_cast<Derived const*
>(
this)->translate_impl(state, trans, work);
314 return this->
translate(m_transEqClassRep[
id], trans);
347 __host__ __device__
int reverse(
int state)
const {
348 return static_cast<Derived const*
>(
this)->reverse_impl(state);
356template<
class Derived>
358 debug_printf(
"%s:\n\tComputing trans equivalent class... (this->dim()=%d, m_transEqDim=%d)\n",
359 __PRETTY_FUNCTION__, this->dim(), m_transEqDim);
360 if(m_transEqDim != -1) {
361 debug_printf(
"%s:\tTrans equivalent class is already computed. m_transEqDim=%d\n", __func__,
365 if(this->dim() <= 0) {
366 debug_printf(
"%s:\tDimension of the space is ZERO (this->dim() = %d)\n", __func__,
372 Eigen::ArrayX<bool> calculated = Eigen::ArrayX<bool>::Zero(this->dim());
374 for(
int basis = 0; basis < this->dim(); ++basis) {
375 if(calculated(basis))
continue;
376 calculated(basis) =
true;
377 for(period = 1; period < this->sysSize(); ++period) {
378 translated = this->translate(basis, period);
379 if(basis == translated)
break;
380 calculated(translated) =
true;
385 m_transEqClassRep.resize(m_transEqDim);
386 m_transPeriod.resize(m_transEqDim);
387 m_stateToTransEqClass.resize(this->dim());
389 calculated = Eigen::ArrayX<bool>::Zero(this->dim());
390 for(
int basis = 0; basis < this->dim(); ++basis) {
391 if(calculated(basis))
continue;
392 calculated(basis) =
true;
393 m_stateToTransEqClass(basis) = num;
395 for(period = 1; period < this->sysSize(); ++period) {
396 translated = this->translate(basis, period);
397 if(basis == translated)
break;
398 calculated(translated) =
true;
399 m_stateToTransEqClass(translated) = num;
401 m_transEqClassRep(num) = basis;
402 m_transPeriod(num) = period;
405 debug_printf(
"\t(END) Computed trans equivalent classes (m_transEqDim=%d)\n\n", m_transEqDim);
408template<
class Derived>
410 m_parityPair.resize(this->dim());
411 for(
auto j = 0; j != this->dim(); ++j) {
412 auto reversed = this->reverse(j);
413 m_parityPair(j) = reversed;
414 m_parityPair(reversed) = j;
439 debug_constructor_printf(1);
450 debug_constructor_printf(2);
461 debug_constructor_printf((Default));
474 Eigen::RowVectorXi res;
478 template<
class EigenDerived>
486 template<
class EigenDerived>
488 Eigen::DenseBase<EigenDerived>&)
const {
493 int res = 0, base = 1;
494 for(
int pos = 0; pos != this->
sysSize(); ++pos, base *= this->
dimLoc()) {
522 debug_constructor_printf((Default));
526 debug_constructor_printf(1);
539 Eigen::RowVectorXi res;
543 template<
class EigenDerived>
551 template<
class EigenDerived>
553 Eigen::DenseBase<EigenDerived>&)
const {
558 Eigen::ArrayXi config1(this->
sysSize());
560 Eigen::ArrayXi config2(this->
sysSize());
561 for(
int pos = 0; pos != this->
sysSize(); ++pos)
562 config2[pos] = config1[this->
sysSize() - 1 - pos];
567template<
class TotalSpace_,
typename ScalarType_ = Complex_t<Real_t>>
572 using Real =
typename Eigen::NumTraits<ScalarType_>::Real;
592 debug_constructor_printf(1);
602 debug_constructor_printf(2);
614 template<
typename Scalar_>
640 debug_printf(
"%s:\n\tCopy assignment operator.\n\n", __PRETTY_FUNCTION__);
652 debug_printf(
"%s:\n\tMove assignment operator.\n\n", __PRETTY_FUNCTION__);
__global__ void setTransEqDim_kernel(ManyBodySpaceBase< Derived > *obj, int transEqDim)
Definition ManyBodySpaceBase.cuh:68
__global__ void copyTransEqClass_kernel(ManyBodySpaceBase< Derived > *obj, int *srcTransEqClassRep, int *srcTransPeriod)
Definition ManyBodySpaceBase.cuh:76
Provides utilities for converting an integer to the corresponding expression in the positional notati...
Definition BaseNnumber.hpp:19
__host__ __device__ Integer digit(Integer const num, Integer const pos, Integer const base, Integer const length) const
Returns the (pos)-th digit of the input (num) in given base and length.
Definition BaseNnumber.hpp:113
__host__ __device__ Integer maxVal() const
Definition BaseNnumber.hpp:57
__host__ __device__ Integer shiftDigits(Integer const num, Integer const trans, Integer const base, Integer const length) const
Shifts a number (num) to right by (trans) in terms of the positional notation with given base and len...
Definition BaseNnumber.hpp:139
__host__ __device__ Integer digitsToNumber(Input const &digits, Integer const base, Integer const length) const
Converts an array of integers to the corresponding integer in terms of the positional notation with g...
Definition BaseNnumber.hpp:166
__host__ __device__ auto printInDigits(Output &output, Integer const num, Integer const base, Integer const length) const -> typename std::enable_if< std::is_integral< Output >::value==false, BaseConverter const & >::type
Expresses an integer (num) in the positional notation with given (base) and (length)
Definition BaseNnumber.hpp:191
Definition HilbertSpace.hpp:47
__host__ __device__ HilbertSpace()=default
Default constructor.
__host__ __device__ int dim() const
Definition HilbertSpace.hpp:108
__host__ __device__ HilbertSpace & operator=(HilbertSpace &&other)=default
Move assignment operator.
__host__ __device__ HilbertSpace & operator=(HilbertSpace const &other)=default
Copy assignment operator.
__host__ __device__ HilbertSpace(HilbertSpace &&other)=default
Move constructor.
__host__ __device__ bool operator==(HilbertSpace const &other) const
Equality operator.
Definition HilbertSpace.hpp:103
__host__ __device__ ~HilbertSpace()=default
Destructor.
__host__ __device__ HilbertSpace(HilbertSpace const &other)=default
Copy constructor.
__host__ __device__ HilbertSpace(int dim)
Constructor.
Definition HilbertSpace.hpp:57
Definition HilbertSpace.hpp:32
__host__ __device__ bool operator==(HilbertSpace const &other) const
Definition HilbertSpace.hpp:40
__host__ __device__ int dim() const
Definition HilbertSpace.hpp:34
Lists a weak composition of an integer N up to length L with a constraint that each summand does not ...
Definition IntegerComposition.hpp:57
__host__ __device__ int locNumber(Index_ const num, Index_ const pos) const
Definition IntegerComposition.hpp:253
__host__ __device__ Index_t dim() const
Definition IntegerComposition.hpp:90
__host__ __device__ void ordinalToPart(Vector_t &vec, Index_t const num) const
Converts an ordinal number of a composition of the integer N to a vector form.
Definition IntegerComposition.hpp:225
__host__ __device__ Index_t translate(Index_t const num, int trans, Vector_t &workSpace) const
Definition IntegerComposition.hpp:283
__host__ __device__ Index_t partToOrdinal(Vector_t const &vec) const
Converts an composition of the integer N from a vector form to an ordinal number.
Definition IntegerComposition.hpp:209
Definition HilbertSpace.hpp:506
__host__ __device__ int reverse_impl(int state) const
Definition HilbertSpace.hpp:557
__host__ __device__ int locState_impl(int state, int pos) const
Definition HilbertSpace.hpp:534
__host__ __device__ int configToOrdinal_impl(Eigen::DenseBase< EigenDerived > &config) const
Definition HilbertSpace.hpp:544
__host__ __device__ int translate_impl(int state, int trans, Eigen::DenseBase< EigenDerived > &) const
Definition HilbertSpace.hpp:552
typename HilbertSpaceTraits< ManyBodyBosonSpace >::LocalSpace LocalSpace
Definition HilbertSpace.hpp:512
__host__ __device__ ManyBodyBosonSpace(int systemSize, int nBosons, int max)
Definition HilbertSpace.hpp:524
__host__ __device__ int dim_impl() const
Definition HilbertSpace.hpp:531
__host__ __device__ ManyBodyBosonSpace(int systemSize=0, int nBosons=0)
Default constructor.
Definition HilbertSpace.hpp:520
__host__ __device__ Eigen::RowVectorXi ordinalToConfig_impl(int basisNum) const
Definition HilbertSpace.hpp:538
IntegerComposition m_iComp
Definition HilbertSpace.hpp:508
__host__ __device__ int translate_impl(int state, int trans) const
Definition HilbertSpace.hpp:548
ManyBodySpinSpace defined by , where.
Definition HilbertSpace.hpp:130
__host__ __device__ ManyBodySpaceBase()=default
Default constructor.
__host__ __device__ LocSpace_t const & locSpace() const
Definition HilbertSpace.hpp:264
int m_systemSize
Definition HilbertSpace.hpp:141
bool gotKernelAttribute
Definition HilbertSpace.hpp:135
Eigen::VectorX< int > Vector_t
Definition HilbertSpace.hpp:139
Vector_t m_parityPair
Definition HilbertSpace.hpp:147
__host__ __device__ int translate(int state, int trans) const
Translate the input state to the left by one.
Definition HilbertSpace.hpp:300
__host__ __device__ ManyBodySpaceBase(int systemSize, LocSpace_t &&locSpace)
Constructor2.
Definition HilbertSpace.hpp:169
__host__ __device__ ~ManyBodySpaceBase()=default
Destructor.
__host__ __device__ Vector_t const & parityPair() const
Definition HilbertSpace.hpp:350
__host__ __device__ Vector_t const & stateToTransEqClass() const
Definition HilbertSpace.hpp:320
__host__ __device__ int dimLoc() const
Definition HilbertSpace.hpp:266
int m_transEqDim
Definition HilbertSpace.hpp:143
__host__ __device__ Vector_t const & transPeriod() const
Definition HilbertSpace.hpp:317
__host__ __device__ ManyBodySpaceBase(int systemSize, Args... args)
Constructor3.
Definition HilbertSpace.hpp:183
__host__ __device__ bool operator==(ManyBodySpaceBase const &other) const
Equality operator.
Definition HilbertSpace.hpp:259
__host__ __device__ int transPeriod(int id) const
Definition HilbertSpace.hpp:318
__host__ __device__ int transEqDim() const
Definition HilbertSpace.hpp:309
__host__ __device__ int configToOrdinal(Eigen::DenseBase< EigenDerived > &config) const
Definition HilbertSpace.hpp:287
__host__ __device__ int parityPair(int state) const
Definition HilbertSpace.hpp:351
__host__ __device__ int stateToTransEqClass(int state) const
Definition HilbertSpace.hpp:323
__host__ __device__ ManyBodySpaceBase(ManyBodySpaceBase &&other)
Move constructor.
Definition HilbertSpace.hpp:212
__host__ Derived const & printInString(int basisNum) const
Print a basis state specified by the input (basisNum) in a string of integers.
Definition HilbertSpace.hpp:277
typename HilbertSpaceTraits< Derived >::LocalSpace LocSpace_t
Definition HilbertSpace.hpp:132
__host__ __device__ ManyBodySpaceBase & operator=(ManyBodySpaceBase const &other)=delete
Copy assignment operator (deleted)
__host__ __device__ int translate(int state, int trans, Eigen::DenseBase< EigenDerived > &work) const
Definition HilbertSpace.hpp:304
__host__ __device__ void computeTransEqClass() const
Definition HilbertSpace.hpp:357
__host__ __device__ ManyBodySpaceBase(int systemSize, LocSpace_t const &locSpace)
Constructor1.
Definition HilbertSpace.hpp:157
__host__ __device__ int stateToTransPeriod(int state) const
Definition HilbertSpace.hpp:326
__host__ __device__ Eigen::RowVectorXi ordinalToConfig(int basisNum) const
Definition HilbertSpace.hpp:283
Vector_t m_transPeriod
Definition HilbertSpace.hpp:145
__host__ __device__ void computeParityPair() const
Definition HilbertSpace.hpp:409
Vector_t m_stateToTransEqClass
Definition HilbertSpace.hpp:146
LocSpace_t m_locSpace
Definition HilbertSpace.hpp:142
__host__ __device__ ManyBodySpaceBase(ManyBodySpaceBase const &other)
Copy constructor.
Definition HilbertSpace.hpp:197
__host__ __device__ Derived & operator=(ManyBodySpaceBase &&other)
Move assignment operator.
Definition HilbertSpace.hpp:243
struct cudaFuncAttributes attr
Definition HilbertSpace.hpp:134
__host__ __device__ int transEqClassRep(int id, int trans) const
Definition HilbertSpace.hpp:313
__host__ __device__ int reverse(int state) const
Reverse the input state.
Definition HilbertSpace.hpp:347
Vector_t m_transEqClassRep
Definition HilbertSpace.hpp:144
__host__ __device__ int transEqClassRep(int id) const
Definition HilbertSpace.hpp:312
__host__ __device__ int locState(int state, int pos) const
Definition HilbertSpace.hpp:267
__host__ __device__ int sysSize() const
Definition HilbertSpace.hpp:265
__host__ __device__ Vector_t const & transEqClassRep() const
Definition HilbertSpace.hpp:311
Definition HilbertSpace.hpp:423
__host__ __device__ Eigen::RowVectorXi ordinalToConfig_impl(int basisNum) const
Definition HilbertSpace.hpp:473
__host__ __device__ int configToOrdinal_impl(Eigen::DenseBase< EigenDerived > &config) const
Definition HilbertSpace.hpp:479
__host__ __device__ int locState_impl(int state, int pos) const
Definition HilbertSpace.hpp:469
BaseConverter< int > m_bConv
Definition HilbertSpace.hpp:425
__host__ __device__ int reverse_impl(int state) const
Definition HilbertSpace.hpp:492
__host__ __device__ int dim_impl() const
Definition HilbertSpace.hpp:466
typename HilbertSpaceTraits< ManyBodySpinSpace >::LocalSpace LocalSpace
Definition HilbertSpace.hpp:429
__host__ __device__ ManyBodySpinSpace(int systemSize, LocalSpace const &locSpace)
Constructor1.
Definition HilbertSpace.hpp:437
__host__ __device__ ManyBodySpinSpace(int systemSize, LocalSpace &&locSpace)
Constructor2.
Definition HilbertSpace.hpp:448
__host__ __device__ int translate_impl(int state, int trans, Eigen::DenseBase< EigenDerived > &) const
Definition HilbertSpace.hpp:487
__host__ __device__ ManyBodySpinSpace(int systemSize=0, int dimLoc=0)
Default constructor.
Definition HilbertSpace.hpp:459
__host__ __device__ int translate_impl(int state, int trans) const
Definition HilbertSpace.hpp:483
__host__ __device__ int & cols()
Definition MatrixUtils.cuh:403
Definition HilbertSpace.hpp:568
__host__ __device__ SubSpace(TotalSpace const &totalSpace)
Construct a SubSpace object by copying totalSpace to its member variable (m_totalSpace)
Definition HilbertSpace.hpp:590
Matrix_t m_basisStates
Definition HilbertSpace.hpp:581
typename Eigen::NumTraits< ScalarType_ >::Real Real
Definition HilbertSpace.hpp:572
__host__ __device__ Matrix_t & basis()
Definition HilbertSpace.hpp:668
__host__ __device__ int dimTot() const
Definition HilbertSpace.hpp:672
__host__ __device__ SubSpace(SubSpace< TotalSpace_, Scalar_ > const &other)
Definition HilbertSpace.hpp:615
__host__ __device__ Matrix_t const & basis() const
Definition HilbertSpace.hpp:669
ScalarType_ Scalar
Definition HilbertSpace.hpp:571
__host__ __device__ SubSpace & operator=(SubSpace &&other)
Move assignment operator.
Definition HilbertSpace.hpp:651
__host__ __device__ TotalSpace const & totalSpace() const
Definition HilbertSpace.hpp:671
__host__ __device__ SubSpace(SubSpace const &other)=default
Copy constructor.
__host__ __device__ SubSpace & operator=(SubSpace const &other)
Copy assignment operator.
Definition HilbertSpace.hpp:639
__host__ __device__ int dim_impl() const
Definition HilbertSpace.hpp:676
TotalSpace_ TotalSpace
Definition HilbertSpace.hpp:570
TotalSpace m_totalSpace
Definition HilbertSpace.hpp:580
__host__ __device__ SubSpace()=default
Default constructor.
__host__ __device__ bool operator==(SubSpace const &other) const
Equality operator.
Definition HilbertSpace.hpp:663
__host__ __device__ SubSpace(SubSpace &&other)=default
Move constructor.
__host__ __device__ ~SubSpace()=default
Destructor.
__host__ __device__ SubSpace(TotalSpace &&totalSpace)
Construct a SubSpace object by moving totalSpace to its member variable (m_totalSpace)
Definition HilbertSpace.hpp:600
Definition HilbertSpace.hpp:23