Wed 05 Feb 2014 11:01:33 PM UTC, comment #7:
Well I implemented the code for the el_not_and, el_not_or, el_and_not and el_or_not operators and a changeset is attached.
However, it seems that Jaroslav never implemented the tree_compound_binary_expression::rvalue method and so the compound operators are in fact never called. I can, and have, added this method and get these compound operators to work, but in doing so I a lot of code for full matrix compound operators that is currently dead will start being used including for operators like mul_trans, herm_ldiv etc. So this change comes with a risk that this currently dead code has errors in it. I hesitate to apply it without a bit of testing, though "make check" seems to pass correctly
D.
(file #30466)
|
Mon 03 Feb 2014 08:06:32 PM UTC, comment #6:
I'm not proposing to add the operators as that are already there. I believe Micheal added them a couple of years ago. Look in ov.h(enum compound_binary_ops). The operators
op_trans_mul,
op_mul_trans,
op_herm_mul,
op_mul_herm,
op_trans_ldiv,
op_herm_ldiv,
op_el_not_and,
op_el_not_or,
op_el_and_not,
op_el_or_not,
num_compound_binary_ops,
are already defined and used for full matrices. I have a first try of the operators op_el_not_and, op_el_not_or, op_el_and_not and op_el_or_not written for scalar-sparse, sparse-scalar, full-sparse, sparse-full and sparse-sparse with the exception of op_el_not_or and op_el_or_not for sparse-sparse binary operators as I can't see a way of efficently implementing that.I just need to debug it as it doesn't quite work yet ;-)
D.
PS: I was probably optomistic for the effort needed to implement the other compound operators though UMFPACK and CHOLMOD seem to natively support the transpose and hermitian version of the solvers
|
Mon 03 Feb 2014 05:00:37 PM UTC, comment #5:
For this Feature Request, I was really just asking about 'and_not'. If implementing or_not at the same time is convenient, then by all means go ahead, but it's not something that can be used practically with sparse matrices anyway (or optimized for full matrices as far as I know).
Many bitset libraries include 'and, or, xor, and_not', as these are the set of binary boolean operators (up to swapping the inputs) for which (0,0) -> 0, but I don't know of any particular implementations or uses of or_not.
Also, by not_or and not_and, do you mean nor and nand or do you mean r(or_not) and r(and_not) (like rmul and rdiv)?
|
Mon 03 Feb 2014 04:39:55 PM UTC, comment #4:
I was proposing a new operator, but only because I didn't know it was possible to specially handle a recognized sequence. Yes, of course it would be better to handle & and ~ together specially if possible (since it may optimize existing code).
But, I still think it is important to have the functional equivalent so that it can be used with bsxfun (that is, once http://savannah.gnu.org/bugs/?41441 is resolved)
|
Mon 03 Feb 2014 04:26:38 PM UTC, comment #3:
David, are you proposing adding new operators, or just recognizing the sequence of operators and handling them specially as is done for the other compound operators?
I would rather not introduce new syntax.
|
Sun 02 Feb 2014 11:49:35 PM UTC, comment #2:
Do we want to also provide the functional equivalents such as and_not, or_not in the same way that we provide functional forms of the operators 'and' and 'or'. Or is it enough for people to call
|
Sun 02 Feb 2014 05:19:36 PM UTC, comment #1:
The compound operators not_and, not_or, an_not and or_not exist already in octave and are used for full matrices. Its just a matter of slightly modifying a couple of macros in Sparse-op-defs.h, instatiating these functions and then installing the associated binary operators in the op-sm-sm.cc, etc. I've started doing this and should have a patch shortly
We should probably also treat the other compound operators trans_mul, mul_trans, herm_mul, mul_herm, trans_ldiv and herm_ldiv as well. Seems like a nice little project so I'll try to do this at the same time
D.
|
Sun 02 Feb 2014 05:11:38 AM UTC, original submission:
In pretty much every project I write, I always end up writing an andnot.m
function [r] = andnot(a,b)
a(logical(b)) = false
r = logical(a)
end
It comes up consistently with logical operations and if you're dealing with sparse matrices, you can't say a & ~b without invoking an OOM
|