public override void OnInspectorGUI() { DrawDefaultInspector(); CubicEquation equation = target as CubicEquation; equation.sqErr = EditorGUILayout.Slider(new GUIContent("Squared Error"), equation.sqErr, 1.0F, 10.0F); }
/// <summary> /// For more info on OnSceneGUI and Handles.DrawBezier visit this link: https://docs.unity3d.com/ScriptReference/Handles.DrawBezier.html /// </summary> private void OnSceneGUI() { CubicEquation equation = target as CubicEquation; Bezier bezier = equation.GetBezier(equation.a, equation.b, equation.c, equation.d, equation.x0, equation.x1); Handles.DrawBezier(bezier.p0, bezier.p3, bezier.p1, bezier.p2, Color.yellow, null, 2); }
internal override List <double> LogFInvRemote(double target, SGNFnAParam A) { List <double> roots = new List <double>(); double D = -A.B; double B = -A.N * (Math.Log(A.Mode) - 1.0) - target; double qA = -A.N / A.Mode; roots.AddRange(CubicEquation.GetRealRoots(Util.Tools.Combine(D, 0, B, qA), l: 0, u: A.Mode, ROrder: true));// # modif_0.11 roots.Add(Math.Exp(Math.Log(2.0) - target / A.N)); return(roots); }
internal override List <double> LogFInvRemote(double target, SGNFnAParam A) { List <double> roots = new List <double>(); double c3 = -A.N; double c2 = A.N - target; double c0 = -A.B; roots.AddRange(CubicEquation.GetRealRoots(Tools.Combine(c0, 0, c2, c3), l: 0)); roots.Add(-target / A.N); return(roots); } //# end of log.f.inv.remote
private void solveButton_Click(object sender, EventArgs e) { if (a.Text.Trim() == string.Empty || a.Text.Trim() == "0") { MessageBox.Show("Пожалуйста, проверьте аргумент a", "Ошибка"); return; } else if (b.Text.Trim() == string.Empty || b.Text.Trim() == "0") { MessageBox.Show("Пожалуйста, проверьте аргумент a", "Ошибка"); return; } else if (c.Text.Trim() == string.Empty) { MessageBox.Show("Пожалуйста, проверьте аргумент b", "Ошибка"); return; } else if (d.Text.Trim() == string.Empty) { MessageBox.Show("Пожалуйста, проверьте аргумент с", "Ошибка"); return; } else if (f.Text.Trim() == string.Empty) { MessageBox.Show("Пожалуйста, проверьте аргумент d", "Ошибка"); return; } try { CubicEquation ce = new CubicEquation(a.Text, b.Text, c.Text, d.Text, f.Text); double?[] res = ce.Solve(); string result = ""; foreach (double?i in res) { result += " " + Math.Round(Convert.ToDecimal(i), 2) + ";"; } if (res[1].Equals(null) && res[2].Equals(null)) { label3.Text = "x = " + Math.Round(Convert.ToDecimal(res[0]), 2); } else { label3.Text = "x = " + result; } } catch (Exception) { MessageBox.Show("Проверьте введенные данные."); } }
public static double LowestEigenvalue(this SymmetricMatrix3 @this) { var b = @this.Trace(); var c = [email protected] * @this.ZZ + @this.YZ * @this.YZ - @this.XX * @this.ZZ + @this.ZX * @this.ZX - @this.XX * @this.YY + @this.XY * @this.XY; var d = @this.Det(); return(CubicEquation.Solve(-1, b, c, d).Min()); }
internal override double[] Start(SGNFnAParam A) { List <double> roots = new List <double>(); //# solutions in small values for t double C = A.Y2 / A.CV2; double B = -A.Y / A.CV2; roots.AddRange(QuadraticEquation.GetRealRoots(Tools.Combine(C, B, -1), l: 0, ROrder: true)); //# solutions in large values for t double D = A.Y / A.CV2; B = -A.Mu / A.Sigma2; double qA = 1 / A.Sigma2; double[] theta = Tools.Combine(D, 1, B, qA); roots.AddRange(CubicEquation.GetRealRoots(theta, l: 0, ROrder: true)); return(roots.ToArray()); } //# end of start
} //LogFSecond internal override List <double> LogFInvRemote(double target, SGNFnAParam A) { List <double> roots = new List <double>(); //# small values double c3 = -(A.N + 1.0) + A.LM / A.LS2; double c2 = A.N + 1 - Math.Pow(A.LM, 2) / 2.0 / A.LS2 - target; double c0 = -A.B; roots.AddRange(CubicEquation.GetRealRoots(Tools.Combine(c3, c2, 0, c0), l: 0)); //# large values double C = -Math.Pow(A.LM, 2) / 2.0 / A.LS2 - target; double B = A.LM / A.LS2 - (A.N + 1); double vA = -1.0 / 2.0 / A.LS2; double[] tmp = QuadraticEquation.GetRealRoots(Tools.Combine(C, B, vA), l: 0, ROrder: true).ToArray().Exp(); roots.AddRange(tmp); return(roots); } //LogFInvRemote
internal override List <double> LogFInvRemote(double target, SGNFnAParam A) { List <double> roots = new List <double>(); roots.Add(A.Y / (1 + Math.Sqrt(-2.0 * A.CV2 * target))); //# We try a solution with a small t double D = -A.Y2 / 2.0 / A.CV2; double C = A.Y / A.CV2; /* * 3/2 - 1/2/A$cv2 - A$mu^2/2/A$sigma2 - target */ double B = 3.0 / 2.0 - 1.0 / 2.0 / A.CV2 - Math.Pow(A.Mu, 2) / 2.0 / A.Sigma2 - target; double qA = -2.0 + A.Mu / A.Sigma2; double[] theta = Tools.Combine(D, C, B, qA); roots.AddRange(CubicEquation.GetRealRoots(theta, ROrder: true)); // Look also for a solution with a large value for t double tmp = -2.0 * A.Sigma2 * (target + 1 / 2.0 / A.CV2); if (tmp > 0) { double racine = A.Mu + Math.Sqrt(tmp); if (racine > 0.0) { roots.Add(racine); } } return(roots); }