help-octave
[Top][All Lists]
Advanced

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

Re: How do you pass two Octave functions to an .oct function?


From: David Grundberg
Subject: Re: How do you pass two Octave functions to an .oct function?
Date: Sun, 18 Oct 2009 16:13:19 +0200
User-agent: Thunderbird 2.0.0.23 (X11/20090817)

babelproofreader skrev:
I'd think these messages are pretty understandable.
You simply can't pass a raw double * pointer (the local buffer) to
feval, because it can't handle it. You need to create a valid
octave_value from it. Declare rolling_vector as ColumnVector and it
will likely work.

I have stripped my code down to the bare minimum, declared the input as
ColumnVector, and it still fails on compile. My revised code is
#include <octave/oct.h>
#include <octave/dColVector.h>
#include <octave/parse.h>
DEFUN_DLD (rollingfft, args, , "Help String")
{
octave_value_list retval;
octave_value_list fft_result_vector;
octave_value_list ifft_result_vector;
octave_value_list real_result_vector;

octave_function *fcn1 = args(0).function_value (); // supply Octave "fft" function octave_function *fcn2 = args(1).function_value (); // supply Octave "ifft" function octave_function *fcn3 = args(2).function_value (); // supply Octave "real" function
 ColumnVector input_vector = args(3).column_vector_value ();
 ColumnVector output_vector = args(3).column_vector_value ();

 fft_result_vector = feval( fcn1 , input_vector );
ifft_result_vector = feval( fcn2 , fft_result_vector ); real_result_vector = feval( fcn3 , ifft_result_vector ); retval = real_result_vector; return retval; }

and the error message is
octave:1> mkoctfile rollingfft.cc
rollingfft.cc: In function ‘octave_value_list Frollingfft(const
octave_value_list&, int)’:
rollingfft.cc:18: error: no matching function for call to
‘feval(octave_function*&, ColumnVector&)’
/usr/include/octave-3.0.1/octave/parse.h:118: note: candidates are:
octave_value_list feval(const std::string&, const octave_value_list&, int)
/usr/include/octave-3.0.1/octave/parse.h:123: note: octave_value_list feval(octave_function*, const octave_value_list&, int) /usr/include/octave-3.0.1/octave/parse.h:126: note: octave_value_list feval(const octave_value_list&, int)

I don't understand under which circumstances you'd want to replace the fourier transform functions. Passing the functions like arguments makes me suspect you haven't looked at the API. Also, naming a variable of type octave_value_list "vector" is confusing, so I removed that.

Have you tried implementing this in Octave code (.m)?


#include <octave/oct.h>
#include <octave/dColVector.h>
#include <octave/parse.h>

DEFUN_DLD (rollingfft, args, , "Help String")
{
 octave_value_list retval;
 octave_value_list fft_result;
 ComplexColumnVector freq_rep;
 octave_value_list ifft_result;
 octave_value_list real_result;

 fft_result = feval ("fft", args (0), 1);
 freq_rep = fft_result (0).complex_column_vector_value ();
 ifft_result = feval ("ifft", octave_value (freq_rep), 1);
 real_result = feval ("real", ifft_result, 1);
 retval = real_result;

 return retval;
}





reply via email to

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