Reorganization of headers (I): rename JSC -> ABACUS

All files need to be changed to refer to new headers.
First step of the reorganization.
This commit is contained in:
J.-S. Caux
2018-02-10 14:33:07 +01:00
parent 0c893c89f7
commit 63cdd4250c
176 changed files with 8391 additions and 9384 deletions
+182 -181
View File
@@ -1,8 +1,8 @@
/**********************************************************
This software is part of J.-S. Caux's ABACUS++ library.
This software is part of J.-S. Caux's ABACUS library.
Copyright (c) 2006-9.
Copyright (c) J.-S. Caux.
-----------------------------------------------------------
@@ -10,73 +10,74 @@ File: Young_Tableau.cc
Purpose: Defines Young_Tableau class and procedures.
Last modified: 08/10/2009
***********************************************************/
#include "JSC.h"
#include "ABACUS.h"
namespace JSC {
using namespace std;
Young_Tableau::Young_Tableau () : Nrows(0), Ncols(0), Row_L(0), Col_L(0), id(0LL), maxid(0LL),
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),
dimchoose(0), choose_table(0LL)
{}
Young_Tableau::Young_Tableau (int Nr, int Nc)
: Nrows(Nr), Ncols(Nc), Row_L(new int[Nrows]), Col_L(new int[Ncols]), id(0LL),
maxid(choose_lli(Nr + Nc, Nc) - 1LL),
map(new long long int [YOUNG_TABLEAU_ID_OPTION == 2 ? JSC::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1]),
Young_Tableau::Young_Tableau (int Nr, int Nc)
: Nrows(Nr), Ncols(Nc), Row_L(new int[Nrows]), Col_L(new int[Ncols]), id(0LL),
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 (JSC::min(Nr, Nc) + 1),
dimchoose (ABACUS::min(Nr, Nc) + 1),
choose_table(new long long int[(Nr + Nc + 1) * dimchoose])
{
// 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
for (int cti = 0; cti < Nr + Nc + 1; ++cti)
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;
}
// Fill map with zeros:
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? JSC::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = 0LL;
// 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;
}
/* 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 ? JSC::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1]),
/* 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 (JSC::min(Nr, Nc) + 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.
// 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 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 ? JSC::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;
(*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),
map(new long long int [YOUNG_TABLEAU_ID_OPTION == 2 ? JSC::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1]),
map_computed(RefTableau.map_computed), idnr_reached(RefTableau.idnr_reached),
: Nrows(RefTableau.Nrows), Ncols(RefTableau.Ncols), Row_L(new int[RefTableau.Nrows]), Col_L(new int[RefTableau.Ncols]),
id(RefTableau.id), maxid(RefTableau.maxid),
map(new long long int [YOUNG_TABLEAU_ID_OPTION == 2 ? ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1]),
map_computed(RefTableau.map_computed), idnr_reached(RefTableau.idnr_reached),
nboxes_reached(RefTableau.nboxes_reached),
dimchoose (RefTableau.dimchoose),
choose_table(new long long int[(Nrows + Ncols + 1) * dimchoose])
@@ -85,24 +86,24 @@ namespace JSC {
for (int i = 0; i < Ncols; ++i) Col_L[i] = RefTableau.Col_L[i];
// Construct the choose_table
for (int cti = 0; cti < Nrows + Ncols + 1; ++cti)
for (int cti = 0; cti < Nrows + Ncols + 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;
}
// The map:
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? JSC::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),
: 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) * (JSC::min(Nr, Nc) + 1)]),
//map(new long long int[JSC::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT)]),
map(new long long int[YOUNG_TABLEAU_ID_OPTION == 2 ? JSC::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 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)
{
@@ -114,31 +115,31 @@ namespace JSC {
// Construct the choose_table
// Copy entries from reference table
for (int cti = 0; cti < JSC::min(Nr + Nc + 1, dimref); ++cti)
for (int ctj = 0; ctj < JSC::min(Nr + Nc + 1, dimref); ++ctj)
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)
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)
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 < JSC::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT); ++i) map[i] = 0LL;
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? JSC::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = 0LL;
//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),
map(new long long int[YOUNG_TABLEAU_ID_OPTION == 2 ? JSC::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1]),
: Nrows(Nr), Ncols(Nc), Row_L(new int[Nrows]), Col_L(new int[Ncols]), id(0LL),
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 (JSC::min(Nr, Nc) + 1),
dimchoose (ABACUS::min(Nr, Nc) + 1),
choose_table(new long long int[(Nr + Nc + 1) * dimchoose])
{
// Constructs empty tableau of appropriate size
@@ -149,8 +150,8 @@ namespace JSC {
// Construct the choose_table
// Copy entries from reference table
for (int cti = 0; cti < JSC::min(Nr + Nc + 1, RefTableau.Nrows + RefTableau.Ncols + 1); ++cti)
for (int ctj = 0; ctj < JSC::min(dimchoose, RefTableau.dimchoose); ++ctj)
for (int cti = 0; cti < ABACUS::min(Nr + Nc + 1, RefTableau.Nrows + RefTableau.Ncols + 1); ++cti)
for (int ctj = 0; ctj < ABACUS::min(dimchoose, RefTableau.dimchoose); ++ctj)
choose_table[dimchoose * cti + ctj] = cti >= ctj ? RefTableau.choose_table[RefTableau.dimchoose * cti + ctj] : 0LL;
// add missing parts if there are any
@@ -158,11 +159,11 @@ namespace JSC {
for (int cti = 0; cti < Nr + Nc + 1; ++cti)
for (int ctj = 0; ctj < dimchoose; ++ctj)
if (cti >= refdim1 || ctj >= RefTableau.dimchoose)
if (cti >= refdim1 || ctj >= RefTableau.dimchoose)
choose_table[dimchoose * cti + ctj] = cti >= ctj ? choose_lli(cti, ctj) : 0LL;
// The map:
for (int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? JSC::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)
@@ -181,15 +182,15 @@ namespace JSC {
dimchoose = RefTableau.dimchoose;
if (choose_table != 0LL) delete[] choose_table;
choose_table = new long long int[(Nrows + Ncols + 1) * dimchoose];
for (int cti = 0; cti < Nrows + Ncols + 1; ++cti)
for (int ctj = 0; ctj < dimchoose; ++ctj)
for (int cti = 0; cti < Nrows + Ncols + 1; ++cti)
for (int ctj = 0; ctj < dimchoose; ++ctj)
{
choose_table[dimchoose * cti + ctj] = RefTableau.choose_table[dimchoose * cti + ctj];
}
if (map != 0LL) delete[] map;
map = new long long int[YOUNG_TABLEAU_ID_OPTION == 2 ? JSC::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1];
for (long long int i = 0; i < (YOUNG_TABLEAU_ID_OPTION == 2 ? JSC::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT) : 1); ++i) map[i] = RefTableau.map[i];
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];
map_computed = RefTableau.map_computed;
idnr_reached = RefTableau.idnr_reached;
nboxes_reached = RefTableau.nboxes_reached;
@@ -197,7 +198,7 @@ namespace JSC {
if (choose_table[0] != 1LL) { // compute the table
for (int cti = 0; cti < Nrows + Ncols + 1; ++cti)
for (int cti = 0; cti < Nrows + Ncols + 1; ++cti)
for (int ctj = 0; ctj < dimchoose; ++ctj)
{
choose_table[dimchoose * cti + ctj] = cti >= ctj ? choose_lli(cti, ctj) : 0LL;
@@ -217,13 +218,13 @@ namespace JSC {
//*********************************************************************************
// Member functions
Young_Tableau& Young_Tableau::Compute_Map (long long int idnr_to_reach)
{
if (idnr_to_reach < 0LL) JSCerror("negative id requested in Compute_Map");
if (idnr_to_reach < 0LL) ABACUSerror("negative id requested in Compute_Map");
long long int idnr_to_reach_here = ABACUS::min(idnr_to_reach, ABACUS::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT));
long long int idnr_to_reach_here = JSC::min(idnr_to_reach, JSC::min(maxid + 1LL, TABLEAU_ID_UPPER_LIMIT));
if (!map_computed) {
nboxes_reached = -1;
idnr_reached = 0LL;
@@ -239,12 +240,12 @@ namespace JSC {
// Keep a copy of the Tableau, in case...
int* old_Row_L = new int[Nrows];
for (int i = 0; i < Nrows; ++i) old_Row_L[i] = Row_L[i];
while (idnr_reached <= JSC::min(idnr_to_reach, TABLEAU_ID_UPPER_LIMIT)) {
while (idnr_reached <= ABACUS::min(idnr_to_reach, TABLEAU_ID_UPPER_LIMIT)) {
nboxes_reached++;
Distribute_boxes (nboxes_reached, 0);
}
// Reset Row_L
for (int i = 0; i < Nrows; ++i) Row_L[i] = old_Row_L[i];
delete[] old_Row_L;
@@ -260,27 +261,27 @@ namespace JSC {
if (level > Nrows) {
// Failed to achieve proper distribution. Do nothing.
}
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;
JSCerror("nboxes_to_dist too high");
ABACUSerror("nboxes_to_dist too high");
}
else if (nboxes_to_dist == 0) {
for (int j = level; j < Nrows; ++j) Row_L[j] = 0;
Compute_id (0);
if (idnr_reached < TABLEAU_ID_UPPER_LIMIT) map[idnr_reached] = id;
idnr_reached++;
idnr_reached++;
}
else {
int maxlength = level == 0 ? Ncols : Row_L[level - 1];
for (int nboxes_of_level = (nboxes_to_dist - 1)/(Nrows - level) + 1;
nboxes_of_level <= JSC::min(nboxes_to_dist, maxlength); ++nboxes_of_level) {
for (int nboxes_of_level = (nboxes_to_dist - 1)/(Nrows - level) + 1;
nboxes_of_level <= ABACUS::min(nboxes_to_dist, maxlength); ++nboxes_of_level) {
Row_L[level] = nboxes_of_level;
Distribute_boxes (nboxes_to_dist - nboxes_of_level, level + 1);
}
}
}
return(*this);
}
@@ -290,7 +291,7 @@ namespace JSC {
return(*this);
}
long long int Young_Tableau::Compute_Descendent_id (int option, Vect_INT& Desc_Row_L, int Nrows_Desc, int Ncols_Desc,
long long int Young_Tableau::Compute_Descendent_id (int option, Vect_INT& Desc_Row_L, int Nrows_Desc, int Ncols_Desc,
const Young_Tableau& RefTableau)
{
long long int answer = 0;
@@ -301,16 +302,16 @@ namespace JSC {
else if (Nrows_Desc == 1) answer = Desc_Row_L[0];
else {
int highest_occupied_row = Nrows_Desc - 1;
while (Desc_Row_L[highest_occupied_row] == 0) highest_occupied_row--; // index of highest occupied row;
while (Desc_Row_L[highest_occupied_row] == 0) highest_occupied_row--; // index of highest occupied row;
for (int j = 0; j < Desc_Row_L[highest_occupied_row]; ++j)
answer += RefTableau.choose_table[RefTableau.dimchoose * (highest_occupied_row + Ncols_Desc - j)
+ JSC::min(highest_occupied_row, Ncols_Desc - j)];
for (int j = 0; j < Desc_Row_L[highest_occupied_row]; ++j)
answer += RefTableau.choose_table[RefTableau.dimchoose * (highest_occupied_row + Ncols_Desc - j)
+ 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];
answer += Compute_Descendent_id (0, Desc_Desc_Row_L, highest_occupied_row, Ncols_Desc - 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);
}
@@ -319,31 +320,31 @@ namespace JSC {
else if (option == 1) {
if (Nrows_Desc == 0 || Ncols_Desc == 0) answer = 0;
else if (Desc_Row_L[0] == 0) answer = 0;
else if ((Nrows_Desc == 1) || (Desc_Row_L[1] == 0)) answer = Desc_Row_L[0];
else {
int ndiag = 0;
while (Desc_Row_L[ndiag] > ndiag) ndiag++;
if (ndiag == 1) {
int Desc_Col_L_0 = Nrows_Desc;
while (Desc_Row_L[Desc_Col_L_0 - 1] == 0) Desc_Col_L_0--;
answer = (Desc_Col_L_0 - 1) * Ncols_Desc + Desc_Row_L[0];
}
else {
for (int j = 0; j < ndiag; ++j) answer += RefTableau.choose_table[RefTableau.dimchoose * Nrows_Desc + j]
for (int j = 0; j < ndiag; ++j) answer += RefTableau.choose_table[RefTableau.dimchoose * Nrows_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;
Vect_INT Desc2_Row_L(ndiag);
for (int i = 0; i < ndiag; ++i) {
for (int i = 0; i < ndiag; ++i) {
Desc2_Row_L[i] = 0;
while(Desc_Row_L[Desc2_Row_L[i] ] > i && Desc2_Row_L[i] < Ncols_Desc) Desc2_Row_L[i]++;
Desc2_Row_L[i] -= ndiag;
@@ -354,10 +355,10 @@ namespace JSC {
answer += Desc2_id * RefTableau.choose_table[RefTableau.dimchoose * Ncols_Desc + ndiag] + Desc1_id;
}
}
} // else if (option == 1)
else JSCerror("Wrong option in Young_Tableau::Compute_Descendent_id");
else ABACUSerror("Wrong option in Young_Tableau::Compute_Descendent_id");
return(answer);
}
@@ -366,22 +367,22 @@ namespace JSC {
{
long long int idnr = 0;
if (option == 0) {
if (Nrows == 0) idnr = 0;
else if (Row_L[0] == 0) idnr = 0;
else if (Nrows == 1) idnr = Row_L[0];
else {
int highest_occupied_row = Nrows - 1;
while (Row_L[highest_occupied_row] == 0) highest_occupied_row--; // index of highest occupied row;
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)
+ JSC::min(highest_occupied_row, Ncols - j)];
+ ABACUS::min(highest_occupied_row, Ncols - j)];
Vect_INT Desc_Row_L(highest_occupied_row);
@@ -389,28 +390,28 @@ namespace JSC {
idnr += Compute_Descendent_id (0, Desc_Row_L, highest_occupied_row, Ncols - Row_L[highest_occupied_row], (*this));
}
}
}
else if (option == 1) {
if (Nrows == 0 || Ncols == 0) idnr = 0;
else if (Row_L[0] == 0) idnr = 0;
else if ((Nrows == 1) || (Row_L[1] == 0)) idnr = Row_L[0];
else {
int ndiag = 0;
while (Row_L[ndiag] > ndiag) ndiag++;
if (ndiag == 1) {
idnr = (Col_L[0] - 1) * Ncols + Row_L[0];
}
else {
for (int j = 0; j < ndiag; ++j) idnr += choose_table[dimchoose * Nrows + j] * choose_table[dimchoose * Ncols + j];
Vect_INT Desc1_Row_L(ndiag);
for (int i = 0; i < ndiag; ++i) Desc1_Row_L[i] = Row_L[i] - ndiag;
@@ -422,22 +423,22 @@ namespace JSC {
idnr += Desc2_id * choose_table[dimchoose * Ncols + ndiag] + Desc1_id;
}
}
} // else if (option == 1)
else if (option == 2) {
// The order here is given by first listing all tableaux with 0 boxes, then 1, 2, ... by using Map
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 < JSC::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 JSCerror("Wrong option for Tableau ids");
else ABACUSerror("Wrong option for Tableau ids");
id = idnr;
return (*this);
}
@@ -446,7 +447,7 @@ namespace JSC {
Set_to_id (idnr, 0);
return(*this);
}
Young_Tableau& Young_Tableau::Set_to_id (long long int idnr, int option) // sets the tableau to the one corresponding to idnr
{
@@ -454,28 +455,28 @@ namespace JSC {
if ((idnr < 0) || ((maxid < idnr) && (Nrows*Ncols != 0))) {
cout << "Nrows = " << Nrows << "\tNcols = " << Ncols << "\tmaxid = " << maxid << "\trequested id = " << idnr << endl;
JSCerror("Wrong idnr in Set_to_id for Young Tableau.");
ABACUSerror("Wrong idnr in Set_to_id for Young Tableau.");
}
id = idnr;
int NColumnseff = Ncols;
long long int ideff = idnr;
for (int i = 0; i < Ncols; ++i) {
if (ideff == 0) Col_L[i] = 0;
else {
int nbar = 0;
if (ideff <= 0) nbar = 0;
while (ideff >= choose_table[dimchoose * (NColumnseff + nbar) + JSC::min(NColumnseff, nbar)]) nbar++;
while (ideff >= choose_table[dimchoose * (NColumnseff + nbar) + ABACUS::min(NColumnseff, nbar)]) nbar++;
Col_L[i] = nbar;
ideff -= choose_table[dimchoose * (NColumnseff + Col_L[i] - 1) + JSC::min(NColumnseff, Col_L[i] - 1)];
ideff -= choose_table[dimchoose * (NColumnseff + Col_L[i] - 1) + ABACUS::min(NColumnseff, Col_L[i] - 1)];
NColumnseff--;
}
@@ -488,58 +489,58 @@ namespace JSC {
else if (option == 1) {
if ((idnr < 0LL) || ((maxid < idnr) && (Nrows*Ncols != 0))) JSCerror("Wrong idnr in Set_to_id for Young Tableau.");
if (Nrows*Ncols == 0 && idnr != 0LL) JSCerror("Trying nonzero id on empty 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.");
id = idnr;
if (idnr == 0LL) {
for (int i = 0; i < Nrows; ++i) Row_L[i] = 0;
for (int i = 0; i < Ncols; ++i) Col_L[i] = 0;
}
else {
int ndiag = 0;
int sum = 0;
int sum = 0;
while ((sum < idnr) && (ndiag < Nrows) && (ndiag < Ncols)) {
ndiag++;
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) JSCerror("Zero ndiag for nonzero idnr in Tableau.");
if (ndiag == 0 && idnr != 0LL) ABACUSerror("Zero ndiag for nonzero idnr in Tableau.");
else if (ndiag == 1) {
if (Nrows >= Ncols) {
Col_L[0] = (idnr - 1)/Ncols + 1;
Col_L[0] = (idnr - 1)/Ncols + 1;
for (int i = 1; i < idnr - Ncols * (Col_L[0] - 1); ++i) Col_L[i] = 1;
for (int i = idnr - Ncols * (Col_L[0] - 1); i < Ncols; ++i) Col_L[i] = 0;
(*this).Set_Row_L_given_Col_L();
}
else if (Nrows < Ncols) {
Row_L[0] = (idnr - 1)/Nrows + 1;
Row_L[0] = (idnr - 1)/Nrows + 1;
for (int i = 1; i < idnr - Nrows * (Row_L[0] - 1); ++i) Row_L[i] = 1;
for (int i = idnr - Nrows * (Row_L[0] - 1); i < Nrows; ++i) Row_L[i] = 0;
(*this).Set_Col_L_given_Row_L();
}
}
else {
Young_Tableau Residual1(ndiag, Ncols - ndiag);
Young_Tableau Residual2(ndiag, Nrows - ndiag);
Residual2.Set_to_id(residual_id/(Residual1.maxid + 1LL));
residual_id -= (Residual1.maxid + 1LL) * Residual2.id;
Residual1.Set_to_id(residual_id);
for (int i = 0; i < ndiag; ++i) Row_L[i] = ndiag + Residual1.Row_L[i];
for (int i = 0; i < Residual2.Ncols; ++i) Row_L[ndiag + i] = Residual2.Col_L[i];
(*this).Set_Col_L_given_Row_L();
}
}
} // else if (option == 1)
@@ -547,23 +548,23 @@ namespace JSC {
else if (option == 2) {
Compute_Map (idnr); // make sure the state map is computed
(*this).Set_to_id (map[idnr], 0);
(*this).Set_to_id (map[idnr], 0);
id = idnr;
}
else JSCerror("Wrong option for Tableau id in Set_to_id");
else ABACUSerror("Wrong option for Tableau id in Set_to_id");
return(*this);
}
Young_Tableau& Young_Tableau::Set_Row_L (Vect_INT& Row_Lengths) // set row lengths to elements of given vector
{
if (Row_Lengths.size() != Nrows) JSCerror("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]) JSCerror("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();
@@ -627,7 +628,7 @@ namespace JSC {
// Recomputes id.
if (id == 0LL || Nrows == 0 || Ncols == 0) return(false); // Tableau is empty
if (i < 0 || i >= Nrows) JSCerror("Trying to Lower_Row of out of bounds index.");
if (i < 0 || i >= Nrows) ABACUSerror("Trying to Lower_Row of out of bounds index.");
if (Row_L[i] < 1 || (i < Nrows - 1 && Row_L[i+1] == Row_L[i])) // can't lower Row_L, breaks tableau rules
return(false);
else {
@@ -638,14 +639,14 @@ namespace JSC {
}
return(false);
}
bool Young_Tableau::Raise_Row (int i)
{
// Adds a box to row i. Returns success boolean.
// Recomputes id.
if (Nrows == 0 || Ncols == 0) return(false); // Tableau is empty
if (i < 0 || i >= Nrows) JSCerror("Trying to Raise_Row of out of bounds index.");
if (i < 0 || i >= Nrows) ABACUSerror("Trying to Raise_Row of out of bounds index.");
if (Row_L[i] == Ncols || (i > 1 && Row_L[i-1] == Row_L[i])) // can't raise Row_L, breaks tableau rules
return(false);
else {
@@ -656,21 +657,21 @@ namespace JSC {
}
return(false);
}
bool Young_Tableau::Raise_Lowest_Nonzero_Row()
{
{
// 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:
int iln0r = Nrows - 1;
while (Row_L[iln0r] == 0 && iln0r >= 0) iln0r--;
if (iln0r < 0) JSCerror("id wrongly set in Young_Tableau (Raise_Lowest_Nonzero_Row).");
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 !
@@ -687,7 +688,7 @@ namespace JSC {
}
bool Young_Tableau::Raise_Next_to_Lowest_Nonzero_Row()
{
{
// same thing, but for Row under lowest nonzero length one.
// Important: allow raising first row if tableau is empty.
@@ -701,10 +702,10 @@ namespace JSC {
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]) {
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();
@@ -715,17 +716,17 @@ namespace JSC {
return(true);
}
return(false);
return(false);
}
bool Young_Tableau::Move_Box_from_Col_to_Col (int ifrom, int ito)
{
// Moves a box from column ifrom to column ito. Recomputes id.
// If fails: returns false, leaves Tableau unchanged.
if (!(ifrom >= 0 && ifrom < Ncols && ito >= 0 && ito < Ncols))
return(false);
else { // try it out
int* Col_L_check = new int[Ncols];
for (int i = 0; i < Ncols; ++i) Col_L_check[i] = Col_L[i];
@@ -745,7 +746,7 @@ namespace JSC {
Vect<Young_Tableau> Young_Tableau::Descendents (int fixed_Nboxes)
{
// Produces a vector of Young_Tableau which are the descendents of
// Produces a vector of Young_Tableau which are the descendents of
// the (*this) object. If the number of boxes is not fixed, there
// are up to 2 decendents. If the number of boxes is fixed, there
// can be many more.
@@ -784,27 +785,27 @@ namespace JSC {
for (int i = 0; i < Nrows; ++i) Nboxes_tot += Row_L[i];
int Nboxes_above = 0;
for (int level = 0; level < Nrows; ++level) {
Tableau_zero.Row_L[level] = JSC::min(Nboxes_tot - Nboxes_above, Ncols);
Tableau_zero.Row_L[level] = ABACUS::min(Nboxes_tot - Nboxes_above, Ncols);
Nboxes_above += Tableau_zero.Row_L[level];
}
Tableau_zero.Set_Col_L_given_Row_L();
int level_bdry = 0;
for (int level = 0; level < Nrows; ++level)
for (int level = 0; level < Nrows; ++level)
if (Row_L[level] < Tableau_zero.Row_L[level]) level_bdry = level;
int right_bdry = JSC::min(Row_L[level_bdry] + 1, Ncols - 1);
// We can now displace a box from right to left, starting from
int right_bdry = ABACUS::min(Row_L[level_bdry] + 1, Ncols - 1);
// We can now displace a box from right to left, starting from
// a column with index <= right_bdry.
int left_bdry = 0;
for (int level = 0; level < Ncols; ++level)
for (int level = 0; level < Ncols; ++level)
if (Col_L[level] > Tableau_zero.Col_L[level]) left_bdry = level;
// We can put a box into a column with index >= left_bdry
// Now do the descendents:
Vect<Young_Tableau> Tableau_desc_init ((right_bdry - left_bdry) * (right_bdry - left_bdry));
Young_Tableau Tableau_ref = (*this);
Young_Tableau Tableau_check = (*this);
Young_Tableau Tableau_check = (*this);
for (int ifrom = right_bdry; ifrom >= left_bdry + 1; --ifrom)
for (int ito = ifrom - 1; ito >= left_bdry; --ito) {
if (Tableau_check.Move_Box_from_Col_to_Col (ifrom, ito)) {
@@ -825,13 +826,13 @@ namespace JSC {
Vect<Young_Tableau> Young_Tableau::Descendents_Boosted_State (int fixed_Nboxes)
{
// Produces a vector of Young_Tableau which are the descendents of
// Produces a vector of Young_Tableau which are the descendents of
// the (*this) object. If the number of boxes is not fixed, there
// are up to 2 decendents. If the number of boxes is fixed, there
// can be many more.
// IMPORTANT ASSUMPTIONS:
// (*this) is (or is descended from) a boosted state. The only
// (*this) is (or is descended from) a boosted state. The only
// descendents considered here are thus those for which the raised
// box is the highest still occupied box of the originally boosted state.
@@ -845,7 +846,7 @@ namespace JSC {
for (int i = 0; i < Nrows; ++i) Nboxes += Row_L[i];
if (Nboxes == 0) return(Vect<Young_Tableau> (0));
// Look for the level with the highest as yet unraised box of initial
// boosted state:
@@ -854,7 +855,7 @@ namespace JSC {
while (Row_L[level_from] == Ncols) level_from++; // necessarily is a row length < Ncols
if (Row_L[level_from] == 0) level_from--; // if row empty or beyond limit, go back one
if (Row_L[level_from] == 0) level_from--; // if row empty or beyond limit, go back one
if (!fixed_Nboxes) {
// The convention here is that we *remove* the highest yet unraised box only
@@ -871,7 +872,7 @@ namespace JSC {
Tableau_desc[0] = descendent_attempt;
return(Tableau_desc);
}
else if (ndesc != 0) JSCerror("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)
@@ -893,7 +894,7 @@ namespace JSC {
if (ndesc > 0) {
Vect<Young_Tableau> Tableau_desc(ndesc);
if (check1) Tableau_desc[0] = Tableau_check1;
if (check2) Tableau_desc[ndesc - 1] = Tableau_check2; // only up to 2 descendents
if (check2) Tableau_desc[ndesc - 1] = Tableau_check2; // only up to 2 descendents
return(Tableau_desc);
}
@@ -902,7 +903,7 @@ namespace JSC {
return(Vect<Young_Tableau> (0));
}
int Young_Tableau::Add_Boxes_From_Lowest (int Nboxes)
int Young_Tableau::Add_Boxes_From_Lowest (int Nboxes)
{
// tries to add Nboxes to Tableau, returns number of boxes added.
if (Ncols == 0 || Nrows == 0) return(0); // can't do anything !
@@ -913,7 +914,7 @@ namespace JSC {
int previous_Row_L = 0;
for (int working_level = 0; working_level < Nrows; ++working_level) {
previous_Row_L = Row_L[working_level];
Row_L[working_level] = JSC::min(previous_Row_L + Nboxes - Nboxes_added, Ncols);
Row_L[working_level] = ABACUS::min(previous_Row_L + Nboxes - Nboxes_added, Ncols);
Nboxes_added += Row_L[working_level] - previous_Row_L;
if (Nboxes_added == Nboxes) break;
}
@@ -923,4 +924,4 @@ namespace JSC {
return(Nboxes_added);
}
} // namespace JSC
} // namespace ABACUS