StatMech
Loading...
Searching...
No Matches
OperatorSpace< ScalarType > Class Template Reference

#include <OperatorSpace.hpp>

Inheritance diagram for OperatorSpace< ScalarType >:
Inheritance graph
Collaboration diagram for OperatorSpace< ScalarType >:
Collaboration graph

Public Types

using BaseSpace = typename HilbertSpaceTraits< OperatorSpace >::BaseSpace
 
using Scalar = ScalarType
 
- Public Types inherited from OperatorSpaceBase< Derived >
typedef Eigen::NumTraits< ScalarType >::Real Real
 

Private Member Functions

__host__ __device__ int dim_impl () const
 
template<typename RealType >
__host__ __device__ void action_impl (int &resBasisNum, Complex_t< RealType > &coeff, int opNum, int basisNum) const
 

Private Attributes

friend HilbertSpace< OperatorSpace >
 
friend OperatorSpaceBase< OperatorSpace >
 

Additional Inherited Members

- Public Member Functions inherited from OperatorSpaceBase< Derived >
__host__ __device__ OperatorSpaceBase (BaseSpace const &baseSpace)
 Construct a OperatorSpaceBase object by copying a BaseSpace object.
 
__host__ __device__ OperatorSpaceBase (BaseSpace &&baseSpace)
 Construct a OperatorSpaceBase object by moving a BaseSpace object.
 
__host__ __device__ OperatorSpaceBase ()=default
 Default constructor.
 
__host__ __device__ OperatorSpaceBase (OperatorSpaceBase const &other)=default
 Copy constructor.
 
__host__ __device__ OperatorSpaceBase (OperatorSpaceBase &&other)=default
 Move constructor.
 
__host__ __device__ ~OperatorSpaceBase ()=default
 Destructor.
 
__host__ __device__ OperatorSpaceBaseoperator= (OperatorSpaceBase const &other)=default
 Copy assignment operator.
 
__host__ __device__ OperatorSpaceBaseoperator= (OperatorSpaceBase &&other)=default
 Move assignment operator.
 
__host__ __device__ int dim () const
 
__host__ __device__ BaseSpace const & baseSpace () const
 
__host__ __device__ int baseDim () const
 
template<typename RealType >
__host__ __device__ void action (int &resBasisNum, Complex_t< RealType > &coeff, int opNum, int basisNum) const
 
template<typename RealType , class EigenDerived >
__host__ __device__ void action (int &resBasisNum, Complex_t< RealType > &coeff, int opNum, int basisNum, Eigen::DenseBase< EigenDerived > &config) const
 
__host__ __device__ std::pair< int, Complex_t< Real > > action (int opNum, int basisNum) const
 
__host__ void basisOp (Eigen::SparseMatrix< ScalarType > &res, int opNum) const
 
__host__ Eigen::SparseMatrix< ScalarTypebasisOp (int opNum) const
 

Member Typedef Documentation

◆ BaseSpace

template<typename ScalarType = Complex_t<Real_t>>
using OperatorSpace< ScalarType >::BaseSpace = typename HilbertSpaceTraits<OperatorSpace>::BaseSpace

◆ Scalar

template<typename ScalarType = Complex_t<Real_t>>
using OperatorSpace< ScalarType >::Scalar = ScalarType

Member Function Documentation

◆ action_impl()

template<typename ScalarType = Complex_t<Real_t>>
template<typename RealType >
__host__ __device__ void OperatorSpace< ScalarType >::action_impl ( int &  resBasisNum,
Complex_t< RealType > &  coeff,
int  opNum,
int  basisNum 
) const
inlineprivate

Variant of sigma Z

Variant of sigma X

Variant of sigma Y

147 {
148 // debug_printf("%s\n", __PRETTY_FUNCTION__);
149 resBasisNum = basisNum;
150 coeff = {0.0, 0.0};
151 int Digit1, Digit2;
152
153 if(opNum < this->baseSpace().dim()) {
155 resBasisNum = basisNum;
156 if(opNum == 0) { coeff = 1.0 / RealType(sqrt(RealType(this->baseSpace().dim()))); }
157 else if(opNum == 1 && this->baseSpace().dim() % 2 == 0) {
158 coeff = (basisNum % 2 == 0 ? 1.0 : -1.0)
159 / RealType(sqrt(RealType(this->baseSpace().dim())));
160 }
161 else {
162 coeff = sin(M_PI
163 * (2 * (opNum / 2) * basisNum / RealType(this->baseSpace().dim())
164 + (opNum % 2) / 2.0))
165 / RealType(sqrt(RealType(this->baseSpace().dim()) / 2.0));
166 ;
167 }
168 }
169 else if(opNum < this->baseSpace().dim() * (this->baseSpace().dim() + 1) / 2) {
171 opNum -= this->baseSpace().dim();
172 Digit1 = int(sqrt(RealType(2 * opNum) + 0.25) + 0.5);
173 Digit2 = opNum - Digit1 * (Digit1 - 1) / 2;
174 if(Digit1 == basisNum) {
175 resBasisNum = Digit2;
176 coeff = Complex_t<RealType>(1.0 / sqrt(RealType(2)), 0.0);
177 }
178 else if(Digit2 == basisNum) {
179 resBasisNum = Digit1;
180 coeff = Complex_t<RealType>(1.0 / sqrt(RealType(2)), 0.0);
181 }
182 }
183 else if(opNum < this->baseSpace().dim() * this->baseSpace().dim()) {
185 opNum -= this->baseSpace().dim() * (this->baseSpace().dim() + 1) / 2;
186 Digit1 = int(sqrt(RealType(2 * opNum) + 0.25) + 0.5);
187 Digit2 = opNum - Digit1 * (Digit1 - 1) / 2;
188 if(Digit1 == basisNum) {
189 resBasisNum = Digit2;
190 coeff = Complex_t<RealType>(0.0, -1.0 / sqrt(RealType(2)));
191 }
192 else if(Digit2 == basisNum) {
193 resBasisNum = Digit1;
194 coeff = Complex_t<RealType>(0.0, +1.0 / sqrt(RealType(2)));
195 }
196 }
197 else {
198 // clang-format off
199 #ifndef __CUDA_ARCH__
200 std::cerr << "Error: " << __PRETTY_FUNCTION__ << "\n\t"
201 << " opNum(" << opNum << ") must be less than "
202 << this->baseSpace().dim() * this->baseSpace().dim() << std::endl;
203 std::exit(EXIT_FAILURE);
204 #endif
205 // clang-format on
206 }
207 return;
208 };
Definition mytypes.hpp:147
__host__ __device__ int dim() const
Definition OperatorSpace.hpp:75
__host__ __device__ BaseSpace const & baseSpace() const
Definition OperatorSpace.hpp:79

◆ dim_impl()

template<typename ScalarType = Complex_t<Real_t>>
__host__ __device__ int OperatorSpace< ScalarType >::dim_impl ( ) const
inlineprivate
140 {
141 return this->baseSpace().dim() * this->baseSpace().dim();
142 }

Member Data Documentation

◆ HilbertSpace< OperatorSpace >

template<typename ScalarType = Complex_t<Real_t>>
friend OperatorSpace< ScalarType >::HilbertSpace< OperatorSpace >
private

◆ OperatorSpaceBase< OperatorSpace >

template<typename ScalarType = Complex_t<Real_t>>
friend OperatorSpace< ScalarType >::OperatorSpaceBase< OperatorSpace >
private

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