StatMech
Loading...
Searching...
No Matches
ParitySector< ManyBodySpace, RealType > Class Template Reference

Parity invariant sector of a many-body Hilbert space. More...

#include <ParitySector.hpp>

Inheritance diagram for ParitySector< ManyBodySpace, RealType >:
Inheritance graph
Collaboration diagram for ParitySector< ManyBodySpace, RealType >:
Collaboration graph

Public Types

using Base = SubSpace< ManyBodySpace, RealType >
 
- Public Types inherited from SubSpace< TotalSpace_, ScalarType_ >
using TotalSpace = TotalSpace_
 
using Scalar = ScalarType_
 
using Real = typename Eigen::NumTraits< ScalarType_ >::Real
 

Public Member Functions

template<typename std::enable_if_t< std::is_convertible_v< ManyBodySpace, ManyBodySpaceBase< ManyBodySpace > > > * = nullptr>
__host__ __device__ ParitySector (int parity, ManyBodySpace const &mbHSpace)
 Construct a ParitySector object from a ManyBodySpace object.
 
template<typename... Args>
__host__ __device__ ParitySector (int parity, int systemSize, Args... args)
 Default constructor.
 
__host__ __device__ int parity () const
 
__host__ __device__ int rep (int j, int trans=0) const
 
__host__ __device__ int period (int j) const
 
- Public Member Functions inherited from SubSpace< TotalSpace_, ScalarType_ >
__host__ __device__ SubSpace (TotalSpace const &totalSpace)
 Construct a SubSpace object by copying totalSpace to its member variable (m_totalSpace)
 
__host__ __device__ SubSpace (TotalSpace &&totalSpace)
 Construct a SubSpace object by moving totalSpace to its member variable (m_totalSpace)
 
__host__ __device__ SubSpace ()=default
 Default constructor.
 
__host__ __device__ SubSpace (SubSpace const &other)=default
 Copy constructor.
 
template<typename Scalar_ >
__host__ __device__ SubSpace (SubSpace< TotalSpace_, Scalar_ > const &other)
 
__host__ __device__ SubSpace (SubSpace &&other)=default
 Move constructor.
 
__host__ __device__ ~SubSpace ()=default
 Destructor.
 
__host__ __device__ SubSpaceoperator= (SubSpace const &other)
 Copy assignment operator.
 
__host__ __device__ SubSpaceoperator= (SubSpace &&other)
 Move assignment operator.
 
__host__ __device__ bool operator== (SubSpace const &other) const
 Equality operator.
 
__host__ __device__ Matrix_tbasis ()
 
__host__ __device__ Matrix_t const & basis () const
 
__host__ __device__ TotalSpace const & totalSpace () const
 
__host__ __device__ int dimTot () const
 
- Public Member Functions inherited from HilbertSpace< Derived >
__host__ __device__ int dim () const
 
__host__ __device__ bool operator== (HilbertSpace const &other) const
 

Private Member Functions

__host__ __device__ int numParityPairs ()
 

Private Attributes

int m_parity
 
int m_NumParityEigens = 0
 

Additional Inherited Members

- Protected Types inherited from SubSpace< TotalSpace_, ScalarType_ >
using Matrix_t = SparseCompressed< Scalar >
 
using Matrix_t = Eigen::SparseMatrix< Scalar >
 
- Protected Attributes inherited from SubSpace< TotalSpace_, ScalarType_ >
TotalSpace m_totalSpace
 
Matrix_t m_basisStates
 

Detailed Description

template<class ManyBodySpace, typename RealType = Real_t>
class ParitySector< ManyBodySpace, RealType >

Parity invariant sector of a many-body Hilbert space.

Template Parameters
Scalar_t
int
Matrix

Member Typedef Documentation

◆ Base

template<class ManyBodySpace , typename RealType = Real_t>
using ParitySector< ManyBodySpace, RealType >::Base = SubSpace<ManyBodySpace, RealType>

Constructor & Destructor Documentation

◆ ParitySector() [1/2]

template<class ManyBodySpace , typename RealType = Real_t>
template<typename std::enable_if_t< std::is_convertible_v< ManyBodySpace, ManyBodySpaceBase< ManyBodySpace > > > * = nullptr>
__host__ __device__ ParitySector< ManyBodySpace, RealType >::ParitySector ( int  parity,
ManyBodySpace const &  mbHSpace 
)
inline

Construct a ParitySector object from a ManyBodySpace object.

Parameters
k
mbHSpace
36 : Base(mbHSpace), m_parity(parity) {
37 debug_constructor_printf(1);
38 assert(parity == +1 || parity == -1);
39 if(this->totalSpace().sysSize() == 0) { return; }
40
41 Eigen::ArrayX<bool> calculated = Eigen::ArrayX<bool>::Constant(mbHSpace.dim(), false);
42 for(int state = 0; state != mbHSpace.dim(); ++state) {
43 if(calculated[state]) continue;
44 calculated[state] = true;
45
46 int reversed = mbHSpace.reverse(state);
47 if(reversed == state)
49 else
50 calculated[reversed] = true;
51 }
52 int dim = (mbHSpace.dim() - m_NumParityEigens) / 2;
53 if(m_parity == +1) dim += m_NumParityEigens;
54 debug_print("mbHSpace.dim() = " << mbHSpace.dim() << ", dim = " << dim
55 << ", m_NumParityEigens = " << m_NumParityEigens);
56
57 this->basis().resize(mbHSpace.dim(), dim);
58 this->basis().reserve(Eigen::VectorXi::Constant(dim, 2));
59 dim = 0;
60 calculated = Eigen::ArrayX<bool>::Constant(mbHSpace.dim(), false);
61 Eigen::ArrayXi parityEigen(m_NumParityEigens);
63 for(int state = 0; state != mbHSpace.dim(); ++state) {
64 if(calculated[state]) continue;
65 calculated[state] = true;
66
67 int reversed = mbHSpace.reverse(state);
68 if(reversed == state) { parityEigen(m_NumParityEigens++) = state; }
69 else {
70 this->basis().insert(state, dim) = 1.0 / sqrt(2.0);
71 this->basis().insert(reversed, dim) = 1.0 / sqrt(2.0);
72 calculated[reversed] = true;
73 dim += 1;
74 }
75 }
76 if(m_parity == 1) {
77 for(int j = 0; j != parityEigen.size(); ++j)
78 this->basis().insert(parityEigen[j], dim++) = 1;
79 }
80
81 debug_print("mbHSpace.dim() = " << mbHSpace.dim() << ", dim = " << dim
82 << ", this->dim() = " << this->dim());
83 this->basis().makeCompressed();
84 assert(dim == this->dim());
85 };
__host__ __device__ int dim() const
Definition HilbertSpace.hpp:34
SubSpace< ManyBodySpace, RealType > Base
Definition ParitySector.hpp:26
__host__ __device__ int parity() const
Definition ParitySector.hpp:99
int m_parity
Definition ParitySector.hpp:17
int m_NumParityEigens
Definition ParitySector.hpp:18
__host__ __device__ void resize(int rows, int cols, int reserved=1)
Definition MatrixUtils.cuh:353
__host__ __device__ Matrix_t & basis()
Definition HilbertSpace.hpp:668
__host__ __device__ TotalSpace const & totalSpace() const
Definition HilbertSpace.hpp:671
debug_print("# Determining GPU configuration.")

◆ ParitySector() [2/2]

template<class ManyBodySpace , typename RealType = Real_t>
template<typename... Args>
__host__ __device__ ParitySector< ManyBodySpace, RealType >::ParitySector ( int  parity,
int  systemSize,
Args...  args 
)
inline

Default constructor.

Parameters
k
systemSize
dimLoc
95 : ParitySector(parity, ManyBodySpace(systemSize, args...)) {
96 debug_constructor_printf((Default));
97 }
Parity invariant sector of a many-body Hilbert space.
Definition ParitySector.hpp:15

Member Function Documentation

◆ numParityPairs()

template<class ManyBodySpace , typename RealType = Real_t>
__host__ __device__ int ParitySector< ManyBodySpace, RealType >::numParityPairs ( )
inlineprivate
20 {
21 assert((this->dim() - m_NumParityEigens) % 2 == 0);
22 return (this->dim() - m_NumParityEigens) / 2;
23 }

◆ parity()

template<class ManyBodySpace , typename RealType = Real_t>
__host__ __device__ int ParitySector< ManyBodySpace, RealType >::parity ( ) const
inline
99{ return m_parity; };

◆ period()

template<class ManyBodySpace , typename RealType = Real_t>
__host__ __device__ int ParitySector< ManyBodySpace, RealType >::period ( int  j) const
inline
110 {
111 assert(j < this->dim() && "j < this->dim()");
112 return this->basis().outerIndexPtr()[j + 1] - this->basis().outerIndexPtr()[j];
113 };
__host__ __device__ int * outerIndexPtr() const
Definition MatrixUtils.cuh:420

◆ rep()

template<class ManyBodySpace , typename RealType = Real_t>
__host__ __device__ int ParitySector< ManyBodySpace, RealType >::rep ( int  j,
int  trans = 0 
) const
inline
101 {
102 assert(j < this->dim());
103 int const period
104 = this->basis().outerIndexPtr()[j + 1] - this->basis().outerIndexPtr()[j];
105 int const innerId = this->basis().outerIndexPtr()[j] + (trans % period);
106 assert(innerId < this->basis().nonZeros());
107 return this->basis().innerIndexPtr()[innerId];
108 };
__host__ __device__ int period(int j) const
Definition ParitySector.hpp:110
__host__ __device__ int * innerIndexPtr() const
Definition MatrixUtils.cuh:421

Member Data Documentation

◆ m_NumParityEigens

template<class ManyBodySpace , typename RealType = Real_t>
int ParitySector< ManyBodySpace, RealType >::m_NumParityEigens = 0
private

◆ m_parity

template<class ManyBodySpace , typename RealType = Real_t>
int ParitySector< ManyBodySpace, RealType >::m_parity
private

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