public bool Equals(ImmutableDenseVector <TDataType, TOperationDefiner> equand)
        {
            if (equand == null)
            {
                return(false);
            }

            var opDef = new TOperationDefiner();

            var length = Length;

            if (equand.Length != length)
            {
                return(false);
            }

            var equandItems = equand.Items;

            for (int i = 0; i < length; i++)
            {
                if (!opDef.Equals(this[i], equandItems[i]))
                {
                    return(false);
                }
            }

            return(true);
        }
        public TDataType InnerProduct(ImmutableDenseVector <TDataType, TOperationDefiner> operand)
        {
            if (operand.Length != Length)
            {
                throw new ArgumentOutOfRangeException("The Length of the two vectors must match");
            }

            var operandItems = operand.Items;

            var result = _opDef.Zero;

            for (int i = 0; i < Length; i++)
            {
                result = _opDef.Add(result, _opDef.Multiply(Items[i], operandItems[i]));
            }

            return(result);
        }
        public ImmutableDenseVector <TDataType, TOperationDefiner> Apply(Func <TDataType, TDataType, TDataType> func,
                                                                         ImmutableDenseVector <TDataType, TOperationDefiner> vector)
        {
            if (vector.Length != Length)
            {
                throw new ArgumentOutOfRangeException("The Length of the two vectors must match");
            }

            var thatItems = vector.Items;

            var result = new TDataType[Length];

            for (int i = 0; i < Length; i++)
            {
                result[i] = func(Items[i], thatItems[i]);
            }

            return(new ImmutableDenseVector <TDataType, TOperationDefiner>(result.UnsafeMakeImmutable()));
        }
        public ImmutableDenseVector <TDataType, TOperationDefiner> Subtract(
            ImmutableDenseVector <TDataType, TOperationDefiner> subtrand)
        {
            if (subtrand.Length != Length)
            {
                throw new ArgumentOutOfRangeException("The Length of the two vectors must match");
            }

            var addendItems = subtrand.Items;

            var result = new TDataType[Length];

            for (int i = 0; i < Length; i++)
            {
                result[i] = _opDef.Subtract(Items[i], addendItems[i]);
            }

            return(new ImmutableDenseVector <TDataType, TOperationDefiner>(result.UnsafeMakeImmutable()));
        }