Tensor Dimension

Tensor Dimension

A tensor's dimension refers to the number of indices required to uniquely specify an element within the tensor. Mathematically, it can be expressed as:

Formal Definition:

For a tensor T, its dimension n is the number of independent indices (i1,i2,...,in)(i₁, i₂, ..., iₙ) needed to specify any component Ti1i2...inTᵢ₁ᵢ₂...ᵢₙ

Mathematical Examples:

  • Scalar (0D): aa

  • Vector (1D): aia_i

  • Matrix (2D): aija_{ij}

  • 3D Tensor: aijka_{ijk}

Real Mathematical Examples:

  • CopyScalar: 5

  • Vector: v=[2,3,4]v = [2, 3, 4]

  • Matrix: M=[1234]\mathbf{M} = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}

  • 3D Tensor: T=[[1234],[5678]]\mathbf{T} = \begin{bmatrix} \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}, \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} \end{bmatrix}

Classification by Dimension

a. Scalar (0-dimension)

  • Definition: No indices needed

  • Notation: ss or s0s₀

  • Examples:

    • Temperature: 25°C

    • Mass: 5 kg

    • Potential: V=10VV = 10V

b. Vector (1-dimension)

  • Definition: One index needed

  • Notation: vivᵢ or v[i]v[i]

  • Examples:

    • Position vector: r=[x,y,z]r = [x, y, z]

    • Force vector: F=[Fx,Fy,Fz]F = [Fx, Fy, Fz]

    • Momentum: p=[px,py,pz]p = [px, py, pz]

c. Matrix (2-dimension)

  • Definition: Two indices needed

  • Notation: MijMᵢⱼ or M[i,j]M[i,j]

  • Examples: Stress tensor: σij=[σxxσxyσxzσyxσyyσyzσzxσzyσzz]\sigma_{ij} = \begin{bmatrix} \sigma_{xx} & \sigma_{xy} & \sigma_{xz} \\ \sigma_{yx} & \sigma_{yy} & \sigma_{yz} \\ \sigma_{zx} & \sigma_{zy} & \sigma_{zz} \end{bmatrix} Inertia tensor: Iij=[IxxIxyIxzIyxIyyIyzIzxIzyIzz]I_{ij} = \begin{bmatrix} I_{xx} & I_{xy} & I_{xz} \\ I_{yx} & I_{yy} & I_{yz} \\ I_{zx} & I_{zy} & I_{zz} \end{bmatrix}

d. 3-Dimensional Tensor

  • Definition: Three indices needed

  • Notation: TijkTᵢⱼₖ or T[i,j,k]T[i,j,k]

  • Examples:

    • Piezoelectric tensor: djkd_{ᵢⱼₖ}

    • Elastic stiffness tensor: CjklC_{ᵢⱼₖₗ}

Mathematical Properties Based on Dimension

a. Transformation Rules

For a tensor TT of dimension nn, under coordinate transformation RR:

Ti1i2in=Ri1j1Ri2j2RinjnTj1j2jnT{\prime}{i_1 i_2 \ldots i_n} = R{i_1 j_1} R_{i_2 j_2} \ldots R_{i_n j_n} T_{j_1 j_2 \ldots j_n}

b. Components Count

For a tensor in n-dimensional space:

  • 0D (Scalar): 11 component

  • 1D (Vector): nn components

  • 2D (Matrix): n2 components

  • 3D Tensor: n3 components

Mathematical Operations by Dimension

a. Inner Products

  • Vectors (1D): ab=iaibi\mathbf{a} \cdot \mathbf{b} = \sum_{i} a_i b_i

  • Matrices (2D): A:B=i,jAijBij\mathbf{A} : \mathbf{B} = \sum_{i,j} A_{ij} B_{ij}

  • 3D Tensors: T1T2=i,j,kT1ijkT2ijkT_1 \cdot T_2 = \sum_{i,j,k} T_{1_{ijk}} T_{2_{ijk}}

b. Outer Products

  • Vectors to Matrix: (ab)ij=aibj(a \otimes b)_{ij} = a_i b_j

  • Matrices to 4D Tensor: (AB)ijkl=AijBkl(A \otimes B){ijkl} = A{ij} B_{kl}

Implementation with PHP

Tensor Dimensions
<?php

// 0-dimensional tensor (Scalar)
$scalar = 5;

// 1-dimensional tensor (Vector)
$vector = [1, 2, 3];

// 2-dimensional tensor (Matrix)
$matrix = [
    [1, 2, 3],
    [4, 5, 6]
];

// 3-dimensional tensor
$tensor_3d = [
    [[1, 2], [3, 4]],
    [[5, 6], [7, 8]]
];

// Function to determine dimension
function getTensorDimension($tensor) {
    if (!is_array($tensor)) {
        return 0;  // Scalar
    }
    
    $dim = 1;
    $current = $tensor;
    
    while (is_array(current($current))) {
        $dim++;
        $current = current($current);
    }
    
    return $dim;
}

// Examples
echo "Scalar dimension: " . getTensorDimension($scalar) . "\n";  // 0
echo "Vector dimension: " . getTensorDimension($vector) . "\n";  // 1
echo "Matrix dimension: " . getTensorDimension($matrix) . "\n";  // 2
echo "3D Tensor dimension: " . getTensorDimension($tensor_3d) . "\n";  // 3

Last updated