home *** CD-ROM | disk | FTP | other *** search
- /* #include <math.h> */
- #include <net.h>
-
-
- #define PI 3.1415926536
- #define UNEND 1e4
- #define INTERVALLE 20000
- #define FVEKSIZE 3
-
- /* Nachrichtenstruktur */
- struct Nachr{
- int MatZeilenNr;
- double MatZeile[FVEKSIZE];
- } Nachricht;
-
- extern double sin();
- int errno;
-
- double UeberlappIntegralTrapez(f1,f2,a,b,n)
- double (*f1)();
- double (*f2)();
- double a,b;
- int n;
- {
- double integ, step, aktx;
- int i;
-
- step = (b-a)/n;
- integ = 0.0;
- for( i = 0, aktx = a + step; i < (n-1); i++, aktx += step){
- integ += 2.0*((*f1)(aktx))*((*f2)(aktx));
- }
- integ += ((*f1)(a))*((*f2)(a));
- integ += ((*f1)(b))*((*f2)(b));
- integ *= (step/2.0);
- return(integ);
- }
-
-
-
-
- double MyF(x)
- double x;
- {
- return(2.0*x);
- }
-
- double ZweiS(r)
- double r;
- {
- return(exp(-r)*r);
- }
-
-
- double (* fvek[FVEKSIZE])();
-
- main(){
- int i,j;
-
- fvek[0] = MyF;
- fvek[1] = sin;
- fvek[2] = ZweiS;
-
- for(;;){
- /* Zeile loeschen */
- for(j = 0; j < FVEKSIZE; j++) Nachricht.MatZeile[j] = 0.0;
-
- /* Horchen welche Zeile dran ist */
- net_receive(&i,&j);
- Nachricht.MatZeilenNr = i;
-
- /* Matrixzeile berechnen */
- for (j = 0; j < FVEKSIZE; j++){
- Nachricht.MatZeile[j] = UeberlappIntegralTrapez(fvek[i],fvek[j],0.0,UNEND,INTERVALLE);
- }
- /* Und zuruecksenden */
- net_send(sizeof(Nachricht),&Nachricht,1);
- }
- }