public void Multiply_multiplicationOfnumbers_SideTestOfToString() { //Act var result = a.Multiply(b); //Assert Assert.AreEqual((unchecked ((sbyte)(24 * 42))).ToString(), result.ToString()); //result test }
public void Q8_24_MultiplyNoOverflow() { var pos = new Fixed <Q8_24>(2); var neg = new Fixed <Q8_24>(-16); var posRes = pos.Multiply(pos); var posNeg = pos.Multiply(neg); var negPos = neg.Multiply(pos); var negRes = neg.Multiply(neg); Assert.AreEqual("4", posRes.ToString()); Assert.AreEqual("-32", posNeg.ToString()); Assert.AreEqual("-32", negPos.ToString()); }
public void Q8_24Test() { for (int i = 0; i < 1000; i++) { f9 = f7.Multiply(f8); } }
public void Q16_16Test() { for (int i = 0; i < 1000; i++) { f6 = f4.Multiply(f5); } }
public void Q24_8Test() { for (int i = 0; i < 1000; i++) { f3 = f1.Multiply(f2); } }
public void MultiplicationTestingSameTypesQ24_8(int in1, int in2, string exp) { var f1 = new Fixed <Q24_8>(in1); var f2 = new Fixed <Q24_8>(in2); Assert.Equal(exp, f1.Multiply(f2).ToString()); }
public static void Multiply_multiplicationOfnumbers_negativeResult_SideTestOfToString(Fixed <Q> a, Fixed <Q> b) { //Act var result = a.Multiply(b); //Assert Assert.AreEqual((24 * -42).ToString(), result.ToString()); //result test }
public void Multiplication3() { var f1 = new Fixed <Q24_8>(3); var f2 = new Fixed <Q24_8>(-4); var f3 = f1.Multiply(f2); Assert.AreEqual("-12", f3.ToString()); }
public void TestMultiplication(int intValue1, int intValue2, string expectedResult) { f1 = new Fixed <Q>(intValue1); f2 = new Fixed <Q>(intValue2); var f3 = f1.Multiply(f2); Assert.AreEqual(expectedResult, f3.ToString()); }
public void test3() { var f1 = new Fixed <Q24_8>(3); var f2 = new Fixed <Q24_8>(2); var f3 = f1.Multiply(f2); Assert.AreEqual(f3.ToString(), "6"); }
public void test4() { var f1 = new Fixed <Q8_24>(19); var f2 = new Fixed <Q8_24>(13); var f3 = f1.Multiply(f2); Assert.AreEqual(f3.ToString(), "-9"); }
public void Multiply() { var f1 = new Fixed <Q24_8>(3); var f2 = new Fixed <Q24_8>(2); var f3 = f1.Multiply(f2); Assert.AreEqual("6", f3.ToString()); }
public void Multiplication1() { var f1 = new Fixed <Q8_24>(3); var f2 = new Fixed <Q8_24>(4); var f3 = f1.Multiply(f2); Assert.AreEqual("12", f3.ToString()); }
public void Q24_8_MultiplyOverflow() { var lhs = new Fixed <Q24_8>(Int32.MaxValue); var res = lhs.Multiply(lhs); Assert.AreEqual("1", res.ToString()); }
public void Q8_24_MultiplyOverflow() { var lhs = new Fixed <Q8_24>(16); var res = lhs.Multiply(lhs); Assert.AreEqual("0", res.ToString()); }
public void MultiplyHigher() { var f1 = new Fixed <Q24_8>(19); var f2 = new Fixed <Q24_8>(13); var f3 = f1.Multiply(f2); Assert.AreEqual("247", f3.ToString()); }
public void Q24_8_MultiplyDecimal() { var lhs = new Fixed <Q24_8>(10).Divide(new Fixed <Q24_8>(4)); var res = lhs.Multiply(new Fixed <Q24_8>(8)); Assert.AreEqual("20", res.ToString()); }
public void Multiplication2() { var f1 = new Fixed <Q16_16>(3); var f2 = new Fixed <Q16_16>(0); var f3 = f1.Multiply(f2); Assert.AreEqual("0", f3.ToString()); }
public Fixed <T> Multiply <T>(int a, int b) where T : IArithmetics, new() { var aFixed = new Fixed <T>(a); var bFixed = new Fixed <T>(b); var resultFixed = aFixed.Multiply(bFixed); Assert.AreEqual(Math.Round(a * (double)b, roundDeximalCount), Math.Round(resultFixed, roundDeximalCount)); return(resultFixed); }
public void Multiply_multiplicationOfnumbers_SideTestOfToString() { //Arrange Fixed <Q8_24> a = new Fixed <Q8_24>(3); Fixed <Q8_24> b = new Fixed <Q8_24>(42); //Act var result = a.Multiply(b); //Assert Assert.AreEqual((3 * 42).ToString(), result.ToString()); //result test }
public void Multiply_multiplicationOfnumbers_negativeResult_SideTestOfToString() { //Arrange Fixed <Q24_8> a = new Fixed <Q24_8>(24); Fixed <Q24_8> b = new Fixed <Q24_8>(-42); //Act var result = a.Multiply(b); //Assert Assert.AreEqual((24 * -42).ToString(), result.ToString()); //result test }
public void MultBigQ8_24() { // Too big numbers int a = 7; int b = 50; var aFixed = new Fixed <Q8_24>(a); var bFixed = new Fixed <Q8_24>(b); var negAFixed = bFixed.Multiply(aFixed); //Assert.AreEqual(a * b, Math.Round(negAFixed, roundDeximalCount)); Assert.Inconclusive(); }
public void Fixed_ToString() { var f = new Fixed <T>(67); Assert.AreEqual(((double)f).ToString(), f.ToString()); f = f.Add(new Fixed <T>(48)); Assert.AreEqual(((double)f).ToString(), f.ToString()); f = f.Subtract(new Fixed <T>(85)); Assert.AreEqual(((double)f).ToString(), f.ToString()); f = f.Multiply(new Fixed <T>(6)); Assert.AreEqual(((double)f).ToString(), f.ToString()); f = f.Divide(new Fixed <T>(7)); Assert.AreEqual(((double)f).ToString(), f.ToString()); f = new Fixed <T>(-95); Assert.AreEqual(((double)f).ToString(), f.ToString()); f = f.Divide(new Fixed <T>(11)); Assert.AreEqual(((double)f).ToString(), f.ToString()); f = new Fixed <T>(0); Assert.AreEqual("0", f.ToString()); }
public void Q16_16Test() { var f1 = new Fixed <Q16_16>(a); var f2 = new Fixed <Q16_16>(b); var f3 = f1.Multiply(f2); }
public void Q24_8Test() { var f1 = new Fixed <Q24_8>(a); var f2 = new Fixed <Q24_8>(b); var f3 = f1.Multiply(f2); }
static void Main(string[] args) { Console.WriteLine("Q24_8:"); { var f1 = new Fixed <Q24_8>(3); Console.WriteLine($"3: {f1}"); var f2 = new Fixed <Q24_8>(2); var f3 = f1.Add(f2); Console.WriteLine($"3 + 2: {f3}"); f3 = f1.Multiply(f2); Console.WriteLine($"3 * 2: {f3}"); f1 = new Fixed <Q24_8>(19); f2 = new Fixed <Q24_8>(13); f3 = f1.Multiply(f2); Console.WriteLine($"19 * 13: {f3}"); f1 = new Fixed <Q24_8>(3); f2 = new Fixed <Q24_8>(2); f3 = f1.Divide(f2); Console.WriteLine($"3 / 2: {f3}"); f1 = new Fixed <Q24_8>(248); f2 = new Fixed <Q24_8>(10); f3 = f1.Divide(f2); Console.WriteLine($"248 / 10: {f3}"); f1 = new Fixed <Q24_8>(625); f2 = new Fixed <Q24_8>(1000); f3 = f1.Divide(f2); Console.WriteLine($"625 / 1000: {f3}"); } // Console.WriteLine(); Console.WriteLine("Q16_16:"); { var f1 = new Fixed <Q16_16>(3); Console.WriteLine($"3: {f1}"); var f2 = new Fixed <Q16_16>(2); var f3 = f1.Add(f2); Console.WriteLine($"3 + 2: {f3}"); f3 = f1.Multiply(f2); Console.WriteLine($"3 * 2: {f3}"); f1 = new Fixed <Q16_16>(19); f2 = new Fixed <Q16_16>(13); f3 = f1.Multiply(f2); Console.WriteLine($"19 * 13: {f3}"); f1 = new Fixed <Q16_16>(248); f2 = new Fixed <Q16_16>(10); f3 = f1.Divide(f2); Console.WriteLine($"248 / 10: {f3}"); f1 = new Fixed <Q16_16>(625); f2 = new Fixed <Q16_16>(1000); f3 = f1.Divide(f2); Console.WriteLine($"625 / 1000: {f3}"); } // Console.WriteLine(); Console.WriteLine("Q8_24:"); { var f1 = new Fixed <Q8_24>(3); var f2 = new Fixed <Q8_24>(2); var f3 = f1.Add(f2); Console.WriteLine($"3 + 2: {f3}"); f3 = f1.Multiply(f2); Console.WriteLine($"3 * 2: {f3}"); f1 = new Fixed <Q8_24>(19); f2 = new Fixed <Q8_24>(13); f3 = f1.Multiply(f2); Console.WriteLine($"19 * 13: {f3}"); f1 = new Fixed <Q8_24>(248); f2 = new Fixed <Q8_24>(10); f3 = f1.Divide(f2); Console.WriteLine($"248 / 10: {f3}"); f1 = new Fixed <Q8_24>(625); f2 = new Fixed <Q8_24>(1000); f3 = f1.Divide(f2); Console.WriteLine($"625 / 1000: {f3}"); } }
static void Main(string[] args) { #region Operations Console.WriteLine("Q24_8:"); { var f1 = new Fixed <Q24_8>(3); Console.WriteLine($"3: {f1}"); var f2 = new Fixed <Q24_8>(2); var f3 = f1.Add(f2); Console.WriteLine($"3 + 2: {f3}"); f3 = f1.Multiply(f2); Console.WriteLine($"3 * 2: {f3}"); f1 = new Fixed <Q24_8>(19); f2 = new Fixed <Q24_8>(13); f3 = f1.Multiply(f2); Console.WriteLine($"19 * 13: {f3}"); f1 = new Fixed <Q24_8>(3); f2 = new Fixed <Q24_8>(2); f3 = f1.Divide(f2); Console.WriteLine($"3 / 2: {f3}"); f1 = new Fixed <Q24_8>(248); f2 = new Fixed <Q24_8>(10); f3 = f1.Divide(f2); Console.WriteLine($"248 / 10: {f3}"); f1 = new Fixed <Q24_8>(625); f2 = new Fixed <Q24_8>(1000); f3 = f1.Divide(f2); Console.WriteLine($"625 / 1000: {f3}"); } Console.WriteLine(); Console.WriteLine("Q16_16:"); { var f1 = new Fixed <Q16_16>(3); Console.WriteLine($"3: {f1}"); var f2 = new Fixed <Q16_16>(2); var f3 = f1.Add(f2); Console.WriteLine($"3 + 2: {f3}"); f3 = f1.Multiply(f2); Console.WriteLine($"3 * 2: {f3}"); f1 = new Fixed <Q16_16>(19); f2 = new Fixed <Q16_16>(13); f3 = f1.Multiply(f2); Console.WriteLine($"19 * 13: {f3}"); f1 = new Fixed <Q16_16>(248); f2 = new Fixed <Q16_16>(10); f3 = f1.Divide(f2); Console.WriteLine($"248 / 10: {f3}"); f1 = new Fixed <Q16_16>(625); f2 = new Fixed <Q16_16>(1000); f3 = f1.Divide(f2); Console.WriteLine($"625 / 1000: {f3}"); } Console.WriteLine(); Console.WriteLine("Q8_24:"); { var f1 = new Fixed <Q8_24>(3); var f2 = new Fixed <Q8_24>(2); var f3 = f1.Add(f2); Console.WriteLine($"3 + 2: {f3}"); f3 = f1.Multiply(f2); Console.WriteLine($"3 * 2: {f3}"); f1 = new Fixed <Q8_24>(19); f2 = new Fixed <Q8_24>(13); f3 = f1.Multiply(f2); Console.WriteLine($"19 * 13: {f3}"); f1 = new Fixed <Q8_24>(248); f2 = new Fixed <Q8_24>(10); f3 = f1.Divide(f2); Console.WriteLine($"248 / 10: {f3}"); f1 = new Fixed <Q8_24>(625); f2 = new Fixed <Q8_24>(1000); f3 = f1.Divide(f2); Console.WriteLine($"625 / 1000: {f3}"); } #endregion #region Gaussian Elimination Console.WriteLine(); Console.WriteLine("Gaussian elimination:"); Console.WriteLine(); Console.WriteLine("Q8_24:"); var matrixArr = RandomArray.GetRandomMatrixArray(10, 100); var matrix = new Matrix(matrixArr, 10); Console.WriteLine("Original matrix:"); matrix.Print(); Console.WriteLine("After elimination:"); matrix.EliminateRows(); matrix.Print(); #endregion var summary = BenchmarkRunner.Run <FixedTest>(); }
public void Q8_24Test() { var f1 = new Fixed <Q8_24>(a); var f2 = new Fixed <Q8_24>(b); var f3 = f1.Multiply(f2); }