Add is_invertible

main
Micke Nordin 2 years ago
parent 08a1877709
commit 881b0b44cf
Signed by: micke
GPG Key ID: 014B273D614BE877

@ -145,10 +145,6 @@ public:
} }
return result; return result;
} }
const bool is_unitary() const{
matrix m = this->hermitian_conjugate();
return (*this * m == this->I());
}
// FIXME: This is very dumb // FIXME: This is very dumb
const vector get_eigenvalues() const { const vector get_eigenvalues() const {
if (this->is_diagonal()) if (this->is_diagonal())
@ -163,6 +159,11 @@ public:
return false; return false;
return *this == this->hermitian_conjugate(); return *this == this->hermitian_conjugate();
} }
const bool is_invertible() const { return this->determinant() != 0; }
const bool is_unitary() const {
matrix m = this->hermitian_conjugate();
return (*this * m == this->I());
}
friend std::ostream &operator<<(std::ostream &os, const matrix &m) { friend std::ostream &operator<<(std::ostream &os, const matrix &m) {
char last = '\0'; char last = '\0';
int longest = 0; int longest = 0;

Loading…
Cancel
Save