18 data += { 10, 20, 30 };
19 data += { 100, 200, 300 };
20 data += { 1000, 2000, 3000 };
22 Format fmt{ __func__,
",",
"\n",
"csv" };
25 data.
save(csvstream, fmt);
38 for (
const auto x : { 6, 3, 2 }) {
40 data += { phi, sin(phi), cos(phi) };
44 Format fmt{ __func__,
",",
"\n",
"csv" };
48 data.
save(csvstream, fmt, [](
const auto &crow) {
61 table += { -4, 3, 7, 1 };
62 table += { -2, 8, 2, 0 };
63 table += { 9, 1, 1, 2 };
69 for (
size_t idx = 0; idx < crow.size(); idx++) {
70 results[idx] += std::pow(crow[idx], 2);
74 for (
auto &res : results) {
79 Data normtable = table;
81 for (
auto &crow : normtable.
data()) {
82 for (
size_t idx = 0; idx < crow.size(); idx++) {
83 crow[idx] /= results[idx];
90 Format fmt{ __func__,
",\t",
"\n",
"csv" };
94 table.
save(csvstream, fmt);
95 csvstream <<
"-------------------------------" << std::endl;
97 normtable.
save(csvstream, fmt);
108 table += { 1, 2, 3, 4 };
109 table += { 5, 6, 7, 8 };
110 table += { 9, 10, 11, 12 };
114 std::replace_if(
ALL(crow), [](
double x) {
return x > 6; }, -1);
118 Format fmt{ __func__,
",",
"\n",
"csv" };
122 table.
save(csvstream, fmt);
138 std::ifstream ifs(filename);
143 std::replace_if(
ALL(crow), [](
double x) {
return x < 6; }, 0);
147 Format fmt{ __func__,
",\t",
"\n",
"csv" };
149 table.
save(csvstream, fmt);
160 for (
double x = -5; x < 5; x += 1) {
161 table += { x, pow(x, 3), pow(x, 5) };
165 const auto view = table.
view(
167 return crow[1] > 0 && crow[2] > 0;
173 Format fmt{ __func__,
",\t",
"\n",
"csv" };
175 view.save(csvstream, fmt);
187 for (
double x = -4; x < 4; x += 1) {
188 table += { x, pow(x, 3), sin(x) };
196 Format fmt{ __func__,
",\t",
"\n",
"csv" };
198 table.
save(csvstream, fmt);
199 csvstream <<
"--------------" << std::endl;
200 view.save(csvstream, fmt);
212 table += { x, std::cos(x), std::sin(x) };
216 const auto view = table.
view(
224 Format fmt{ __func__,
",\t",
"\n",
"csv" };
226 table.
save(csvstream, fmt);
227 csvstream <<
"--------------" << std::endl;
228 view.save(csvstream, fmt);
229 csvstream <<
"--------------" << std::endl;
231 fmt.write_line(csvstream, clmn);
void apply(FN fn)
apply ändere alle oder bestimmte Elemente
static double to_degrees(double x)
void ex18()
ex18 Bearbeitung einer Tabelle. Berechnung der Normen von Vektoren
auto select_rows(size_t step, size_t startidx=0, bool last=false) const
view Teile der Tabelle als View
void ex19()
ex19 Suchen und Bearbeiten von Elementen einer Tabelle
void ex23()
ex23 Kopie einer Spalte
std::vector< double > Column
auto view() const
view die ganze Tabelle als view
void save(std::ostream &ofs, Format fmt) const
save Schreibe Tabelle in Datei
void ex20()
ex20 lade Tabelle aus csv-Datei ändere Werte und speichere Tabelle wieder ab
The Data class Eine Klasse für Zahlentabellen mit fester Anzahl von Spalten. Die Anzahl der Reihen wä...
const auto & data() const
data lesender Zugriff auf die interne Struktur
static std::ofstream get_stream(const std::string &fname)
get_output_stream Öffnen einer Ausgabedatei falls die Datei nicht geöffnet werden kann wird ein Fehle...
void ex21()
ex21 Filter für Funktionswerte (Sicht auf Tabelle)
void ex17()
ex17 Ausgabe einer Tabelle in Datei. Jede Zeile wird vor dem Speichern bearbeitet ...
void read_csv(std::ifstream &ifs)
read_csv lese Daten aus csv-Datei
void ex16()
ex16 Aufbau einer Tabelle und Ausgabe in Datei
static const std::string data_directory
void ex22()
ex22 Filter für Funktionswerte: Filter für jede zweite Reihe der Tabelle
static constexpr double PI
std::array< double, N > Row