main.cpp File Reference

#include "par.h"
#include <iostream>

Go to the source code of this file.

Namespaces

namespace  std

Functions

int main ()


Function Documentation

int main  ) 
 

Definition at line 9 of file main.cpp.

References endifp, and ifp.

00010 {
00011 
00012 // ***************** TEST #1 CALCULATE PI *****************
00013 par<double> x(100000);
00014 double pi;
00015 addr(x);
00016 pi += 4.0/(1.0+(x*2.0))*pow(-1.0,x); 
00017 cout << "PI = " << setw(30) <<setprecision(25)<< pi << endl << endl;
00018 
00019 // ***************** TEST #2 SHUFFLE EXCHANGE SORT (not working!) *********************
00020 int const N=6;
00021 par<int> list(N), LEFT(N), RIGHT(N), self(N), temp(N);
00022 int l[]={80, 40 , 30 , 50 , 60, 10 };
00023 list = l;
00024 addr(self);
00025 
00026 for (int j=1; j<=N/2; j++)
00027         {
00028         cout << "-->  " << list << endl;
00029         LEFT = rotate(list,-1);
00030         cout << "left " << LEFT << endl;
00031         RIGHT = rotate(list,1);
00032         cout << "right" << RIGHT << endl;
00033         ifp (self%2 == 0 )
00034                 {
00035                 ifp (RIGHT < list)
00036                         { list=RIGHT; }
00037                         endifp  
00038                 ifp (LEFT >= list) 
00039                         { list=LEFT; }
00040                         endifp
00041                 }
00042                 endifp
00043 /*    cout << "-->  " << list << endl;
00044         LEFT = rotate(list,-1);
00045         cout << "left " << LEFT << endl;
00046         RIGHT = rotate(list,1);
00047         cout << "right" << RIGHT << endl;
00048         ifp ((self+1)%2 == 0 && self!=(N-1))
00049                 {
00050                 ifp (RIGHT > list)
00051                         { list=RIGHT; }
00052                         endifp  
00053                 ifp (RIGHT >= list)
00054                         { list=LEFT; }
00055                         endifp
00056                 }
00057                 endifp
00058 */      }
00059 cout << "FINAL" << list << endl;
00060 
00061 
00062 // ******************* TEST #3 PRIMES BY SEIVE ***************
00063 const int psize=100;
00064 par<int> primes(psize);
00065 par<bool> pflag(psize);
00066 int p=2;
00067 
00068 cout << "primes -> " << endl;
00069 pflag = true; pflag[0]=false; pflag[1]=false;
00070 addr(primes);
00071 while (any(pflag))
00072         {
00073         cerr << p << " ";
00074         pflag = (pflag & ((primes % p) != 0 ));
00075         ifp (pflag==true)       
00076                 p = first_index(pflag);         
00077         endifp
00078         }
00079 cout << endl;
00080 
00081 return 0;
00082 }


Generated on Tue Jan 4 17:45:20 2005 for ZIPPAR by  doxygen 1.3.9.1