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

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

[Octave-bug-tracker] [bug #57794] cart2sph output size is incompatible w


From: Nicholas Jankowski
Subject: [Octave-bug-tracker] [bug #57794] cart2sph output size is incompatible with matlab depending number of outputs
Date: Tue, 11 Feb 2020 15:11:58 -0500 (EST)
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36

URL:
  <https://savannah.gnu.org/bugs/?57794>

                 Summary: cart2sph output size is incompatible with matlab
depending number of outputs
                 Project: GNU Octave
            Submitted by: nrjank
            Submitted on: Tue 11 Feb 2020 08:11:56 PM UTC
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: Nicholas Jankowski
        Originator Email: 
             Open/Closed: Open
                 Release: 5.1.0
         Discussion Lock: Any
        Operating System: Any

    _______________________________________________________

Details:

the standard form for calling cart2sph [1] is 

 [theta, phi, r] = cart2sph (x, y, z)

If called this way, Octave's output is Matlab compatible.  Similarly, if
called with only two outputs, both programs will output only theta and phi. 
however, if either zero or one output is specified, the behavior is
incompatible:

Octave 5.1.0:

>> [a,b,c] = cart2sph(1,2,3)
a =  1.1071
b =  0.93027
c =  3.7417

>> [a,b] = cart2sph(1,2,3)
a =  1.1071
b =  0.93027

>> a = cart2sph(1,2,3)
a =

   1.10715   0.93027   3.74166

>> cart2sph(1,2,3)
ans =

   1.10715   0.93027   3.74166


Matlab 2019a:

>> [a,b,c] = cart2sph(1,2,3)
a =
    1.1071
b =
    0.9303
c =
    3.7417
>> [a,b] = cart2sph(1,2,3)
a =
    1.1071
b =
    0.9303
>> a = cart2sph(1,2,3)
a =
    1.1071
>> cart2sph(1,2,3)
ans =
    1.1071


Whether or not this incompatibility is deliberate, it could cause mismatch
errors for anyone trying to run code on both systems.

Second, the Octave behavior does not match the help text, which specifies
that:

"If only a single return argument is requested then return a matrix S where
each row represents one spherical coordinate (theta, phi, r)."

The output appears to be a single row with each column representing one
spherical coordinate. 


Finally, Octave allows an input form that Matlab does not, where the input is
a single 3 element array where "each row of C represents the Cartesian
coordinate (x, y, z)".  However:


>> [a,b,c] = cart2sph([1,2,3])
a =  1.1071
b =  0.93027
c =  3.7417

>> [a,b,c] = cart2sph([1;2;3])
error: cart2sph: matrix input must have 3 columns [X, Y, Z]
error: called from
    cart2sph at line 52 column 7


Again, it appears that the row/column behavior is reversed from the text. 

I would suggest the output behavior be made matlab compatible (only returning
the first value), and a row or column determination be made for the input. Or,
better, I see no reason the function should not accept both a row or column
array, so long that input element order is preserved.

(there was also recently some concern [2] that the help text could be more
explicit in using the terms elevation and azimuth, since there are a number of
conventions for using the variables theta and phi)

[1] https://octave.sourceforge.io/octave/function/cart2sph.html
[2]
https://octave.1599824.n4.nabble.com/use-of-cart2sph-not-in-line-with-manual-tp4695664.html




    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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