python/t1calc.py
changeset 0 0efde00f9229
equal deleted inserted replaced
-1:000000000000 0:0efde00f9229
       
     1 #!/usr/bin/python
       
     2 
       
     3 import pylab as pl
       
     4 from indep import indep
       
     5 from move import move
       
     6 
       
     7 def t1calc(S, Srows, T1, T1rows, sel, pr, Frows, Fbcols, abar, gap=None):
       
     8     b = pl.array([1])
       
     9     sel = sel.squeeze()
       
    10     while (T1rows < Frows - Fbcols) and pl.any(sel==1) and b.size!=0:
       
    11         b = indep(S[pl.logical_and(sel, sel),:], gap)
       
    12         if b.size != 0:
       
    13             b = move(b, pl.find(sel), Srows)
       
    14             b = b.squeeze()
       
    15             j = b.shape[-1]-1
       
    16             while not (b[j] and pl.any(abar==j)):
       
    17                 j -= 1
       
    18                 if j == -1:
       
    19                    print 'Message from t1calc, called from left_prm'
       
    20                    print 'Denominator is noninvertible'
       
    21                    exit()
       
    22             aa = pl.remainder(pr, Frows) == pl.remainder(j, Frows)
       
    23             bb = j<pr
       
    24             if not pl.any(bb * aa):
       
    25                 if T1.size is 0:
       
    26                     T1 = b.copy()
       
    27                 else:
       
    28                     T1 = pl.row_stack((T1, b))
       
    29                 T1rows += 1
       
    30             if pr.size is 0:
       
    31                 pr = pl.array([j])
       
    32             else:
       
    33                 pr = pl.vstack((pr, j))
       
    34             while j < Srows:
       
    35                 sel[j] = 0
       
    36                 j += Frows
       
    37     return T1, T1rows, sel, pr
       
    38 
       
    39 if __name__== "__main__":
       
    40     pass