<?xml version="1.0" encoding="utf-8" ?> <!-- for emacs: -*- coding: utf-8 -*- --> <!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head><title>saving polynomials and matrices in files</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="_two_spdimensional_spformatting.html">next</a> | <a href="_creating_spand_spwriting_spfiles.html">previous</a> | <a href="_two_spdimensional_spformatting.html">forward</a> | <a href="_creating_spand_spwriting_spfiles.html">backward</a> | <a href="___The_sp__Macaulay2_splanguage.html">up</a> | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div> </td> </tr> </table> <div><a href="index.html" title="">Macaulay2Doc</a> > <a href="___The_sp__Macaulay2_splanguage.html" title="">The Macaulay2 language</a> > <a href="_saving_sppolynomials_spand_spmatrices_spin_spfiles.html" title="">saving polynomials and matrices in files</a></div> <hr/> <div><h1>saving polynomials and matrices in files</h1> <div>Use the function <a href="_to__String.html" title="convert to a string">toString</a> to convert polynomials, matrices, and other mathematical objects to a linear format that can be saved in a file.<table class="examples"><tr><td><pre>i1 : R = QQ[x..z] o1 = R o1 : PolynomialRing</pre> </td></tr> <tr><td><pre>i2 : p = (x-y-1)^3 3 2 2 3 2 2 o2 = x - 3x y + 3x*y - y - 3x + 6x*y - 3y + 3x - 3y - 1 o2 : R</pre> </td></tr> <tr><td><pre>i3 : m = matrix {{x^2, x^2-y^2, x*y*z^7 }} o3 = | x2 x2-y2 xyz7 | 1 3 o3 : Matrix R <--- R</pre> </td></tr> <tr><td><pre>i4 : M = image m o4 = image | x2 x2-y2 xyz7 | 1 o4 : R-module, submodule of R</pre> </td></tr> <tr><td><pre>i5 : f = temporaryFileName() o5 = /tmp/M2-21648-1</pre> </td></tr> <tr><td><pre>i6 : f << toString (p,m,M) << close o6 = /tmp/M2-21648-1 o6 : File</pre> </td></tr> <tr><td><pre>i7 : get f o7 = (x^3-3*x^2*y+3*x*y^2-y^3-3*x^2+6*x*y-3*y^2+3*x-3*y-1,matrix {{x^2, x^2-y^2, x*y*z^7}},image matrix {{x^2, x^2-y^2, x*y*z^7}})</pre> </td></tr> <tr><td><pre>i8 : (p',m',M') = value get f 3 2 2 3 2 2 o8 = (x - 3x y + 3x*y - y - 3x + 6x*y - 3y + 3x - 3y - 1, | x2 x2-y2 ------------------------------------------------------------------------ xyz7 |, image | x2 x2-y2 xyz7 |) o8 : Sequence</pre> </td></tr> <tr><td><pre>i9 : p == p' o9 = true</pre> </td></tr> <tr><td><pre>i10 : m == m' o10 = true</pre> </td></tr> <tr><td><pre>i11 : M == M' o11 = true</pre> </td></tr> <tr><td><pre>i12 : removeFile f</pre> </td></tr> </table> </div> </div> </body> </html>