magic.product: Product of two magic squares

Description Usage Arguments Details Author(s) References Examples

Description

Gives a magic square that is a product of two magic squares.

Usage

1
2

Arguments

a

First magic square; if a is an integer, use magic(a).

b

as above

mat

Matrix, of same size as a, of integers treated as modulo 8. Default value of NULL equivalent to passing a*0. Each number from 0-7 corresponds to one of the 8 squares which have the same Frenicle's standard form, as generated by transf(). Then subsquares of the product square (ie tiles of the same size as b) are rotated and transposed appropriately according to their corresponding entry in mat. This is a lot easier to see than to describe (see examples section).

Details

Function magic.product.fast() does not take a mat argument, and is equivalent to magic.product() with mat taking the default value of NULL. The improvement in speed is doubtful unless order(a)>>order(b), in which case there appears to be a substantial saving.

Author(s)

Robin K. S. Hankin

References

William H. Benson and Oswald Jacoby. New recreations with magic squares, Dover 1976 (and that paper in JRM)

Examples

1
2
3
4
5
6
7
8
9
magic.product(magic(3),magic(4))
magic.product(3,4)

mat <- matrix(0,3,3)
a <- magic.product(3,4,mat=mat)
mat[1,1] <- 1
b <- magic.product(3,4,mat=mat)

a==b

Example output

Loading required package: abind
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
 [1,]   17   28   24   29   97  108  104  109   81    92    88    93
 [2,]   31   22   26   19  111  102  106   99   95    86    90    83
 [3,]   30   23   27   18  110  103  107   98   94    87    91    82
 [4,]   20   25   21   32  100  105  101  112   84    89    85    96
 [5,]  129  140  136  141   65   76   72   77    1    12     8    13
 [6,]  143  134  138  131   79   70   74   67   15     6    10     3
 [7,]  142  135  139  130   78   71   75   66   14     7    11     2
 [8,]  132  137  133  144   68   73   69   80    4     9     5    16
 [9,]   49   60   56   61   33   44   40   45  113   124   120   125
[10,]   63   54   58   51   47   38   42   35  127   118   122   115
[11,]   62   55   59   50   46   39   43   34  126   119   123   114
[12,]   52   57   53   64   36   41   37   48  116   121   117   128
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
 [1,]   17   28   24   29   97  108  104  109   81    92    88    93
 [2,]   31   22   26   19  111  102  106   99   95    86    90    83
 [3,]   30   23   27   18  110  103  107   98   94    87    91    82
 [4,]   20   25   21   32  100  105  101  112   84    89    85    96
 [5,]  129  140  136  141   65   76   72   77    1    12     8    13
 [6,]  143  134  138  131   79   70   74   67   15     6    10     3
 [7,]  142  135  139  130   78   71   75   66   14     7    11     2
 [8,]  132  137  133  144   68   73   69   80    4     9     5    16
 [9,]   49   60   56   61   33   44   40   45  113   124   120   125
[10,]   63   54   58   51   47   38   42   35  127   118   122   115
[11,]   62   55   59   50   46   39   43   34  126   119   123   114
[12,]   52   57   53   64   36   41   37   48  116   121   117   128
       [,1]  [,2]  [,3]  [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12]
 [1,]  TRUE FALSE FALSE FALSE TRUE TRUE TRUE TRUE TRUE  TRUE  TRUE  TRUE
 [2,] FALSE  TRUE FALSE FALSE TRUE TRUE TRUE TRUE TRUE  TRUE  TRUE  TRUE
 [3,] FALSE FALSE  TRUE FALSE TRUE TRUE TRUE TRUE TRUE  TRUE  TRUE  TRUE
 [4,] FALSE FALSE FALSE  TRUE TRUE TRUE TRUE TRUE TRUE  TRUE  TRUE  TRUE
 [5,]  TRUE  TRUE  TRUE  TRUE TRUE TRUE TRUE TRUE TRUE  TRUE  TRUE  TRUE
 [6,]  TRUE  TRUE  TRUE  TRUE TRUE TRUE TRUE TRUE TRUE  TRUE  TRUE  TRUE
 [7,]  TRUE  TRUE  TRUE  TRUE TRUE TRUE TRUE TRUE TRUE  TRUE  TRUE  TRUE
 [8,]  TRUE  TRUE  TRUE  TRUE TRUE TRUE TRUE TRUE TRUE  TRUE  TRUE  TRUE
 [9,]  TRUE  TRUE  TRUE  TRUE TRUE TRUE TRUE TRUE TRUE  TRUE  TRUE  TRUE
[10,]  TRUE  TRUE  TRUE  TRUE TRUE TRUE TRUE TRUE TRUE  TRUE  TRUE  TRUE
[11,]  TRUE  TRUE  TRUE  TRUE TRUE TRUE TRUE TRUE TRUE  TRUE  TRUE  TRUE
[12,]  TRUE  TRUE  TRUE  TRUE TRUE TRUE TRUE TRUE TRUE  TRUE  TRUE  TRUE

magic documentation built on May 2, 2019, 12:21 p.m.