par Andeval » 31 Déc 2002 20:21
Bonsoir...
<BR>Bien que je ne sois pas sur un forum de C++
<BR><IMG SRC="images/smiles/icon_biggrin.gif">
<BR>.....J'ai un petit probleme dans l'exemple suivant: (merci de m'indiquer l'erreur car j'ai encore un peu de mal a les "detecter" <IMG SRC="images/smiles/icon_wink.gif"> )
<BR>
<BR>
<BR>#ifdef aCC
<BR>#include <complex>
<BR>#else
<BR>#include <complex.h>
<BR>#endif
<BR>
<BR>#include <stdio.h>
<BR>#include <iostream.h>
<BR>
<BR>extern "C" c05ajf_(double *x, double *eps, double *eta, double (*f)(double *), int *nfmax, int *ifail);
<BR>
<BR>int main()
<BR>{
<BR> double eps, eta, x;
<BR> int ifail, k, nfmax;
<BR> double f(double *);
<BR>
<BR>#ifdef aCC
<BR> complex <float> z1,z2;
<BR>#else
<BR> complex z1,z2;
<BR>#endif
<BR>
<BR> ios::sync_with_stdio(); // for working together
<BR>
<BR>#ifdef aCC
<BR> z1=sqrt(complex <float> (0.0,1.0));
<BR>#else
<BR> z1=sqrt(complex(0.0,1.0));
<BR>#endif
<BR> cout << "C++ stuff:n sqrt(i)=" << real(z1) << "+i" << imag(z1) << "n";
<BR>
<BR> printf("C05AJF Example Program Resultsnn");
<BR> for (k=1; k<=2; k++)
<BR> {
<BR> eps = k==1 ? 0.1e-3 : 0.1e-4;
<BR> x = 1.0;
<BR> eta = 0.0;
<BR> nfmax = 200;
<BR> ifail = 1;
<BR> c05ajf_(&x,&eps,&eta,f,&nfmax,&ifail);
<BR> if (ifail==0)
<BR> printf("With eps = %e root = %fn",eps,x);
<BR> else
<BR> {
<BR> printf("ifail = %dn",ifail);
<BR> if (ifail==3 || ifail==4)
<BR> printf("With eps = %e final value = %fn",eps,x);
<BR> }
<BR> }
<BR>}
<BR>double f(double *x)
<BR>{
<BR> return exp(-*x) - *x;
<BR>}
<BR>
<BR>
<BR>``script'' pour la compilation et l'exécution avec les compilateurs C++ des systèmes :
<BR>#!/usr/local/bin/tcsh
<BR>if ( "$SYSTEM" == 'AIX'&'ATX' ) then
<BR>xlC nagex1b.C `cernlib nag` -lxlf90 -lxlf -lcomplex -lm
<BR>endif
<BR>if ( "$SYSTEM" == 'HP-UX' ) then
<BR>if ( "$SYSVER" == 'A.09.05' ) then
<BR>CC nagex1b.C `cernlib nag` -lf -lcomplex
<BR>endif
<BR>if ( "$SYSVER" == 'B.10.20' ) then
<BR>aCC -DaCC nagex1b.C `cernlib nag` -lf
<BR>endif
<BR>endif
<BR>./a.out
<BR>rm a.out
<BR>exit