GSL

From TORI
Revision as of 18:47, 30 July 2019 by T (talk | contribs) (Text replacement - "\$([^\$]+)\$" to "\\(\1\\)")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

GSL may refer to the GNU Scientific Library.


Obtaining

The GSL software can be loaded using the Port software. It seems to load the GSL from http://www.gnu.org/software/gsl/manual/gsl-ref.html

By default, the "port" loads the files, required for GLS, to some directories according to its own idea abut prudence and convenience. It requires certain time and skills to find the GSL support among the system directories and to guess the correct way to compile codes with the GSL routines. The following commands to compile a code with the GSL library are suggested in the manual [1]:

gcc -Wall -pedantic -c -I/usr/local/include gslApp.c

gcc gslApp.o -o gslApp -L/usr/local/lib -lgsl -lgslcblas.a -lm

Certain skills are required to guess, which words in the commands above should be modified in order to make executable module from the code with the GSL routines.

Representation of the complex numbers in GSL

Each GSL routine, that deals with complex numbers, require either the complete rewriting, or, at least, the arranging of some specific shell for calling, because the internal GSL representation of the complex number is very complex. Instead of to write the arighmetic expression "as is", in the in the form, accepted for integer, folod, double, etc, the internal GSL format impllies writing of the call of the specific routine. Instead of infix oprations +,-,*,/, the name of the corresponding procedre should be specified.

Complex arithmetic operators are implemented in the following way [2]:

gsl_complex gsl_complex_add(gsl_complex a, gsl_complex b)
This function returns the sum of the complex numbers a and b, z=a+b.

gsl_complex gsl_complex_sub(gsl_complex a, gsl_complex b)
This function returns the difference of the complex numbers a and b, z=a−b.

gsl_complex gsl_complex_gsl_complex_mul(gsl_complex a, gsl_complex b)
This function returns the product of the complex numbers a and b, z = ab.

gsl_complex gsl_complex_div(gsl_complex a, gsl_complex b)
This function returns the quotient of the complex numbers a and b, z=a/b.

gsl_complex gsl_complex_add_real(gsl_complex a, double x)
This function returns the sum of the complex number a and the real number x, z=a+x.

gsl_complex gsl_complex_sub_real(gsl_complex a, double x)
This function returns the difference of the complex number a and the real number x, z=a-x.

gsl_complex gsl_complex gsl complex_mul_real (gsl_complex a, double x)
This function returns the product of the complex number a and the real number x, z=ax.

 gsl_complex gsl_complex_div_real(gsl_complex a, double x)
This function returns the quotient of the complex number a and the real number x, z = a/x.

gsl_complex gsl_complex_add_imag(gsl_complex a, double y)
This function returns the sum of the complex number a and the imaginary number iy, z = a + iy.

gsl_complex gsl_complex_sub_imag(gsl_complex a, double y)
This function returns the difference of the complex number a and the imaginary number iy, z = a − iy.

gsl_complex gsl_complex_mul_imag(gsl_complex a, double y)
This function returns the product of the complex number a and the imaginary number iy, z = a ∗ (iy).

gsl_complex gsl_complex_gsl_complex_div_imag (gsl_complex a, double y)
This function returns the quotient of the complex number a and the imaginary number iy, z=a/(iy).

gsl_complex gsl_complex_conjugate(gsl_complex z)
This function returns the complex conjugate of the complex number z, z∗=x−iy.

gsl_complex gsl_complex_inverse(gsl_complex z)
This function returns the inverse, or reciprocal, of the complex number z, \(1/z=(x−iy)/(x^2+y^2)\).

gsl_complex gsl_complex_negative(gsl_complex z)
This function returns the negative of the complex number z, −z = (−x) + i(−y).

and so on. The commonly accepted notations +,-,*,/ for the variables inthe internal GSL complex format are not supported at all. For example, for two gsl_complex variables \(a\) and \(b\), instead of a+b, in the gsl representation one should write gsl_complex_add(a,b) that implies 7 times more characters per operation. In comparison to case of use of complex double variables, for the comfortable work with GLS libraries in the GSL notations, the size of the monitor should be, roughly, twice larger, and the amount of misprints in the program raises, roughly, 7 times, and the time for the catching raises, roughly, 49 times, as the time to catch each single misprint also raises 7 times. The implementation, that can be programmed in the conventional notations within 1 year, in the GSL notations may require a half-century and, probably, becomes out of date before the debugging is finished.

For the reason above, the use of the GSL routines "as is" is not recommended at all. If the numeric implementation of some function id required, and it is not yet loaded to TORI, then, in principle, the GLS orutine can be useful, but it should be either rewritten to the common notations (to allow +,-,*,/ for addition, subtraction, multiplication and division), or wrapped with a function that uses the conventional notations (+,-,*,/).

References

  1. http://home.uchicago.edu/~skrainka/pdfs/GSLBasics.pdf Benjamin S. Skrainka. Introduction to GNU Scientific Library. March 4, 2011.
  2. http://www.physics.helsinki.fi/courses/s/tl3/progs/gsl/gsl-ref-1.5.pdf Mark Galassi, Jim Davies, James Theiler, Brian Gough, Gerard Jungman, Michael Booth, Fabrice Rossi. GNU Scientific Library. Reference Manual Edition 1.5, for GSL Version 1.5 24 June 2004.

http://www.gnu.org/software/gsl/manual/gsl-ref.html


Keywords

C++, programing