~ubuntu-branches/ubuntu/karmic/scilab/karmic

« back to all changes in this revision

Viewing changes to routines/calelm/wmsum.f

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2002-03-21 16:57:43 UTC
  • Revision ID: james.westby@ubuntu.com-20020321165743-e9mv12c1tb1plztg
Tags: upstream-2.6
ImportĀ upstreamĀ versionĀ 2.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
      subroutine wmsum(flag,ar,ai,na,m,n,vr,vi,nv)
 
2
c!purpose
 
3
c     computes the sum of the entries of a complexmatrix according to flag
 
4
c!calling sequence
 
5
c     subroutine wmsum(flag,ar,ai,na,m,n,vr,vi,nv)
 
6
c     double precision ar(na,n),ai(na,n),vr(*),vi(*)
 
7
c     integer na,n,m,nv
 
8
c     integer flag
 
9
c!parameters
 
10
c     flag : indicates operation to perform
 
11
c            0 : returns in v(1) the sum of all entries of a
 
12
c            1 : returns in v(j) the sum of jth column of a
 
13
c            2 : returns in v(i) the sum of ith row of a
 
14
c     a    : array containing the a matrix
 
15
c     na   : a matrix leading dimension
 
16
c     m    : a matrix row dimension
 
17
c     n    : a matrix column dimension
 
18
c     v    : array containing the result, may be confused with a row or
 
19
c            a column of the a matrix
 
20
c            if flag==0 size(v)>=1
 
21
c            if flag==1 size(v)>=n*nv
 
22
c            if flag==1 size(v)>=m*nv
 
23
c     nv   : increment between to consecutive entries ov v
 
24
c!
 
25
c     Copyright INRIA
 
26
      double precision ar(na,n),ai(na,n),vr(*),vi(*)
 
27
      integer na,n,m,nv
 
28
      integer flag
 
29
c
 
30
      double precision t,dsum
 
31
      integer iv
 
32
c
 
33
      iv=1
 
34
      if(flag.eq.0) then
 
35
c     sum of all the entries
 
36
         tr=0.0d0
 
37
         ti=0.0d0
 
38
         do 10 j=1,n
 
39
            tr=tr+dsum(m,ar(1,j),1)
 
40
            ti=ti+dsum(m,ai(1,j),1)
 
41
 10      continue
 
42
         vr(1)=tr
 
43
         vi(1)=ti
 
44
      elseif(flag.eq.1) then
 
45
         do 20 j=1,n
 
46
            tr=dsum(m,ar(1,j),1)
 
47
            ti=dsum(m,ai(1,j),1)
 
48
            vr(iv)=tr
 
49
            vi(iv)=ti
 
50
            iv=iv+nv
 
51
 20      continue
 
52
      elseif(flag.eq.2) then
 
53
         do 30 i=1,m
 
54
            tr=dsum(n,ar(i,1),m)
 
55
            ti=dsum(n,ai(i,1),m)
 
56
            vr(iv)=tr
 
57
            vi(iv)=ti
 
58
            iv=iv+nv
 
59
 30      continue
 
60
      endif
 
61
      return
 
62
      end