help-octave
[Top][All Lists]
Advanced

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

passing array from c++ wrapper to c function


From: grg
Subject: passing array from c++ wrapper to c function
Date: Mon, 28 Feb 2011 10:23:11 -0800 (PST)

Hi there,

I'm a total ignorant about C and C++, yet I'd like to create an .oct file
that allows me to run a C function from octave.

I'm stuck, because I cannot understand how to pass a double array from C++
to  C.  

I've searched the web extensively, but haven't found much help (probably
because of my ignorance).

Can you suggest a solution, please?

Thanks!
grg

below is my (not working!) t.cc C++ wrapper and included C function:
--------------------------------------------------------------------------------------------------------------------------------

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <octave/oct.h>
         
     
extern "C" 
{            
     double t (double *x)
     {
        printf ("%g\n", x[1]);                       
        printf ("%g\n", x[2]);                       
        return 0;
     }
}

    


DEFUN_DLD (t, args, , "test interpolation") 
{
   octave_value retval;
   retval = t ( args(0).data() );     
  return retval; 
} 


-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/passing-array-from-c-wrapper-to-c-function-tp3328449p3328449.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

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