octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #52756] implement xor as C++ function


From: Sahil Yadav
Subject: [Octave-bug-tracker] [bug #52756] implement xor as C++ function
Date: Tue, 16 Jan 2018 12:47:03 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36

Follow-up Comment #2, bug #52756 (project octave):

So i got to know that the function was to be implemented as a core function
rather than an oct file and i gave it quite some time.

I have implemented it now in ./libinterp/corefcn/data.cc as an inbuilt
function. Everything looks fine to me including the help text, usage, test
cases etc. 

Regarding the time taken :
The script that you provided runs in almost the same time now, i have had many
applications running simultaneously so the time was elevated for both the
functions (0.34 seconds for xor and 0.30 seconds for or). I think this is fine
enough. Time complexity again has been O(n) (Couldn't think of less than that
though).

I have basically implemented xor like this : 


xor(a,b) = !a != !b 


I had tried making a whole new operator for xor and tried mapping it to '^'
operator of c++, but was unable to do so because of the problem that i had
been treating (using the already written macros for operators) the operator^
as logical whereas of course it's bitwise (and ended up changing all the files
related to operators in liboctave and libinterp, eventually, messing up the
source and starting from scratch).

The only difference between the .m version and this is, the error that it
throws is now the one in error.h and not the one that had been hard coded in
xor.m . More precisely, we now get this (the following is the output of one of
the assert test statements):


Expected <X and Y must be of compatible size or scalars>, but got <mx_el_ne:
nonconformant arguments (op1 is 3x2, op2 is 2x3)>



Though I tried my best, there may be some styling mistakes, which will be
rectified as soon as you point them out.

Kindly, do tell me if there's anything wrong in my approach. This task has
really deepened my understanding of the octave codebase as well as mercurial.
Looking forward for a successful push of the changeset :-) 

(file #42926)
    _______________________________________________________

Additional Item Attachment:

File name: xor.diff                       Size:2 KB


    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?52756>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]