public Matrix add(Matrix matrix) {
		if (matrix.cols == cols && matrix.rows == rows) {
			Matrix newMatrix = new Matrix(rows, cols);
			for (int i = 0; i < cols * rows; i++) {
				newMatrix.values[i] = this.values[i] + matrix.values[i];
			}
			return newMatrix;
		} else {
			try {
				throw new Exception("Attempted to add incompatible matrices.");
			} catch (Exception e) {
				e.printStackTrace();
			}
			return null;
		}
	}