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

« back to all changes in this revision

Viewing changes to routines/calelm/gdcp2i.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 gdcp2i(n, itab, m)
 
2
c!purpose
 
3
c       decomposition of an integer n in a base tw0.
 
4
c       n=a1+a2*2+a3*2**2+.........+am*2**(m-1).
 
5
c!calling sequence
 
6
c     subroutine gdcp2i(n,itab,m)
 
7
c     integer n,itab,m
 
8
c
 
9
c        n     : integer to be decomposed (n.le.32767)
 
10
c
 
11
c        itab  :logical vector of dimension 15.
 
12
c               in output: if(a(i-1).ne.0)then itab(i)=.true.
 
13
c               else itab(i)=.false.
 
14
c
 
15
c        m     :the number of itab elements to be consider in output.
 
16
c
 
17
c!originator
 
18
c  j. hanen -september 1978-ensm-nantes.
 
19
c!
 
20
c
 
21
      dimension ipow2(15)
 
22
      logical itab(*)
 
23
c
 
24
      data ipow2(1), ipow2(2), ipow2(3), ipow2(4), ipow2(5),
 
25
     * ipow2(6), ipow2(7), ipow2(8), ipow2(9), ipow2(10),
 
26
     * ipow2(11), ipow2(12), ipow2(13), ipow2(14), ipow2(15)
 
27
     * /16384,8192,4096,2048,1024,512,256,128,64,32,16,8,4,2,1/
 
28
c
 
29
      m = 0
 
30
      k = 15
 
31
      nn = abs(n)
 
32
      if (nn.gt.32767) nn = mod(nn,32767)
 
33
      do 30 i=1,15
 
34
         if (nn.lt.ipow2(i)) go to 10
 
35
         itab(k) = .true.
 
36
         nn = nn - ipow2(i)
 
37
         if (m.eq.0) m = k
 
38
         go to 20
 
39
   10    itab(k) = .false.
 
40
   20    k = k - 1
 
41
   30 continue
 
42
c
 
43
      return
 
44
      end