Print a table (for console output in particular)
| 754 | |
| 755 | // Print a table (for console output in particular) |
| 756 | std::string TableMultiVariableLookup_Impl::printTable(unsigned int precision) const { |
| 757 | std::vector<TableMultiVariableLookupPoint> points = this->points(); |
| 758 | std::stringstream ss; |
| 759 | int size = points[0].x().size(); |
| 760 | |
| 761 | ss << "|" << centered("n", 5) << "|"; |
| 762 | for (int i = 1; i <= size; ++i) { |
| 763 | std::stringstream tempss; |
| 764 | tempss << "x" << i; |
| 765 | ss << centered(tempss.str(), 15) << "|"; |
| 766 | } |
| 767 | ss << centered("y", 15) << "|"; |
| 768 | ss << "\n" |
| 769 | << "|-----+"; |
| 770 | for (int i = 1; i <= size; ++i) { |
| 771 | ss << std::string(15, '-') << "+"; |
| 772 | } |
| 773 | ss << std::string(15, '-') << "|\n"; |
| 774 | |
| 775 | int i = 1; |
| 776 | for (const TableMultiVariableLookupPoint& pt : points) { |
| 777 | ss << "|" << centered(std::to_string(i), 5); |
| 778 | for (const double& x : pt.x()) { |
| 779 | ss << "|" << centered(x, 15, precision); |
| 780 | } |
| 781 | ss << "|" << centered(pt.y(), 15, precision) << "|\n"; |
| 782 | ++i; |
| 783 | } |
| 784 | |
| 785 | return ss.str(); |
| 786 | } |
| 787 | |
| 788 | std::vector<double> TableMultiVariableLookup_Impl::xValues(int xIndex) const { |
| 789 | std::vector<double> result; |