Ejemplo n.º 1
0
        public static SparseVectorD ToSparse(this VectorXD vector, double zeroTolerance = ZeroTolerance)
        {
            var elements = Enumerable.Range(0, vector.Length)
                           .Zip(vector.GetValues().ToArray(), (index, value) => (index, value)).Where(x => Math.Abs(x.value) > zeroTolerance).ToArray();

            return(new SparseVectorD(elements, vector.Length));
        }
Ejemplo n.º 2
0
        public void ArrayConstructor_ShouldSucced()
        {
            VectorXD v = new VectorXD(new double[] { 1, 2, 5, 6 });

            Assert.Equal(new double[] { 1, 2, 5, 6 }, v.GetValues().ToArray());
            Assert.Equal("VectorXD, 4:\n\n1 2 5 6", v.ToString());
        }