Add identity matrix and check for eigenvalue
This commit is contained in:
parent
909c52ecfd
commit
e662c7bebd
1 changed files with 16 additions and 0 deletions
16
matrix.hpp
16
matrix.hpp
|
@ -108,6 +108,22 @@ public:
|
|||
const matrix hermitian_conjugate() const {
|
||||
return this->transpose().conjugate();
|
||||
}
|
||||
const matrix I() const {
|
||||
matrix m = matrix(this->num_entries, this->entry_dimension);
|
||||
for (long long i = 0; i < this->num_entries; i++) {
|
||||
for (long long j = 0; j < this->entry_dimension; j++) {
|
||||
if (i == j) {
|
||||
m[i][j] = cnumber(1, 0);
|
||||
} else {
|
||||
m[i][j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
const bool is_eigenvalue(cnumber z) const {
|
||||
return ((*this - (this->I() * z)).determinant() == 0);
|
||||
}
|
||||
const bool is_hermitian() const {
|
||||
if (this->entry_dimension != this->num_entries)
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue