Ask Your Question
0

Problem regarding user input in Sage manifolds

asked 7 years ago

Shouvik gravatar image

updated 7 years ago

vdelecroix gravatar image

I am unable to take input from user in case of sage manifold,i am working in differentiable manifold.Especially,I am having problem to take input from user in case of vector fields(differentiable manifold) Any help is appreciated

Preview: (hide)

Comments

1

In order to get help you need:

  1. to give details about your operating system and your Sage installation
  2. describe precisely your problem
  3. provide some code snippet
vdelecroix gravatar imagevdelecroix ( 7 years ago )

My operating system is windows and i am executing sage software 7.6 using sage manifold appliance (virtual box) My problem is t I am unable to take raw_input from user(just like python) for vector field on a 5 dimensional manifold. The code snippet is as follows M = Manifold(5, 'M') X.<a,b,c,d,e> = M.chart() v = M.vector_field(name='v') eU = X.frame() v[eU,:]=raw_input("enter a value") print v[0]

Shouvik gravatar imageShouvik ( 7 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 7 years ago

dan_fulea gravatar image

Note that the raw input captures a string from the user - in my case from the sage interpreter:

sage: a = raw_input( "Please enter a number... >" )
Please enter a number... >7
sage: a
'7'

The code has to arrange that the input is parsed correctly. For the posted case an evaluation would be enough, if the user raw input is prepared to be evaluated. Note for this the example:

sage: eval( '17, 5, 22, 196544, -1' )
(17, 5, 22, 196544, -1)
sage: type( _ )
<type 'tuple'>

Slightly changed code:

M = Manifold(5, 'M')
X.<a,b,c,d,e> = M.chart()
v = M.vector_field(name='v')
eU = X.frame()
v[eU,:] = eval( raw_input( "enter five numbers (comma separated) > " ) )
print "eU =", eU
print "v[ eU, : ] =", v[eU,:]

Let's see it it works, code was copy-pasted into the sage interpreter via %cpaste:

sage: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:M = Manifold(5, 'M')
X.<a,b,c,d,e> = M.chart()
v = M.vector_field(name='v')
eU = X.frame()
v[eU,:] = eval( raw_input( "enter five numbers (comma separated) > " ) )
print "eU =", eU
print "v[ eU, : ] =", v[eU,:]
:::::::
:--
enter five numbers (comma separated) > 17, 5, 22, 196544, -1
eU = Coordinate frame (M, (d/da,d/db,d/dc,d/dd,d/de))
v[ eU, : ] = [17, 5, 22, 196544, -1]
sage:
Preview: (hide)
link

Comments

thank you,its working

Shouvik gravatar imageShouvik ( 7 years ago )

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: 7 years ago

Seen: 387 times

Last updated: Jul 15 '17