I have two column vector A and B of same length n.
In both vectors, there are only 3 possible values for their elements: -1, 0 and 1.
When I multiply A by B element-wise, I hope to get the expect results for 1x1, 1x(-1) and (-1)x(-1).
However, here, when 0 is a term in the multiplication, I'd like to get the following results:
0x0 = 1
0x1 = -1
0x(-1) = -1
Element-wise multiplication is easy in MATLAB:
times(A,B) or A.*B
I'd like know how to set up a predefined result for an operation, say, 0x0 =1. Knowing this one, I'll be able to deal with the others.