help-octave
[Top][All Lists]
Advanced

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

Re: Calling other functions from .oct files


From: Peter Williams
Subject: Re: Calling other functions from .oct files
Date: Thu, 1 May 2003 02:32:16 -0400
User-agent: KMail/1.5.1

Here's how I tried to get this working

#include <octave/oct.h>
#include <string.h>

using namespace std;
DEFUN_DLD (my_call_test, args, ,"Test a call")
     
{
  
  ColumnVector NumRands(2);
  NumRands(0) = 9000;
  NumRands(1) = 1;
  octave_value_list x, unis;
  x(0) = octave_value(NumRands);
  string ranfunc = "rand"
  unis = feval(ranfunc,x,1);
  
  return octave_value (unis);
  
}

Here's the error message that I'm getting

mkoctfile my_call_test.cpp
my_call_test.cpp: In function `octave_value_list Fmy_call_test(const
   octave_value_list&, int)':
my_call_test.cpp:15: parse error before `=' token

Do I need to include something else? I modified the snipet you sent me 
to declare unis as an octave_value_list, and line 15 is the one with 
the feval statement.

Thanks, 
Pete

On Thursday 01 May 2003 02:03, Heber Farnsworth wrote:
> Here is a code snipet that works (or did back when I wrote it)
>
>    ColumnVector NumRands(2);
>    NumRands(0) = 9000;
>    NumRands(1) = 1;
>    octave_value_list x;
>    x(0) = octave_value(NumRands);
>    string ranfunc = "rand"
>    unis = feval(ranfunc,x,1);
>
> Heber
>
> On Wednesday, April 30, 2003, at 10:32 PM, Peter Williams wrote:
> > Hi everyone,
> >     I'm starting to do some work with .oct files and I need a little
> > guidance.  The classes and structures document is very useful,
> > but what I want to do is call functions that I would normally use
> > in a .m from my C++ code.  I'm not really sure how to go about
> > this, or where to look in the source for examples.
> >     If someone could point me in the right direction or give me a
> > brief example of how you would call "randn" from C++ source.  I
> > know I can use numerical recipies inside my own code to
> > accomplish this, but I'm curious how/if I can access the rand.cc
> > source from my code.  Looked through Da Coda, but I didn't see
> > anything like this.
> >
> > Thanks,
> > Pete Williams
> >
> >
> >
> > -------------------------------------------------------------
> > Octave is freely available under the terms of the GNU GPL.
> >
> > Octave's home on the web:  http://www.octave.org
> > How to fund new projects:  http://www.octave.org/funding.html
> > Subscription information:  http://www.octave.org/archive.html
> > -------------------------------------------------------------



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

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

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