[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gsl] Cannot free vector after gsl_multimin_fdfminimizer_x call
From: |
Michael Braun |
Subject: |
Re: [Bug-gsl] Cannot free vector after gsl_multimin_fdfminimizer_x call |
Date: |
Mon, 18 Apr 2011 11:25:08 -0400 |
Ah, yes, that makes sense. Thanks for pointing that out. Much appreciated.
MB
On Apr 18, 2011, at 5:39 AM, Frank Reininghaus wrote:
> Hi,
>
> 2011/4/18 Michael Braun <address@hidden>:
>> When I run this code, it prints the current state of the minimizer as
>> expected (as you can see in this output). The problem comes when trying to
>> free Y. The error is generated by the gsl_vector_free(Y) call. I have no
>> idea what I could be doing wrong here.
>
> You are changing the pointer Y in this line:
>
>> // ASSIGNING CURRENT VALUE TO Y
>> Y = gsl_multimin_fdfminimizer_x(s);
>
> Now it does not point to the address you've allocated in the 'Y =
> gsl_vector_alloc(2)' statement, but to some memory which is owned by
> the gsl_multimin_fdfminimizer object. This memory is free'd when you
> call 'gsl_multimin_fdfminimizer_free (s)', such that any attempt to
> free the memory again later on will result in an error.
>
> To fix this, you should copy the values of the vector returned by
> 'gsl_multimin_fdfminimizer_x(s)' to the vector that 'Y' points to,
> rather than changing the pointer itself.
>
> Cheers,
> Frank
smime.p7s
Description: S/MIME cryptographic signature