* hypergeometric function @ 2001-12-19 13:20 Stefan Koch 2001-12-01 23:20 ` Stefan Koch ` (2 more replies) 0 siblings, 3 replies; 21+ messages in thread From: Stefan Koch @ 2001-12-19 13:20 UTC (permalink / raw) To: gsl-discuss Hello, I'm a new user of the gsl-library. Everything works well. But when I tried to look at the hypergeometric function, I recognized a discontinuity (jump) in the graphic-drawing of the function. I think this should not be so. I used the following code segment: void Test(void) { double AktVal, x; int n, p, LoopX, MidX, MidY, CalcSize, gsl_error; CSize sizeTotal; gsl_sf_result result; sizeTotal = GetTotalSize(); MidX = sizeTotal.cx/2.0; MidY = sizeTotal.cy/2.0; n = 3; p= 8; CalcSize = 1000; x = 0; gsl_error = gsl_sf_hyperg_1F1_int_e(-n, p+1, x, &result) ; if(gsl_error) AfxMessageBox(gsl_strerror (gsl_error)); AktVal = result.val; pDC->MoveTo(0, MidY - AktVal); for(LoopX = 0; LoopX < CalcSize; LoopX++ ) { x += 0.1; gsl_error = gsl_sf_hyperg_1F1_int_e(-n, p+1, x, &result); if(gsl_error) AfxMessageBox(gsl_strerror (gsl_error)); AktVal = 100.0*result.val; pDC->LineTo( LoopX, MidY - AktVal); } } (Visual C++ 6.0, NT 4.0) Can anybody tell me if there's something wrong with my code or with the function? No error message occured. Thanks for your help. Best regards Stefan Koch mailto:s.koch@seh-zuelpich.de ^ permalink raw reply [flat|nested] 21+ messages in thread
* hypergeometric function 2001-12-19 13:20 hypergeometric function Stefan Koch @ 2001-12-01 23:20 ` Stefan Koch 2001-12-19 13:20 ` Dan, Ho-Jin 2001-12-19 13:20 ` Brian Gough 2 siblings, 0 replies; 21+ messages in thread From: Stefan Koch @ 2001-12-01 23:20 UTC (permalink / raw) To: gsl-discuss Hello, I'm a new user of the gsl-library. Everything works well. But when I tried to look at the hypergeometric function, I recognized a discontinuity (jump) in the graphic-drawing of the function. I think this should not be so. I used the following code segment: void Test(void) { double AktVal, x; int n, p, LoopX, MidX, MidY, CalcSize, gsl_error; CSize sizeTotal; gsl_sf_result result; sizeTotal = GetTotalSize(); MidX = sizeTotal.cx/2.0; MidY = sizeTotal.cy/2.0; n = 3; p= 8; CalcSize = 1000; x = 0; gsl_error = gsl_sf_hyperg_1F1_int_e(-n, p+1, x, &result) ; if(gsl_error) AfxMessageBox(gsl_strerror (gsl_error)); AktVal = result.val; pDC->MoveTo(0, MidY - AktVal); for(LoopX = 0; LoopX < CalcSize; LoopX++ ) { x += 0.1; gsl_error = gsl_sf_hyperg_1F1_int_e(-n, p+1, x, &result); if(gsl_error) AfxMessageBox(gsl_strerror (gsl_error)); AktVal = 100.0*result.val; pDC->LineTo( LoopX, MidY - AktVal); } } (Visual C++ 6.0, NT 4.0) Can anybody tell me if there's something wrong with my code or with the function? No error message occured. Thanks for your help. Best regards Stefan Koch mailto:s.koch@seh-zuelpich.de ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: hypergeometric function 2001-12-19 13:20 hypergeometric function Stefan Koch 2001-12-01 23:20 ` Stefan Koch @ 2001-12-19 13:20 ` Dan, Ho-Jin 2001-12-02 18:35 ` Dan, Ho-Jin 2001-12-19 13:20 ` Dan, Ho-Jin 2001-12-19 13:20 ` Brian Gough 2 siblings, 2 replies; 21+ messages in thread From: Dan, Ho-Jin @ 2001-12-19 13:20 UTC (permalink / raw) To: s.koch; +Cc: gsl-discuss [-- Attachment #1: Type: text/plain, Size: 422 bytes --] Hi, I couldn't find the discontinuty of the hypergeometry graph. please, check the file hyperg.gif, Yours, Dan, Ho-Jin Stefan Koch wrote: >Hello, > >I'm a new user of the gsl-library. Everything works well. But when I tried >to look at the hypergeometric function, I recognized a discontinuity (jump) >in the graphic-drawing of the function. I think this should not be so. I >used the following code segment: > --snip [-- Attachment #2: gsl_sf_h1.c --] [-- Type: text/plain, Size: 240 bytes --] #include <stdio.h> #include <gsl/gsl_sf.h> int main() { int i, m=1000; int n=3, p=8; double result, x; for (i=0; i<m; i++) { x = i*0.1; result = gsl_sf_hyperg_1F1_int(-n, p+1, x); printf("%f %f\n", x, result); } } [-- Attachment #3: hyperg.gif --] [-- Type: image/gif, Size: 14044 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: hypergeometric function 2001-12-19 13:20 ` Dan, Ho-Jin @ 2001-12-02 18:35 ` Dan, Ho-Jin 2001-12-19 13:20 ` Dan, Ho-Jin 1 sibling, 0 replies; 21+ messages in thread From: Dan, Ho-Jin @ 2001-12-02 18:35 UTC (permalink / raw) To: s.koch; +Cc: gsl-discuss [-- Attachment #1: Type: text/plain, Size: 422 bytes --] Hi, I couldn't find the discontinuty of the hypergeometry graph. please, check the file hyperg.gif, Yours, Dan, Ho-Jin Stefan Koch wrote: >Hello, > >I'm a new user of the gsl-library. Everything works well. But when I tried >to look at the hypergeometric function, I recognized a discontinuity (jump) >in the graphic-drawing of the function. I think this should not be so. I >used the following code segment: > --snip [-- Attachment #2: gsl_sf_h1.c --] [-- Type: text/plain, Size: 240 bytes --] #include <stdio.h> #include <gsl/gsl_sf.h> int main() { int i, m=1000; int n=3, p=8; double result, x; for (i=0; i<m; i++) { x = i*0.1; result = gsl_sf_hyperg_1F1_int(-n, p+1, x); printf("%f %f\n", x, result); } } [-- Attachment #3: hyperg.gif --] [-- Type: image/gif, Size: 14044 bytes --] ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: hypergeometric function 2001-12-19 13:20 ` Dan, Ho-Jin 2001-12-02 18:35 ` Dan, Ho-Jin @ 2001-12-19 13:20 ` Dan, Ho-Jin 1 sibling, 0 replies; 21+ messages in thread From: Dan, Ho-Jin @ 2001-12-19 13:20 UTC (permalink / raw) To: s.koch; +Cc: gsl-discuss Hi, I couldn't find the discontinuty of the hypergeometry graph. please, check the file hyperg.gif, Yours, Dan, Ho-Jin Stefan Koch wrote: >Hello, > >I'm a new user of the gsl-library. Everything works well. But when I tried >to look at the hypergeometric function, I recognized a discontinuity (jump) >in the graphic-drawing of the function. I think this should not be so. I >used the following code segment: > --snip ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: hypergeometric function 2001-12-19 13:20 hypergeometric function Stefan Koch 2001-12-01 23:20 ` Stefan Koch 2001-12-19 13:20 ` Dan, Ho-Jin @ 2001-12-19 13:20 ` Brian Gough 2001-12-03 8:21 ` Brian Gough [not found] ` <NEBBIBGCPKOPEIODNFDIEEIHCAAA.s.koch@seh-zuelpich.de> 2 siblings, 2 replies; 21+ messages in thread From: Brian Gough @ 2001-12-19 13:20 UTC (permalink / raw) To: s.koch; +Cc: gsl-discuss Stefan Koch writes: > I'm a new user of the gsl-library. Everything works well. But when > I tried to look at the hypergeometric function, I recognized a > discontinuity (jump) in the graphic-drawing of the function. I > think this should not be so. I used the following code segment: > (Visual C++ 6.0, NT 4.0) > Can anybody tell me if there's something wrong with my code or > with the function? No error message occured. Hi, I don't see the discontinuity either. What version of GSL are you using? -- did you compile it yourself or use a precompiled version. regards Brian Gough ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: hypergeometric function 2001-12-19 13:20 ` Brian Gough @ 2001-12-03 8:21 ` Brian Gough [not found] ` <NEBBIBGCPKOPEIODNFDIEEIHCAAA.s.koch@seh-zuelpich.de> 1 sibling, 0 replies; 21+ messages in thread From: Brian Gough @ 2001-12-03 8:21 UTC (permalink / raw) To: s.koch; +Cc: gsl-discuss Stefan Koch writes: > I'm a new user of the gsl-library. Everything works well. But when > I tried to look at the hypergeometric function, I recognized a > discontinuity (jump) in the graphic-drawing of the function. I > think this should not be so. I used the following code segment: > (Visual C++ 6.0, NT 4.0) > Can anybody tell me if there's something wrong with my code or > with the function? No error message occured. Hi, I don't see the discontinuity either. What version of GSL are you using? -- did you compile it yourself or use a precompiled version. regards Brian Gough ^ permalink raw reply [flat|nested] 21+ messages in thread
[parent not found: <NEBBIBGCPKOPEIODNFDIEEIHCAAA.s.koch@seh-zuelpich.de>]
* Re: AW: hypergeometric function [not found] ` <NEBBIBGCPKOPEIODNFDIEEIHCAAA.s.koch@seh-zuelpich.de> @ 2001-12-19 13:20 ` Brian Gough 2001-12-03 15:27 ` Brian Gough 2001-12-19 13:20 ` J.J. Gomez Cadenas 0 siblings, 2 replies; 21+ messages in thread From: Brian Gough @ 2001-12-19 13:20 UTC (permalink / raw) To: s.koch; +Cc: gsl-discuss Stefan Koch writes: > With the following function I produced the output shown in the attached file > Hyper.jpg. You can see the discontinuity clearly. Please note that I > multiply the output of the hypergeometric function by a factor of 100. > I used gsl 1.0 from GnuWin32, the precompiled version (dll). I got the > dicontinuity with the free download version from Network Theory Ltd. too. Ok, I see it now at x=13..14. I didn't see it on the original scale. Thanks for the bug report. I've found the problem, so a revised version will be available in the next release or you can apply the patch below and rebuild from source to fix it. regards Brian Gough Index: specfunc/hyperg_1F1.c =================================================================== RCS file: /cvs/gsl/gsl/specfunc/hyperg_1F1.c,v retrieving revision 1.67 retrieving revision 1.69 diff -u -r1.67 -r1.69 --- hyperg_1F1.c 2001/11/19 22:32:10 1.67 +++ hyperg_1F1.c 2001/12/05 19:34:41 1.69 @@ -1084,13 +1084,28 @@ Ma0p1b = (b*(a0+x)*Ma0b + x*(a0-b)*Ma0bp1)/(a0*b); } - Mnm1 = Ma0b; - Mn = Ma0p1b; - for(n=a0+1; n<a; n++) { - Mnp1 = ((b-n)*Mnm1 + (2*n-b+x)*Mn)/n; - Mnm1 = Mn; - Mn = Mnp1; - } + /* Initialise the recurrence correctly BJG */ + + if (a0 >= a) + { + Mn = Ma0b; + } + else if (a0 + 1>= a) + { + Mn = Ma0p1b; + } + else + { + Mnm1 = Ma0b; + Mn = Ma0p1b; + + for(n=a0+1; n<a; n++) { + Mnp1 = ((b-n)*Mnm1 + (2*n-b+x)*Mn)/n; + Mnm1 = Mn; + Mn = Mnp1; + } + } + result->val = Mn; result->err = (fabs(x) + 1.0) * GSL_DBL_EPSILON * fabs(Mn); result->err *= fabs(b-a)+1.0; ^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: AW: hypergeometric function 2001-12-19 13:20 ` AW: " Brian Gough @ 2001-12-03 15:27 ` Brian Gough 2001-12-19 13:20 ` J.J. Gomez Cadenas 1 sibling, 0 replies; 21+ messages in thread From: Brian Gough @ 2001-12-03 15:27 UTC (permalink / raw) To: s.koch; +Cc: gsl-discuss Stefan Koch writes: > With the following function I produced the output shown in the attached file > Hyper.jpg. You can see the discontinuity clearly. Please note that I > multiply the output of the hypergeometric function by a factor of 100. > I used gsl 1.0 from GnuWin32, the precompiled version (dll). I got the > dicontinuity with the free download version from Network Theory Ltd. too. Ok, I see it now at x=13..14. I didn't see it on the original scale. Thanks for the bug report. I've found the problem, so a revised version will be available in the next release or you can apply the patch below and rebuild from source to fix it. regards Brian Gough Index: specfunc/hyperg_1F1.c =================================================================== RCS file: /cvs/gsl/gsl/specfunc/hyperg_1F1.c,v retrieving revision 1.67 retrieving revision 1.69 diff -u -r1.67 -r1.69 --- hyperg_1F1.c 2001/11/19 22:32:10 1.67 +++ hyperg_1F1.c 2001/12/05 19:34:41 1.69 @@ -1084,13 +1084,28 @@ Ma0p1b = (b*(a0+x)*Ma0b + x*(a0-b)*Ma0bp1)/(a0*b); } - Mnm1 = Ma0b; - Mn = Ma0p1b; - for(n=a0+1; n<a; n++) { - Mnp1 = ((b-n)*Mnm1 + (2*n-b+x)*Mn)/n; - Mnm1 = Mn; - Mn = Mnp1; - } + /* Initialise the recurrence correctly BJG */ + + if (a0 >= a) + { + Mn = Ma0b; + } + else if (a0 + 1>= a) + { + Mn = Ma0p1b; + } + else + { + Mnm1 = Ma0b; + Mn = Ma0p1b; + + for(n=a0+1; n<a; n++) { + Mnp1 = ((b-n)*Mnm1 + (2*n-b+x)*Mn)/n; + Mnm1 = Mn; + Mn = Mnp1; + } + } + result->val = Mn; result->err = (fabs(x) + 1.0) * GSL_DBL_EPSILON * fabs(Mn); result->err *= fabs(b-a)+1.0; ^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: AW: hypergeometric function 2001-12-19 13:20 ` AW: " Brian Gough 2001-12-03 15:27 ` Brian Gough @ 2001-12-19 13:20 ` J.J. Gomez Cadenas 2001-12-05 2:07 ` J.J. Gomez Cadenas ` (2 more replies) 1 sibling, 3 replies; 21+ messages in thread From: J.J. Gomez Cadenas @ 2001-12-19 13:20 UTC (permalink / raw) To: gsl-discuss Hi all, I get the problem below when trying to link a test program for a C++ complex class that wraps gsl complex. The program compiles fine AND compiles, links and executes no problem in Linux. I have just downloaded version v1 of GSL for windows. Any ideas? Note: I have searched in the sources for "HUGE" and I only find the work in gsl_nan.h However, I cannot see the word __HUGE there... thanks, jj This is the error.... Done Searching Libraries libgsld.lib(invhyp.obj) : error LNK2001: unresolved external symbol __HUGE ../Win32Debug/test_complex.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. ^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: AW: hypergeometric function 2001-12-19 13:20 ` J.J. Gomez Cadenas @ 2001-12-05 2:07 ` J.J. Gomez Cadenas 2001-12-19 13:20 ` Brian Gough 2001-12-19 13:20 ` J.J. Gomez Cadenas 2 siblings, 0 replies; 21+ messages in thread From: J.J. Gomez Cadenas @ 2001-12-05 2:07 UTC (permalink / raw) To: gsl-discuss Hi all, I get the problem below when trying to link a test program for a C++ complex class that wraps gsl complex. The program compiles fine AND compiles, links and executes no problem in Linux. I have just downloaded version v1 of GSL for windows. Any ideas? Note: I have searched in the sources for "HUGE" and I only find the work in gsl_nan.h However, I cannot see the word __HUGE there... thanks, jj This is the error.... Done Searching Libraries libgsld.lib(invhyp.obj) : error LNK2001: unresolved external symbol __HUGE ../Win32Debug/test_complex.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. ^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: AW: hypergeometric function 2001-12-19 13:20 ` J.J. Gomez Cadenas 2001-12-05 2:07 ` J.J. Gomez Cadenas @ 2001-12-19 13:20 ` Brian Gough 2001-12-05 12:20 ` Brian Gough 2001-12-19 13:20 ` J.J. Gomez Cadenas 2001-12-19 13:20 ` J.J. Gomez Cadenas 2 siblings, 2 replies; 21+ messages in thread From: Brian Gough @ 2001-12-19 13:20 UTC (permalink / raw) To: J.J. Gomez Cadenas; +Cc: gsl-discuss J.J. Gomez Cadenas writes: > I get the problem below when trying to link a test program for a > C++ complex class that wraps gsl complex. The program compiles fine > AND compiles, links and executes no problem in Linux. I have just > downloaded version v1 of GSL for windows. Any ideas? > Note: I have searched in the sources for "HUGE" and I only find > the work in gsl_nan.h However, I cannot see the word __HUGE > there... > This is the error.... > > Done Searching Libraries libgsld.lib(invhyp.obj) : error LNK2001: > unresolved external symbol __HUGE ../Win32Debug/test_complex.exe : > fatal error LNK1120: 1 unresolved externals Error executing > link.exe. Haven't ever seen that. You'll need to send the program to the list I think. Brian ^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: AW: hypergeometric function 2001-12-19 13:20 ` Brian Gough @ 2001-12-05 12:20 ` Brian Gough 2001-12-19 13:20 ` J.J. Gomez Cadenas 1 sibling, 0 replies; 21+ messages in thread From: Brian Gough @ 2001-12-05 12:20 UTC (permalink / raw) To: J.J. Gomez Cadenas; +Cc: gsl-discuss J.J. Gomez Cadenas writes: > I get the problem below when trying to link a test program for a > C++ complex class that wraps gsl complex. The program compiles fine > AND compiles, links and executes no problem in Linux. I have just > downloaded version v1 of GSL for windows. Any ideas? > Note: I have searched in the sources for "HUGE" and I only find > the work in gsl_nan.h However, I cannot see the word __HUGE > there... > This is the error.... > > Done Searching Libraries libgsld.lib(invhyp.obj) : error LNK2001: > unresolved external symbol __HUGE ../Win32Debug/test_complex.exe : > fatal error LNK1120: 1 unresolved externals Error executing > link.exe. Haven't ever seen that. You'll need to send the program to the list I think. Brian ^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: AW: hypergeometric function 2001-12-19 13:20 ` Brian Gough 2001-12-05 12:20 ` Brian Gough @ 2001-12-19 13:20 ` J.J. Gomez Cadenas 2001-12-05 12:20 ` J.J. Gomez Cadenas 2001-12-19 13:20 ` Brian Gough 1 sibling, 2 replies; 21+ messages in thread From: J.J. Gomez Cadenas @ 2001-12-19 13:20 UTC (permalink / raw) To: Brian Gough, J.J. Gomez Cadenas; +Cc: gsl-discuss This is the test program. #include "GslPP/DataTypes/Complex.h" #include <iostream> #include <fstream> int main() { double re,im; cout << " Enter the real and imaginary part of a complex number\n"; cout << " >>enter real part "; cin >> re; cout << " >>enter imaginary part "; cin >> im; cout.width(10); cout.precision(12); Complex z1 = Complex (re, im); cout << " z1 = " << z1 << endl << " real part = " << z1.real () << " imag part = " << z1.imag () << " arg = " << z1.arg () << " abs = " << z1.abs () << endl << " z**2 = " << z1.abs2 () << " log |z| = " << z1.logAbs () << endl; double r, theta; cout << " Enter a complex number in polar coordinates\n"; cout << " >>enter radius "; cin >> r; cout << " >>enter polar angle "; cin >> theta; Complex z2 = Complex (); z2.setPolar (r, theta); cout << " z2 = " << z2 << endl << " real part = " << z2.real () << " imag part = " << z2.imag () << " arg = " << z2.arg () << " abs = " << z2.abs () << endl << " z**2 = " << z2.abs2 () << " log |z| = " << z2.logAbs () << endl; /* Assignement operators */ Complex z3 = z1; //Complex& operator = (const Complex& z); Complex z4; z4= 10.0; //Complex& operator = (double d); cout << " z3 must be = z1, z3 = " << z3 << endl; cout << " z4 must be = (10,0), z4 = " << z4 << endl; // Complex& operator += (const Complex& z); z1 += z2; cout << " z1 += z2 = " << z1 << endl; z1 = z3; // Complex& operator -= (const Complex& z); z1 -= z2; cout << " z1 -= z2 = " << z1 << endl; z1 = z3; // Complex& operator *= (const Complex& z); z1 *= z2; cout << " z1 *= z2 = " << z1 << endl; z1 = z3; // Complex& operator *= (double d); z1 *= 10.; cout << " z1 *= 10. = " << z1 << endl; z1 = z3; // Complex& operator /= (const Complex& z); z1 /= z2; cout << " z1 /= z2 = " << z1 << endl; z1 = z3; // Complex& operator /= (double d); z1 /= 10.; cout << " z1 /= 10. = " << z1 << endl; z1 = z3; /* * Operations with complex numbers */ // friend Complex operator - (const Complex& z); //Complex operator + (const Complex& z1, const Complex& z2); cout << " z1 + z2 = " << z1 + z2 << endl; z1 = z3; // Complex operator - (const Complex& z1, const Complex& z2); cout << " z1 - z2 = " << z1 - z2 << endl; z1 = z3; //Complex operator * (const Complex& z1, const Complex& z2); cout << " z1 * z2 = " << z1 * z2 << endl; z1 = z3; // Complex operator / (const Complex& z1, const Complex& z2); cout << " z1 / z2 = " << z1 / z2 << endl; z1 = z3; /* Complex operator + (double a, const Complex& z); Complex operator - (double a, const Complex& z); Complex operator * (double a, const Complex& z); Complex operator / (double a, const Complex& z); */ cout << " 10 + z1 = " << 10. + z1 << endl; z1 = z3; cout << " 10 - z1 = " << 10. - z1 << endl; z1 = z3; cout << " 10 * z2 = " << 10. * z1 << endl; z1 = z3; cout << " 10 / z1 = " << 10. / z1 << endl; z1 = z3; /* Complex operator + (const Complex& z, double a); Complex operator - (const Complex& z, double a); Complex operator * (const Complex& z, double a); Complex operator / (const Complex& z, double a); */ cout << " z1 + 10 = " << z1 + 10. << endl; z1 = z3; cout << " z1 - 10 = " << z1 - 10. << endl; z1 = z3; cout << " z1 * 10 = " << z1 * 10. << endl; z1 = z3; cout << " z1/10 = " << z1/10. << endl; z1 = z3; /* * Complex functions. */ cout << " Elementary functions " << endl << " abs (z1) = " <<abs (z1) <<endl << " conj (z1) = " <<conj (z1) <<endl << " inverse (z1) = " <<inverse (z1) <<endl << " sqrt (z1) = " <<sqrt (z1) <<endl << " Csqrt (10.) = " <<Csqrt (10.) <<endl << " pow (z1,z2) = " <<pow(z1,z2) <<endl << " pow (z1,10.) = " <<pow(z1,10.) <<endl << " exp (z1) = " <<exp(z1) <<endl << " log (z1) = " <<log(z1) <<endl << " log10 (z1) = " <<log10(z1) <<endl; cout << " Trigonometric functions " << endl << " sin (z1) = " <<sin (z1) <<endl << " cos (z1) = " <<cos (z1) <<endl << " tan (z1) = " <<tan (z1) <<endl << " sec (z1) = " <<sec (z1) <<endl << " csc (z1) = " <<csc (z1) <<endl << " cot (z1) = " <<cot (z1) <<endl; cout << " Inverse Trigonometric functions " << endl << " asin (z1) = " <<asin (z1) <<endl << " acos (z1) = " <<acos (z1) <<endl << " atan (z1) = " <<atan (z1) <<endl << " asec (z1) = " <<asec (z1) <<endl << " acsc (z1) = " <<acsc (z1) <<endl << " acot (z1) = " <<acot (z1) <<endl; cout << " Hyperbolic functions " << endl << " sinh (z1) = " <<sinh (z1) <<endl << " cosh (z1) = " <<cosh (z1) <<endl << " tanh (z1) = " <<tanh (z1) <<endl << " sech (z1) = " <<sech (z1) <<endl << " csch (z1) = " <<csch (z1) <<endl << " coth (z1) = " <<coth (z1) <<endl; cout << " Inverse hyperbolic functions " << endl << " asinh (z1) = " <<asinh (z1) <<endl << " acosh (z1) = " <<acosh (z1) <<endl << " atanh (z1) = " <<atanh (z1) <<endl << " asech (z1) = " <<asech (z1) <<endl << " acsch (z1) = " <<acsch (z1) <<endl << " acoth (z1) = " <<acoth (z1) <<endl; return 0; } This is the header Complex.h /* -*- mode: c++ -*- */ /* * Complex.h * This is a wrapper around the complex type defined in the GSL * * This code is part of the * Gsl++library, a C++ wrapper around the GNU Scientific Library (GNU) * * Copyright for this wrapper (C) 2001,2002 * J. Burguet, J.J. Gomez-Cadenas, J.A. Hernando * * For the GSL library * Copyright (C) 1996, 1997, 1998, 1999, 2000 Brian Gough and others, * see documentation of the GSL library * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _COMPLEX_ #define _COMPLEX_ #include <iostream> // to overload ostream& << #include <gsl/gsl_complex.h> #include <gsl/gsl_complex_math.h> using namespace std; //needed by gcc 3.2 and MVC++ /** * Complex numbers * * This is a wrapper class around the complex numbers defined by the GSL * * A gsl complex is a structure defined as: * * typedef struct * { * double dat[2] * } gsl_complex; * * See gsl manual chapter 5 */ class Complex; Complex operator - (const Complex& z); Complex operator + (const Complex& z1, const Complex& z2); ///< z1+z2 Complex operator - (const Complex& z1, const Complex& z2); ///< z1-z2 Complex operator * (const Complex& z1, const Complex& z2); ///< z1*z2 Complex operator / (const Complex& z1, const Complex& z2); ///< z1/z2 Complex operator + (double a, const Complex& z); ///< a + z Complex operator - (double a, const Complex& z); ///< a - z Complex operator * (double a, const Complex& z); ///< a * z Complex operator / (double a, const Complex& z); ///< a / z Complex operator + (const Complex& z, double a); ///< z + a Complex operator - (const Complex& z, double a); ///< z - a Complex operator * (const Complex& z, double a); ///< z * a Complex operator / (const Complex& z, double a); ///< z / ac /* * Complex functions. */ // Elementary functions double fabs(const Complex& z); ///< absolute value, |z| double abs(const Complex& z); ///< absolute value, |z| Complex conj(const Complex& z); ///< complex conjugate Complex inverse(const Complex& z); ///< 1/z Complex sqrt(const Complex& z); ///< complex square root Complex Csqrt(double a); ///< complex sqrt of a real Complex pow(const Complex& z1, const Complex& z2); ///< z1**z2 Complex pow(const Complex& z, double a); ///< z**a Complex exp(const Complex& z); ///< exponential function, exp(z) Complex log(const Complex& z); ///< natural logarithm, log(z) Complex log10(const Complex& z); ///< logarithm in base 10, log10(z) // Trigonometric Complex sin(const Complex& z); ///< sinus, sin(z) Complex cos(const Complex& z); ///< cosinus, cos(z) Complex tan(const Complex& z); ///< tangent, tan(z) Complex sec(const Complex& z); ///< secant, sec(z) = 1/cos(z) Complex csc(const Complex& z); ///< cosecant, cosec(z) = 1/sin(z) Complex cot(const Complex& z); ///< cotangent, cotan(z) = 1/cot(z) // Inverse trigonometric Complex asin(const Complex& z); ///< arcsin(z) Complex acos(const Complex& z); ///< arccos(z) Complex atan(const Complex& z); ///< arctan(z) Complex asec(const Complex& z); ///< arcsec(z) Complex acsc(const Complex& z); ///< arccosec(z) Complex acot(const Complex& z); ///< arccotg(z) // Hyperbolic Complex sinh(const Complex& z); ///< sinh(z) Complex cosh(const Complex& z); ///< cosh(z) Complex tanh(const Complex& z); ///< tanh(z) Complex sech(const Complex& z); ///< sech(z) = 1/cosh(z) Complex csch(const Complex& z); ///< cosech(z) = 1/sinh(z) Complex coth(const Complex& z); ///< cotanh(z) = 1/coth(z) // Inverse hyperbolic Complex asinh(const Complex& z); ///< arcsinh(z) Complex acosh(const Complex& z); ///< arccosh(z) Complex atanh(const Complex& z); ///< arctan(z) Complex asech(const Complex& z); ///< arcsec(z) Complex acsch(const Complex& z); ///< arccosec(z) Complex acoth(const Complex& z); ///< arccotg(z) class Complex { private: gsl_complex m_gslComplex; ///< a gsl complex number public: Complex(); Complex(double x, double y); Complex(const Complex& z); ~Complex(); /* Reading functions */ double real() const; ///< real part, Re(z) double imag() const; ///< imaginary part, Im(z) double arg() const; ///< argument, -pi < arg(z) < pi double abs() const; ///< absolute value, |z| double abs2() const; ///< squared absolute value, |z|**2 double logAbs() const; ///< log|z|. It allows accurate evaluation near |z|=1 /* Setting functions */ void setRectangular(double x, double y); void setPolar(double r, double theta); /* Assignement operators */ Complex& operator = (const Complex& z); Complex& operator = (double d); Complex& operator += (const Complex& z); Complex& operator -= (const Complex& z); Complex& operator *= (const Complex& z); Complex& operator *= (double d); Complex& operator /= (const Complex& z); Complex& operator /= (double d); /* * Friend functions */ /* * Operations with complex numbers */ friend Complex operator - (const Complex& z); friend Complex operator + (const Complex& z1, const Complex& z2); ///< z1+z2 friend Complex operator - (const Complex& z1, const Complex& z2); ///< z1-z2 friend Complex operator * (const Complex& z1, const Complex& z2); ///< z1*z2 friend Complex operator / (const Complex& z1, const Complex& z2); ///< z1/z2 friend Complex operator + (double a, const Complex& z); ///< a + z friend Complex operator - (double a, const Complex& z); ///< a - z friend Complex operator * (double a, const Complex& z); ///< a * z friend Complex operator / (double a, const Complex& z); ///< a / z friend Complex operator + (const Complex& z, double a); ///< z + a friend Complex operator - (const Complex& z, double a); ///< z - a friend Complex operator * (const Complex& z, double a); ///< z * a friend Complex operator / (const Complex& z, double a); ///< z / ac /* * Complex functions. */ // Elementary functions friend double fabs(const Complex& z); ///< absolute value, |z| friend double abs(const Complex& z); ///< absolute value, |z| friend Complex conj(const Complex& z); ///< complex conjugate friend Complex inverse(const Complex& z); ///< 1/z friend Complex sqrt(const Complex& z); ///< complex square root friend Complex Csqrt(double a); ///< complex sqrt of a real friend Complex pow(const Complex& z1, const Complex& z2); ///< z1**z2 friend Complex pow(const Complex& z, double a); ///< z**a friend Complex exp(const Complex& z); ///< exponential function, exp(z) friend Complex log(const Complex& z); ///< natural logarithm, log(z) friend Complex log10(const Complex& z); ///< logarithm in base 10, log10(z) // Trigonometric friend Complex sin(const Complex& z); ///< sinus, sin(z) friend Complex cos(const Complex& z); ///< cosinus, cos(z) friend Complex tan(const Complex& z); ///< tangent, tan(z) friend Complex sec(const Complex& z); ///< secant, sec(z) = 1/cos(z) friend Complex csc(const Complex& z); ///< cosecant, cosec(z) = 1/sin(z) friend Complex cot(const Complex& z); ///< cotangent, cotan(z) = 1/cot(z) // Inverse trigonometric friend Complex asin(const Complex& z); ///< arcsin(z) friend Complex acos(const Complex& z); ///< arccos(z) friend Complex atan(const Complex& z); ///< arctan(z) friend Complex asec(const Complex& z); ///< arcsec(z) friend Complex acsc(const Complex& z); ///< arccosec(z) friend Complex acot(const Complex& z); ///< arccotg(z) // Hyperbolic friend Complex sinh(const Complex& z); ///< sinh(z) friend Complex cosh(const Complex& z); ///< cosh(z) friend Complex tanh(const Complex& z); ///< tanh(z) friend Complex sech(const Complex& z); ///< sech(z) = 1/cosh(z) friend Complex csch(const Complex& z); ///< cosech(z) = 1/sinh(z) friend Complex coth(const Complex& z); ///< cotanh(z) = 1/coth(z) // Inverse hyperbolic friend Complex asinh(const Complex& z); ///< arcsinh(z) friend Complex acosh(const Complex& z); ///< arccosh(z) friend Complex atanh(const Complex& z); ///< arctan(z) friend Complex asech(const Complex& z); ///< arcsec(z) friend Complex acsch(const Complex& z); ///< arccosec(z) friend Complex acoth(const Complex& z); ///< arccotg(z) }; ostream& operator << (ostream& s, const Complex& z); #endif /* _COMPLEX_ */ And this is the .cpp, all straight forward! ** * Complex numbers and complex functions. * * The class Complex is a wrapper around gsl_complex. * * @version v1 * @author JJ Gomez Cadenas, JBC * @date 17/08/2001 */ #include <gsl/gsl_errno.h> #include "GslPP/DataTypes/Complex.h" /** * Default constructor, z = 0. */ Complex::Complex() { m_gslComplex = gsl_complex_rect(0.0, 0.0); } /** * Create a complex number z = x + iy */ Complex::Complex(double x, double y) { m_gslComplex = gsl_complex_rect(x, y); } /** * Copy constructor */ Complex::Complex(const Complex& z) { m_gslComplex = gsl_complex_rect(z.real(), z.imag()); } /** * Destructor */ Complex::~Complex() { } /* * Reading functions. */ /// Real part double Complex::real() const { return GSL_REAL(m_gslComplex); } /// Imaginary part double Complex::imag() const { return GSL_IMAG(m_gslComplex); } /// Argument, -pi < arg < pi double Complex::arg() const { return gsl_complex_arg(m_gslComplex); } /// Modulus double Complex::abs() const { return gsl_complex_abs(m_gslComplex); } /// Modulus squared double Complex::abs2() const { return gsl_complex_abs2(m_gslComplex); } double Complex::logAbs() const { return gsl_complex_logabs(m_gslComplex); } /* * Setting functions */ void Complex::setRectangular(double x, double y) { m_gslComplex = gsl_complex_rect(x, y); } void Complex::setPolar(double r, double theta) { m_gslComplex = gsl_complex_polar(r, theta); } /* * Assignement operators. */ Complex& Complex::operator = (const Complex& z) { m_gslComplex = gsl_complex_rect(z.real(), z.imag()); return *this; } Complex& Complex::operator = (double d) { m_gslComplex = gsl_complex_rect(d, 0.0); return *this; } Complex& Complex::operator += (const Complex& z) m_gslComplex = gsl_complex_add(m_gslComplex, z.m_gslComplex); return *this; } Complex& Complex::operator -= (const Complex& z) { m_gslComplex = gsl_complex_sub(m_gslComplex, z.m_gslComplex); return *this; } Complex& Complex::operator *= (const Complex& z) { m_gslComplex = gsl_complex_mul(m_gslComplex, z.m_gslComplex); return *this; } Complex& Complex::operator *= (double a) { m_gslComplex = gsl_complex_mul_real(m_gslComplex, a); return *this; } Complex& Complex::operator /= (const Complex& z) { m_gslComplex = gsl_complex_div(z.m_gslComplex, m_gslComplex); return *this; } Complex& Complex::operator /= (double a) { m_gslComplex = gsl_complex_div_real(m_gslComplex, a); return *this; } /* * Operations with complex numbers. */ Complex operator - (const Complex& z) { return Complex(-GSL_REAL(z.m_gslComplex), -GSL_IMAG(z.m_gslComplex)); } Complex operator + (const Complex& z1, const Complex& z2) { gsl_complex gz = gsl_complex_add(z1.m_gslComplex, z2.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator - (const Complex& z1, const Complex& z2) { gsl_complex gz = gsl_complex_sub(z1.m_gslComplex, z2.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator * (const Complex& z1, const Complex& z2) { gsl_complex gz = gsl_complex_mul(z1.m_gslComplex, z2.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator / (const Complex& z1, const Complex& z2) { gsl_complex gz = gsl_complex_div(z1.m_gslComplex, z2.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator + (double a, const Complex& z) { gsl_complex gz = gsl_complex_add_real(z.m_gslComplex, a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator - (double a, const Complex& z) { gsl_complex gz = gsl_complex_sub_real(z.m_gslComplex, a); return Complex(-GSL_REAL(gz), -GSL_IMAG(gz)); } Complex operator * (double a, const Complex& z) { gsl_complex gz = gsl_complex_mul_real(z.m_gslComplex, a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator / (double a, const Complex& z) { gsl_complex ac = gsl_complex_rect(a, 0); // complexization of a gsl_complex gz = gsl_complex_div(ac, z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator + (const Complex& z, double a) { gsl_complex gz = gsl_complex_add_real(z.m_gslComplex, a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator - (const Complex& z, double a) { gsl_complex gz = gsl_complex_sub_real(z.m_gslComplex, a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator * (const Complex& z, double a) { gsl_complex gz = gsl_complex_mul_real(z.m_gslComplex, a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator / (const Complex& z, double a) { gsl_complex gz = gsl_complex_div_real(z.m_gslComplex, a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } /* * Complex functions. */ // Elementary functions double fabs(const Complex& z) { return gsl_complex_abs(z.m_gslComplex); } double abs(const Complex& z) { return gsl_complex_abs(z.m_gslComplex); } Complex conj(const Complex& z) { gsl_complex gz = gsl_complex_conjugate(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex inverse(const Complex& z) { gsl_complex gz = gsl_complex_inverse(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex sqrt(const Complex& z) { gsl_complex gz = gsl_complex_sqrt(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex Csqrt(double a) { gsl_complex gz = gsl_complex_sqrt_real(a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex pow(const Complex& z1, const Complex& z2) { gsl_complex gz = gsl_complex_pow(z1.m_gslComplex, z2.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex pow(const Complex& z, double a) { gsl_complex gz = gsl_complex_pow_real(z.m_gslComplex, a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex exp(const Complex& z) { gsl_complex gz = gsl_complex_exp(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex log(const Complex& z) { gsl_complex gz = gsl_complex_log(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex log10(const Complex& z) { gsl_complex gz = gsl_complex_log10(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } // Trigonometric Complex sin(const Complex& z) { gsl_complex gz = gsl_complex_sin(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex cos(const Complex& z) { gsl_complex gz = gsl_complex_cos(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex tan(const Complex& z) { gsl_complex gz = gsl_complex_tan(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex sec(const Complex& z) { gsl_complex gz = gsl_complex_sec(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex csc(const Complex& z) { gsl_complex gz = gsl_complex_csc(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex cot(const Complex& z) { gsl_complex gz = gsl_complex_cot(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } // Inverse trigonometric Complex asin(const Complex& z) { gsl_complex gz = gsl_complex_arcsin(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex acos(const Complex& z) { gsl_complex gz = gsl_complex_arccos(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex atan(const Complex& z) { gsl_complex gz = gsl_complex_arctan(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex asec(const Complex& z) { gsl_complex gz = gsl_complex_arcsec(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex acsc(const Complex& z) { gsl_complex gz = gsl_complex_arccsc(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex acot(const Complex& z) { gsl_complex gz = gsl_complex_arccot(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } // Hyperbolic Complex sinh(const Complex& z) { gsl_complex gz = gsl_complex_sinh(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex cosh(const Complex& z) { gsl_complex gz = gsl_complex_cosh(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex tanh(const Complex& z) { gsl_complex gz = gsl_complex_tanh(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex sech(const Complex& z) { gsl_complex gz = gsl_complex_sech(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex csch(const Complex& z) { gsl_complex gz = gsl_complex_csch(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex coth(const Complex& z) { gsl_complex gz = gsl_complex_coth(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } // Inverse hyperbolic Complex asinh(const Complex& z) { gsl_complex gz = gsl_complex_arcsinh(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex acosh(const Complex& z) { gsl_complex gz = gsl_complex_arccosh(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex atanh(const Complex& z) { gsl_complex gz = gsl_complex_arctanh(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex asech(const Complex& z) { gsl_complex gz = gsl_complex_arcsech(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex acsch(const Complex& z) { gsl_complex gz = gsl_complex_arccsch(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex acoth(const Complex& z) { gsl_complex gz = gsl_complex_arccoth(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } /** * Write complex number to a stream (for visual output) */ ostream& operator << (ostream& s, const Complex& z) { s << "( " << z.real() << ", " << z.imag() << " )"; return s; } Finally, this is the error Linking... Searching Libraries Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\kernel32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\ws2_32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\advapi32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\msvcrt.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\msvcprt.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\msvcirt.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\oldnames.lib: Searching C:\cygwin\jj\GSL++\GslPP\v0r1\Win32Debug\libGslPP.lib: Searching C:\ARCHIV~1\GSL\lib\libgsld.lib: Searching C:\ARCHIV~1\GSL\lib\libgslcblasd.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\kernel32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\ws2_32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\advapi32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\msvcrt.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\msvcprt.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\msvcirt.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\oldnames.lib: Searching C:\cygwin\jj\GSL++\GslPP\v0r1\Win32Debug\libGslPP.lib: Searching C:\ARCHIV~1\GSL\lib\libgsld.lib: Searching C:\ARCHIV~1\GSL\lib\libgslcblasd.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\kernel32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\ws2_32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\advapi32.lib: Done Searching Libraries libgsld.lib(invhyp.obj) : error LNK2001: unresolved external symbol __HUGE ../Win32Debug/test_complex.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. test_complex.exe - 2 error(s), 0 warning(s) Notice that the missing symbol is in a module of libgsld.lib. I downloaded v1 only a few days ago Incidentally, I also use cygwin in windows. I compiled the library without problems and the test example runs flawlessly. It also runs in Linux. jj ^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: AW: hypergeometric function 2001-12-19 13:20 ` J.J. Gomez Cadenas @ 2001-12-05 12:20 ` J.J. Gomez Cadenas 2001-12-19 13:20 ` Brian Gough 1 sibling, 0 replies; 21+ messages in thread From: J.J. Gomez Cadenas @ 2001-12-05 12:20 UTC (permalink / raw) To: Brian Gough, J.J. Gomez Cadenas; +Cc: gsl-discuss This is the test program. #include "GslPP/DataTypes/Complex.h" #include <iostream> #include <fstream> int main() { double re,im; cout << " Enter the real and imaginary part of a complex number\n"; cout << " >>enter real part "; cin >> re; cout << " >>enter imaginary part "; cin >> im; cout.width(10); cout.precision(12); Complex z1 = Complex (re, im); cout << " z1 = " << z1 << endl << " real part = " << z1.real () << " imag part = " << z1.imag () << " arg = " << z1.arg () << " abs = " << z1.abs () << endl << " z**2 = " << z1.abs2 () << " log |z| = " << z1.logAbs () << endl; double r, theta; cout << " Enter a complex number in polar coordinates\n"; cout << " >>enter radius "; cin >> r; cout << " >>enter polar angle "; cin >> theta; Complex z2 = Complex (); z2.setPolar (r, theta); cout << " z2 = " << z2 << endl << " real part = " << z2.real () << " imag part = " << z2.imag () << " arg = " << z2.arg () << " abs = " << z2.abs () << endl << " z**2 = " << z2.abs2 () << " log |z| = " << z2.logAbs () << endl; /* Assignement operators */ Complex z3 = z1; //Complex& operator = (const Complex& z); Complex z4; z4= 10.0; //Complex& operator = (double d); cout << " z3 must be = z1, z3 = " << z3 << endl; cout << " z4 must be = (10,0), z4 = " << z4 << endl; // Complex& operator += (const Complex& z); z1 += z2; cout << " z1 += z2 = " << z1 << endl; z1 = z3; // Complex& operator -= (const Complex& z); z1 -= z2; cout << " z1 -= z2 = " << z1 << endl; z1 = z3; // Complex& operator *= (const Complex& z); z1 *= z2; cout << " z1 *= z2 = " << z1 << endl; z1 = z3; // Complex& operator *= (double d); z1 *= 10.; cout << " z1 *= 10. = " << z1 << endl; z1 = z3; // Complex& operator /= (const Complex& z); z1 /= z2; cout << " z1 /= z2 = " << z1 << endl; z1 = z3; // Complex& operator /= (double d); z1 /= 10.; cout << " z1 /= 10. = " << z1 << endl; z1 = z3; /* * Operations with complex numbers */ // friend Complex operator - (const Complex& z); //Complex operator + (const Complex& z1, const Complex& z2); cout << " z1 + z2 = " << z1 + z2 << endl; z1 = z3; // Complex operator - (const Complex& z1, const Complex& z2); cout << " z1 - z2 = " << z1 - z2 << endl; z1 = z3; //Complex operator * (const Complex& z1, const Complex& z2); cout << " z1 * z2 = " << z1 * z2 << endl; z1 = z3; // Complex operator / (const Complex& z1, const Complex& z2); cout << " z1 / z2 = " << z1 / z2 << endl; z1 = z3; /* Complex operator + (double a, const Complex& z); Complex operator - (double a, const Complex& z); Complex operator * (double a, const Complex& z); Complex operator / (double a, const Complex& z); */ cout << " 10 + z1 = " << 10. + z1 << endl; z1 = z3; cout << " 10 - z1 = " << 10. - z1 << endl; z1 = z3; cout << " 10 * z2 = " << 10. * z1 << endl; z1 = z3; cout << " 10 / z1 = " << 10. / z1 << endl; z1 = z3; /* Complex operator + (const Complex& z, double a); Complex operator - (const Complex& z, double a); Complex operator * (const Complex& z, double a); Complex operator / (const Complex& z, double a); */ cout << " z1 + 10 = " << z1 + 10. << endl; z1 = z3; cout << " z1 - 10 = " << z1 - 10. << endl; z1 = z3; cout << " z1 * 10 = " << z1 * 10. << endl; z1 = z3; cout << " z1/10 = " << z1/10. << endl; z1 = z3; /* * Complex functions. */ cout << " Elementary functions " << endl << " abs (z1) = " <<abs (z1) <<endl << " conj (z1) = " <<conj (z1) <<endl << " inverse (z1) = " <<inverse (z1) <<endl << " sqrt (z1) = " <<sqrt (z1) <<endl << " Csqrt (10.) = " <<Csqrt (10.) <<endl << " pow (z1,z2) = " <<pow(z1,z2) <<endl << " pow (z1,10.) = " <<pow(z1,10.) <<endl << " exp (z1) = " <<exp(z1) <<endl << " log (z1) = " <<log(z1) <<endl << " log10 (z1) = " <<log10(z1) <<endl; cout << " Trigonometric functions " << endl << " sin (z1) = " <<sin (z1) <<endl << " cos (z1) = " <<cos (z1) <<endl << " tan (z1) = " <<tan (z1) <<endl << " sec (z1) = " <<sec (z1) <<endl << " csc (z1) = " <<csc (z1) <<endl << " cot (z1) = " <<cot (z1) <<endl; cout << " Inverse Trigonometric functions " << endl << " asin (z1) = " <<asin (z1) <<endl << " acos (z1) = " <<acos (z1) <<endl << " atan (z1) = " <<atan (z1) <<endl << " asec (z1) = " <<asec (z1) <<endl << " acsc (z1) = " <<acsc (z1) <<endl << " acot (z1) = " <<acot (z1) <<endl; cout << " Hyperbolic functions " << endl << " sinh (z1) = " <<sinh (z1) <<endl << " cosh (z1) = " <<cosh (z1) <<endl << " tanh (z1) = " <<tanh (z1) <<endl << " sech (z1) = " <<sech (z1) <<endl << " csch (z1) = " <<csch (z1) <<endl << " coth (z1) = " <<coth (z1) <<endl; cout << " Inverse hyperbolic functions " << endl << " asinh (z1) = " <<asinh (z1) <<endl << " acosh (z1) = " <<acosh (z1) <<endl << " atanh (z1) = " <<atanh (z1) <<endl << " asech (z1) = " <<asech (z1) <<endl << " acsch (z1) = " <<acsch (z1) <<endl << " acoth (z1) = " <<acoth (z1) <<endl; return 0; } This is the header Complex.h /* -*- mode: c++ -*- */ /* * Complex.h * This is a wrapper around the complex type defined in the GSL * * This code is part of the * Gsl++library, a C++ wrapper around the GNU Scientific Library (GNU) * * Copyright for this wrapper (C) 2001,2002 * J. Burguet, J.J. Gomez-Cadenas, J.A. Hernando * * For the GSL library * Copyright (C) 1996, 1997, 1998, 1999, 2000 Brian Gough and others, * see documentation of the GSL library * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _COMPLEX_ #define _COMPLEX_ #include <iostream> // to overload ostream& << #include <gsl/gsl_complex.h> #include <gsl/gsl_complex_math.h> using namespace std; //needed by gcc 3.2 and MVC++ /** * Complex numbers * * This is a wrapper class around the complex numbers defined by the GSL * * A gsl complex is a structure defined as: * * typedef struct * { * double dat[2] * } gsl_complex; * * See gsl manual chapter 5 */ class Complex; Complex operator - (const Complex& z); Complex operator + (const Complex& z1, const Complex& z2); ///< z1+z2 Complex operator - (const Complex& z1, const Complex& z2); ///< z1-z2 Complex operator * (const Complex& z1, const Complex& z2); ///< z1*z2 Complex operator / (const Complex& z1, const Complex& z2); ///< z1/z2 Complex operator + (double a, const Complex& z); ///< a + z Complex operator - (double a, const Complex& z); ///< a - z Complex operator * (double a, const Complex& z); ///< a * z Complex operator / (double a, const Complex& z); ///< a / z Complex operator + (const Complex& z, double a); ///< z + a Complex operator - (const Complex& z, double a); ///< z - a Complex operator * (const Complex& z, double a); ///< z * a Complex operator / (const Complex& z, double a); ///< z / ac /* * Complex functions. */ // Elementary functions double fabs(const Complex& z); ///< absolute value, |z| double abs(const Complex& z); ///< absolute value, |z| Complex conj(const Complex& z); ///< complex conjugate Complex inverse(const Complex& z); ///< 1/z Complex sqrt(const Complex& z); ///< complex square root Complex Csqrt(double a); ///< complex sqrt of a real Complex pow(const Complex& z1, const Complex& z2); ///< z1**z2 Complex pow(const Complex& z, double a); ///< z**a Complex exp(const Complex& z); ///< exponential function, exp(z) Complex log(const Complex& z); ///< natural logarithm, log(z) Complex log10(const Complex& z); ///< logarithm in base 10, log10(z) // Trigonometric Complex sin(const Complex& z); ///< sinus, sin(z) Complex cos(const Complex& z); ///< cosinus, cos(z) Complex tan(const Complex& z); ///< tangent, tan(z) Complex sec(const Complex& z); ///< secant, sec(z) = 1/cos(z) Complex csc(const Complex& z); ///< cosecant, cosec(z) = 1/sin(z) Complex cot(const Complex& z); ///< cotangent, cotan(z) = 1/cot(z) // Inverse trigonometric Complex asin(const Complex& z); ///< arcsin(z) Complex acos(const Complex& z); ///< arccos(z) Complex atan(const Complex& z); ///< arctan(z) Complex asec(const Complex& z); ///< arcsec(z) Complex acsc(const Complex& z); ///< arccosec(z) Complex acot(const Complex& z); ///< arccotg(z) // Hyperbolic Complex sinh(const Complex& z); ///< sinh(z) Complex cosh(const Complex& z); ///< cosh(z) Complex tanh(const Complex& z); ///< tanh(z) Complex sech(const Complex& z); ///< sech(z) = 1/cosh(z) Complex csch(const Complex& z); ///< cosech(z) = 1/sinh(z) Complex coth(const Complex& z); ///< cotanh(z) = 1/coth(z) // Inverse hyperbolic Complex asinh(const Complex& z); ///< arcsinh(z) Complex acosh(const Complex& z); ///< arccosh(z) Complex atanh(const Complex& z); ///< arctan(z) Complex asech(const Complex& z); ///< arcsec(z) Complex acsch(const Complex& z); ///< arccosec(z) Complex acoth(const Complex& z); ///< arccotg(z) class Complex { private: gsl_complex m_gslComplex; ///< a gsl complex number public: Complex(); Complex(double x, double y); Complex(const Complex& z); ~Complex(); /* Reading functions */ double real() const; ///< real part, Re(z) double imag() const; ///< imaginary part, Im(z) double arg() const; ///< argument, -pi < arg(z) < pi double abs() const; ///< absolute value, |z| double abs2() const; ///< squared absolute value, |z|**2 double logAbs() const; ///< log|z|. It allows accurate evaluation near |z|=1 /* Setting functions */ void setRectangular(double x, double y); void setPolar(double r, double theta); /* Assignement operators */ Complex& operator = (const Complex& z); Complex& operator = (double d); Complex& operator += (const Complex& z); Complex& operator -= (const Complex& z); Complex& operator *= (const Complex& z); Complex& operator *= (double d); Complex& operator /= (const Complex& z); Complex& operator /= (double d); /* * Friend functions */ /* * Operations with complex numbers */ friend Complex operator - (const Complex& z); friend Complex operator + (const Complex& z1, const Complex& z2); ///< z1+z2 friend Complex operator - (const Complex& z1, const Complex& z2); ///< z1-z2 friend Complex operator * (const Complex& z1, const Complex& z2); ///< z1*z2 friend Complex operator / (const Complex& z1, const Complex& z2); ///< z1/z2 friend Complex operator + (double a, const Complex& z); ///< a + z friend Complex operator - (double a, const Complex& z); ///< a - z friend Complex operator * (double a, const Complex& z); ///< a * z friend Complex operator / (double a, const Complex& z); ///< a / z friend Complex operator + (const Complex& z, double a); ///< z + a friend Complex operator - (const Complex& z, double a); ///< z - a friend Complex operator * (const Complex& z, double a); ///< z * a friend Complex operator / (const Complex& z, double a); ///< z / ac /* * Complex functions. */ // Elementary functions friend double fabs(const Complex& z); ///< absolute value, |z| friend double abs(const Complex& z); ///< absolute value, |z| friend Complex conj(const Complex& z); ///< complex conjugate friend Complex inverse(const Complex& z); ///< 1/z friend Complex sqrt(const Complex& z); ///< complex square root friend Complex Csqrt(double a); ///< complex sqrt of a real friend Complex pow(const Complex& z1, const Complex& z2); ///< z1**z2 friend Complex pow(const Complex& z, double a); ///< z**a friend Complex exp(const Complex& z); ///< exponential function, exp(z) friend Complex log(const Complex& z); ///< natural logarithm, log(z) friend Complex log10(const Complex& z); ///< logarithm in base 10, log10(z) // Trigonometric friend Complex sin(const Complex& z); ///< sinus, sin(z) friend Complex cos(const Complex& z); ///< cosinus, cos(z) friend Complex tan(const Complex& z); ///< tangent, tan(z) friend Complex sec(const Complex& z); ///< secant, sec(z) = 1/cos(z) friend Complex csc(const Complex& z); ///< cosecant, cosec(z) = 1/sin(z) friend Complex cot(const Complex& z); ///< cotangent, cotan(z) = 1/cot(z) // Inverse trigonometric friend Complex asin(const Complex& z); ///< arcsin(z) friend Complex acos(const Complex& z); ///< arccos(z) friend Complex atan(const Complex& z); ///< arctan(z) friend Complex asec(const Complex& z); ///< arcsec(z) friend Complex acsc(const Complex& z); ///< arccosec(z) friend Complex acot(const Complex& z); ///< arccotg(z) // Hyperbolic friend Complex sinh(const Complex& z); ///< sinh(z) friend Complex cosh(const Complex& z); ///< cosh(z) friend Complex tanh(const Complex& z); ///< tanh(z) friend Complex sech(const Complex& z); ///< sech(z) = 1/cosh(z) friend Complex csch(const Complex& z); ///< cosech(z) = 1/sinh(z) friend Complex coth(const Complex& z); ///< cotanh(z) = 1/coth(z) // Inverse hyperbolic friend Complex asinh(const Complex& z); ///< arcsinh(z) friend Complex acosh(const Complex& z); ///< arccosh(z) friend Complex atanh(const Complex& z); ///< arctan(z) friend Complex asech(const Complex& z); ///< arcsec(z) friend Complex acsch(const Complex& z); ///< arccosec(z) friend Complex acoth(const Complex& z); ///< arccotg(z) }; ostream& operator << (ostream& s, const Complex& z); #endif /* _COMPLEX_ */ And this is the .cpp, all straight forward! ** * Complex numbers and complex functions. * * The class Complex is a wrapper around gsl_complex. * * @version v1 * @author JJ Gomez Cadenas, JBC * @date 17/08/2001 */ #include <gsl/gsl_errno.h> #include "GslPP/DataTypes/Complex.h" /** * Default constructor, z = 0. */ Complex::Complex() { m_gslComplex = gsl_complex_rect(0.0, 0.0); } /** * Create a complex number z = x + iy */ Complex::Complex(double x, double y) { m_gslComplex = gsl_complex_rect(x, y); } /** * Copy constructor */ Complex::Complex(const Complex& z) { m_gslComplex = gsl_complex_rect(z.real(), z.imag()); } /** * Destructor */ Complex::~Complex() { } /* * Reading functions. */ /// Real part double Complex::real() const { return GSL_REAL(m_gslComplex); } /// Imaginary part double Complex::imag() const { return GSL_IMAG(m_gslComplex); } /// Argument, -pi < arg < pi double Complex::arg() const { return gsl_complex_arg(m_gslComplex); } /// Modulus double Complex::abs() const { return gsl_complex_abs(m_gslComplex); } /// Modulus squared double Complex::abs2() const { return gsl_complex_abs2(m_gslComplex); } double Complex::logAbs() const { return gsl_complex_logabs(m_gslComplex); } /* * Setting functions */ void Complex::setRectangular(double x, double y) { m_gslComplex = gsl_complex_rect(x, y); } void Complex::setPolar(double r, double theta) { m_gslComplex = gsl_complex_polar(r, theta); } /* * Assignement operators. */ Complex& Complex::operator = (const Complex& z) { m_gslComplex = gsl_complex_rect(z.real(), z.imag()); return *this; } Complex& Complex::operator = (double d) { m_gslComplex = gsl_complex_rect(d, 0.0); return *this; } Complex& Complex::operator += (const Complex& z) m_gslComplex = gsl_complex_add(m_gslComplex, z.m_gslComplex); return *this; } Complex& Complex::operator -= (const Complex& z) { m_gslComplex = gsl_complex_sub(m_gslComplex, z.m_gslComplex); return *this; } Complex& Complex::operator *= (const Complex& z) { m_gslComplex = gsl_complex_mul(m_gslComplex, z.m_gslComplex); return *this; } Complex& Complex::operator *= (double a) { m_gslComplex = gsl_complex_mul_real(m_gslComplex, a); return *this; } Complex& Complex::operator /= (const Complex& z) { m_gslComplex = gsl_complex_div(z.m_gslComplex, m_gslComplex); return *this; } Complex& Complex::operator /= (double a) { m_gslComplex = gsl_complex_div_real(m_gslComplex, a); return *this; } /* * Operations with complex numbers. */ Complex operator - (const Complex& z) { return Complex(-GSL_REAL(z.m_gslComplex), -GSL_IMAG(z.m_gslComplex)); } Complex operator + (const Complex& z1, const Complex& z2) { gsl_complex gz = gsl_complex_add(z1.m_gslComplex, z2.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator - (const Complex& z1, const Complex& z2) { gsl_complex gz = gsl_complex_sub(z1.m_gslComplex, z2.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator * (const Complex& z1, const Complex& z2) { gsl_complex gz = gsl_complex_mul(z1.m_gslComplex, z2.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator / (const Complex& z1, const Complex& z2) { gsl_complex gz = gsl_complex_div(z1.m_gslComplex, z2.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator + (double a, const Complex& z) { gsl_complex gz = gsl_complex_add_real(z.m_gslComplex, a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator - (double a, const Complex& z) { gsl_complex gz = gsl_complex_sub_real(z.m_gslComplex, a); return Complex(-GSL_REAL(gz), -GSL_IMAG(gz)); } Complex operator * (double a, const Complex& z) { gsl_complex gz = gsl_complex_mul_real(z.m_gslComplex, a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator / (double a, const Complex& z) { gsl_complex ac = gsl_complex_rect(a, 0); // complexization of a gsl_complex gz = gsl_complex_div(ac, z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator + (const Complex& z, double a) { gsl_complex gz = gsl_complex_add_real(z.m_gslComplex, a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator - (const Complex& z, double a) { gsl_complex gz = gsl_complex_sub_real(z.m_gslComplex, a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator * (const Complex& z, double a) { gsl_complex gz = gsl_complex_mul_real(z.m_gslComplex, a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex operator / (const Complex& z, double a) { gsl_complex gz = gsl_complex_div_real(z.m_gslComplex, a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } /* * Complex functions. */ // Elementary functions double fabs(const Complex& z) { return gsl_complex_abs(z.m_gslComplex); } double abs(const Complex& z) { return gsl_complex_abs(z.m_gslComplex); } Complex conj(const Complex& z) { gsl_complex gz = gsl_complex_conjugate(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex inverse(const Complex& z) { gsl_complex gz = gsl_complex_inverse(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex sqrt(const Complex& z) { gsl_complex gz = gsl_complex_sqrt(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex Csqrt(double a) { gsl_complex gz = gsl_complex_sqrt_real(a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex pow(const Complex& z1, const Complex& z2) { gsl_complex gz = gsl_complex_pow(z1.m_gslComplex, z2.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex pow(const Complex& z, double a) { gsl_complex gz = gsl_complex_pow_real(z.m_gslComplex, a); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex exp(const Complex& z) { gsl_complex gz = gsl_complex_exp(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex log(const Complex& z) { gsl_complex gz = gsl_complex_log(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex log10(const Complex& z) { gsl_complex gz = gsl_complex_log10(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } // Trigonometric Complex sin(const Complex& z) { gsl_complex gz = gsl_complex_sin(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex cos(const Complex& z) { gsl_complex gz = gsl_complex_cos(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex tan(const Complex& z) { gsl_complex gz = gsl_complex_tan(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex sec(const Complex& z) { gsl_complex gz = gsl_complex_sec(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex csc(const Complex& z) { gsl_complex gz = gsl_complex_csc(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex cot(const Complex& z) { gsl_complex gz = gsl_complex_cot(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } // Inverse trigonometric Complex asin(const Complex& z) { gsl_complex gz = gsl_complex_arcsin(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex acos(const Complex& z) { gsl_complex gz = gsl_complex_arccos(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex atan(const Complex& z) { gsl_complex gz = gsl_complex_arctan(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex asec(const Complex& z) { gsl_complex gz = gsl_complex_arcsec(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex acsc(const Complex& z) { gsl_complex gz = gsl_complex_arccsc(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex acot(const Complex& z) { gsl_complex gz = gsl_complex_arccot(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } // Hyperbolic Complex sinh(const Complex& z) { gsl_complex gz = gsl_complex_sinh(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex cosh(const Complex& z) { gsl_complex gz = gsl_complex_cosh(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex tanh(const Complex& z) { gsl_complex gz = gsl_complex_tanh(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex sech(const Complex& z) { gsl_complex gz = gsl_complex_sech(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex csch(const Complex& z) { gsl_complex gz = gsl_complex_csch(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex coth(const Complex& z) { gsl_complex gz = gsl_complex_coth(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } // Inverse hyperbolic Complex asinh(const Complex& z) { gsl_complex gz = gsl_complex_arcsinh(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex acosh(const Complex& z) { gsl_complex gz = gsl_complex_arccosh(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex atanh(const Complex& z) { gsl_complex gz = gsl_complex_arctanh(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex asech(const Complex& z) { gsl_complex gz = gsl_complex_arcsech(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex acsch(const Complex& z) { gsl_complex gz = gsl_complex_arccsch(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } Complex acoth(const Complex& z) { gsl_complex gz = gsl_complex_arccoth(z.m_gslComplex); return Complex(GSL_REAL(gz), GSL_IMAG(gz)); } /** * Write complex number to a stream (for visual output) */ ostream& operator << (ostream& s, const Complex& z) { s << "( " << z.real() << ", " << z.imag() << " )"; return s; } Finally, this is the error Linking... Searching Libraries Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\kernel32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\ws2_32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\advapi32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\msvcrt.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\msvcprt.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\msvcirt.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\oldnames.lib: Searching C:\cygwin\jj\GSL++\GslPP\v0r1\Win32Debug\libGslPP.lib: Searching C:\ARCHIV~1\GSL\lib\libgsld.lib: Searching C:\ARCHIV~1\GSL\lib\libgslcblasd.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\kernel32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\ws2_32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\advapi32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\msvcrt.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\msvcprt.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\msvcirt.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\oldnames.lib: Searching C:\cygwin\jj\GSL++\GslPP\v0r1\Win32Debug\libGslPP.lib: Searching C:\ARCHIV~1\GSL\lib\libgsld.lib: Searching C:\ARCHIV~1\GSL\lib\libgslcblasd.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\kernel32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\ws2_32.lib: Searching C:\Archivos de programa\Microsoft Visual Studio\VC98\LIB\advapi32.lib: Done Searching Libraries libgsld.lib(invhyp.obj) : error LNK2001: unresolved external symbol __HUGE ../Win32Debug/test_complex.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. test_complex.exe - 2 error(s), 0 warning(s) Notice that the missing symbol is in a module of libgsld.lib. I downloaded v1 only a few days ago Incidentally, I also use cygwin in windows. I compiled the library without problems and the test example runs flawlessly. It also runs in Linux. jj ^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: AW: hypergeometric function 2001-12-19 13:20 ` J.J. Gomez Cadenas 2001-12-05 12:20 ` J.J. Gomez Cadenas @ 2001-12-19 13:20 ` Brian Gough 2001-12-06 8:34 ` Brian Gough 2001-12-19 13:20 ` J.J. Gomez Cadenas 1 sibling, 2 replies; 21+ messages in thread From: Brian Gough @ 2001-12-19 13:20 UTC (permalink / raw) To: J.J. Gomez Cadenas; +Cc: J.J. Gomez Cadenas, gsl-discuss J.J. Gomez Cadenas writes: > Done Searching Libraries > libgsld.lib(invhyp.obj) : error LNK2001: unresolved external symbol __HUGE > ../Win32Debug/test_complex.exe : fatal error LNK1120: 1 unresolved externals > Error executing link.exe. > > test_complex.exe - 2 error(s), 0 warning(s) > > Notice that the missing symbol is in a module of libgsld.lib. I downloaded > v1 only a few days ago > Hi, I couldn't even get that far unfortunately (see below). Have you tried recompiling the library yourself using GSL.dsw? Brian --------------------Configuration: test - Win32 Debug-------------------- Compiling... jjtest.c c:\program files\microsoft visual studio\vc98\include\eh.h(32) : fatal error C1189: #error : "eh.h is only for C++!" Error executing cl.exe. jjtest.obj - 1 error(s), 0 warning(s) --------------------Configuration: test - Win32 Debug-------------------- Compiling... GSL_Complex.cpp c:\program files\microsoft visual studio\vc98\include\utility(81) : error C2146: syntax error : missing ';' before identifier 'iterator_category' c:\program files\microsoft visual studio\vc98\include\utility(84) : see reference to class template instantiation 'std::iterator_traits<_It>' being compiled c:\program files\microsoft visual studio\vc98\include\utility(81) : error C2838: illegal qualified name in member declaration c:\program files\microsoft visual studio\vc98\include\utility(84) : see reference to class template instantiation 'std::iterator_traits<_It>' being compiled .... c:\program files\microsoft visual studio\vc98\include\xstring(292) : see declaration of 'replace' c:\program files\microsoft visual studio\vc98\include\xstring(597) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled c:\program files\microsoft visual studio\vc98\include\xstring(297) : fatal error C1003: error count exceeds 100; stopping compilation c:\program files\microsoft visual studio\vc98\include\xstring(597) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled Error executing cl.exe. GSL_Complex.obj - 102 error(s), 0 warning(s) ^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: AW: hypergeometric function 2001-12-19 13:20 ` Brian Gough @ 2001-12-06 8:34 ` Brian Gough 2001-12-19 13:20 ` J.J. Gomez Cadenas 1 sibling, 0 replies; 21+ messages in thread From: Brian Gough @ 2001-12-06 8:34 UTC (permalink / raw) To: J.J. Gomez Cadenas; +Cc: J.J. Gomez Cadenas, gsl-discuss J.J. Gomez Cadenas writes: > Done Searching Libraries > libgsld.lib(invhyp.obj) : error LNK2001: unresolved external symbol __HUGE > ../Win32Debug/test_complex.exe : fatal error LNK1120: 1 unresolved externals > Error executing link.exe. > > test_complex.exe - 2 error(s), 0 warning(s) > > Notice that the missing symbol is in a module of libgsld.lib. I downloaded > v1 only a few days ago > Hi, I couldn't even get that far unfortunately (see below). Have you tried recompiling the library yourself using GSL.dsw? Brian --------------------Configuration: test - Win32 Debug-------------------- Compiling... jjtest.c c:\program files\microsoft visual studio\vc98\include\eh.h(32) : fatal error C1189: #error : "eh.h is only for C++!" Error executing cl.exe. jjtest.obj - 1 error(s), 0 warning(s) --------------------Configuration: test - Win32 Debug-------------------- Compiling... GSL_Complex.cpp c:\program files\microsoft visual studio\vc98\include\utility(81) : error C2146: syntax error : missing ';' before identifier 'iterator_category' c:\program files\microsoft visual studio\vc98\include\utility(84) : see reference to class template instantiation 'std::iterator_traits<_It>' being compiled c:\program files\microsoft visual studio\vc98\include\utility(81) : error C2838: illegal qualified name in member declaration c:\program files\microsoft visual studio\vc98\include\utility(84) : see reference to class template instantiation 'std::iterator_traits<_It>' being compiled .... c:\program files\microsoft visual studio\vc98\include\xstring(292) : see declaration of 'replace' c:\program files\microsoft visual studio\vc98\include\xstring(597) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled c:\program files\microsoft visual studio\vc98\include\xstring(297) : fatal error C1003: error count exceeds 100; stopping compilation c:\program files\microsoft visual studio\vc98\include\xstring(597) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled Error executing cl.exe. GSL_Complex.obj - 102 error(s), 0 warning(s) ^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: AW: hypergeometric function 2001-12-19 13:20 ` Brian Gough 2001-12-06 8:34 ` Brian Gough @ 2001-12-19 13:20 ` J.J. Gomez Cadenas 2001-12-06 9:15 ` J.J. Gomez Cadenas 2001-12-19 13:20 ` J.J. Gomez Cadenas 1 sibling, 2 replies; 21+ messages in thread From: J.J. Gomez Cadenas @ 2001-12-19 13:20 UTC (permalink / raw) To: Brian Gough, J.J. Gomez Cadenas; +Cc: J.J. Gomez Cadenas, gsl-discuss Hi Brian, No, I haven't tried, I just downloaded the .exe program. I may try next week. MVC++ is a pain in the neck... jj -----Mensaje original----- De: Brian Gough [ mailto:bjg@network-theory.co.uk ] Enviado el: jueves, 13 de diciembre de 2001 0:36 Para: J.J. Gomez Cadenas CC: J.J. Gomez Cadenas; gsl-discuss@sources.redhat.com Asunto: RE: AW: hypergeometric function J.J. Gomez Cadenas writes: > Done Searching Libraries > libgsld.lib(invhyp.obj) : error LNK2001: unresolved external symbol __HUGE > ../Win32Debug/test_complex.exe : fatal error LNK1120: 1 unresolved externals > Error executing link.exe. > > test_complex.exe - 2 error(s), 0 warning(s) > > Notice that the missing symbol is in a module of libgsld.lib. I downloaded > v1 only a few days ago > Hi, I couldn't even get that far unfortunately (see below). Have you tried recompiling the library yourself using GSL.dsw? Brian --------------------Configuration: test - Win32 Debug-------------------- Compiling... jjtest.c c:\program files\microsoft visual studio\vc98\include\eh.h(32) : fatal error C1189: #error : "eh.h is only for C++!" Error executing cl.exe. jjtest.obj - 1 error(s), 0 warning(s) --------------------Configuration: test - Win32 Debug-------------------- Compiling... GSL_Complex.cpp c:\program files\microsoft visual studio\vc98\include\utility(81) : error C2146: syntax error : missing ';' before identifier 'iterator_category' c:\program files\microsoft visual studio\vc98\include\utility(84) : see reference to class template instantiation 'std::iterator_traits<_It>' being compiled c:\program files\microsoft visual studio\vc98\include\utility(81) : error C2838: illegal qualified name in member declaration c:\program files\microsoft visual studio\vc98\include\utility(84) : see reference to class template instantiation 'std::iterator_traits<_It>' being compiled .... c:\program files\microsoft visual studio\vc98\include\xstring(292) : see declaration of 'replace' c:\program files\microsoft visual studio\vc98\include\xstring(597) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled c:\program files\microsoft visual studio\vc98\include\xstring(297) : fatal error C1003: error count exceeds 100; stopping compilation c:\program files\microsoft visual studio\vc98\include\xstring(597) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled Error executing cl.exe. GSL_Complex.obj - 102 error(s), 0 warning(s) ^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: AW: hypergeometric function 2001-12-19 13:20 ` J.J. Gomez Cadenas @ 2001-12-06 9:15 ` J.J. Gomez Cadenas 2001-12-19 13:20 ` J.J. Gomez Cadenas 1 sibling, 0 replies; 21+ messages in thread From: J.J. Gomez Cadenas @ 2001-12-06 9:15 UTC (permalink / raw) To: Brian Gough, J.J. Gomez Cadenas; +Cc: J.J. Gomez Cadenas, gsl-discuss Hi Brian, No, I haven't tried, I just downloaded the .exe program. I may try next week. MVC++ is a pain in the neck... jj -----Mensaje original----- De: Brian Gough [mailto:bjg@network-theory.co.uk] Enviado el: jueves, 13 de diciembre de 2001 0:36 Para: J.J. Gomez Cadenas CC: J.J. Gomez Cadenas; gsl-discuss@sources.redhat.com Asunto: RE: AW: hypergeometric function J.J. Gomez Cadenas writes: > Done Searching Libraries > libgsld.lib(invhyp.obj) : error LNK2001: unresolved external symbol __HUGE > ../Win32Debug/test_complex.exe : fatal error LNK1120: 1 unresolved externals > Error executing link.exe. > > test_complex.exe - 2 error(s), 0 warning(s) > > Notice that the missing symbol is in a module of libgsld.lib. I downloaded > v1 only a few days ago > Hi, I couldn't even get that far unfortunately (see below). Have you tried recompiling the library yourself using GSL.dsw? Brian --------------------Configuration: test - Win32 Debug-------------------- Compiling... jjtest.c c:\program files\microsoft visual studio\vc98\include\eh.h(32) : fatal error C1189: #error : "eh.h is only for C++!" Error executing cl.exe. jjtest.obj - 1 error(s), 0 warning(s) --------------------Configuration: test - Win32 Debug-------------------- Compiling... GSL_Complex.cpp c:\program files\microsoft visual studio\vc98\include\utility(81) : error C2146: syntax error : missing ';' before identifier 'iterator_category' c:\program files\microsoft visual studio\vc98\include\utility(84) : see reference to class template instantiation 'std::iterator_traits<_It>' being compiled c:\program files\microsoft visual studio\vc98\include\utility(81) : error C2838: illegal qualified name in member declaration c:\program files\microsoft visual studio\vc98\include\utility(84) : see reference to class template instantiation 'std::iterator_traits<_It>' being compiled .... c:\program files\microsoft visual studio\vc98\include\xstring(292) : see declaration of 'replace' c:\program files\microsoft visual studio\vc98\include\xstring(597) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled c:\program files\microsoft visual studio\vc98\include\xstring(297) : fatal error C1003: error count exceeds 100; stopping compilation c:\program files\microsoft visual studio\vc98\include\xstring(597) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled Error executing cl.exe. GSL_Complex.obj - 102 error(s), 0 warning(s) ^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: AW: hypergeometric function 2001-12-19 13:20 ` J.J. Gomez Cadenas 2001-12-06 9:15 ` J.J. Gomez Cadenas @ 2001-12-19 13:20 ` J.J. Gomez Cadenas 1 sibling, 0 replies; 21+ messages in thread From: J.J. Gomez Cadenas @ 2001-12-19 13:20 UTC (permalink / raw) To: Brian Gough, J.J. Gomez Cadenas; +Cc: J.J. Gomez Cadenas, gsl-discuss Hi Brian, No, I haven't tried, I just downloaded the .exe program. I may try next week. MVC++ is a pain in the neck... jj -----Mensaje original----- De: Brian Gough [mailto:bjg@network-theory.co.uk] Enviado el: jueves, 13 de diciembre de 2001 0:36 Para: J.J. Gomez Cadenas CC: J.J. Gomez Cadenas; gsl-discuss@sources.redhat.com Asunto: RE: AW: hypergeometric function J.J. Gomez Cadenas writes: > Done Searching Libraries > libgsld.lib(invhyp.obj) : error LNK2001: unresolved external symbol __HUGE > ../Win32Debug/test_complex.exe : fatal error LNK1120: 1 unresolved externals > Error executing link.exe. > > test_complex.exe - 2 error(s), 0 warning(s) > > Notice that the missing symbol is in a module of libgsld.lib. I downloaded > v1 only a few days ago > Hi, I couldn't even get that far unfortunately (see below). Have you tried recompiling the library yourself using GSL.dsw? Brian --------------------Configuration: test - Win32 Debug-------------------- Compiling... jjtest.c c:\program files\microsoft visual studio\vc98\include\eh.h(32) : fatal error C1189: #error : "eh.h is only for C++!" Error executing cl.exe. jjtest.obj - 1 error(s), 0 warning(s) --------------------Configuration: test - Win32 Debug-------------------- Compiling... GSL_Complex.cpp c:\program files\microsoft visual studio\vc98\include\utility(81) : error C2146: syntax error : missing ';' before identifier 'iterator_category' c:\program files\microsoft visual studio\vc98\include\utility(84) : see reference to class template instantiation 'std::iterator_traits<_It>' being compiled c:\program files\microsoft visual studio\vc98\include\utility(81) : error C2838: illegal qualified name in member declaration c:\program files\microsoft visual studio\vc98\include\utility(84) : see reference to class template instantiation 'std::iterator_traits<_It>' being compiled .... c:\program files\microsoft visual studio\vc98\include\xstring(292) : see declaration of 'replace' c:\program files\microsoft visual studio\vc98\include\xstring(597) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled c:\program files\microsoft visual studio\vc98\include\xstring(297) : fatal error C1003: error count exceeds 100; stopping compilation c:\program files\microsoft visual studio\vc98\include\xstring(597) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled Error executing cl.exe. GSL_Complex.obj - 102 error(s), 0 warning(s) ^ permalink raw reply [flat|nested] 21+ messages in thread
* RE: AW: hypergeometric function 2001-12-19 13:20 ` J.J. Gomez Cadenas 2001-12-05 2:07 ` J.J. Gomez Cadenas 2001-12-19 13:20 ` Brian Gough @ 2001-12-19 13:20 ` J.J. Gomez Cadenas 2 siblings, 0 replies; 21+ messages in thread From: J.J. Gomez Cadenas @ 2001-12-19 13:20 UTC (permalink / raw) To: gsl-discuss Hi all, I get the problem below when trying to link a test program for a C++ complex class that wraps gsl complex. The program compiles fine AND compiles, links and executes no problem in Linux. I have just downloaded version v1 of GSL for windows. Any ideas? Note: I have searched in the sources for "HUGE" and I only find the work in gsl_nan.h However, I cannot see the word __HUGE there... thanks, jj This is the error.... Done Searching Libraries libgsld.lib(invhyp.obj) : error LNK2001: unresolved external symbol __HUGE ../Win32Debug/test_complex.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. ^ permalink raw reply [flat|nested] 21+ messages in thread
end of thread, other threads:[~2001-12-19 13:20 UTC | newest] Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2001-12-19 13:20 hypergeometric function Stefan Koch 2001-12-01 23:20 ` Stefan Koch 2001-12-19 13:20 ` Dan, Ho-Jin 2001-12-02 18:35 ` Dan, Ho-Jin 2001-12-19 13:20 ` Dan, Ho-Jin 2001-12-19 13:20 ` Brian Gough 2001-12-03 8:21 ` Brian Gough [not found] ` <NEBBIBGCPKOPEIODNFDIEEIHCAAA.s.koch@seh-zuelpich.de> 2001-12-19 13:20 ` AW: " Brian Gough 2001-12-03 15:27 ` Brian Gough 2001-12-19 13:20 ` J.J. Gomez Cadenas 2001-12-05 2:07 ` J.J. Gomez Cadenas 2001-12-19 13:20 ` Brian Gough 2001-12-05 12:20 ` Brian Gough 2001-12-19 13:20 ` J.J. Gomez Cadenas 2001-12-05 12:20 ` J.J. Gomez Cadenas 2001-12-19 13:20 ` Brian Gough 2001-12-06 8:34 ` Brian Gough 2001-12-19 13:20 ` J.J. Gomez Cadenas 2001-12-06 9:15 ` J.J. Gomez Cadenas 2001-12-19 13:20 ` J.J. Gomez Cadenas 2001-12-19 13:20 ` J.J. Gomez Cadenas
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).