Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are some interesting/practical uses for arrays with three or more dimensions?

When using arrays I generally use only a one or two dimensional array -- very rarely three or more. I'm just kind of curious, what are some interesting/practical uses for arrays with three or more dimensions? Have you ever used an array with four or more dimensions? I had a professor in college use a six dimensional array in a program he demonstrated in class...ever had more than this?

like image 579
Dustin Martin Avatar asked Feb 09 '11 14:02

Dustin Martin


1 Answers

In scientific programming it can be quite common. We just start calling these higher dimensional arrays tensors. Scalars are 0-dimensional tensors, vectors are 1-dimensional tensors, matrices are 2-dimensional tensors, and after that we just call them d-dimensional tensors (d=3,4,5,6). Dot products are then called contractions over indices.

Where are they used? I use them in some of my physics simulations. For instance, one method for simulating electrons on a lattice (regular array of sites) uses a tensor with a different set of indices for each connection to a neighboring site. In a 2D square lattice (think sites in the center of each space on a chess board), that means that each tensor has four indices, one for each neighboring site, so it is a 4-dimensional tensor.

like image 119
Justin Peel Avatar answered Sep 22 '22 15:09

Justin Peel