python/t1calc.py
author Puneeth Chaganti <punchagan@fossee.in>
Fri, 27 May 2011 14:24:59 +0530
changeset 0 0efde00f9229
permissions -rw-r--r--
Initial commit.

#!/usr/bin/python

import pylab as pl
from indep import indep
from move import move

def t1calc(S, Srows, T1, T1rows, sel, pr, Frows, Fbcols, abar, gap=None):
    b = pl.array([1])
    sel = sel.squeeze()
    while (T1rows < Frows - Fbcols) and pl.any(sel==1) and b.size!=0:
        b = indep(S[pl.logical_and(sel, sel),:], gap)
        if b.size != 0:
            b = move(b, pl.find(sel), Srows)
            b = b.squeeze()
            j = b.shape[-1]-1
            while not (b[j] and pl.any(abar==j)):
                j -= 1
                if j == -1:
                   print 'Message from t1calc, called from left_prm'
                   print 'Denominator is noninvertible'
                   exit()
            aa = pl.remainder(pr, Frows) == pl.remainder(j, Frows)
            bb = j<pr
            if not pl.any(bb * aa):
                if T1.size is 0:
                    T1 = b.copy()
                else:
                    T1 = pl.row_stack((T1, b))
                T1rows += 1
            if pr.size is 0:
                pr = pl.array([j])
            else:
                pr = pl.vstack((pr, j))
            while j < Srows:
                sel[j] = 0
                j += Frows
    return T1, T1rows, sel, pr

if __name__== "__main__":
    pass