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

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

[Octave-bug-tracker] [bug #60086] Matrix exponentiation fails for empty


From: Rik
Subject: [Octave-bug-tracker] [bug #60086] Matrix exponentiation fails for empty matrix
Date: Mon, 22 Feb 2021 12:51:06 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36

Follow-up Comment #3, bug #60086 (project octave):

This seems pretty easy to fix.  The code for powers of a matrix is in
libinterp/corefcn/xpow.cc.  There are many different cases, but the input
validation all looks like this:


  octave_value retval;

  octave_idx_type nr = a.rows ();
  octave_idx_type nc = a.cols ();

  if (nr == 0 || nc == 0 || nr != nc)
    err_nonsquare_matrix ();



It would be easy enough to check for an empty matrix (nr == 0 || nc == 0) and
immediately return an empty matrix.

Do we want to be fully Matlab compatible with respect to matrix dimensions? 
Matlab issues an error when the matrix is empty, but not square.  For
example,


zeros (0,2) ^ 2


I don't see the reasoning for that.  If the matrix is empty, then raising it
to a power is still always going to be an empty matrix.  We should decide on
this question before implementing a solution.  

    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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