<< makematrix_invhilbert Makematrix makematrix_moler >>

Makematrix >> Makematrix > makematrix_magic

makematrix_magic

Returns the magic matrix

Calling Sequence

A = makematrix_magic ( n )

Parameters

n :

a 1-by-1 matrix of doubles, integer value, the size of the matrix to return

A :

a n-by-n matrix of doubles, integer values

Description

Returns the magic matrix of size n. The sum over the rows or the sum over the columns is always the same. This is a port of Scilab's magic.f

The algorithm is different if n is a multiple of 4, an even or odd number.

Examples

A = makematrix_magic ( 5 )
// Check that it is "magic"
sum(A,"r")
sum(A,"c")

A = makematrix_magic ( 4 )

Authors

Bibliography

"Mathematical recreations and essays", 12th ed., by w. w. Rouse Ball and h. s. m. Coxeter


Report an issue
<< makematrix_invhilbert Makematrix makematrix_moler >>