help-octave
[Top][All Lists]
Advanced

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

Re: Question about oct files


From: Keith Goodman
Subject: Re: Question about oct files
Date: Sat, 27 May 2006 18:20:54 -0700

On 5/27/06, Guillem Borrell Nogueras <address@hidden> wrote:
On Sunday 28 May 2006 02:21, Keith Goodman wrote:
> On 5/27/06, Guillem Borrell Nogueras <address@hidden> wrote:
> > How can I make an oct file return a value allocated runtime?
> > ColumnVector, Matrix... seem to allocate at compile time.
>
> I don't think I understand the question. But how about this:

You are right, the question was ambiguous.

I am using the GSL ode integration routines, I need variable-step Runge-Kutta
ode integration. This is an operation I do quite often and I was trying to
wrap some of my code to use it with Octave.

Obviously I don't know how much time steps will be necessary to integrate the
equation so I use a pointer and save the results incrementing it.  This is
something that you cannot do in Fortran (well, something that I don't know
how to do).

If I count the number of time steps and then I try to use the counter to
create an octave Matrix...

*pointer=&pointer_top
int counter=1
while (t<t1)
        *pointer = rk_integration_routine(...)
        pointer++
        counter++

Matrix result(counter)
... then save the contents of pointer,pointer+1 ... to result.

I am trying something similar and I get a Segmentation Fault.  Is there a way
to get the oct file to return the result of the integration?  The oct
functions must return an octave_value and it seems that a Matrix,
ColumnVector... cannot be allocated this way.

Or maybe I am doing something seriously wrong...

How about

Matrix result(1,1,0);
result.stack(pointer);
result.stack(pointer2);
etc.

?



reply via email to

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