# allsubhypercubes: Subhypercubes of magic hypercubes In magic: Create and Investigate Magic Squares

## Description

Extracts all subhypercubes from an n-dimensional hypercube.

## Usage

 `1` ```allsubhypercubes(a) ```

## Arguments

 `a` The magic hypercube whose subhypercubes are computed

## Value

Returns a list, each element of which is a subhypercube of `a`. Note that major diagonals are also returned (as n-by-1 arrays).

The names of the list are the extracted subhypercubes. Consider `a <- magichypercube.4n(1,d=4)` (so n=4) and if ```jj <- allsubhypercubes(a)```, consider `jj`. The name of `jj` is `"n-i+1,i,i,"`; its value is a square matrix. The columns of `jj` may be recovered by `a[n-i+1,i,i,]` with i=1...n (NB: that is, jj[] == ```cbind(a[n-1+1,1,1,], a[n-2+1,2,2,], a[n-3+1,3,3,], a[n-4+1,4,4,])``` where `n=4`).

The list does not include the whole array.

## Note

This function is a dog's dinner. It's complicated, convoluted, and needs an absurd use of the `eval(parse(text=...))` construction. Basically it sucks big time.

BUT... I cannot for the life of me see a better way that gives the same results, without loops, on hypercubes of arbitrary dimension.

On my 256MB Linuxbox, `allsubhypercubes()` cannot cope with `d` as high as 5, for `n=4`. Heigh ho.

The term “subhypercube” does not include diagonally oriented entities at `is.magichypercube`. But it does here.

## Author(s)

Robin K. S. Hankin

## See Also

`is.perfect`

## Examples

 ```1 2``` ``` a <- magichypercube.4n(1,d=4) allsubhypercubes(a) ```

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