alpar@711: // -*- mode:C++ -*- alpar@711: #ifndef HUGO_BENCH_TEST_H alpar@711: #define HUGO_BENCH_TEST_H alpar@711: alpar@711: #include alpar@718: #include alpar@718: alpar@718: #include alpar@711: alpar@711: ///An experimental typedef factory alpar@711: #define GRAPH_TYPEDEF_FACTORY(Graph) \ alpar@711: typedef typename Graph:: Node Node;\ alpar@711: typedef typename Graph:: NodeIt NodeIn;\ alpar@711: typedef typename Graph:: Edge Edge;\ alpar@711: typedef typename Graph:: EdgeIt EdgeIt;\ alpar@711: typedef typename Graph:: InEdgeIt InEdgeIt;\ alpar@711: typedef typename Graph::OutEdgeIt OutEdgeIt; alpar@711: alpar@711: #define GRAPH_TYPEDEF_FACTORY_NOTYPENAME(Graph) \ alpar@711: typedef Graph:: Node Node;\ alpar@711: typedef Graph:: NodeIt NodeIn;\ alpar@711: typedef Graph:: Edge Edge;\ alpar@711: typedef Graph:: EdgeIt EdgeIt;\ alpar@711: typedef Graph:: InEdgeIt InEdgeIt;\ alpar@711: typedef Graph::OutEdgeIt OutEdgeIt; alpar@711: alpar@711: alpar@711: ///A primitive primtest alpar@718: alpar@718: ///\bug 2 is not a prime according to this function! alpar@711: bool isPrim(int n) alpar@711: { alpar@711: if(n%2) { alpar@711: for(int k=3;n/k>=k;k+=2) alpar@711: if(!(n%k)) return false; alpar@711: return true; alpar@711: } alpar@711: return false; alpar@711: } alpar@711: alpar@711: ///Finds the smallest prime not less then \c n. alpar@711: int nextPrim(int n) alpar@711: { alpar@711: for(n+=!(n%2);!isPrim(n);n+=2) ; alpar@711: return n; alpar@711: } alpar@711: alpar@711: alpar@711: /// Class to generate consecutive primes alpar@711: class Primes alpar@711: { alpar@711: std::vector primes; alpar@711: int n; alpar@711: alpar@711: bool isPrime(int m) alpar@711: { alpar@711: for(int i=0;m