code: public static final DoubleMatrix2D invert2x2Matrix(DoubleMatrix2D A) throws Exception{
  		if(2!=A.rows() || A.rows() != A.columns()){
  			throw new IllegalArgumentException("matrix is not 2x2");
  		}
  		//ad - bc
  		double s = A.getQuick(0, 0)*A.getQuick(1, 1)-A.getQuick(0, 1)*A.getQuick(1, 0);
  		if(Math.abs(s) < 1.e-16){
  			throw new Exception("Matrix is singular");
  		}
  		DoubleMatrix2D ret = new DenseDoubleMatrix2D(2, 2);
  		ret.setQuick(0, 0, A.getQuick(1, 1) / s);
  		ret.setQuick(1, 1, A.getQuick(0, 0) / s);
  		ret.setQuick(0, 1, -A.getQuick(1, 0) / s);
  		ret.setQuick(1, 0, A.getQuick(0, 1) / s);
  		return ret;
  	}
docs: inversion of {{a, b},{c, d}}
  @param A
  @return