[bug #55077] automatic broadcasting for dot product

Andreas Bertsatos <[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 #4, bug #55077 (group octave):

Perhaps, this topic should be discussed on next monthly meeting and decide
which functions should be included in the list for extending broadcasting. 

Testing with Octave 11.0.92, I see that from the list with functional form
only: *xor*, *max*, *min*, *mod*, *rem*, *atan2*, *atan2d*, and *hypot*
support broadcasting; *bitand*, *bitor*, and *bitxor* only support common
size, while *dot* requires equal size (the same applies to *cross* as well).

Full broadcasting support

octave:52> xor ([0, 1, 2, 3], [3; 2; 1])
ans =

  1  0  0  0
  1  0  0  0
  1  0  0  0

octave:53> max ([0, 1, 2, 3], [3; 2; 1])
ans =

   3   3   3   3
   2   2   2   3
   1   1   2   3

octave:54> min ([0, 1, 2, 3], [3; 2; 1])
ans =

   0   1   2   3
   0   1   2   2
   0   1   1   1

octave:55> mod ([0, 1, 2, 3], [3; 2; 1])
ans =

   0   1   2   0
   0   1   0   1
   0   0   0   0

octave:56> rem ([0, 1, 2, 3], [3; 2; 1])
ans =

   0   1   2   0
   0   1   0   1
   0   0   0   0

octave:57> atan2 ([0, 1, 2, 3], [3; 2; 1])
ans =

        0   0.3218   0.5880   0.7854
        0   0.4636   0.7854   0.9828
        0   0.7854   1.1071   1.2490

octave:58> atan2d ([0, 1, 2, 3], [3; 2; 1])
ans =

         0   18.4349   33.6901   45.0000
         0   26.5651   45.0000   56.3099
         0   45.0000   63.4349   71.5651

octave:59> hypot ([0, 1, 2, 3], [3; 2; 1])
ans =

   3.0000   3.1623   3.6056   4.2426
   2.0000   2.2361   2.8284   3.6056
   1.0000   1.4142   2.2361   3.1623


Common size only

octave:60> bitand ([0, 1, 2, 3], [3; 2; 1])
error: bitand: size of X and Y must match, or one operand must be a scalar
octave:71> bitand  ([0, 1, 2, 3], [1])
ans =

   0   1   0   1

octave:61> bitor ([0, 1, 2, 3], [3; 2; 1])
error: bitor: size of X and Y must match, or one operand must be a scalar
octave:72> bitor  ([0, 1, 2, 3], [1])
ans =

   1   1   3   3

octave:62> bitxor ([0, 1, 2, 3], [3; 2; 1])
error: bitxor: size of X and Y must match, or one operand must be a scalar
octave:73> bitxor  ([0, 1, 2, 3], [1])
ans =

   1   0   3   2


Explicitly equal sizes

octave:63> dot ([0, 1, 2, 3], [3; 2; 1])
error: dot: sizes of X and Y must match
octave:65> dot ([0, 1, 2, 3], [1])
error: dot: sizes of X and Y must match

octave:69> cross ([0, 1, 2; 2, 2, 3], [1, 2, 2])
error: cross: X and Y must have the same dimensions
error: called from
    cross at line 137 column 5
octave:70> cross ([0, 1, 2; 2, 2, 3], [1, 2, 2; 5, 5, 5])
ans =

  -2   2  -1
  -5   5   0


Regarding bit* functions, I also found another bug report regarding their
wrong behavior with negative inputs, (which should be invalid according to
their documented behavior). So these there functions need our attention for
multiple reasons.

About *dot* I don't have a string opinion, but I believe that it makes sense
to pair it with *cross* as far as Octave extended behavior is concerned.


    _______________________________________________________

Reply to this item at:

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

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

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaZIS5wAKCRCqLAuaBUf3
TvFXAP9zHF+rd3zsl3zZca+jmbyp/0j8B7owHYm7Ll/4NJuUrQEAjUnij2+QcA8y
IlNpvQXwDkRfaV+sOh4LxS+9FXrfkwY=
=eAiW
-----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.