Remove deprecated files; make sure data output is precision 16
This commit is contained in:
@@ -20,11 +20,11 @@ using namespace JSC;
|
||||
|
||||
namespace JSC {
|
||||
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, bool fixed_iK, XXZ_Bethe_State& LeftState,
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, bool fixed_iK, XXZ_Bethe_State& LeftState,
|
||||
//XXZ_Bethe_State& RightState, DP Chem_Pot, fstream& DAT_outfile)
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXZ_Bethe_State& LeftState,
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXZ_Bethe_State& LeftState,
|
||||
// XXZ_Bethe_State& RightState, DP Chem_Pot, fstream& DAT_outfile)
|
||||
DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXZ_Bethe_State& LeftState,
|
||||
DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXZ_Bethe_State& LeftState,
|
||||
XXZ_Bethe_State& RightState, DP Chem_Pot, stringstream& DAT_outfile)
|
||||
{
|
||||
// This function prints the matrix information to the fstream,
|
||||
@@ -61,20 +61,21 @@ namespace JSC {
|
||||
while(iKout < 0) iKout += RightState.chain.Nsites;
|
||||
while(iKout >= RightState.chain.Nsites) iKout -= RightState.chain.Nsites;
|
||||
|
||||
DAT_outfile << setprecision(16);
|
||||
// Print information to fstream:
|
||||
if (iKout >= iKmin && iKout <= iKmax) {
|
||||
if (whichDSF == 'Z') {
|
||||
DAT_outfile << endl << setprecision(16) << LeftState.E - RightState.E - (LeftState.base.Mdown - RightState.base.Mdown) * Chem_Pot << "\t"
|
||||
DAT_outfile << endl << setprecision(16) << LeftState.E - RightState.E - (LeftState.base.Mdown - RightState.base.Mdown) * Chem_Pot << "\t"
|
||||
<< iKout << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
<< setprecision(3) << LeftState.dev << "\t"
|
||||
<< LeftState.label;
|
||||
}
|
||||
else {
|
||||
DAT_outfile << endl << setprecision(16) << LeftState.E - RightState.E - (LeftState.base.Mdown - RightState.base.Mdown) * Chem_Pot << "\t"
|
||||
DAT_outfile << endl << setprecision(16) << LeftState.E - RightState.E - (LeftState.base.Mdown - RightState.base.Mdown) * Chem_Pot << "\t"
|
||||
<< iKout << "\t"
|
||||
<< ME << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
<< setprecision(3) << LeftState.dev << "\t"
|
||||
<< LeftState.label;
|
||||
}
|
||||
@@ -92,11 +93,11 @@ namespace JSC {
|
||||
return(data_value);
|
||||
}
|
||||
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, bool fixed_iK, XXX_Bethe_State& LeftState,
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, bool fixed_iK, XXX_Bethe_State& LeftState,
|
||||
//XXX_Bethe_State& RightState, DP Chem_Pot, fstream& DAT_outfile)
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXX_Bethe_State& LeftState,
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXX_Bethe_State& LeftState,
|
||||
//XXX_Bethe_State& RightState, DP Chem_Pot, fstream& DAT_outfile)
|
||||
DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXX_Bethe_State& LeftState,
|
||||
DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXX_Bethe_State& LeftState,
|
||||
XXX_Bethe_State& RightState, DP Chem_Pot, stringstream& DAT_outfile)
|
||||
{
|
||||
// This function prints the matrix element information to the fstream,
|
||||
@@ -137,7 +138,7 @@ namespace JSC {
|
||||
if (LeftState.base.Mdown == RightState.base.Mdown - 1) { // two infinite rapidities, use rescaled S^- matrix element instead of S^+
|
||||
nrinfrap = 2;
|
||||
// Correction factor for MEsq: Smffsq to Spffsq = 2/((N - 2M + 2) (N - 2M + 1))
|
||||
ME = sqrt(2.0/((RightState.chain.Nsites - 2*RightState.base.Mdown + 2.0) * (RightState.chain.Nsites - 2*RightState.base.Mdown + 1.0)))
|
||||
ME = sqrt(2.0/((RightState.chain.Nsites - 2*RightState.base.Mdown + 2.0) * (RightState.chain.Nsites - 2*RightState.base.Mdown + 1.0)))
|
||||
* exp(real(ln_Smin_ME (RightState, LeftState)));
|
||||
}
|
||||
else if (LeftState.base.Mdown == RightState.base.Mdown) { // one infinite rapidity, use rescaled S^z matrix element instead of S^+
|
||||
@@ -170,29 +171,30 @@ namespace JSC {
|
||||
while(iKout < 0) iKout += RightState.chain.Nsites;
|
||||
while(iKout >= RightState.chain.Nsites) iKout -= RightState.chain.Nsites;
|
||||
|
||||
DAT_outfile << setprecision(16);
|
||||
// Print information to fstream:
|
||||
if (iKout >= iKmin && iKout <= iKmax) {
|
||||
if (whichDSF == 'Z') {
|
||||
DAT_outfile << endl << setprecision(16) << LeftState.E - RightState.E - (LeftState.base.Mdown + nrinfrap - RightState.base.Mdown) * Chem_Pot << "\t"
|
||||
DAT_outfile << endl << setprecision(16) << LeftState.E - RightState.E - (LeftState.base.Mdown + nrinfrap - RightState.base.Mdown) * Chem_Pot << "\t"
|
||||
<< iKout << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
<< setprecision(3) << LeftState.dev << "\t"
|
||||
<< LeftState.label;
|
||||
}
|
||||
else if (whichDSF == 'q') {
|
||||
DAT_outfile << endl << setprecision(16) << LeftState.E - RightState.E - (LeftState.base.Mdown + nrinfrap - RightState.base.Mdown) * Chem_Pot << "\t"
|
||||
DAT_outfile << endl << setprecision(16) << LeftState.E - RightState.E - (LeftState.base.Mdown + nrinfrap - RightState.base.Mdown) * Chem_Pot << "\t"
|
||||
<< iKout << "\t"
|
||||
<< real(ME_CX) << "\t" << imag(ME_CX) - twoPI * int(imag(ME_CX)/twoPI + 1.0e-10) << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
<< setprecision(3) << LeftState.dev << "\t"
|
||||
<< LeftState.label;
|
||||
}
|
||||
|
||||
else {
|
||||
DAT_outfile << endl << setprecision(16) << LeftState.E - RightState.E - (LeftState.base.Mdown + nrinfrap - RightState.base.Mdown) * Chem_Pot << "\t"
|
||||
DAT_outfile << endl << setprecision(16) << LeftState.E - RightState.E - (LeftState.base.Mdown + nrinfrap - RightState.base.Mdown) * Chem_Pot << "\t"
|
||||
<< iKout << "\t"
|
||||
<< ME << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
<< setprecision(3) << LeftState.dev << "\t"
|
||||
<< LeftState.label;
|
||||
}
|
||||
@@ -203,7 +205,7 @@ namespace JSC {
|
||||
//DP data_value = (iKout == 0 ? 1.0 : 2.0) * MEsq;
|
||||
if (whichDSF == 'Z') // use 1/(1 + omega)
|
||||
data_value = 1.0/(1.0 + LeftState.E - RightState.E - (LeftState.base.Mdown - RightState.base.Mdown) * Chem_Pot);
|
||||
else if (whichDSF == 'q')
|
||||
else if (whichDSF == 'q')
|
||||
data_value = exp(2.0 * real(ME_CX));
|
||||
else if (fixed_iK) // data value is MEsq * omega:
|
||||
data_value = ME * ME * (LeftState.E - RightState.E - (LeftState.base.Mdown - RightState.base.Mdown) * Chem_Pot);
|
||||
@@ -211,11 +213,11 @@ namespace JSC {
|
||||
return(data_value);
|
||||
}
|
||||
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, bool fixed_iK, XXZ_gpd_Bethe_State& LeftState,
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, bool fixed_iK, XXZ_gpd_Bethe_State& LeftState,
|
||||
//XXZ_gpd_Bethe_State& RightState, DP Chem_Pot, fstream& DAT_outfile)
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXZ_gpd_Bethe_State& LeftState,
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXZ_gpd_Bethe_State& LeftState,
|
||||
// XXZ_gpd_Bethe_State& RightState, DP Chem_Pot, fstream& DAT_outfile)
|
||||
DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXZ_gpd_Bethe_State& LeftState,
|
||||
DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, XXZ_gpd_Bethe_State& LeftState,
|
||||
XXZ_gpd_Bethe_State& RightState, DP Chem_Pot, stringstream& DAT_outfile)
|
||||
{
|
||||
// This function prints the matrix element information to the fstream,
|
||||
@@ -233,7 +235,7 @@ namespace JSC {
|
||||
*/
|
||||
|
||||
bool fixed_iK = (iKmin == iKmax);
|
||||
|
||||
|
||||
|
||||
// If any of the rapidities outside of fundamental interval -pi/2 < lambda <= pi/2, set matrix element to zero.
|
||||
bool rap_in_fundamental = true;
|
||||
@@ -254,9 +256,9 @@ namespace JSC {
|
||||
for (int k = 0; k < LeftState.chain.Nstrings; ++k)
|
||||
sum1 += LeftState.base.Nrap[k] * (2 * JSC::min(LeftState.chain.Str_L[j], LeftState.chain.Str_L[k]) - ((j == k) ? 1 : 0));
|
||||
// This almost does it: only missing are the states with one on -PI/2 and one on PI/2
|
||||
if (LeftState.base.Nrap[j] >= 1
|
||||
&& (LeftState.Ix2[j][0] <= -(LeftState.chain.Nsites - sum1)
|
||||
|| (LeftState.Ix2[j][LeftState.base.Nrap[j] - 1] - LeftState.Ix2[j][0])
|
||||
if (LeftState.base.Nrap[j] >= 1
|
||||
&& (LeftState.Ix2[j][0] <= -(LeftState.chain.Nsites - sum1)
|
||||
|| (LeftState.Ix2[j][LeftState.base.Nrap[j] - 1] - LeftState.Ix2[j][0])
|
||||
> 2*(LeftState.chain.Nsites - sum1)))
|
||||
rap_in_fundamental = false;
|
||||
*/
|
||||
@@ -267,7 +269,7 @@ namespace JSC {
|
||||
// rap_in_fundamental = false;
|
||||
//}
|
||||
/*
|
||||
if (LeftState.base.Nrap[j] > 0 &&
|
||||
if (LeftState.base.Nrap[j] > 0 &&
|
||||
((LeftState.lambda[j][LeftState.base.Nrap[j] - 1] - LeftState.lambda[j][0] >= PI)
|
||||
|| LeftState.lambda[j][0] < -0.5*PI + 1.0e-10
|
||||
|| LeftState.lambda[j][LeftState.base.Nrap[j] - 1] > 0.5*PI
|
||||
@@ -279,7 +281,7 @@ namespace JSC {
|
||||
rap_in_fundamental = false;
|
||||
*/
|
||||
/*
|
||||
if (LeftState.base.Nrap[j] > 0 &&
|
||||
if (LeftState.base.Nrap[j] > 0 &&
|
||||
((LeftState.lambda[j][LeftState.base.Nrap[j] - 1] - LeftState.lambda[j][0] >= PI)
|
||||
//|| (LeftState.base.Nrap[j] == 1 && fabs(LeftState.lambda[j][0]) > 0.5*PI)
|
||||
))
|
||||
@@ -287,10 +289,10 @@ namespace JSC {
|
||||
*/
|
||||
|
||||
// Logic: allow rapidities -PI/2 <= lambda <= PI/2 (including boundaries)
|
||||
if (LeftState.base.Nrap[j] > 0 &&
|
||||
if (LeftState.base.Nrap[j] > 0 &&
|
||||
(LeftState.lambda[j][0] < -PI/2 || LeftState.lambda[j][LeftState.base.Nrap[j] - 1] > PI/2))
|
||||
rap_in_fundamental = false;
|
||||
if (RightState.base.Nrap[j] > 0 &&
|
||||
if (RightState.base.Nrap[j] > 0 &&
|
||||
(RightState.lambda[j][0] < -PI/2 || RightState.lambda[j][RightState.base.Nrap[j] - 1] > PI/2))
|
||||
rap_in_fundamental = false;
|
||||
|
||||
@@ -334,20 +336,21 @@ namespace JSC {
|
||||
while(iKout < 0) iKout += RightState.chain.Nsites;
|
||||
while(iKout >= RightState.chain.Nsites) iKout -= RightState.chain.Nsites;
|
||||
|
||||
DAT_outfile << setprecision(16);
|
||||
// Print information to fstream:
|
||||
if (iKout >= iKmin && iKout <= iKmax) {
|
||||
if (whichDSF == 'Z') {
|
||||
DAT_outfile << endl << setprecision(16) << LeftState.E - RightState.E - (LeftState.base.Mdown - RightState.base.Mdown) * Chem_Pot << "\t"
|
||||
DAT_outfile << endl << setprecision(16) << LeftState.E - RightState.E - (LeftState.base.Mdown - RightState.base.Mdown) * Chem_Pot << "\t"
|
||||
<< iKout << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
<< setprecision(3) << LeftState.dev << "\t"
|
||||
<< LeftState.label;
|
||||
}
|
||||
else {
|
||||
DAT_outfile << endl << setprecision(16) << LeftState.E - RightState.E - (LeftState.base.Mdown - RightState.base.Mdown) * Chem_Pot << "\t"
|
||||
DAT_outfile << endl << setprecision(16) << LeftState.E - RightState.E - (LeftState.base.Mdown - RightState.base.Mdown) * Chem_Pot << "\t"
|
||||
<< iKout << "\t"
|
||||
<< ME << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
<< setprecision(3) << LeftState.dev << "\t"
|
||||
<< LeftState.label;
|
||||
|
||||
|
||||
@@ -20,11 +20,11 @@ using namespace JSC;
|
||||
|
||||
namespace JSC {
|
||||
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, bool fixed_iK, LiebLin_Bethe_State& LeftState,
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, bool fixed_iK, LiebLin_Bethe_State& LeftState,
|
||||
// LiebLin_Bethe_State& RefState, DP Chem_Pot, fstream& DAT_outfile)
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, LiebLin_Bethe_State& LeftState,
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, LiebLin_Bethe_State& LeftState,
|
||||
// LiebLin_Bethe_State& RefState, DP Chem_Pot, fstream& DAT_outfile)
|
||||
DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, LiebLin_Bethe_State& LeftState,
|
||||
DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, LiebLin_Bethe_State& LeftState,
|
||||
LiebLin_Bethe_State& RefState, DP Chem_Pot, stringstream& DAT_outfile)
|
||||
{
|
||||
// This function prints the matrix element information to the fstream,
|
||||
@@ -45,7 +45,7 @@ namespace JSC {
|
||||
ME = real(exp(ln_Psi_ME (LeftState, RefState)));
|
||||
else if (whichDSF == 'g')
|
||||
ME = real(exp(ln_Psi_ME (RefState, LeftState)));
|
||||
else if (whichDSF == 'q') // geometrical quench
|
||||
else if (whichDSF == 'q') // geometrical quench
|
||||
//ME_CX = (LiebLin_Twisted_ln_Overlap(1.0, RefState.lambdaoc, RefState.lnnorm, LeftState));
|
||||
//ME_CX = (LiebLin_ln_Overlap(RefState.lambdaoc, RefState.lnnorm, LeftState));
|
||||
ME_CX = LiebLin_ln_Overlap(LeftState.lambdaoc, LeftState.lnnorm, RefState);
|
||||
@@ -56,66 +56,67 @@ namespace JSC {
|
||||
// The product is ME_CX * ME = e^{-\delta S_e} \langle \rho_{sp} | g2 (x=0) | \rho_{sp} + e \rangle
|
||||
// and is the first half of the t-dep expectation value formula coming from the Quench Action formalism
|
||||
}
|
||||
else if (whichDSF == 'C') { // BEC to finite c quench: overlap
|
||||
else if (whichDSF == 'C') { // BEC to finite c quench: overlap
|
||||
ME_CX = exp(2.0* ln_Overlap_with_BEC (LeftState)); // overlap sq part
|
||||
ME = 0.0;
|
||||
}
|
||||
else JSCerror("Wrong whichDSF in Compute_Matrix_Element_Contrib.");
|
||||
|
||||
if (is_nan(ME)) ME = (whichDSF == 'Z') ? 1.0e+200 : 0.0;
|
||||
if (is_nan(ME)) ME = (whichDSF == 'Z') ? 1.0e+200 : 0.0;
|
||||
if (is_nan(norm(ME_CX))) ME_CX = -100.0;
|
||||
|
||||
|
||||
|
||||
DAT_outfile << setprecision(16);
|
||||
// Print information to fstream:
|
||||
if (LeftState.iK - RefState.iK >= iKmin && LeftState.iK - RefState.iK <= iKmax) {
|
||||
if (whichDSF == 'Z') {
|
||||
DAT_outfile << endl << LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot << "\t"
|
||||
<< LeftState.iK - RefState.iK
|
||||
//<< "\t" << LeftState.conv
|
||||
DAT_outfile << endl << LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot << "\t"
|
||||
<< LeftState.iK - RefState.iK
|
||||
//<< "\t" << LeftState.conv
|
||||
<< 0 << "\t" // This is the deviation, here always 0
|
||||
<< "\t" << LeftState.label;
|
||||
}
|
||||
else if (whichDSF == 'q') {
|
||||
DAT_outfile << endl << LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot << "\t"
|
||||
DAT_outfile << endl << LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot << "\t"
|
||||
<< LeftState.iK - RefState.iK << "\t"
|
||||
<< real(ME_CX) << "\t" << imag(ME_CX) - twoPI * int(imag(ME_CX)/twoPI + 1.0e-10) << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
<< 0 << "\t" // This is the deviation, here always 0
|
||||
<< LeftState.label;
|
||||
}
|
||||
else if (whichDSF == '1') {
|
||||
DAT_outfile << endl << LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot << "\t"
|
||||
DAT_outfile << endl << LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot << "\t"
|
||||
<< LeftState.iK - RefState.iK << "\t"
|
||||
<< ME << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
<< 0 << "\t" // This is the deviation, here always 0
|
||||
<< LeftState.label;
|
||||
DAT_outfile << "\t" << Momentum_Right_Excitations(LeftState) << "\t" << Momentum_Left_Excitations(LeftState);
|
||||
//cout << Momentum_Right_Excitations(LeftState) << "\t" << Momentum_Left_Excitations(LeftState);
|
||||
}
|
||||
else if (whichDSF == 'B') { // BEC to finite c > 0 quench; g2 (x=0)
|
||||
if (fabs(real(ME_CX) * ME) > 1.0e-100)
|
||||
if (fabs(real(ME_CX) * ME) > 1.0e-100)
|
||||
DAT_outfile << endl << LeftState.E - RefState.E << "\t"
|
||||
<< LeftState.iK - RefState.iK << "\t"
|
||||
<< real(ME_CX) << "\t" // the overlap is always real
|
||||
<< ME << "\t"
|
||||
<< ME << "\t"
|
||||
//<< 0 << "\t" // This is the deviation, here always 0 // omit this here
|
||||
<< LeftState.label;
|
||||
}
|
||||
else if (whichDSF == 'C') { // BEC to finite c, overlap sq
|
||||
if (fabs(real(ME_CX)) > 1.0e-100)
|
||||
if (fabs(real(ME_CX)) > 1.0e-100)
|
||||
DAT_outfile << endl << LeftState.E - RefState.E << "\t"
|
||||
<< LeftState.iK - RefState.iK << "\t"
|
||||
<< real(ME_CX) << "\t" // the overlap is always real
|
||||
<< ME << "\t"
|
||||
<< ME << "\t"
|
||||
//<< 0 << "\t" // This is the deviation, here always 0 // omit this here
|
||||
<< LeftState.label;
|
||||
}
|
||||
else {
|
||||
DAT_outfile << endl << LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot << "\t"
|
||||
DAT_outfile << endl << LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot << "\t"
|
||||
<< LeftState.iK - RefState.iK << "\t"
|
||||
<< ME << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
<< 0 << "\t" // This is the deviation, here always 0
|
||||
<< LeftState.label;
|
||||
}
|
||||
@@ -126,36 +127,36 @@ namespace JSC {
|
||||
if (whichDSF == 'Z') // use 1/(1 + omega)
|
||||
data_value = 1.0/(1.0 + LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot);
|
||||
else if (whichDSF == 'd' || whichDSF == '1') {
|
||||
if (fixed_iK)
|
||||
if (fixed_iK)
|
||||
/*
|
||||
// use omega * MEsq/iK^2
|
||||
//data_value = (LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot)
|
||||
// use omega * MEsq/iK^2
|
||||
//data_value = (LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot)
|
||||
// MEsq/JSC::max(1, (LeftState.iK - RefState.iK) * (LeftState.iK - RefState.iK))
|
||||
//: 0.0;
|
||||
//: 0.0;
|
||||
*/
|
||||
// Careful: use fabs(E) since this must also work with Tgt0 or arbitrary RefState DEPRECATED ++G_1, USE abs_data_value
|
||||
data_value = (LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot) * ME * ME;
|
||||
else if (!fixed_iK) // use ME if momentum in fundamental window -iK_UL <= iK <= iK_UL
|
||||
//data_value = abs(LeftState.iK - RefState.iK) <= RefState.Tableau[0].Ncols ? // this last nr is iK_UL
|
||||
//data_value = abs(LeftState.iK - RefState.iK) <= RefState.Tableau[0].Ncols ? // this last nr is iK_UL
|
||||
//MEsq : 0.0;
|
||||
//data_value = (LeftState.iK - RefState.iK == 0 ? 1.0 : 2.0) * MEsq;
|
||||
//data_value = ME * ME;
|
||||
// use omega * MEsq/iK^2
|
||||
// use omega * MEsq/iK^2
|
||||
// Careful: use fabs(E) since this must also work with Tgt0 or arbitrary RefState DEPRECATED ++G_1, USE abs_data_value
|
||||
data_value = (LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot) * ME * ME/JSC::max(1, (LeftState.iK - RefState.iK) * (LeftState.iK - RefState.iK));
|
||||
}
|
||||
else if (whichDSF == 'g' || whichDSF == 'o') {
|
||||
if (fixed_iK)
|
||||
if (fixed_iK)
|
||||
/*
|
||||
// use omega * MEsq/((k^2 - mu + 4 c N/L)/L)
|
||||
data_value = (LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot)
|
||||
data_value = (LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot)
|
||||
* MEsq/((((LeftState.K - RefState.K) * (LeftState.K - RefState.K) - Chem_Pot) + 4.0 * RefState.c_int * RefState.N/RefState.L)/RefState.L)
|
||||
: 0.0;
|
||||
*/
|
||||
// Careful: use fabs(E) since this must also work with Tgt0 or arbitrary RefState
|
||||
data_value = (LeftState.E - RefState.E - (LeftState.N - RefState.N) * Chem_Pot) * ME * ME;
|
||||
else if (!fixed_iK) { // simply use MEsq if momentum in fundamental window -iK_UL <= iK <= iK_UL
|
||||
//data_value = abs(LeftState.iK - RefState.iK) <= RefState.Tableau[0].Ncols ? // this last nr is iK_UL
|
||||
//data_value = abs(LeftState.iK - RefState.iK) <= RefState.Tableau[0].Ncols ? // this last nr is iK_UL
|
||||
//MEsq : 0.0;
|
||||
//data_value = (LeftState.iK - RefState.iK == 0 ? 1.0 : 2.0) * MEsq;
|
||||
data_value = ME * ME;
|
||||
@@ -165,9 +166,9 @@ namespace JSC {
|
||||
}
|
||||
}
|
||||
//else if (whichDSF == 'o')
|
||||
//data_value = abs(LeftState.iK - RefState.iK) <= RefState.Tableau[0].Ncols ? // this last nr is iK_UL
|
||||
//data_value = abs(LeftState.iK - RefState.iK) <= RefState.Tableau[0].Ncols ? // this last nr is iK_UL
|
||||
//MEsq : 0.0;
|
||||
else if (whichDSF == 'q')
|
||||
else if (whichDSF == 'q')
|
||||
data_value = exp(2.0 * real(ME_CX));
|
||||
else if (whichDSF == 'B')
|
||||
data_value = abs(ME_CX * ME)/(1.0 + sqrt(fabs(LeftState.E - RefState.E)));
|
||||
|
||||
@@ -20,9 +20,9 @@ using namespace JSC;
|
||||
|
||||
namespace JSC {
|
||||
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, bool fixed_iK, ODSLF_XXZ_Bethe_State& LeftState,
|
||||
//DP Compute_Matrix_Element_Contrib (char whichDSF, bool fixed_iK, ODSLF_XXZ_Bethe_State& LeftState,
|
||||
//ODSLF_XXZ_Bethe_State& RefState, DP Chem_Pot, fstream& DAT_outfile)
|
||||
DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, ODSLF_XXZ_Bethe_State& LeftState,
|
||||
DP Compute_Matrix_Element_Contrib (char whichDSF, int iKmin, int iKmax, ODSLF_XXZ_Bethe_State& LeftState,
|
||||
ODSLF_XXZ_Bethe_State& RefState, DP Chem_Pot, fstream& DAT_outfile)
|
||||
{
|
||||
// This function prints the matrix element information to the fstream,
|
||||
@@ -55,19 +55,20 @@ namespace JSC {
|
||||
while(iKout < 0) iKout += RefState.chain.Nsites;
|
||||
while(iKout >= RefState.chain.Nsites) iKout -= RefState.chain.Nsites;
|
||||
|
||||
DAT_outfile << setprecision(16);
|
||||
// Print information to fstream:
|
||||
if (iKout >= iKmin && iKout <= iKmax) {
|
||||
if (whichDSF == 'Z') {
|
||||
DAT_outfile << endl << LeftState.E - RefState.E - (LeftState.base.Mdown - RefState.base.Mdown) * Chem_Pot << "\t"
|
||||
DAT_outfile << endl << LeftState.E - RefState.E - (LeftState.base.Mdown - RefState.base.Mdown) * Chem_Pot << "\t"
|
||||
<< iKout << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
<< LeftState.base_id << "\t" << LeftState.type_id << "\t" << LeftState.id;
|
||||
}
|
||||
else {
|
||||
DAT_outfile << endl << LeftState.E - RefState.E - (LeftState.base.Mdown - RefState.base.Mdown) * Chem_Pot << "\t"
|
||||
DAT_outfile << endl << LeftState.E - RefState.E - (LeftState.base.Mdown - RefState.base.Mdown) * Chem_Pot << "\t"
|
||||
<< iKout << "\t"
|
||||
<< ME << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
//<< LeftState.conv << "\t"
|
||||
<< LeftState.base_id << "\t" << LeftState.type_id << "\t" << LeftState.id;
|
||||
}
|
||||
} // if iKmin <= iKout <= iKmax
|
||||
|
||||
+210
-210
File diff suppressed because it is too large
Load Diff
@@ -1,466 +0,0 @@
|
||||
/**********************************************************
|
||||
|
||||
This software is part of J.-S. Caux's ABACUS library.
|
||||
|
||||
Copyright (c).
|
||||
|
||||
-----------------------------------------------------------
|
||||
|
||||
File: Scan_Thread_List.cc
|
||||
|
||||
Purpose: defines all functions for Scan_Thread_List class.
|
||||
|
||||
|
||||
***********************************************************/
|
||||
|
||||
#include "JSC.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace JSC;
|
||||
|
||||
namespace JSC {
|
||||
|
||||
Scan_Thread_List::Scan_Thread_List()
|
||||
{
|
||||
dim = 2;
|
||||
nthreads_tot = 0;
|
||||
nthreads_done = 0;
|
||||
//omega = Vect<float>(1.0e+6, dim);
|
||||
//iK = Vect_INT(0, dim);
|
||||
//abs_data_value = Vect_DP (0.0, Nentries);
|
||||
abs_data_value = Vect<float> (0.0, dim);
|
||||
label = Vect<string> (dim);
|
||||
type = Vect<int> (dim);
|
||||
isdone = Vect<bool> (false, dim);
|
||||
}
|
||||
|
||||
Scan_Thread_List::Scan_Thread_List (int Nentries)
|
||||
{
|
||||
dim = Nentries;
|
||||
nthreads_tot = 0;
|
||||
nthreads_done = 0;
|
||||
////omega = Vect_DP(1.0e+6, Nentries);
|
||||
//omega = Vect<float>(1.0e+6, Nentries);
|
||||
//iK = Vect_INT(0, Nentries);
|
||||
//abs_data_value = Vect_DP (0.0, Nentries);
|
||||
abs_data_value = Vect<float> (0.0, Nentries);
|
||||
label = Vect<string> (Nentries);
|
||||
type = Vect<int> (Nentries);
|
||||
isdone = Vect<bool> (false, Nentries);
|
||||
}
|
||||
|
||||
bool Scan_Thread_List::Increase_Size (int nr_to_add) // resizes the vectors to accommodate up to nr_to_add additional entries
|
||||
{
|
||||
dim += nr_to_add;
|
||||
// Nentries stays the same
|
||||
|
||||
//cout << "Called Increase_Size with nr_to_add = " << nr_to_add << endl;
|
||||
try {
|
||||
//omega.Increase_Size (nr_to_add);
|
||||
//iK.Increase_Size (nr_to_add);
|
||||
abs_data_value.Increase_Size (nr_to_add);
|
||||
//cout << "Increasing size of label" << endl;
|
||||
label.Increase_Size (nr_to_add, "");
|
||||
//cout << "Done increasing size of label" << endl;
|
||||
type.Increase_Size (nr_to_add);
|
||||
isdone.Increase_Size (nr_to_add, false);
|
||||
}
|
||||
|
||||
catch (bad_alloc) {
|
||||
cout << "dim " << dim << "\tnr_to_add " << nr_to_add << endl;
|
||||
JSCerror("Memory allocation failed in Scan_Thread_List::Increase_Size.");
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
//void Scan_Thread_List::Include_Thread (DP omega_ref, int iK_ref, DP abs_data_value_ref, string label_ref, int type_ref)
|
||||
void Scan_Thread_List::Include_Thread (DP data_value_ref, string label_ref, int type_ref)
|
||||
{
|
||||
if (nthreads_tot > dim - 10) { // Resize the Scan_Thread_List, by doubling its size
|
||||
//cout << "Resizing threads list" << endl;
|
||||
(*this).Increase_Size (dim);
|
||||
//cout << "Done resizing" << endl;
|
||||
}
|
||||
|
||||
//cout << "Including thread for label " << label_ref << " and type " << type_ref << endl;
|
||||
|
||||
//omega[nthreads] = omega_ref;
|
||||
//iK[nthreads] = iK_ref;
|
||||
abs_data_value[nthreads_tot] = abs(data_value_ref);
|
||||
label[nthreads_tot] = label_ref;
|
||||
type[nthreads_tot] = type_ref;
|
||||
isdone[nthreads_tot] = false;
|
||||
|
||||
nthreads_tot++;
|
||||
|
||||
if (nthreads_tot >= dim) {
|
||||
(*this).Save("Threads_stopped.thr");
|
||||
JSCerror("nthreads_tot >= dim in Scan_Thread_List.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Scan_Thread_List::Order_in_abs_data_value ()
|
||||
{
|
||||
// Reorders all entries in decreasing order in abs_data_value
|
||||
|
||||
if (nthreads_tot > 1) {
|
||||
|
||||
Vect_INT index(dim);
|
||||
for (int i = 0; i < nthreads_tot; ++i) index[i] = i;
|
||||
|
||||
abs_data_value.QuickSort(index, 0, nthreads_tot - 1);
|
||||
|
||||
////Vect_DP omega_ordered(nthreads);
|
||||
//Vect<float> omega_ordered(nthreads);
|
||||
//Vect_INT iK_ordered(nthreads);
|
||||
//Vect_DP abs_data_value_ordered(nthreads);
|
||||
Vect<float> abs_data_value_ordered(nthreads_tot);
|
||||
Vect<string> label_ordered(nthreads_tot);
|
||||
Vect<int> type_ordered(nthreads_tot);
|
||||
Vect<bool> isdone_ordered(nthreads_tot);
|
||||
|
||||
// Put data in proper order
|
||||
for (int i = 0; i < nthreads_tot; ++i) {
|
||||
//omega_ordered[i] = omega[index[nthreads - 1 - i] ];
|
||||
//iK_ordered[i] = iK[index[nthreads - 1 - i] ];
|
||||
abs_data_value_ordered[i] = abs_data_value[nthreads_tot - 1 - i];
|
||||
label_ordered[i] = label[index[nthreads_tot - 1 - i] ];
|
||||
type_ordered[i] = type[index[nthreads_tot - 1 - i] ];
|
||||
//sector_lowest_raisable_ordered[i] = sector_lowest_raisable[index[nthreads - 1 - i] ];
|
||||
isdone_ordered[i] = isdone[index[nthreads_tot - 1 - i] ];
|
||||
}
|
||||
|
||||
// Put back in *this object:
|
||||
for (int i = 0; i < nthreads_tot; ++i) {
|
||||
//omega[i] = omega_ordered[i];
|
||||
//iK[i] = iK_ordered[i];
|
||||
abs_data_value[i] = abs_data_value_ordered[i];
|
||||
label[i] = label_ordered[i];
|
||||
type[i] = type_ordered[i];
|
||||
isdone[i] = isdone_ordered[i];
|
||||
} // The rest are all simply 0.
|
||||
|
||||
// Done !
|
||||
}
|
||||
}
|
||||
/*
|
||||
void Scan_Thread_List::Order_in_omega ()
|
||||
{
|
||||
// Reorders all entries in increasing order in omega
|
||||
|
||||
if (nthreads > 1) {
|
||||
|
||||
Vect_INT index(0, dim);
|
||||
for (int i = 0; i < nthreads; ++i) index[i] = i;
|
||||
|
||||
omega.QuickSort(index, 0, nthreads - 1);
|
||||
|
||||
//Vect_DP omega_ordered(nthreads);
|
||||
Vect<float> omega_ordered(nthreads);
|
||||
Vect_INT iK_ordered(nthreads);
|
||||
//Vect_DP abs_data_value_ordered(nthreads);
|
||||
Vect<float> abs_data_value_ordered(nthreads);
|
||||
Vect<string> label_ordered(nthreads);
|
||||
Vect<int> type_ordered(nthreads);
|
||||
|
||||
// Put data in proper order
|
||||
for (int i = 0; i < nthreads; ++i) {
|
||||
omega_ordered[i] = omega[i];
|
||||
iK_ordered[i] = iK[index[i] ];
|
||||
abs_data_value_ordered[i] = abs_data_value[index[i] ];
|
||||
label_ordered[i] = label[index[i] ];
|
||||
type_ordered[i] = type[index[i] ];
|
||||
}
|
||||
|
||||
// Put back in *this object:
|
||||
for (int i = 0; i < nthreads; ++i) {
|
||||
omega[i] = omega_ordered[i];
|
||||
iK[i] = iK_ordered[i];
|
||||
abs_data_value[i] = abs_data_value_ordered[i];
|
||||
label[i] = label_ordered[i];
|
||||
type[i] = type_ordered[i];
|
||||
} // The rest are all simply 0.
|
||||
|
||||
// Done !
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
DP Scan_Thread_List::Highest_abs_data_value_ordered (DP omega_MIN, DP omega_MAX) // returns highest abs_data_value in window omega_MIN to omega_MAX
|
||||
{
|
||||
// Assume that the threads have been Order_in_abs_data_value
|
||||
for (int i = 0; i < nthreads; ++i)
|
||||
if (omega[i] > omega_MIN && omega[i] < omega_MAX) return(abs_data_value[i]);
|
||||
|
||||
return(0.0);
|
||||
}
|
||||
*/
|
||||
//DP Scan_Thread_List::Highest_abs_data_value (DP omega_MIN, DP omega_MAX) // returns highest abs_data_value in window omega_MIN to omega_MAX
|
||||
DP Scan_Thread_List::Highest_abs_data_value () // returns highest abs_data_value
|
||||
{
|
||||
// Works even if list is not ordered
|
||||
DP maxdatavalue = 0.0;
|
||||
for (int i = 0; i < nthreads_tot; ++i)
|
||||
//if (omega[i] > omega_MIN && omega[i] < omega_MAX && abs_data_value[i] > maxdatavalue)
|
||||
if (!isdone[i] && (abs_data_value[i] > maxdatavalue))
|
||||
maxdatavalue = abs_data_value[i];
|
||||
|
||||
return(maxdatavalue);
|
||||
}
|
||||
|
||||
DP Scan_Thread_List::kth_highest_abs_data_value (int k) // returns the k-th highest abs_data_value in window omega_MIN to omega_MAX
|
||||
{
|
||||
// Works even if list is not ordered
|
||||
if (k < 1) JSCerror("Give k > 1 in Scan_Thread_List::kth_Highest_abs_data_value.");
|
||||
else if (k == 1 || k >= nthreads_tot) // Threads list not long enough, return the top one
|
||||
//return ((*this).Highest_abs_data_value (-1.0e+10, 1.0e+10));
|
||||
return ((*this).Highest_abs_data_value ());
|
||||
|
||||
Vect<DP> topk (0.0, k);
|
||||
|
||||
for (int i = 0; i < nthreads_tot; ++i)
|
||||
if (!isdone[i] && (abs_data_value[i] > topk[0])) {
|
||||
topk[0] = abs_data_value[i];
|
||||
topk.QuickSort(0, k-1);
|
||||
}
|
||||
|
||||
return(topk[0]);
|
||||
}
|
||||
|
||||
bool Scan_Thread_List::Exists_data_value_greater_than (DP value)
|
||||
{
|
||||
for (int i = 0; i < nthreads_tot; ++i)
|
||||
if (abs_data_value[i] > value) return(true);
|
||||
return(false);
|
||||
}
|
||||
|
||||
/*
|
||||
DP Scan_Thread_List::Lowest_omega () // returns lowest omega
|
||||
{
|
||||
// Assume that the threads have been Order_in_omega
|
||||
return(omega[0]);
|
||||
}
|
||||
*/
|
||||
void Scan_Thread_List::Merge (const Scan_Thread_List& reflist)
|
||||
{
|
||||
if (nthreads_tot + reflist.nthreads_tot >= dim) // JSCerror("Scan_Threads_List: too big to merge.");
|
||||
//(*this).Increase_Size (reflist.nthreads);
|
||||
(*this).Increase_Size (nthreads_tot/10 + reflist.nthreads_tot);
|
||||
|
||||
for (int i = 0; i < reflist.nthreads_tot; ++i) {
|
||||
//omega[nthreads] = reflist.omega[i];
|
||||
//iK[nthreads] = reflist.iK[i];
|
||||
abs_data_value[nthreads_tot] = reflist.abs_data_value[i];
|
||||
label[nthreads_tot] = reflist.label[i];
|
||||
type[nthreads_tot] = reflist.type[i];
|
||||
isdone[nthreads_tot] = reflist.isdone[i];
|
||||
nthreads_tot++;
|
||||
}
|
||||
}
|
||||
|
||||
/* // DEACTIVATED IN ABACUS++G_2
|
||||
void Scan_Thread_List::Remove_Threads (int ithread_down, int ithread_up)
|
||||
{
|
||||
if (ithread_down < 0 || ithread_up > nthreads) {
|
||||
JSCerror("Trying to remove inexistent entries in Remove_Threads.");
|
||||
}
|
||||
|
||||
for (int i = 0; i < nthreads - ithread_up - 1; ++i) {
|
||||
//omega[ithread_down + i] = omega[ithread_up + i + 1];
|
||||
//iK[ithread_down + i] = iK[ithread_up + 1 + i];
|
||||
abs_data_value[ithread_down + i] = abs_data_value[ithread_up + i + 1];
|
||||
label[ithread_down + i] = label[ithread_up + i + 1];
|
||||
type[ithread_down + i] = type[ithread_up + i + 1];
|
||||
}
|
||||
// Zero the other entries:
|
||||
for (int i = nthreads - ithread_up - 1; i < nthreads; ++i) {
|
||||
//omega[i] = 1.0e+6;
|
||||
//iK[i] = 0;
|
||||
abs_data_value[i] = 0.0;//-1.0e-30; // give a small negative value, so these are put at the very bottom of the list
|
||||
label[i] = "";
|
||||
type[i] = 0;
|
||||
}
|
||||
|
||||
nthreads -= ithread_up - ithread_down + 1; // removed that many entries.
|
||||
}
|
||||
*/
|
||||
/* // DEACTIVATED IN ABACUS++G_2
|
||||
int Scan_Thread_List::Remove_Threads (const Vect<bool>& threads_done)
|
||||
{
|
||||
// If threads_done[ithread] == true, remove from list
|
||||
|
||||
if (threads_done.size() != nthreads) JSCerror("Wrong size boolean vector in Scan_Thread_List::Remove_Threads.");
|
||||
|
||||
int nr_removed = 0;
|
||||
|
||||
for (int i = 0; i < nthreads; ++i) {
|
||||
if (!threads_done[i]) {
|
||||
//omega[i - nr_removed] = omega[i];
|
||||
//iK[i - nr_removed] = iK[i];
|
||||
abs_data_value[i - nr_removed] = abs_data_value[i];
|
||||
label[i - nr_removed] = label[i];
|
||||
type[i - nr_removed] = type[i];
|
||||
|
||||
}
|
||||
else nr_removed++;
|
||||
}
|
||||
// Zero other entries:
|
||||
for (int i = nthreads - nr_removed; i < nthreads; ++i) {
|
||||
//omega[i] = 1.0e+6;
|
||||
//iK[i] = 0;
|
||||
abs_data_value[i] = 0.0;
|
||||
label[i] = "";
|
||||
type[i] = 0;
|
||||
}
|
||||
|
||||
nthreads -= nr_removed;
|
||||
|
||||
return(nr_removed);
|
||||
}
|
||||
*/
|
||||
|
||||
void Scan_Thread_List::Remove_Done_Threads ()
|
||||
{
|
||||
// If isdone[ithread] == true, remove from list
|
||||
|
||||
int nr_removed = 0;
|
||||
|
||||
for (int i = 0; i < nthreads_tot; ++i) {
|
||||
if (!isdone[i]) {
|
||||
//omega[i - nr_removed] = omega[i];
|
||||
//iK[i - nr_removed] = iK[i];
|
||||
abs_data_value[i - nr_removed] = abs_data_value[i];
|
||||
label[i - nr_removed] = label[i];
|
||||
type[i - nr_removed] = type[i];
|
||||
isdone[i - nr_removed] = isdone[i];
|
||||
}
|
||||
else nr_removed++;
|
||||
}
|
||||
// Zero other entries:
|
||||
for (int i = nthreads_tot - nr_removed; i < nthreads_tot; ++i) {
|
||||
//omega[i] = 1.0e+6;
|
||||
//iK[i] = 0;
|
||||
abs_data_value[i] = 0.0;
|
||||
label[i] = "";
|
||||
type[i] = 0;
|
||||
isdone[i] = false;
|
||||
}
|
||||
|
||||
nthreads_tot -= nr_removed;
|
||||
if (nthreads_done != nr_removed) {
|
||||
cout << nthreads_done << "\t" << nr_removed << endl;
|
||||
JSCerror("Miscount in removing threads during Remove_Done_Threads.");
|
||||
}
|
||||
nthreads_done = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void Scan_Thread_List::Clear ()
|
||||
{
|
||||
// dim is preserved
|
||||
|
||||
nthreads_tot = 0;
|
||||
nthreads_done = 0;
|
||||
////omega = Vect_DP(0.0, dim);
|
||||
//omega = Vect<float> (1.0e+6, dim);
|
||||
//iK = Vect_INT(0, dim);
|
||||
//abs_data_value = Vect_DP (0.0, dim);
|
||||
abs_data_value = Vect<float> (0.0, dim);
|
||||
label = Vect<string> (dim);
|
||||
type = Vect<int> (dim);
|
||||
isdone = Vect<bool> (false, dim);
|
||||
}
|
||||
|
||||
void Scan_Thread_List::Save(const char* outfile_Cstr)
|
||||
{
|
||||
// We save only the undone threads, so after cleanup.
|
||||
(*this).Remove_Done_Threads();
|
||||
|
||||
ofstream outfile;
|
||||
|
||||
outfile.open(outfile_Cstr);
|
||||
if (outfile.fail()) JSCerror("Could not open outfile... ");
|
||||
outfile.precision(3);
|
||||
|
||||
if (nthreads_tot > 0) {
|
||||
//outfile << omega[0] << "\t" << iK[0] << "\t" << abs_data_value[0] << "\t" << label[0] << "\t" << type[0];
|
||||
outfile << abs_data_value[0] << "\t" << label[0] << "\t" << type[0];
|
||||
for (int i = 1; i < nthreads_tot; ++i) {
|
||||
//outfile << endl << omega[i] << "\t" << iK[i] << "\t" << abs_data_value[i] << "\t" << label[i] << "\t" << type[i];
|
||||
outfile << endl << abs_data_value[i] << "\t" << label[i] << "\t" << type[i];
|
||||
}
|
||||
}
|
||||
|
||||
outfile.close();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void Scan_Thread_List::Load (const char* thrfile_Cstr)
|
||||
{
|
||||
/*
|
||||
// Check that the data fits within limits:
|
||||
struct stat statbuf;
|
||||
|
||||
stat (thrfile_Cstr, &statbuf);
|
||||
int filesize = statbuf.st_size;
|
||||
|
||||
// Determine the number of entries approximately
|
||||
// Don't overestimate entry_size: pretend label takes no space...
|
||||
int entry_size = 2* sizeof(float) + sizeof(int);
|
||||
|
||||
int estimate_nr_entries = filesize/entry_size;
|
||||
*/
|
||||
|
||||
// Get number of lines in the file:
|
||||
int nrlines = 0;
|
||||
ifstream infile1(thrfile_Cstr);
|
||||
if(infile1.fail()) {
|
||||
cout << "Could not open file " << thrfile_Cstr << " in Scan_Thread_List::Load." << endl;
|
||||
JSCerror("Terminating.");
|
||||
}
|
||||
string dummy;
|
||||
while (getline(infile1, dummy)) ++nrlines;
|
||||
infile1.close();
|
||||
|
||||
int estimate_nr_entries = JSC::max(10, (11*nrlines)/10);
|
||||
|
||||
if (estimate_nr_entries > dim) {
|
||||
(*this).Increase_Size (estimate_nr_entries - dim/2); // give dim/2 safety
|
||||
}
|
||||
|
||||
ifstream infile;
|
||||
infile.open(thrfile_Cstr);
|
||||
if(infile.fail()) {
|
||||
cout << "Could not open file " << thrfile_Cstr << " in Scan_Thread_List::Load." << endl;
|
||||
JSCerror("Terminating.");
|
||||
}
|
||||
|
||||
(*this).Clear();
|
||||
|
||||
DP abs_data_value_DP;
|
||||
while (infile.peek() != EOF) {
|
||||
//infile >> omega[nthreads];
|
||||
//infile >> iK[nthreads];
|
||||
//infile >> abs_data_value[nthreads]; // nasty bug: reading into float bugs when value less or more than float limits
|
||||
infile >> abs_data_value_DP; // cure: first read into double, then cast to float:
|
||||
abs_data_value[nthreads_tot] = float(abs_data_value_DP);
|
||||
infile >> label[nthreads_tot];
|
||||
infile >> type[nthreads_tot];
|
||||
isdone[nthreads_tot] = false;
|
||||
nthreads_tot++;
|
||||
if (nthreads_tot >= dim) {
|
||||
cout << "file " << thrfile_Cstr << endl << "estimate_nr_entries = " << estimate_nr_entries << "\tnrlines = " << nrlines << endl << "nthreads_tot = " << nthreads_tot << "\tdim = " << dim << endl;
|
||||
JSCerror("Too many threads in input file.");
|
||||
}
|
||||
}
|
||||
|
||||
infile.close();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace JSC
|
||||
@@ -1,254 +0,0 @@
|
||||
/**********************************************************
|
||||
|
||||
This software is part of J.-S. Caux's ABACUS library.
|
||||
|
||||
Copyright (c).
|
||||
|
||||
-----------------------------------------------------------
|
||||
|
||||
File: Scan_Thread_Set.cc
|
||||
|
||||
Purpose: defines all functions for Scan_Thread_Set class.
|
||||
|
||||
|
||||
***********************************************************/
|
||||
|
||||
#include "JSC.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace JSC;
|
||||
|
||||
namespace JSC {
|
||||
|
||||
Scan_Thread_Set::Scan_Thread_Set()
|
||||
{
|
||||
dim = Vect<int> (nlists);
|
||||
nthreads_tot = Vect<int> (nlists);
|
||||
nthreads_done = Vect<int> (nlists);
|
||||
|
||||
label = Vect<Vect<string> > (nlists);
|
||||
type = Vect<Vect<int> > (nlists);
|
||||
isdone = Vect<Vect<bool> > (nlists);
|
||||
|
||||
|
||||
// Give starting values to all:
|
||||
for (int il = 0; il < nlists; ++il) {
|
||||
dim[il] = 100;
|
||||
nthreads_tot[il] = 0;
|
||||
nthreads_done[il] = 0;
|
||||
label[il] = Vect<string> (dim[il]);
|
||||
type[il] = Vect<int> (dim[il]);
|
||||
isdone[il] = Vect<bool> (false, dim[il]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Scan_Thread_Set::Increase_Size (int il, int nr_to_add) // resizes the vectors to accommodate up to nr_to_add additional entries
|
||||
{
|
||||
if (il < 0 || il > nlists) JSCerror("ilist out of bounds in Scan_Thread_Set::Increase_Size");
|
||||
|
||||
dim[il] += nr_to_add;
|
||||
|
||||
try {
|
||||
label[il].Increase_Size (nr_to_add, "");
|
||||
type[il].Increase_Size (nr_to_add);
|
||||
isdone[il].Increase_Size (nr_to_add, false);
|
||||
}
|
||||
|
||||
catch (bad_alloc) {
|
||||
cout << "dim[il] " << dim[il] << "\tnr_to_add " << nr_to_add << endl;
|
||||
JSCerror("Memory allocation failed in Scan_Thread_Set::Increase_Size.");
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
void Scan_Thread_Set::Include_Thread (DP abs_data_value_ref, string label_ref, int type_ref)
|
||||
{
|
||||
// Determine which ilist index is to be used:
|
||||
int il = int(-log(abs_data_value_ref)/logscale);
|
||||
if (il < 0) il = 0;
|
||||
if (il >= nlists) il = nlists - 1;
|
||||
|
||||
if (nthreads_tot[il] > dim[il] - 10) { // Resize the Scan_Thread_Set list, by doubling its size
|
||||
//cout << "Resizing threads list" << endl;
|
||||
(*this).Increase_Size (il, dim[il]);
|
||||
//cout << "Done resizing" << endl;
|
||||
}
|
||||
|
||||
//cout << "Including thread for label " << label_ref << " and type " << type_ref << endl;
|
||||
|
||||
label[il][nthreads_tot[il] ] = label_ref;
|
||||
type[il][nthreads_tot[il] ] = type_ref;
|
||||
isdone[il][nthreads_tot[il] ] = false;
|
||||
|
||||
nthreads_tot[il]++;
|
||||
|
||||
}
|
||||
|
||||
void Scan_Thread_Set::Merge (const Scan_Thread_Set& refset)
|
||||
{
|
||||
if (nlists != refset.nlists) JSCerror("nlists don't match in Scan_Thread_Set::Merge");
|
||||
|
||||
for (int il = 0; il < nlists; ++il) {
|
||||
|
||||
if (nthreads_tot[il] + refset.nthreads_tot[il] >= dim[il])
|
||||
(*this).Increase_Size (il, nthreads_tot[il]/10 + refset.nthreads_tot[il]);
|
||||
|
||||
for (int i = 0; i < refset.nthreads_tot[il]; ++i) {
|
||||
label[il][nthreads_tot[il] ] = refset.label[il][i];
|
||||
type[il][nthreads_tot[il] ] = refset.type[il][i];
|
||||
isdone[il][nthreads_tot[il] ] = refset.isdone[il][i];
|
||||
nthreads_tot[il]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Scan_Thread_Set::Remove_Done_Threads (int il)
|
||||
{
|
||||
// If isdone[ithread] == true, remove from list
|
||||
|
||||
int nr_removed = 0;
|
||||
|
||||
for (int i = 0; i < nthreads_tot[il]; ++i) {
|
||||
if (!isdone[il][i]) {
|
||||
label[il][i - nr_removed] = label[il][i];
|
||||
type[il][i - nr_removed] = type[il][i];
|
||||
isdone[il][i - nr_removed] = isdone[il][i];
|
||||
}
|
||||
else nr_removed++;
|
||||
}
|
||||
// Zero other entries:
|
||||
for (int i = nthreads_tot[il] - nr_removed; i < nthreads_tot[il]; ++i) {
|
||||
label[il][i] = "";
|
||||
type[il][i] = 0;
|
||||
isdone[il][i] = false;
|
||||
}
|
||||
|
||||
nthreads_tot[il] -= nr_removed;
|
||||
if (nthreads_done[il] != nr_removed) {
|
||||
cout << nthreads_done[il] << "\t" << nr_removed << endl;
|
||||
JSCerror("Miscount in removing threads during Scan_Thread_Set::Remove_Done_Threads.");
|
||||
}
|
||||
nthreads_done[il] = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void Scan_Thread_Set::Remove_Done_Threads ()
|
||||
{
|
||||
// If isdone[ithread] == true, remove from list
|
||||
|
||||
for (int il = 0; il < nlists; ++il)
|
||||
(*this).Remove_Done_Threads(il);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void Scan_Thread_Set::Clear ()
|
||||
{
|
||||
for (int il = 0; il < nlists; ++il) {
|
||||
|
||||
nthreads_tot[il] = 0;
|
||||
nthreads_done[il] = 0;
|
||||
label[il] = Vect<string> (dim[il]);
|
||||
type[il] = Vect<int> (dim[il]);
|
||||
isdone[il] = Vect<bool> (false, dim[il]);
|
||||
}
|
||||
}
|
||||
|
||||
void Scan_Thread_Set::Save(const char* outfile_Cstr)
|
||||
{
|
||||
// We save only the undone threads, so after cleanup.
|
||||
(*this).Remove_Done_Threads();
|
||||
|
||||
ofstream outfile;
|
||||
|
||||
outfile.open(outfile_Cstr);
|
||||
if (outfile.fail()) JSCerror("Could not open outfile... ");
|
||||
outfile.precision(3);
|
||||
|
||||
//cout << "Saving threads: nthreads_tot vector is" << endl;
|
||||
//for (int il = 0; il < nlists; ++il)
|
||||
//if (nthreads_tot[il] > 0) cout << il << "\t" << nthreads_tot[il] << "\t";
|
||||
//cout << endl;
|
||||
|
||||
bool started = false;
|
||||
for (int il = 0; il < nlists; ++il) {
|
||||
|
||||
if (nthreads_tot[il] > 0) {
|
||||
if (started) outfile << endl;
|
||||
outfile << il << "\t" << label[il][0] << "\t" << type[il][0];
|
||||
started = true;
|
||||
for (int i = 1; i < nthreads_tot[il]; ++i) {
|
||||
outfile << endl << il << "\t" << label[il][i] << "\t" << type[il][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outfile.close();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void Scan_Thread_Set::Load (const char* thrfile_Cstr)
|
||||
{
|
||||
ifstream infile;
|
||||
infile.open(thrfile_Cstr);
|
||||
if(infile.fail()) {
|
||||
cout << "Could not open file " << thrfile_Cstr << " in Scan_Thread_Set::Load." << endl;
|
||||
JSCerror("Terminating.");
|
||||
}
|
||||
|
||||
(*this).Clear();
|
||||
|
||||
// First count the number of elements in each list:
|
||||
Vect<int> nthreads_read(0, nlists);
|
||||
int il_read;
|
||||
string label_read;
|
||||
int type_read;
|
||||
|
||||
while (infile.peek() != EOF) {
|
||||
infile >> il_read;
|
||||
infile >> label_read;
|
||||
infile >> type_read;
|
||||
nthreads_read[il_read]++;
|
||||
}
|
||||
|
||||
infile.close();
|
||||
|
||||
//cout << "nthreads_read vector: " << endl;
|
||||
//for (int il = 0; il < nlists; ++il)
|
||||
//if (nthreads_read[il] > 0) cout << il << "\t" << nthreads_read[il] << "\t";
|
||||
//cout << endl;
|
||||
|
||||
// Now allocate the proper sizes:
|
||||
for (int il = 0; il < nlists; ++il) {
|
||||
(*this).Increase_Size (il, JSC::max(0, nthreads_read[il] - dim[il] + 10));
|
||||
nthreads_read[il] = 0;
|
||||
}
|
||||
|
||||
// Read threads data in:
|
||||
ifstream infile2;
|
||||
infile2.open(thrfile_Cstr);
|
||||
infile.seekg(0);
|
||||
while (infile2.peek() != EOF) {
|
||||
infile2 >> il_read;
|
||||
infile2 >> label[il_read][nthreads_read[il_read] ];
|
||||
infile2 >> type[il_read][nthreads_read[il_read] ];
|
||||
//isdone[il_read][nthreads_read[il_read] ] = false; // no need
|
||||
nthreads_tot[il_read]++;
|
||||
nthreads_read[il_read]++;
|
||||
}
|
||||
|
||||
infile2.close();
|
||||
|
||||
//cout << "Loading threads: nthreads_tot vector is" << endl;
|
||||
//for (int il = 0; il < nlists; ++il)
|
||||
//if (nthreads_tot[il] > 0) cout << il << "\t" << nthreads_tot[il] << "\t";
|
||||
//cout << endl;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
} // namespace JSC
|
||||
Reference in New Issue
Block a user