A special kind of matrix which is a range (vector).
Inheritance: MatrixValue
Esempio n. 1
0
        /// <summary>
        /// Tries to create a new instance from the given bytes.
        /// </summary>
        /// <param name="content">The binary content.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var R = new RangeValue();

            R.DimensionY = BitConverter.ToInt32(content, 0);
            R.DimensionX = BitConverter.ToInt32(content, 4);
            var count = BitConverter.ToInt32(content, 8);
            var pos   = 12;

            for (var i = 0; i < count; i++)
            {
                var row = BitConverter.ToInt32(content, pos);
                var col = BitConverter.ToInt32(content, pos + 4);
                var re  = BitConverter.ToDouble(content, pos + 8);
                var im  = BitConverter.ToDouble(content, pos + 16);
                R[row, col] = new ScalarValue(re, im);
                pos        += 24;
            }

            R.Start = BitConverter.ToDouble(content, content.Length - 25);
            R.End   = BitConverter.ToDouble(content, content.Length - 17);
            R.Step  = BitConverter.ToDouble(content, content.Length - 9);
            R.All   = BitConverter.ToBoolean(content, content.Length - 1);
            return(R);
        }
Esempio n. 2
0
        public MatrixValue Function(ScalarValue start, ScalarValue end, ScalarValue count, ScalarValue basis)
        {
            var c = count.GetIntegerOrThrowException("count", Name);

            if (c < 2)
            {
                throw new ArgumentException("logspace");
            }

            var s = (end.Re - start.Re) / (c - 1);
            var r = new RangeValue(start.Re, end.Re, s);
            return MatrixValue.PowSM(basis, r);
        }
Esempio n. 3
0
        public MatrixValue Function(ScalarValue start, ScalarValue end, ScalarValue count, ScalarValue basis)
        {
            var c = count.GetIntegerOrThrowException("count", Name);

            if (c < 2)
            {
                throw new ArgumentException("logspace");
            }

            var s = (end.Re - start.Re) / (c - 1);
            var r = new RangeValue(start.Re, end.Re, s);

            return(MatrixValue.PowSM(basis, r));
        }
Esempio n. 4
0
 /// <summary>
 /// Performs the integration with the values hold in Values and standard x values.
 /// </summary>
 /// <returns>The result of the integration.</returns>
 public virtual ScalarValue Integrate()
 {
     var x = new RangeValue(1, Values.Length, 1);
     return Integrate(x);
 }
Esempio n. 5
0
        /// <summary>
        /// Tries to create a new instance from the given bytes.
        /// </summary>
        /// <param name="content">The binary content.</param>
        /// <returns>The new instance.</returns>
        public override Value Deserialize(byte[] content)
        {
            var R = new RangeValue();
            R.DimensionY = BitConverter.ToInt32(content, 0);
            R.DimensionX = BitConverter.ToInt32(content, 4);
            var count = BitConverter.ToInt32(content, 8);
            var pos = 12;

            for (var i = 0; i < count; i++)
            {
                var row = BitConverter.ToInt32(content, pos);
                var col = BitConverter.ToInt32(content, pos + 4);
                var re = BitConverter.ToDouble(content, pos + 8);
                var im = BitConverter.ToDouble(content, pos + 16);
                R[row, col] = new ScalarValue(re, im);
                pos += 24;
            }

            R.Start = BitConverter.ToDouble(content, content.Length - 25);
            R.End = BitConverter.ToDouble(content, content.Length - 17);
            R.Step = BitConverter.ToDouble(content, content.Length - 9);
            R.All = BitConverter.ToBoolean(content, content.Length - 1);
            return R;
        }