31 std::unique_ptr<helpers::tmatrix<int>>
PHM::s2ph =
nullptr;
32 std::unique_ptr<helpers::tmatrix<int>>
PHM::ph2s =
nullptr;
33 std::unique_ptr<helpers::tmatrix<int>>
PHM::s2b =
nullptr;
34 std::unique_ptr<helpers::tmatrix<int>>
PHM::b2s =
nullptr;
52 for(
int i=1;i<
gnr();i++)
94 (*ph2s)((*s2ph)(a,b),0) = a;
95 (*ph2s)((*s2ph)(a,b),1) = b;
108 for(
int b=a+1;b<
L;b++)
110 (*s2b)(a,b) = (*
s2b)(b,a) = tel;
116 assert(tel ==
b2s->getn());
133 auto getelem = [
this](
int a,
int b) {
137 int j = a > b ? 1 : 0;
138 return (*
this)(i,j,j);
140 return (*
this)(0,a,a);
143 auto getrho = [
this](
int a,
int b) {
147 return -1 * (*this)(i,0,1);
149 return (*
this)(0,a,a);
154 if(a/
L != b/
L && c/
L != d/
L && a/
L==c/
L)
156 if(a%
L==c%
L && b%
L==d%
L)
157 res += getelem(a%L,b%L);
159 if(a%L==d%L && b%L==c%L)
160 res -= getrho(a%L,b%L);
163 else if(a/
L == b/
L && c/
L == d/
L)
169 res += getelem(a%
L,b%L);
171 if(a==b && c==d && a!=c)
172 res += (*this)(0,a%
L,c%
L);
175 if(a%
L==d%
L && b%
L==c%
L)
176 res += getrho(a%L,b%L);
178 if(a==b && c==d && a%L!=c%L)
179 res += (*this)(0,a%
L,c%
L);
205 const int idx = (*s2b)(a,b);
220 const int idx = (*s2b)(a,b);
238 (*
this)(0,b,a) = (*
this)(0,a,b) = tpm.
getDiag(a,b);
240 (*this)(0,a,a) += spm(0,a);
244 for(
int i=1;i<
gnr();i++)
246 auto& block = (*this)[i];
250 block(0,0) = spm(0,a) - tpm.
getDiag(a,b);
251 block(1,1) = spm(0,b) - tpm.
getDiag(a,b);
252 block(0,1) = block(1,0) = - tpm(a,a+L,b,b+L);
269 for(
int i=0;i<M*M;++i)
271 int a = (*ph2s)(i,0);
272 int b = (*ph2s)(i,1);
274 for(
int j=i;j<M*M;++j)
276 int c = (*ph2s)(j,0);
277 int d = (*ph2s)(j,1);
279 Gmat(i,j) = -tpm(a,d,c,b);
282 Gmat(i,j) += spm(0,a%
L);
284 Gmat(j,i) = Gmat(i,j);
301 for(
int i=0;i<M*M;++i)
303 int a = (*ph2s)(i,0);
304 int b = (*ph2s)(i,1);
306 for(
int j=i;j<M*M;++j)
308 int c = (*ph2s)(j,0);
309 int d = (*ph2s)(j,1);
311 Gmat(i,j) = Gmat(j,i) = (*this)(a,b,c,d);
322 output <<
"The LxL block: " << std::endl;
323 output << phm[0] << std::endl;
327 for(
int i=1;i<phm.
gnr();i++)
329 output <<
"Block " << i-1 <<
" for " << (*phm.
b2s)(i,0) <<
"\t" << (*phm.
b2s)(i,1) << std::endl;
330 output << phm[i] << std::endl;
345 (*this)[0].sep_pm(pos[0], neg[0]);
347 #pragma omp parallel for if(gnr()>100)
348 for(
int i=1;i<
gnr();i++)
349 (*
this)[i].sep_pm_2x2(pos[i], neg[i]);
359 (*this)[0].sqrt(option);
361 #pragma omp parallel for if(gnr()>100)
362 for(
int i=1;i<
gnr();i++)
363 (*
this)[i].sqrt_2x2(option);
370 #pragma omp parallel for if(gnr()>100)
371 for(
int i=1;i<
gnr();i++)
372 (*
this)[i].invert_2x2();
377 (*this)[0].L_map(map[0],
object[0]);
379 #pragma omp parallel for if(gnr()>100)
380 for(
int i=1;i<
gnr();i++)
381 (*
this)[i].L_map_2x2(map[i],
object[i]);
390 hid_t dataset_id, dataspace_id;
394 hsize_t dimblock = (*this)[0].gn() * (*this)[0].gn();
396 dataspace_id = H5Screate_simple(1, &dimblock, NULL);
398 dataset_id = H5Dcreate(group_id,
"Block", H5T_IEEE_F64LE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
400 double *data =
const_cast<Matrix &
>((*this)[0]).gMatrix();
402 status = H5Dwrite(dataset_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
405 status = H5Dclose(dataset_id);
408 status = H5Sclose(dataspace_id);
413 dataspace_id = H5Screate_simple(1, &dimblock, NULL);
415 for(
int i=1;i<
gnr();i++)
417 std::string blockname =
"2x2_" + std::to_string(i);
419 dataset_id = H5Dcreate(group_id, blockname.c_str(), H5T_IEEE_F64LE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
421 data =
const_cast<Matrix &
>((*this)[i]).gMatrix();
423 status = H5Dwrite(dataset_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
426 status = H5Dclose(dataset_id);
430 status = H5Sclose(dataspace_id);
437 hid_t dataset_id, attribute_id, dataspace_id;
450 int idx1 = (*s2ph)(a,b);
451 int idx2 = (*s2ph)(c,d);
453 if(idx1>=0 && idx2>=0)
454 fullTPM(idx1, idx2) = (*this)(a,b,c,d);
458 hsize_t dimblock = M*M*M*M;
460 dataspace_id = H5Screate_simple(1, &dimblock, NULL);
462 dataset_id = H5Dcreate(group_id,
"PHM", H5T_IEEE_F64LE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
464 status = H5Dwrite(dataset_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, fullTPM.
gMatrix());
467 status = H5Sclose(dataspace_id);
470 dataspace_id = H5Screate(H5S_SCALAR);
472 attribute_id = H5Acreate (dataset_id,
"M", H5T_STD_I64LE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT);
473 status = H5Awrite (attribute_id, H5T_NATIVE_INT, &M );
476 status = H5Aclose(attribute_id);
479 attribute_id = H5Acreate (dataset_id,
"N", H5T_STD_I64LE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT);
480 status = H5Awrite (attribute_id, H5T_NATIVE_INT, &
N );
483 status = H5Aclose(attribute_id);
486 status = H5Sclose(dataspace_id);
489 status = H5Dclose(dataset_id);
504 dataset_id = H5Dopen(group_id,
"Block", H5P_DEFAULT);
507 status = H5Dread(dataset_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, (*
this)[0].gMatrix());
510 status = H5Dclose(dataset_id);
513 for(
int i=1;i<
gnr();i++)
515 std::string blockname =
"2x2_" + std::to_string(i);
517 dataset_id = H5Dopen(group_id, blockname.c_str(), H5P_DEFAULT);
520 status = H5Dread(dataset_id, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, (*
this)[i].gMatrix());
523 status = H5Dclose(dataset_id);
static std::unique_ptr< helpers::tmatrix< int > > s2b
table translating single particles indices to the correct 2x2 block
static std::unique_ptr< helpers::tmatrix< int > > s2ph
table translating single particles indices to two particle indices
void WriteToFile(hid_t &group_id) const
void WriteFullToFile(hid_t &group_id) const
Matrix Gimg(const TPM &) const
const Matrix & getBlock(int a, int b) const
void ReadFromFile(hid_t &group_id)
std::ostream & operator<<(std::ostream &output, const doci2DM::BlockStructure< MyBlockType > &blocks_p)
void sep_pm(BlockMatrix &, BlockMatrix &)
void setDim(int, int, int)
double operator()(int a, int b, int c, int d) const
#define HDF5_STATUS_CHECK(status)
static std::unique_ptr< helpers::tmatrix< int > > b2s
table translating the block index to the single particle indices
double getDiag(int, int) const
static std::unique_ptr< helpers::tmatrix< int > > ph2s
table translating two particles indices to single particle indices
void L_map(const BlockMatrix &, const BlockMatrix &)