Related-utility-functions.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
  2. <html>
  3. <!-- Created on November 8, 2012 by texi2html 1.82
  4. texi2html was written by:
  5. Lionel Cons <[email protected]> (original author)
  6. Karl Berry <[email protected]>
  7. Olaf Bachmann <[email protected]>
  8. and many others.
  9. Maintained by: Many creative people.
  10. Send bugs and suggestions to <[email protected]>
  11. -->
  12. <head>
  13. <title>avram - a virtual machine code interpreter: 3.1.4.4 Related utility functions</title>
  14. <meta name="description" content="avram - a virtual machine code interpreter: 3.1.4.4 Related utility functions">
  15. <meta name="keywords" content="avram - a virtual machine code interpreter: 3.1.4.4 Related utility functions">
  16. <meta name="resource-type" content="document">
  17. <meta name="distribution" content="global">
  18. <meta name="Generator" content="texi2html 1.82">
  19. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  20. <style type="text/css">
  21. <!--
  22. a.summary-letter {text-decoration: none}
  23. blockquote.smallquotation {font-size: smaller}
  24. pre.display {font-family: serif}
  25. pre.format {font-family: serif}
  26. pre.menu-comment {font-family: serif}
  27. pre.menu-preformatted {font-family: serif}
  28. pre.smalldisplay {font-family: serif; font-size: smaller}
  29. pre.smallexample {font-size: smaller}
  30. pre.smallformat {font-family: serif; font-size: smaller}
  31. pre.smalllisp {font-size: smaller}
  32. span.roman {font-family:serif; font-weight:normal;}
  33. span.sansserif {font-family:sans-serif; font-weight:normal;}
  34. ul.toc {list-style: none}
  35. -->
  36. </style>
  37. </head>
  38. <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
  39. <a name="Related-utility-functions"></a>
  40. <table cellpadding="1" cellspacing="1" border="0">
  41. <tr><td valign="middle" align="left">[<a href="Two-dimensional-arrays.html#Two-dimensional-arrays" title="Previous section in reading order"> &lt; </a>]</td>
  42. <td valign="middle" align="left">[<a href="Comparison.html#Comparison" title="Next section in reading order"> &gt; </a>]</td>
  43. <td valign="middle" align="left"> &nbsp; </td>
  44. <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
  45. <td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Up section"> Up </a>]</td>
  46. <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> &gt;&gt; </a>]</td>
  47. <td valign="middle" align="left"> &nbsp; </td>
  48. <td valign="middle" align="left"> &nbsp; </td>
  49. <td valign="middle" align="left"> &nbsp; </td>
  50. <td valign="middle" align="left"> &nbsp; </td>
  51. <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
  52. <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
  53. <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
  54. <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
  55. </tr></table>
  56. <hr size="1">
  57. <a name="Related-utility-functions-1"></a>
  58. <h4 class="subsubsection">3.1.4.4 Related utility functions</h4>
  59. <p>A small selection of additional functions that are likely to be of use
  60. to developers concerned with matrix operations has been incorporated
  61. into the API to save the trouble of reinventing them, although doing
  62. so would be straightforward. They are described in this section
  63. without further motivation.
  64. </p>
  65. <dl>
  66. <dt><a name="index-_002aavm_005fmatrix_005ftransposition"></a><u>Function:</u> void <b>*avm_matrix_transposition</b><i> (void *<var>matrix</var>, int <var>rows</var>, int <var>cols</var>, size_t <var>item_size</var>)</i></dt>
  67. <dd><p>This function takes the address of an arbitrary rectangular
  68. <var>matrix</var> represented as a contiguous array (not a list) and
  69. transposes it in place. That is, this function transforms
  70. an <var>m</var> by <var>n</var> matrix to an <var>n</var> by <var>m</var> matrix
  71. by exchanging the <var>i</var>,<var>j</var>th element with the
  72. <var>j</var>,<var>i</var>th element for all values of <var>i</var> and <var>j</var>.
  73. </p>
  74. <p>The numbers of rows and columns in the <var>matrix</var> are given by the
  75. parameters <var>rows</var> and <var>cols</var>, respectively, and the size of
  76. the entries in bytes is given by <var>item_size</var>.
  77. </p>
  78. <p>The <var>matrix</var> is assumed to be in row major order, but this
  79. function is applicable to matrices in column major order if the caller
  80. <a name="index-column-major-order-2"></a>
  81. passes the number of columns in <var>rows</var> and the number of rows in
  82. <var>cols</var>.
  83. </p>
  84. <p>Alternatively, this function can be seen as a conversion between the
  85. row major and the column major representation of a matrix. An <var>m</var>
  86. by <var>n</var> matrix in row major order will be transformed to the same
  87. <var>m</var> by <var>n</var> matrix in column order, or from column order to row
  88. order.
  89. </p>
  90. <p>A notable feature of this function is that it allocates no memory so
  91. there is no possibility of a memory overflow even for very large
  92. matrices, unlike a naive implementation which would involve making a
  93. temporary copy of the matrix. There is a possibility of a segmentation
  94. <a name="index-segmentation-fault-5"></a>
  95. fault if invalid pointers or dimensions are given.
  96. </p></dd></dl>
  97. <dl>
  98. <dt><a name="index-_002aavm_005fmatrix_005freflection"></a><u>Function:</u> void <b>*avm_matrix_reflection</b><i> (int <var>upper_triangular</var>, void *<var>matrix</var>, int <var>n</var>, size_t <var>item_size</var>)</i></dt>
  99. <dd><p>This function takes a symmetric square <var>matrix</var> of dimension
  100. <var>n</var> containing entries of <var>item_size</var> bytes each and fills in
  101. the redundant entries.
  102. </p>
  103. <p>If <var>upper_triangular</var> is non-zero, the
  104. upper triangle of the <var>matrix</var> is copied to the lower triangle. If
  105. <var>upper_triangular</var> is zero, the lower triangular entries are
  106. copied to the upper triangle.
  107. </p>
  108. <p>These conventions assume row major order. If the <var>matrix</var> is in
  109. <a name="index-row-major-order"></a>
  110. column major order, then the caller can either transpose it in place
  111. <a name="index-column-major-order-3"></a>
  112. before and after this function by <code>avm_matrix_transposition</code>, or
  113. can complement the value of <var>upper_triangular</var>.
  114. </p>
  115. <p>Note that this function may be unnecessary for <code>LAPACK</code> library
  116. functions that ignore the redundant entries in a symmetric matrix,
  117. because they can be left uninitialized, but it is included for the
  118. sake of completeness.
  119. </p></dd></dl>
  120. <dl>
  121. <dt><a name="index-_002aavm_005frow_005fnumber_005farray"></a><u>Function:</u> list <b>*avm_row_number_array</b><i> (counter <var>m</var>, int *<var>fault</var>)</i></dt>
  122. <dd><p>A fast, memory efficient finite map from natural numbers to their list
  123. representations can be obtained by using this function as an
  124. alternative to <code>avm_natural</code> or <code>avm_recoverable_natural</code>
  125. when repeated evaluations of numbers within a known range are
  126. required (<a href="Simple-Operations.html#Simple-Operations">Simple Operations</a> and <a href="Recoverable-Operations.html#Recoverable-Operations">Recoverable Operations</a>).
  127. </p>
  128. <p>Given a positive integer <var>m</var>, this function allocates and returns
  129. an array of <var>m</var> lists whose <var>i</var>th entry is the list
  130. representation of the number <var>i</var> as explained in
  131. <a href="Representation-of-Numeric-and-Textual-Data.html#Representation-of-Numeric-and-Textual-Data">Representation of Numeric and Textual Data</a>.
  132. </p>
  133. <p>An amount of memory proportional to <var>m</var> is used for the array and
  134. its contents. If there is insufficient memory, a <code>NULL</code> value is
  135. returned and the integer referenced by <var>fault</var> is set to a
  136. non-zero value.
  137. </p></dd></dl>
  138. <dl>
  139. <dt><a name="index-avm_005fdispose_005frows"></a><u>Function:</u> void <b>avm_dispose_rows</b><i> (counter <var>m</var>, list *<var>row_number</var>)</i></dt>
  140. <dd><p>This function reclaims an array <var>row_number</var> of size <var>m</var>
  141. returned by <code>avm_row_number_array</code>, and its contents if any. A
  142. <code>NULL</code> pointer is allowed as the <var>row_number</var> parameter and
  143. will have no effect, but an uninitialized pointer will cause a
  144. <a name="index-segmentation-fault-6"></a>
  145. segmentation fault.
  146. </p></dd></dl>
  147. <dl>
  148. <dt><a name="index-avm_005finitialize_005fmatcon"></a><u>Function:</u> void <b>avm_initialize_matcon</b><i> ();</i></dt>
  149. <dd><p>This function initializes some static variables used by the functions
  150. declared in &lsquo;<tt>matcon.h</tt>&rsquo; and should be called before any of them is
  151. called or they might not perform according to specifications.
  152. </p></dd></dl>
  153. <dl>
  154. <dt><a name="index-avm_005fcount_005fmatcon"></a><u>Function:</u> void <b>avm_count_matcon</b><i> ();</i></dt>
  155. <dd><p>This function frees the static variables allocated by
  156. <code>avm_initialize_matcon</code> and is used to verify the absence of
  157. memory leaks. It should be called after the last call to any functions
  158. in &lsquo;<tt>matcon.h</tt>&rsquo; but before <code>avm_count_lists</code> if the latter
  159. is being used (<a href="Simple-Operations.html#Simple-Operations">Simple Operations</a>).
  160. </p></dd></dl>
  161. <hr size="1">
  162. <table cellpadding="1" cellspacing="1" border="0">
  163. <tr><td valign="middle" align="left">[<a href="Two-dimensional-arrays.html#Two-dimensional-arrays" title="Previous section in reading order"> &lt; </a>]</td>
  164. <td valign="middle" align="left">[<a href="Comparison.html#Comparison" title="Next section in reading order"> &gt; </a>]</td>
  165. <td valign="middle" align="left"> &nbsp; </td>
  166. <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
  167. <td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Up section"> Up </a>]</td>
  168. <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> &gt;&gt; </a>]</td>
  169. <td valign="middle" align="left"> &nbsp; </td>
  170. <td valign="middle" align="left"> &nbsp; </td>
  171. <td valign="middle" align="left"> &nbsp; </td>
  172. <td valign="middle" align="left"> &nbsp; </td>
  173. <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
  174. <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
  175. <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
  176. <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
  177. </tr></table>
  178. <p>
  179. <font size="-1">
  180. This document was generated on <i>November 8, 2012</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 1.82</i></a>.
  181. </font>
  182. <br>
  183. </p>
  184. </body>
  185. </html>