private static void pvand_test() //****************************************************************************80 // // Purpose: // // PVAND_TEST tests PVAND. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 23 February 2014 // // Author: // // John Burkardt // { const int N = 5; double[] alpha = null; double[] alpha1 = { 0.0, 1.0, 2.0, 3.0, 4.0 }; int test; double[] x1 = { 5.0, 3.0, 4.0, 1.0, 2.0 }; Console.WriteLine(""); Console.WriteLine("PVAND_TEST:"); Console.WriteLine(" Solve a Vandermonde linear system A*x=b"); for (test = 1; test <= 2; test++) { switch (test) { case 1: alpha = typeMethods.r8vec_copy_new(N, alpha1); break; case 2: int seed = 123456789; alpha = UniformRNG.r8vec_uniform_01_new(N, ref seed); break; } typeMethods.r8vec_print(N, alpha, " Vandermonde vector ALPHA:"); double[] a = VandermondeMatrix.vand1(N, alpha); double[] x = typeMethods.r8vec_copy_new(N, x1); double[] b = typeMethods.r8mat_mv_new(N, N, a, x); typeMethods.r8vec_print(N, b, " Right hand side B:"); x = VandermondeMatrix.pvand(N, alpha, b); typeMethods.r8vec_print(N, x, " Solution X:"); } }
private static void dvandprg_test() //****************************************************************************80 // // Purpose: // // DVANDPRG_TEST tests DVANDPRG. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 18 April 2014 // // Author: // // John Burkardt // { const int N = 5; double[] alpha = null; double[] alpha1 = { 0.0, 1.0, 2.0, 3.0, 4.0 }; int test; double[] x1 = { 5.0, 3.0, 4.0, 1.0, 2.0 }; Console.WriteLine(""); Console.WriteLine("DVANDPRG_TEST:"); Console.WriteLine(" Solve a Vandermonde linear system A'*x=b"); Console.WriteLine(" progressively."); Console.WriteLine(" First we use ALPHA = 0, 1, 2, 3, 4."); Console.WriteLine(" Then we choose ALPHA at random."); for (test = 1; test <= 2; test++) { switch (test) { case 1: alpha = typeMethods.r8vec_copy_new(N, alpha1); break; case 2: int seed = 123456789; alpha = UniformRNG.r8vec_uniform_01_new(N, ref seed); break; } typeMethods.r8vec_print(N, alpha, " Vandermonde vector ALPHA:"); double[] a = VandermondeMatrix.vand1(N, alpha); double[] x = typeMethods.r8vec_copy_new(N, x1); double[] b = typeMethods.r8mat_mtv_new(N, N, a, x); typeMethods.r8vec_print(N, b, " Right hand side B:"); x = new double[N]; double[] c = new double[N]; double[] m = new double[N]; int nsub; for (nsub = 1; nsub <= N; nsub++) { VandermondeMatrix.dvandprg(nsub, alpha, b, ref x, ref c, ref m); typeMethods.r8vec_print(nsub, x, " Solution X:"); } } }