public void RandomUnitVector()
        {
            var epsilon = 0.0001;

            // unit vector should have length 1
            ThinSvd.RandomUnitVector(10).Magnitude().Should().BeApproximately(1, epsilon);
            // unit vector with single element should be [-1] or [+1]
            Math.Abs(ThinSvd.RandomUnitVector(1)[0]).Should().BeApproximately(1, epsilon);
            // two randomly generated unit vectors should not be equal
            ThinSvd.RandomUnitVector(10).Should().NotBeEquivalentTo(ThinSvd.RandomUnitVector(10));
        }
예제 #2
0
        public void RandomUnitVector()
        {
            var epsilon = 0.0001;

            // unit vector should have length 1
            Assert.AreEqual(1, V.Magnitude(ThinSvd.RandomUnitVector(10)), epsilon);
            // unit vector with single element should be [-1] or [+1]
            Assert.AreEqual(1, Math.Abs(ThinSvd.RandomUnitVector(1)[0]), epsilon);
            // two randomly generated unit vectors should not be equal
            Assert.AreNotEqual(ThinSvd.RandomUnitVector(10), ThinSvd.RandomUnitVector(10));
        }