[bug #68121] convert isequal to built-in function for performance

Andy Potvin <[email protected]>
Newsgroups gmane.comp.gnu.octave.bugs
Message-ID <[email protected]>
Please use the bug tracker to post updates to a bug report.  The mailing list is intended as a read-only notification stream.  Info posted to this mailing list address won't appear in the tracker database where it is most useful.

Follow-up Comment #2, bug #68121 (group octave):

Hi Dr. Jankowski:

Thanks for the quick response.

I'm not doing anything fancy, just checking over a million 9x9 matricies with
elements 0-9.  It SHOULD be much faster to do isequal(M1,M2) versus
all(all(M1==M2)) [fn1] because a built-in wouldn't actually do 81 comparisons
before quick exiting if any element were not the same. [fn2]

Again, I'm unfamiliar with Octave source code, but a built-in isequal(n) [fn3]
should be simpler than the .m file version.  Whatever internal data structure
Octave has should be easier to work with than all the possible MATLAB/Octave
data types (classes).  I'm guessing that, internally, Octave workspace
variables are pointers to some uniform data structure/object, right?  Let's
call it an OctaveVariable object. [fn4]  If the pointers are the same,
isequaln is a quick exit true, right? [fn5]  But, if they aren't, it should be
easy enough to compare all OctaveVariable fields/members and recurse if
necessary.

Sorry if my assumptions are naive/wrong.
Andy

[fn1] In my case about 80-81 times faster.

[fn2] While for-loops are slow in MATLAB/Octave, they are fast in source code
(C/C++).

[fn3] If isequal gets implemented as a built-in, you'll also be able to
implement isequaln for insignificant additional time.  ;-)

[fn4] Just FMI, what is the actual name of the object?

[fn5] Perhaps isequal would have to drill in?  Or does your OctaveVarible has
a boolean field called something like AnyNaNAnywhere.







    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?68121>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
signature.asc (application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaanR8wAKCRCqLAuaBUf3
TvWWAQD4r7tdlrz6dC5JjbcMnH9bM3fOXmr//Y/CadI4NixekwEA+HRIQnvlRwoS
cQvrEO+/bUvIOCZ/XGUaLHo5aMTcbws=
=VD6L
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.