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

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

[Octave-bug-tracker] [bug #51333] Reductions on an empty matrix is incon


From: Sarrah Bastawala
Subject: [Octave-bug-tracker] [bug #51333] Reductions on an empty matrix is inconsistent
Date: Sun, 17 Apr 2022 10:34:48 -0400 (EDT)

Follow-up Comment #7, bug #51333 (project octave):


As I worked on bug #61690, to make functions sum, prod etc that use function
do_mx_red_op to perform reductions, and was able to succesfully make it
consistent with Matlab, I tried to work and see if a similar logic would work
to solve this as well.

Going through the comments, 

[comment #2 comment #2:]
> Yes, that's what I found as well. This means that if we would choose to go
with Matlabs version it is just a matter of adding a check for "dim < 0" in
the following if-statement.
> 
> For "dot"  we add, right after the definition of dimx and dimy

this unfortunately is not possible or understandable to me as this code
doesn't seem to exist in dot.cc file anymore. Instead, I worked on the
function get_red_dims , and was able to procure these results :


octave:1> dot([],[])
ans = [](0x0)
octave:2> dot([],[],1)
ans = [](0x0)
octave:3> dot([],[],2)
ans = [](0x1)


which although seem to have solved for empty matrices, shows slight
differences when dimensions are specified. This is because my code change
looks like :


  if(x(1)==0 && dim == 0){ printf("here"); z(0) = 0;}
  else{
  for (int i = 0; i < nd; i++)
    {
      if (i < dim)
        {
          z(i) = x(i);
          tmp_m *= x(i);
        }


and when dim is specified as 1 by the user, it is converted to 0 for index
conventions in vectors. 

The only reason I am doing this is to make it compatible with Matlab, which
seems to do this :


>> dot([],[])

ans =

     0

>> dot([],[],1)

ans =

  1×0 empty double row vector

>> dot([],[],2)

ans =

  0×1 empty double column vector


How exactly would we want to proceed? And if we want to make this reciprocate
Matlab behaviour, does anyone have an idea of how we could differenciate
between dot([],[]) and dot([],[],1), as dim=1 doesn't seem to work.


    _______________________________________________________

Reply to this item at:

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

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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