123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
- <html>
- <!-- Created on November 8, 2012 by texi2html 1.82
- texi2html was written by:
- Lionel Cons <[email protected]> (original author)
- Karl Berry <[email protected]>
- Olaf Bachmann <[email protected]>
- and many others.
- Maintained by: Many creative people.
- Send bugs and suggestions to <[email protected]>
- -->
- <head>
- <title>avram - a virtual machine code interpreter: 3.1.4.4 Related utility functions</title>
- <meta name="description" content="avram - a virtual machine code interpreter: 3.1.4.4 Related utility functions">
- <meta name="keywords" content="avram - a virtual machine code interpreter: 3.1.4.4 Related utility functions">
- <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="Related-utility-functions"></a>
- <table cellpadding="1" cellspacing="1" border="0">
- <tr><td valign="middle" align="left">[<a href="Two-dimensional-arrays.html#Two-dimensional-arrays" title="Previous section in reading order"> < </a>]</td>
- <td valign="middle" align="left">[<a href="Comparison.html#Comparison" title="Next section in reading order"> > </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> << </a>]</td>
- <td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Up section"> Up </a>]</td>
- <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> >> </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
- <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
- <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
- <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
- </tr></table>
- <hr size="1">
- <a name="Related-utility-functions-1"></a>
- <h4 class="subsubsection">3.1.4.4 Related utility functions</h4>
- <p>A small selection of additional functions that are likely to be of use
- to developers concerned with matrix operations has been incorporated
- into the API to save the trouble of reinventing them, although doing
- so would be straightforward. They are described in this section
- without further motivation.
- </p>
- <dl>
- <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>
- <dd><p>This function takes the address of an arbitrary rectangular
- <var>matrix</var> represented as a contiguous array (not a list) and
- transposes it in place. That is, this function transforms
- an <var>m</var> by <var>n</var> matrix to an <var>n</var> by <var>m</var> matrix
- by exchanging the <var>i</var>,<var>j</var>th element with the
- <var>j</var>,<var>i</var>th element for all values of <var>i</var> and <var>j</var>.
- </p>
- <p>The numbers of rows and columns in the <var>matrix</var> are given by the
- parameters <var>rows</var> and <var>cols</var>, respectively, and the size of
- the entries in bytes is given by <var>item_size</var>.
- </p>
- <p>The <var>matrix</var> is assumed to be in row major order, but this
- function is applicable to matrices in column major order if the caller
- <a name="index-column-major-order-2"></a>
- passes the number of columns in <var>rows</var> and the number of rows in
- <var>cols</var>.
- </p>
- <p>Alternatively, this function can be seen as a conversion between the
- row major and the column major representation of a matrix. An <var>m</var>
- by <var>n</var> matrix in row major order will be transformed to the same
- <var>m</var> by <var>n</var> matrix in column order, or from column order to row
- order.
- </p>
- <p>A notable feature of this function is that it allocates no memory so
- there is no possibility of a memory overflow even for very large
- matrices, unlike a naive implementation which would involve making a
- temporary copy of the matrix. There is a possibility of a segmentation
- <a name="index-segmentation-fault-5"></a>
- fault if invalid pointers or dimensions are given.
- </p></dd></dl>
- <dl>
- <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>
- <dd><p>This function takes a symmetric square <var>matrix</var> of dimension
- <var>n</var> containing entries of <var>item_size</var> bytes each and fills in
- the redundant entries.
- </p>
- <p>If <var>upper_triangular</var> is non-zero, the
- upper triangle of the <var>matrix</var> is copied to the lower triangle. If
- <var>upper_triangular</var> is zero, the lower triangular entries are
- copied to the upper triangle.
- </p>
- <p>These conventions assume row major order. If the <var>matrix</var> is in
- <a name="index-row-major-order"></a>
- column major order, then the caller can either transpose it in place
- <a name="index-column-major-order-3"></a>
- before and after this function by <code>avm_matrix_transposition</code>, or
- can complement the value of <var>upper_triangular</var>.
- </p>
- <p>Note that this function may be unnecessary for <code>LAPACK</code> library
- functions that ignore the redundant entries in a symmetric matrix,
- because they can be left uninitialized, but it is included for the
- sake of completeness.
- </p></dd></dl>
- <dl>
- <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>
- <dd><p>A fast, memory efficient finite map from natural numbers to their list
- representations can be obtained by using this function as an
- alternative to <code>avm_natural</code> or <code>avm_recoverable_natural</code>
- when repeated evaluations of numbers within a known range are
- required (<a href="Simple-Operations.html#Simple-Operations">Simple Operations</a> and <a href="Recoverable-Operations.html#Recoverable-Operations">Recoverable Operations</a>).
- </p>
- <p>Given a positive integer <var>m</var>, this function allocates and returns
- an array of <var>m</var> lists whose <var>i</var>th entry is the list
- representation of the number <var>i</var> as explained in
- <a href="Representation-of-Numeric-and-Textual-Data.html#Representation-of-Numeric-and-Textual-Data">Representation of Numeric and Textual Data</a>.
- </p>
- <p>An amount of memory proportional to <var>m</var> is used for the array and
- its contents. If there is insufficient memory, a <code>NULL</code> value is
- returned and the integer referenced by <var>fault</var> is set to a
- non-zero value.
- </p></dd></dl>
- <dl>
- <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>
- <dd><p>This function reclaims an array <var>row_number</var> of size <var>m</var>
- returned by <code>avm_row_number_array</code>, and its contents if any. A
- <code>NULL</code> pointer is allowed as the <var>row_number</var> parameter and
- will have no effect, but an uninitialized pointer will cause a
- <a name="index-segmentation-fault-6"></a>
- segmentation fault.
- </p></dd></dl>
- <dl>
- <dt><a name="index-avm_005finitialize_005fmatcon"></a><u>Function:</u> void <b>avm_initialize_matcon</b><i> ();</i></dt>
- <dd><p>This function initializes some static variables used by the functions
- declared in ‘<tt>matcon.h</tt>’ and should be called before any of them is
- called or they might not perform according to specifications.
- </p></dd></dl>
- <dl>
- <dt><a name="index-avm_005fcount_005fmatcon"></a><u>Function:</u> void <b>avm_count_matcon</b><i> ();</i></dt>
- <dd><p>This function frees the static variables allocated by
- <code>avm_initialize_matcon</code> and is used to verify the absence of
- memory leaks. It should be called after the last call to any functions
- in ‘<tt>matcon.h</tt>’ but before <code>avm_count_lists</code> if the latter
- is being used (<a href="Simple-Operations.html#Simple-Operations">Simple Operations</a>).
- </p></dd></dl>
- <hr size="1">
- <table cellpadding="1" cellspacing="1" border="0">
- <tr><td valign="middle" align="left">[<a href="Two-dimensional-arrays.html#Two-dimensional-arrays" title="Previous section in reading order"> < </a>]</td>
- <td valign="middle" align="left">[<a href="Comparison.html#Comparison" title="Next section in reading order"> > </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="Library-Reference.html#Library-Reference" title="Beginning of this chapter or previous chapter"> << </a>]</td>
- <td valign="middle" align="left">[<a href="Type-Conversions.html#Type-Conversions" title="Up section"> Up </a>]</td>
- <td valign="middle" align="left">[<a href="Character-Table.html#Character-Table" title="Next chapter"> >> </a>]</td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left"> </td>
- <td valign="middle" align="left">[<a href="avram.html#Top" title="Cover (top) of document">Top</a>]</td>
- <td valign="middle" align="left">[<a href="avram_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
- <td valign="middle" align="left">[<a href="Function-Index.html#Function-Index" title="Index">Index</a>]</td>
- <td valign="middle" align="left">[<a href="avram_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
- </tr></table>
- <p>
- <font size="-1">
- This document was generated on <i>November 8, 2012</i> using <a href="http://www.nongnu.org/texi2html/"><i>texi2html 1.82</i></a>.
- </font>
- <br>
- </p>
- </body>
- </html>
|