help-gsl
[Top][All Lists]
Advanced

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

[Help-gsl] Underlying types in the GSL


From: Peter Jay Salzman
Subject: [Help-gsl] Underlying types in the GSL
Date: Mon, 12 Feb 2007 22:29:12 -0500
User-agent: Mutt/1.5.13 (2006-08-11)

The compiler complained about this code:

   double a[] = { 2.0L, 3.0L, 2.0L, 10.0L, 3.0L, 4.0L, 3.0L, 6.0L, 1.0L };
   gsl_matrix_view A = gsl_matrix_view_array(a, 3, 3);

Apparently, gsl_matrix_view_array() is expecting doubles, not long doubles.
Not believing my ears and whiskers, I looked at gsl_matrix.h.  Using bash's
"tab completion", I found that there's a number of gsl_matrix.h's.  One for
each data type.

Fair enough.  I guess it's possible someone might need to do work in both
long double, and say, short int.

But the tgmath.h header makes it possible to use the correct function based
on the argument type.  I don't really know how tgmath does its magic, but:

   float       a = 1.0F, ansA;
   double      b = 1.0,  ansB;
   long double c = 1.0L, ansC;

   ansA = sqrt(a); // calls sqrtf()
   ansB = sqrt(b); // calls sqrt()
   ansC = sqrt(c); // calls sqrtl();

Why doesn't the GSL do the same thing?

Thanks!
Pete




reply via email to

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