creativity  v1.3.0
Agent-based model of creativity and piracy
tabulate.hpp
1 #pragma once
2 #include "creativity/data/Equation.hpp"
3 #include "creativity/data/SUR.hpp"
4 #include <Eigen/Core>
5 #include <string>
6 
7 namespace creativity { namespace data {
8 
10 enum class TableFormat {
11  Text,
12  HTML,
13  LaTeX
14 };
15 
21  unsigned precision = 6;
23  bool showpoint = false;
25  bool dot_align = true;
27  std::string indent;
31  std::string title;
36  bool escape = true;
40  bool rows_align_left = false;
44  bool extracol_align_left = true;
53  bool preamble = false;
62  bool postamble = false;
64  struct {
66  bool diagonal = true;
68  bool lower = true;
70  bool upper = true;
71  } matrix;
82  explicit tabulation_options(const std::string &title = "", TableFormat format = TableFormat::Text, unsigned precision = 6, bool showpoint = false)
83  : format{format}, precision{precision}, showpoint{showpoint}, title{title} {}
84 
90  tabulation_options(TableFormat format, unsigned precision = 6, bool showpoint = false)
91  : tabulation_options("", format, precision, showpoint) {}
92 };
93 
94 
117 std::string tabulate(
118  const Eigen::Ref<const Eigen::MatrixXd> &matrix,
119  const tabulation_options &options = tabulation_options{},
120  const std::vector<std::string> &rownames = {},
121  const std::vector<std::string> &colnames = {},
122  const std::vector<std::string> &extracol = {});
123 
130 std::string tabulate_preamble(const tabulation_options &options);
131 
138 std::string tabulate_postamble(const tabulation_options &options);
139 
153 std::string tabulate_escape(const std::string &in, const tabulation_options &options);
154 
163 std::string tabulate(
164  const Equation &equation,
165  const tabulation_options &options = tabulation_options{},
166  const std::vector<std::string> &rownames = {});
167 
177 std::string tabulate(
178  const SUR &sur,
179  const tabulation_options &options = tabulation_options{},
180  const std::vector<std::string> &rownames = {});
181 
182 }}
std::string tabulate(const Eigen::Ref< const Eigen::MatrixXd > &matrix, const tabulation_options &options=tabulation_options{}, const std::vector< std::string > &rownames={}, const std::vector< std::string > &colnames={}, const std::vector< std::string > &extracol={})
Function that takes an Eigen matrix and optional row and column names and displays the results...
TableFormat
Enum for supported table output formats.
Definition: tabulate.hpp:10
std::string tabulate_preamble(const tabulation_options &options)
Returns the preamble (if any) for the format contain within the given tabulation_options.
Primary namespace for all Creativity library code.
Definition: config.hpp:4
std::string indent
The indent (only applies when format is Text)
Definition: tabulate.hpp:27
std::string tabulate_escape(const std::string &in, const tabulation_options &options)
Escapes a value according to the given tabulation options format.
Class to store a equation.
Definition: Equation.hpp:33
Struct holding various options controlling tabulation output.
Definition: tabulate.hpp:17
Class for running a seemingly-unrelated regressions model.
Definition: SUR.hpp:13
std::string tabulate_postamble(const tabulation_options &options)
Returns the postamble (if any) for the format contain within the given tabulation_options.
tabulation_options(const std::string &title="", TableFormat format=TableFormat::Text, unsigned precision=6, bool showpoint=false)
Constructs a tabulation_options struct.
Definition: tabulate.hpp:82
tabulation_options(TableFormat format, unsigned precision=6, bool showpoint=false)
Constructs a tabulation_options struct without a title but with a specified format.
Definition: tabulate.hpp:90
std::string title
The title of the table; if non-empty, this title will be displayed as a heading in some format-specif...
Definition: tabulate.hpp:31