0001 function prodAB = cprod(A,B)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 if isnumeric(A) && iscstruct(B)
0017 realA = real(A);
0018 imagA = imag(A);
0019 prodAB.real = realA*B.real - imagA*B.imag;
0020 prodAB.imag = realA*B.imag + imagA*B.real;
0021
0022 elseif iscstruct(A) && isnumeric(B)
0023 realB = real(B);
0024 imagB = imag(B);
0025 prodAB.real = A.real*realB - A.imag*imagB;
0026 prodAB.imag = A.real*imagB + A.imag*realB;
0027
0028 elseif isnumeric(A) && isnumeric(B)
0029 prodAB = A*B;
0030
0031 elseif iscstruct(A) && iscstruct(B)
0032 prodAB.real = A.real*B.real - A.imag*B.imag;
0033 prodAB.imag = A.real*B.imag + A.imag*B.real;
0034
0035 else
0036 ME = MException('cprod:inputError', ...
0037 'Input does not have the expected format.');
0038 throw(ME);
0039
0040 end
0041
0042 end