Ask Your Question
0

How should I write this algorithm?

asked 2013-04-14 08:16:08 +0200

Neda gravatar image

updated 2013-04-14 08:26:35 +0200

hello I want to write this algorithm in sage, but I don't know how to write it as an algorithm in sage, could you please help me

Algorithm : update basis-update of intermediate basis G with reduct h Given: a finite set G_old ? B[X] and the reduct 0!=h ? B[X]

Find: updates G_new ? B[X] of G_old

begin

1: G_new <-- Ø

2: while G_old !=Ø do

3: selecting from G_old ; G_old <-- G_old {g}

4: if HT(h) not divisible HT(g) then

5: G_new <-- G_new U {g}

6: end

7:end

8: G_new <-- G_new U {h}

9: return G_new

end

thank you so much

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2013-04-15 07:35:34 +0200

slelievre gravatar image

Some of the code you wrote didn't make it. You should indent code so that it is displayed properly.

I don't exactly understand your algorithm, but from what I can grasp it might be something like this.

def update_basis(G,h):
    G_old = G.copy()
    G_new = []
    while G_old:
        g = G_old.pop()
        if ht(h) % ht(g):
            G_new.append(g)
    G_new.append(h)
    return G_new
edit flag offensive delete link more

Comments

thank you so so much, I think I should learn python programming ..

Neda gravatar imageNeda ( 2013-04-15 13:37:59 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-04-14 08:16:08 +0200

Seen: 322 times

Last updated: Apr 15 '13