Arpack example not clear, any simpler examples
Author 
Message 
utab #1 / 4

Arpack example not clear, any simpler examples
Dear all, I tried ARPACK library this afternoon, and could not decide where to post and ended up here ;) So I am trying to compile the dssimp.f example in the arpack directory with a diagonal matrix for the eigenvalues. I wrote a simple matrix vector multiplication routine to try it out. But the example, for the poisson equation was a bit hard for me to understand. I can compile my code with the given matrix multiplication routine below. But there is no success so far. When I look at the calling of av(Matrixvector product) in the example program it takes "workd" as the two input arguments to the routine however workd is declared to be double precision workd(3*maxn) where maxn is given as 256 in the example routine. At this point I thought that my routine will not work properly because of the dimension mismatch but it works I could not understand how this simple example will work for the simple A matrix below. And do you have any simpler examples from your own tries? Thx, subroutine MATRIXVECTOR(N,X,Y) integer i, j, N double precision X(N), Y(N) double precision A(3,3) A(1,1)=1.0 A(1,2)=0.0 A(1,3)=0.0 A(2,1)=0.0 A(2,2)=4.0 A(2,3)=0.0 A(3,1)=0.0 A(3,2)=0.0 A(3,3)=6.0 do 10 i=1,n Y(i)=0 10 continue do 20 i=1,n do 30 j=1,n Y(i) = A(i,j) * X(j) + Y(i); 30 continue 20 continue end

Thu, 21 Apr 2011 01:52:12 GMT 


Glen Herrmannsfeld #2 / 4

Arpack example not clear, any simpler examples
Quote:
> I tried ARPACK library this afternoon, > and could not decide where to post and ended up here ;)
This might be the best place. Quote: > So I am trying to compile the dssimp.f example in the arpack directory > with a diagonal matrix for the eigenvalues. I wrote a simple matrix > vector multiplication routine to try it out. But the example, for the > poisson equation was a bit hard for me to understand. I can compile my > code with the given matrix multiplication routine below. But there is no > success so far. When I look at the calling of av(Matrixvector product) > in the example program it takes "workd" as the two input arguments to the > routine however workd is declared to be > double precision workd(3*maxn) > where maxn is given as 256 in the example routine. > At this point I thought that my routine will not work properly because of > the dimension mismatch but it works I could not understand how this > simple example will work for the simple A matrix below. And do you have > any simpler examples from your own tries?
It is legal to pass a 1D array that is long enough as an actual argument to a 2D dummy argument. Quote: > subroutine MATRIXVECTOR(N,X,Y) > integer i, j, N > double precision X(N), Y(N) > double precision A(3,3) > A(1,1)=1.0 > A(1,2)=0.0 > A(1,3)=0.0 > A(2,1)=0.0 > A(2,2)=4.0 > A(2,3)=0.0 > A(3,1)=0.0 > A(3,2)=0.0 > A(3,3)=6.0 > do 10 i=1,n > Y(i)=0 > 10 continue > do 20 i=1,n > do 30 j=1,n > Y(i) = A(i,j) * X(j) + Y(i); > 30 continue > 20 continue > end
It you mean passing WORKD as X and Y above, that would not be legal. If you pass the same variable more than once you aren't allowed to modify it.  glen

Thu, 21 Apr 2011 05:16:08 GMT 


utab #3 / 4

Arpack example not clear, any simpler examples
Quote:
>> I tried ARPACK library this afternoon, and could not decide where to >> post and ended up here ;) > This might be the best place.
Ok thx Quote: >> So I am trying to compile the dssimp.f example in the arpack directory >> with a diagonal matrix for the eigenvalues. I wrote a simple matrix >> vector multiplication routine to try it out. But the example, for the >> poisson equation was a bit hard for me to understand. I can compile my >> code with the given matrix multiplication routine below. But there is >> no success so far. When I look at the calling of av(Matrixvector >> product) in the example program it takes "workd" as the two input >> arguments to the routine however workd is declared to be >> double precision workd(3*maxn) >> where maxn is given as 256 in the example routine. At this point I >> thought that my routine will not work properly because of the dimension >> mismatch but it works I could not understand how this simple example >> will work for the simple A matrix below. And do you have any simpler >> examples from your own tries? > It is legal to pass a 1D array that is long enough as an actual argument > to a 2D dummy argument.
Ok, but still not clear to me, because it is mentioned in the explanations that I should only supply a matrixvector routine that is capable of doing 'w<A*x' Quote: > It you mean passing WORKD as X and Y above, that would not be legal. > If you pass the same variable more than once you aren't allowed to > modify it.
I am sorry but in the example file the call to the matrixvector product,av, in the dsaupd loop is like call av (nx, workd(ipntr(1)), workd(ipntr(2))) so it is not that the argument repeated two times. Can I kindly ask whether you used this library before or not. Because AFAIU, I have a conceptual understanding in the matrix operations to use this routine and other correctly, Thanks for the gentle reply anyway ;) Quote:

Thu, 21 Apr 2011 06:14:15 GMT 


Glen Herrmannsfeld #4 / 4

Arpack example not clear, any simpler examples
(snip) Quote: >>>double precision workd(3*maxn)
(snip) Quote: > Ok, but still not clear to me, because it is mentioned in the > explanations that I should only supply a matrixvector routine that is > capable of doing 'w<A*x' >>It you mean passing WORKD as X and Y above, that would not be legal. >>If you pass the same variable more than once you aren't allowed to >>modify it. > I am sorry but in the example file the call to the matrixvector > product,av, in the dsaupd loop is like > call av (nx, workd(ipntr(1)), workd(ipntr(2)))
OK, that explains it. Quote: > so it is not that the argument repeated two times. Can I kindly ask > whether you used this library before or not. Because AFAIU, I have a > conceptual understanding in the matrix operations to use this routine and > other correctly,
No, but many programs written in the fortran 66 days used these conventions. call av (nx, workd(ipntr(1)), workd(ipntr(2))) and a subroutine starting with subroutine MATRIXVECTOR(N,X,Y) integer i, j, N double precision X(N), Y(N) With nx equal to 3 in the call, ipntr(1) might be 1 and ipntr(2) might be 4. Then X is the first three elements of WORKD and Y is the next three. The standard requires this to work, such that the array elements starting at workd(ipntr(1)) are used by X, and workd(ipntr(2)) are used by Y. The elements used by the subroutine are required to be within the actual array. For arrays of more than one dimension, you have to know how they are ordered in memory.  glen

Thu, 21 Apr 2011 08:20:16 GMT 


