File tree Expand file tree Collapse file tree 1 file changed +16
-14
lines changed Expand file tree Collapse file tree 1 file changed +16
-14
lines changed Original file line number Diff line number Diff line change @@ -11,27 +11,29 @@ pseudo::~pseudo()
1111
1212void pseudo::check_betar ()
1313{
14+ bool min_flag = false ;
1415 for (int ib = 0 ; ib < nbeta; ib++)
1516 {
16- int flag = mesh+1 ;
1717 for (int ir = 0 ; ir < mesh; ir++)
1818 {
19- // to check is non-normal number and it shoule not be zero
20- if ((std::abs (betar (ib, ir)) < 1.0e-30 ) && (std::abs (betar (ib, ir))!=0 ))
19+ // Get the bit representation of the double
20+ uint64_t bits = *(uint64_t *)&betar (ib, ir);
21+ // Extract exponent field (bits 52-62)
22+ uint64_t exponent = (bits >> 52 ) & 0x7FF ;
23+ // Define exponent threshold for 1e-30
24+ // Calculated as: bias + floor(log2(1e-30))
25+ // Where bias = 1023 and log2(1e-30) ≈ -99.657
26+ // Thus threshold is approximately 923
27+ if ((exponent <= 923 ))
2128 {
22- flag = ir ;
23- break ;
29+ min_flag = true ;
30+ betar (ib, ir) = 0.0 ;
2431 }
2532 }
26- if (flag<mesh)
27- {
28- std::cout << " WARNING: beta function is set to "
29- << " zero for beta after " <<std::to_string (flag + 1 );
30- }
31- for (int ir = flag; ir < mesh; ir++)
32- {
33- betar (ib, ir) = 0.0 ;
34- }
33+ }
34+ if (min_flag)
35+ {
36+ std::cout << " WARNING: some of potential function is set to zero cause of less than 1e-30.\n " ;
3537 }
3638}
3739
You can’t perform that action at this time.
0 commit comments