Could you code your ternary state in std::bitset<2> and define the product in terms of and ? For example, if your ternary types are:
1 = P = (1, 1) 0 = Z = (0, 0) -1 = M = (1, 0) or (0, 1)
I believe that you can define your product as:
1 * 1 = 1 => P * P = P => (1, 1) & (1, 1) = (1, 1) = P 1 * 0 = 0 => P * Z = Z => (1, 1) & (0, 0) = (0, 0) = Z 1 * -1 = -1 => P * M = M => (1, 1) & (1, 0) = (1, 0) = M
Then the inner work can begin with the adoption of and from the bits of the elements and ... I am working on how to add them.
Edit:
My stupid proposal did not consider that (-1)(-1) = 1 , which could not be processed by the proposal I proposed. Thanks @ user92382 for this.
source share