Hello,

the leading dimension argument appears for all 2D arrays in the BLAS and

LAPACK interfaces.

If your matrix is simply a 2-by-6 matrix, that starts from A(1,1), then sure

you can work with a 2-by-6 array:

- Code: Select all
`N=2, M=6, A(1,1), LDA=2.`

And LDA = N = number of rows of the matrix.

Now imagine that you have a 20-by-20 array, and you want to work on the

2-by-6 block starting in position A(4,10), in Matlab notation this is

A(4:5,10:15) then you can simply work on this submatrix with

- Code: Select all
`N=2, M=6, A(4,10), LDA=20.`

If you look at any LAPACK subroutines (for example

DGETRF), you will

soon understand how useful the leading dimension can be useful.

Another advantage, slightly more complex, is that some leading dimension

are

bad. In general, if you take N=LDA=2^9=512 or another power

of 2 or an integer made of high power of 2 (e.g. 2^9+2^8=768), you'll

end up with lots of cache line conflicts and performance can be very poor.

So if you need to work with a matrix of size 512, a good idea is to set

LDA=513 to avoid this problem. This effect and its cure were mentionned

several times in the past. Recently, Sven Hammarling (NAG) and some

colleagues from the University of Manchester came up with nice examples.

Julien