main
Micke Nordin 2 years ago
parent 690228e9ea
commit 97a4d8e0ab
Signed by: micke
GPG Key ID: 014B273D614BE877

@ -32,7 +32,8 @@ public:
~vector() { ~vector() {
this->dimention = 0; this->dimention = 0;
free(this->entries); free(this->entries);
this->entries = NULL; //this->entries = NULL;
this->err = true;
} }
long long get_dimention() const { return this->dimention; } long long get_dimention() const { return this->dimention; }
cnumber *get_entries() const { return this->entries; } cnumber *get_entries() const { return this->entries; }
@ -40,7 +41,7 @@ public:
if (index < this->get_dimention()) { if (index < this->get_dimention()) {
return this->entries[index]; return this->entries[index];
} }
return cnumber(0,0); return cnumber(0, 0);
} }
void set_entry(const long long index, const cnumber z) { void set_entry(const long long index, const cnumber z) {
if (index < this->get_dimention()) { if (index < this->get_dimention()) {
@ -52,7 +53,8 @@ public:
return this->get_entry(index); return this->get_entry(index);
} }
// FIXME: Figure out how to make sure you do not try to access something outside of the index // FIXME: Figure out how to make sure you do not try to access something
// outside of the index
cnumber &operator[](const long long index) { return this->entries[index]; } cnumber &operator[](const long long index) { return this->entries[index]; }
friend ostream &operator<<(ostream &os, const vector &v) { friend ostream &operator<<(ostream &os, const vector &v) {
@ -101,7 +103,7 @@ public:
return product; return product;
} }
const cnumber operator*(const vector &v) const { const cnumber operator*(const vector &v) const {
cnumber res(0,0); cnumber res(0, 0);
for (long long i = 0; i < this->get_dimention(); i++) { for (long long i = 0; i < this->get_dimention(); i++) {
res = res + this->get_entry(i) * v.get_entry(i); res = res + this->get_entry(i) * v.get_entry(i);
} }

Loading…
Cancel
Save