From 6121ccdea108c3f0bb50009f44c81561aa71530a Mon Sep 17 00:00:00 2001 From: "Per.Andreas.Brodtkorb" Date: Mon, 18 Feb 2013 12:20:22 +0000 Subject: [PATCH] Added magic.py --- pywafo/src/wafo/magic.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 pywafo/src/wafo/magic.py diff --git a/pywafo/src/wafo/magic.py b/pywafo/src/wafo/magic.py new file mode 100644 index 0000000..2f2a1f2 --- /dev/null +++ b/pywafo/src/wafo/magic.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +""" +Created on Tue Apr 17 13:59:12 2012 + +@author: pab +""" +import numpy as np + +def magic(n): + ix = np.arange(n)+1 + J, I = np.meshgrid(ix,ix) + A = np.mod(I+J-(n+3)/2,n) + B = np.mod(I+2*J-2,n) + M = n*A + B + 1 + return M \ No newline at end of file