bugGNU Octave - Bugs: bug #41428, Add an &~ binary operator


bug #41428: Add an &~ binary operator

Submitted by:  David Spies <dspyz>
Submitted on:  Sun 02 Feb 2014 05:11:38 AM UTC  
Category: Octave FunctionSeverity: 1 - Wish
Priority: 3 - LowItem Group: Feature Request
Status: Patch SubmittedAssigned to: David Bateman <dbateman>
Originator Name: Open/Closed: Open
Release: devOperating System: Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


(Jump to the original submission Jump to the original submission)

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


(file #30466)

David Bateman <dbateman>
Project MemberIn charge of this item.
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


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 ;-)


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

David Bateman <dbateman>
Project MemberIn charge of this item.
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)?

David Spies <dspyz>
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)

David Spies <dspyz>
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.

John W. Eaton <jwe>
Project Administrator
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

Rik <rik5>
Project Administrator
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


David Bateman <dbateman>
Project MemberIn charge of this item.
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)

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

David Spies <dspyz>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #30466:  patch.compound_ops added by dbateman (34KiB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by dbateman (Posted a comment)
  • -unavailable- added by dspyz (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.


    Please enter the title of George Orwell's famous dystopian book (it's a date):



    Follow 6 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 05 Feb 2014 11:01:33 PM UTCdbatemanAttached File-=>Added patch.compound_ops, #30466
      StatusIn Progress=>Patch Submitted
    Mon 03 Feb 2014 04:26:38 PM UTCjweSeverity3 - Normal=>1 - Wish
      Priority5 - Normal=>3 - Low
    Sun 02 Feb 2014 11:49:35 PM UTCrik5StatusNone=>In Progress
    Sun 02 Feb 2014 05:19:36 PM UTCdbatemanAssigned toNone=>dbateman

    Back to the top

    Powered by Savane 3.1-cleanup1