public VariableInfo(IArithmeticVariable v, int p) { this.variable = v; this.precision = p; }
protected void RandomizeInputVariableBitConverter(ref IArithmeticVariable variable) { byte[] eightBytes = new byte[8]; Term randomValueTerm = null; var layout = this.termManager.GetLayout(variable.Term); var layoutKind = layout.Kind; this.random.NextBytes(eightBytes); switch (layoutKind) { case LayoutKind.I1: randomValueTerm = this.termManager.I1(eightBytes[0]); break; case LayoutKind.I2: randomValueTerm = this.termManager.I2( BitConverter.ToInt16(eightBytes, 0)); break; case LayoutKind.I4: randomValueTerm = this.termManager.I4( BitConverter.ToInt32(eightBytes, 0)); break; case LayoutKind.I8: randomValueTerm = this.termManager.I8( BitConverter.ToInt64(eightBytes, 0)); break; case LayoutKind.R4: randomValueTerm = this.termManager.R4( BitConverter.ToSingle(eightBytes, 0)); break; case LayoutKind.R8: randomValueTerm = this.termManager.R8( BitConverter.ToDouble(eightBytes, 0)); break; case LayoutKind.Struct: if (layout.StructType.IsDecimalType) { using (_ProtectingThreadContext.Acquire()) { randomValueTerm = this.termManager.Decimal(new decimal( BitConverter.ToInt32(eightBytes, 0), BitConverter.ToInt32(eightBytes, 0), BitConverter.ToInt32(eightBytes, 0), this.random.Next(2) != 0, (byte)this.random.Next(29))); } } else { randomValueTerm = null; } break; case LayoutKind.Uniform: break; default: randomValueTerm = null; break; } if (randomValueTerm != null) { this.modelBuilder.TryAssign(variable, randomValueTerm); } }