private static void test05( ) //****************************************************************************80 // // Purpose: // // TEST05 tests I4_SOBOL. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 23 January 2007 // // Author: // // John Burkardt // { int DIM_NUM = 3; SobolSampler.SobolConfig config = new(DIM_NUM); Console.WriteLine(); Console.WriteLine("TEST05"); Console.WriteLine(" I4_SOBOL computes the next element of a Sobol sequence."); Console.WriteLine(); Console.WriteLine(" In this test, we demonstrate how the SEED can be"); Console.WriteLine(" manipulated to skip ahead in the sequence, or"); Console.WriteLine(" to come back to any part of the sequence."); Console.WriteLine(); Console.WriteLine(" Using dimension DIM_NUM = " + DIM_NUM); config.seed = 0; Console.WriteLine(); Console.WriteLine(" Seed Seed I4_SOBOL"); Console.WriteLine(" In Out"); Console.WriteLine(); for (int i = 1; i <= 11; i++) { int seed_in = config.seed; int res = SobolSampler.i4_sobol(DIM_NUM, ref config); int seed_out = config.seed; string cout = ""; string t = seed_in.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; cout += t; t = seed_out.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; cout += t; for (int j = 0; j < DIM_NUM; j++) { t = config.quasi[j].ToString(CultureInfo.InvariantCulture).PadLeft(14) + " "; cout += t; } Console.WriteLine(cout); } Console.WriteLine(); Console.WriteLine(" Jump ahead by increasing SEED:"); config.seed = 100; Console.WriteLine(); Console.WriteLine(" Seed Seed I4_SOBOL"); Console.WriteLine(" In Out"); Console.WriteLine(); for (int i = 1; i <= 5; i++) { int seed_in = config.seed; int res = SobolSampler.i4_sobol(DIM_NUM, ref config); int seed_out = config.seed; string cout = ""; string t = seed_in.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; cout += t; t = seed_out.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; cout += t; for (int j = 0; j < DIM_NUM; j++) { t = config.quasi[j].ToString(CultureInfo.InvariantCulture).PadLeft(14) + " "; cout += t; } Console.WriteLine(cout); } Console.WriteLine(); Console.WriteLine(" Jump back by decreasing SEED:"); config.seed = 3; Console.WriteLine(); Console.WriteLine(" Seed Seed I4_SOBOL"); Console.WriteLine(" In Out"); Console.WriteLine(); for (int i = 1; i <= 11; i++) { int seed_in = config.seed; int res = SobolSampler.i4_sobol(DIM_NUM, ref config); int seed_out = config.seed; string cout = ""; string t = seed_in.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; cout += t; t = seed_out.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; cout += t; for (int j = 0; j < DIM_NUM; j++) { t = config.quasi[j].ToString(CultureInfo.InvariantCulture).PadLeft(14) + " "; cout += t; } Console.WriteLine(cout); } Console.WriteLine(); Console.WriteLine(" Jump ahead by increasing SEED:"); config.seed = 98; Console.WriteLine(); Console.WriteLine(" Seed Seed I4_SOBOL"); Console.WriteLine(" In Out"); Console.WriteLine(); for (int i = 1; i <= 5; i++) { int seed_in = config.seed; int res = SobolSampler.i4_sobol(DIM_NUM, ref config); int seed_out = config.seed; string cout = ""; string t = seed_in.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; cout += t; t = seed_out.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; cout += t; for (int j = 0; j < DIM_NUM; j++) { t = config.quasi[j].ToString(CultureInfo.InvariantCulture).PadLeft(14) + " "; cout += t; } Console.WriteLine(cout); } }
private static void test04( ) //****************************************************************************80 // // Purpose: // // TEST04 tests I4_SOBOL. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 23 January 2007 // // Author: // // John Burkardt // { int DIM_NUM = 4; SobolSampler.SobolConfig config = new(DIM_NUM); Console.WriteLine(); Console.WriteLine("TEST04"); Console.WriteLine(" I4_SOBOL computes the next element of a Sobol sequence."); Console.WriteLine(); Console.WriteLine(" In this test, we call I4_SOBOL repeatedly."); for (int dim_num = 2; dim_num <= DIM_NUM; dim_num++) { config.seed = 0; Console.WriteLine(); Console.WriteLine(" Using dimension DIM_NUM = " + dim_num); Console.WriteLine(); Console.WriteLine(" Seed Seed I4_SOBOL"); Console.WriteLine(" In Out"); Console.WriteLine(); for (int i = 0; i <= 110; i++) { int seed_in = config.seed; int res = SobolSampler.i4_sobol(dim_num, ref config); int seed_out = config.seed; switch (i) { case <= 11: case >= 95: { string cout = ""; string t = seed_in.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; cout += t; t = seed_out.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; cout += t; for (int j = 0; j < dim_num; j++) { t = config.quasi[j].ToString(CultureInfo.InvariantCulture).PadLeft(14) + " "; cout += t; } Console.WriteLine(cout); break; } case 12: Console.WriteLine("...................."); break; } } } }