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

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

[Octave-bug-tracker] [bug #46672] magic (N) should not error for any int


From: Bernardo Sulzbach
Subject: [Octave-bug-tracker] [bug #46672] magic (N) should not error for any integer input values
Date: Sat, 12 Dec 2015 15:03:24 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/47.0.2526.73 Chrome/47.0.2526.73 Safari/537.36

URL:
  <http://savannah.gnu.org/bugs/?46672>

                 Summary: magic (N) should not error for any integer input
values
                 Project: GNU Octave
            Submitted by: mafagafogigante
            Submitted on: Sat 12 Dec 2015 01:03:23 PM BRST
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Matlab Compatibility
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: Any

    _______________________________________________________

Details:

MATLAB behavior:

 magic(-1) = []
 magic(0) = []
 magic(1) = 1
 magic(2) = [1 3; 4 2]
 magic(3) = [8 1 6; 3 5 7; 4 9 2]
 magic(4) = [16 2 3 13; 5 11 10 8; 9 7 6 12; 4 14 15 1]


Octave old behavior:

 magic(-1) // errors
 magic(0) // errors
 magic(1) = 1 // ==
 magic(2) // errors
 magic(3) = [8 1 6; 3 5 7; 4 9 2] // ==
 magic(4) = [16 2 3 13; 5 11 10 8; 9 7 6 12; 4 14 15 1] // ==


Octave behavior after this patch

 magic(-1) = [] // ==
 magic(0) = [] // ==
 magic(1) = 1 // ==
 magic(2) = [4 3; 1 2] // As in MATLAB, not a magic square (there is not one
for n == 2).
                       // But this one is slightly different from MATLAB's.
                       // This is because we some things here are done
differently,
                       // but it is a minor issue that I considered not worthy
of
                       // further investigation.
 magic(3) = [8 1 6; 3 5 7; 4 9 2] // ==
 magic(4) = [16 2 3 13; 5 11 10 8; 9 7 6 12; 4 14 15 1] // ==


Old documentation note: Note: N must be greater than 2 for the magic square to
exist.

New documentation note: Note: N must be a scalar greater than or equal to 3. 
If you supply N less than 3, magic returns either a nonmagic square, or else
the degenerate magic squares 1 and [].

The new docs reflect MATLAB documentation and perfectly describe the new
behavior of magic(N) for these "odd" values of N.

The tests provided in magic.m pass with my patch.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?46672>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

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