| 1 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Reference</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="Příručka k aplikaci Genius"><link rel="up" href="ch06.html" title="Chapter 6. Programování s jazykem GEL"><link rel="prev" href="ch06s07.html" title="Návrat hodnot"><link rel="next" href="ch06s09.html" title="L-hodnoty"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Reference</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch06s07.html">Prev</a> </td><th width="60%" align="center">Chapter 6. Programování s jazykem GEL</th><td width="20%" align="right"> <a accesskey="n" href="ch06s09.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="genius-gel-references"></a>Reference</h2></div></div></div><p>Pro některé funkce je nutné, aby vracely více než jednu hodnotu. To lze zajistit vrácením vektoru hodnot, ale častokrát je praktičtější použít předávání reference (odkazu) na proměnnou. Předáte funkci referenci na proměnnou a funkce proměnnou nastaví pomocí dereference. Nemusíte se s používáním referencí omezovat jen na tento účel, ale tohle je jejich hlavní využití.</p><p lang="en"> |
| 2 | When using functions that return values through references |
| 3 | in the argument list, just pass the variable name with an ampersand. |
| 4 | For example the following code will compute an eigenvalue of a matrix |
| 5 | <code class="varname">A</code> with initial eigenvector guess |
| 6 | <code class="varname">x</code>, and store the computed eigenvector |
| 7 | into the variable named <code class="varname">v</code>: |
| 8 | </p><pre lang="en" class="programlisting">RayleighQuotientIteration (A,x,0.001,100,&v) |
| 9 | </pre><p lang="en"> |
| 10 | </p><p>V detailech fungování a syntaxi jsou reference podobné jako v jazyku C. Operátor <code class="literal">&</code> odkazuje na proměnnou a <code class="literal">*</code> provádí dereferenci proměnné. Obojí lze uplatnit pouze na identifikátory, takže <code class="literal">**a</code> není v jazyce GEL platný výraz.</p><p lang="en"> |
| 11 | References are best explained by an example: |
| 12 | </p><pre lang="en" class="programlisting">a=1; |
| 13 | b=&a; |
| 14 | *b=2; |
| 15 | </pre><p lang="en"> |
| 16 | now <code class="varname">a</code> contains 2. You can also reference functions: |
| 17 | </p><pre lang="en" class="programlisting">function f(x) = x+1; |
| 18 | t=&f; |
| 19 | *t(3) |
| 20 | </pre><p lang="en"> |
| 21 | gives us 4. |
| 22 | </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch06s07.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch06.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ch06s09.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Návrat hodnot </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> L-hodnoty</td></tr></table></div></body></html> |