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 Function Severity:  1 - Wish
Priority:  3 - Low Item Group:  Feature Request
Status:  Patch Submitted Assigned to:  David Bateman <dbateman>
Originator Name:  Open/Closed:  Open
Release:  dev Operating 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)

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)

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

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

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

D.

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

David Spies <dspyz>

 

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

Attach Files:
   
   
Comment:
   

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
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by dbateman (Posted a comment)
  • -email is unavailable- added by dspyz (Submitted the item)
  •  

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

    Only project members can vote.

     

     

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-02-05 dbateman Attached File- => Added patch.compound_ops, #30466
        StatusIn Progress => Patch Submitted
    2014-02-03 jwe Severity3 - Normal => 1 - Wish
        Priority5 - Normal => 3 - Low
    2014-02-02 rik5 StatusNone => In Progress
    2014-02-02 dbateman Assigned toNone => dbateman

    Back to the top


    Powered by Savane 3.3