int z = 0; //flag private void recountBtn_Click(object sender, EventArgs e) { I1 -= 0.09; I2 -= 0.09; I3 -= 0.09; I4 -= 0.09; I5 -= 0.09; I6 -= 0.09; I1tb.Text = I1.ToString(); I2tb.Text = I2.ToString(); I3tb.Text = I3.ToString(); I4tb.Text = I4.ToString(); I5tb.Text = I5.ToString(); I6tb.Text = I6.ToString(); U2 = I2 * EU * IV / ((IV + I2 + I1) * (I2 + I3 + I4 + I5 - Math.Pow(I2, 2) / (IV + I2 + I1) - Math.Pow((I4 + I5), 2) / (I4 + I5 + I6))); U1 = U2 * I2 / (IV + I2 + I1) + EU * IV / (IV + I2 + I1); U3 = U2 * (I4 + I5) / (I4 + I5 + I6); U1 = Math.Round(U1, 3); U2 = Math.Round(U2, 3); U3 = Math.Round(U3, 3); U1label.Text = "U1 = " + U1.ToString(); U2label.Text = "U2 = " + U2.ToString(); U3label.Text = "U3 = " + U3.ToString(); if (z == 1) { F1 = Math.Round(Math.Pow(U11 - U1, 2), 3); } if (z == 2) { F1 = Math.Round(Math.Pow(U22 - U2, 2), 3); } if (z == 3) { F1 = Math.Round(Math.Pow(U33 - U3, 2), 3); } if (F1 < F) { FTB.Text = F1.ToString(); F = F1; logsRTB.AppendText("Целевая функция уменьшается F=" + F1.ToString() + "\n"); logsRTB.ScrollToCaret(); } else { logsRTB.AppendText("Целевая функция увеличилась F=" + F1.ToString() + "\n"); logsRTB.ScrollToCaret(); recountBtn.Enabled = false; } Fz = 0; calculateGrad(); calculateHessian(); }
public void ToStringTests() { Helper.RunWithMultipleSimulators((qsim) => { var _ = AbstractCallable._; var dump = qsim.Get <ICallable>(typeof(Microsoft.Quantum.Extensions.Diagnostics.DumpMachine <>)); var trace = qsim.Get <IUnitary>(typeof(Circuits.Generics.Trace <>)); var x = qsim.Get <Intrinsic.X>(); var q2 = new FreeQubit(2) as Qubit; var Q = new Q(q2); var Qs = new QArray <Qubit>(q2); var qs = new Qs(Qs); var udtOp = new U3(x); var udtQ = new Q(q2); var t1 = new QTuple <(long, Range, (Qubit, IUnitary))>((1L, new Range(10, -2, 4), (q2, x))); var t4 = new T4((3L, (1.1, false, Result.One))); var t5 = new T5((Pauli.PauliX, Qs, qs, Q)); var d_1 = dump.Partial(_); var d_2 = d_1.Partial(_); var x_1 = x.Partial(new Func <Qubit, Qubit>(q => q)); var x_2 = x_1.Partial(new Func <Qubit, Qubit>(q => q)); var x_3 = x.Partial <OperationPartial <Qubit, Qubit, QVoid> >(_); var t_1 = trace.Adjoint.Partial(_); var t_2 = t_1.Controlled.Partial(_); Assert.Equal("()", QVoid.Instance.ToString()); Assert.Equal("_", _.ToString()); Assert.Equal("U3(X)", udtOp.ToString()); Assert.Equal("q:2", q2.ToString()); Assert.Equal("Q(q:2)", udtQ.ToString()); Assert.Equal("(1, 10..-2..4, (q:2, X))", t1.ToString()); Assert.Equal("T4((3, (1.1, False, One)))", t4.ToString()); Assert.Equal("T5((PauliX, [q:2], Qs([q:2]), Q(q:2)))", t5.ToString()); Assert.Equal("X", x.ToString()); Assert.Equal("(Adjoint X)", x.Adjoint.ToString()); Assert.Equal("(Controlled X)", x.Controlled.ToString()); Assert.Equal("(Adjoint (Controlled X))", x.Controlled.Adjoint.ToString()); Assert.Equal("(Controlled (Adjoint X))", x.Adjoint.Controlled.ToString()); Assert.Equal("X{_}", x_1.ToString()); Assert.Equal("(Adjoint X{_})", x_1.Adjoint.ToString()); Assert.Equal("X{_}{_}", x_2.ToString()); Assert.Equal("X{_}", x_3.ToString()); Assert.Equal("DumpMachine", dump.ToString()); Assert.Equal("DumpMachine{_}", d_1.ToString()); Assert.Equal("DumpMachine{_}{_}", d_2.ToString()); Assert.Equal("Trace", trace.ToString()); Assert.Equal("(Adjoint Trace)", trace.Adjoint.ToString()); Assert.Equal("(Controlled Trace)", trace.Controlled.ToString()); Assert.Equal("(Adjoint (Controlled Trace))", trace.Controlled.Adjoint.ToString()); Assert.Equal("(Adjoint Trace){_}", t_1.ToString()); Assert.Equal("(Adjoint (Controlled (Adjoint Trace){_}){_})", t_2.Adjoint.ToString()); }); }
public override ArrayList GetItemInfo() { ArrayList itemInfo = new ArrayList { new InputText(this, "P1:", P1.ToString(), true, "p1"), new InputText(this, "U1:", U1.ToString(), true, "u1"), new InputText(this, "V1:", V1.ToString(), true, "v1"), new InputText(this, "P2:", P2.ToString(), true, "p2"), new InputText(this, "U2:", U2.ToString(), true, "u2"), new InputText(this, "V2:", V2.ToString(), true, "v2"), new InputText(this, "P3:", P3.ToString(), true, "p3"), new InputText(this, "U3:", U3.ToString(), true, "u3"), new InputText(this, "V3:", V3.ToString(), true, "v3"), new InputText(this, "Material:", Enum.GetName(typeof(P3DMaterial), Material), false, ""), }; return(itemInfo); }
private void button1_Click(object sender, EventArgs e) { IV = Double.Parse(Ivtb.Text); I1 = Double.Parse(I1tb.Text); I2 = Double.Parse(I2tb.Text); I3 = Double.Parse(I3tb.Text); I4 = Double.Parse(I4tb.Text); I5 = Double.Parse(I5tb.Text); I6 = Double.Parse(I6tb.Text); EU = Double.Parse(Etb.Text); U2 = I2 * EU * IV / ((IV + I2 + I1) * (I2 + I3 + I4 + I5 - Math.Pow(I2, 2) / (IV + I2 + I1) - Math.Pow((I4 + I5), 2) / (I4 + I5 + I6))); U1 = U2 * I2 / (IV + I2 + I1) + EU * IV / (IV + I2 + I1); U3 = U2 * (I4 + I5) / (I4 + I5 + I6); U2 = Math.Round(U2, 3); U1 = Math.Round(U1, 3); U3 = Math.Round(U3, 3); U1label.Text = "U1 = " + U1.ToString(); U2label.Text = "U2 = " + U2.ToString(); U3label.Text = "U3 = " + U3.ToString(); }