StatMech
Loading...
Searching...
No Matches
ManyBodySpaceBase< Derived > Class Template Reference

ManyBodySpinSpace \(\mathcal{H}\) defined by \(\mathcal{H} \coloneqq \mathcal{H}_{\mathrm{loc}}^{\otimes L}\), where. More...

#include <HilbertSpace.hpp>

Inheritance diagram for ManyBodySpaceBase< Derived >:
Inheritance graph
Collaboration diagram for ManyBodySpaceBase< Derived >:
Collaboration graph

Public Member Functions

__host__ __device__ ManyBodySpaceBase (int systemSize, LocSpace_t const &locSpace)
 Constructor1.
 
__host__ __device__ ManyBodySpaceBase (int systemSize, LocSpace_t &&locSpace)
 Constructor2.
 
template<typename... Args>
__host__ __device__ ManyBodySpaceBase (int systemSize, Args... args)
 Constructor3.
 
__host__ __device__ ManyBodySpaceBase ()=default
 Default constructor.
 
__host__ __device__ ManyBodySpaceBase (ManyBodySpaceBase const &other)
 Copy constructor.
 
__host__ __device__ ManyBodySpaceBase (ManyBodySpaceBase &&other)
 Move constructor.
 
__host__ __device__ ~ManyBodySpaceBase ()=default
 Destructor.
 
Operator overloads
__host__ __device__ ManyBodySpaceBaseoperator= (ManyBodySpaceBase const &other)=delete
 Copy assignment operator (deleted)
 
__host__ __device__ Derived & operator= (ManyBodySpaceBase &&other)
 Move assignment operator.
 
__host__ __device__ bool operator== (ManyBodySpaceBase const &other) const
 Equality operator.
 
__host__ __device__ LocSpace_t const & locSpace () const
 
__host__ __device__ int sysSize () const
 
__host__ __device__ int dimLoc () const
 
__host__ __device__ int locState (int state, int pos) const
 
__host__ Derived const & printInString (int basisNum) const
 Print a basis state specified by the input (basisNum) in a string of integers.
 
__host__ __device__ Eigen::RowVectorXi ordinalToConfig (int basisNum) const
 
template<class EigenDerived >
__host__ __device__ int configToOrdinal (Eigen::DenseBase< EigenDerived > &config) const
 
Parity operation
__host__ __device__ int reverse (int state) const
 Reverse the input state.
 
__host__ __device__ Vector_t const & parityPair () const
 
__host__ __device__ int parityPair (int state) const
 
__host__ __device__ void computeParityPair () const
 
- Public Member Functions inherited from HilbertSpace< Derived >
__host__ __device__ int dim () const
 
__host__ __device__ bool operator== (HilbertSpace const &other) const
 

Protected Types

using Vector_t = Eigen::VectorX< int >
 

Protected Attributes

int m_systemSize = 0
 
LocSpace_t m_locSpace
 
int m_transEqDim = -1
 
Vector_t m_transEqClassRep
 
Vector_t m_transPeriod
 
Vector_t m_stateToTransEqClass
 
Vector_t m_parityPair
 

Private Types

using LocSpace_t = typename HilbertSpaceTraits< Derived >::LocalSpace
 

Private Attributes

struct cudaFuncAttributes attr
 
bool gotKernelAttribute = false
 

Translation operation

__host__ __device__ int translate (int state, int trans) const
 Translate the input state to the left by one.
 
template<class EigenDerived >
__host__ __device__ int translate (int state, int trans, Eigen::DenseBase< EigenDerived > &work) const
 
__host__ __device__ int transEqDim () const
 
__host__ __device__ Vector_t const & transEqClassRep () const
 
__host__ __device__ int transEqClassRep (int id) const
 
__host__ __device__ int transEqClassRep (int id, int trans) const
 
__host__ __device__ Vector_t const & transPeriod () const
 
__host__ __device__ int transPeriod (int id) const
 
__host__ __device__ Vector_t const & stateToTransEqClass () const
 
__host__ __device__ int stateToTransEqClass (int state) const
 
__host__ __device__ int stateToTransPeriod (int state) const
 
__host__ __device__ void computeTransEqClass () const
 
void setTransEqDim_kernel (ManyBodySpaceBase *, int)
 
void copyTransEqClass_kernel (ManyBodySpaceBase *, int *, int *)
 

Detailed Description

template<class Derived>
class ManyBodySpaceBase< Derived >

ManyBodySpinSpace \(\mathcal{H}\) defined by \(\mathcal{H} \coloneqq \mathcal{H}_{\mathrm{loc}}^{\otimes L}\), where.

  • \(L\): System size
  • \(\mathrm{dimLoc}\): Dimension of the local Hilbert space \(\mathcal{H}_{\mathrm{loc}}\)
    Note
    Now only a homogeneous tensor product of local Hilbert spaces is supported.
    Template Parameters
    int
    Container

Member Typedef Documentation

◆ LocSpace_t

template<class Derived >
using ManyBodySpaceBase< Derived >::LocSpace_t = typename HilbertSpaceTraits<Derived>::LocalSpace
private

◆ Vector_t

template<class Derived >
using ManyBodySpaceBase< Derived >::Vector_t = Eigen::VectorX<int>
protected

Constructor & Destructor Documentation

◆ ManyBodySpaceBase() [1/6]

template<class Derived >
__host__ __device__ ManyBodySpaceBase< Derived >::ManyBodySpaceBase ( int  systemSize,
LocSpace_t const &  locSpace 
)
inline

Constructor1.

Parameters
systemSize
locSpace
Returns
host
158 : m_systemSize{systemSize}, m_locSpace{locSpace} {
159 debug_constructor_printf(1);
160 debug_printf("\tlocSpace.dim() = %d\n\n", locSpace.dim());
161 }
__host__ __device__ LocSpace_t const & locSpace() const
Definition HilbertSpace.hpp:264
int m_systemSize
Definition HilbertSpace.hpp:141
LocSpace_t m_locSpace
Definition HilbertSpace.hpp:142

◆ ManyBodySpaceBase() [2/6]

template<class Derived >
__host__ __device__ ManyBodySpaceBase< Derived >::ManyBodySpaceBase ( int  systemSize,
LocSpace_t &&  locSpace 
)
inline

Constructor2.

Parameters
systemSize
locSpace
Returns
host
170 : m_systemSize{systemSize}, m_locSpace{std::move(locSpace)} {
171 debug_constructor_printf(2);
172 debug_printf("\tlocSpace.dim() = %d\n\n", locSpace.dim());
173 }

◆ ManyBodySpaceBase() [3/6]

template<class Derived >
template<typename... Args>
__host__ __device__ ManyBodySpaceBase< Derived >::ManyBodySpaceBase ( int  systemSize,
Args...  args 
)
inline

Constructor3.

Template Parameters
ArgsTypes of arguments for a constructor of LocSpace_t
Parameters
systemSize
argsArguments for a constructor of LocSpace_t
184 : ManyBodySpaceBase(systemSize, LocSpace_t(args...)) {
185 debug_constructor_printf(3);
186 }
__host__ __device__ ManyBodySpaceBase()=default
Default constructor.
typename HilbertSpaceTraits< Derived >::LocalSpace LocSpace_t
Definition HilbertSpace.hpp:132

◆ ManyBodySpaceBase() [4/6]

template<class Derived >
__host__ __device__ ManyBodySpaceBase< Derived >::ManyBodySpaceBase ( )
default

Default constructor.

◆ ManyBodySpaceBase() [5/6]

template<class Derived >
__host__ __device__ ManyBodySpaceBase< Derived >::ManyBodySpaceBase ( ManyBodySpaceBase< Derived > const &  other)
inline

Copy constructor.

Parameters
other
198 : HilbertSpace<Derived>(other),
199 m_systemSize(other.m_systemSize),
200 m_locSpace(other.m_locSpace),
201 m_transEqDim(other.m_transEqDim),
202 m_transEqClassRep{other.m_transEqClassRep},
203 m_transPeriod{other.m_transPeriod},
204 m_stateToTransEqClass{other.m_stateToTransEqClass} {
205 debug_constructor_printf((Copy));
206 }
Definition HilbertSpace.hpp:32
int m_transEqDim
Definition HilbertSpace.hpp:143
Vector_t m_transPeriod
Definition HilbertSpace.hpp:145
Vector_t m_stateToTransEqClass
Definition HilbertSpace.hpp:146
Vector_t m_transEqClassRep
Definition HilbertSpace.hpp:144

◆ ManyBodySpaceBase() [6/6]

template<class Derived >
__host__ __device__ ManyBodySpaceBase< Derived >::ManyBodySpaceBase ( ManyBodySpaceBase< Derived > &&  other)
inline

Move constructor.

Parameters
other
213 : HilbertSpace<Derived>(other),
215 m_locSpace(other.m_locSpace),
217 m_transEqClassRep{std::move(other.m_transEqClassRep)},
218 m_transPeriod{std::move(other.m_transPeriod)},
220 debug_constructor_printf((Move));
221 }

◆ ~ManyBodySpaceBase()

template<class Derived >
__host__ __device__ ManyBodySpaceBase< Derived >::~ManyBodySpaceBase ( )
default

Destructor.

Member Function Documentation

◆ computeParityPair()

template<class Derived >
__host__ __device__ void ManyBodySpaceBase< Derived >::computeParityPair
409 {
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;
415 }
416}
__host__ __device__ int dim() const
Definition HilbertSpace.hpp:34
Vector_t m_parityPair
Definition HilbertSpace.hpp:147
__host__ __device__ int reverse(int state) const
Reverse the input state.
Definition HilbertSpace.hpp:347

◆ computeTransEqClass()

template<class Derived >
__host__ void ManyBodySpaceBase< Derived >::computeTransEqClass
357 {
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__,
363 return;
364 }
365 if(this->dim() <= 0) {
366 debug_printf("%s:\tDimension of the space is ZERO (this->dim() = %d)\n", __func__,
367 this->dim());
368 return;
369 }
370 int translated;
371 int period = 0;
372 Eigen::ArrayX<bool> calculated = Eigen::ArrayX<bool>::Zero(this->dim());
373 m_transEqDim = 0;
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;
381 }
382 m_transEqDim += 1;
383 }
384
387 m_stateToTransEqClass.resize(this->dim());
388 int num = 0;
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;
394
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;
400 }
401 m_transEqClassRep(num) = basis;
402 m_transPeriod(num) = period;
403 num += 1;
404 }
405 debug_printf("\t(END) Computed trans equivalent classes (m_transEqDim=%d)\n\n", m_transEqDim);
406}
__host__ __device__ int translate(int state, int trans) const
Translate the input state to the left by one.
Definition HilbertSpace.hpp:300
__host__ __device__ int sysSize() const
Definition HilbertSpace.hpp:265

◆ configToOrdinal()

template<class Derived >
template<class EigenDerived >
__host__ __device__ int ManyBodySpaceBase< Derived >::configToOrdinal ( Eigen::DenseBase< EigenDerived > &  config) const
inline
287 {
288 return static_cast<Derived const*>(this)->configToOrdinal_impl(config);
289 }

◆ dimLoc()

template<class Derived >
__host__ __device__ int ManyBodySpaceBase< Derived >::dimLoc ( ) const
inline
266{ return m_locSpace.dim(); }

◆ locSpace()

template<class Derived >
__host__ __device__ LocSpace_t const & ManyBodySpaceBase< Derived >::locSpace ( ) const
inline
264{ return m_locSpace; }

◆ locState()

template<class Derived >
__host__ __device__ int ManyBodySpaceBase< Derived >::locState ( int  state,
int  pos 
) const
inline
267 {
268 return static_cast<Derived const*>(this)->locState_impl(state, pos);
269 }

◆ operator=() [1/2]

template<class Derived >
__host__ __device__ Derived & ManyBodySpaceBase< Derived >::operator= ( ManyBodySpaceBase< Derived > &&  other)
inline

Move assignment operator.

Parameters
other
Returns
*this
243 {
244 debug_printf("%s:\n\tMove assignment operator.\n\n", __PRETTY_FUNCTION__);
246 m_locSpace = other.m_locSpace;
248 m_transEqClassRep = std::move(other.m_transEqClassRep);
249 m_transPeriod = std::move(other.m_transPeriod);
251 return *static_cast<Derived*>(this);
252 }

◆ operator=() [2/2]

template<class Derived >
__host__ __device__ ManyBodySpaceBase & ManyBodySpaceBase< Derived >::operator= ( ManyBodySpaceBase< Derived > const &  other)
delete

Copy assignment operator (deleted)

Parameters
other
Returns
*this

◆ operator==()

template<class Derived >
__host__ __device__ bool ManyBodySpaceBase< Derived >::operator== ( ManyBodySpaceBase< Derived > const &  other) const
inline

Equality operator.

Parameters
other
Returns
bool
259 {
260 return m_locSpace == other.locSpace() && m_systemSize == other.sysSize();
261 }

◆ ordinalToConfig()

template<class Derived >
__host__ __device__ Eigen::RowVectorXi ManyBodySpaceBase< Derived >::ordinalToConfig ( int  basisNum) const
inline
283 {
284 return static_cast<Derived const*>(this)->ordinalToConfig_impl(basisNum);
285 }

◆ parityPair() [1/2]

template<class Derived >
__host__ __device__ Vector_t const & ManyBodySpaceBase< Derived >::parityPair ( ) const
inline
350{ return m_parityPair; }

◆ parityPair() [2/2]

template<class Derived >
__host__ __device__ int ManyBodySpaceBase< Derived >::parityPair ( int  state) const
inline
351{ return m_parityPair[state]; }

◆ printInString()

template<class Derived >
__host__ Derived const & ManyBodySpaceBase< Derived >::printInString ( int  basisNum) const
inline

Print a basis state specified by the input (basisNum) in a string of integers.

Parameters
basisNum
Returns
A const reference to itself
277 {
278 Eigen::RowVectorXi config = this->ordinalToConfig(basisNum);
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);
282 }
__host__ __device__ Eigen::RowVectorXi ordinalToConfig(int basisNum) const
Definition HilbertSpace.hpp:283

◆ reverse()

template<class Derived >
__host__ __device__ int ManyBodySpaceBase< Derived >::reverse ( int  state) const
inline

Reverse the input state.

Parameters
[in]state
[in]trans
Returns
int
347 {
348 return static_cast<Derived const*>(this)->reverse_impl(state);
349 }

◆ stateToTransEqClass() [1/2]

template<class Derived >
__host__ __device__ Vector_t const & ManyBodySpaceBase< Derived >::stateToTransEqClass ( ) const
inline
320 {
322 }

◆ stateToTransEqClass() [2/2]

template<class Derived >
__host__ __device__ int ManyBodySpaceBase< Derived >::stateToTransEqClass ( int  state) const
inline
323 {
324 return m_stateToTransEqClass[state];
325 };

◆ stateToTransPeriod()

template<class Derived >
__host__ __device__ int ManyBodySpaceBase< Derived >::stateToTransPeriod ( int  state) const
inline
326 {
327 auto eqClass = this->stateToTransEqClass(state);
328 return this->transPeriod(eqClass);
329 };
__host__ __device__ Vector_t const & stateToTransEqClass() const
Definition HilbertSpace.hpp:320
__host__ __device__ Vector_t const & transPeriod() const
Definition HilbertSpace.hpp:317

◆ sysSize()

template<class Derived >
__host__ __device__ int ManyBodySpaceBase< Derived >::sysSize ( ) const
inline
265{ return m_systemSize; }

◆ transEqClassRep() [1/3]

template<class Derived >
__host__ __device__ Vector_t const & ManyBodySpaceBase< Derived >::transEqClassRep ( ) const
inline
311{ return m_transEqClassRep; }

◆ transEqClassRep() [2/3]

template<class Derived >
__host__ __device__ int ManyBodySpaceBase< Derived >::transEqClassRep ( int  id) const
inline
312{ return m_transEqClassRep[id]; }

◆ transEqClassRep() [3/3]

template<class Derived >
__host__ __device__ int ManyBodySpaceBase< Derived >::transEqClassRep ( int  id,
int  trans 
) const
inline
313 {
314 return this->translate(m_transEqClassRep[id], trans);
315 }

◆ transEqDim()

template<class Derived >
__host__ __device__ int ManyBodySpaceBase< Derived >::transEqDim ( ) const
inline
309{ return m_transEqDim; }

◆ translate() [1/2]

template<class Derived >
__host__ __device__ int ManyBodySpaceBase< Derived >::translate ( int  state,
int  trans 
) const
inline

Translate the input state to the left by one.

Parameters
[in]state
[in]trans
Returns
int
300 {
301 return static_cast<Derived const*>(this)->translate_impl(state, trans);
302 }

◆ translate() [2/2]

template<class Derived >
template<class EigenDerived >
__host__ __device__ int ManyBodySpaceBase< Derived >::translate ( int  state,
int  trans,
Eigen::DenseBase< EigenDerived > &  work 
) const
inline
305 {
306 return static_cast<Derived const*>(this)->translate_impl(state, trans, work);
307 }

◆ transPeriod() [1/2]

template<class Derived >
__host__ __device__ Vector_t const & ManyBodySpaceBase< Derived >::transPeriod ( ) const
inline
317{ return m_transPeriod; }

◆ transPeriod() [2/2]

template<class Derived >
__host__ __device__ int ManyBodySpaceBase< Derived >::transPeriod ( int  id) const
inline
318{ return m_transPeriod[id]; }

Friends And Related Symbol Documentation

◆ copyTransEqClass_kernel

template<class Derived >
void copyTransEqClass_kernel ( ManyBodySpaceBase< Derived > *  obj,
int *  srcTransEqClassRep,
int *  srcTransPeriod 
)
friend
77 {
78 int const idx = blockIdx.x * blockDim.x + threadIdx.x;
79 if(idx >= obj->transEqDim()) return;
80 obj->m_transEqClassRep(idx) = srcTransEqClassRep[idx];
81 obj->m_transPeriod(idx) = srcTransPeriod[idx];
82 for(auto trans = 0; trans != srcTransPeriod[idx]; ++trans) {
83 auto translated = obj->translate(srcTransEqClassRep[idx], trans);
84 obj->m_stateToTransEqClass(translated) = idx;
85 }
86}
__host__ __device__ int transEqDim() const
Definition HilbertSpace.hpp:309

◆ setTransEqDim_kernel

template<class Derived >
void setTransEqDim_kernel ( ManyBodySpaceBase< Derived > *  obj,
int  transEqDim 
)
friend
68 {
69 debug_printf("%s\n\ttransEqDim=%d\n", __PRETTY_FUNCTION__, transEqDim);
71 obj->m_transEqClassRep.resize(transEqDim);
72 obj->m_transPeriod.resize(transEqDim);
73 obj->m_stateToTransEqClass.resize(obj->dim());
74}

Member Data Documentation

◆ attr

template<class Derived >
struct cudaFuncAttributes ManyBodySpaceBase< Derived >::attr
private

◆ gotKernelAttribute

template<class Derived >
bool ManyBodySpaceBase< Derived >::gotKernelAttribute = false
mutableprivate

◆ m_locSpace

template<class Derived >
LocSpace_t ManyBodySpaceBase< Derived >::m_locSpace
protected

◆ m_parityPair

template<class Derived >
Vector_t ManyBodySpaceBase< Derived >::m_parityPair
mutableprotected

◆ m_stateToTransEqClass

template<class Derived >
Vector_t ManyBodySpaceBase< Derived >::m_stateToTransEqClass
mutableprotected

◆ m_systemSize

template<class Derived >
int ManyBodySpaceBase< Derived >::m_systemSize = 0
protected

◆ m_transEqClassRep

template<class Derived >
Vector_t ManyBodySpaceBase< Derived >::m_transEqClassRep
mutableprotected

◆ m_transEqDim

template<class Derived >
int ManyBodySpaceBase< Derived >::m_transEqDim = -1
mutableprotected

◆ m_transPeriod

template<class Derived >
Vector_t ManyBodySpaceBase< Derived >::m_transPeriod
mutableprotected

The documentation for this class was generated from the following file: