[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: about "Dynamically Linked Functions"

From: geraint
Subject: Re: about "Dynamically Linked Functions"
Date: Wed, 9 Apr 2003 12:51:50 +0000

> From: myong <address@hidden>
> Date: Wed 09/Apr/2003 09:03 GMT
> To: octave <address@hidden>
> Subject: about "Dynamically Linked Functions"
> Where can I get more detail information about dynamically linked 
> functions, especially the passing o farguments.

A good starting place is It is 
also highly recommended that you take a look at the examples included in the 
octave source code, such as

In answer to the specific question about argument passing, arguments are passed 
to dynamically loaded functions packaged within an octave_value_list, as the 
second argument to the function. The objects then need to be extracted into 
appropriate containers (e.g. column_vector_value) before use. An 
octave_value_list is also returned from the function, so it is possible to 
return more than one object back to Octave.

The following example may serve to illustrate the method.

== ==

#include <octave/oct.h>

DEFUN_DLD (myoct, args, , "dummy function")
  octave_value_list retval;
  int nargin = args.length();

  if (nargin != 2)
    error("Require 2 input arguments");

  ColumnVector a = args(0).column_vector_value();
  ColumnVector b = args(1).column_vector_value();

  if (a.length() != b.length())
    error("Input vectors not of same length");

  ColumnVector c = a + b;
  ColumnVector d = a - b;

  retval(0) = c;
  retval(1) = d;

  return retval;

$ mkoctfile
$ octave -q
octave:1> [ c , d ] = myoct ( [ 1 ; 2 ] , [ 3 ; 4 ] )
c =


d =



Hope this helps,

Join Freeserve

Winner of the 2003 Internet Service Providers' Association awards for Best 
Unmetered ISP and Best Consumer Application.

Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:
How to fund new projects:
Subscription information:

reply via email to

[Prev in Thread] Current Thread [Next in Thread]