|
|
|
@ -21,8 +21,8 @@ public:
|
|
|
|
|
~matrix() {
|
|
|
|
|
this->num_cols = 0;
|
|
|
|
|
this->num_rows = 0;
|
|
|
|
|
free(this->cols);
|
|
|
|
|
this->cols = NULL;
|
|
|
|
|
// free(this->cols);
|
|
|
|
|
// this->cols = NULL;
|
|
|
|
|
}
|
|
|
|
|
const vector get_diagonal() const {
|
|
|
|
|
long long diag_len = this->num_rows;
|
|
|
|
@ -39,6 +39,20 @@ public:
|
|
|
|
|
}
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
const vector get_row(long long index) const { return this->cols[index]; }
|
|
|
|
|
|
|
|
|
|
const vector get_column(long long index) const {
|
|
|
|
|
vector v(this->num_rows);
|
|
|
|
|
for (long long j = 0; j < this->num_rows; j++) {
|
|
|
|
|
v[j] = this->cols[j][index];
|
|
|
|
|
}
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const matrix rotate_ninety() const {
|
|
|
|
|
matrix m(this->num_cols, this->num_rows);
|
|
|
|
|
return m;
|
|
|
|
|
}
|
|
|
|
|
const matrix transpose() const {
|
|
|
|
|
matrix n(this->num_rows, this->num_cols);
|
|
|
|
|
for (long long i = 0; i < this->num_cols; i++) {
|
|
|
|
@ -64,7 +78,7 @@ public:
|
|
|
|
|
}
|
|
|
|
|
const bool is_hermitian() const {
|
|
|
|
|
if (this->num_rows != this->num_cols)
|
|
|
|
|
return false;
|
|
|
|
|
return false;
|
|
|
|
|
matrix m = this->hermitian_conjugate();
|
|
|
|
|
bool equal = true;
|
|
|
|
|
for (long long i = 0; i < m.num_cols; i++) {
|
|
|
|
@ -122,6 +136,18 @@ public:
|
|
|
|
|
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
const matrix operator*(const matrix m) const {
|
|
|
|
|
matrix n(this->num_cols, m.num_rows);
|
|
|
|
|
// if (this->num_cols != m.num_rows && m.num_cols != this->num_rows)
|
|
|
|
|
// return n;
|
|
|
|
|
for (long long i = 0; i < this->num_rows; i++) {
|
|
|
|
|
for (long long j = 0; j < this->num_rows; j++) {
|
|
|
|
|
n[i][j] = this->get_row(i) * m.get_column(j);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return n;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const matrix operator+(const matrix &m) const {
|
|
|
|
|
matrix n(this->num_cols, this->num_rows);
|
|
|
|
|