double IVectorD.Dot(IVectorD other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } return(X * other[0] + Y * other[1] + Z * other[2] + W * other[3]); }
IVectorD IVectorD.Subtract(IVectorD other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } if (this.Dimension >= other.Dimension) { return(new Vector4d(X - other[0], Y - other[1], Z - other[2], W - other[3])); } else { return(other.Subtract(this)); } }
IVectorD IVectorD.Add(IVectorD other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } if (this.Dimension >= other.Dimension) { return(new Vector4d(X + other[0], Y + other[1], Z + other[2], W + other[3])); } else { return(other.Add(this)); } }
double IVectorD.Dot(IVectorD other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } if (other.Dimension < this.Dimension) { return(other.Dot(this)); } var dim = this.Dimension; var result = 0.0; for (var i = 0; i < dim; i++) { result += this.values[i] * other[i]; } return(result); }
IVectorD IVectorD.Subtract(IVectorD other) { if (other == null) { throw new ArgumentNullException(nameof(other)); } if (this.Dimension >= other.Dimension) { var dim = this.Dimension; var result = new double[dim]; for (var i = 0; i < dim; i++) { result[i] = this.values[i] - other[i]; } return(new VectorNd(ref result)); } else { return(other.Subtract(this)); } }