Table 2 shows the time required to access a matrix element when the indices are local variables, for
example, matrix[m1,m2]. The data shows that it takes slightly longer to access an element with
variable indices, but the overhead for indirect access is about the same, at a mean of 5.8 mS.
Matrix dimensions
10 rows, 10 columns
20 rows, 20 columns
Table 3 shows the mean time required to access each element of matrices of various sizes. Element
indices are local variables, and the elements were accessed by value, for example, matrix[m1,m2].
Matrix
Matrix
rows
columns
5
25
5
35
5
45
5
55
5
65
5
75
5
85
5
95
5
105
5
115
5
125
5
135
5
145
5
155
10
10
10
20
10
30
10
40
[15,15]
27.8
[20,20]
32.7
Table 2
Matrix element access time, variable indices
Element
Access time Tav,
accessed
value method
(mS)
[1,1]
15.5
[5,5]
17.9
[10,10]
20.6
[1,1]
15.5
[5,5]
19.5
[10,10]
24.2
[15,15]
29.5
[20,20]
34.2
Table 3
Mean matrix element access time, direct access
Mean access time,
single element (mS)
18.9
19.7
20.9
21.4
22.5
23.6
25.0
25.9
27.0
27.9
28.9
30.1
31.3
32.4
18.2
20.3
22.6
24.9
33.3
38.2
Access time Tar,
reference method
(mS)
21.2
23.7
26.2
21.3
25.2
30.2
35.3
40.2
Matrix
Matrix
rows
columns
20
10
20
20
20
30
25
5
30
10
30
20
35
5
40
10
40
20
45
5
50
10
55
5
60
10
65
5
70
10
75
5
80
10
85
5
5.5
5.5
Reference method
overhead
Tar - Tav
5.7
5.8
5.6
5.8
5.7
6.0
5.8
6.0
Mean access time,
single element (mS)
21.5
25.5
29.3
19.1
23.8
30.0
21.2
25.2
34.0
21.9
27.7
23.6
30.3
25.0
32.9
26.0
35.4
27.4
7 - 50