public float getDeterminant() {
		if(!isSquare())
			throw new IllegalArgumentException("Non-square matrix");
		if(numRows == 1) return elements[0][0];
		if(numRows == 2) {
			return elements[0][0] * elements[1][1] - elements[0][1] *
					elements[1][0];
		}
		
		float sum = 0;
		for(int i = 0; i < numRows; i++) {
			Matrix sub = getExcludedMatrix(i, 0);
			float term = elements[i][0] * sub.getDeterminant();
			sum += term * ((i & 1) == 0 ? 1 : -1);
		}
		
		return sum; // TODO improve this and get inverse
	}