Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
howto:data [2010/11/30 21:51] – gawrilow | user_guide:tutorials:data [2019/02/11 16:43] (current) – restored. oroehrig | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Save and load data in polymake ====== | + | {{page>.:latest:@FILEID@}} |
- | + | ||
- | In polymake there are different ways to save and load data depending on the type and the format of the data. We distinguish between polymake objects (Polytope, Matroid, | + | |
- | + | ||
- | ===== Handling polymake objects ===== | + | |
- | polymake objects that are stored in polymake' | + | |
- | $p=load(" | + | |
- | If you did not start '' | + | |
- | $p=load(" | + | |
- | To store polymake objects use the command | + | |
- | save($p," | + | |
- | **Note:** If you load a polymake object and compute new properties, these properties will automatically be added to the original XML-file at the end of the session. | + | |
- | + | ||
- | ===== Handling complex data types ===== | + | |
- | + | ||
- | It is also possible to store complex data structures in XML format via '' | + | |
- | $s=new Set< | + | |
- | save_data($s," | + | |
- | To load such files just type | + | |
- | $s=load_data(" | + | |
- | + | ||
- | ===== Handling arbitrary files ===== | + | |
- | + | ||
- | Of course, it is also possible to load data from files in other formats. For this purpose use the standard Perl functions for reading and writing. Here is an example:\\ Assume you want to load some points stored in the file points.txt which looks like this: | + | |
- | 1 0 0 0 | + | |
- | 1 1 0 0 | + | |
- | 1 0 1 0 | + | |
- | 1 1 1 0 | + | |
- | 1 0 0 1 | + | |
- | 1 1 0 1 | + | |
- | 1 0 1 1 | + | |
- | 1 1 1 1 | + | |
- | To read this file try the following: | + | |
- | open(INPUT, "< points.txt" | + | |
- | while(< | + | |
- | print $_; | + | |
- | | + | |
- | close(INPUT); | + | |
- | + | ||
- | ''< | + | |
- | open(INPUT, "< points.txt" | + | |
- | $matrix=new Matrix< | + | |
- | close(INPUT); | + | |