[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] gsl_vector_complex_set with double
From: |
Kevin Channon |
Subject: |
Re: [Help-gsl] gsl_vector_complex_set with double |
Date: |
Tue, 24 Feb 2009 22:16:19 +0000 |
Hi Alejandro,
> But it seems it doesn't work well. The conversion from gsl_vector_complex *
> to gsl_vector * is done fine. But the error handler of GSL just complains
> about accessing an out-of-range index. Even if I deactivate it with a
> gsl_set_error_handler_off(), the vector only has half the values added.
>
> for( i=0; i<N; i++ )
> {
> gsl_vector_set( (gsl_vector *)x, 2*i, -L/2 + i*(L/(N-1)) );
> }
>
Yes, that does seem to be a problem. The best way to do it might be to make
a function like:
int gsl_vector_complex_set_real(gsl_vector_complex *vec, int index,
double value)
{
gsl_complex temp = {value, 0.0};
gsl_vector_complex_set(vec, index, temp);
return GSL_SUCCESS;
}
you could call this instead of gsl_vector_complex_set() when you want to set the
real part of an element in the vector using a double. You could also
make a similar
function for setting the imaginary part of the element too, if you liked :-)
Kevin
--
Kevin Channon
School of Chemistry
University of Bristol
UK
Re: [Help-gsl] gsl_vector_complex_set with double, Brian Gough, 2009/02/25