private void Helper2(IElementalAccessMatrix A, IElementalAccessVector b, IElementalAccessVector x, ILinearSolver solver, IPreconditioner M, ILinearIteration iter) { Random r = new Random(); double K = r.NextDouble(), f = r.NextDouble(), gl = r.NextDouble(), gr = r.NextDouble(); //assemble(A, b, K, f); //boundary(A, b, x, gl, gr); A.SetValue(0, 0, 1); A.SetValue(0, 1, 1); A.SetValue(0, 2, 1.3); A.SetValue(1, 0, -0.5); A.SetValue(1, 1, -0.25); A.SetValue(1, 2, -1.25); A.SetValue(2, 0, 2.5); A.SetValue(2, 1, 3.25); A.SetValue(2, 2, -1.25); b.SetValue(0, 1.25); b.SetValue(1, 3.75); b.SetValue(1, -2.35); double[] ans = solve(A, b, x, solver, M, iter); //double[] ref_Renamed = reference(b.Length - 1, K, f, gl, gr); //checkEqual(ans, ref_Renamed); Console.WriteLine("!: " + solver + " " + M + " " + iter + " " + x.GetValue(0) + " " + x.GetValue(1) + " " + x.GetValue(2)); Blas.Default.Zero(A); Blas.Default.Zero(b); Blas.Default.Zero(x); }
private static void checkEqual(IElementalAccessVector x, double[] data) { Assert.IsTrue(x.Length == data.Length); for (int i = 0; i < data.Length; ++i) { Assert.AreEqual(x.GetValue(i), data[i], 1e-12); } }
/// <summary> Dense representation of the vector using getValue</summary> public static double[] getElVector(IElementalAccessVector x) { double[] ret = new double[x.Length]; for (int i = 0; i < ret.Length; ++i) { ret[i] = x.GetValue(i); } return(ret); }
private void model(IElementalAccessVector y, IElementalAccessVector x) { y.SetValue(0, x.GetValue(0) - x.GetValue(1) - 1); y.SetValue(1, 3 * x.GetValue(0) - 2 * x.GetValue(1) + 1); y.SetValue(2, -2 * x.GetValue(2) * x.GetValue(2) - 1 * x.GetValue(1) + 2); y.SetValue(0, x.GetValue(0) - x.GetValue(3) * x.GetValue(3) - 1); y.SetValue(1, x.GetValue(1) + x.GetValue(2) - 1); y.SetValue(2, x.GetValue(0) + x.GetValue(1) + 2); y.SetValue(3, x.GetValue(4) * x.GetValue(3) - 1); y.SetValue(4, x.GetValue(3) + 2 - x.GetValue(0)); }
public static void model11(IElementalAccessVector y, IElementalAccessVector x) { //y er residualer, mens x er endogene //for (int i = 0; i < WindowsApplication1.Program.varsBigEndoNoLag.Count; i++) //{ //} y.SetValue(0, x.GetValue(0) - x.GetValue(3) * x.GetValue(3) - 1); y.SetValue(1, x.GetValue(1) + x.GetValue(2) - 1); y.SetValue(2, x.GetValue(0) + x.GetValue(1) + 2); y.SetValue(3, x.GetValue(4) * x.GetValue(3) - 1); y.SetValue(4, x.GetValue(3) + 2 - x.GetValue(0)); }