public void BiHarmonicAlg(int n, number ev1, number ev2) { n++; number t = ((number)1) / n; number s = ((number)1) - t; number _ev1 = n - 1, _ev2 = ((number)1), _ev3 = ((number)1) * _ev2; //number _ev1 = 1f / ev1 + n, _ev2 = 1f / ev2, _ev3 = .5f * _ev2; double power = 1; //1.2f; _ev1 = (number)Math.Pow((double)_ev1, power); _ev2 = (number)Math.Pow((double)_ev2, power); _ev3 = (number)Math.Pow((double)_ev3, power); number total = _ev1 + _ev2 + _ev3; CombineStrats(_ev1 / total, _ev2 / total, _ev3 / total); }
public DegreeAngle(int circles, int degrees, int minutes, number seconds, bool isNegative) { Assert.IsGreaterThanOrEqual(circles, 0, nameof(circles)); Assert.IsInRange(degrees, MinDegrees, MaxDegrees, nameof(degrees)); Assert.IsInRange(minutes, MinMinutes, MaxMinutes, nameof(minutes)); Assert.IsInRange(seconds, _secondsRange, nameof(seconds)); number totalSeconds = (circles * Constants.ArcsecondsPerTurn + degrees * Constants.ArcsecondsPerDegree + minutes * Constants.ArcsecondsPerArcminute + seconds); if (isNegative) { totalSeconds *= -1; } Assert.IsInRange(totalSeconds, MinTotalSeconds, MaxTotalSeconds, nameof(totalSeconds)); TotalSeconds = totalSeconds; _circles = circles; _degrees = degrees; _minutes = minutes; _seconds = seconds; }
private void TimerShiftStarFood_Tick(object sender, EventArgs e) { if (counterStarFood == number.zero) { sFood.visible = true; timerShiftStarFood.Stop(); timerShiftStarFood.Start(); } else if (counterStarFood == number.five && sFood.visible == true) { sFood.visible = false; counterStarFood = number.zero; } counterStarFood++; if ((int)counterStarFood == 10) { counterStarFood = number.zero; } }
public static Angle operator %(Angle nominator, number denominator) { if (denominator == Constants.Zero) { throw new DivideByZeroException("Denominator is zero."); } var nominatorUnit = nominator.Unit; if (nominatorUnit.IsEquivalentOf(DefaultUnit)) { return(new Angle(nominator.Turns % denominator, value: null, unit: nominator._unit)); } else { number resultValue = nominator.Value % denominator; number turns = GetTurns(resultValue, nominatorUnit); return(new Angle(turns, resultValue, nominatorUnit)); } }
public void MultipleSerialConversion_ShouldHaveSameValueAtTheEnd(number value) { // arrange var units = new List <AngleUnit> { AngleUnit.Turn, AngleUnit.Radian, AngleUnit.Degree, AngleUnit.Gradian, AngleUnit.Turn }; var initialAngle = new Angle(value, units.First()); Angle?finalAngle = null; // act units.ForEach(u => finalAngle = (finalAngle ?? initialAngle).Convert(u)); // assert finalAngle.Should().Be(initialAngle); }
public void MultipleSerialConversion_ShouldHaveSameValueAtTheEnd(number value) { // arrange var units = new List <WeightUnit> { WeightUnit.Kilogram, WeightUnit.Gram, WeightUnit.Ton, WeightUnit.Pound, WeightUnit.Ounce, WeightUnit.Kilogram }; var initialWeight = new Weight(value, units.First()); Weight?finalWeight = null; // act units.ForEach(u => finalWeight = (finalWeight ?? initialWeight).Convert(u)); // assert finalWeight.Should().Be(initialWeight); }
public RadianAngle GetBearingTo(GeoCoordinate destination) { if (IsEmpty) { throw new ArgumentException("Cannot compute bearing from unknown coordinate."); } if (destination.IsEmpty) { throw new ArgumentException("Cannot compute bearing to unknown coordinate."); } var φ1 = LatitudeRadians; var λ1 = LongitudeRadians; var φ2 = destination.LatitudeRadians; var λ2 = destination.LongitudeRadians; var Δλ = λ2 - λ1; number y = MathA.Sin(Δλ) * MathA.Cos(φ2); number x = MathA.Cos(φ1) * MathA.Sin(φ2) - MathA.Sin(φ1) * MathA.Cos(φ2) * MathA.Cos(Δλ); return(MathA.Atan2(y, x)); }
private static IEnumerable <DestinationPointTestData> GetDestinationPointTestData() { const number zero = (number)0m; const number half = (number)0.5m; const number one = (number)1m; const number two = (number)2m; const number ten = (number)10m; yield return(new DestinationPointTestData(zero, zero, TenDegreeOfLatitudeInMeters, zero, ten, zero)); yield return(new DestinationPointTestData(zero, zero, TenDegreeOfLatitudeInMeters, Constants.PI, -ten, zero)); yield return(new DestinationPointTestData(zero, zero, TenDegreeOfLatitudeInMeters, -Constants.PI, -ten, zero)); yield return(new DestinationPointTestData(zero, zero, TenDegreeOfLatitudeInMeters, 2 * Constants.PI, ten, zero)); yield return(new DestinationPointTestData(zero, zero, TenDegreeOfLongitudeInMetersAtTheEquator, half * Constants.PI, zero, ten)); yield return(new DestinationPointTestData(zero, zero, TenDegreeOfLongitudeInMetersAtTheEquator, (one + half) * Constants.PI, zero, -ten)); yield return(new DestinationPointTestData(zero, zero, TenDegreeOfLongitudeInMetersAtTheEquator, (two + half) * Constants.PI, zero, ten)); }
public Length GetDistanceTo(GeoCoordinate destination) { if (IsEmpty) { throw new ArgumentException("Cannot compute distance from unknown coordinate."); } if (destination.IsEmpty) { throw new ArgumentException("Cannot compute distance to unknown coordinate."); } var φ1 = LatitudeRadians; var λ1 = LongitudeRadians; var φ2 = destination.LatitudeRadians; var λ2 = destination.LongitudeRadians; var Δφ = φ2 - φ1; var Δλ = λ2 - λ1; number a = MathA.Sin(Δφ * Constants.Half) * MathA.Sin(Δφ * Constants.Half) + MathA.Cos(φ1) * MathA.Cos(φ2) * MathA.Sin(Δλ * Constants.Half) * MathA.Sin(Δλ * Constants.Half); number c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a)); return(c * EarthRadius); }
public GeoCoordinate GetDestinationPoint(Length distance, RadianAngle bearing) { if (IsEmpty) { throw new ArgumentException("Cannot compute destination point from unknown coordinate."); } var φ1 = LatitudeRadians; var λ1 = LongitudeRadians; var δ = new RadianAngle(distance / EarthRadius); var φ2 = MathA.Asin(MathA.Sin(φ1) * MathA.Cos(δ) + MathA.Cos(φ1) * MathA.Sin(δ) * MathA.Cos(bearing)); number y = MathA.Sin(bearing) * MathA.Sin(δ) * MathA.Cos(φ1); number x = MathA.Cos(δ) - MathA.Sin(φ1) * MathA.Sin(φ2); var Δλ = MathA.Atan2(y, x); var λ2 = λ1 + Δλ; // Normalize longitude to range -π ... +π (that is, -180° ... +180°) λ2 = (λ2 + 3 * RadianAngle.PI) % (2 * Constants.PI) - RadianAngle.PI; return(new GeoCoordinate(φ2, λ2)); }
private static IEnumerable <ITestDataProvider> GetBearingTestData() { const number zero = (number)0; const number pi = Constants.PI; yield return(new BearingTestData(zero, zero, 90, zero, zero * pi / 180)); yield return(new BearingTestData(zero, zero, zero, 90, 90 * pi / 180)); yield return(new BearingTestData(zero, zero, -90, zero, 180 * pi / 180)); yield return(new BearingTestData(zero, zero, zero, -90, -90 * pi / 180)); yield return(new BearingTestData(zero, zero, 45, 90, 45 * pi / 180)); yield return(new BearingTestData(zero, zero, -45, 90, 135 * pi / 180)); yield return(new BearingTestData(zero, zero, -45, -90, -135 * pi / 180)); yield return(new BearingTestData(zero, zero, 45, -90, -45 * pi / 180)); yield return(new BearingTestData(50.233620m, 18.991077m, 52.256371m, 21.011800m, 0.54517783m)); }
private static ParsingExpression TranslateNumber(number num) { uint min = 0, max = uint.MaxValue; if (num.quantor.strings.Any(s => s == "+")) { min = 1; } else if (num.quantor.strings.Any(s => s == "?")) { max = 1; } else if (num.quantor.strings.Any(s => s == "*")) { ; // ok } else { throw new NotImplementedException(""); } return(new ParsingExpression.Number(min, max, TranslateTrivial(num.trivial))); }
public override object Run() { { var Expr_13 = Expr; LNode L, R; if (Expr_13.Calls(CodeSymbols.Assign, 2) && (L = Expr_13.Args[0]) != null && (R = Expr_13.Args[1]) != null || Expr_13.Calls(CodeSymbols.Eq, 2) && (L = Expr_13.Args[0]) != null && (R = Expr_13.Args[1]) != null) { EquationMode = true; number[,] results = RunCore(LNode.Call(CodeSymbols.Sub, LNode.List(L, R)).SetStyle(NodeStyle.Operator), true); number[,] results2 = new number[results.GetLength(0) - 1, results.GetLength(1) - 1]; for (int i = 0; i < results.GetLength(0) - 1; i++) { for (int j = 0; j < results.GetLength(1) - 1; j++) { int sign = Math.Sign(results[i, j]); if (sign == 0 || sign != Math.Sign(results[i + 1, j]) || sign != Math.Sign(results[i, j + 1]) || sign != Math.Sign(results[i + 1, j + 1])) { results2[i, j] = (number)1; } else { results2[i, j] = (number)0; } } } return(Results = results2); } else { EquationMode = Expr.ArgCount == 2 && Expr.Name.IsOneOf( CodeSymbols.GT, CodeSymbols.LT, CodeSymbols.GE, CodeSymbols.LE, CodeSymbols.Neq, CodeSymbols.And, CodeSymbols.Or); return(Results = RunCore(Expr, false)); } } }
publick static void Main(string[] args) { string[] names = new string[3] { "Tom", "John", "George"; } for (int i = 0; i < names.length; i++) { Console.WriteLine(names [i] + "\n"); } int[] array = new int[5]; array[0] = 24; array[1] = 4; array[2] = 2; array[3] = 7; array[4] = 56; for (int i = 0; i < array.length; i++) { Console.WriteLine(array [i] + "\n"); } int[,] number = new number[5, 5]; number [1, 2] = 23; Console.WriteLine(number[i]); Console.ReadKey(); }
private static number GetValue(number metres, PowerUnit targetUnit) => metres / targetUnit.ValueInWatts;
private static number GetWatts(number value, PowerUnit sourceUnit) => value * sourceUnit.ValueInWatts;
public RadianAngle(number radians) { Assert.IsNotNaN(radians, nameof(radians)); Assert.IsInRange(radians, MinRadians, MaxRadians, nameof(radians)); _radians = radians; }
number = CapNumber(number, min, max);
public void ShouldReturnProperValue(number lat1, number lon1, number lat2, number lon2, bool expectedResult) { // arrange var sut = new GeoCoordinate(lat1, lon1); // act bool result = sut.Equals(new GeoCoordinate(lat2, lon2)); // assert result.Should().Be(expectedResult); }
public Card(mast Mast, number number) { this.mast = Mast; this.number = number; }
public void ConstructorForTotalSeconds_ShouldCreateValidTime(number totalSeconds, int expectedHours, int expectedMinutes, number expectedSeconds, bool expectedIsNegative) { // arrange // act var time = new Time(totalSeconds); // assert time.TotalSeconds.Should().Be(totalSeconds); time.Hours.Should().Be(expectedHours); time.Minutes.Should().Be(expectedMinutes); time.Seconds.Should().Be(expectedSeconds); time.IsNegative.Should().Be(expectedIsNegative); }
methods.Add(new ClaimTime(number, module));
static public void Main() { number [] numbers = new number[10]; //an array of number to store the top 10 highest sequence numbers with the highest step counts ulong input = 10000; //***input is the starting sequence number*** //fills the array with a the sequence number and step count to 0 for each number for (int i = 0; i < 10; i++) { numbers[i].num = 0; numbers[i].steps = 0; } ulong control = input; //variable that controls when the all of the sequence numbers have been tested //uses the control variable to stop the while loop until every sequence number starting from in is tested while (control != 0) { ulong count = 0; //sets the step count to 0 input = control; //sets input to the control (current sequence number), to make sure the current sequence number is being tested while (input > 1) //compute the sequence count until input = 1 { if (input % 2 == 0) //tests is input is even { input = input / 2; } else //input is odd { input = (input * 3) + 1; } count++; //increments the step count } input = control; //resets input to be equal to the current sequence number bool dup = false; //duplicate flag int dupIndex = 0; //index of a number with a duplicate step count int smallestIndex = 0; //index with the smallest number of steps ulong smallest = numbers[0].steps; //number with the smallest step count //goes through the array numbers to see which element has the smallest step count and if there are duplicate sequence numbers with the same //step count for (int i = 0; i < 10; i++) { if (numbers[i].steps <= smallest) //checks to see which element has the smallest step count { smallest = numbers[i].steps; //reassigns the number with the smallest number of steps smallestIndex = i; //saves the index with the smallest number of steps } if (numbers[i].steps == count) //checks to see if there is a number in the array with the same step count as the current sequence number { dup = true; //sets the duplicate flag to true dupIndex = i; //saves the index where the duplicate step count occurs } } //if the current sequence number being tested has a higher step count than the smallest step count in the array and the step count is not //a duplicate replace the information at the smallest index to match the current sequence number if (count > numbers[smallestIndex].steps && dup == false) { numbers[smallestIndex].steps = count; numbers[smallestIndex].num = input; } //if the current sequence number being tested is < the sequence number at the duplicate index and the duplicate flag is true, set the number //at the duplicate index to the current sequence number if (input < numbers[dupIndex].num && dup == true) { numbers[dupIndex].num = input; } control--; //decrement the sequence number } //sorts the numbers based on step count Console.WriteLine("Sorted based on step count size: "); Array.Sort(numbers, (x, y) => y.steps.CompareTo(x.steps)); //prints the numbers array to show the sequence number and the step count for that sequence number for (int i = 0; i < 10; i++) { Console.WriteLine(numbers[i].num + " " + numbers[i].steps); } //sorted the numbers based on the size of the sequence number Console.WriteLine("Sorted based on sequence number size: "); Array.Sort(numbers, (x, y) => y.num.CompareTo(x.num)); //prints the numbers array to show the sequence number and the step count for that sequence number for (int i = 0; i < 10; i++) { Console.WriteLine(numbers[i].num + " " + numbers[i].steps); } }
SomeQuantity ILinearQuantityFactory <SomeQuantity, SomeUnit> .Create(number value, SomeUnit unit) => Create(value, unit);
public static SomeQuantity Create(number value, SomeUnit unit) => new SomeQuantity(value, unit);
if (numberResolver(number)) {
yield return(new Line(number, hits.Any() ? string.Join(string.Empty, hits) : null));
public void remove_nanny(number nanny_id) { throw new NotImplementedException(); }
public List <Child> Mothers_children(number mother_id) { throw new NotImplementedException(); }
private SomeUnit(number valueInUnits) { ValueInUnits = valueInUnits; }
/// Optional. The number of versions to retrieve per "page" of results. If there are more remaining results than this number, the response message
public SomeQuantity(number value, SomeUnit unit) { Value = value; Unit = unit; }