help-octave
[Top][All Lists]
Advanced

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

Re: Passing matrices using Octave API


From: Mike Miller
Subject: Re: Passing matrices using Octave API
Date: Thu, 6 Oct 2016 09:21:56 -0700
User-agent: NeoMutt/20160916 (1.7.0)

On Thu, Oct 06, 2016 at 10:40:57 +0530, Shamika Mohanan wrote:
> Both foo1 and foo2 are functions. In both cases, foo2 calls foo1. Something
> like this-
> 
> First case-
> foo2()
> {
>    mtd=foo1(iRows,iCols);
>    octave_value _list in(1)=octave_value (mtd);
> }
> 
> foo1(iRows,iCols)
> {
> 
>    ComplexMatrix matrix_double_complex = ComplexMatrix  (iRows,iCols);
>    //Perform calculations
>    return matrix_double_complex;
> }
> 
> Second case-
> 
> foo1()
> {
>    return octave_value_list in;
> }
> 
> foo2()
> {
>    a=foo1();
>    //Perform calculations
> }
> 
> Can this be done using pointers? Also, where do I find these examples? I
> read the documentation and have gone through the code but have been
> unsuccessful in finding examples.

What you have looks mostly correct to me, aside from not declaring the
types of functions and variables.

Is the problem that you don't want to be copying large arrays in the
parameter lists and return values of these functions? Good news, Octave
array data types are implemented with shared heap pointers and reference
counters. You don't have to worry about that at all, just follow what
you have sketched above.

-- 
mike



reply via email to

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