File: ex5f.f

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (53 lines) | stat: -rw-r--r-- 1,400 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
      subroutine foubare2(ch,a,ia,b,ib,c,mc,nc,d,w)
c     -----------------------------------------
c     -----------   EXAMPLE   -----------------
c     inputs:  ch, a,b and c; ia,ib and mc,nc
c     ch=character, a=integer, b=real and c=double 
c     ia,ib and [mc,nc] are the dimensions of a,b and c resp.
c     outputs: a,b,c,d
c     if ch='mul'   a,b and c = 2 * (a,b and c) 
c     and d of same dimensions as c with
c     d(i,j)=(i+j)*c(i,j)
c     if ch='add' a,b and c = 2 + (a,b and c)
c     d(i,j)=(i+j)+c(i,j)
c     w is a working array of size [mc,nc]
c     -------------------------------------------
      character*(*) ch
      integer a(*)
      real b(*)
      double precision c(mc,*),d(mc,*),w(mc,*)
      if(ch(1:3).eq.'mul') then
      do 1 k=1,ia
         a(k)=2*a(k)
 1    continue
      do 2 k=1,ib
         b(k)=2.0*b(k)
 2    continue
      do 3 i=1,mc
      do 3 j=1,nc
         c(i,j)=2.0d0*c(i,j)
 3    continue
      do 4 i=1,mc
      do 4 j=1,nc
       w(i,j)=dble(i+j)
       d(i,j)=w(i,j)*c(i,j)
 4    continue
      elseif(ch(1:3).eq.'add') then
      do 10 k=1,ia
         a(k)=2+a(k)
 10   continue
      do 20 k=1,ib
         b(k)=2.0+b(k)
 20   continue
      do 30 i=1,mc
      do 30 j=1,nc
         c(i,j)=2.0d0+c(i,j)
 30   continue
      do 40 i=1,mc
      do 40 j=1,nc
       w(i,j)=dble(i+j)
       d(i,j)=w(i,j)+c(i,j)
 40   continue
      endif
      end