# INDEX Indexing Multidimensional Arrays

INDEX is a FORTRAN77 library which can convert the index of a multidimensional array entry into the corresponding index of a one dimensional vector, using either row or column major indexing, with zero or unit base.

### 2D Array Example:

Consider, for example, the following 3x4 array A:

```        11 12 13 14
21 22 23 24
31 32 33 34
```

Indexing by columns, the array would be stored in a 1D vector as

```        11 21 31 | 12 22 32 | 13 23 33 | 14 24 34
```
and the indexing of the elements would be
```        11 21 31 | 12 22 32 | 13 23 33 | 14 24 34
0  1  2    3  4  5    6  7  8    9 10 11  <- zero based
1  2  3    4  5  6    7  8  9   10 11 12  <- one based
```

Indexing by rows, the array would be stored in a 1D vector as

```        11 12 13 14 | 21 22 23 24 | 31 32 33 34
```
and the indexing of the elements would be
```        11 12 13 14 | 21 22 23 24 | 31 32 33 34
0  1  2  3    4  5  6  7   8   9 10 11  <- zero based
1  2  3  4    5  6  7  8   9  10 11 12  <- one based
```

### Languages:

INDEX is available in a C version and a C++ version and a FORTRAN77 version and a FORTRAN90 version and a MATLAB version.

### Related Data and Programs:

CELL, a FORTRAN77 library which defines a cell array, a generalization of an array which can compactly store and retrieve vector or matrix data of varying size, such as the rows of a triangular matrix.

SUBPAK, a FORTRAN77 library which contains many utility routines;

### Source Code:

• index.f, the source code.
• index.sh, BASH commands to compile the source code.

### List of Routines:

• INDEX0 indexes a 1D vector using a zero base.
• INDEX01 indexes a 2D array by columns, with a zero base.
• INDEX012 indexes a 3D array by columns with zero base.
• INDEX0123 indexes a 4D array by columns, with a zero base.
• INDEX0N indexes an N-dimensional array by columns, with zero base.
• INDEX1 indexes a 1D vector using a unit base.
• INDEX10 indexes a 2D array by rows, with a zero base.
• INDEX12 indexes a 2D array by columns, with a unit base.
• INDEX123 indexes a 3D array by columns with unit base.
• INDEX1234 indexes a 4D array by columns, with a unit base.
• INDEX1N indexes an N-dimensional array by columns, with unit base.
• INDEX21 indexes a 2D array by rows, with a unit base.
• INDEX210 indexes a 3D array by rows, with zero base.
• INDEX321 indexes a 3D array by rows, with zero base.
• INDEX3210 indexes a 4D array by rows, with zero base.
• INDEX4321 indexes a 4D array by rows, with unit base.
• INDEXN0 indexes an N-dimensional array by rows, with zero base.
• INDEXN1 indexes an N-dimensional array by rows, with unit base.
• TIMESTAMP prints the current YMDHMS date as a time stamp.

You can go up one level to the FORTRAN77 source codes.

Last revised on 28 November 2012.