Esempio n. 1
0
        public void UncertainMathLogExp()
        {
            UncertainValue la = UncertainMath.Log(a);

            Assert.IsTrue(la.Uncertainty == a.RelativeUncertainty);
            Assert.IsTrue(UncertainMath.Exp(la) == a);
        }
Esempio n. 2
0
        public void UncertainMathSqrtSquare()
        {
            UncertainValue sa = UncertainMath.Sqrt(a);

            Assert.IsTrue(TestUtilities.IsNearlyEqual(sa.RelativeUncertainty, a.RelativeUncertainty / 2.0));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(UncertainMath.Pow(sa, 2.0).Value, a.Value));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(UncertainMath.Pow(sa, 2.0).Uncertainty, a.Uncertainty));
        }
Esempio n. 3
0
        public void UncertainMathSinASin()
        {
            UncertainValue y  = new UncertainValue(0.5, 0.1);
            UncertainValue x  = UncertainMath.Asin(y);
            UncertainValue sx = UncertainMath.Sin(x);

            Assert.IsTrue(TestUtilities.IsNearlyEqual(sx.Value, y.Value));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(sx.Uncertainty, y.Uncertainty));
        }
Esempio n. 4
0
        public void UncertainMathCosACos()
        {
            UncertainValue y  = new UncertainValue(0.5, 0.1);
            UncertainValue x  = UncertainMath.Acos(y);
            UncertainValue cx = UncertainMath.Cos(x);

            Assert.IsTrue(TestUtilities.IsNearlyEqual(cx.Value, y.Value));
            Assert.IsTrue(TestUtilities.IsNearlyEqual(cx.Uncertainty, y.Uncertainty));
        }
Esempio n. 5
0
 public void UncertainMathValueAgreement()
 {
     // We need to move to IsNearlyEqual because exact equality fails in release mode, even though all-digit printed values are the same
     // I suspect this has to do with the optomized comparison including bits beyond those that strictly belong to the value and are random
     Assert.IsTrue(TestUtilities.IsNearlyEqual(UncertainMath.Cos(a).Value, Math.Cos(a.Value)));
     Assert.IsTrue(TestUtilities.IsNearlyEqual(UncertainMath.Sin(a).Value, Math.Sin(a.Value)));
     Assert.IsTrue(TestUtilities.IsNearlyEqual(UncertainMath.Tan(a).Value, Math.Tan(a.Value)));
     Assert.IsTrue(TestUtilities.IsNearlyEqual(UncertainMath.Cosh(a).Value, Math.Cosh(a.Value)));
     Assert.IsTrue(TestUtilities.IsNearlyEqual(UncertainMath.Sinh(a).Value, Math.Sinh(a.Value)));
     Assert.IsTrue(TestUtilities.IsNearlyEqual(UncertainMath.Tanh(a).Value, Math.Tanh(a.Value)));
     Assert.IsTrue(TestUtilities.IsNearlyEqual(UncertainMath.Log(a).Value, Math.Log(a.Value)));
     Assert.IsTrue(TestUtilities.IsNearlyEqual(UncertainMath.Exp(a).Value, Math.Exp(a.Value)));
     Assert.IsTrue(TestUtilities.IsNearlyEqual(UncertainMath.Sqrt(a).Value, Math.Sqrt(a.Value)));
     Assert.IsTrue(TestUtilities.IsNearlyEqual(UncertainMath.Atan(a).Value, Math.Atan(a.Value)));
 }
Esempio n. 6
0
        public void UncertainValueZeroUncertaintiesTest()
        {
            UncertainValue p = new UncertainValue(3.141592653, 0.0);
            UncertainValue q = new UncertainValue(2.718281828, 0.0);

            UncertainValue sum = p + q;

            Assert.IsTrue(sum.Value == p.Value + q.Value);
            Assert.IsTrue(sum.Uncertainty == 0.0);

            UncertainValue difference = p - q;

            Assert.IsTrue(difference.Value == p.Value - q.Value);
            Assert.IsTrue(difference.Uncertainty == 0.0);

            UncertainValue product = p * q;

            Assert.IsTrue(product.Value == p.Value * q.Value);
            Assert.IsTrue(product.Uncertainty == 0.0);

            UncertainValue quotient = p / q;

            Assert.IsTrue(quotient.Value == p.Value / q.Value);
            Assert.IsTrue(quotient.Uncertainty == 0.0);

            UncertainValue exp = UncertainMath.Exp(p);

            Assert.IsTrue(exp.Value == Math.Exp(p.Value));
            Assert.IsTrue(exp.Uncertainty == 0.0);

            UncertainValue log = UncertainMath.Log(q);

            Assert.IsTrue(log.Value == Math.Log(q.Value));
            Assert.IsTrue(log.Uncertainty == 0.0);

            UncertainValue tan = UncertainMath.Tan(q);

            Assert.IsTrue(TestUtilities.IsNearlyEqual(tan.Value, Math.Tan(q.Value)));
            Assert.IsTrue(tan.Uncertainty == 0.0);

            UncertainValue atan = UncertainMath.Atan(q);

            Assert.IsTrue(TestUtilities.IsNearlyEqual(atan.Value, Math.Atan(q.Value)));
            Assert.IsTrue(atan.Uncertainty == 0.0);
        }