Click or drag to resize
Vector Class
The Vector class represents a D-dimensional Euclidean vector. Vectors are immutable: their values cannot be changed after they are created. It includes methods for addition, subtraction, dot product, scalar product, unit vector, Euclidean norm, and the Euclidean distance between two vectors.
Inheritance Hierarchy
SystemObject
  Algs4NetVector

Namespace: Algs4Net
Assembly: Algs4Net (in Algs4Net.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C#
public class Vector

The Vector type exposes the following members.

Constructors
  NameDescription
Public methodVector(Double)
Initializes a vector from either an array or a vararg list. The vararg syntax supports a constructor that takes a variable number of arugments such as Vector x = new Vector(1.0, 2.0, 3.0, 4.0).
Public methodVector(Int32)
Initializes a d-dimensional zero vector.
Top
Properties
  NameDescription
Public propertyDimension
Returns the dimension of this vector.
Public propertyLength
Returns the length (dimenstion) of this vector. For better semantics, use Dimension
Top
Methods
  NameDescription
Public methodCartesian
Returns the ith cartesian coordinate.
Public methodDirection
Returns a unit vector in the direction of this vector.
Public methodDistanceTo
Returns the Euclidean distance between this vector and the specified vector.
Public methodDot
Returns the do product of this vector with the specified vector.
Public methodMagnitude
Returns the magnitude of this vector. This is also known as the L2 norm or the Euclidean norm.
Public methodStatic memberMainTest
Demo test the Vector data type.
Public methodMinus
Returns the difference between this vector and the specified vector.
Public methodPlus
Returns the sum of this vector and the specified vector.
Public methodScale
Returns the scalar-vector product of this vector and the specified scalar
Public methodTimes
Returns the scalar-vector product of this vector and the specified scalar. Use Scale(Double) for better semantics.
Public methodToString
Returns a string representation of this vector.
(Overrides ObjectToString.)
Top
Remarks

For additional documentation, see Section 1.2 of Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

This class is a C# port from the original Java class Vector implementation by the respective authors.

See Also