// implement the Matrix class #include using std::cout; using std::endl; #include "Matrix.h" Matrix::Matrix(double a, double b, double c, double d): a_(a), b_(b), c_(c), d_(d) { //default constrctor } Matrix::Matrix(const Matrix& m): a_(m.a_), b_(m.b_), c_(m.c_), d_(m.d_) { //copy constructor } double Matrix::det() { return a_*d_ - b_*c_; } bool Matrix::isSingular() { if(det() == 0 ) return false; else return true; } Matrix Matrix::inverse() { double k = 1/det(); Matrix temp(k*d_,-k*b_,-k*c_,k*a_); return temp; } void Matrix::print() { cout << a_ << " " << b_ << '\n' << c_ << " " << d_ << "\n"; }