Make it possible to print as row

main
Micke Nordin 2 years ago
parent d88f108aec
commit 10d74236e7
Signed by: micke
GPG Key ID: 014B273D614BE877

@ -8,6 +8,7 @@ private:
uint64_t dimention = 0; uint64_t dimention = 0;
cnumber *entries = NULL; cnumber *entries = NULL;
bool err = true; bool err = true;
bool row = false;
public: public:
bool is_error() { return this->err; } bool is_error() { return this->err; }
@ -44,6 +45,8 @@ public:
} }
return cnumber(0, 0); return cnumber(0, 0);
} }
void make_row() { this->row = true; }
void make_column() { this->row = false; }
void set_entry(const uint64_t index, const cnumber z) { void set_entry(const uint64_t index, const cnumber z) {
if (index < this->get_dimention()) { if (index < this->get_dimention()) {
this->entries[index] = z; this->entries[index] = z;
@ -60,6 +63,16 @@ public:
friend std::ostream &operator<<(std::ostream &os, const vector &v) { friend std::ostream &operator<<(std::ostream &os, const vector &v) {
int longest = 0; int longest = 0;
if (v.row) {
os << '(';
for (uint64_t i = 0; i < v.get_dimention(); i++) {
os << v[i];
if (i != v.get_dimention() - 1)
os << ',';
}
os << ')';
return os;
}
for (uint64_t i = 0; i < v.get_dimention(); i++) { for (uint64_t i = 0; i < v.get_dimention(); i++) {
std::ostringstream oss; std::ostringstream oss;
oss << v[i]; oss << v[i];

Loading…
Cancel
Save