Thu 06 Feb 2014 07:56:21 AM UTC, original submission:
Can you add three fairly standard logical matrix multiply operations (particularly for sparse matrices) which can be useful for dealing with graphs and adjacency matrices?
mult_any
Same as
res = logical(A * B)
mult_all
Same as
res = A * B == sum(B,1)
(here the '==' is automatically broadcasted)
This one is the one I actually need since the matrix A * B may require more memory than I have available, but I suspect there's a more memory efficient way to make this particular computation.
Particularly if we find a k such that A(i,k) is false and B(k,j) is true than res(i,j) must be false (without having to explore other k-values)
mult_parity
Same as
res = logical(mod(A * B,2))
You can think of these operations in the context that the columns of B mark sets of relevant variables and the rows of A are values for those variables. The resulting matrix represents each of the operations (any, or, parity) for each set of values on each set of variables.
Note that a normal matrix multiply can be thought of as mult_join_sum for a logical matrix B.
I suppose there could be others like mult_maj, but that doesn't correspond to a commutative associative binary operation like the others (and, or, xor), so I expect there might not be anything to be gained by implementing it explicitly.
|