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

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

[Octave-bug-tracker] [bug #60797] sqrtm: returns nan for matrix of ones


From: Markus Mützel
Subject: [Octave-bug-tracker] [bug #60797] sqrtm: returns nan for matrix of ones with rows and columns >=4
Date: Mon, 6 Dec 2021 13:17:10 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36 Edg/96.0.1054.43

Follow-up Comment #5, bug #60797 (project octave):

Installed the version from octave.space here.
It fails like this:

>> sqrtm(ones(4))
warning: sqrtm: matrix is singular, may not have a square root
ans =

   0.500000   0.500000   0.024457   0.975543
   0.500000   0.500000   0.658514   0.341486
   0.500000   0.500000   0.658514   0.341486
   0.500000   0.500000   0.658514   0.341486


Seems to be a pretty good solution though:

>> ans^2
ans =

   1   1   1   1
   1   1   1   1
   1   1   1   1
   1   1   1   1


The 64-bit version calculates the expected solution:

>> sqrtm(ones(4))
warning: sqrtm: matrix is singular, may not have a square root
ans =

   0.5000 + 0.0000i   0.5000 - 0.0000i   0.5000 - 0.0000i   0.5000 - 0.0000i
   0.5000 - 0.0000i   0.5000 + 0.0000i   0.5000 + 0.0000i   0.5000 + 0.0000i
   0.5000 - 0.0000i   0.5000 + 0.0000i   0.5000 + 0.0000i   0.5000 + 0.0000i
   0.5000 - 0.0000i   0.5000 + 0.0000i   0.5000 + 0.0000i   0.5000 + 0.0000i


Do we expect that this function returns the same value on all platforms for
this test?
Or should we just change the test to something like:

 assert (sqrtm (ones (4))^2, ones (4), 4*eps)



    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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