/// <inheritdoc /> public void StoreElementR4(int index, FValue value, ICliMarshaller marshaller) { AssertIndexValidity(index); Contents.WriteFloat32(index * sizeof(float), (Float32Value)marshaller.ToCtsValue(value, CorLibTypeFactory.Single)); }
/// <inheritdoc /> public void StoreElementR8(int index, FValue value, ICliMarshaller marshaller) { AssertIndexValidity(index); Contents.WriteFloat64(index * sizeof(double), (Float64Value)marshaller.ToCtsValue(value, CorLibTypeFactory.Double)); }
/// <inheritdoc /> protected override DispatchResult Execute(ExecutionContext context, CilInstruction instruction, FValue left, FValue right) { left.F64 += right.F64; context.ProgramState.Stack.Push(left); return DispatchResult.Success(); }
/// <inheritdoc /> protected override DispatchResult Execute(ExecutionContext context, CilInstruction instruction, FValue left, FValue right) { bool result = left.IsGreaterThan(right, instruction.OpCode.Code == CilCode.Cgt_Un); return(ConvertToI4AndReturnSuccess(context, result)); }
public string writeModel(string outModelPath) { outPath = outModelPath; using (System.IO.StreamWriter sw = new System.IO.StreamWriter(outPath)) { sw.WriteLine(modelTypes.LinearRegression.ToString()); sw.WriteLine(InTablePath); sw.WriteLine(String.Join(",", IndependentFieldNames)); sw.WriteLine(String.Join(",", DependentFieldNames)); sw.WriteLine(String.Join(",", ClassFieldNames)); sw.WriteLine(SampleSize.ToString()); sw.WriteLine(NumberOfVariables.ToString()); sw.WriteLine(InterceptThroughOrigin.ToString()); sw.WriteLine(RMSE); sw.WriteLine(FValue.ToString()); sw.WriteLine(PValue.ToString()); sw.WriteLine(Rsquared.ToString()); sw.WriteLine(AdjustedRsquared.ToString()); sw.WriteLine(String.Join(" ", (from double d in Coefficients select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in StandardErrors select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in minValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in maxValues select d.ToString()).ToArray())); sw.WriteLine(String.Join(" ", (from double d in sumValues select d.ToString()).ToArray())); sw.Close(); } return(outPath); }
public void getReport(double alpha) { Forms.RunningProcess.frmRunningProcessDialog rd = new Forms.RunningProcess.frmRunningProcessDialog(false); rd.Text = "Regression Results"; rd.TopLevel = true; rd.pgbProcess.Visible = false; rd.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable; rd.addMessage("Dependent field = " + DependentFieldNames[0]); rd.addMessage("Independent fields = " + String.Join(", ", IndependentFieldNames)); rd.addMessage("Sample size = " + SampleSize.ToString()); rd.addMessage("Intercept Through Origin = " + InterceptThroughOrigin.ToString()); rd.addMessage("F-statistic = " + FValue.ToString() + " p-value = " + PValue.ToString()); rd.addMessage("RMSE = " + RMSE.ToString()); rd.addMessage("R2 = " + Rsquared.ToString()); rd.addMessage("Adj-R2 = " + AdjustedRsquared.ToString() + "\n\nCoefficents and standard errors:\n"); rd.addMessage("Param: Intercept, " + String.Join(", ", IndependentFieldNames)); rd.addMessage("Coef: " + string.Join(", ", (from double d in Coefficients select d.ToString()).ToArray())); rd.addMessage("STE: " + string.Join(", ", (from double d in StandardErrors select d.ToString()).ToArray()) + "\n"); try { if (ModelHelper.chartingAvailable()) { regChart(); } } catch { System.Windows.Forms.MessageBox.Show("Cannot create charts"); } rd.Show(); rd.enableClose(); }
/// <inheritdoc /> protected override Trilean VerifyCondition(ExecutionContext context, CilInstruction instruction, FValue left, FValue right) { // ReSharper disable once CompareOfFloatsByEqualityOperator bool equal = left.F64 == right.F64; bool lessThan = left.IsLessThan(right, IsSigned(instruction)); return(lessThan || equal); }
/// <inheritdoc /> protected override DispatchResult Execute(CilExecutionContext context, CilInstruction instruction, FValue left, FValue right) { // ReSharper disable once CompareOfFloatsByEqualityOperator var i4Result = new I4Value(left.F64 == right.F64 ? 1 : 0); context.ProgramState.Stack.Push(i4Result); return(DispatchResult.Success()); }
/// <summary> /// Safe read method of the internal audio signal. /// Reads silence if the internal audio signal is not set. /// </summary> /// <param name="buffer">The buffer to fill</param> /// <param name="offset"></param> /// <param name="count"></param> public void Read(float[] buffer, int offset, int count) { if (FValue != null) { FValue.Read(buffer, offset, count); } else { buffer.ReadSilence(offset, count); } }
public void CkfiniteNoThrow() { var value = new FValue(1); ExecutionContext.ProgramState.Stack.Push(value); var result = Dispatcher.Execute(ExecutionContext, new CilInstruction(CilOpCodes.Ckfinite)); Assert.True(result.IsSuccess); Assert.Equal(1, ExecutionContext.ProgramState.Stack.Size); }
public void CkfiniteThrow(double d) { var value = new FValue(d); ExecutionContext.ProgramState.Stack.Push(value); var result = Dispatcher.Execute(ExecutionContext, new CilInstruction(CilOpCodes.Ckfinite)); Assert.False(result.IsSuccess); Assert.Equal(result.Exception.Message, new ArithmeticException().Message); Assert.Equal(1, ExecutionContext.ProgramState.Stack.Size); }
static void Main(string[] args) { // Test input arguments if (args.Length != 3) { Console.WriteLine("Please use three arguments: double FValue, int DF1, int DF2."); //Console.ReadLine(); return; } // Try to convert the input arguments to numbers. // FValue double FValue; bool test = double.TryParse(args[0], System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture.NumberFormat, out FValue); if (test == false) { Console.WriteLine("First argument must be double (nnn.n)."); return; } // DF1 int DF1; test = int.TryParse(args[1], out DF1); if (test == false) { Console.WriteLine("Second argument must be int."); return; } // DF2 int DF2; test = int.TryParse(args[2], out DF2); if (test == false) { Console.WriteLine("Third argument must be int."); return; } // Calculate the cumulative F distribution function probability Chart c = new Chart(); double result = c.DataManipulator.Statistics.FDistribution(FValue, DF1, DF2); Console.WriteLine("Input parameters: " + FValue.ToString(System.Globalization.CultureInfo.InvariantCulture.NumberFormat) + " " + DF1.ToString() + " " + DF2.ToString()); Console.WriteLine("Cumulative F distribution function probability: " + result.ToString("P")); }
/// <inheritdoc /> public DispatchResult Execute(CilExecutionContext context, CilInstruction instruction) { var argument = context.ProgramState.Stack.Pop(); var result = argument switch { FValue float64Value => Execute(context, float64Value), IntegerValue integerValue => Execute(context, integerValue), _ => DispatchResult.InvalidProgram() }; if (result.IsSuccess) { context.ProgramState.ProgramCounter += instruction.Size; } return(result); }
public override void Evaluate(int SpreadMax) { if (FInput.IsAnyInvalid()) { FOutput.FlushNil(); return; // if no input, no further calculation. } bool doFlush = false; // any of the update slices is true -> update the plugin. var anyUpdate = FUpdate.Any(); // Flush upstream changes through the plugin if (FInput.IsChanged) { FOutput.SliceCount = 0; FOutput.AssignFrom(FInput); doFlush = true; } else if (!anyUpdate) { return; } var keyCount = FKey.SliceCount; var ValueSpread = FValue.ToISpread(); bool newData = ValueSpread.IsChanged; // changed pin newData |= !FAutoSense[0]; // assume newData, if AutoSense is off. if (anyUpdate && newData) { SpreadMax = FInput.SliceCount; doFlush = true; for (int i = 0; i < SpreadMax; i++) { Message message = FInput[i]; var keyIndex = 0; foreach (var key in FKey) { var fieldIndex = i * keyCount + keyIndex; keyIndex++; if (!FUpdate[fieldIndex]) { continue; } if (!message.Fields.Contains(key)) { message[key] = BinFactory.New(TargetDynamicType); } var value = ValueSpread[fieldIndex] as ISpread; if (value.SliceCount > 0) { if (message[key].GetInnerType().IsAssignableFrom(TargetDynamicType)) { // check if any relevant change occurred if (!message[key].Equals(value as IEnumerable)) { message.AssignFrom(key, value); } } else { var casted = from slice in value as IEnumerable <object> let targetType = message[key].GetInnerType() select Convert.ChangeType(slice, targetType); if (!message[key].Equals(casted)) { message.AssignFrom(key, casted); } } } else { message[key].Clear(); } } } } if (doFlush) { FOutput.Flush(); } }
public override void Evaluate(int SpreadMax) { if (!FInput.IsChanged && !FConfig.IsChanged && !FKey.IsChanged && !FAvoidNil.IsChanged) { return; } SpreadMax = FInput.IsAnyInvalid() ? 0 : FInput.SliceCount; if (SpreadMax == 0) { if (FOutput.SliceCount > 0) // zero inputs -> zero outputs. { FOutput.FlushNil(); FBinSize.SliceCount = 1; FBinSize[0] = 0; FBinSize.Flush(); FValue.ToISpread().FlushNil(); return; } else { return; // already zero'ed } } FOutput.FlushResult(FInput); var keyCount = FKey.SliceCount; FBinSize.SliceCount = SpreadMax; var input = FValue.ToISpread(); input.SliceCount = SpreadMax * keyCount; for (int i = 0; i < SpreadMax; i++) { Message message = FInput[i]; var count = 0; var index = 0; foreach (var key in FKey) { var type = TargetDynamicType; var output = (input[i * keyCount + index] as ISpread); output.SliceCount = 0; if (!message.Fields.Contains(key)) { if (!FAvoidNil.IsAnyInvalid() && FAvoidNil[0]) { output.SliceCount = 1; output[0] = TypeIdentity.Instance.NewDefault(type); } } else { var inputBin = message[key]; if (type.IsAssignableFrom(inputBin.GetInnerType())) { output.SliceCount = inputBin.Count; for (int j = 0; j < inputBin.Count; j++) { output[j] = inputBin[j]; } } else // will throw Exception, if Conversion is not possible { output.SliceCount = inputBin.Count; for (int j = 0; j < inputBin.Count; j++) { output[j] = Convert.ChangeType(inputBin[j], type, CultureInfo.InvariantCulture); } } } count += output.SliceCount; index++; } FBinSize[i] = count; } input.Flush(); FBinSize.Flush(); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (CateID <= 0 || string.IsNullOrEmpty(FieldName)) { function.WriteErrMsg("参数不规范"); } if (Direction == 1) { string css = " <style type=\"text/css\">" + ".text_200_auto {display:block;margin-bottom:3px;width:200px;}</style>"; CSS_L.Text = css; } string[] GradeCate = GradeBll.GetCate(CateID).GradeAlias.Split(new char[] { '|' }); ListItem item1 = new ListItem(); if (GradeCate != null && GradeCate.Length == 1) { item1 = new ListItem(GradeCate[0], "0"); this.DDLGrade1.Visible = true; } ListItem item2 = new ListItem(); if (GradeCate != null && GradeCate.Length == 2) { item1 = new ListItem(GradeCate[0], "0"); this.DDLGrade1.Visible = true; item2 = new ListItem(GradeCate[1], "0"); this.DDLGrade2.Visible = true; } ListItem item3 = new ListItem(); if (GradeCate != null && GradeCate.Length == 3) { item1 = new ListItem(GradeCate[0], "0"); this.DDLGrade1.Visible = true; item2 = new ListItem(GradeCate[1], "0"); this.DDLGrade2.Visible = true; item3 = new ListItem(GradeCate[2], "0"); this.DDLGrade3.Visible = true; } ListItem item4 = new ListItem(); if (GradeCate != null && GradeCate.Length == 4) { item1 = new ListItem(GradeCate[0], "0"); this.DDLGrade1.Visible = true; item2 = new ListItem(GradeCate[1], "0"); this.DDLGrade2.Visible = true; item3 = new ListItem(GradeCate[2], "0"); this.DDLGrade3.Visible = true; item4 = new ListItem(GradeCate[3], "0"); this.DDLGrade4.Visible = true; } ListItem item5 = new ListItem(); if (GradeCate != null && GradeCate.Length == 5) { item1 = new ListItem(GradeCate[0], "0"); this.DDLGrade1.Visible = true; item2 = new ListItem(GradeCate[1], "0"); this.DDLGrade2.Visible = true; item3 = new ListItem(GradeCate[2], "0"); this.DDLGrade3.Visible = true; item4 = new ListItem(GradeCate[3], "0"); this.DDLGrade4.Visible = true; item5 = new ListItem(GradeCate[4], "0"); this.DDLGrade5.Visible = true; } ListItem item6 = new ListItem(); if (GradeCate != null && GradeCate.Length == 6) { item1 = new ListItem(GradeCate[0], "0"); this.DDLGrade1.Visible = true; item2 = new ListItem(GradeCate[1], "0"); this.DDLGrade2.Visible = true; item3 = new ListItem(GradeCate[2], "0"); this.DDLGrade3.Visible = true; item4 = new ListItem(GradeCate[3], "0"); this.DDLGrade4.Visible = true; item5 = new ListItem(GradeCate[4], "0"); this.DDLGrade5.Visible = true; item6 = new ListItem(GradeCate[5], "0"); this.DDLGrade6.Visible = true; } BindGradeDrop(CateID, 0, item1, 1); //绑定一级下拉框 if (!string.IsNullOrEmpty(FValue)) //传入值不为空时 { this.DDLGrade2.Items.Insert(0, item2); if (GradeCate.Length == 3) { this.DDLGrade3.Items.Insert(0, item3); } if (GradeCate.Length == 4) { this.DDLGrade3.Items.Insert(0, item3); this.DDLGrade4.Items.Insert(0, item4); } if (GradeCate.Length == 5) { this.DDLGrade3.Items.Insert(0, item3); this.DDLGrade4.Items.Insert(0, item4); this.DDLGrade5.Items.Insert(0, item5); } if (GradeCate.Length == 6) { this.DDLGrade3.Items.Insert(0, item3); this.DDLGrade4.Items.Insert(0, item4); this.DDLGrade5.Items.Insert(0, item5); this.DDLGrade6.Items.Insert(0, item6); } string[] ValArr = FValue.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries); int Gid = 0; int Gid1 = 0; int Gid2 = 0; int Gid3 = 0; int Gid4 = 0; int Gid5 = 0; string GName = ""; string GName1 = ""; string GName2 = ""; string GName3 = ""; string GName4 = ""; string GName5 = ""; switch (ValArr.Length) { case 1: GName = ValArr[0]; Gid = B_GradeOption.GradeIDByName(CateID, 0, GName); if (Gid > 0) { this.DDLGrade1.SelectedValue = Gid.ToString(); BindGradeDrop(CateID, Gid, item2, 2); //绑定二级下拉框 } break; case 2: GName = ValArr[0]; Gid = B_GradeOption.GradeIDByName(CateID, 0, GName); GName1 = ValArr[1]; Gid1 = B_GradeOption.GradeIDByName(CateID, Gid, GName1); if (Gid > 0) { this.DDLGrade1.SelectedValue = Gid.ToString(); BindGradeDrop(CateID, Gid, item2, 2); //绑定二级下拉框 if (Gid1 > 0) { this.DDLGrade2.SelectedValue = Gid1.ToString(); if (GradeCate.Length == 3) { BindGradeDrop(CateID, Gid1, item3, 3); //绑定三级下拉框 } } } break; case 3: GName = ValArr[0]; Gid = B_GradeOption.GradeIDByName(CateID, 0, GName); GName1 = ValArr[1]; Gid1 = B_GradeOption.GradeIDByName(CateID, Gid, GName1); GName2 = ValArr[2]; Gid2 = B_GradeOption.GradeIDByName(CateID, Gid1, GName2); if (Gid > 0) { this.DDLGrade1.SelectedValue = Gid.ToString(); BindGradeDrop(CateID, Gid, item2, 2); //绑定二级下拉框 if (Gid1 > 0) { this.DDLGrade2.SelectedValue = Gid1.ToString(); if (GradeCate.Length == 3) { BindGradeDrop(CateID, Gid1, item3, 3); //绑定三级下拉框 if (Gid2 > 0) { this.DDLGrade3.SelectedValue = Gid2.ToString(); } } } } break; case 4: GName = ValArr[0]; Gid = B_GradeOption.GradeIDByName(CateID, 0, GName); GName1 = ValArr[1]; Gid1 = B_GradeOption.GradeIDByName(CateID, Gid, GName1); GName2 = ValArr[2]; //throw new Exception(Gid+"|"+Gid1);389|408 Gid2 = B_GradeOption.GradeIDByName(CateID, Gid1, GName2); GName3 = ValArr[3]; Gid3 = B_GradeOption.GradeIDByName(CateID, Gid2, GName3); if (Gid > 0) { this.DDLGrade1.SelectedValue = Gid.ToString(); BindGradeDrop(CateID, Gid, item2, 2); if (Gid1 > 0) { this.DDLGrade2.SelectedValue = Gid1.ToString(); if (GradeCate.Length == 3) { BindGradeDrop(CateID, Gid1, item3, 3); if (Gid2 > 0) { this.DDLGrade3.SelectedValue = Gid2.ToString(); } } if (GradeCate.Length == 4) { BindGradeDrop(CateID, Gid1, item3, 3); this.DDLGrade3.SelectedValue = Gid2.ToString(); BindGradeDrop(CateID, Gid2, item4, 4); if (Gid3 > 0) { this.DDLGrade4.SelectedValue = Gid3.ToString(); } } } } break; case 5: GName = ValArr[0]; Gid = B_GradeOption.GradeIDByName(CateID, 0, GName); GName1 = ValArr[1]; Gid1 = B_GradeOption.GradeIDByName(CateID, Gid, GName1); GName2 = ValArr[2]; //throw new Exception(Gid+"|"+Gid1);389|408 Gid2 = B_GradeOption.GradeIDByName(CateID, Gid1, GName2); GName3 = ValArr[3]; Gid3 = B_GradeOption.GradeIDByName(CateID, Gid2, GName3); GName4 = ValArr[4]; Gid4 = B_GradeOption.GradeIDByName(CateID, Gid3, GName4); if (Gid > 0) { this.DDLGrade1.SelectedValue = Gid.ToString(); BindGradeDrop(CateID, Gid, item2, 2); if (Gid1 > 0) { this.DDLGrade2.SelectedValue = Gid1.ToString(); if (GradeCate.Length == 3) { BindGradeDrop(CateID, Gid1, item3, 3); if (Gid2 > 0) { this.DDLGrade3.SelectedValue = Gid2.ToString(); } } if (GradeCate.Length == 4) { BindGradeDrop(CateID, Gid1, item3, 3); this.DDLGrade3.SelectedValue = Gid2.ToString(); BindGradeDrop(CateID, Gid2, item4, 4); if (Gid3 > 0) { this.DDLGrade4.SelectedValue = Gid3.ToString(); } } if (GradeCate.Length == 5) { BindGradeDrop(CateID, Gid1, item3, 3); this.DDLGrade3.SelectedValue = Gid2.ToString(); BindGradeDrop(CateID, Gid2, item4, 4); this.DDLGrade4.SelectedValue = Gid3.ToString(); BindGradeDrop(CateID, Gid3, item5, 5); if (Gid4 > 0) { this.DDLGrade5.SelectedValue = Gid4.ToString(); } } } } break; case 6: GName = ValArr[0]; Gid = B_GradeOption.GradeIDByName(CateID, 0, GName); GName1 = ValArr[1]; Gid1 = B_GradeOption.GradeIDByName(CateID, Gid, GName1); GName2 = ValArr[2]; //throw new Exception(Gid+"|"+Gid1);389|408 Gid2 = B_GradeOption.GradeIDByName(CateID, Gid1, GName2); GName3 = ValArr[3]; Gid3 = B_GradeOption.GradeIDByName(CateID, Gid2, GName3); GName4 = ValArr[4]; Gid4 = B_GradeOption.GradeIDByName(CateID, Gid3, GName4); GName5 = ValArr[5]; Gid5 = B_GradeOption.GradeIDByName(CateID, Gid4, GName5); if (Gid > 0) { this.DDLGrade1.SelectedValue = Gid.ToString(); BindGradeDrop(CateID, Gid, item2, 2); if (Gid1 > 0) { this.DDLGrade2.SelectedValue = Gid1.ToString(); if (GradeCate.Length == 3) { BindGradeDrop(CateID, Gid1, item3, 3); if (Gid2 > 0) { this.DDLGrade3.SelectedValue = Gid2.ToString(); } } if (GradeCate.Length == 4) { BindGradeDrop(CateID, Gid1, item3, 3); this.DDLGrade3.SelectedValue = Gid2.ToString(); BindGradeDrop(CateID, Gid2, item4, 4); if (Gid3 > 0) { this.DDLGrade4.SelectedValue = Gid3.ToString(); } } if (GradeCate.Length == 5) { BindGradeDrop(CateID, Gid1, item3, 3); this.DDLGrade3.SelectedValue = Gid2.ToString(); BindGradeDrop(CateID, Gid2, item4, 4); this.DDLGrade4.SelectedValue = Gid3.ToString(); BindGradeDrop(CateID, Gid3, item5, 5); if (Gid4 > 0) { this.DDLGrade5.SelectedValue = Gid4.ToString(); } } if (GradeCate.Length == 6) { BindGradeDrop(CateID, Gid1, item3, 3); this.DDLGrade3.SelectedValue = Gid2.ToString(); BindGradeDrop(CateID, Gid2, item4, 4); this.DDLGrade4.SelectedValue = Gid3.ToString(); BindGradeDrop(CateID, Gid3, item5, 5); this.DDLGrade5.SelectedValue = Gid4.ToString(); BindGradeDrop(CateID, Gid4, item6, 6); if (Gid5 > 0) { this.DDLGrade6.SelectedValue = Gid5.ToString(); } } } } break; } } else { this.DDLGrade2.Items.Insert(0, item2); if (GradeCate.Length == 3) { this.DDLGrade3.Items.Insert(0, item3); } if (GradeCate.Length == 4) { this.DDLGrade3.Items.Insert(0, item3); this.DDLGrade4.Items.Insert(0, item4); } if (GradeCate.Length == 5) { this.DDLGrade3.Items.Insert(0, item3); this.DDLGrade4.Items.Insert(0, item4); this.DDLGrade5.Items.Insert(0, item5); } if (GradeCate.Length == 6) { this.DDLGrade3.Items.Insert(0, item3); this.DDLGrade4.Items.Insert(0, item4); this.DDLGrade5.Items.Insert(0, item5); this.DDLGrade6.Items.Insert(0, item6); } } } }
/// <inheritdoc /> protected override DispatchResult Execute(CilExecutionContext context, FValue value) { value.F64 = -value.F64; context.ProgramState.Stack.Push(value); return(DispatchResult.Success()); }
public override void Evaluate(int SpreadMax) { InitDX11Graph(); #region early break if ( !FInput.IsChanged && !FConfig.IsChanged && !FKey.IsChanged && !FAvoidNil.ToISpread().IsChanged && !FAvoidNilEnable.IsChanged && !FSwapDim.IsChanged ) { return; } SpreadMax = FInput.IsAnyInvalid() ? 0 : FInput.SliceCount; if (SpreadMax == 0) { if (!FAvoidNilEnable.IsAnyInvalid() && FAvoidNilEnable[0]) { var force = FAvoidNil.ToISpread().IsChanged || FAvoidNilEnable.IsChanged; if (force || FOutput.SliceCount > 0) // zero inputs -> zero outputs. { FOutput.FlushNil(); // set a default FBinSize.SliceCount = 1; FBinSize[0] = 1; FBinSize.Flush(); FValue.ToISpread().SliceCount = 1; var output = (FValue.ToISpread())[0] as ISpread; var dummies = GetDefaults(FAvoidNil.ToISpread(), 0).ToList(); output.SliceCount = dummies.Count; for (int j = 0; j < dummies.Count; j++) { output[j] = dummies[j]; } FValue.ToISpread().Flush(); return; } else { return; // already defaulted } } else { var force = !FAvoidNilEnable.IsAnyInvalid() && !FAvoidNilEnable[0] && FAvoidNilEnable.IsChanged; if (force || FOutput.SliceCount > 0) // zero inputs -> zero outputs. { FOutput.FlushNil(); FBinSize.SliceCount = 1; FBinSize[0] = 0; FBinSize.Flush(); FValue.ToISpread().FlushNil(); return; } else { return; // already zero'ed } } } #endregion early break FOutput.FlushResult(FInput); var keyCount = FKey.SliceCount; FBinSize.SliceCount = SpreadMax; var binnedOutput = FValue.ToISpread(); binnedOutput.SliceCount = SpreadMax * keyCount; if (!FSwapDim.IsAnyInvalid() && FSwapDim[0]) // fields first { for (int i = 0; i < keyCount; i++) { var fieldName = FKey[i]; var count = 0; var index = 0; foreach (var message in FInput) { var output = (binnedOutput[i * keyCount + index] as ISpread); SetData(message, index, fieldName, output); count += output.SliceCount; index++; } FBinSize[i] = count; } } else // messages first { for (int i = 0; i < SpreadMax; i++) { Message message = FInput[i]; var count = 0; var index = 0; foreach (var fieldName in FKey) { var output = (binnedOutput[i * keyCount + index] as ISpread); SetData(message, index, fieldName, output); count += output.SliceCount; index++; } FBinSize[i] = count; } } binnedOutput.Flush(); FBinSize.Flush(); }
public void DictionaryList() { Console.Title = "Домашнее задание по теме Generic < Dictionary < TKey, TValue> >"; //================================================================================ // Создаем новый Dictionary <TKey, TValue> имен //================================================================================ ColorModule.Colorconsole("Имеем Dictionary <TKey, TValue> городов", ConsoleColor.Magenta); Console.WriteLine(""); ColorModule.Colorconsole("Dictionary < IKey, IValue >", ConsoleColor.Green); Dictionary <IKey, IValue> dictionary1 = new Dictionary <IKey, IValue>(); dictionary1.Add(new DKey() { KeyD = 1 }, new DValue() { ValueD = "Boris" }); dictionary1.Add(new DKey() { KeyD = 2 }, new DValue() { ValueD = "Sergei" }); dictionary1.Add(new DKey() { KeyD = 3 }, new DValue() { ValueD = "Mihail" }); dictionary1.Add(new DKey() { KeyD = 4 }, new DValue() { ValueD = "Natasha" }); dictionary1.Add(new DKey() { KeyD = 5 }, new DValue() { ValueD = "Dima" }); dictionary1.Add(new DKey() { KeyD = 6 }, new DValue() { ValueD = "Vlad" }); foreach (KeyValuePair <IKey, IValue> item in dictionary1) { ColorModule.Colorconsole(" " + item.Key.KeyD + " : " + item.Value.ValueD, ConsoleColor.Gray); } Console.WriteLine(Environment.NewLine); Dictionary <IKey, IValue> dictionary2 = new Dictionary <IKey, IValue>(); var valueKey1 = new FKey() { KeyD = 100 }; var valueKey2 = new FValue() { ValueD = "Smirnov" }; var valueKey3 = new FKey() { KeyD = 110 }; var valueKey4 = new FValue() { ValueD = "Kovalev" }; var valueKey5 = new FKey() { KeyD = 120 }; var valueKey6 = new FValue() { ValueD = "Ivanov" }; var valueKey7 = new FKey() { KeyD = 130 }; var valueKey8 = new FValue() { ValueD = "Smirnov" }; var valueKey9 = new FKey() { KeyD = 140 }; var valueKey10 = new FValue() { ValueD = "Pupkin" }; dictionary2.Add(valueKey1, valueKey2); dictionary2.Add(valueKey3, valueKey4); dictionary2.Add(valueKey5, valueKey6); dictionary2.Add(valueKey7, valueKey8); dictionary2.Add(valueKey9, valueKey10); foreach (KeyValuePair <IKey, IValue> item in dictionary2) { ColorModule.Colorconsole(" " + item.Key.KeyD + " : " + item.Value.ValueD, ConsoleColor.Gray); } Console.WriteLine(Environment.NewLine); Console.WriteLine("Нажмите любую клавишу для выхода....."); MenuModule.menu = "0"; Console.ReadLine(); }
/// <inheritdoc /> protected override Trilean VerifyCondition(CilExecutionContext context, CilInstruction instruction, FValue left, FValue right) { // ReSharper disable once CompareOfFloatsByEqualityOperator return(left.F64 == right.F64); }
/// <inheritdoc /> protected override DispatchResult Execute(CilExecutionContext context, FValue value) => DispatchResult.InvalidProgram();
/// <inheritdoc /> public void StoreElementR8(int index, FValue value, ICliMarshaller marshaller) => _values[index] = marshaller.ToCtsValue(value, CorLibTypeFactory.Double);
/// <summary> /// Performs the operation on the pushed floating point value. /// </summary> /// <param name="context">The context to execute the instruction in.</param> /// <param name="value">The pushed value to perform the operation on.</param> /// <returns>The result of the operation.</returns> protected abstract DispatchResult Execute(CilExecutionContext context, FValue value);
public override void Execute(Context context, IEnumerable <MetadataMember> targets) { if (!context.IsReflectionCorlibSafe) { return; } foreach (var Method in targets.OfType <MethodDefinition>().Where(m => m.CilMethodBody is not null)) { var Instructions = Method.CilMethodBody.Instructions; Method.CilMethodBody.ConstructSymbolicFlowGraph(out var DFG); /* Dfg Constructing. */ for (int x = 0; x < Instructions.Count; x++) { var Instr = Instructions[x]; /* Some People Make It Callvirt To Deafet Public tools :p */ if ((Instr.IsCode(CilCode.Call) || Instr.IsCode(CilCode.Callvirt)) && Instr.IsFromNS("System", "Math") && DFG.Nodes.Contains(Instr.Offset)) { var CallNode = DFG.Nodes[Instr.Offset] .GetOrderedDependencies(DependencyCollectionFlags.IncludeStackDependencies) .ToList(); if (CallNode.Any(x => x.Contents.OpCode.OperandType == CilOperandType.InlineMethod)) { continue; } var vm = new CilVirtualMachine(Method.CilMethodBody, context.Module.Is32Module()); var ex = new CilExecutionContext(vm, vm.CurrentState, default); foreach (var Dep in CallNode) { var CInstr = Dep.Contents; vm.Dispatcher.Execute(ex, CInstr); CInstr.Nop(); } var ISlot = new object[((IMethodDescriptor)Instr.Operand) .Signature.GetTotalParameterCount()]; for (int i = 0; i < ISlot.Length; i++) { var Value = vm.CurrentState.Stack.Pop(); ISlot[i] = Value switch { I4Value I4 => I4.I32, I8Value I8 => I8.I64, FValue F => F.F64, Float32Value F32 => F32.F32, Float64Value F64 => F64.F64, Integer16Value I6 => I6.I16, Integer32Value I32 => I32.I32, Integer64Value I64 => I64.I64, _ => throw new NotSupportedException(nameof(Value)) }; } var InvocationValue = context.ReflectionCorlib.ResolveMethod(((IMethodDescriptor)Instr.Operand).MetadataToken.ToInt32()) .Invoke(null, ISlot); Instr.OpCode = ((IMethodDescriptor)Instr.Operand).Signature.ReturnType.ElementType switch { ElementType.I4 => CilOpCodes.Ldc_I4, ElementType.I8 => CilOpCodes.Ldc_I8, ElementType.R4 => CilOpCodes.Ldc_R4, ElementType.R8 => CilOpCodes.Ldc_R8, _ => CilOpCodes.Ldc_I4, }; Instr.Operand = InvocationValue; } } } } }
/// <inheritdoc /> protected override DispatchResult Execute(CilExecutionContext context, CilInstruction instruction, FValue left, FValue right) { return(DispatchResult.InvalidProgram()); }
public override void Evaluate(int SpreadMax) { InitDX11Graph(); if (FInput.IsAnyInvalid()) { FOutput.FlushNil(); return; // if no input, no further calculation. } bool doFlush = false; // any of the update slices is true -> update the plugin. var anyUpdate = FUpdate.Any(); // Flush upstream changes through the plugin if (FInput.IsChanged) { FOutput.SliceCount = 0; FOutput.AssignFrom(FInput); doFlush = true; } else if (!anyUpdate) { return; } var dataSpread = FValue.ToISpread(); bool newData = dataSpread.IsChanged; // changed pin newData |= FForce[0]; // assume newData, if AutoSense is off. if (anyUpdate && newData) { // Update and Force not included in spreading. SpreadMax = dataSpread.SliceCount.CombineWith(FKey).CombineWith(FInput); if (FUpdate.IsAnyInvalid() || FForce.IsAnyInvalid()) { SpreadMax = 0; } FIterations[0] = SpreadMax; doFlush = true; var fieldIndex = 0; for (int i = 0; i < SpreadMax; i++) // iterate spreaded (except update, which gets cut short) { Message message = FInput[i]; for (int j = 0; j < FKey[i].SliceCount; j++, fieldIndex++) // iterate all relevant fields for each message { if (!FUpdate[fieldIndex]) { continue; // update is per-field } var key = FKey[i][j]; var spread = dataSpread[fieldIndex] as ISpread; LazyInsert(message, key, spread); } } } if (doFlush) { FOutput.Flush(); } }
/// <inheritdoc /> protected override Trilean VerifyCondition(ExecutionContext context, CilInstruction instruction, FValue left, FValue right) { return(left.IsGreaterThan(right, IsSigned(instruction))); }