Arpack example not clear, any simpler examples 
Author Message
 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(Matrix-vector 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  
 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(Matrix-vector 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  
 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(Matrix-vector
>> 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 matrix-vector 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 matrix-vector
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 ;)

- Show quoted text -

Quote:

> -- glen



Thu, 21 Apr 2011 06:14:15 GMT  
 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 matrix-vector 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 matrix-vector
> 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  
 
 [ 4 post ] 

 Relevant Pages 

1. some clear examples for FFI call to a Windows api function in Franz Allegro for Windows

2. nephyte needs f83 examples & examples

3. nephyte needs f83 examples & examples

4. nephyte needs f83 examples & examples

5. Aef's examples: DDE example ( dde.zip 1/3)

6. Aef's examples: DDE example (dde.zip 0/3)

7. Aef's examples:DDE example (dde.zip3/3)

8. Aef's examples: DDE example (dde.zip 2/3)

9. Announce: TimingAnalyzer Diagram Examples, Scripting Examples, App Note

10. Announce: TimingAnalyzer Diagram Examples, Scripting Examples, App Note

11. Shared lib package example (other than tcl-example)?

12. looking for an archive of examples, or a book of examples

 

 
Powered by phpBB® Forum Software