in any of the 1 level blas, there are incx and incy; I read that you can put
integer number in them, and the numbers that you want.
Well, sure, you pick the number you want, you are the user so you decide. But
the INCX value does have some meaning ... Be careful with your interpretation,
BLAS routines are not asking for INCX just for the fun of having a useless
extra argument.
So what does INCX mean? Typically a vector is represented by three arguments:
N, X(I), INCX. First its length: N, then a pointer to the first element of the
array: X(I), and third the increment INCX. The vector you want to work with is
then defined in memory with:
- Code: Select all
[ X(I), X(I+INCX), X(I+2*INCX), ..., X(I+(N-1)*INCX) ]
If your vector is stored contiguously in memory, then INCX=1.
Now, imagine you have an M-by-N matrix stored by column in a M*N array A. The
array A is declared in Fortran with:
- Code: Select all
DOUBLE PRECISION A(LDA,N)
where LDA>=M is the leading dimension of A. Then the column J of A is defined
with:
- Code: Select all
M, A(1,J), 1
the row I of A is defined with:
- Code: Select all
N, A(I,1), LDA
This is one classical example where the increment argument, INCX, is useful.
You can find others in more application specific configuration.
In general, you have INCX>0 but INCX<0 is allowed as well.
In some cases, INCX=0 is allowed. One use of INCX=0 is for example if you want
to initialize all the elements of a vector X to 10.00D+00, you can do
- Code: Select all
CALL DCOPY( N, 10D+00, 0, X, 1)
For exemple in a routine like dcopy, can give a difference if I insert 5 and
5, instead of 1 and 1? And if I insert 0 for incx and 1 for incy, what does it
happen?
I hope you can now answer your question by yourself, but basically
- if you type:
- Code: Select all
CALL DCOPY( 5, X, 5, Y, 1)
The code will perform as:
- Code: Select all
Y(1) = X( 1)
Y(2) = X( 6)
Y(3) = X(11)
Y(4) = X(16)
Y(5) = X(21)
- if you type:
- Code: Select all
CALL DCOPY( 5, X, 0, Y, 1)
The code will perform as:
- Code: Select all
Y(1) = X(1)
Y(2) = X(1)
Y(3) = X(1)
Y(4) = X(1)
Y(5) = X(1)
and etc.
-j