# Shift origin of arrays and vectors

### Description

Shift origin of arrays and vectors.

### Usage

1 2 |

### Arguments

`x` |
Vector to be shifted |

`i` |
Number of places elements to be shifted, with default value of 1 meaning to put the last element first, followed by the first element, then the second, etc |

`a` |
Array to be shifted |

`v` |
Vector of numbers to be shifted in each dimension, with
default value corresponding to |

### Details

Function `shift(x,n)`

returns *P^n(x)* where *P* is the
permutation *(n,1,2,...,n-1)*.

Function `ashift`

is the array generalization of this: the
*n-th* dimension is shifted by `v[n]`

. In other
words,
`ashift(a,v)=a[shift(1:(dim(a)[1]),v[1]),...,shift(1:(dim(a)[n]),v[n])]`

.
It is named by analogy with `abind()`

and `aperm()`

.

This function is here because a shifted semimagic square or hypercube is semimagic and a shifted pandiagonal square or hypercube is pandiagonal (note that a shifted magic square is not necessarily magic, and a shifted perfect hypercube is not necessarily perfect).

### Author(s)

Robin K. S. Hankin

### Examples

1 2 3 4 5 |