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() before reshaping. reshape does not transpose data; use transpose() when rows and columns should swap.
Be explicit about ordering, especially when exchanging data with other systems. Use flatten() to make a one-dimensional view, and resize() only when adding or removing entries is intended.