Hey maybe somebody should gather these soluitions up and publish them online as
"gsl tips and tricks". On 4/8/06, John D Lamb <[EMAIL PROTECTED]> 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 > [email protected] > http://lists.gnu.org/mailman/listinfo/help-gsl > _______________________________________________ Help-gsl mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-gsl
