StatMech
Loading...
Searching...
No Matches
Ensemble copy.hpp File Reference

Go to the source code of this file.

Classes

class  RandomMatrixEnsemble< Scalar_t >
 

Functions

template<class Derived1 , class Derived2 , class TotalSpace , typename Scalar >
__global__ void constructHamiltonian_kernel (Eigen::MatrixBase< Derived1 > *dTotMat, Eigen::MatrixBase< Derived2 > const *dLocMat, SubSpace< TotalSpace, Scalar > const *subSpace)
 

Function Documentation

◆ constructHamiltonian_kernel()

template<class Derived1 , class Derived2 , class TotalSpace , typename Scalar >
__global__ void constructHamiltonian_kernel ( Eigen::MatrixBase< Derived1 > *  dTotMat,
Eigen::MatrixBase< Derived2 > const *  dLocMat,
SubSpace< TotalSpace, Scalar > const *  subSpace 
)
15 {
16 int const idx = blockIdx.x * blockDim.x + threadIdx.x;
17 int const idy = blockIdx.y * blockDim.y + threadIdx.y;
18 if(idx >= (*dTotMat).rows() || idy >= (*dTotMat).cols()) return;
19 if(idx < idy) return;
20
21 int const dimLoc = (*dLocMat).cols();
22
23 (*dTotMat)(idx, idy) = {0, 0};
24 magma_index_t innerX, innerY, locIdX, locIdY;
25 for(auto valuePosX = (*subSpace).basis().outerIndexPtr()[idx];
26 valuePosX != (*subSpace).basis().outerIndexPtr()[idx + 1]; ++valuePosX) {
27 innerX = (*subSpace).basis().innerIndexPtr()[valuePosX];
28 auto conjCoeffX = conj((*subSpace).basis().valuePtr()[valuePosX]);
29
30 for(auto valuePosY = (*subSpace).basis().outerIndexPtr()[idy];
31 valuePosY != (*subSpace).basis().outerIndexPtr()[idy + 1]; ++valuePosY) {
32 innerY = (*subSpace).basis().innerIndexPtr()[valuePosY];
33 auto CoeffY = (*subSpace).basis().valuePtr()[valuePosY];
34
35 // if((innerX - innerY) / dimLoc != 0) continue; // WRONG FORMULA used until 2020/10/07
36 if(innerX / dimLoc != innerY / dimLoc) continue;
37 locIdX = innerX % dimLoc;
38 locIdY = innerY % dimLoc;
39 (*dTotMat)(idx, idy) += conjCoeffX * (*dLocMat)(locIdX, locIdY) * CoeffY;
40 }
41 }
42
43 (*dTotMat)(idy, idx) = conj((*dTotMat)(idx, idy));
44 // printf("LDT=%d, id=(%d,%d), val=%+f%+f*i\t %s is yet to be tested.\n", LDT, idx, idy,
45 // real(dTotMat[idx + LDT * idy]), imag(dTotMat[idx + LDT * idy]), __func__);
46 // printf("\t id=(%d,%d)\n", idx, idy);
47 return;
48}