#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

class Matrix {
protected:
   double** mp;
   int rows, cols;
public:
   Matrix(int, int);
    Matrix(Matrix&);
   ~Matrix();
   Matrix& operator=( Matrix&);
   double& operator()(int, int);
   friend Matrix operator+( Matrix&,  Matrix&);
   friend Matrix operator*(Matrix&, double);
   friend Matrix operator*(double,  Matrix&);
   friend Matrix operator*( Matrix&,  Matrix&);
   friend istream& operator>>(istream&,  Matrix&);
   friend ostream& operator<<(ostream&,  Matrix&);
   Matrix restrict(int, int); // Return the ij'th max'l submatrix
};

class Vector : public Matrix {
public:
   Vector(Matrix &other) : Matrix(other) {
        assert(cols==1);
    };
      Vector(int n) : Matrix(n, 1) {;};
    double& operator()(int);
    friend double operator|( Vector& ,  Vector&);

};

class SquareMatrix : public Matrix {
public:
    SquareMatrix(Matrix &other) : Matrix(other) {
        assert(rows==cols);
    };
    SquareMatrix(int n) : Matrix(n,n) {;};
    double tr();  // calculate trace
    double det();  // calculate determinant
    SquareMatrix inv();  // calculate inverse
    SquareMatrix adj();
};
