INDEX
Indexing Multidimensional Arrays
INDEX
is a MATLAB 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
Licensing:
The computer code and data files described and made available on this
web page are distributed under
the GNU LGPL license.
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 MATLAB 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 MATLAB library which
contains many utility routines;
Source Code:
-
index0.m,
indexes a 1D vector using a zero base.
-
index01.m,
indexes a 2D array by columns, with a zero base.
-
index012.m,
indexes a 3D array by columns with zero base.
-
index0123.m,
indexes a 4D array by columns, with a zero base.
-
index0n.m,
indexes an N-dimensional array by columns, with zero base.
-
index1.m,
indexes a 1D vector using a unit base.
-
index10.m,
indexes a 2D array by rows, with a zero base.
-
index12.m,
indexes a 2D array by columns, with a unit base.
-
index123.m,
indexes a 3D array by columns with unit base.
-
index1234.m,
indexes a 4D array by columns, with a unit base.
-
index1n.m,
indexes an N-dimensional array by columns, with unit base.
-
index21.m,
indexes a 2D array by rows, with a unit base.
-
index210.m,
indexes a 3D array by rows, with zero base.
-
index321.m,
indexes a 3D array by rows, with zero base.
-
index3210.m,
indexes a 4D array by rows, with zero base.
-
index4321.m,
indexes a 4D array by rows, with unit base.
-
indexn0.m,
indexes an N-dimensional array by rows, with zero base.
-
indexn1.m,
indexes an N-dimensional array by rows, with unit base.
-
timestamp.m,
prints the current YMDHMS date as a time stamp.
Examples and Tests:
-
index_test.m,
a sample calling program.
-
index_test01.m,
tests INDEX0 and INDEX1.
-
index_test02.m,
tests INDEX01, INDEX10, INDEX12 and INDEX21.
-
index_test03.m,
tests INDEX012, INDEX123, INDEX210, and INDEX321.
-
index_test04.m,
tests INDEX0123, INDEX1234, INDEX3210, and INDEX4321.
-
index_test05.m,
tests INDEX0N, INDEX1N, INDEXN0 and INDEXN1.
-
index_test_output.txt,
the output file.
You can go up one level to
the MATLAB source codes.
Last revised on 27 November 2012.