On Thu, Apr 2, 2009 at 7:16 PM, ARMAND BRUMER <bru...@fordham.edu> wrote:
> Hello William,
>
> I have spent some time trying to figure out how to save information produced
> by Sage in a forma readable by Magma. Basically, I would like the equivalent
> of PrintFile in magma.

Here is an example of writing a string to a file using Sage:

sage: a = random_matrix(QQ,2)
sage: open('filename','w').write(str(a) + '\n')
sage: !cat filename
[  2   2]
[  1 1/2]

There is more about the open function here:
   http://docs.python.org/library/functions.html

If you have an object in Sage, e.g., a matrix and want to use it in
Magma, you can do this:

sage: b = magma(a)
sage: b.EchelonForm()
[1 0]
[0 1]

Sometimes you can get something that can be just pasted into magma as follows:

sage: a._magma_init_(magma)
'Matrix(RationalField(),2,2,StringToIntegerSequence("4 4 2 1"))/2'

The above will not always work because of the complexity of the
recursive datatypes
in Sage and Magma.


> Does it exist in Sage? Sorry for such a naive question, but I have not found
> any answer in the reference or tutorial.

You might try the Python tutorial (here:http://docs.python.org/) since
anything in Python works in Sage.


> In fact, are there any examples of
> small full programs which are not interactive, I find that is the best way
> for me to learn.

In the root of your Sage install there is a file

    examples/example.sage

which is a simple non-interactive Sage script.  You can run it by doing

   sage example.sage

in that directory. You can also look at the Sage source code in

   SAGE_ROOT/devel/sage/sage/

William

>
> Thanks ever so much...
>
> Best regards,
> armand
>
>
>



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to