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:
For a tensor T, its dimension n is the number of independent indices ( i 1 , i 2 , . . . , i n ) (i₁, i₂, ..., iₙ) ( i 1 , i 2 , ... , i n ) needed to specify any component T i 1 i 2 . . . i n Tᵢ₁ᵢ₂...ᵢₙ T i 1 i 2 .. . in
Mathematical Examples:
Matrix (2D): a i j a_{ij} a ij
3D Tensor: a i j k a_{ijk} a ijk
Real Mathematical Examples:
Vector: v = [ 2 , 3 , 4 ] v = [2, 3, 4] v = [ 2 , 3 , 4 ]
Matrix:
M = [ 1 2 3 4 ] \mathbf{M} = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} M = [ 1 3 2 4 ]
3D Tensor:
T = [ [ 1 2 3 4 ] , [ 5 6 7 8 ] ] \mathbf{T} = \begin{bmatrix} \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}, \begin{bmatrix} 5 & 6 \\ 7 & 8 \end{bmatrix} \end{bmatrix} T = [ [ 1 3 2 4 ] , [ 5 7 6 8 ] ]
Classification by Dimension
a. Scalar (0-dimension)
Definition : No indices needed
Examples :
Potential: V = 10 V V = 10V V = 10 V
b. Vector (1-dimension)
Definition : One index needed
Notation : v i vᵢ v i or v [ i ] v[i] v [ i ]
Examples :
Position vector: r = [ x , y , z ] r = [x, y, z] r = [ x , y , z ]
Force vector: F = [ F x , F y , F z ] F = [Fx, Fy, Fz] F = [ F x , F y , F z ]
Momentum: p = [ p x , p y , p z ] p = [px, py, pz] p = [ p x , p y , p z ]
c. Matrix (2-dimension)
Definition : Two indices needed
Notation : M i j Mᵢⱼ M ij or M [ i , j ] M[i,j] M [ i , j ]
Examples :
Stress tensor:
σ i j = [ σ x x σ x y σ x z σ y x σ y y σ y z σ z x σ z y σ z z ] \sigma_{ij} = \begin{bmatrix} \sigma_{xx} & \sigma_{xy} & \sigma_{xz} \\ \sigma_{yx} & \sigma_{yy} & \sigma_{yz} \\ \sigma_{zx} & \sigma_{zy} & \sigma_{zz} \end{bmatrix} σ ij = σ xx σ y x σ z x σ x y σ yy σ zy σ x z σ yz σ zz
Inertia tensor:
I i j = [ I x x I x y I x z I y x I y y I y z I z x I z y I z z ] I_{ij} = \begin{bmatrix} I_{xx} & I_{xy} & I_{xz} \\ I_{yx} & I_{yy} & I_{yz} \\ I_{zx} & I_{zy} & I_{zz} \end{bmatrix} I ij = I xx I y x I z x I x y I yy I zy I x z I yz I zz
d. 3-Dimensional Tensor
Definition : Three indices needed
Notation : T i j k Tᵢⱼₖ T ijk or T [ i , j , k ] T[i,j,k] T [ i , j , k ]
Examples :
Piezoelectric tensor: d ᵢ j k d_{ᵢⱼₖ} d ᵢ jk
Elastic stiffness tensor: C ᵢ j k l C_{ᵢⱼₖₗ} C ᵢ jk l
Mathematical Properties Based on Dimension
a. Transformation Rules
For a tensor T T T of dimension n n n , under coordinate transformation R R R :
T ′ i 1 i 2 … i n = R i 1 j 1 R i 2 j 2 … R i n j n T j 1 j 2 … j n T{\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} T ′ i 1 i 2 … i n = R i 1 j 1 R i 2 j 2 … R i n j n T j 1 j 2 … j n
b. Components Count
For a tensor in n-dimensional space:
0D (Scalar): 1 1 1 component
1D (Vector): n n n components
2D (Matrix): n 2 n² n 2 components
3D Tensor: n 3 n³ n 3 components
Mathematical Operations by Dimension
a. Inner Products
Vectors (1D): a ⋅ b = ∑ i a i b i \mathbf{a} \cdot \mathbf{b} = \sum_{i} a_i b_i a ⋅ b = ∑ i a i b i
Matrices (2D): A : B = ∑ i , j A i j B i j \mathbf{A} : \mathbf{B} = \sum_{i,j} A_{ij} B_{ij} A : B = ∑ i , j A ij B ij
3D Tensors: T 1 ⋅ T 2 = ∑ i , j , k T 1 i j k T 2 i j k T_1 \cdot T_2 = \sum_{i,j,k} T_{1_{ijk}} T_{2_{ijk}} T 1 ⋅ T 2 = ∑ i , j , k T 1 ijk T 2 ijk
b. Outer Products
Vectors to Matrix: ( a ⊗ b ) i j = a i b j (a \otimes b)_{ij} = a_i b_j ( a ⊗ b ) ij = a i b j
Matrices to 4D Tensor: ( A ⊗ B ) i j k l = A i j B k l (A \otimes B){ijkl} = A{ij} B_{kl} ( A ⊗ B ) ijk l = A ij B k l
Implementation with PHP
Tensor Dimensions
Copy <?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