3
<title>Reading and writing permutations - GNU Scientific Library -- Reference Manual</title>
4
<meta http-equiv="Content-Type" content="text/html">
5
<meta name="description" content="GNU Scientific Library -- Reference Manual">
6
<meta name="generator" content="makeinfo 4.8">
7
<link title="Top" rel="start" href="index.html#Top">
8
<link rel="up" href="Permutations.html#Permutations" title="Permutations">
9
<link rel="prev" href="Applying-Permutations.html#Applying-Permutations" title="Applying Permutations">
10
<link rel="next" href="Permutations-in-cyclic-form.html#Permutations-in-cyclic-form" title="Permutations in cyclic form">
11
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
13
Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 The GSL Team.
15
Permission is granted to copy, distribute and/or modify this document
16
under the terms of the GNU Free Documentation License, Version 1.2 or
17
any later version published by the Free Software Foundation; with the
18
Invariant Sections being ``GNU General Public License'' and ``Free Software
19
Needs Free Documentation'', the Front-Cover text being ``A GNU Manual'',
20
and with the Back-Cover Text being (a) (see below). A copy of the
21
license is included in the section entitled ``GNU Free Documentation
24
(a) The Back-Cover Text is: ``You have freedom to copy and modify this
25
GNU Manual, like GNU software.''-->
26
<meta http-equiv="Content-Style-Type" content="text/css">
27
<style type="text/css"><!--
28
pre.display { font-family:inherit }
29
pre.format { font-family:inherit }
30
pre.smalldisplay { font-family:inherit; font-size:smaller }
31
pre.smallformat { font-family:inherit; font-size:smaller }
32
pre.smallexample { font-size:smaller }
33
pre.smalllisp { font-size:smaller }
34
span.sc { font-variant:small-caps }
35
span.roman { font-family:serif; font-weight:normal; }
36
span.sansserif { font-family:sans-serif; font-weight:normal; }
42
<a name="Reading-and-writing-permutations"></a>
43
Next: <a rel="next" accesskey="n" href="Permutations-in-cyclic-form.html#Permutations-in-cyclic-form">Permutations in cyclic form</a>,
44
Previous: <a rel="previous" accesskey="p" href="Applying-Permutations.html#Applying-Permutations">Applying Permutations</a>,
45
Up: <a rel="up" accesskey="u" href="Permutations.html#Permutations">Permutations</a>
49
<h3 class="section">9.7 Reading and writing permutations</h3>
51
<p>The library provides functions for reading and writing permutations to a
52
file as binary data or formatted text.
55
— Function: int <b>gsl_permutation_fwrite</b> (<var>FILE * stream, const gsl_permutation * p</var>)<var><a name="index-gsl_005fpermutation_005ffwrite-981"></a></var><br>
56
<blockquote><p>This function writes the elements of the permutation <var>p</var> to the
57
stream <var>stream</var> in binary format. The function returns
58
<code>GSL_EFAILED</code> if there was a problem writing to the file. Since the
59
data is written in the native binary format it may not be portable
60
between different architectures.
61
</p></blockquote></div>
64
— Function: int <b>gsl_permutation_fread</b> (<var>FILE * stream, gsl_permutation * p</var>)<var><a name="index-gsl_005fpermutation_005ffread-982"></a></var><br>
65
<blockquote><p>This function reads into the permutation <var>p</var> from the open stream
66
<var>stream</var> in binary format. The permutation <var>p</var> must be
67
preallocated with the correct length since the function uses the size of
68
<var>p</var> to determine how many bytes to read. The function returns
69
<code>GSL_EFAILED</code> if there was a problem reading from the file. The
70
data is assumed to have been written in the native binary format on the
72
</p></blockquote></div>
75
— Function: int <b>gsl_permutation_fprintf</b> (<var>FILE * stream, const gsl_permutation * p, const char * format</var>)<var><a name="index-gsl_005fpermutation_005ffprintf-983"></a></var><br>
76
<blockquote><p>This function writes the elements of the permutation <var>p</var>
77
line-by-line to the stream <var>stream</var> using the format specifier
78
<var>format</var>, which should be suitable for a type of <var>size_t</var>. On a
79
GNU system the type modifier <code>Z</code> represents <code>size_t</code>, so
80
<code>"%Zu\n"</code> is a suitable format. The function returns
81
<code>GSL_EFAILED</code> if there was a problem writing to the file.
82
</p></blockquote></div>
85
— Function: int <b>gsl_permutation_fscanf</b> (<var>FILE * stream, gsl_permutation * p</var>)<var><a name="index-gsl_005fpermutation_005ffscanf-984"></a></var><br>
86
<blockquote><p>This function reads formatted data from the stream <var>stream</var> into the
87
permutation <var>p</var>. The permutation <var>p</var> must be preallocated with
88
the correct length since the function uses the size of <var>p</var> to
89
determine how many numbers to read. The function returns
90
<code>GSL_EFAILED</code> if there was a problem reading from the file.
91
</p></blockquote></div>