feat(opatIO): added printTable method
tables can now be printed with clear truncation rules
This commit is contained in:
@@ -296,37 +296,110 @@ void OpatIO::printTableIndex() {
|
||||
}
|
||||
}
|
||||
|
||||
void OpatIO::printTable(OPATTable table, uint32_t truncateDigits) {
|
||||
int printTo;
|
||||
bool truncate = false;
|
||||
if (table.N_R > truncateDigits) {
|
||||
printTo = truncateDigits;
|
||||
truncate = true;
|
||||
} else {
|
||||
printTo = table.N_R-1;
|
||||
}
|
||||
std::cout << "LogR (size: " << table.logR.size() << "): [";
|
||||
for (int i = 0; i < printTo; ++i) {
|
||||
std::cout << table.logR.at(i) << ", ";
|
||||
}
|
||||
if (truncate) {
|
||||
std::cout << "..., ";
|
||||
for (int i = truncateDigits; i > 1; --i) {
|
||||
std::cout << table.logR.at(table.logR.size() - i) << ", ";
|
||||
}
|
||||
}
|
||||
std::cout << table.logR.back() << "]" << std::endl;
|
||||
|
||||
// // Print a table
|
||||
// void OpatIO::printTable(OPATTable table) {
|
||||
// std::cout << "Table ID: " << table.tableID << std::endl;
|
||||
// std::cout << "N_R: " << table.N_R << std::endl;
|
||||
// std::cout << "N_T: " << table.N_T << std::endl;
|
||||
// std::cout << "LogR: ";
|
||||
// for (uint32_t i = 0; i < table.N_R; ++i) {
|
||||
// std::cout << table.logR[i] << " ";
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
// std::cout << "LogT: ";
|
||||
// for (uint32_t i = 0; i < table.N_T; ++i) {
|
||||
// std::cout << table.logT[i] << " ";
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
// std::cout << "LogKappa: ";
|
||||
// for (uint32_t i = 0; i < table.N_R * table.N_T; ++i) {
|
||||
// std::cout << table.logKappa[i] << " ";
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
// }
|
||||
if (table.N_T > truncateDigits) {
|
||||
printTo = truncateDigits;
|
||||
truncate = true;
|
||||
} else {
|
||||
printTo = table.N_T-1;
|
||||
}
|
||||
std::cout << "LogT (size: " << table.logT.size() << "): [";
|
||||
for (int i = 0; i < printTo; ++i) {
|
||||
std::cout << table.logT.at(i) << ", ";
|
||||
}
|
||||
if (truncate) {
|
||||
std::cout << "..., ";
|
||||
for (int i = truncateDigits; i > 1; --i) {
|
||||
std::cout << table.logT.at(table.logT.size() - i) << ", ";
|
||||
}
|
||||
}
|
||||
std::cout << table.logT.back() << "]" << std::endl;
|
||||
|
||||
// // Get all tables
|
||||
// std::vector<OPATTable> OpatIO::getTables() {
|
||||
// std::vector<OPATTable> tables;
|
||||
// for (const auto &index : tableIndex) {
|
||||
// tables.push_back(getTable(index.tableID));
|
||||
// }
|
||||
// return tables;
|
||||
// }
|
||||
bool truncateRow = false;
|
||||
bool truncateCol = false;
|
||||
int printToRow, printToCol;
|
||||
if (table.N_T > truncateDigits) {
|
||||
printToRow = truncateDigits;
|
||||
truncateRow = true;
|
||||
} else {
|
||||
printToRow = table.N_T-1;
|
||||
}
|
||||
if (table.N_R > truncateDigits) {
|
||||
printToCol = truncateDigits;
|
||||
truncateCol = true;
|
||||
} else {
|
||||
printToCol = table.N_R-1;
|
||||
}
|
||||
|
||||
std::cout << "LogKappa (size: " << table.N_R << " x " << table.N_T << "): \n[";
|
||||
for (int rowIndex = 0; rowIndex < printToRow; rowIndex++) {
|
||||
std::cout << "[";
|
||||
for (int colIndex = 0; colIndex < printToCol; colIndex++) {
|
||||
std::cout << table.logKappa.at(rowIndex).at(colIndex) << ", ";
|
||||
}
|
||||
if (truncateRow) {
|
||||
std::cout << "..., ";
|
||||
for (int i = truncateDigits; i > 1; i--) {
|
||||
std::cout << table.logKappa.at(rowIndex).at(table.logKappa.at(rowIndex).size() - i) << ", ";
|
||||
}
|
||||
}
|
||||
std::cout << table.logKappa.at(rowIndex).back() << "],\n";
|
||||
}
|
||||
if (truncateCol) {
|
||||
std::cout << ".\n.\n.\n";
|
||||
for (int rowIndex = truncateDigits; rowIndex > 1; rowIndex--) {
|
||||
std::cout << "[";
|
||||
for (int colIndex = 0; colIndex < printToCol; colIndex++) {
|
||||
std::cout << table.logKappa.at(rowIndex).at(colIndex) << ", ";
|
||||
}
|
||||
if (truncateRow) {
|
||||
std::cout << "..., ";
|
||||
for (int i = truncateDigits; i > 1; i--) {
|
||||
std::cout << table.logKappa.at(rowIndex).at(table.logKappa.at(rowIndex).size() - i) << ", ";
|
||||
}
|
||||
}
|
||||
std::cout << table.logKappa.at(rowIndex).back() << "],\n";
|
||||
}
|
||||
std::cout << "[";
|
||||
for (int colIndex = 0; colIndex < printToCol; colIndex++) {
|
||||
std::cout << table.logKappa.back().at(colIndex) << ", ";
|
||||
}
|
||||
if (truncateRow) {
|
||||
std::cout << "..., ";
|
||||
for (int i = truncateDigits; i > 1; i--) {
|
||||
std::cout << table.logKappa.back().at(table.logKappa.back().size() - i) << ", ";
|
||||
}
|
||||
}
|
||||
std::cout << table.logKappa.back().back() << "]";
|
||||
}
|
||||
std::cout << "]" << std::endl;
|
||||
}
|
||||
|
||||
void OpatIO::printTable(double X, double Z, uint32_t truncateDigits) {
|
||||
int tableID = lookupTableID(X, Z);
|
||||
OPATTable table = getTable(tableID);
|
||||
printTable(table, truncateDigits);
|
||||
}
|
||||
|
||||
// Get the table index
|
||||
std::vector<TableIndex> OpatIO::getTableIndex() {
|
||||
|
||||
@@ -61,9 +61,11 @@ private:
|
||||
void flushQueue();
|
||||
|
||||
OPATTable getTable(int tableID);
|
||||
void printTable(OPATTable table, uint32_t truncateDigits=5);
|
||||
|
||||
void XZLookupEpsilon();
|
||||
void buildTableIDToComposition();
|
||||
|
||||
public:
|
||||
OpatIO();
|
||||
OpatIO(std::string filename);
|
||||
@@ -79,9 +81,8 @@ public:
|
||||
|
||||
void printHeader();
|
||||
void printTableIndex();
|
||||
void printTable(OPATTable table);
|
||||
void printTable(double X, double Z, uint32_t truncateDigits=5);
|
||||
|
||||
std::vector<OPATTable> getTables();
|
||||
std::vector<TableIndex> getTableIndex();
|
||||
Header getHeader();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user