public static Psi[][][] CalculatePsi(double[][] lambda, PolinomType p_type, int[] rang, int[] x, int multiplicative) { Psi[][][] result = new Psi[lambda.Length][][]; for (int i = 0; i < result.Length; i++) { result[i] = new Psi[3][]; for (int l = 0; l < 3; l++) { Log.WriteLine(" X" + i + ":"); result[i][l] = new Psi[x[l]]; for (int j = 0; j < result[i][l].Length; j++) { result[i][l][j] = new Psi(multiplicative); for (int k = 0; k <= rang[l]; k++) { int index = (j+2*l) * (rang[l] + 1) + k; //for (int m = 0; m < l; m++) // index += (x[m]) * (rang[m] + 1); result[i][l][j].lambda.Add(lambda[i][index]); result[i][l][j].Add(new Polinom(p_type, k)); } } } } return result; }
public void bind_add_range_property() { PropertyTreeReader pt = LoadContent("psi-add-range.xml"); Assert.True(pt.Read()); Psi p = pt.Bind <Psi>(new Psi()); Assert.Equal(4, p.B.Count); Assert.Equal("a", p.B[0]); Assert.Equal("c", p.B[2]); Assert.Equal("d", p.B[3]); }
public void bind_clear_method() { PropertyTreeReader pt = LoadContent("psi.xml"); Assert.True(pt.Read()); Psi p = new Psi(); Assert.Equal(3, p.A.Count); p = pt.Bind <Psi>(p); Assert.Equal(0, p.A.Count); }
public void bind_template_add_range_property() { PropertyTreeReader pt = LoadContent("psi-add-range.xml"); Assume.That(pt.Read(), Is.True); Psi p = new Psi(); var template = pt.Bind<ITemplate<Psi>>(); template.Initialize(p); Assert.That(p.B.Count, Is.EqualTo(4)); Assert.That(p.B[0], Is.EqualTo("a")); Assert.That(p.B[2], Is.EqualTo("c")); Assert.That(p.B[3], Is.EqualTo("d")); }
public void bind_remove_method() { PropertyTreeReader pt = LoadContent("psi-remove.xml"); Assert.True(pt.Read()); Psi p = new Psi(); Assert.Equal(3, p.A.Count); p = pt.Bind <Psi>(p); Assert.Equal(2, p.A.Count); Assert.Equal(47, p.A[0].B); Assert.Equal(47, p.A[1].B); }
public void bind_template_add_range_property() { PropertyTreeReader pt = LoadContent("psi-add-range.xml"); Assert.True(pt.Read()); Psi p = new Psi(); var template = pt.Bind <Template <Psi> >(); template.Apply(p); Assert.Equal(4, p.B.Count); Assert.Equal("a", p.B[0]); Assert.Equal("c", p.B[2]); Assert.Equal("d", p.B[3]); }
public static void psi_values_test() //****************************************************************************80 // // Purpose: // // PSI_VALUES_TEST tests PSI_VALUES. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 09 February 2007 // // Author: // // John Burkardt // { double fx = 0; double x = 0; Console.WriteLine(""); Console.WriteLine("PSI_VALUES_TEST"); Console.WriteLine(" PSI_VALUES stores values of"); Console.WriteLine(" the PSI function."); Console.WriteLine(""); Console.WriteLine(" X PSI(X)"); Console.WriteLine(""); int n_data = 0; for (;;) { Psi.psi_values(ref n_data, ref x, ref fx); if (n_data == 0) { break; } Console.WriteLine(" " + x.ToString(CultureInfo.InvariantCulture).PadLeft(12) + " " + fx.ToString("0.################").PadLeft(24) + ""); } }
public static Psi[][][] CalculatePsi(double[][] lambda, PolinomType p_type, int[] rang, int[] x, bool useFrom2Lab) { Psi[][][] result = new Psi[lambda.Length][][]; for (int i = 0; i < result.Length; i++) { result[i] = new Psi[3][]; for (int l = 0; l < 3; l++) { Log.WriteLine(" X" + i + ":"); result[i][l] = new Psi[x[l]]; for (int j = 0; j < result[i][l].Length; j++) { result[i][l][j] = new Psi(useFrom2Lab ? 1 : 0); for (int k = 0; k <= rang[l]; k++) { int index = (x[0]) * (rang[0] + 1) + (x[1]) * (rang[1]) + j * (rang[2]) + k; result[i][l][j].lambda.Add(lambda[i][index]); result[i][l][j].Add(new Polinom(p_type, k)); } } } } return result; }
public void bind_remove_method() { PropertyTreeReader pt = LoadContent("psi-remove.xml"); Assume.That(pt.Read(), Is.True); Psi p = new Psi(); Assume.That(p.A.Count, Is.EqualTo(3)); p = pt.Bind<Psi>(p); Assert.That(p.A.Count, Is.EqualTo(2)); Assert.That(p.A[0].B, Is.EqualTo(47)); Assert.That(p.A[1].B, Is.EqualTo(47)); }
public void bind_clear_method() { PropertyTreeReader pt = LoadContent("psi.xml"); Assume.That(pt.Read(), Is.True); Psi p = new Psi(); Assume.That(p.A.Count, Is.EqualTo(3)); p = pt.Bind<Psi>(p); Assert.That(p.A.Count, Is.EqualTo(0)); }
/* Xt = Data.Xt {t : 1,2,3} */ static double[][] W(Psi[][] p, double[][] X, int t, int multiplicative) { double[][] w; var e = 0; w = new double[X.Length][]; for (int i = 0; i < w.Length; i++) { w[i] = new double[p[t - 1].Length]; for (int j = 0; j < w[i].Length; j++) { if (multiplicative == 0) w[i][j] = p[t - 1][j].value(X[i][j]); else if (multiplicative == 1) w[i][j] = Math.Log(1 + e + p[t - 1][j].value(X[i][j])); else w[i][j] = Math.Log(1.6 + Math.Asin(p[t - 1][j].value(X[i][j]))); } } return w; }
private static double f(Psi[][][] psi, double[][][]x, double[][][] a, double[][] c, int y, int q, int multiplicative) { var e = 0; if(multiplicative==0) { double A = 0; for (int i = 0; i < c[y].Length; i++) A += c[y][i] * F(psi, x[i], a, i, y, q, multiplicative); return A; } else if(multiplicative==1) { double A = 1; for (int i = 0; i < c[y].Length; i++) A *= Math.Pow(1+e+F(psi, x[i], a, i, y, q, multiplicative), c[y][i]); A -= 1 + e; return A; } else { double A = 1; for (int i = 0; i < c[y].Length; i++) A *= Math.Pow(1.6 + Math.Asin(F(psi, x[i], a, i, y, q, multiplicative)), c[y][i]); A -= 1.6; return Math.Sin(A); } }
private static double F(Psi[][][] p, double[][] X, double[][][] a, int x, int y, int q, int multiplicative) { var e = 0; if(multiplicative==0) { double A = 0; for (int i = 0; i < p[y][x].Length; i++) A += a[y][x][i] * (p[y][x][i]).value(X[q][i]); return A; } else if(multiplicative==1) { double A = 1; for (int i = 0; i < p[y][x].Length; i++) A *= Math.Pow(1+e+(p[y][x][i]).value(X[q][i]), a[y][x][i]); A -= 1 + e; return A; } else { double A = 1; for (int i = 0; i < p[y][x].Length; i++) A *= Math.Pow(1.6 + Math.Asin((p[y][x][i]).value(X[q][i])), a[y][x][i]); A -= 1.6; return Math.Sin(A); } }
public static double[][] Y_Get(double[][][] a, double[][][] x, double[][] c, Psi[][][] psi, int length, int length2, int multiplicative) { var Yo = new double[length][]; for (int i = 0; i < Yo.Length; i++) { Yo[i] = new double[length2]; for (int j = 0; j < Yo[i].Length; j++) { Yo[i][j] = f(psi, x, a, c, i, j, multiplicative); } } return Yo; }
public static double[][][] F_Get(double [][][]x, double[][] y, double[][] yt, double[][][] a, Psi[][][] psi, int multiplicative) { double[][][] tF = new double[yt.Length][][]; var e = 0; for (int i = 0; i < tF.Length; i++) { tF[i] = new double[y.Length][]; for (int j = 0; j < tF[i].Length; j++) { tF[i][j] = new double[3]; for (int k = 0; k < 3; k++) { if (multiplicative == 0) tF[i][j][k] = F(psi, x[k], a, k, i, j, multiplicative); else if (multiplicative == 1) tF[i][j][k] = Math.Log(1 + e + F(psi, x[k], a, k, i, j, multiplicative)); else tF[i][j][k] = Math.Log(1.6 + Math.Asin(F(psi, x[k], a, k, i, j, multiplicative))); } } } return tF; }
public static double[][][] A_Get(double[][][]x, double[][] yt, Psi[][][] psi, int method, int multiplicative) { double[][][] a = new double[yt.Length][][]; for (int i = 0; i < a.Length; i++) { a[i] = new double[3][]; for (int j = 0; j < 3; j++) { double[][] w = W(psi[i], x[j], j + 1, multiplicative); switch (method) { case 0: if (multiplicative ==0) a[i][j] = SlaeSolver.Solve(w, yt[i]); else if(multiplicative==1) a[i][j] = SlaeSolver.Solve(w, log(yt[i])); else if (multiplicative == 2) a[i][j] = SlaeSolver.Solve(w, Asin(yt[i])); break; case 1: if (multiplicative==0) a[i][j] = Gradient_method.X(w, yt[i], 0.00001); else if(multiplicative==1) a[i][j] = Gradient_method.X(w, log(yt[i]), 0.00001); else if (multiplicative == 2) a[i][j] = Gradient_method.X(w, Asin(yt[i]), 0.00001); break; } } } return a; }