A+B, A-B are possible only when A and B have the same dimensions, or one of them is a scalar.
A*B is possible only when the number of columns of A equals the number of rows of B, or one of them is a scalar.