Example #1
0
        public void Abs()
        {
            // arrange
            var bufferSize = 10;
            var targetData = new int[bufferSize];
            var srcData    = Enumerable.Range(-1 * bufferSize / 2, bufferSize).ToArray();

            var target = new DataAndLayout <int>(targetData, new FastAccess(new Layout(new int[] { bufferSize }, 0, new int[] { 1 })));
            var src    = new DataAndLayout <int>(srcData, new FastAccess(new Layout(new int[] { bufferSize }, 0, new int[] { 1 })));

            // action
            ScalarOps.Abs(target, src);

            // assert
            var allPositive = target.Data.All(v => v >= 0);

            Assert.IsTrue(allPositive);
        }