Ask Your Question
0

sage and nohup

asked 13 years ago

Matthieu Deneufchâtel gravatar image

updated 13 years ago

niles gravatar image

Does anyone understand why the code below, saved in the file input.txt, does not work when it is run with the command

nohup sage < input.txt > output.txt &

(Of course, I use * for the product but it does not appear properly here)?

import sage.combinat.lyndon_word as LW

from sage.combinat.words.shuffle_product import ShuffleProduct_w1w2 as SP

from sage.combinat.free_module import CombinatorialFreeModule as CFM

F=CFM(QQ, ['a','b'])

R.<a,b>=FreeAlgebra(QQ,2)

Module=CombinatorialFreeModule(F.base_ring(),R)

def TP_free_algebra(w1,w2):
  if type(w1)==Integer:
    if type(w2)==Integer:
      return w1*w2*tensor((Module.basis()[1],Module.basis()[1]))
    else:
      L2=list(w2)
      result=0
      for i in L2:
        result+=w1*i[0]*tensor((Module.basis()[1],Module.basis()[i[1]]))    
      return result
  else:
    if type(w2)==Integer:
      L1=list(w1)
      result=0
      for i in L1:
        result+=w2*i[0]*tensor((Module.basis()[i[1]],Module.basis()[1]))    
      return result
    else:
      L1=list(w1)
      L2=list(w2)
      result=0
      for i in L1:
        for j in L2:
          result+=i[0]*j[0]*tensor((Module.basis()[i[1]],Module.basis()[j[1]]))
      return result

TP_free_algebra(Word('a'),Word('b'))
Preview: (hide)

Comments

Concerning `*`: Why don't you use the editor to format code like code?

Simon King gravatar imageSimon King ( 13 years ago )

2 Answers

Sort by » oldest newest most voted
0

answered 13 years ago

Matthieu Deneufchâtel gravatar image

My code works without nohup. I don't why, but I could not make it work with it, so I used the screen command and was able to do what I want. Thanks for your answer anyway.

Preview: (hide)
link
0

answered 13 years ago

niles gravatar image

Does it work without nohup? I haven't used "<" in my nohupped sage jobs -- what is it supposed to do? Also, why not use .sage instead of .txt? I would try

nohup sage input.sage > output.txt &

(after copying input.txt to input.sage)

Preview: (hide)
link

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 13 years ago

Seen: 997 times

Last updated: Jan 30 '12