~ubuntu-branches/debian/sid/arpack/sid

« back to all changes in this revision

Viewing changes to EXAMPLES/NONSYM/dndrv5.f

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2015-10-12 09:33:05 UTC
  • mfrom: (1.3.5)
  • Revision ID: package-import@ubuntu.com-20151012093305-w41sv3g9nzbaodfz
Tags: 3.3.0-1
* New upstream release
* Update of the homepage (moved to github)
* libparpack links against libarpack (instead of static build)
* Update the symbol files. No need to change of SONAME:
  - About the parpack change: https://github.com/opencollab/arpack-ng/pull/21
  - Transfer the call to the library:
    https://github.com/opencollab/arpack-ng/pull/19
* Standards-Version updated to version 3.9.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
c\Example-5
9
9
c
10
10
c     ... Suppose we want to solve A*x = lambda*B*x in shift-invert mode
11
 
c         The matrix A is the tridiagonal matrix with 2 on the diagonal,
12
 
c         -2 on the subdiagonal and 3 on the superdiagonal.  The matrix M
13
 
c         is the tridiagonal matrix with 4 on the diagonal and 1 on the
 
11
c         The matrix A is the tridiagonal matrix with 2 on the diagonal, 
 
12
c         -2 on the subdiagonal and 3 on the superdiagonal.  The matrix M 
 
13
c         is the tridiagonal matrix with 4 on the diagonal and 1 on the 
14
14
c         off-diagonals.
15
15
c     ... The shift sigma is a complex number (sigmar, sigmai).
16
16
c     ... OP = Real_Part{inv[A-(SIGMAR,SIGMAI)*M]*M and  B = M.
59
59
c     %-----------------------------%
60
60
c
61
61
      integer           maxn, maxnev, maxncv, ldv
62
 
      parameter         (maxn=256, maxnev=98, maxncv=100,
 
62
      parameter         (maxn=256, maxnev=10, maxncv=25, 
63
63
     &                   ldv=maxn )
64
64
c
65
65
c     %--------------%
128
128
c     | SIGMAI to solve problems of different sizes, and   |
129
129
c     | to get different parts of the spectrum. However,   |
130
130
c     | The following conditions must be satisfied:        |
131
 
c     |                     N <= MAXN,                     |
 
131
c     |                     N <= MAXN,                     | 
132
132
c     |                   NEV <= MAXNEV,                   |
133
 
c     |               NEV + 2 <= NCV <= MAXNCV             |
 
133
c     |               NEV + 2 <= NCV <= MAXNCV             | 
134
134
c     %----------------------------------------------------%
135
135
c
136
 
      n     = 100
137
 
      nev   = 98
138
 
      ncv   = 100
 
136
      n     = 100 
 
137
      nev   = 4 
 
138
      ncv   = 20 
139
139
      if ( n .gt. maxn ) then
140
140
         print *, ' ERROR with _NDRV5: N is greater than MAXN '
141
141
         go to 9000
162
162
c     | diagonal and 1 on the off-diagonals.              |
163
163
c     %---------------------------------------------------%
164
164
c
165
 
      c1 = dcmplx( 0.0D+0, 0.0D+0)
166
 
      c3 = dcmplx( 0.0D+0, 0.0D+0)
 
165
      c1 = dcmplx(-2.0D+0-sigmar, -sigmai)
 
166
      c2 = dcmplx( 2.0D+0-4.0D+0*sigmar, -4.0D+0*sigmai)
 
167
      c3 = dcmplx( 3.0D+0-sigmar, -sigmai)
167
168
c
168
169
      do 10 j = 1, n-1
169
170
         cdl(j) = c1 
170
 
         cdd(j) = dcmplx( j-sigmar, sigmai)
 
171
         cdd(j) = c2
171
172
         cdu(j) = c3
172
173
  10  continue 
173
 
      cdd(n) = dcmplx( n-sigmar, sigmai)
 
174
      cdd(n) = c2 
174
175
175
176
      call zgttrf(n, cdl, cdd, cdu, cdu2, ipiv, ierr)
176
177
      if ( ierr .ne. 0 ) then
567
568
c     %---------------------------%
568
569
c
569
570
 9000 continue
 
571
c
570
572
      end
571
573
572
574
c==========================================================================
575
577
c
576
578
      subroutine mv (n, v, w)
577
579
      integer           n, j
578
 
      Double precision  v(n), w(n)
 
580
      Double precision
 
581
     &                  v(n), w(n), one, four 
 
582
      parameter         (one = 1.0D+0, four = 4.0D+0)
579
583
c
580
584
c     Compute the matrix vector multiplication y<---M*x
581
 
c     where M is a n by n diagonal matrix with 1 on thediagonal
 
585
c     where M is a n by n symmetric tridiagonal matrix with 4 on the 
 
586
c     diagonal, 1 on the subdiagonal and superdiagonal.
582
587
583
 
      do 10 j = 1,n
584
 
         w(j) = v(j)
 
588
      w(1) =  four*v(1) + one*v(2)
 
589
      do 10 j = 2,n-1
 
590
         w(j) = one*v(j-1) + four*v(j) + one*v(j+1) 
585
591
 10   continue 
 
592
      w(n) =  one*v(n-1) + four*v(n) 
586
593
      return
587
594
      end
588
595
c------------------------------------------------------------------
589
596
      subroutine av (n, v, w)
590
597
      integer           n, j
591
 
      Double precision  v(n), w(n)
 
598
      Double precision            
 
599
     &                  v(n), w(n), three, two 
 
600
      parameter         (three = 3.0D+0, two = 2.0D+0)
592
601
c
593
602
c     Compute the matrix vector multiplication y<---A*x
594
 
c     where A is a n by n diagonal matrix with j on the
595
 
c     diagonal, where j is row's number
 
603
c     where M is a n by n symmetric tridiagonal matrix with 2 on the
 
604
c     diagonal, -2 on the subdiagonal and 3 on the superdiagonal.
596
605
c
597
 
      do 10 j = 1,n
598
 
         w(j) = j*v(j)
 
606
      w(1) =  two*v(1) + three*v(2)
 
607
      do 10 j = 2,n-1
 
608
         w(j) = -two*v(j-1) + two*v(j) + three*v(j+1)
599
609
 10   continue
 
610
      w(n) =  -two*v(n-1) + two*v(n)
600
611
      return
601
612
      end
 
613