This file is indexed.

/usr/share/doc/mathgl/mathgl_en/mathgl_en_12.html is in mathgl-doc-en 2.1.3.1-4ubuntu3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- This manual is for MathGL (version 2.1.2), a collection of classes and routines for scientific plotting. Please report any errors in this manual to mathgl.abalakin@gmail.org.

Copyright C 2008-2012 Alexey A. Balakin.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.2
or any later version published by the Free Software Foundation;
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts.  A copy of the license is included in the section entitled "GNU
Free Documentation License."


 -->
<!-- Created on December 22, 2013 by texi2html 1.82
texi2html was written by: 
            Lionel Cons <Lionel.Cons@cern.ch> (original author)
            Karl Berry  <karl@freefriends.org>
            Olaf Bachmann <obachman@mathematik.uni-kl.de>
            and many others.
Maintained by: Many creative people.
Send bugs and suggestions to <texi2html-bug@nongnu.org>
-->
<head>
<title>MathGL 2.1.2: 2.3 Data handling</title>

<meta name="description" content="MathGL 2.1.2: 2.3 Data handling">
<meta name="keywords" content="MathGL 2.1.2: 2.3 Data handling">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.82">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.roman {font-family:serif; font-weight:normal;}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
-->
</style>


</head>

<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">

<a name="Data-handling"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="mathgl_en_11.html#Cutting-sample" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Array-creation" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Data-handling-1"></a>
<h2 class="section">2.3 Data handling</h2>

<p>Class <code>mglData</code> contains all functions for the data handling in MathGL (see section <a href="mathgl_en_51.html#Data-processing">Data processing</a>). There are several matters why I use class <code>mglData</code> but not a single array: it does not depend on type of data (mreal or double), sizes of data arrays are kept with data, memory working is simpler and safer.
</p>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#Array-creation">2.3.1 Array creation</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Linking-array">2.3.2 Linking array</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
<tr><td align="left" valign="top"><a href="#Change-data">2.3.3 Change data</a></td><td>&nbsp;&nbsp;</td><td align="left" valign="top">
</td></tr>
</table>

<hr size="6">
<a name="Array-creation"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Data-handling" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Linking-array" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Data-handling" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Array-creation-1"></a>
<h3 class="subsection">2.3.1 Array creation</h3>

<p>There are many ways in MathGL how data arrays can be created and filled.
</p>
<p>One can put the data in <code>mglData</code> instance by several ways. Let us do it for sinus function:
</p><ul>
<li>
one can create external array, fill it and put to <code>mglData</code> variable
<pre class="verbatim">  double *a = new double[50];
  for(int i=0;i&lt;50;i++)   a[i] = sin(M_PI*i/49.);

  mglData y;
  y.Set(a,50);
</pre>
</li><li>
another way is to create <code>mglData</code> instance of the desired size and then to work directly with data in this variable
<pre class="verbatim">  mglData y(50);
  for(int i=0;i&lt;50;i++)   y.a[i] = sin(M_PI*i/49.);
</pre>
</li><li>
next way is to fill the data in <code>mglData</code> instance by textual formula with the help of <code>Modify()</code> function
<pre class="verbatim">  mglData y(50);
  y.Modify(&quot;sin(pi*x)&quot;);
</pre>
</li><li>
or one may fill the array in some interval and modify it later
<pre class="verbatim">  mglData y(50);
  y.Fill(0,M_PI);
  y.Modify(&quot;sin(u)&quot;);
</pre>
</li><li>
finally it can be loaded from file
<pre class="verbatim">  FILE *fp=fopen(&quot;sin.dat&quot;,&quot;wt&quot;);   // create file first
  for(int i=0;i&lt;50;i++)   fprintf(fp,&quot;%g\n&quot;,sin(M_PI*i/49.));
  fclose(fp);

  mglData y(&quot;sin.dat&quot;);             // load it
</pre><p>At this you can use textual or HDF files, as well as import values from bitmap image (PNG is supported right now).
</p>
</li><li>
at this one can read only part of data
<pre class="verbatim">  FILE *fp-fopen(&quot;sin.dat&quot;,&quot;wt&quot;);   // create large file first
  for(int i=0;i&lt;70;i++)   fprintf(fp,&quot;%g\n&quot;,sin(M_PI*i/49.));
  fclose(fp);

  mglData y;
  y.Read(&quot;sin.dat&quot;,50);             // load it
</pre></li></ul>

<p>Creation of 2d- and 3d-arrays is mostly the same. But one should keep in mind that class <code>mglData</code> uses flat data representation. For example, matrix 30*40 is presented as flat (1d-) array with length 30*40=1200 (nx=30, ny=40). The element with indexes {i,j} is a[i+nx*j]. So for 2d array we have:
</p><pre class="verbatim">  mglData z(30,40);
  for(int i=0;i&lt;30;i++)   for(int j=0;j&lt;40;j++)
    z.a[i+30*j] = sin(M_PI*i/29.)*sin(M_PI*j/39.);
</pre><p>or by using <code>Modify()</code> function
</p><pre class="verbatim">  mglData z(30,40);
  z.Modify(&quot;sin(pi*x)*cos(pi*y)&quot;);
</pre>
<p>The only non-obvious thing here is using multidimensional arrays in C/C++, i.e. arrays defined like <code>mreal dat[40][30];</code>. Since, formally these elements <code>dat[i]</code> can address the memory in arbitrary place you should use the proper function to convert such arrays to <code>mglData</code> object. For C++ this is functions like <code>mglData::Set(mreal **dat, int N1, int N2);</code>. For C this is functions like <code>mgl_data_set_mreal2(HMDT d, const mreal **dat, int N1, int N2);</code>. At this, you should keep in mind that <code>nx=N2</code> and <code>ny=N1</code> after conversion.
</p>
<hr size="6">
<a name="Linking-array"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Array-creation" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Change-data" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Data-handling" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Linking-array-1"></a>
<h3 class="subsection">2.3.2 Linking array</h3>

<p>Sometimes the data arrays are so large, that one couldn&rsquo;t&rsquo; copy its values to another array (i.e. into mglData). In this case, he can define its own class derived from <code>mglDataA</code> (see <a href="mathgl_en_75.html#mglDataA-class">User defined types (mglDataA class)</a>) or can use <code>Link</code> function.
</p>
<p>In last case, MathGL just save the link to an external data array, but not copy it. You should provide the existence of this data array for whole time during which MathGL can use it. Another point is that MathGL will automatically create new array if you&rsquo;ll try to modify data values by any of <code>mglData</code> functions. So, you should use only function with <code>const</code> modifier if you want still using link to the original data array.
</p>
<p>Creating the link is rather simple &ndash; just the same as using <code>Set</code> function
</p><pre class="verbatim">  double *a = new double[50];
  for(int i=0;i&lt;50;i++)   a[i] = sin(M_PI*i/49.);

  mglData y;
  y.Link(a,50);
</pre>
<hr size="6">
<a name="Change-data"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Linking-array" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_13.html#Data-plotting" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Data-handling" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> &gt;&gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="mathgl_en.html#Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_88.html#Index" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<a name="Change-data-1"></a>
<h3 class="subsection">2.3.3 Change data</h3>

<p>MathGL has functions for data processing: differentiating, integrating, smoothing and so on (for more detail, see <a href="mathgl_en_51.html#Data-processing">Data processing</a>). Let us consider some examples. The simplest ones are integration and differentiation. The direction in which operation will be performed is specified by textual string, which may contain symbols &lsquo;<samp>x</samp>&rsquo;, &lsquo;<samp>y</samp>&rsquo; or &lsquo;<samp>z</samp>&rsquo;. For example, the call of <code>Diff(&quot;x&quot;)</code> will differentiate data along &lsquo;<samp>x</samp>&rsquo; direction; the call of <code>Integral(&quot;xy&quot;)</code> perform the double integration of data along &lsquo;<samp>x</samp>&rsquo; and &lsquo;<samp>y</samp>&rsquo; directions; the call of <code>Diff2(&quot;xyz&quot;)</code> will apply 3d Laplace operator to data and so on. Example of this operations on 2d array a=x*y is presented in code:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
  gr-&gt;SetRanges(0,1,0,1,0,1);
  mglData a(30,40); a.Modify(&quot;x*y&quot;);
  gr-&gt;SubPlot(2,2,0); gr-&gt;Rotate(60,40);
  gr-&gt;Surf(a);    gr-&gt;Box();
  gr-&gt;Puts(mglPoint(0.7,1,1.2),&quot;a(x,y)&quot;);
  gr-&gt;SubPlot(2,2,1); gr-&gt;Rotate(60,40);
  a.Diff(&quot;x&quot;);    gr-&gt;Surf(a);  gr-&gt;Box();
  gr-&gt;Puts(mglPoint(0.7,1,1.2),&quot;da/dx&quot;);
  gr-&gt;SubPlot(2,2,2); gr-&gt;Rotate(60,40);
  a.Integral(&quot;xy&quot;); gr-&gt;Surf(a);  gr-&gt;Box();
  gr-&gt;Puts(mglPoint(0.7,1,1.2),&quot;\\int da/dx dxdy&quot;);
  gr-&gt;SubPlot(2,2,3); gr-&gt;Rotate(60,40);
  a.Diff2(&quot;y&quot;); gr-&gt;Surf(a);  gr-&gt;Box();
  gr-&gt;Puts(mglPoint(0.7,1,1.2),&quot;\\int {d^2}a/dxdy dx&quot;);
  return 0;
}
</pre>
 <img src="../png/dat_diff.png" alt="Example of data differentiation and integration">

<p>Data smoothing (function <a href="mathgl_en_58.html#smooth">smooth</a>) is more interesting and important. This function has single argument which define type of smoothing and its direction. Now 3 methods are supported: &lsquo;<samp>3</samp>&rsquo; &ndash; linear averaging by 3 points, &lsquo;<samp>5</samp>&rsquo; &ndash; linear averaging by 5 points, and default one &ndash; quadratic averaging by 5 points.
</p>
<p>MathGL also have some amazing functions which is not so important for data processing as useful for data plotting. There are functions for finding envelope (useful for plotting rapidly oscillating data), for data sewing (useful to removing jumps on the phase), for data resizing (interpolation). Let me demonstrate it:
</p><pre class="verbatim">int sample(mglGraph *gr)
{
  gr-&gt;SubPlot(2,2,0,&quot;&quot;);  gr-&gt;Title(&quot;Envelop sample&quot;);
  mglData d1(1000); gr-&gt;Fill(d1,&quot;exp(-8*x^2)*sin(10*pi*x)&quot;);
  gr-&gt;Axis();     gr-&gt;Plot(d1, &quot;b&quot;);
  d1.Envelop('x');  gr-&gt;Plot(d1, &quot;r&quot;);

  gr-&gt;SubPlot(2,2,1,&quot;&quot;);  gr-&gt;Title(&quot;Smooth sample&quot;);
  mglData y0(30),y1,y2,y3;
  gr-&gt;SetRanges(0,1,0,1);
  gr-&gt;Fill(y0, &quot;0.4*sin(pi*x) + 0.3*cos(1.5*pi*x) - 0.4*sin(2*pi*x)+0.5*rnd&quot;);

  y1=y0;  y1.Smooth(&quot;x3&quot;);
  y2=y0;  y2.Smooth(&quot;x5&quot;);
  y3=y0;  y3.Smooth(&quot;x&quot;);

  gr-&gt;Plot(y0,&quot;{m7}:s&quot;, &quot;legend 'none'&quot;); //gr-&gt;AddLegend(&quot;none&quot;,&quot;k&quot;);
  gr-&gt;Plot(y1,&quot;r&quot;, &quot;legend ''3' style'&quot;);
  gr-&gt;Plot(y2,&quot;g&quot;, &quot;legend ''5' style'&quot;);
  gr-&gt;Plot(y3,&quot;b&quot;, &quot;legend 'default'&quot;);
  gr-&gt;Legend();   gr-&gt;Box();

  gr-&gt;SubPlot(2,2,2);   gr-&gt;Title(&quot;Sew sample&quot;);
  mglData d2(100, 100); gr-&gt;Fill(d2, &quot;mod((y^2-(1-x)^2)/2,0.1)&quot;);
  gr-&gt;Rotate(50, 60);   gr-&gt;Light(true);  gr-&gt;Alpha(true);
  gr-&gt;Box();            gr-&gt;Surf(d2, &quot;b&quot;);
  d2.Sew(&quot;xy&quot;, 0.1);  gr-&gt;Surf(d2, &quot;r&quot;);

  gr-&gt;SubPlot(2,2,3);   gr-&gt;Title(&quot;Resize sample (interpolation)&quot;);
  mglData x0(10), v0(10), x1, v1;
  gr-&gt;Fill(x0,&quot;rnd&quot;);     gr-&gt;Fill(v0,&quot;rnd&quot;);
  x1 = x0.Resize(100);    v1 = v0.Resize(100);
  gr-&gt;Plot(x0,v0,&quot;b+ &quot;);  gr-&gt;Plot(x1,v1,&quot;r-&quot;);
  gr-&gt;Label(x0,v0,&quot;%n&quot;);
  return 0;
}
</pre>
 <img src="../png/dat_extra.png" alt="Example of data manipulation">

<p>Also one can create new data arrays on base of the existing one: extract slice, row or column of data (<a href="mathgl_en_57.html#subdata">subdata</a>), summarize along a direction(s) (<a href="mathgl_en_57.html#sum">sum</a>), find distribution of data elements (<a href="mathgl_en_57.html#hist">hist</a>) and so on.
</p>
<p><a name="Solve-sample"></a>
Another interesting feature of MathGL is interpolation and root-finding. There are several functions for linear and cubic spline interpolation (see <a href="mathgl_en_59.html#Interpolation">Interpolation</a>). Also there is a function <a href="mathgl_en_57.html#evaluate">evaluate</a> which do interpolation of data array for values of each data element of index data. It look as indirect access to the data elements.
</p>
<p>This function have inverse function <a href="mathgl_en_57.html#solve">solve</a> which find array of indexes at which data array is equal to given value (i.e. work as root finding). But <a href="mathgl_en_57.html#solve">solve</a> function have the issue &ndash; usually multidimensional data (2d and 3d ones) have an infinite number of indexes which give some value. This is contour lines for 2d data, or isosurface(s) for 3d data. So, <a href="mathgl_en_57.html#solve">solve</a> function will return index only in given direction, assuming that other index(es) are the same as equidistant index(es) of original data. If data have multiple roots then second (and later) branches can be found by consecutive call(s) of <a href="mathgl_en_57.html#solve">solve</a> function.  Let me demonstrate this on the following sample.
</p>
<pre class="verbatim">int sample(mglGraph *gr)
{
  gr-&gt;SetRange('z',0,1);
  mglData x(20,30), y(20,30), z(20,30), xx,yy,zz;
  gr-&gt;Fill(x,&quot;(x+2)/3*cos(pi*y)&quot;);
  gr-&gt;Fill(y,&quot;(x+2)/3*sin(pi*y)&quot;);
  gr-&gt;Fill(z,&quot;exp(-6*x^2-2*sin(pi*y)^2)&quot;);

  gr-&gt;SubPlot(2,1,0); gr-&gt;Title(&quot;Cartesian space&quot;);   gr-&gt;Rotate(30,-40);
  gr-&gt;Axis(&quot;xyzU&quot;);   gr-&gt;Box();  gr-&gt;Label('x',&quot;x&quot;); gr-&gt;Label('y',&quot;y&quot;);
  gr-&gt;SetOrigin(1,1); gr-&gt;Grid(&quot;xy&quot;);
  gr-&gt;Mesh(x,y,z);

  // section along 'x' direction
  mglData u = x.Solve(0.5,'x');
  mglData v(u.nx);  v.Fill(0,1);
  xx = x.Evaluate(u,v);   yy = y.Evaluate(u,v);   zz = z.Evaluate(u,v);
  gr-&gt;Plot(xx,yy,zz,&quot;k2o&quot;);

  // 1st section along 'y' direction
  mglData u1 = x.Solve(-0.5,'y');
  mglData v1(u1.nx);  v1.Fill(0,1);
  xx = x.Evaluate(v1,u1); yy = y.Evaluate(v1,u1); zz = z.Evaluate(v1,u1);
  gr-&gt;Plot(xx,yy,zz,&quot;b2^&quot;);

  // 2nd section along 'y' direction
  mglData u2 = x.Solve(-0.5,'y',u1);
  xx = x.Evaluate(v1,u2); yy = y.Evaluate(v1,u2); zz = z.Evaluate(v1,u2);
  gr-&gt;Plot(xx,yy,zz,&quot;r2v&quot;);

  gr-&gt;SubPlot(2,1,1); gr-&gt;Title(&quot;Accompanied space&quot;);
  gr-&gt;SetRanges(0,1,0,1); gr-&gt;SetOrigin(0,0);
  gr-&gt;Axis(); gr-&gt;Box();  gr-&gt;Label('x',&quot;i&quot;); gr-&gt;Label('y',&quot;j&quot;);
  gr-&gt;Grid(z,&quot;h&quot;);

  gr-&gt;Plot(u,v,&quot;k2o&quot;);    gr-&gt;Line(mglPoint(0.4,0.5),mglPoint(0.8,0.5),&quot;kA&quot;);
  gr-&gt;Plot(v1,u1,&quot;b2^&quot;);  gr-&gt;Line(mglPoint(0.5,0.15),mglPoint(0.5,0.3),&quot;bA&quot;);
  gr-&gt;Plot(v1,u2,&quot;r2v&quot;);  gr-&gt;Line(mglPoint(0.5,0.7),mglPoint(0.5,0.85),&quot;rA&quot;);
}
</pre>
 <img src="../png/solve.png" alt="Example of data interpolation and root finding">


<hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#Linking-array" title="Previous section in reading order"> &lt; </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_13.html#Data-plotting" title="Next section in reading order"> &gt; </a>]</td>
<td valign="middle" align="left"> &nbsp; </td>
<td valign="middle" align="left">[<a href="mathgl_en_9.html#Examples" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
<td valign="middle" align="left">[<a href="#Data-handling" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="mathgl_en_20.html#General-concepts" title="Next chapter"> &gt;&gt; </a>]</td>
</tr></table>
<p>
 <font size="-1">
  This document was generated by <em>Build Daemon user</em> on <em>December 22, 2013</em> using <a href="http://www.nongnu.org/texi2html/"><em>texi2html 1.82</em></a>.
 </font>
 <br>

</p>
</body>
</html>