# reshape() Function & Examples

Use the reshape() matrix function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## reshape

#### reshape(x, sizes)

Try it yourself:

```calculio
reshape([1, 2, 3, 4, 5, 6], [2, 3])
reshape([[1, 2], [3, 4]], [1, 4])
reshape([[1, 2], [3, 4]], [4])
reshape([1, 2, 3, 4], [-1, 2])
```

[size](https://calcul.io/function/size/index.md)

[squeeze](https://calcul.io/function/squeeze/index.md)

[resize](https://calcul.io/function/resize/index.md)

---

## reshape(): Changing Array Dimensions

**reshape()** changes an array or matrix’s dimensions without changing its total number of entries. It is useful for preparing data for a matrix operation or converting between flat and grid-like layouts.

## Preserve element count

The requested dimensions must contain exactly the same number of values as the input. Check sizes with [size()](https://calcul.io/function/size/index.md) before reshaping. reshape does not transpose data; use [transpose()](https://calcul.io/function/transpose/index.md) when rows and columns should swap.

Be explicit about ordering, especially when exchanging data with other systems. Use [flatten()](https://calcul.io/function/flatten/index.md) to make a one-dimensional view, and [resize()](https://calcul.io/function/resize/index.md) only when adding or removing entries is intended.

[All functions](https://calcul.io/functions/index.md)
