help-gsl
[Top][All Lists]
Advanced

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

Re: [Help-gsl] How to do power and exponent of a vector?


From: Analabha Roy
Subject: Re: [Help-gsl] How to do power and exponent of a vector?
Date: Sat, 8 Apr 2006 05:48:08 -0500

Hey maybe somebody should  gather these soluitions up and publish them
online as

"gsl tips and tricks".





On 4/8/06, John D Lamb <address@hidden> wrote:
>
> James Bergstra wrote:
> >>            I want to use gsl to do power of a vector (eg vectorA^0.8)
> and
> >>also exponent of a vector (eg. exp(vectorA)). How can I do this without
> >>using loops?
> >
> > I've written an extension that has exp, and other math.h-ish functions
> for vectors and
> > matrices.
> >
> > http://www-etud.iro.umontreal.ca/~bergstrj/msl/html/index.html
>
> That would explain your interest in streaming SIMD extensions. :-)
>
> It's diffilcult to avoid loops altogether, but you could hide them in a
> generic funtion like:
>
> int map( double (*function)( double ), gsl_vector* a, const gsl_vector* b
> ){
>   int i;
>   for( i = 0; i < b->size; ++i )
>     gsl_vector_set( a, i, function( gsl_vector_get( b, i ) ) );
>   return 0;
> }
>
> I haven't added the usual checks that a and b are nonzero and have the
> same size.
>
> Then use (for example) map( exp, a, b ) to do the work.
>
> If you really want to avoid loops you could rewrite this as a recursive
> function - in this case it won't look good.
>
> --
> JDL
>
>
> _______________________________________________
> Help-gsl mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-gsl
>


reply via email to

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