✦ For everyone, free.

Practical knowledge for real and everyday life

Home

1.5.1 Multidimensional Array Tensor Representation

Multidimensional Array Tensor Representation generalizes vectors and matrices, enabling efficient handling of complex data structures in mathematics and computing.

Multidimensional Array Tensor Representation is the concrete realization of a tensor's component data as a rectangular block of numbers indexed by several independent integer coordinates, one for each of the tensor's upper and lower indices, structured for direct storage, indexing, and manipulation in a computational setting. This representation strips away the basis-independence and transformation-law requirements central to the algebraic definition of a tensor and instead treats the tensor purely as raw indexed data, the form in which tensors are actually stored and processed by numerical software.


Structure of the Multidimensional Array

Shape and Axes

A multidimensional array representing a tensor of type (p, q) over an n-dimensional vector space has p + q axes, commonly called dimensions in a computational context, with each axis having length n. The ordered list of axis lengths is called the shape of the array.

shape = n1 , , np+q

with each entry of this list equal to n in the case of a tensor built uniformly over a single vector space, though computational libraries also permit arrays with different lengths along different axes, useful for representing more general multidimensional data beyond strict tensor algebra.

Indexing an Entry

An individual entry of the array is accessed by supplying one integer index per axis, matching the p + q indices of the corresponding tensor component; the entry at index tuple (i_1, ..., i_p, j_1, ..., j_q) corresponds exactly to the component T^{i_1...i_p}_{j_1...j_q}.


Memory Layout Conventions

Row-Major and Column-Major Ordering

Because computer memory is fundamentally linear, a multidimensional array must be laid out as a single sequential block of memory, using either row-major order, in which the last axis varies fastest, or column-major order, in which the first axis varies fastest. Both conventions represent the identical logical array; they differ only in how index tuples map to physical memory addresses.

Strides

The stride along a given axis is the number of memory positions to skip when incrementing the index along that axis by one, and the full set of strides for an array determines the exact memory address of any entry from its index tuple.

address = base + k=1 p+q stridek × indexk

What the Array Representation Omits

No Built-In Distinction Between Upper and Lower Indices

A raw multidimensional array does not, by itself, record which of its axes correspond to contravariant indices and which correspond to covariant indices; this distinction must be tracked separately, typically by convention or by an accompanying data structure, since the array's memory layout treats every axis identically regardless of its algebraic role.

No Built-In Transformation Law

Unlike the algebraically defined tensor, a raw array carries no automatic mechanism enforcing the transformation law that relates its entries in one basis to its entries in another; software that manipulates array-represented tensors must implement the appropriate contraction with change-of-basis matrices explicitly whenever a basis change is required, since the array alone does not encode this requirement.


Operations on the Array Representation

Elementwise Operations

Addition of two tensors and scalar multiplication of a tensor correspond directly to elementwise addition and elementwise scalar multiplication of the underlying arrays, operations that computational libraries implement efficiently by iterating over corresponding entries.

Contraction as Array Reduction

Contracting a tensor over a matched pair of indices corresponds to summing the array along the two axes associated with those indices wherever their index values coincide, an operation implemented in array-processing software as a specialized reduction, often accelerated using optimized routines originally developed for matrix multiplication.

Reshaping and Axis Permutation

Because the array representation is fundamentally a block of memory addressed by axis position, operations such as reordering the axes, called a permutation or transpose, or reinterpreting the same underlying data with a different shape, called a reshape, are purely structural manipulations of the indexing scheme rather than genuine algebraic operations on the tensor.


The Broader Computational Usage of the Term

Tensors in Computing Contexts

In numerical computing and machine learning, the term tensor is frequently used to refer simply to a multidimensional array, without necessarily requiring the transformation-law property that defines a tensor in the algebraic sense; such usage treats the array shape and its axes as the complete definition, appropriate for many computational tasks even though it departs from the stricter mathematical requirement of basis-independent, transformation-respecting behavior.


Diagrammatic Summary

Rank 3 array, shape (2, 2, 2) linear memory, row-major: T000 T001 T010 T011 T100 T101 T110 T111

The diagram shows a rank-three multidimensional array conceptually laid out as blocks addressed by three indices, alongside its underlying flattened memory representation, illustrating how the logical index structure of the tensor maps onto a linear sequence of stored values.