Exemplo n.º 1
0
            public override VectorBase Add(VectorBase other)
            {
                if (other.Length != this.Length)
                {
                    throw new ArgumentException("Unequal vector lengths.");
                }

                if (other is ZeroVector)
                {
                    return(this);
                }

                if (other is BasisVector)
                {
                    BasisVector obv = other as BasisVector;
                    if (obv.Index == this.Index)
                    {
                        return(new BasisVector(obv.Value + this.Value, Index, Length));
                    }
                }

                VectorBase result = other.Copy();

                result.SetValueAtIndex(result[Index] + Value, Index);
                return(result);
            }
Exemplo n.º 2
0
 public override VectorBase SetValueAtIndex(double value, int index)
 {
     if (index == _index)
     {
         _value = value;
         return(this);
     }
     else if (_indexIsInRange(index))
     {
         VectorBase result = this.AsFullVector();
         result.SetValueAtIndex(value, index);
         return(result);
     }
     else
     {
         throw new IndexOutOfRangeException();
     }
 }
Exemplo n.º 3
0
        public double this[int index]
        {
            get { return(_vector[index]); }

            set { _vector.SetValueAtIndex(value, index); }
        }