help-octave
[Top][All Lists]
Advanced

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

Re: Convert double to octave_value for assignment to column vector


From: Jaroslav Hajek
Subject: Re: Convert double to octave_value for assignment to column vector
Date: Tue, 8 Jun 2010 06:46:23 +0200

On Mon, Jun 7, 2010 at 11:51 PM, babelproofreader
<address@hidden> wrote:
>
>> If I were you, I would declare i_slopes and friends as a ColumnVector
>> (as opposed to a OCTAVE_LOCAL_BUFFER'd double*).
>
> This works, and I had thought of doing this myself. The thing is, the
> function rep_median_compile.cc is just an interim function for me to
> learn/develop my coding skills. Ultimately the function I want to write will
> be an adaptive, moving window application of the repeated median fit, with
> various length look back periods determined by a second input column to the
> function. This being the case, I think I really need to learn/be shown the
> proper syntax for the use of OCTAVE_LOCAL_BUFFER, as in the final function
> it will not be possible to predefine the length of i_slopes etc. The problem
> as I now see it is how does one pass the contents of an OCTAVE_LOCAL_BUFFER
> to a feval median call?

As the name suggests, OCTAVE_LOCAL_BUFFER declares a *local* buffer,
that gets automatically deallocated at end of its scope and (since
3.3.50 or so) uses an efficient allocation mechanism. All what you get
is a pointer to memory. It is only useful for intermediate
calculations in C++ (or C, Fortran). The data classes handled by the
interpreter (octave_value, Array etc) manage their own memory, there
is no way you can just "borrow" them a pointer, because you have no
explicit control of their lifetime.
You need to use Array and descendants (e.g. Matrix, ColumnVector) to
pass data to feval.


-- 
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

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