Finish first clean of src files

This commit is contained in:
J.-S. Caux
2018-02-11 15:43:12 +01:00
parent e7dd24d337
commit 0559fa9301
22 changed files with 2143 additions and 5453 deletions
+50 -107
View File
@@ -20,7 +20,8 @@ using namespace std;
namespace ABACUS {
Young_Tableau::Young_Tableau () : Nrows(0), Ncols(0), Row_L(0), Col_L(0), id(0LL), maxid(0LL),
map(new long long int [1]), map_computed(false), idnr_reached(0LL), nboxes_reached(-1),
map(new long long int [1]), map_computed(false),
idnr_reached(0LL), nboxes_reached(-1),
dimchoose(0), choose_table(0LL)
{}
@@ -47,32 +48,11 @@ namespace ABACUS {
}
// Fill map with zeros:
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = 0LL;
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i)
map[i] = 0LL;
}
/* SEGFAULTS
Young_Tableau::Young_Tableau (int Nr, int Nc, long long int idnr)
: Nrows(Nr), Ncols(Nc), Row_L(new int[Nrows]), Col_L(new int[Ncols]), id(idnr),
maxid(choose_lli(Nr + Nc, Nc) - 1LL),
map(new long long int [YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1]),
map_computed(false), idnr_reached(0LL), nboxes_reached(-1),
dimchoose (ABACUS::min(Nr, Nc) + 1),
choose_table(new long long int[(Nr + Nc + 1) * dimchoose])
{
// Constructs Young tableau of given idnr, if consistent with Nr, Nc.
// Construct the choose_table
for (int cti = 0; cti < Nr + Nc + 1; ++cti)
for (int ctj = 0; ctj < dimchoose; ++ctj) {
if (cti >= ctj) choose_table[dimchoose * cti + ctj] = choose_lli(cti, ctj);
else choose_table[dimchoose * cti + ctj] = 0LL;
}
for (int i = 0; i < YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1; ++i) map[i] = 0LL;
(*this).Set_to_id(idnr);
}
*/
Young_Tableau::Young_Tableau (const Young_Tableau& RefTableau) // copy constructor
: Nrows(RefTableau.Nrows), Ncols(RefTableau.Ncols), Row_L(new int[RefTableau.Nrows]), Col_L(new int[RefTableau.Ncols]),
id(RefTableau.id), maxid(RefTableau.maxid),
@@ -93,47 +73,11 @@ namespace ABACUS {
}
// The map:
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = RefTableau.map[i];
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i)
map[i] = RefTableau.map[i];
}
/*
Young_Tableau::Young_Tableau (int Nr, int Nc, long long int* ref_choose_table, int dimref)
: Nrows(Nr), Ncols(Nc), Row_L(new int[Nrows]), Col_L(new int[Ncols]), id(0LL),
maxid(choose_lli(Nr + Nc, Nc) - 1LL),
//choose_table(new long long int[(Nr + Nc + 1) * (Nr + Nc + 1)]),
choose_table(new long long int[(Nr + Nc + 1) * (ABACUS::min(Nr, Nc) + 1)]),
//map(new long long int[ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT)]),
map(new long long int[YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1]),
map_computed(false), idnr_reached(0LL), nboxes_reached(-1)
{
// Constructs empty tableau of appropriate size
for (int i = 0; i < Nrows; ++i) Row_L[i] = 0;
for (int i = 0; i < Ncols; ++i) Col_L[i] = 0;
// Construct the choose_table
// Copy entries from reference table
for (int cti = 0; cti < ABACUS::min(Nr + Nc + 1, dimref); ++cti)
for (int ctj = 0; ctj < ABACUS::min(Nr + Nc + 1, dimref); ++ctj)
choose_table[(Nr + Nc + 1) * cti + ctj] = cti >= ctj ? ref_choose_table[dimref * cti + ctj] : 0LL;
// add missing parts if there are any
if (dimref < Nr + Nc + 1) {
for (int cti = 0; cti < Nr + Nc + 1; ++cti)
for (int ctj = dimref; ctj < Nr + Nc + 1; ++ctj)
choose_table[(Nr + Nc + 1) * cti + ctj] = 0LL;
for (int cti = dimref; cti < Nr + Nc + 1; ++cti)
for (int ctj = 0; ctj < Nr + Nc + 1; ++ctj)
choose_table[(Nr + Nc + 1) * cti + ctj] = cti >= ctj ? choose_lli(cti, ctj) : 0LL;
}
// The map:
//for (int i = 0; i < ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT); ++i) map[i] = 0LL;
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = 0LL;
}
*/
Young_Tableau::Young_Tableau (int Nr, int Nc, const Young_Tableau& RefTableau)
: Nrows(Nr), Ncols(Nc), Row_L(new int[Nrows]), Col_L(new int[Ncols]), id(0LL),
maxid(choose_lli(Nr + Nc, Nc) - 1LL),
@@ -163,7 +107,8 @@ namespace ABACUS {
choose_table[dimchoose * cti + ctj] = cti >= ctj ? choose_lli(cti, ctj) : 0LL;
// The map:
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = 0LL;
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i)
map[i] = 0LL;
}
Young_Tableau& Young_Tableau::operator= (const Young_Tableau& RefTableau)
@@ -190,7 +135,9 @@ namespace ABACUS {
if (map != 0LL) delete[] map;
map = new long long int[YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1];
for (long long int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = RefTableau.map[i];
for (long long int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2
? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i)
map[i] = RefTableau.map[i];
map_computed = RefTableau.map_computed;
idnr_reached = RefTableau.idnr_reached;
nboxes_reached = RefTableau.nboxes_reached;
@@ -263,7 +210,8 @@ namespace ABACUS {
}
else if (nboxes_to_dist > Ncols * (Nrows - level)) {
cout << Nrows << "\t" << Ncols << "\t" << level << "\t" << nboxes_to_dist << "\t" << idnr_reached << "\t" << nboxes_reached << endl;
cout << Nrows << "\t" << Ncols << "\t" << level << "\t" << nboxes_to_dist << "\t"
<< idnr_reached << "\t" << nboxes_reached << endl;
ABACUSerror("nboxes_to_dist too high");
}
else if (nboxes_to_dist == 0) {
@@ -309,10 +257,11 @@ namespace ABACUS {
+ ABACUS::min(highest_occupied_row, Ncols_Desc - j)];
Vect_INT Desc_Desc_Row_L(highest_occupied_row);
for (int i = 0; i < highest_occupied_row; ++i) Desc_Desc_Row_L[i] = Desc_Row_L[i] - Desc_Row_L[highest_occupied_row];
for (int i = 0; i < highest_occupied_row; ++i)
Desc_Desc_Row_L[i] = Desc_Row_L[i] - Desc_Row_L[highest_occupied_row];
answer += Compute_Descendent_id (0, Desc_Desc_Row_L, highest_occupied_row, Ncols_Desc - Desc_Row_L[highest_occupied_row],
RefTableau);
answer += Compute_Descendent_id (0, Desc_Desc_Row_L, highest_occupied_row,
Ncols_Desc - Desc_Row_L[highest_occupied_row], RefTableau);
}
}
@@ -338,7 +287,7 @@ namespace ABACUS {
else {
for (int j = 0; j < ndiag; ++j) answer += RefTableau.choose_table[RefTableau.dimchoose * Nrows_Desc + j]
* RefTableau.choose_table[RefTableau.dimchoose * Ncols_Desc + j];
* RefTableau.choose_table[RefTableau.dimchoose * Ncols_Desc + j];
Vect_INT Desc1_Row_L(ndiag);
for (int i = 0; i < ndiag; ++i) Desc1_Row_L[i] = Desc_Row_L[i] - ndiag;
@@ -381,8 +330,9 @@ namespace ABACUS {
int highest_occupied_row = Nrows - 1;
while (Row_L[highest_occupied_row] == 0) highest_occupied_row--; // index of highest occupied row;
for (int j = 0; j < Row_L[highest_occupied_row]; ++j) idnr += choose_table[dimchoose * (highest_occupied_row + Ncols - j)
+ ABACUS::min(highest_occupied_row, Ncols - j)];
for (int j = 0; j < Row_L[highest_occupied_row]; ++j)
idnr += choose_table[dimchoose * (highest_occupied_row + Ncols - j)
+ ABACUS::min(highest_occupied_row, Ncols - j)];
Vect_INT Desc_Row_L(highest_occupied_row);
@@ -432,7 +382,8 @@ namespace ABACUS {
Compute_id (0); // sets the id according to rule 0
Compute_Map (idnr); // make sure the state map is computed
while (map[idnr] != id && idnr < ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT)) idnr++; // match with inverse map to get the idnr according to rule 2
while (map[idnr] != id && idnr < ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT))
idnr++; // match with inverse map to get the idnr according to rule 2
}
else ABACUSerror("Wrong option for Tableau ids");
@@ -448,13 +399,15 @@ namespace ABACUS {
return(*this);
}
Young_Tableau& Young_Tableau::Set_to_id (long long int idnr, int option) // sets the tableau to the one corresponding to idnr
Young_Tableau& Young_Tableau::Set_to_id (long long int idnr, int option)
// sets the tableau to the one corresponding to idnr
{
if (option == 0) {
if ((idnr < 0) || ((maxid < idnr) && (Nrows*Ncols != 0))) {
cout << "Nrows = " << Nrows << "\tNcols = " << Ncols << "\tmaxid = " << maxid << "\trequested id = " << idnr << endl;
cout << "Nrows = " << Nrows << "\tNcols = " << Ncols
<< "\tmaxid = " << maxid << "\trequested id = " << idnr << endl;
ABACUSerror("Wrong idnr in Set_to_id for Young Tableau.");
}
id = idnr;
@@ -489,7 +442,8 @@ namespace ABACUS {
else if (option == 1) {
if ((idnr < 0LL) || ((maxid < idnr) && (Nrows*Ncols != 0))) ABACUSerror("Wrong idnr in Set_to_id for Young Tableau.");
if ((idnr < 0LL) || ((maxid < idnr) && (Nrows*Ncols != 0)))
ABACUSerror("Wrong idnr in Set_to_id for Young Tableau.");
if (Nrows*Ncols == 0 && idnr != 0LL) ABACUSerror("Trying nonzero id on empty Tableau.");
@@ -508,7 +462,8 @@ namespace ABACUS {
sum += choose_table[dimchoose * Nrows + ndiag] * choose_table[dimchoose * Ncols + ndiag];
}
long long int residual_id = idnr - 1 - sum + choose_table[dimchoose * Nrows + ndiag] * choose_table[dimchoose * Ncols + ndiag];
long long int residual_id = idnr - 1 - sum + choose_table[dimchoose * Nrows + ndiag]
* choose_table[dimchoose * Ncols + ndiag];
if (ndiag == 0 && idnr != 0LL) ABACUSerror("Zero ndiag for nonzero idnr in Tableau.");
@@ -561,9 +516,12 @@ namespace ABACUS {
Young_Tableau& Young_Tableau::Set_Row_L (Vect_INT& Row_Lengths) // set row lengths to elements of given vector
{
if (Row_Lengths.size() != Nrows) ABACUSerror("Vector of incompatible dimension used to initialize Young Tableau.");
if (Row_Lengths.size() != Nrows)
ABACUSerror("Vector of incompatible dimension used to initialize Young Tableau.");
for (int i = 0; i < Row_Lengths.size() - 1; ++i) if (Row_Lengths[i] < Row_Lengths[i+1]) ABACUSerror("Vector is not a proper Young tableau.");
for (int i = 0; i < Row_Lengths.size() - 1; ++i)
if (Row_Lengths[i] < Row_Lengths[i+1])
ABACUSerror("Vector is not a proper Young tableau.");
for (int i = 0; i < Nrows; ++i) Row_L[i] = Row_Lengths[i];
(*this).Set_Col_L_given_Row_L();
@@ -663,8 +621,6 @@ namespace ABACUS {
{
// adds a box to the lowest nonzero length Row, recomputes id, returns true if tableau has changed
//cout << "Check before: "; (*this).Print();
if (id == 0LL || Nrows == 0 || Ncols == 0) return(false); // Tableau is empty
// otherwise find the lowest nonzero row:
@@ -674,13 +630,12 @@ namespace ABACUS {
if (iln0r < 0) ABACUSerror("id wrongly set in Young_Tableau (Raise_Lowest_Nonzero_Row).");
// This should not happen, since if iln0r == -1, id should be 0.
else if (iln0r == 0 && Row_L[0] < Ncols || iln0r > 0 && Row_L[iln0r - 1] > Row_L[iln0r]) { // there is space for at least one more box !
else if (iln0r == 0 && Row_L[0] < Ncols || iln0r > 0 && Row_L[iln0r - 1] > Row_L[iln0r]) {
// there is space for at least one more box !
Row_L[iln0r] += 1;
Set_Col_L_given_Row_L();
Compute_id();
//cout << "Check after: iln0r = " << iln0r; (*this).Print();
return(true);
}
@@ -693,28 +648,20 @@ namespace ABACUS {
// Important: allow raising first row if tableau is empty.
//cout << "Check before: "; (*this).Print();
if (Ncols == 0 || Nrows == 0) return(false); // no space !
// Find index of lowest nonzero row: can be -1 if Tableau is empty
int iln0r = Nrows - 1;
while (Row_L[iln0r] == 0 && iln0r >= 0) iln0r--;
//cout << "iln0r = " << iln0r << "\t" << Row_L[iln0r] << "\t" << Row_L[iln0r + 1] << endl;
//if (iln0r == Nrows - 1) return(false); // no row under that one; allow raising of row 0
if (iln0r == -1 && Row_L[0] < Ncols || iln0r >= 0 && iln0r < Nrows - 1 && Row_L[iln0r] > Row_L[iln0r + 1]) {
// there is space for at least one more box !
Row_L[iln0r + 1] += 1;
Set_Col_L_given_Row_L();
Compute_id();
// there is space for at least one more box !
Row_L[iln0r + 1] += 1;
Set_Col_L_given_Row_L();
Compute_id();
//cout << "Check after: iln0r = " << iln0r; (*this).Print();
return(true);
}
return(true);
}
return(false);
}
@@ -836,8 +783,6 @@ namespace ABACUS {
// descendents considered here are thus those for which the raised
// box is the highest still occupied box of the originally boosted state.
//cout << "Tableau in Desc_Boosted: " << (*this) << endl;
int ndesc = 0;
// Is tableau non-empty ?
@@ -860,19 +805,17 @@ namespace ABACUS {
if (!fixed_Nboxes) {
// The convention here is that we *remove* the highest yet unraised box only
//cout << "Removing box from " << (*this) << " with id " << (*this).id << endl;
Young_Tableau descendent_attempt = (*this);
if (descendent_attempt.Lower_Row(level_from)) ndesc = 1;
//cout << "Obtained: " << descendent_attempt << " with id " << descendent_attempt.id << endl;
//if (ndesc > 0) {
if (ndesc == 1) {
Vect<Young_Tableau> Tableau_desc(ndesc);
//if (ndesc == 1) Tableau_desc[0] = descendent_attempt;
Tableau_desc[0] = descendent_attempt;
return(Tableau_desc);
}
else if (ndesc != 0) ABACUSerror("There should be either 0 or 1 descendents in Descended_Boosted_State with fixed_iK == true.");
else if (ndesc != 0)
ABACUSerror("There should be either 0 or 1 descendents in Descended_Boosted_State with fixed_iK == true.");
} // if (!fixed_Nboxes)
@@ -886,10 +829,12 @@ namespace ABACUS {
Young_Tableau Tableau_ref = (*this);
Young_Tableau Tableau_check1 = (*this);
bool check1 = (Tableau_check1.Lower_Row(level_from) && Tableau_check1.Raise_Lowest_Nonzero_Row());
if (check1 && Tableau_check1.Row_L[level_from] == Tableau_ref.Row_L[level_from] - 1) ndesc++; // to make sure we don't Raise the one we've just removed
if (check1 && Tableau_check1.Row_L[level_from] == Tableau_ref.Row_L[level_from] - 1)
ndesc++; // to make sure we don't Raise the one we've just removed
Young_Tableau Tableau_check2 = (*this);
bool check2 = (Tableau_check2.Lower_Row(level_from) && Tableau_check2.Raise_Next_to_Lowest_Nonzero_Row());
if (check2 && Tableau_check2.Row_L[level_from] == Tableau_ref.Row_L[level_from] - 1) ndesc++; // to make sure we don't Raise the one we've just removed
if (check2 && Tableau_check2.Row_L[level_from] == Tableau_ref.Row_L[level_from] - 1)
ndesc++; // to make sure we don't Raise the one we've just removed
if (ndesc > 0) {
Vect<Young_Tableau> Tableau_desc(ndesc);
@@ -908,8 +853,6 @@ namespace ABACUS {
// tries to add Nboxes to Tableau, returns number of boxes added.
if (Ncols == 0 || Nrows == 0) return(0); // can't do anything !
//cout << "Requesting Nboxes " << Nboxes << " in tableau." << endl;
int Nboxes_added = 0;
int previous_Row_L = 0;
for (int working_level = 0; working_level < Nrows; ++working_level) {