# magichypercube.4n: Magic hypercubes of order 4n In magic: Create and Investigate Magic Squares

## Description

Returns magic hypercubes of order 4n and any dimension.

## Usage

 `1` ```magichypercube.4n(m, d = 3) ```

## Arguments

 `m` Magic hypercube produced of order n=4m `d` Dimensionality of cube

## Details

Uses a rather kludgy (but vectorized) method. I am not 100% sure that the method does in fact produce magic squares for all orders and dimensions.

## Author(s)

Robin K. S. Hankin

## Examples

 ```1 2``` ```magichypercube.4n(1,d=4) magichypercube.4n(2,d=3) ```

### Example output

```Loading required package: abind
, , 1, 1

[,1] [,2] [,3] [,4]
[1,]    1  252  248   13
[2,]  255    6   10  243
[3,]  254    7   11  242
[4,]    4  249  245   16

, , 2, 1

[,1] [,2] [,3] [,4]
[1,]  240   21   25  228
[2,]   18  235  231   30
[3,]   19  234  230   31
[4,]  237   24   28  225

, , 3, 1

[,1] [,2] [,3] [,4]
[1,]  224   37   41  212
[2,]   34  219  215   46
[3,]   35  218  214   47
[4,]  221   40   44  209

, , 4, 1

[,1] [,2] [,3] [,4]
[1,]   49  204  200   61
[2,]  207   54   58  195
[3,]  206   55   59  194
[4,]   52  201  197   64

, , 1, 2

[,1] [,2] [,3] [,4]
[1,]  192   69   73  180
[2,]   66  187  183   78
[3,]   67  186  182   79
[4,]  189   72   76  177

, , 2, 2

[,1] [,2] [,3] [,4]
[1,]   81  172  168   93
[2,]  175   86   90  163
[3,]  174   87   91  162
[4,]   84  169  165   96

, , 3, 2

[,1] [,2] [,3] [,4]
[1,]   97  156  152  109
[2,]  159  102  106  147
[3,]  158  103  107  146
[4,]  100  153  149  112

, , 4, 2

[,1] [,2] [,3] [,4]
[1,]  144  117  121  132
[2,]  114  139  135  126
[3,]  115  138  134  127
[4,]  141  120  124  129

, , 1, 3

[,1] [,2] [,3] [,4]
[1,]  128  133  137  116
[2,]  130  123  119  142
[3,]  131  122  118  143
[4,]  125  136  140  113

, , 2, 3

[,1] [,2] [,3] [,4]
[1,]  145  108  104  157
[2,]  111  150  154   99
[3,]  110  151  155   98
[4,]  148  105  101  160

, , 3, 3

[,1] [,2] [,3] [,4]
[1,]  161   92   88  173
[2,]   95  166  170   83
[3,]   94  167  171   82
[4,]  164   89   85  176

, , 4, 3

[,1] [,2] [,3] [,4]
[1,]   80  181  185   68
[2,]  178   75   71  190
[3,]  179   74   70  191
[4,]   77  184  188   65

, , 1, 4

[,1] [,2] [,3] [,4]
[1,]  193   60   56  205
[2,]   63  198  202   51
[3,]   62  199  203   50
[4,]  196   57   53  208

, , 2, 4

[,1] [,2] [,3] [,4]
[1,]   48  213  217   36
[2,]  210   43   39  222
[3,]  211   42   38  223
[4,]   45  216  220   33

, , 3, 4

[,1] [,2] [,3] [,4]
[1,]   32  229  233   20
[2,]  226   27   23  238
[3,]  227   26   22  239
[4,]   29  232  236   17

, , 4, 4

[,1] [,2] [,3] [,4]
[1,]  241   12    8  253
[2,]   15  246  250    3
[3,]   14  247  251    2
[4,]  244    9    5  256

, , 1

[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]  512    9   17  488  480   41   49  456
[2,]    2  503  495   26   34  471  463   58
[3,]    3  502  494   27   35  470  462   59
[4,]  509   12   20  485  477   44   52  453
[5,]  508   13   21  484  476   45   53  452
[6,]    6  499  491   30   38  467  459   62
[7,]    7  498  490   31   39  466  458   63
[8,]  505   16   24  481  473   48   56  449

, , 2

[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]   65  440  432   89   97  408  400  121
[2,]  447   74   82  423  415  106  114  391
[3,]  446   75   83  422  414  107  115  390
[4,]   68  437  429   92  100  405  397  124
[5,]   69  436  428   93  101  404  396  125
[6,]  443   78   86  419  411  110  118  387
[7,]  442   79   87  418  410  111  119  386
[8,]   72  433  425   96  104  401  393  128

, , 3

[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]  129  376  368  153  161  344  336  185
[2,]  383  138  146  359  351  170  178  327
[3,]  382  139  147  358  350  171  179  326
[4,]  132  373  365  156  164  341  333  188
[5,]  133  372  364  157  165  340  332  189
[6,]  379  142  150  355  347  174  182  323
[7,]  378  143  151  354  346  175  183  322
[8,]  136  369  361  160  168  337  329  192

, , 4

[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]  320  201  209  296  288  233  241  264
[2,]  194  311  303  218  226  279  271  250
[3,]  195  310  302  219  227  278  270  251
[4,]  317  204  212  293  285  236  244  261
[5,]  316  205  213  292  284  237  245  260
[6,]  198  307  299  222  230  275  267  254
[7,]  199  306  298  223  231  274  266  255
[8,]  313  208  216  289  281  240  248  257

, , 5

[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]  256  265  273  232  224  297  305  200
[2,]  258  247  239  282  290  215  207  314
[3,]  259  246  238  283  291  214  206  315
[4,]  253  268  276  229  221  300  308  197
[5,]  252  269  277  228  220  301  309  196
[6,]  262  243  235  286  294  211  203  318
[7,]  263  242  234  287  295  210  202  319
[8,]  249  272  280  225  217  304  312  193

, , 6

[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]  321  184  176  345  353  152  144  377
[2,]  191  330  338  167  159  362  370  135
[3,]  190  331  339  166  158  363  371  134
[4,]  324  181  173  348  356  149  141  380
[5,]  325  180  172  349  357  148  140  381
[6,]  187  334  342  163  155  366  374  131
[7,]  186  335  343  162  154  367  375  130
[8,]  328  177  169  352  360  145  137  384

, , 7

[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]  385  120  112  409  417   88   80  441
[2,]  127  394  402  103   95  426  434   71
[3,]  126  395  403  102   94  427  435   70
[4,]  388  117  109  412  420   85   77  444
[5,]  389  116  108  413  421   84   76  445
[6,]  123  398  406   99   91  430  438   67
[7,]  122  399  407   98   90  431  439   66
[8,]  392  113  105  416  424   81   73  448

, , 8

[,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8]
[1,]   64  457  465   40   32  489  497    8
[2,]  450   55   47  474  482   23   15  506
[3,]  451   54   46  475  483   22   14  507
[4,]   61  460  468   37   29  492  500    5
[5,]   60  461  469   36   28  493  501    4
[6,]  454   51   43  478  486   19   11  510
[7,]  455   50   42  479  487   18   10  511
[8,]   57  464  472   33   25  496  504    1
```

magic documentation built on Feb. 9, 2022, 1:07 a.m.