help-octave
[Top][All Lists]
Advanced

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

Re: passing array from c++ wrapper to c function


From: grg
Subject: Re: passing array from c++ wrapper to c function
Date: Tue, 1 Mar 2011 04:47:13 -0800 (PST)

Andy, 
Thanks a lot for the suggestion.

Now, I am stuck again, because I cannot pass back to C++ a vector from C.
Instead of the vector I get a logical.
I've tried to read the Dal Segno Al Coda, DaCodaAlFine, but I am too
clueless about C++ to be able to understand those.

Below if my function now.   Please enlighten me!

--------------------------------------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <octave/oct.h>
    
extern "C" 
{              
     double* t2 (double *x, int lenx)
     {
     int i;
     double out[lenx-1];
                           
        for (i=0; i<=lenx-1; i++)
        {
            out[i]=x[i]*2;
            printf ("%g\n", out[i]);
        }                            
        return out;
     }
}


DEFUN_DLD (t2, args, , "test interpolation") 
{
    octave_value_list retval;    
    Array<double> ar = args(0).array_value ();     
    retval(0) = octave_value( t2 (ar.fortran_vec(), ar.length()) ); 
        
  return retval ; 
} 

--------------------------------------------------------------------------------




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


reply via email to

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