# Index notation

﻿
Index notation

Index notation is used in mathematics to refer to the elements of matrices or the components of a vector. The formalism of how indices are used varies according to the discipline. In particular, there are different methods for referring to the elements of a list, a vector, or a matrix, depending on whether one is writing a formal mathematical paper for publication, or when one is writing a computer program. In some fields, the terms "index notation", or "indicial notation" are used to refer to Einstein 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\left\{c\right\}_j = mathbf\left\{a\right\}_j + mathbf\left\{b\right\}_j$

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

Superscripts are used instead of subscripts to distinguish covariant from contravariant entities, see Covariance and contravariance.

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

In the C programming language, we can write the above as *(base + i) (pointer form) or base [i] (array indexing form), which is exactly equivalent because the C standard defines the array indexing form as a transformation to pointer form. Coincidentally, since pointer addition is commutative, this allows for obscure expressions such as 3 [base] which is equivalent to base [3] .

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 arraysIn C, all three methods can be used. When the first method is used, the programmer decides how the elements of the array are laid out in the computer's memory, and provides the formulas to compute the location of each element. The second method is used when the number of elements in each row is the same and known at the time the program is written. The programmer declares the array to have, say, three columns by writing e.g. elementtype tablename [] [3] ;. One then refers to a particular element of the array by writing tablename [first index] [second index] . The compiler computes the total number of memory cells occupied by each row, uses the first index to find the address of the desired row, and then uses the second index to find the address of the desired element in the row. When the third method is used, the programmer declares the table to be an array of pointers, like in elementtype *tablename [] ;. When the programmer subsequently specifies a particular element tablename [first index] [second 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 [] [3] , const float A [] [3] , const float B [] [3] ) { int i, j, k; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { result [i] [j] = 0; for (k = 0; k < 3; ++k) result [i] [j] += A [i] [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".

Wikimedia Foundation. 2010.

### Look at other dictionaries:

• Abstract index notation — is a mathematical notation for tensors and spinors that uses indices to indicate their types, rather than their components in a particular basis. The indices are mere placeholders, not related to any fixed basis, and in particular are non… …   Wikipedia

• Multi-index notation — The mathematical notation of multi indices simplifies formulae used in multivariable calculus, partial differential equations and the theory of distributions, by generalising the concept of an integer index to an ordered tuple of indices.… …   Wikipedia

• Tetrad (index notation) — In Riemannian geometry, we can introduce a coordinate system over the Riemannian manifold (at least, over a chart), giving n coordinates :xi, i=1,...,n for an n dimensional manifold. Locally, at least, this gives a basis for the 1 forms, dxi… …   Wikipedia

• Index Des Notations Musicales — Le but de cette page est de permettre la reconnaissance de symboles inconnus sur une partition. Les éléments graphiques sont repris d autres pages, et devraient être créés plus spécifiquement pour ne contenir que la représentation graphique du… …   Wikipédia en Français

• Index notations (musique) — Index des notations musicales Le but de cette page est de permettre la reconnaissance de symboles inconnus sur une partition. Les éléments graphiques sont repris d autres pages, et devraient être créés plus spécifiquement pour ne contenir que la… …   Wikipédia en Français

• notation — I noun annotation, chronicle, comment, commentary, entry, footnote, inscription, marginalia, memorandum, minute, note, record, register II index comment, marginalia, memorandum, reminder, symbol …   Law dictionary

• Index of chess articles — Contents 1 Books 2 General articles 2.1 0–9 2.2 A …   Wikipedia

• Notation graphique — Partition graphique Une partition graphique est une forme de notation musicale qui utilise des symboles et des indications textuelles non conventionnels pour indiquer la manière dont doit être interprété un morceau de musique. Elle est… …   Wikipédia en Français

• Notation Composer — rightNotation Player, Notation Musician, and Notation Composer are all members of the product family developed by Notation Software, Inc. The original MIDI to notation technology used in Notation software products was created by Notation Software …   Wikipedia

• Notation musicale — Pour les articles homonymes, voir notation. En musique, on appelle notation le fait de transcrire sur un support les constituants d une œuvre musicale, afin de conserver celle ci, de la diffuser et de l interpréter de manière différée. Sommaire 1 …   Wikipédia en Français