private static void i4_bit_hi1_test( ) //****************************************************************************80 // // Purpose: // // I4_BIT_HI1_TEST tests I4_BIT_HI1. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 23 January 2007 // // Author: // // John Burkardt // { int seed = 123456789; Console.WriteLine(); Console.WriteLine("I4_BIT_HI1_TEST"); Console.WriteLine(" I4_BIT_HI1 returns the location of the high bit in an integer."); Console.WriteLine(); Console.WriteLine(" I I4_BIT_HI1(I)"); Console.WriteLine(); for (int test = 1; test <= 10; test++) { int i = UniformRNG.i4_uniform(0, 100, ref seed); int j = SobolSampler.i4_bit_hi1(i); string cout = " "; string t = i.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; cout += t; t = j.ToString(CultureInfo.InvariantCulture).PadLeft(6); cout += t; Console.WriteLine(cout); } }
private static void i8_bit_lo0_test( ) //****************************************************************************80 // // Purpose: // // I8_BIT_LO0_TEST tests I8_BIT_LO0. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 12 May 2007 // // Author: // // John Burkardt // { int seed = 123456789; Console.WriteLine(); Console.WriteLine("I8_BIT_LO0_TEST"); Console.WriteLine(" I8_BIT_LO0 returns the location of the low zero bit"); Console.WriteLine(" in an integer."); Console.WriteLine(); Console.WriteLine(" I I8_BIT_LO0(I)"); Console.WriteLine(); for (int test = 1; test <= 10; test++) { long i = UniformRNG.i4_uniform(0, 100, ref seed); int j = SobolSampler.i8_bit_lo0(i); string cout = " "; string t = i.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; t += j.ToString(CultureInfo.InvariantCulture).PadLeft(6); cout += t; Console.WriteLine(cout); } }
private static void Main(string[] args) //****************************************************************************80 // // Purpose: // // MAIN is the main program for SOBOL_DATASET. // // Discussion: // // SOBOL_DATASET generates a Sobol dataset and writes it to a file. // // Usage: // // sobol_dataset m n skip // // where // // * M, the spatial dimension, // * N, the number of points to generate, // * SKIP, the number of initial points to skip. // // creates an M by N Sobol dataset and writes it to the // file "sobol_M_N.txt". // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 12 December 2009 // // Author: // // John Burkardt // { int m; int n; int skip; Console.WriteLine(""); Console.WriteLine("SOBOL_DATASET"); Console.WriteLine(""); Console.WriteLine(" Generate a Sobol quasirandom dataset."); // // Get the spatial dimension. // try { m = Convert.ToInt32(args[0]); } catch { Console.WriteLine(""); Console.WriteLine(" Enter the value of M"); m = Convert.ToInt32(Console.ReadLine()); } Console.WriteLine(""); Console.WriteLine(" Spatial dimension M = " + m + ""); // // Get the number of points. // try { n = Convert.ToInt32(args[1]); } catch { Console.WriteLine(""); Console.WriteLine(" Enter the number of points N"); n = Convert.ToInt32(Console.ReadLine()); } Console.WriteLine(" Number of points N = " + n + ""); // // Get SKIP. // try { skip = Convert.ToInt32(args[2]); } catch { Console.WriteLine(""); Console.WriteLine(" Enter the value of SKIP"); skip = Convert.ToInt32(Console.ReadLine()); } Console.WriteLine(" SKIP is = " + skip + ""); // // Compute the data. // double[] r = SobolSampler.i8_sobol_generate(m, n, skip); // // Write it to a file. // string m_ostring = m.ToString(); string n_ostring = n.ToString(); string output_filename = "sobol_" + m_ostring + "_" + n_ostring + ".txt"; typeMethods.r8mat_write(output_filename, m, n, r); Console.WriteLine(""); Console.WriteLine(" The data was written to the file \"" + output_filename + "\"."); Console.WriteLine(""); Console.WriteLine("SOBOL_DATASET:"); Console.WriteLine(" Normal end of execution."); Console.WriteLine(""); }
private static void test09( ) //****************************************************************************80 // // Purpose: // // TEST09 tests I8_SOBOL. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 12 May 2007 // // Author: // // John Burkardt // { int DIM_NUM = 3; SobolSampler.SobolConfigLarge config = new(DIM_NUM); Console.WriteLine(); Console.WriteLine("TEST09"); Console.WriteLine(" I8_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 I8_SOBOL"); Console.WriteLine(" In Out"); Console.WriteLine(); for (int i = 1; i <= 11; i++) { long seed_in = config.seed; int res = SobolSampler.i8_sobol(DIM_NUM, ref config); long seed_out = config.seed; string cout = seed_in.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; string 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 I8_SOBOL"); Console.WriteLine(" In Out"); Console.WriteLine(); for (int i = 1; i <= 5; i++) { long seed_in = config.seed; int res = SobolSampler.i8_sobol(DIM_NUM, ref config); long seed_out = config.seed; string cout = seed_in.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; string 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 I8_SOBOL"); Console.WriteLine(" In Out"); Console.WriteLine(); for (int i = 1; i <= 11; i++) { long seed_in = config.seed; int res = SobolSampler.i8_sobol(DIM_NUM, ref config); long seed_out = config.seed; string cout = seed_in.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; string 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 I8_SOBOL"); Console.WriteLine(" In Out"); Console.WriteLine(); for (int i = 1; i <= 5; i++) { long seed_in = config.seed; int res = SobolSampler.i8_sobol(DIM_NUM, ref config); long seed_out = config.seed; string cout = seed_in.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; string 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 test08( ) //****************************************************************************80 // // Purpose: // // TEST08 tests I8_SOBOL. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 12 May 2007 // // Author: // // John Burkardt // { int DIM_MAX = 4; SobolSampler.SobolConfigLarge config = new(DIM_MAX); Console.WriteLine(); Console.WriteLine("TEST08"); Console.WriteLine(" I8_SOBOL computes the next element of a Sobol sequence."); Console.WriteLine(); Console.WriteLine(" In this test, we call I8_SOBOL repeatedly."); for (int dim_num = 2; dim_num <= DIM_MAX; dim_num++) { config.seed = 0; Console.WriteLine(); Console.WriteLine(" Using dimension DIM_NUM = " + dim_num); Console.WriteLine(); Console.WriteLine(" Seed Seed I8_SOBOL"); Console.WriteLine(" In Out"); Console.WriteLine(); for (int i = 0; i <= 110; i++) { long seed_in = config.seed; int res = SobolSampler.i8_sobol(dim_num, ref config); long seed_out = config.seed; switch (i) { case <= 11: case >= 95: { string cout = seed_in.ToString(CultureInfo.InvariantCulture).PadLeft(6) + " "; string 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; } } } }