HΦ  3.2.0
bitcalc.c File Reference

File for giving functions of treating bits on the target of Hilbert space. More...

#include "bitcalc.h"
#include "wrapperMPI.h"
+ Include dependency graph for bitcalc.c:

Go to the source code of this file.

Functions

int GetSplitBit (const int Nsite, long unsigned int *irght, long unsigned int *ilft, long unsigned int *ihfbit)
 function of getting right, left and half bits corresponding to a original Hilbert space. } More...
 
int GetSplitBitByModel (const int Nsite, const int iCalcModel, long unsigned int *irght, long unsigned int *ilft, long unsigned int *ihfbit)
 function of splitting original bit into right and left spaces. More...
 
int GetSplitBitForGeneralSpin (const int Nsite, long unsigned int *ihfbit, const long int *SiteToBit)
 function of getting right, left and half bits corresponding to a original space. More...
 
void SplitBit (const long unsigned int ibit, const long unsigned int irght, const long unsigned int ilft, const long unsigned int ihfbit, long unsigned int *isplited_Bit_right, long unsigned int *isplited_Bit_left)
 function of splitting a original bit to right and left spaces More...
 
int GetOffComp (long unsigned int *_list_2_1, long unsigned int *_list_2_2, long unsigned int _ibit, const long unsigned int _irght, const long unsigned int _ilft, const long unsigned int _ihfbit, long unsigned int *_ioffComp)
 function of getting off-diagonal component More...
 
int GetOffCompGeneralSpin (const long unsigned int org_ibit, const int org_isite, const int org_ispin, const int off_ispin, long unsigned int *_ioffComp, const long int *SiteToBit, const long unsigned int *Tpow)
 function of getting off-diagonal component for general spin More...
 
int ConvertToList1GeneralSpin (const long unsigned int org_ibit, const long unsigned int ihlfbit, long unsigned int *_ilist1Comp)
 function of converting component to list_1 More...
 
void SgnBit_old (const long unsigned int org_bit, int *sgn)
 function of getting fermion signs (for 32bit) More...
 
void SgnBit (const long unsigned int org_bit, int *sgn)
 function of getting fermion sign (64 bit) More...
 
int BitCheck (const long unsigned int org_bit, const long unsigned int target_bit)
 bit check function More...
 
int BitCheckGeneral (const long unsigned int org_bit, const unsigned int org_isite, const unsigned int target_ispin, const long int *SiteToBit, const long unsigned int *Tpow)
 bit check function for general spin More...
 
int GetBitGeneral (const unsigned int isite, const long unsigned int org_bit, const long int *SiteToBit, const long unsigned int *Tpow)
 get bit at a site for general spin More...
 
int GetLocal2Sz (const unsigned int isite, const long unsigned int org_bit, const long int *SiteToBit, const long unsigned int *Tpow)
 get 2sz at a site for general spin More...
 
unsigned long int snoob (unsigned long int x)
 "finding the next higher number after a given number that has the same number of 1-bits" This method is introduced in S.H. Warren, Hacker$B!G(Bs Delight, second ed., Addison-Wesley, ISBN: 0321842685, 2012. More...
 
int pop (unsigned int x)
 calculating number of 1-bits in x (32 bit) This method is introduced in S.H. Warren, Hacker$B!G(Bs Delight, second ed., Addison-Wesley, ISBN: 0321842685, 2012. More...
 

Detailed Description

File for giving functions of treating bits on the target of Hilbert space.

Version
0.1, 0.2
Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)

Definition in file bitcalc.c.

Function Documentation

◆ BitCheck()

int BitCheck ( const long unsigned int  org_bit,
const long unsigned int  target_bit 
)

bit check function

Parameters
org_bitoriginal bit to check
target_bittarget bit to check
Return values
1
0
Version
0.1
Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)
Parameters
[in]org_bit
[in]target_bit

Definition at line 367 of file bitcalc.c.

371 {
372  return (org_bit >> target_bit) &1;
373  // (org_bit & (2^target_bit))/2^target_bit
374 }

◆ BitCheckGeneral()

int BitCheckGeneral ( const long unsigned int  org_bit,
const unsigned int  org_isite,
const unsigned int  target_ispin,
const long int *  SiteToBit,
const long unsigned int *  Tpow 
)

bit check function for general spin

Parameters
org_bitoriginal bit to check
org_isitesite index (org_isite >= 1)
target_ispintarget spin to check
SiteToBitList for getting bit at a site
TpowList for getting total bit at a site before
Return values
0bit does not exists
1bit exists
Version
0.2
Author
Kazuyoshi Yoshimi (The University of Tokyo)
Parameters
[in]org_bit
[in]org_isite
[in]target_ispin
[in]SiteToBit
[in]Tpow

Definition at line 393 of file bitcalc.c.

References FALSE, GetBitGeneral(), and TRUE.

Referenced by expec_cisajs_SpinGCGeneral(), expec_cisajs_SpinGeneral(), expec_cisajscktalt_SpinGCGeneral(), expec_cisajscktalt_SpinGeneral(), GetOffCompGeneralSpin(), GetPairExcitedStateGeneralSpin(), GetPairExcitedStateGeneralSpinGC(), mltplyGeneralSpinGC(), SetDiagonalChemi(), SetDiagonalInterAll(), SetDiagonalTEChemi(), SetDiagonalTEInterAll(), SetDiagonalTETransfer(), X_child_CisAisCjuAju_GeneralSpin_MPIdouble(), X_child_CisAisCjuAju_GeneralSpin_MPIsingle(), X_GC_child_AisCis_GeneralSpin_MPIdouble(), X_GC_child_CisAis_GeneralSpin_MPIdouble(), X_GC_child_CisAisCjuAju_GeneralSpin_MPIdouble(), X_GC_child_CisAisCjuAju_GeneralSpin_MPIsingle(), X_GC_child_CisAisCjuAjv_GeneralSpin_MPIdouble(), X_GC_child_CisAisCjuAjv_GeneralSpin_MPIsingle(), X_GC_child_CisAitCjuAju_GeneralSpin_MPIdouble(), and X_GC_child_CisAitCjuAju_GeneralSpin_MPIsingle().

400 {
401 
402  if(GetBitGeneral(org_isite, org_bit, SiteToBit, Tpow) !=target_ispin){
403  return FALSE;
404  }
405  return TRUE;
406 }
#define TRUE
Definition: global.h:26
int GetBitGeneral(const unsigned int isite, const long unsigned int org_bit, const long int *SiteToBit, const long unsigned int *Tpow)
get bit at a site for general spin
Definition: bitcalc.c:422
#define FALSE
Definition: global.h:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ConvertToList1GeneralSpin()

int ConvertToList1GeneralSpin ( const long unsigned int  org_ibit,
const long unsigned int  ihlfbit,
long unsigned int *  _ilist1Comp 
)

function of converting component to list_1

Parameters
org_ibita original bit
ihlfbita split bit for general spin
_ilist1Compa component converted to list_1
Version
0.2
Author
Kazuyoshi Yoshimi (The University of Tokyo)
Parameters
[in]org_ibit
[in]ihlfbit
[out]_ilist1Comp

Definition at line 285 of file bitcalc.c.

References FALSE, list_2_1, list_2_2, and TRUE.

Referenced by expec_cisajscktalt_SpinGeneral(), GetPairExcitedStateGeneralSpin(), makeHam(), mltplyGeneralSpin(), totalspin_Spin(), X_child_CisAit_GeneralSpin_MPIdouble(), X_child_CisAitCjuAjv_GeneralSpin_MPIdouble(), and X_child_CisAitCjuAjv_GeneralSpin_MPIsingle().

290 {
291  long unsigned int ia, ib;
292  long unsigned int tmp_list;
293  ia=org_ibit%ihlfbit;
294  ib=org_ibit/ihlfbit;
295  if(list_2_1[ia]*list_2_2[ib]==0){
296  *_ilist1Comp=0;
297  return FALSE;
298  }
299  *_ilist1Comp = list_2_1[ia] + list_2_2[ib] - 2;
300  return TRUE;
301 }
#define TRUE
Definition: global.h:26
long unsigned int * list_2_1
Definition: global.h:49
#define FALSE
Definition: global.h:25
long unsigned int * list_2_2
Definition: global.h:50
+ Here is the caller graph for this function:

◆ GetBitGeneral()

int GetBitGeneral ( const unsigned int  isite,
const long unsigned int  org_bit,
const long int *  SiteToBit,
const long unsigned int *  Tpow 
)

get bit at a site for general spin

Parameters
isitesite index (isite >= 1)
org_bitoriginal bit to check
SiteToBitList for getting bit at a site
TpowList for getting total bit at a site before
Returns
bit at a site
Version
0.2
Author
Kazuyoshi Yoshimi (The University of Tokyo)
Parameters
[in]isite
[in]org_bit
[in]SiteToBit
[in]Tpow

Definition at line 422 of file bitcalc.c.

References GetLocal2Sz().

Referenced by BitCheckGeneral(), GetLocal2Sz(), totalspin_Spin(), and totalspin_SpinGC().

428 {
429  long unsigned int tmp_bit=(org_bit/Tpow[isite-1])%SiteToBit[isite-1] ;
430  return (tmp_bit);
431 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetLocal2Sz()

int GetLocal2Sz ( const unsigned int  isite,
const long unsigned int  org_bit,
const long int *  SiteToBit,
const long unsigned int *  Tpow 
)

get 2sz at a site for general spin

Parameters
isitesite index (isite >= 1)
org_bitoriginal bit to check
SiteToBitList for getting bit at a site
TpowList for getting total bit at a site before
Returns
2sz at isite
Version
0.2
Author
Kazuyoshi Yoshimi (The University of Tokyo)
Parameters
[in]isite
[in]org_bit
[in]SiteToBit
[in]Tpow

Definition at line 449 of file bitcalc.c.

References GetBitGeneral().

Referenced by check(), expec_cisajscktalt_SpinGeneral(), expec_energy_flct_GeneralSpin(), expec_energy_flct_GeneralSpinGC(), GetBitGeneral(), sz(), totalspin_Spin(), totalspin_SpinGC(), and totalSz_SpinGC().

455 {
456  int TwiceSz=0;
457  int bitAtSite=0;
458  //get bit
459  bitAtSite=GetBitGeneral(isite, org_bit, SiteToBit, Tpow);
460  TwiceSz=-(SiteToBit[isite-1]-1)+2*bitAtSite; //-2S^{total}_i+2Sz_i
461  return TwiceSz;
462 }
int GetBitGeneral(const unsigned int isite, const long unsigned int org_bit, const long int *SiteToBit, const long unsigned int *Tpow)
get bit at a site for general spin
Definition: bitcalc.c:422
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetOffComp()

int GetOffComp ( long unsigned int *  _list_2_1,
long unsigned int *  _list_2_2,
long unsigned int  _ibit,
const long unsigned int  _irght,
const long unsigned int  _ilft,
const long unsigned int  _ihfbit,
long unsigned int *  _ioffComp 
)

function of getting off-diagonal component

Parameters
_list_2_1list to right space
_list_2_2list to left space
_ibita original bit
_irghta bit to split original space into right space
_ilfta bit to split original space into left space
_ihfbita half bit to split original space
_ioffCompan off diagonal component
Version
0.1
Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)
Parameters
[in]_list_2_1
[in]_list_2_2
[in]_ibit
[in]_irght
[in]_ilft
[in]_ihfbit
[out]_ioffComp

Definition at line 195 of file bitcalc.c.

References FALSE, SplitBit(), and TRUE.

Referenced by child_exchange_element(), child_exchange_spin_element(), child_pairhopp_element(), CisAjt(), totalspin_Hubbard(), totalspin_Spin(), X_Ajt(), X_Ajt_MPI(), X_child_CisAit_spin_MPIdouble(), X_child_CisAjt_MPIdouble(), X_child_CisAjt_MPIsingle(), X_child_CisAjtCkuAku_Hubbard_MPI(), X_child_CisAjtCkuAlv_Hubbard_MPI(), X_child_exchange_spin_element(), X_child_general_hopp_MPIdouble(), X_child_general_hopp_MPIsingle(), X_child_general_int_spin_MPIdouble(), X_child_general_int_spin_MPIsingle(), X_child_general_int_spin_TotalS_MPIdouble(), X_Cis(), X_Cis_MPI(), X_CisAjt(), and X_Spin_CisAit().

204 {
205  long unsigned int ia, ib;
206  SplitBit(_ibit, _irght, _ilft, _ihfbit, &ia, &ib);
207 /*
208  *_ioffComp =_list_2_1[ia];
209  *_ioffComp+=_list_2_2[ib];
210 */
211 
212  //if(myrank==1)
213  //printf( "DEGBUG:_ibit=%ld, _list_2_1=%ld, _list_2_2=%ld\n", _ibit, _list_2_1[ia], _list_2_2[ib]);
214 
215  if(_list_2_1[ia]*_list_2_2[ib]==0){
216  *_ioffComp=0;
217  return FALSE;
218  }
219  *_ioffComp =_list_2_1[ia]-1;
220  *_ioffComp+=_list_2_2[ib]-1;
221 
222  return TRUE;
223 }
void SplitBit(const long unsigned int ibit, const long unsigned int irght, const long unsigned int ilft, const long unsigned int ihfbit, long unsigned int *isplited_Bit_right, long unsigned int *isplited_Bit_left)
function of splitting a original bit to right and left spaces
Definition: bitcalc.c:166
#define TRUE
Definition: global.h:26
#define FALSE
Definition: global.h:25
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetOffCompGeneralSpin()

int GetOffCompGeneralSpin ( const long unsigned int  org_ibit,
const int  org_isite,
const int  org_ispin,
const int  off_ispin,
long unsigned int *  _ioffComp,
const long int *  SiteToBit,
const long unsigned int *  Tpow 
)

function of getting off-diagonal component for general spin

Parameters
org_ibita original bit
org_isitea target site
org_ispina target spin to delete.
off_ispina target spin to create.
_ioffCompa generated bit
SiteToBitList for getting bit at a site
TpowList for getting total bit at a site before
Return values
FALSEoff-diagonal component does not exist
TRUEoff-diagonal component exists
Version
0.2
Author
Kazuyoshi Yoshimi (The University of Tokyo)
Parameters
[in]org_ibit
[in]org_isite
[in]org_ispin
[in]off_ispin
[out]_ioffComp
[in]SiteToBit
[in]Tpow

Definition at line 243 of file bitcalc.c.

References BitCheckGeneral(), FALSE, and TRUE.

Referenced by expec_cisajs_SpinGCGeneral(), expec_cisajscktalt_SpinGCGeneral(), expec_cisajscktalt_SpinGeneral(), GetPairExcitedStateGeneralSpin(), GetPairExcitedStateGeneralSpinGC(), makeHam(), mltplyGeneralSpin(), mltplyGeneralSpinGC(), totalspin_Spin(), totalspin_SpinGC(), X_child_CisAit_GeneralSpin_MPIdouble(), X_child_CisAitCjuAjv_GeneralSpin_MPIdouble(), X_child_CisAitCjuAjv_GeneralSpin_MPIsingle(), X_GC_child_CisAisCjuAjv_GeneralSpin_MPIdouble(), X_GC_child_CisAisCjuAjv_GeneralSpin_MPIsingle(), X_GC_child_CisAit_GeneralSpin_MPIdouble(), X_GC_child_CisAitCjuAju_GeneralSpin_MPIdouble(), X_GC_child_CisAitCjuAju_GeneralSpin_MPIsingle(), X_GC_child_CisAitCjuAjv_GeneralSpin_MPIdouble(), and X_GC_child_CisAitCjuAjv_GeneralSpin_MPIsingle().

252 {
253  if(off_ispin>SiteToBit[org_isite-1]-1 ||
254  off_ispin<0 ||
255  org_ispin>SiteToBit[org_isite-1]-1 ||
256  org_ispin <0){
257  *_ioffComp=0;
258  return FALSE;
259  }
260  if(BitCheckGeneral(org_ibit, org_isite, org_ispin, SiteToBit, Tpow) == FALSE){
261  *_ioffComp=0;
262  return FALSE;
263  }
264 
265  //delete org_ispin and create off_ispin
266  long int tmp_off=0;
267  tmp_off=(long int)(off_ispin-org_ispin);
268  tmp_off *=Tpow[org_isite-1];
269  tmp_off +=org_ibit;
270  *_ioffComp =tmp_off;
271  return TRUE;
272 }
#define TRUE
Definition: global.h:26
#define FALSE
Definition: global.h:25
int BitCheckGeneral(const long unsigned int org_bit, const unsigned int org_isite, const unsigned int target_ispin, const long int *SiteToBit, const long unsigned int *Tpow)
bit check function for general spin
Definition: bitcalc.c:393
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSplitBit()

int GetSplitBit ( const int  Nsite,
long unsigned int *  irght,
long unsigned int *  ilft,
long unsigned int *  ihfbit 
)

function of getting right, left and half bits corresponding to a original Hilbert space. }

Parameters
Nsitea total number of sites
irghta bit to split original Hilbert space into right space \(2^{(Ns+2)/2}-1\)
ilfta bit to split original Hilbert space into left space
ihfbita half bit to split original Hilbert space \(2^{(Ns+2)/2}\)
Version
0.1
Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)
Returns
Parameters
[in]Nsite
[out]irght
[out]ilft
[out]ihfbit

Definition at line 45 of file bitcalc.c.

References cErrSiteNumber.

Referenced by GetSplitBitByModel().

50  {
51  if(Nsite<1){
52  fprintf(stderr, "%s", cErrSiteNumber);
53  return -1;
54  }
55  *ihfbit=1;
56  *ihfbit=(*ihfbit<<(unsigned long int)((Nsite+1)/2));
57  *irght = *ihfbit-1;
58  *ilft=1;
59  *ilft = (*ilft<<(unsigned long int)Nsite)-1;
60  *ilft= *ilft ^ *irght;
61  return 0;
62 }
char * cErrSiteNumber
Error Message in bitcalc.c.
Definition: ErrorMessage.c:103
+ Here is the caller graph for this function:

◆ GetSplitBitByModel()

int GetSplitBitByModel ( const int  Nsite,
const int  iCalcModel,
long unsigned int *  irght,
long unsigned int *  ilft,
long unsigned int *  ihfbit 
)

function of splitting original bit into right and left spaces.

Parameters
Nsitea total number of sites
iCalcModelCalc model defined in CalcMode file
irghta bit to split original space into right space
ilfta bit to split original space into left space
ihfbita half bit to split original space
Version
0.1
Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)
Returns
Parameters
[in]Nsite
[in]iCalcModel
[out]irght
[out]ilft
[out]ihfbit

Definition at line 78 of file bitcalc.c.

References cErrNoModel, and GetSplitBit().

Referenced by expec_cisajs(), expec_cisajscktaltdc(), expec_energy_flct(), GetPairExcitedState(), GetPairExcitedStateHubbard(), makeHam(), mltply(), sz(), totalspin_Hubbard(), and totalspin_Spin().

85 {
86  int tmpNsite=Nsite;
87  switch(iCalcModel){
88  case HubbardGC:
89  case KondoGC:
90  case HubbardNConserved:
91  case Hubbard:
92  case Kondo:
93  tmpNsite *= 2;
94  break;
95  case Spin:
96  case SpinGC:
97  break;
98  default:
99  fprintf(stderr, cErrNoModel, iCalcModel);
100  return -1;
101  }
102 
103  if(GetSplitBit(tmpNsite, irght, ilft, ihfbit)!=0){
104  return -1;
105  }
106 
107  return 0;
108 }
int GetSplitBit(const int Nsite, long unsigned int *irght, long unsigned int *ilft, long unsigned int *ihfbit)
function of getting right, left and half bits corresponding to a original Hilbert space...
Definition: bitcalc.c:45
char * cErrNoModel
Error Message in diagonal calc.c.
Definition: ErrorMessage.c:99
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetSplitBitForGeneralSpin()

int GetSplitBitForGeneralSpin ( const int  Nsite,
long unsigned int *  ihfbit,
const long int *  SiteToBit 
)

function of getting right, left and half bits corresponding to a original space.

Parameters
Nsitea total number of sites
ihfbita bit to split original space
Return values
0normally finished
-1unnormally finished
Version
0.2
Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)
Parameters
[in]Nsite
[out]ihfbit
[in]SiteToBit

Definition at line 124 of file bitcalc.c.

References cErrSiteNumber.

Referenced by check(), GetPairExcitedState(), and mltply().

128  {
129  int isite=0;
130  long int isqrtMaxDim=1;
131  long int tmpbit=1;
132 
133  if(Nsite<1){
134  fprintf(stderr, "%s", cErrSiteNumber);
135  return -1;
136  }
137 
138  for(isite=1; isite<=Nsite ; isite++){
139  isqrtMaxDim *= SiteToBit[isite-1];
140  }
141  isqrtMaxDim =(long int)sqrt(isqrtMaxDim);
142 
143  for(isite=1; isite<=Nsite ; isite++){
144  tmpbit *= SiteToBit[isite-1];
145  if(tmpbit >= isqrtMaxDim) break;
146  }
147  *ihfbit=tmpbit;
148  return 0;
149 }
char * cErrSiteNumber
Error Message in bitcalc.c.
Definition: ErrorMessage.c:103
+ Here is the caller graph for this function:

◆ pop()

int pop ( unsigned int  x)

calculating number of 1-bits in x (32 bit) This method is introduced in S.H. Warren, Hacker$B!G(Bs Delight, second ed., Addison-Wesley, ISBN: 0321842685, 2012.

Parameters
x
Version
2.0
Author
Takahiro Misawa (The University of Tokyo)

Definition at line 492 of file bitcalc.c.

Referenced by expec_energy_flct_HalfSpin(), expec_energy_flct_HalfSpinGC(), expec_energy_flct_Hubbard(), and expec_energy_flct_HubbardGC().

492  {
493  x = x - ((x>>1) & 0x55555555);
494  x = (x & 0x33333333)+ ((x>>2)& 0x33333333);
495  x = (x+(x>>4)) & 0x0F0F0F0F;
496  x = x+ (x>>8);
497  x = x+ (x>>16);
498  return x & 0x0000003F;
499 }
+ Here is the caller graph for this function:

◆ SgnBit()

void SgnBit ( const long unsigned int  org_bit,
int *  sgn 
)

function of getting fermion sign (64 bit)

Parameters
org_bitan original bit
sgnfermion sign
Version
0.1
Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)
Parameters
[in]org_bit
[out]sgn

Definition at line 339 of file bitcalc.c.

Referenced by CisAjt(), GC_Ajt(), GC_Cis(), GC_CisAjt(), X_Ajt(), X_Ajt_MPI(), X_child_CisAjt_MPIdouble(), X_child_CisAjt_MPIsingle(), X_child_CisAjtCkuAku_Hubbard_MPI(), X_child_general_hopp_MPIdouble(), X_child_general_hopp_MPIsingle(), X_Cis(), X_Cis_MPI(), X_GC_Ajt_MPI(), X_GC_child_CisAjtCkuAku_Hubbard_MPI(), X_GC_child_general_hopp_MPIdouble(), X_GC_child_general_hopp_MPIsingle(), X_GC_Cis_MPI(), and X_GC_CisAjt().

343 {
344  long unsigned int bit;
345 
346  bit = org_bit^(org_bit>>1);
347  bit = bit^(bit>>2);
348  bit = bit^(bit>>4);
349  bit = bit^(bit>>8);
350  bit = bit^(bit>>16);
351  bit = bit^(bit>>32);
352  *sgn = 1-2*(bit & 1); // sgn = pm 1
353 }
+ Here is the caller graph for this function:

◆ SgnBit_old()

void SgnBit_old ( const long unsigned int  org_bit,
int *  sgn 
)

function of getting fermion signs (for 32bit)

Parameters
org_bitan original bit
sgnfermion sign
Version
0.1
Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)
Parameters
[in]org_bit
[out]sgn

Definition at line 313 of file bitcalc.c.

317 {
318  long unsigned int bit;
319 
320  bit = org_bit^(org_bit>>1);
321  bit = (bit^(bit>>2) ) & 0x11111111;
322  bit = bit*0x11111111;
323  *sgn = 1-2*((bit>>28) & 1); // sgn = pm 1
324 }

◆ snoob()

unsigned long int snoob ( unsigned long int  x)

"finding the next higher number after a given number that has the same number of 1-bits" This method is introduced in S.H. Warren, Hacker$B!G(Bs Delight, second ed., Addison-Wesley, ISBN: 0321842685, 2012.

Parameters
x
Version
2.0
Author
Takahiro Misawa (The University of Tokyo)

Definition at line 474 of file bitcalc.c.

Referenced by child_omp_sz_hacker(), child_omp_sz_Kondo_hacker(), child_omp_sz_spin_hacker(), and sz().

474  {
475  unsigned long int smallest, ripple, ones;
476  smallest = x &(-x);
477  ripple = x+ smallest;
478  ones = x ^ ripple;
479  ones = (ones>>2)/smallest;
480  return ripple|ones;
481 }
+ Here is the caller graph for this function:

◆ SplitBit()

void SplitBit ( const long unsigned int  ibit,
const long unsigned int  irght,
const long unsigned int  ilft,
const long unsigned int  ihfbit,
long unsigned int *  isplited_Bit_right,
long unsigned int *  isplited_Bit_left 
)

function of splitting a original bit to right and left spaces

Parameters
ibita original bit
irghta bit to split original space into right space
ilfta bit to split original space into left space
ihfbita half bit to split original space
isplited_Bit_righta splitted bit reflected on right space
isplited_Bit_lefta splitted bit reflected on left space
Version
0.1
Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)
Parameters
[in]ibit
[in]irght
[in]ilft
[in]ihfbit
[out]isplited_Bit_right
[out]isplited_Bit_left

Definition at line 166 of file bitcalc.c.

Referenced by GetOffComp().

174 {
175  *isplited_Bit_right=ibit & irght;
176  *isplited_Bit_left=ibit & ilft;
177  *isplited_Bit_left=*isplited_Bit_left/ihfbit;
178 }
+ Here is the caller graph for this function: