Index Notation Article Index for
Index
Website Links For
Notation
 

Information About

Index Notation




It is quite common in some mathematical proofs to refer to the elements of an array using subscripts, and in some cases superscripts. The use of superscripts is frequently encountered in the theory of General Relativity . The following line states in effect that the each of the elements of a vector ''c'' are equal to the sum of the corresponding elements of vectors '''''a''''' and '''''b'''''
:\mathbf{c}_j = \mathbf{a}_j + \mathbf{b}_j

so
:\mathbf{c}_0 = \mathbf{a}_0 + \mathbf{b}_0
:\mathbf{c}_1 = \mathbf{a}_1 + \mathbf{b}_1
and so on.

Superscripts are used instead of subscripts to distinguish covariant from contravariant entities, see Covariance And Contra-variance .

See also: Summation Convention


INDEX NOTATION IN COMPUTING

In several programming languages, index notation is a way of addressing elements of an array. This method is used since it is closest to how it is implemented in Assembly Language whereby the address of the first element is used as a base, and a multiple (the index) of the element size is used to address inside the array.

For example, if an array of integers is stored in a region of the computer's memory starting at the memory cell with address 3000 (the Base Address ), and each integer occupies four cells (bytes), then the elements of this array are at memory locations 3000, 3004, 3008, ..., 0x3000 + 4(''n''-1). In general, the address of the ''i''th element of an array with Base Address ''b'' and element size ''s'' is ''b''+''is''.


C IMPLEMENTATION DETAILS



Multidimensional arrays

Things become more interesting when we consider arrays with more than one index, for example, a two-dimensional table. We have three possibilities:
  • make the two-dimensional array one-dimensional by computing a single index from the two

  • consider a one-dimensional array where each element is another one-dimensional array, i.e an array of arrays

  • use additional storage to hold the array of addresses of each row of the origninal array, and store the rows of the original array as separate one-dimensional arrays

  • tablename When the programmer subsequently specifies a particular element tablename[first index index , the compiler generates instructions to look up the address of the row specified by the first index, and use this address as the base when computing the address of the element specified by the second index.

  • Example

This function multiplies two 3x3 floating point matrices together.

void mult3x3f(float result const float A[ const float B[ [3])
{
int i, j, k;
for (i = 0; i < 3; ++i) {
for (j = 0; j < 3; ++j) {
result {Link without Title} {Link without Title} = 0;
for (k = 0; k < 3; ++k)
  • B[k [j];

  • }

}
}


IN OTHER LANGUAGES

In other programming languages such as Pascal, indices may start at 1, so indexing in a block of memory can be changed to fit a start-at-1 addressing scheme by a simple linear transformation - in this scheme, the memory location of the ''i''th element with Base Address ''b'' and element size ''s'' is ''b''+(''i''-1)''s''.