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