public void PointwiseMultiplySparseVector()
        {
            var zeroArray = new[] { 0.0, 1.0, 0.0, 1.0, 0.0 };
            var vector1   = new SparseVector(Data);
            var vector2   = new SparseVector(zeroArray);
            var result    = new SparseVector(vector1.Count);

            vector1.PointwiseMultiply(vector2, result);

            for (var i = 0; i < vector1.Count; i++)
            {
                Assert.AreEqual(Data[i] * zeroArray[i], result[i]);
            }
            Assert.AreEqual(2, result.NonZerosCount);
        }
コード例 #2
0
        public void PointwiseMultiplySparseVector()
        {
            var zeroArray = new[] { Complex32.Zero, new Complex32(1.0f, 1), Complex32.Zero, new Complex32(1.0f, 1), Complex32.Zero };
            var vector1   = new SparseVector(Data);
            var vector2   = new SparseVector(zeroArray);
            var result    = new SparseVector(vector1.Count);

            vector1.PointwiseMultiply(vector2, result);

            for (var i = 0; i < vector1.Count; i++)
            {
                AssertHelpers.AreEqual(Data[i] * zeroArray[i], result[i]);
            }
            Assert.AreEqual(2, result.NonZerosCount);
        }
コード例 #3
0
        public void CanPointwiseMultiplySparseVector()
        {
            var zeroArray = new[] { 0.0, 1.0, 0.0, 1.0, 0.0 };
            var vector1 = new SparseVector(Data);
            var vector2 = new SparseVector(zeroArray);
            var result = new SparseVector(vector1.Count);

            vector1.PointwiseMultiply(vector2, result);

            for (var i = 0; i < vector1.Count; i++)
            {
                Assert.AreEqual(Data[i] * zeroArray[i], result[i]);
            }

            Assert.AreEqual(2, result.NonZerosCount);
        }
コード例 #4
0
        public void CanPointwiseMultiplySparseVector()
        {
            var zeroArray = new[] { Complex32.Zero, new Complex32(1.0f, 1), Complex32.Zero, new Complex32(1.0f, 1), Complex32.Zero };
            var vector1 = new SparseVector(Data);
            var vector2 = new SparseVector(zeroArray);
            var result = new SparseVector(vector1.Count);

            vector1.PointwiseMultiply(vector2, result);

            for (var i = 0; i < vector1.Count; i++)
            {
                Assert.AreEqual(Data[i] * zeroArray[i], result[i]);
            }

            var resultStorage = (SparseVectorStorage<Complex32>)result.Storage;
            Assert.AreEqual(2, resultStorage.ValueCount);
        }
コード例 #5
0
        public void PointwiseMultiplySparseVector()
        {
            var zeroArray = new[] { Complex32.Zero, new Complex32(1.0f, 1), Complex32.Zero, new Complex32(1.0f, 1), Complex32.Zero };
            var vector1 = new SparseVector(Data);
            var vector2 = new SparseVector(zeroArray);
            var result = new SparseVector(vector1.Count);

            vector1.PointwiseMultiply(vector2, result);

            for (var i = 0; i < vector1.Count; i++)
            {
                AssertHelpers.AreEqual(Data[i] * zeroArray[i], result[i]);
            }
            Assert.AreEqual(2, result.NonZerosCount);
        }
コード例 #6
0
        public void CanPointwiseMultiplySparseVector()
        {
            var zeroArray = new[] { 0.0, 1.0, 0.0, 1.0, 0.0 };
            var vector1 = new SparseVector(Data);
            var vector2 = new SparseVector(zeroArray);
            var result = new SparseVector(vector1.Count);

            vector1.PointwiseMultiply(vector2, result);

            for (var i = 0; i < vector1.Count; i++)
            {
                Assert.AreEqual(Data[i] * zeroArray[i], result[i]);
            }

            var resultStorage = (SparseVectorStorage<double>)result.Storage;
            Assert.AreEqual(2, resultStorage.ValueCount);
        }