1. Download and install the complete GSL package for windows from:
http://gnuwin32.sourceforge.net/packages/gsl.htm
Just choose the "Complete package, except sources" link.
2. Within Visual Studio, go to:
File->New->Project,
then "Visual C++ Projects,"
then "Win32,"
then "Win32 Console Application."
Enter a name and click "OK."
On the next screen click "Finish."
3. Go to the menu Project and choose properties
4. Under Configuration Properties->C/C++->General->Additional Include Directories, type in "C:\Program Files\GnuWin32\include"
5. Under Configuration Properties->Linker->General->Additional Library Directories, type in "C:\Program Files\GnuWin32\lib"
6. Under Configuration Properties->Linker->Input->Additional Dependencies, type in: libgslcblas.a;libgsl.a;
7. Under Configuration Properties->C/C++->Code Generation->Runtime Library, select "Multi-threaded DLL(/MD)" or "Multi-threaded debug DLL(/MD)" depending on your code.
8. Replace the main .cpp file with something like the following:
#include "stdafx.h"
#include <gsl/gsl_poly.h>
int _tmain(int argc, _TCHAR* argv[])
{
int i;
double a[6] = { -1, 0, 0, 0, 0, 1 };
double z[10];
gsl_poly_complex_workspace * w
= gsl_poly_complex_workspace_alloc (6);
gsl_poly_complex_solve (a, 6, w, z);
gsl_poly_complex_workspace_free (w);
for (i = 0; i < 5; i++)
{
printf ("z%d = %+.18f %+.18f\n",
i, z[2*i], z[2*i+1]);
}
return 0;
}
-----------------------------------------------------------------
9. Hit F7 to build your program. You should now be able to run it from the command line. You'll get a result like the following:
z0 = -0.809016994374947670 +0.587785252292473360
z1 = -0.809016994374947670 -0.587785252292473360
z2 = +0.309016994374947510 +0.951056516295152980
z3 = +0.309016994374947510 -0.951056516295152980
z4 = +0.999999999999999890 +0.000000000000000000
No comments:
Post a Comment