Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 3e60ff9d4d6f58c8fbd17208f14089fa > files > 160

octave-doc-3.2.3-3mdv2010.0.i586.rpm

<html lang="en">
<head>
<title>Dynamically Linked Functions - Untitled</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="Untitled">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="prev" href="Packages.html#Packages" title="Packages">
<link rel="next" href="Test-and-Demo-Functions.html#Test-and-Demo-Functions" title="Test and Demo Functions">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Dynamically-Linked-Functions"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Test-and-Demo-Functions.html#Test-and-Demo-Functions">Test and Demo Functions</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Packages.html#Packages">Packages</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
<hr>
</div>

<h2 class="appendix">Appendix A Dynamically Linked Functions</h2>

<p><a name="index-dynamic_002dlinking-2468"></a>
Octave has the possibility of including compiled code as dynamically
linked extensions and then using these extensions as if they were part
of Octave itself.  Octave can call C++ code
through its native oct-file interface or C code through its mex
interface.  It can also indirectly call functions written in any other
language through a simple wrapper.  The reasons to write code in a
compiled language might be either to link to an existing piece of code
and allow it to be used within Octave, or to allow improved performance
for key pieces of code.

   <p>Before going further, you should first determine if you really need to
use dynamically linked functions at all.  Before proceeding with writing
any dynamically linked function to improve performance you should
address ask yourself

     <ul>
<li>Can I get the same functionality using the Octave scripting language only? 
<li>Is it thoroughly optimized Octave code?  Vectorization of Octave code,
doesn't just make it concise, it generally significantly improves its
performance.  Above all, if loops must be used, make sure that the
allocation of space for variables takes place outside the loops using an
assignment to a matrix of the right size, or zeros. 
<li>Does it make as much use as possible of existing built-in library
routines?  These are highly optimized and many do not carry the overhead
of being interpreted. 
<li>Does writing a dynamically linked function represent useful investment
of your time, relative to staying in Octave? 
</ul>

   <p>Also, as oct- and mex-files are dynamically linked to Octave, they
introduce the possibility of Octave crashing due to errors in
the user code.  For example a segmentation violation in the user's code
will cause Octave to abort.

<ul class="menu">
<li><a accesskey="1" href="Oct_002dFiles.html#Oct_002dFiles">Oct-Files</a>
<li><a accesskey="2" href="Mex_002dFiles.html#Mex_002dFiles">Mex-Files</a>
<li><a accesskey="3" href="Standalone-Programs.html#Standalone-Programs">Standalone Programs</a>
</ul>

   </body></html>