One-dimensional-arrays.html 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
  2. <html>
  3. <!-- Created on December 10, 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.2 One dimensional arrays</title>
  14. <meta name="description" content="avram - a virtual machine code interpreter: 3.1.4.2 One dimensional arrays">
  15. <meta name="keywords" content="avram - a virtual machine code interpreter: 3.1.4.2 One dimensional arrays">
  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="One-dimensional-arrays"></a>
  40. <table cellpadding="1" cellspacing="1" border="0">
  41. <tr><td valign="middle" align="left">[<a href="Primitive-types.html#Primitive-types" title="Previous section in reading order"> &lt; </a>]</td>
  42. <td valign="middle" align="left">[<a href="Two-dimensional-arrays.html#Two-dimensional-arrays" 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="One-dimensional-arrays-1"></a>
  58. <h4 class="subsubsection">3.1.4.2 One dimensional arrays</h4>
  59. <p>A couple of functions declared in &lsquo;<tt>matcon.h</tt>&rsquo; are concerned mainly
  60. with one dimensional arrays or vectors. They have been used for
  61. <a name="index-arrays"></a>
  62. vectors of double precision and complex numbers, but are applicable to
  63. <a name="index-vectors"></a>
  64. any base type that is contiguous and of a fixed size.
  65. </p>
  66. <p>The motivation for these functions is to enable a developer to present
  67. an API to virtual code applications wherein external library functions
  68. operating natively on one dimensional arrays of numbers are seen from
  69. the virtual side to operate on lists of numbers. Lists are the
  70. preferred container for interoperability with virtual code
  71. applications.
  72. </p>
  73. <dl>
  74. <dt><a name="index-_002aavm_005fvector_005fof_005flist"></a><u>Function:</u> void <b>*avm_vector_of_list</b><i> (list <var>operand</var>, size_t <var>item_size</var>, list *<var>message</var>, int *<var>fault</var>)</i></dt>
  75. <dd><p>This function calls <code>avm_value_of_list</code> (<a href="Primitive-types.html#Primitive-types">Primitive types</a>)
  76. for each item of the <var>operand</var> and puts all the values together
  77. into one contiguous block, whose address is returned.
  78. </p>
  79. <p>The given <var>item_size</var> is required to be the lengths of the items,
  80. all necessarily equal, and is required only for validation. For
  81. example, <var>item_size</var> is 8 for a list of double precision numbers,
  82. because they occupy 8 bytes each and are represented as lists of length 8.
  83. </p>
  84. <p>The total number of bytes allocated is the product of <var>item_size</var>
  85. and the length of the <var>operand</var>. Unlike the case of
  86. <code>avm_value_of_list</code> (<a href="Primitive-types.html#Primitive-types">Primitive types</a>), the result returned
  87. by this function should be explicitly freed by the caller when no
  88. longer needed.
  89. </p>
  90. <p>Any errors such as insufficient memory cause the integer referenced by
  91. <var>fault</var> to be assigned a non-zero value and the <var>message</var> to
  92. be assigned an error message represented as a list of strings. An
  93. error message of <code>&lt;'bad vector specification'&gt;</code> is possible in
  94. the case of an empty <var>operand</var> or one whose item lengths don&rsquo;t
  95. match the given <var>item_size</var>. Error messages caused by
  96. <code>avm_value_of_list</code> can also be generated by this function. Any
  97. non-empty error message should be reclaimed by the caller using
  98. <code>avm_dispose</code> (<a href="Simple-Operations.html#Simple-Operations">Simple Operations</a>). If an error occurs, a
  99. <code>NULL</code> pointer is returned.
  100. </p></dd></dl>
  101. <dl>
  102. <dt><a name="index-avm_005flist_005fof_005fvector"></a><u>Function:</u> list <b>avm_list_of_vector</b><i> (void *<var>vector</var>, int <var>num_items</var>, size_t <var>item_size</var>, int *<var>fault</var>)</i></dt>
  103. <dd><p>This function takes it on faith that an array of dimension
  104. <var>num_items</var> in which each item occupies <var>item_size</var> bytes
  105. begins at the address given by <var>vector</var>. A list representation of
  106. each item in the array is constructed by the function
  107. <code>avm_list_of_value</code> (<a href="Primitive-types.html#Primitive-types">Primitive types</a>), and a list of all of
  108. the lists thus obtained in order of their position in the array is
  109. returned.
  110. </p>
  111. <p>In the event of any errors caused by <code>avm_list_of_value</code> or
  112. errors due to insufficient memory, the error message is returned as
  113. the function result, and the integer referenced by <var>fault</var> is
  114. assigned a non-zero value. The error message is in the form of a list
  115. of character string representations. A segmentation fault is possible
  116. <a name="index-segmentation-fault-3"></a>
  117. if <var>vector</var> is not a valid pointer or if the array size implied by
  118. misspecified values of <var>num_items</var> and <var>item_size</var>
  119. exceeds its actual size.
  120. </p></dd></dl>
  121. <hr size="1">
  122. <table cellpadding="1" cellspacing="1" border="0">
  123. <tr><td valign="middle" align="left">[<a href="Primitive-types.html#Primitive-types" title="Previous section in reading order"> &lt; </a>]</td>
  124. <td valign="middle" align="left">[<a href="Two-dimensional-arrays.html#Two-dimensional-arrays" title="Next section in reading order"> &gt; </a>]</td>
  125. <td valign="middle" align="left"> &nbsp; </td>
  126. <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> &lt;&lt; </a>]</td>
  127. <td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Up section"> Up </a>]</td>
  128. <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> &gt;&gt; </a>]</td>
  129. <td valign="middle" align="left"> &nbsp; </td>
  130. <td valign="middle" align="left"> &nbsp; </td>
  131. <td valign="middle" align="left"> &nbsp; </td>
  132. <td valign="middle" align="left"> &nbsp; </td>
  133. <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
  134. <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
  135. <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
  136. <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
  137. </tr></table>
  138. <p>
  139. <font size="-1">
  140. This document was generated on <i>December 10, 2012</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 1.82</i></a>.
  141. </font>
  142. <br>
  143. </p>
  144. </body>
  145. </html>