|
|
|
@ -4,20 +4,27 @@
|
|
|
|
|
using namespace std;
|
|
|
|
|
class vector {
|
|
|
|
|
private:
|
|
|
|
|
long long dimention;
|
|
|
|
|
cnumber *entries;
|
|
|
|
|
long long dimention = 0;
|
|
|
|
|
cnumber *entries = NULL;
|
|
|
|
|
bool err = true;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
bool is_error() { return this->err; }
|
|
|
|
|
vector() {};
|
|
|
|
|
vector(const long long dimention) {
|
|
|
|
|
this->err = false;
|
|
|
|
|
this->dimention = dimention;
|
|
|
|
|
this->entries = (cnumber *)calloc(sizeof(cnumber), dimention);
|
|
|
|
|
free(this->entries);
|
|
|
|
|
this->entries = (cnumber *)malloc(sizeof(cnumber)* dimention);
|
|
|
|
|
for (long long i = 0; i < dimention; i++) {
|
|
|
|
|
this->set_entry(i, cnumber(0, 0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
vector(const vector &v) {
|
|
|
|
|
this->err = false;
|
|
|
|
|
this->dimention = v.get_dimention();
|
|
|
|
|
this->entries = (cnumber *)calloc(sizeof(cnumber), v.get_dimention());
|
|
|
|
|
free(this->entries);
|
|
|
|
|
this->entries = (cnumber *)malloc(sizeof(cnumber)* v.get_dimention());
|
|
|
|
|
for (long long i = 0; i < v.get_dimention(); i++) {
|
|
|
|
|
this->set_entry(i, v.get_entry(i));
|
|
|
|
|
}
|
|
|
|
@ -59,10 +66,11 @@ public:
|
|
|
|
|
void operator=(const vector &v) {
|
|
|
|
|
this->dimention = v.get_dimention();
|
|
|
|
|
free(this->entries);
|
|
|
|
|
this->entries = (cnumber *)calloc(sizeof(cnumber), dimention);
|
|
|
|
|
this->entries = (cnumber *)malloc(sizeof(cnumber)* dimention);
|
|
|
|
|
for (long long i = 0; i < v.get_dimention(); i++) {
|
|
|
|
|
this->set_entry(i, v.get_entry(i));
|
|
|
|
|
}
|
|
|
|
|
this->err = false;
|
|
|
|
|
}
|
|
|
|
|
const vector operator+(const vector &v) const {
|
|
|
|
|
if (this->get_dimention() != v.get_dimention()) {
|
|
|
|
|