<div dir="ltr"><div><div><div><div>Thanks for answer, <br>but with C we can compile the trapeze function and put it in librairy, <br></div>If we try to save the trapeze alone in package to import it later, I think, I am not sure<br>
</div>it will be refused because F1 and sin are not define !!! this is the power of the C pointers !!!<br></div>the link is dynamic<br><br></div>thanks<br><div><div><div><div><br></div></div></div></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Apr 18, 2013 at 6:17 PM, Karim <span dir="ltr"><<a href="mailto:kliateni@gmail.com" target="_blank">kliateni@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
<div><br>
Hello,<br>
<br>
There is no such notion in python.<br>
But the closest are iterators and generator functions.<br>
<br>
Cheers<span class="HOEnZb"><font color="#888888"><br>
Karim</font></span><div><div class="h5"><br>
<br>
On 18/04/2013 19:06, abdelkader belahcene wrote:<br>
</div></div></div><div><div class="h5">
<blockquote type="cite">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>Hi everybody, <br>
<br>
</div>
I am new to python and I am discovering it.<br>
</div>
I know C well,<br>
</div>
and want to know if python knows how to manage Pointers<br>
</div>
like pointer to function here is a C example how to write
it in python<br>
</div>
<div>Intergration with trapeze method<br>
</div>
<div><br>
</div>
When we write Trapeze ( at the compilation level) we don't
know which functions <br>
</div>
Fonc to handle. Here for example we use sin and a user
defined F1<br>
</div>
The program is attached too<br>
<div><br>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>
<div>#include <stdio.h><br>
#include <math.h><br>
<br>
double F1 (double x){ <br>
return x*x; <br>
}<br>
double Trapeze(double Fonc(double ), <br>
double left,
double right, double step){<br>
double X1, X0, Y0, Y1, Z = 0; <br>
for(X0=left; X0 < right ; X0 = X0 +
step) {<br>
X1 = X0 + step;<br>
Y1 = Fonc(X1); Y0 = Fonc(X0);<br>
Z += (Y1 + Y0) * step * 0.5;<br>
}<br>
return Z;<br>
}<br>
int main(){ <br>
double y;<br>
y=Trapeze(sin, -2.5, 3.2, 0.1);<br>
printf("\n\tValue for sin is : \t %8.3lf
", y);<br>
y=Trapeze(F1, 0, 3, 0.1);<br>
printf("\n\tValue for F1 is : \t %8.3lf ",
y);<br>
return 0;<br>
} <br>
/**<br>
Value for sin is : 0.197 <br>
Value for F1 is : 9.005<br>
*/<br>
</div>
<div>
thanks a lot<br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<br>
</blockquote>
<br>
</div></div></div>
</blockquote></div><br></div>