예제 #1
0
 public override bool Equals(object?other)
 {
     if (other is ImmutableVector2D)
     {
         return(ImmutableVector2D.Equals(this, other));
     }
     return(false);
 }
예제 #2
0
        protected BigRational[] MultiplyBase(ImmutableVector2D right)
        {
            var vector = new BigRational[Order];

            for (int rowIndex = 0; rowIndex < Order; rowIndex++)
            {
                BigRational value = 0;
                for (int columnIndex = 0; columnIndex < Order; columnIndex++)
                {
                    value += this.UnderlyingValues[rowIndex, columnIndex] * right.UnderlyingVector[columnIndex];
                }
                vector[rowIndex] = value;
            }
            return(vector);
        }
예제 #3
0
        public bool Equals(ImmutableVector2D other)
        {
            if (this.UnderlyingVector.Count != other.UnderlyingVector.Count)
            {
                return(false);
            }

            for (int i = 0; i < this.UnderlyingVector.Count; i++)
            {
                if (this.UnderlyingVector[i] != other.UnderlyingVector[i])
                {
                    return(false);
                }
            }

            return(true);
        }
 /// <summary>
 /// Multiply the matrix by a given vector.
 /// </summary>
 /// <returns>A new <see cref="ImmutableVector2D"/> with the result of the computation</returns>
 public ImmutableVector2D Multiply(ImmutableVector2D right)
 {
     return(new ImmutableVector2D(base.MultiplyBase(right)));
 }
예제 #5
0
 /// <summary>
 /// Returns a new vector which is equal to this vector minus anright vector
 /// </summary>
 public ImmutableVector2D Subtract(ImmutableVector2D right)
 {
     return(new ImmutableVector2D(new[] { this.UnderlyingVector[0] - right.UnderlyingVector[0], this.UnderlyingVector[1] - right.UnderlyingVector[1] }));
 }
예제 #6
0
 /// <summary>
 /// Returns a new vector which is the sum of two vectors together
 /// </summary>
 public ImmutableVector2D Add(ImmutableVector2D right)
 {
     return(new ImmutableVector2D(new[] { this.UnderlyingVector[0] + right.UnderlyingVector[0], this.UnderlyingVector[1] + right.UnderlyingVector[1] }));
 }