]> https://gitweb.dealii.org/ - dealii.git/commitdiff
write own rand() function for the test suite because cygwin has a different implement...
authorTimo Heister <timo.heister@gmail.com>
Thu, 21 Nov 2013 03:07:40 +0000 (03:07 +0000)
committerTimo Heister <timo.heister@gmail.com>
Thu, 21 Nov 2013 03:07:40 +0000 (03:07 +0000)
git-svn-id: https://svn.dealii.org/trunk@31745 0785d39b-7218-0410-832d-ea1e28bc413d

35 files changed:
tests/base/symmetric_tensor_25.cc
tests/base/symmetric_tensor_26.cc
tests/bits/fe_q_constraints.cc
tests/bits/full_matrix_56.cc
tests/bits/joa_1.cc
tests/bits/point_value_hp_01.cc
tests/bits/point_value_hp_02.cc
tests/bits/rt_2.cc
tests/fail/abf_approximation_01.cc
tests/fe/rt_approximation_01.cc
tests/fe/rt_normal_02.cc
tests/hp/count_dofs_per_block_01.cc
tests/hp/count_dofs_per_block_02.cc
tests/hp/crash_10.cc
tests/hp/hp_hanging_nodes_02.cc
tests/lac/full_matrix.cc
tests/lac/full_matrix_02.cc
tests/lac/full_matrix_03.cc
tests/lac/full_matrix_04.cc
tests/lac/sparse_ilu.cc
tests/lac/sparse_ilu_t.cc
tests/lac/sparse_matrix_Tmmult_01.cc
tests/lac/sparse_matrix_Tmmult_02.cc
tests/lac/sparse_matrix_mmult_01.cc
tests/lac/sparse_matrix_mmult_02.cc
tests/lac/sparse_mic.cc
tests/mpi/constraint_matrix_trilinos_bug.cc
tests/mpi/mg_05.cc
tests/mpi/mg_06.cc
tests/mpi/p4est_2d_constraintmatrix_03.cc
tests/mpi/p4est_2d_constraintmatrix_04.cc
tests/mpi/p4est_3d_constraintmatrix_01.cc
tests/mpi/p4est_3d_constraintmatrix_02.cc
tests/mpi/p4est_3d_constraintmatrix_03.cc
tests/tests.h

index 6b74730049a32c62f0bef8b60f8f5da807fbb9a1..d61f2359e4818b04f7c24c27e8d6eb43d52c6765 100644 (file)
@@ -33,7 +33,7 @@ void check ()
     {
       SymmetricTensor<2,dim> S;
       for (unsigned int i=0; i<S.n_independent_components; ++i)
-        S[S.unrolled_to_component_indices (i)] = std::rand () % 10;
+        S[S.unrolled_to_component_indices (i)] = rand() % 10;
 
       deallog << "S = " << S << std::endl;
       deallog << "first invariant  = " << first_invariant(S) << std::endl;
index 50dfd226ee3b0aafff129836123abb64797e6e9c..59a6b28c447dfc5c5281eef054389008b780320f 100644 (file)
@@ -30,11 +30,11 @@ void check ()
 {
   SymmetricTensor<2,dim> S;
   for (unsigned int i=0; i<S.n_independent_components; ++i)
-    S[S.unrolled_to_component_indices (i)] = std::rand () % 10;
+    S[S.unrolled_to_component_indices (i)] = rand() % 10;
 
   Tensor<1,dim> x;
   for (unsigned int i=0; i<dim; ++i)
-    x[i] = std::rand() % 10;
+    x[i] = rand() % 10;
 
   deallog << "S = " << S << std::endl;
   deallog << "x = " << x << std::endl;
index de93aa18d0955832d9ec2ba923d1aaa5e1eef96b..743ea9d7a37742bc41c3401edd634ace20b0e7cc 100644 (file)
@@ -78,7 +78,7 @@ TestFunction<dim>::TestFunction (const unsigned int p_order) :
   for (unsigned int d = 0; d < dim; ++d)
     {
       for (unsigned int c = 0; c < p_order; ++c)
-        coeff[c] = (double) rand () / (double) RAND_MAX;
+        coeff[c] = (double) rand() / (double) RAND_MAX;
       base.push_back (Polynomials::Polynomial<double> (coeff));
     }
 }
@@ -138,7 +138,7 @@ void TestFEQConstraints<dim>::refine_grid_random ()
   Vector<double> estimated_error_per_cell (n_cells);
 
   for (unsigned int i = 0; i < n_cells; ++i)
-    estimated_error_per_cell(i) = (double) rand () / (double) RAND_MAX;
+    estimated_error_per_cell(i) = (double) rand() / (double) RAND_MAX;
 
   GridRefinement::refine_and_coarsen_fixed_number (triangulation,
                                                    estimated_error_per_cell,
index ad3e2e518e88e55ca4e5b48fb621698e6f7e563f..0476ad79d22af814118999bba0992842ed78c096 100644 (file)
@@ -45,7 +45,7 @@ void random_matrix(FullMatrix<double> &A)
   for (unsigned int i=0; i<A.m(); ++i)
     for (unsigned int j=0; j<A.n(); ++j)
       {
-        double rnd = std::rand();
+        double rnd = rand();
         rnd /= RAND_MAX;
         A(i,j) = (i==j) ? A.m()+rnd : rnd;
       }
@@ -60,7 +60,7 @@ check ()
 //  deallog.attach(logfile);
   deallog.depth_console(0);
 //  deallog.threshold_double(1.e-10);
-  std::srand(3391466);
+  srand(3391466);
 
   FullMatrix<double> T2(2,2,entries2), S2(2,2), R2(2,2);
   FullMatrix<double>T3(3,3,entries3), S3(3,3), R3(3,3);
index 2348eff411980447b60f55c8864dcf25cdc1be38..577b8747063e5d8d862e740005141c0a0782a62b 100644 (file)
@@ -1073,8 +1073,8 @@ void LaplaceProblem<dim>::run ()
   // points inside a radius of 0.9)
   for (int i=0; i<1000; i++)
     {
-      double r = sqrt((0.9*std::rand()/RAND_MAX));
-      double phi = 2*3.14*(1.0*std::rand()/RAND_MAX);
+      double r = sqrt((0.9*rand()/RAND_MAX));
+      double phi = 2*3.14*(1.0*rand()/RAND_MAX);
       double x = r*cos(phi);
       double y = r*sin(phi);
       Point<2> p(x,y);
index d9181f645a4ad5905967546f324acb46aa49d849..de877e90a81e93417f241fa648a76fcebaeda781 100644 (file)
@@ -123,7 +123,7 @@ check ()
   endc = dof_handler.end();
   for (; cell!=endc; ++cell)
     {
-      cell->set_active_fe_index (std::rand() % fe.size());
+      cell->set_active_fe_index (rand() % fe.size());
     }
 
   dof_handler.distribute_dofs (fe);
index 2db5a74c211645e0872d1f808146d2450d4afc96..75e202e5dd3161cc36f9584b8be62c4c557c0028 100644 (file)
@@ -132,7 +132,7 @@ check ()
   endc = dof_handler.end();
   for (; cell!=endc; ++cell)
     {
-      cell->set_active_fe_index (std::rand() % fe.size());
+      cell->set_active_fe_index (rand() % fe.size());
     }
 
   dof_handler.distribute_dofs (fe);
index 161a72db68eb91987aca76cb2eceee6eb7a3036b..2b2b5755ecb143a54e083edd0908c71ba3c56165 100644 (file)
@@ -158,7 +158,7 @@ int main ()
   // values between 0 and 1.
   Vector<double> solution(dof_handler.n_dofs ());
   for (unsigned int i = 0; i < dof_handler.n_dofs (); ++i)
-    solution(i) = (double) rand () / (double) RAND_MAX;
+    solution(i) = (double) rand() / (double) RAND_MAX;
 
   // Now check if the function is
   // continuous in normal direction
index 65640ff9f0f6a3bc0f10bb564a6ec82a39ff6629..b4cf3d70232f70984f1c4a7eb6f8d0e26a705dc7 100644 (file)
@@ -293,7 +293,7 @@ public:
       {
         for (unsigned int i=0; i < deg; ++i)
           {
-            double c = ((double) rand ()) / ((double) RAND_MAX + 1);
+            double c = ((double) rand()) / ((double) RAND_MAX + 1);
             coeff[i] = c;
           }
         polys.push_back (Polynomials::Polynomial<double> (coeff));
@@ -518,7 +518,7 @@ int main ()
     // Try arbitrary deformation ...
     for (unsigned int i=0; i < deformation.size (); ++i)
       {
-        double c = ((double) rand ()) / ((double) RAND_MAX + 1);
+        double c = ((double) rand()) / ((double) RAND_MAX + 1);
         deformation (i) = 0.35 * (c - 0.5);
       }
 
index 04978dbc61da98a8124d77e5085c31634b79de70..829acdb2d137851c201b94c8fd4c0248fcdcb09c 100644 (file)
@@ -293,7 +293,7 @@ public:
       {
         for (unsigned int i=0; i < deg; ++i)
           {
-            double c = ((double) rand ()) / ((double) RAND_MAX + 1);
+            double c = ((double) rand()) / ((double) RAND_MAX + 1);
             coeff[i] = c;
           }
         polys.push_back (Polynomials::Polynomial<double> (coeff));
@@ -523,7 +523,7 @@ int main ()
     // Try arbitrary deformation ...
     for (unsigned int i=0; i < deformation.size (); ++i)
       {
-        double c = ((double) rand ()) / ((double) RAND_MAX + 1);
+        double c = ((double) rand()) / ((double) RAND_MAX + 1);
         deformation (i) = 0.35 * (c - 0.5);
       }
 
index 154aa4bc2be24e2061110dfe58858b554735a49b..643189e1a9f103fabb497fdf1ea1fbba96398730 100644 (file)
@@ -291,7 +291,7 @@ int main (int /*argc*/, char **/*argv*/)
 
   // Fill solution vector with random values between 0 and 1.
   for (unsigned int i = 0; i < dof_handler->n_dofs (); ++i)
-    solution(i) = (double) rand () / (double) RAND_MAX;
+    solution(i) = (double) rand() / (double) RAND_MAX;
 
   // Now check if the function is continuous in normal
   // direction.
index c60627beb1fc64f24d990217b0aa66f6eb31f581..98969008de09761de69af67c748ca33250c154b6 100644 (file)
@@ -82,7 +82,7 @@ check ()
   cell = dof_handler.begin_active(),
   endc = dof_handler.end();
   for (; cell!=endc; ++cell)
-    cell->set_active_fe_index (std::rand() % fe.size());
+    cell->set_active_fe_index (rand() % fe.size());
 
   dof_handler.distribute_dofs (fe);
 
index 1fee0b72fc6bf3e281927e9ef32db9bfabda9215..94649a1c01edc04c369fc501567e63c84099fc36 100644 (file)
@@ -82,7 +82,7 @@ check ()
   cell = dof_handler.begin_active(),
   endc = dof_handler.end();
   for (; cell!=endc; ++cell)
-    cell->set_active_fe_index (std::rand() % fe.size());
+    cell->set_active_fe_index (rand() % fe.size());
 
   dof_handler.distribute_dofs (fe);
 
index 2a271e984c1e5fd2c813b740589c4fa44509fe44..6fd1c1c1361d0e913c0c024836f8320a9571cf38 100644 (file)
@@ -71,7 +71,7 @@ void test ()
   typename hp::DoFHandler<dim>::active_cell_iterator cell = dof_handler.begin_active (),
                                                      endc = dof_handler.end ();
   for (; cell != endc; ++cell)
-    cell->set_active_fe_index (random() % fe.size());
+    cell->set_active_fe_index (rand() % fe.size());
 
   dof_handler.distribute_dofs (fe);
 
@@ -113,7 +113,7 @@ int main ()
   // same value it has in
   // hp_hanging_nodes_02
   for (unsigned int i=0; i<64; ++i)
-    random ();
+    rand();
   test<3> ();
 
   return 0;
index e9451b9f6d5fde78d56a487e79b5d5f01f074967..f50d40925f26c6dd0ac0831f0ce0cf1cb22d8eda 100644 (file)
@@ -92,7 +92,7 @@ void run (bool random_p,
     {
       for (; cell != endc; ++cell)
         {
-          cell->set_active_fe_index ((int)(4.0 * (double) random () / (double) RAND_MAX));
+          cell->set_active_fe_index ((int)(4.0 * (double) rand() / (double) RAND_MAX));
         }
     }
   else
index caba2e800003e15acc7373f6746623c7174fed9d..a5620a12f9ec819e9bb72822ec76933e3730d4df 100644 (file)
@@ -37,7 +37,7 @@ void random_matrix(FullMatrix<double> &A)
   for (unsigned int i=0; i<A.m(); ++i)
     for (unsigned int j=0; j<A.n(); ++j)
       {
-        double rnd = std::rand();
+        double rnd = rand();
         rnd /= RAND_MAX;
         A(i,j) = (i==j) ? A.m()+rnd : rnd;
       }
@@ -52,7 +52,7 @@ main ()
   deallog.attach(logfile);
   deallog.depth_console(0);
   deallog.threshold_double(1.e-10);
-  std::srand(3391466);
+  srand(3391466);
 
   FullMatrix<double> T(3,3,entries);
   T.print_formatted(logfile, 0, false);
index 5e8d478e0e4e561b9f21c8c78b636dcc46d982d2..835e2c4723e9170e431a02c4d56a66d0a23d1a7b 100644 (file)
@@ -44,7 +44,7 @@ main ()
   deallog.attach(logfile);
   deallog.depth_console(0);
   deallog.threshold_double(1.e-10);
-  std::srand(3391466);
+  srand(3391466);
 
   FullMatrix<double> A(3,3,entries_A);
   FullMatrix<double> B(3,3,entries_B);
index 7a349f31fe44da5c1fbd5fb3f93906006b151acf..3a6b7ea6fa5ee72a4bcce487d33f4738d3a264a7 100644 (file)
@@ -44,7 +44,7 @@ main ()
   deallog.attach(logfile);
   deallog.depth_console(0);
   deallog.threshold_double(1.e-10);
-  std::srand(3391466);
+  srand(3391466);
 
   FullMatrix<double> A(3,3,entries_A);
   FullMatrix<double> B(3,3,entries_B);
index ea997a7db1582017f7d5cf2054e029fc332729f0..22083f23b31dc84e13aac1ea1cf69b0b2e4047a6 100644 (file)
@@ -52,16 +52,16 @@ void test (const unsigned int n, const unsigned int m)
   for (unsigned int i=0; i<n; ++i)
     {
       for (unsigned int j=0; j<n; ++j)
-        A(i,j) = std::rand();
+        A(i,j) = rand();
       for (unsigned int j=0; j<m; ++j)
         {
-          B(i,j) = Bt(j,i) = std::rand();
-          D(j,i) = Dt(i,j) = std::rand();
+          B(i,j) = Bt(j,i) = rand();
+          D(j,i) = Dt(i,j) = rand();
         }
     }
   for (unsigned int i=0; i<m; ++i)
     for (unsigned int j=0; j<m; ++j)
-      C(i,j) = std::rand();
+      C(i,j) = rand();
 
   // Compare first Schur complement
   // with mmult.
@@ -123,7 +123,7 @@ main ()
   std::ofstream logfile(logname.c_str());
   deallog.attach(logfile);
   deallog.depth_console(0);
-  std::srand(3391466);
+  srand(3391466);
 
   test(3,4);
   test(4,7);
index 339cc14f86b024c8514a4a6c2faed043e05fdbf3..6b17880f8cf58d74423b74dcb65f3c5dff56e64a 100644 (file)
@@ -103,7 +103,7 @@ int main()
           for (unsigned int i=0; i<3; ++i)
             {
               for (unsigned int j=0; j<dim; ++j)
-                v(j) = 1. * std::rand()/RAND_MAX;
+                v(j) = 1. * rand()/RAND_MAX;
 
               A.vmult (tmp1, v);
               ilu.vmult (tmp2, tmp1);
index 5f18c4baad8568920a89d6cec0f4584f66a29209..9bdab5450c0378079e8d32e34e659d844597dae2 100644 (file)
@@ -104,7 +104,7 @@ int main()
           for (unsigned int i=0; i<3; ++i)
             {
               for (unsigned int j=0; j<dim; ++j)
-                v(j) = 1. * std::rand()/RAND_MAX;
+                v(j) = 1. * rand()/RAND_MAX;
 
               A.Tvmult (tmp1, v);
               ilu.Tvmult (tmp2, tmp1);
index 3eca2c82d893e291f984a8755b932d3da73aa6ad..26a45c21abce5a2e0de90b7580148ffd6cfe4892 100644 (file)
@@ -56,9 +56,9 @@ void test (const unsigned int n)
   for (unsigned int i=0; i<n; ++i)
     {
       for (unsigned int j=0; j<n; ++j)
-        A.set(i,j,std::rand());
+        A.set(i,j,rand());
       for (unsigned int j=0; j<n; ++j)
-        B.set(i,j,std::rand());
+        B.set(i,j,rand());
     }
 
   // now form the matrix-matrix product and
@@ -67,7 +67,7 @@ void test (const unsigned int n)
 
   Vector<double> x(n), y(n), z(n), tmp(n);
   for (unsigned int j=0; j<n; ++j)
-    x(j) = std::rand();
+    x(j) = rand();
 
   // then test for correctness
   C.vmult (y, x);
@@ -90,7 +90,7 @@ main ()
   std::ofstream logfile(logname.c_str());
   deallog.attach(logfile);
   deallog.depth_console(0);
-  std::srand(3391466);
+  srand(3391466);
 
   test(3);
   test(7);
index 0d5df1743e93e5e2c19d32981cc9f5cc5bfb74e3..8d5fe440188f0b71c1ad5d25a305e0a05011c76e 100644 (file)
@@ -56,14 +56,14 @@ void test (const unsigned int n)
   for (unsigned int i=0; i<n; ++i)
     {
       for (unsigned int j=0; j<n; ++j)
-        A.set(i,j,std::rand());
+        A.set(i,j,rand());
       for (unsigned int j=0; j<n; ++j)
-        B.set(i,j,std::rand());
+        B.set(i,j,rand());
     }
 
   Vector<double> v(n);
   for (unsigned int j=0; j<n; ++j)
-    v(j) = std::rand();
+    v(j) = rand();
 
   // now form the matrix-matrix product and
   // initialize a test rhs
@@ -71,7 +71,7 @@ void test (const unsigned int n)
 
   Vector<double> x(n), y(n), z(n), tmp(n);
   for (unsigned int j=0; j<n; ++j)
-    x(j) = std::rand();
+    x(j) = rand();
 
   // then test for correctness
   C.vmult (y, x);
@@ -95,7 +95,7 @@ main ()
   std::ofstream logfile(logname.c_str());
   deallog.attach(logfile);
   deallog.depth_console(0);
-  std::srand(3391466);
+  srand(3391466);
 
   test(3);
   test(7);
index bc825f9832d2fb218fb976161ac2439b4b2c5100..1a4f9524431bd753614d54e3aef26c58fb18303d 100644 (file)
@@ -56,9 +56,9 @@ void test (const unsigned int n)
   for (unsigned int i=0; i<n; ++i)
     {
       for (unsigned int j=0; j<n; ++j)
-        A.set(i,j,std::rand());
+        A.set(i,j,rand());
       for (unsigned int j=0; j<n; ++j)
-        B.set(i,j,std::rand());
+        B.set(i,j,rand());
     }
 
   // now form the matrix-matrix product and
@@ -67,7 +67,7 @@ void test (const unsigned int n)
 
   Vector<double> x(n), y(n), z(n), tmp(n);
   for (unsigned int j=0; j<n; ++j)
-    x(j) = std::rand();
+    x(j) = rand();
 
   // then test for correctness
   C.vmult (y, x);
@@ -90,7 +90,7 @@ main ()
   std::ofstream logfile(logname.c_str());
   deallog.attach(logfile);
   deallog.depth_console(0);
-  std::srand(3391466);
+  srand(3391466);
 
   test(3);
   test(7);
index 1e6f9ade5c1c8569f54c8c96a211c078d2d37864..ea7f74a9ae5b02396722a2ba8660fe96fac8f347 100644 (file)
@@ -56,14 +56,14 @@ void test (const unsigned int n)
   for (unsigned int i=0; i<n; ++i)
     {
       for (unsigned int j=0; j<n; ++j)
-        A.set(i,j,std::rand());
+        A.set(i,j,rand());
       for (unsigned int j=0; j<n; ++j)
-        B.set(i,j,std::rand());
+        B.set(i,j,rand());
     }
 
   Vector<double> v(n);
   for (unsigned int j=0; j<n; ++j)
-    v(j) = std::rand();
+    v(j) = rand();
 
   // now form the matrix-matrix product and
   // initialize a test rhs
@@ -71,7 +71,7 @@ void test (const unsigned int n)
 
   Vector<double> x(n), y(n), z(n), tmp(n);
   for (unsigned int j=0; j<n; ++j)
-    x(j) = std::rand();
+    x(j) = rand();
 
   // then test for correctness
   C.vmult (y, x);
@@ -95,7 +95,7 @@ main ()
   std::ofstream logfile(logname.c_str());
   deallog.attach(logfile);
   deallog.depth_console(0);
-  std::srand(3391466);
+  srand(3391466);
 
   test(3);
   test(7);
index c7986cfd47c91f9c9bbb6e843c805c861be6d2f5..f71321fd7f89d39cb526c8d66b1a9b68e644dcd7 100644 (file)
@@ -105,7 +105,7 @@ int main()
           for (unsigned int i=0; i<3; ++i)
             {
               for (unsigned int j=0; j<dim; ++j)
-                v(j) = 1. * std::rand()/RAND_MAX;
+                v(j) = 1. * rand()/RAND_MAX;
 
               A.vmult (tmp1, v);
               mic.vmult (tmp2, tmp1);
index 20f6b418d766ec998fce10dcec31376df0a0cf64..4dd55b01051a70b141165a608b1e34ce0898f50c 100644 (file)
@@ -68,7 +68,7 @@ void test()
       endc = tr.end();
 
       for (; cell!=endc; ++cell)
-        if (std::rand()%42==1)
+        if (rand()%42==1)
           cell->set_refine_flag ();
 
       tr.execute_coarsening_and_refinement ();
index a2c66e45c9064ef97782486c414fcff3071fa3e6..2e952973187c6f3c0efeffdb2b8a605a403c0067 100644 (file)
@@ -101,7 +101,7 @@ void test()
         endc = tr.end();
       
       for (; cell!=endc; ++cell)
-       if (std::rand()%42==1)
+       if (rand()%42==1)
          cell->set_refine_flag ();
       
       tr.execute_coarsening_and_refinement ();
index 285c28d9330ef2b79d9b85f0ceda6f91cd931da0..9d381931615663a6a49da6c923d9e77e0f5dc46c 100644 (file)
@@ -103,7 +103,7 @@ void test()
         endc = tr.end();
       
       for (; cell!=endc; ++cell)
-       if (std::rand()%42==1)
+       if (rand()%42==1)
          cell->set_refine_flag ();
       
       tr.execute_coarsening_and_refinement ();
index c7bab7f9a3ce572d62d1aa2f6e362281adb5c480..c8ccf8c3f575564be72c51fc42c37ccffcad95a1 100644 (file)
@@ -123,7 +123,7 @@ void test()
       endc = tr.end();
 
       for (; cell!=endc; ++cell)
-        if (std::rand()%42==1)
+        if (rand()%42==1)
           cell->set_refine_flag ();
 
       tr.execute_coarsening_and_refinement ();
index d5940f956f3066fb8475ea8da3f4c3543cce1650..d256954daa8f962532d1e0ee7fb3bdfc58f92923 100644 (file)
@@ -160,7 +160,7 @@ void test()
         endc = tr.end();
 
         for (; cell!=endc; ++cell)
-          if (std::rand()%42==1)
+          if (rand()%42==1)
             cell->set_refine_flag ();
 
         tr.execute_coarsening_and_refinement ();
@@ -200,9 +200,9 @@ void test()
         for (; cell!=endc; ++cell)
           if (!cell->is_artificial() && !cell->is_ghost())
             {
-              if (std::rand()%12==1)
+              if (rand()%12==1)
                 cell->set_refine_flag ();
-              else if (std::rand()%7==1)
+              else if (rand()%7==1)
                 cell->set_coarsen_flag ();
             }
       }
index 57dc4fbc4db3ebd3b9aeca02c2b18b6652e0e9e9..e35d11ca0e4c7efc94ba662d4b37c3e4429bcb09 100644 (file)
@@ -60,7 +60,7 @@ void test()
       endc = tr.end();
 
       for (; cell!=endc; ++cell)
-        if (std::rand()%42==1)
+        if (rand()%42==1)
           cell->set_refine_flag ();
 
       tr.execute_coarsening_and_refinement ();
index 46d10f05633d19a3d8b1d55f0dd34b8c320a208c..6d0d656f507d2bfe521bc7feb85d4d9af5618046 100644 (file)
@@ -60,7 +60,7 @@ void test()
       endc = tr.end();
 
       for (; cell!=endc; ++cell)
-        if (std::rand()%42==1)
+        if (rand()%42==1)
           cell->set_refine_flag ();
 
       tr.execute_coarsening_and_refinement ();
index b30e4008e3efbd4624b8f03506617a176e7f0d81..6366dbae460281c682fc06df5d45687e83ba0c2e 100644 (file)
@@ -159,7 +159,7 @@ void test()
         endc = tr.end();
 
         for (; cell!=endc; ++cell)
-          if (std::rand()%42==1)
+          if (rand()%42==1)
             cell->set_refine_flag ();
 
         tr.execute_coarsening_and_refinement ();
@@ -199,9 +199,9 @@ void test()
         for (; cell!=endc; ++cell)
           if (!cell->is_artificial() && !cell->is_ghost())
             {
-              if (std::rand()%12==1)
+              if (rand()%12==1)
                 cell->set_refine_flag ();
-              else if (std::rand()%7==1)
+              else if (rand()%7==1)
                 cell->set_coarsen_flag ();
             }
       }
index fadd4b7fc65fd09a348dbcc0f4fa3e687e9be92b..c7cf65ac838f93869b9db64851d226d51a08eb7b 100644 (file)
 #include <iomanip>
 
 
+// Cygwin has a different implementation for rand() which causes many tests to fail.
+// This here is a reimplementation that gives the same sequence of numbers as a program
+// that uses rand() on a typical linux machine.
+int myrand(bool reseed=false, int seed=1)
+{
+  static int r[32];
+  static int k;
+  static bool inited=false;
+  if (!inited || reseed)
+    {
+      //srand treats a seed 0 as 1 for some reason
+      r[0]=(seed==0)?1:seed;
+
+      for (int i=1; i<31; i++)
+        {
+          r[i] = (16807LL * r[i-1]) % 2147483647;
+          if (r[i] < 0)
+            r[i] += 2147483647;
+        }
+      k=31;
+      for (int i=31; i<34; i++)
+        {
+          r[k%32] = r[(k+32-31)%32];
+          k=(k+1)%32;
+        }
+
+      for (int i=34; i<344; i++)
+        {
+          r[k%32] = r[(k+32-31)%32] + r[(k+32-3)%32];
+          k=(k+1)%32;
+        }
+      inited=true;
+      if (reseed==true)
+        return 0;// do not generate new no
+    }
+
+  r[k%32] = r[(k+32-31)%32] + r[(k+32-3)%32];
+  int ret = r[k%32];
+  k=(k+1)%32;
+  return (unsigned int)ret >> 1;
+}
+
+// reseed our random number generator
+void mysrand(int seed)
+{
+  myrand(true, seed);
+}
+
+
+// I hope this is safe to just override the standard
+// rand() functions here.
+int rand()
+{
+  return myrand();
+}
+
+void srand(int seed)
+{
+  mysrand(seed);
+}
+
+
+
 // given the name of a file, copy it to deallog
 // and then delete it
 inline void cat_file(const char *filename)

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.