help-octave
[Top][All Lists]
Advanced

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

Re: user-defined Octave C++ functions


From: flatmax
Subject: Re: user-defined Octave C++ functions
Date: Wed, 4 Oct 2000 11:29:40 +1100 (EST)

Have you seen the signalPAK page ?
It has some previously implemented audio functions + others :
http://users.powernet.co.uk/kienzle/signalPAK/

On Wed, 4 Oct 2000 address@hidden wrote:

> 
>   Hi.  I want to write a dynamically linked function for loading audio
> file, using an external library like libsnd, returning a structure with
> the format and relevant information.
> 
>    I've had problems creating such structures, though I think it may be my
> lack of familiarity causing it.
> 
> For example,
> #include <stdio.h>
> #include <sndfile.h>
> #include <octave/oct.h>
> #include <octave/ov-struct.h>
> #include <octave/oct-map.h>
> #include <string>
> 
> DEFUN_DLD (test_struct, args, ,"test_struct")
> {
>   ColumnVector in (args(0).vector_value());
>   Octave_map table ();
>   octave_struct test;
>   std::string field_name ("strfield");
>   octave_value tstr ("test this");
>   ColumnVector tmat (3);
>   int i = 0;
>   for (i=0;i<3;i++)
>     {
>       tmat(i) = i;
>     }
>   table[field_name] = tstr;
>   field_name = string("matfield");
>   table[field_name] = octave_value(tmat);
>   
>   test = octave_struct(table);
> 
>   return test;
> }
> 
> 
> gives the following errors:
> address@hidden examples]$ mkoctfile test.cc
> test.cc: In function `class octave_value_list Ftest_struct(const class
> octave_value_list &, int)':
> test.cc:21: no match for `Octave_map ()()[string &]'
> test.cc:23: no match for `Octave_map ()()[string &]'
> test.cc:25: no match for `octave_struct & = octave_struct *'
> /usr/local/include/octave-2.1.31/octave/ov-struct.h:99: candidates are:
> octave_struct::operator =(const octave_struct &)
> 
> whereas just changing the Octave_map to a *Octave_map, i.e.
> #include <stdio.h>
> #include <sndfile.h>
> #include <octave/oct.h>
> #include <octave/ov-struct.h>
> #include <octave/oct-map.h>
> #include <string>
> 
> DEFUN_DLD (test_struct, args, ,"test_struct")
> {
>   ColumnVector in (args(0).vector_value());
>   Octave_map *table = new Octave_map();
>   octave_struct test;
>   std::string field_name ("strfield");
>   octave_value tstr ("test this");
>   ColumnVector tmat (3);
>   int i = 0;
>   for (i=0;i<3;i++)
>     {
>       tmat(i) = i;
>     }
>   (*table)[field_name] = tstr;
>   field_name = string("matfield");
>   (*table)[field_name] = new octave_value(tmat);
>   
>   test = octave_struct(*table);
> 
>   return test;
> }
> 
> compiles without complaints.
> 
> What's up with that?  What's this Octave_map()() gcc was complaining
> about?  And will my non-complaining version have memory leaking problems?
> 
> Lynn
> 
> 
> 
> 
> -----------------------------------------------------------------------
> Octave is freely available under the terms of the GNU GPL.
> 
> Octave's home on the web:  http://www.che.wisc.edu/octave/octave.html
> How to fund new projects:  http://www.che.wisc.edu/octave/funding.html
> Subscription information:  http://www.che.wisc.edu/octave/archive.html
> -----------------------------------------------------------------------
> 




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

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



reply via email to

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