@@ -101,8 +101,8 @@ void SQOpPool::fill_pool(std::string pool_type){
101
101
102
102
if ( aa != ia ){
103
103
SQOperator temp1a;
104
- temp1a.add_term (+1.0 , {aa, ia});
105
- temp1a.add_term (-1.0 , {ia, aa});
104
+ temp1a.add_term (+1.0 , {aa}, { ia});
105
+ temp1a.add_term (-1.0 , {ia}, { aa});
106
106
temp1a.simplify ();
107
107
if (temp1a.terms ().size () > 0 ){
108
108
add_term (1.0 , temp1a);
@@ -111,8 +111,8 @@ void SQOpPool::fill_pool(std::string pool_type){
111
111
112
112
if ( ab != ib ){
113
113
SQOperator temp1b;
114
- temp1b.add_term (+1.0 , {ab, ib});
115
- temp1b.add_term (-1.0 , {ib, ab});
114
+ temp1b.add_term (+1.0 , {ab}, { ib});
115
+ temp1b.add_term (-1.0 , {ib}, { ab});
116
116
temp1b.simplify ();
117
117
if (temp1b.terms ().size () > 0 ){
118
118
add_term (1.0 , temp1b);
@@ -139,8 +139,8 @@ void SQOpPool::fill_pool(std::string pool_type){
139
139
140
140
if ((aa != ba) && (ia != ja)){
141
141
SQOperator temp2aaaa;
142
- temp2aaaa.add_term (+1.0 , {aa,ba, ia,ja});
143
- temp2aaaa.add_term (-1.0 , {ja,ia, ba,aa});
142
+ temp2aaaa.add_term (+1.0 , {aa,ba}, { ia,ja});
143
+ temp2aaaa.add_term (-1.0 , {ja,ia}, { ba,aa});
144
144
temp2aaaa.simplify ();
145
145
if (temp2aaaa.terms ().size () > 0 ){
146
146
std::vector<size_t > vtemp {std::get<1 >(temp2aaaa.terms ()[0 ])[0 ], std::get<1 >(temp2aaaa.terms ()[0 ])[1 ], std::get<1 >(temp2aaaa.terms ()[0 ])[2 ], std::get<1 >(temp2aaaa.terms ()[0 ])[3 ]};
@@ -157,8 +157,8 @@ void SQOpPool::fill_pool(std::string pool_type){
157
157
158
158
if ((ab != bb ) && (ib != jb)){
159
159
SQOperator temp2bbbb;
160
- temp2bbbb.add_term (+1.0 , {ab,bb, ib,jb});
161
- temp2bbbb.add_term (-1.0 , {jb,ib, bb,ab});
160
+ temp2bbbb.add_term (+1.0 , {ab,bb}, { ib,jb});
161
+ temp2bbbb.add_term (-1.0 , {jb,ib}, { bb,ab});
162
162
temp2bbbb.simplify ();
163
163
if (temp2bbbb.terms ().size () > 0 ){
164
164
std::vector<size_t > vtemp {std::get<1 >(temp2bbbb.terms ()[0 ])[0 ], std::get<1 >(temp2bbbb.terms ()[0 ])[1 ], std::get<1 >(temp2bbbb.terms ()[0 ])[2 ], std::get<1 >(temp2bbbb.terms ()[0 ])[3 ]};
@@ -175,8 +175,8 @@ void SQOpPool::fill_pool(std::string pool_type){
175
175
176
176
if ((aa != bb) && (ia != jb)){
177
177
SQOperator temp2abab;
178
- temp2abab.add_term (+1.0 , {aa,bb, ia,jb});
179
- temp2abab.add_term (-1.0 , {jb,ia, bb,aa});
178
+ temp2abab.add_term (+1.0 , {aa,bb}, { ia,jb});
179
+ temp2abab.add_term (-1.0 , {jb,ia}, { bb,aa});
180
180
temp2abab.simplify ();
181
181
if (temp2abab.terms ().size () > 0 ){
182
182
std::vector<size_t > vtemp {std::get<1 >(temp2abab.terms ()[0 ])[0 ], std::get<1 >(temp2abab.terms ()[0 ])[1 ], std::get<1 >(temp2abab.terms ()[0 ])[2 ], std::get<1 >(temp2abab.terms ()[0 ])[3 ]};
@@ -193,8 +193,8 @@ void SQOpPool::fill_pool(std::string pool_type){
193
193
194
194
if ((ab != ba) && (ib != ja)){
195
195
SQOperator temp2baba;
196
- temp2baba.add_term (+1.0 , {ab,ba, ib,ja});
197
- temp2baba.add_term (-1.0 , {ja,ib, ba,ab});
196
+ temp2baba.add_term (+1.0 , {ab,ba}, { ib,ja});
197
+ temp2baba.add_term (-1.0 , {ja,ib}, { ba,ab});
198
198
temp2baba.simplify ();
199
199
if (temp2baba.terms ().size () > 0 ){
200
200
std::vector<size_t > vtemp {std::get<1 >(temp2baba.terms ()[0 ])[0 ], std::get<1 >(temp2baba.terms ()[0 ])[1 ], std::get<1 >(temp2baba.terms ()[0 ])[2 ], std::get<1 >(temp2baba.terms ()[0 ])[3 ]};
@@ -211,8 +211,8 @@ void SQOpPool::fill_pool(std::string pool_type){
211
211
212
212
if ((aa != bb) && (ib != ja)){
213
213
SQOperator temp2abba;
214
- temp2abba.add_term (+1.0 , {aa,bb, ib,ja});
215
- temp2abba.add_term (-1.0 , {ja,ib, bb,aa});
214
+ temp2abba.add_term (+1.0 , {aa,bb}, { ib,ja});
215
+ temp2abba.add_term (-1.0 , {ja,ib}, { bb,aa});
216
216
temp2abba.simplify ();
217
217
if (temp2abba.terms ().size () > 0 ){
218
218
std::vector<size_t > vtemp {std::get<1 >(temp2abba.terms ()[0 ])[0 ], std::get<1 >(temp2abba.terms ()[0 ])[1 ], std::get<1 >(temp2abba.terms ()[0 ])[2 ], std::get<1 >(temp2abba.terms ()[0 ])[3 ]};
@@ -230,8 +230,8 @@ void SQOpPool::fill_pool(std::string pool_type){
230
230
231
231
if ((ab != ba) && (ia != jb)){
232
232
SQOperator temp2baab;
233
- temp2baab.add_term (+1.0 , {ab,ba, ia,jb});
234
- temp2baab.add_term (-1.0 , {jb,ia, ba,ab});
233
+ temp2baab.add_term (+1.0 , {ab,ba}, { ia,jb});
234
+ temp2baab.add_term (-1.0 , {jb,ia}, { ba,ab});
235
235
temp2baab.simplify ();
236
236
if (temp2baab.terms ().size () > 0 ){
237
237
std::vector<size_t > vtemp {std::get<1 >(temp2baab.terms ()[0 ])[0 ], std::get<1 >(temp2baab.terms ()[0 ])[1 ], std::get<1 >(temp2baab.terms ()[0 ])[2 ], std::get<1 >(temp2baab.terms ()[0 ])[3 ]};
@@ -334,13 +334,12 @@ void SQOpPool::fill_pool(std::string pool_type){
334
334
}
335
335
336
336
if (total_parity==1 ){
337
- particles.insert (particles.end (), holes.begin (), holes.end ());
338
- std::vector<size_t > particles_adj (particles.rbegin (), particles.rend ());
339
-
340
337
// need i, j, a, b
341
338
SQOperator t_temp;
342
- t_temp.add_term (+1.0 , particles);
343
- t_temp.add_term (-1.0 , particles_adj);
339
+ t_temp.add_term (+1.0 , particles, holes);
340
+ std::vector<size_t > rparticles (particles.rbegin (), particles.rend ());
341
+ std::vector<size_t > rholes (holes.rbegin (), holes.rend ());
342
+ t_temp.add_term (-1.0 , rholes, rparticles);
344
343
t_temp.simplify ();
345
344
add_term (1.0 , t_temp);
346
345
}
@@ -357,17 +356,17 @@ void SQOpPool::fill_pool(std::string pool_type){
357
356
size_t ab = 2 *nocc_ + 2 *a+1 ;
358
357
359
358
SQOperator temp1;
360
- temp1.add_term (+1.0 /std::sqrt (2 ), {aa, ia});
361
- temp1.add_term (+1.0 /std::sqrt (2 ), {ab, ib});
359
+ temp1.add_term (+1.0 /std::sqrt (2 ), {aa}, { ia});
360
+ temp1.add_term (+1.0 /std::sqrt (2 ), {ab}, { ib});
362
361
363
- temp1.add_term (-1.0 /std::sqrt (2 ), {ia, aa});
364
- temp1.add_term (-1.0 /std::sqrt (2 ), {ib, ab});
362
+ temp1.add_term (-1.0 /std::sqrt (2 ), {ia}, { aa});
363
+ temp1.add_term (-1.0 /std::sqrt (2 ), {ib}, { ab});
365
364
366
365
temp1.simplify ();
367
366
368
367
std::complex<double > temp1_norm (0.0 , 0.0 );
369
368
for (const auto & term : temp1.terms ()){
370
- temp1_norm += std::norm (term. first );
369
+ temp1_norm += std::norm (std::get< 0 >( term) );
371
370
}
372
371
temp1.mult_coeffs (1.0 /std::sqrt (temp1_norm));
373
372
add_term (1.0 , temp1);
@@ -392,70 +391,70 @@ void SQOpPool::fill_pool(std::string pool_type){
392
391
393
392
SQOperator temp2a;
394
393
if ((aa != ba) && (ia != ja)){
395
- temp2a.add_term (2.0 /std::sqrt (12 ), {aa,ba, ia,ja});
394
+ temp2a.add_term (2.0 /std::sqrt (12 ), {aa,ba}, { ia,ja});
396
395
}
397
396
if ((ab != bb ) && (ib != jb)){
398
- temp2a.add_term (2.0 /std::sqrt (12 ), {ab,bb, ib,jb});
397
+ temp2a.add_term (2.0 /std::sqrt (12 ), {ab,bb}, { ib,jb});
399
398
}
400
399
if ((aa != bb) && (ia != jb)){
401
- temp2a.add_term (1.0 /std::sqrt (12 ), {aa,bb, ia,jb});
400
+ temp2a.add_term (1.0 /std::sqrt (12 ), {aa,bb}, { ia,jb});
402
401
}
403
402
if ((ab != ba) && (ib != ja)){
404
- temp2a.add_term (1.0 /std::sqrt (12 ), {ab,ba, ib,ja});
403
+ temp2a.add_term (1.0 /std::sqrt (12 ), {ab,ba}, { ib,ja});
405
404
}
406
405
if ((aa != bb) && (ib != ja)){
407
- temp2a.add_term (1.0 /std::sqrt (12 ), {aa,bb, ib,ja});
406
+ temp2a.add_term (1.0 /std::sqrt (12 ), {aa,bb}, { ib,ja});
408
407
}
409
408
if ((ab != ba) && (ia != jb)){
410
- temp2a.add_term (1.0 /std::sqrt (12 ), {ab,ba, ia,jb});
409
+ temp2a.add_term (1.0 /std::sqrt (12 ), {ab,ba}, { ia,jb});
411
410
}
412
411
413
412
// hermitian conjugate
414
413
if ((ja != ia) && (ba != aa)){
415
- temp2a.add_term (-2.0 /std::sqrt (12 ), {ja,ia, ba,aa});
414
+ temp2a.add_term (-2.0 /std::sqrt (12 ), {ja,ia}, { ba,aa});
416
415
}
417
416
if ((jb != ib ) && (bb != ab)){
418
- temp2a.add_term (-2.0 /std::sqrt (12 ), {jb,ib, bb,ab});
417
+ temp2a.add_term (-2.0 /std::sqrt (12 ), {jb,ib}, { bb,ab});
419
418
}
420
419
if ((jb != ia) && (bb != aa)){
421
- temp2a.add_term (-1.0 /std::sqrt (12 ), {jb,ia, bb,aa});
420
+ temp2a.add_term (-1.0 /std::sqrt (12 ), {jb,ia}, { bb,aa});
422
421
}
423
422
if ((ja != ib) && (ba != ab)){
424
- temp2a.add_term (-1.0 /std::sqrt (12 ), {ja,ib, ba,ab});
423
+ temp2a.add_term (-1.0 /std::sqrt (12 ), {ja,ib}, { ba,ab});
425
424
}
426
425
if ((ja != ib) && (bb != aa)){
427
- temp2a.add_term (-1.0 /std::sqrt (12 ), {ja,ib, bb,aa});
426
+ temp2a.add_term (-1.0 /std::sqrt (12 ), {ja,ib}, { bb,aa});
428
427
}
429
428
if ((jb != ia) && (ba != ab)){
430
- temp2a.add_term (-1.0 /std::sqrt (12 ), {jb,ia, ba,ab});
429
+ temp2a.add_term (-1.0 /std::sqrt (12 ), {jb,ia}, { ba,ab});
431
430
}
432
431
433
432
SQOperator temp2b;
434
433
if ((aa != bb) && (ia != jb)){
435
- temp2b.add_term (0.5 , {aa,bb, ia,jb});
434
+ temp2b.add_term (0.5 , {aa,bb}, { ia,jb});
436
435
}
437
436
if ((ab != ba) && (ib != ja)){
438
- temp2b.add_term (0.5 , {ab,ba, ib,ja});
437
+ temp2b.add_term (0.5 , {ab,ba}, { ib,ja});
439
438
}
440
439
if ((aa != bb) && (ib != ja)){
441
- temp2b.add_term (-0.5 , {aa,bb, ib,ja});
440
+ temp2b.add_term (-0.5 , {aa,bb}, { ib,ja});
442
441
}
443
442
if ((ab != ba) && (ia != jb)){
444
- temp2b.add_term (-0.5 , {ab,ba, ia,jb});
443
+ temp2b.add_term (-0.5 , {ab,ba}, { ia,jb});
445
444
}
446
445
447
446
// hermetian conjugate
448
447
if ((jb != ia) && (bb != aa)){
449
- temp2b.add_term (-0.5 , {jb,ia, bb,aa});
448
+ temp2b.add_term (-0.5 , {jb,ia}, { bb,aa});
450
449
}
451
450
if ((ja != ib) && (ba != ab)){
452
- temp2b.add_term (-0.5 , {ja,ib, ba,ab});
451
+ temp2b.add_term (-0.5 , {ja,ib}, { ba,ab});
453
452
}
454
453
if ((ja != ib) && (bb != aa)){
455
- temp2b.add_term (0.5 , {ja,ib, bb,aa});
454
+ temp2b.add_term (0.5 , {ja,ib}, { bb,aa});
456
455
}
457
456
if ((jb != ia) && (ba != ab)){
458
- temp2b.add_term (0.5 , {jb,ia, ba,ab});
457
+ temp2b.add_term (0.5 , {jb,ia}, { ba,ab});
459
458
}
460
459
461
460
temp2a.simplify ();
@@ -464,10 +463,10 @@ void SQOpPool::fill_pool(std::string pool_type){
464
463
std::complex<double > temp2a_norm (0.0 , 0.0 );
465
464
std::complex<double > temp2b_norm (0.0 , 0.0 );
466
465
for (const auto & term : temp2a.terms ()){
467
- temp2a_norm += std::norm (term. first );
466
+ temp2a_norm += std::norm (std::get< 0 >( term) );
468
467
}
469
468
for (const auto & term : temp2b.terms ()){
470
- temp2b_norm += std::norm (term. first );
469
+ temp2b_norm += std::norm (std::get< 0 >( term) );
471
470
}
472
471
temp2a.mult_coeffs (1.0 /std::sqrt (temp2a_norm));
473
472
temp2b.mult_coeffs (1.0 /std::sqrt (temp2b_norm));
@@ -482,14 +481,6 @@ void SQOpPool::fill_pool(std::string pool_type){
482
481
}
483
482
}
484
483
}
485
- } else if (pool_type == " test" ){
486
- SQOperator A;
487
- A.add_term (+2.0 , {1 ,2 ,4 ,3 });
488
- A.add_term (-2.0 , {2 ,4 });
489
- A.add_term (-2.0 , {3 ,4 ,2 ,1 });
490
- A.add_term (+2.0 , {4 ,2 });
491
- add_term (-0.25 , A);
492
- add_term (+0.75 , A);
493
484
} else {
494
485
throw std::invalid_argument ( " Invalid pool_type specified." );
495
486
}
@@ -505,18 +496,7 @@ std::string SQOpPool::str() const{
505
496
s.push_back (" <-----\n " );
506
497
s.push_back (to_string (term.first ));
507
498
s.push_back (" [\n " );
508
- for (const auto & sub_term : term.second .terms ()) {
509
- int nbody = sub_term.second .size () / 2.0 ;
510
- s.push_back (to_string (sub_term.first ));
511
- s.push_back (" (" );
512
- for (int k=0 ; k<nbody; k++ ) {
513
- s.push_back (std::to_string (sub_term.second [k]) + " ^" );
514
- }
515
- for (int k=nbody; k<2 *nbody; k++ ) {
516
- s.push_back (std::to_string (sub_term.second [k]));
517
- }
518
- s.push_back (" )\n " );
519
- }
499
+ s.push_back (term.second .str ());
520
500
s.push_back (" ]\n\n " );
521
501
counter++;
522
502
}
0 commit comments