Click or drag to resize
Vector Class
Microsoft Research
Base class for vectors. DenseVector, SparseVector, and ApproximateSparseVector all inherit from this base class.
Inheritance Hierarchy

Namespace: MicrosoftResearch.Infer.Maths
Assembly: Infer.Runtime (in Infer.Runtime.dll) Version: 2.6.41128.1 (2.6.41128.1)
Syntax
[SerializableAttribute]
public abstract class Vector : IList<double>, 
	ICollection<double>, IEnumerable<double>, IEnumerable, 
	SettableTo<Vector>, ICloneable, IXmlSerializable, CanSetAllElementsTo<double>, 
	SettableToPower<Vector>, SettableToProduct<Vector>, SettableToProduct<Vector, Vector>, 
	SettableToWeightedSum<Vector>

The Vector type exposes the following members.

Methods
  NameDescription
Public methodAll
Tests if all elements in the vector satisfy the specified condition.
Public methodAny(ConverterDouble, Boolean)
Tests if any elements in the vector satisfy the specified condition.
Public methodAny(Vector, FuncDouble, Double, Boolean)
Test if any corresponding elements in this and that vector satisfy a condition
Public methodAppend(Double)
Appends an item to a vector - returns a new vector
Public methodAppend(Vector)
Return a new vector which is the concatenation of this vector and a second vector.
Public methodClone
Clones this vector - return as a vector
Public methodStatic memberConcat
Create a vector by concatenating two vectors.
Public methodStatic memberConstant(Int32, Double)
Create a dense vector of given length with elements all equal to a specified value
Public methodStatic memberConstant(Int32, Double, Sparsity)
Create a vector of given length with elements all equal to a specified value
Public methodContains
Returns true if the Vector contains the specified item value
Public methodStatic memberCopy(Vector)
Create a vector as a copy of another vector.
Public methodStatic memberCopy(Vector, Sparsity)
Create a vector as a copy of another vector with a given target sparsity
Public methodCopyTo
Copies this vector to the given array starting at the specified index in the target array
Public methodCountAll
Returns the number of elements in the vector which satisfy a given condition.
Public methodEqualsAll
Tests if all elements are equal to a given value.
Public methodFindAll
Returns an enumeration over the indices and values of all elements which satisfy the specified condition. Indices are returned in sorted order.
Public methodStatic memberFromArray(Double)
Constructs a dense vector from an array.
Public methodStatic memberFromArray(Double, Sparsity)
Constructs a vector from an array.
Public methodStatic memberFromArray(Int32, Double, Int32)
Constructs a vector from part of an array.
Public methodStatic memberFromArray(Int32, Double, Int32, Sparsity)
Constructs a vector from part of an array.
Public methodStatic memberFromList
Constructs a vector from a list. Maintains sparsity.
Public methodGetEnumerator
Gets a typed enumerator which yields the vector elements
Public methodGreaterThan(Double)
Tests if all elements are strictly greater than a given value.
Public methodGreaterThan(Vector)
Tests if this vector is strictly greater than a second vector.
Public methodGreaterThanOrEqual(Double)
Tests if all elements are greater than or equal to a given value.
Public methodGreaterThanOrEqual(Vector)
Tests if this vector is than or equal to a second vector.
Public methodIndexAtCumulativeSum
Returns the index of the first element at which the sum of all elements so far is greater than a particular value. Useful for finding the median of a Discrete distribution.
Public methodIndexOf
Returns the index of the first occurence of the given value in the array. Returns -1 if the value is not in the array
Public methodIndexOfAll
Returns an enumeration over the indices of all elements which satisfy the specified condition. Indices are returned in sorted order.
Public methodIndexOfMaximum
Returns the index of the maximum element.
Public methodIndexOfMinimum
Returns the index of the minimum element.
Public methodInner(Vector)
Returns the inner product of this vector with another vector.
Public methodInner(Vector, ConverterDouble, Double)
Returns the inner product of a function of this vector with a second vector.
Public methodInner(ConverterDouble, Double, Vector, ConverterDouble, Double)
Returns the inner product of a function of this vector with a function of a second vector.
Public methodStatic memberInnerProduct
Returns the inner product of two vectors.
Public methodLessThan(Double)
Tests if all elements are strictly less than a given value.
Public methodLessThan(Vector)
Tests if this vector is strictly less than a second vector.
Public methodLessThanOrEqual(Double)
Tests if all elements are less than or equal to a given value.
Public methodLessThanOrEqual(Vector)
Tests if this vector is less than or equal to a second vector.
Public methodLogSumExp
Returns the log of the sum of exponentials of the elements of the vector computed to high accuracy
Public methodMax
Returns the maximum of the elements in the vector
Public methodMax(ConverterDouble, Double)
Returns the maximum of a function of the elements in the vector
Public methodMaxDiff(Vector)
Returns the maximum absolute difference between this vector and another vector.
Public methodMaxDiff(Vector, Double)
Returns the maximum relative difference between this vector and another.
Public methodMedian
Returns the minimum of the elements in the vector
Public methodMin
Returns the minimum of the elements in the vector
Public methodMin(ConverterDouble, Double)
Returns the minimum of a function of the elements in the vector
Public methodOuter
Returns the outer product of this vector with another vector.
Public methodPredivideBy(LowerTriangularMatrix)
Gets the solution to Ax=b, where A is a lower triangular matrix, and b is this vector. Equivalent to the left-division x = A\b.
Public methodPredivideBy(PositiveDefiniteMatrix)
Premultiply this vector by the inverse of a positive definite matrix
Public methodPredivideBy(UpperTriangularMatrix)
Gets the solution to Ax=b, where A is an upper triangular matrix, and b is this vector. Equivalent to the left-division x = A\b.
Public methodPredivideByTranspose
Gets the solution to A'x=b, where A is a lower triangular matrix, and b is this vector. Equivalent to the left-division x = A'\b.
Public methodReduce(Double, FuncDouble, Double, Double)
Reduce method. Operates on this vector
Public methodReduce(Double, Vector, FuncDouble, Double, Double, Double)
Reduce method. Operates on this vector and that vector
Public methodReduce(Double, Vector, Vector, FuncDouble, Double, Double, Double, Double)
Reduce method. Operates on this vector and two other vectors
Public methodScale
Multiplies this vector by a scalar.
Public methodSetAllElementsTo
Sets all elements to a given value.
Public methodSetSubvector
Set a subvector of this to another vector.
Public methodSetTo(IEnumerableDouble)
Copies values from an Enumerable to this vector
Public methodSetTo(Double)
Copies values from an array.
Public methodSetTo(Vector)
Copies values from a Vector to this vector
Public methodSetToDiagonal
Sets this vector to the diagonal of a matrix.
Public methodSetToDifference(Double, Vector)
Set this vector to a constant minus another vector
Public methodSetToDifference(Vector, Vector)
Sets this vector to the difference of two vectors
Public methodSetToDifference(Vector, Double)
Set this vector to another vector minus a constant
Public methodSetToFunction(Vector, ConverterDouble, Double)
Sets the elements of this vector to a function of the elements of a given vector
Public methodSetToFunction(Vector, Vector, FuncDouble, Double, Double)
Sets the elements of this vector to a function of the elements of two vectors
Public methodSetToPower
Sets this vector to the elementwise power of another vector.
Public methodSetToProduct(Matrix, Vector)
Set this vector to the product of a matrix by a vector (i.e. A*x).
Public methodSetToProduct(Vector, Matrix)
Sets this vector to the product of a vector by a matrix (i.e. x*A).
Public methodSetToProduct(Vector, Vector)
Sets this vector to the elementwise product of two other vectors.
Public methodSetToProduct(Vector, Double)
Sets this vector to a vector times a scalar.
Public methodSetToRatio
Sets this vector to the elementwise ratio of two other vectors.
Public methodSetToSubarray
Copies values from an array.
Public methodSetToSubvector
Copies value from a vector.
Public methodSetToSum(Vector, Vector)
Sets this vector to the elementwise sum of two other vectors.
Public methodSetToSum(Vector, Double)
Sets this vector to another vector plus a scalar.
Public methodSetToSum(Double, Vector, Double, Vector)
Set this vector to a linear combination of two other vectors
Public methodSubvector(Int32, Int32)
Create a subvector of this vector
Public methodStatic memberSubvector(Vector, Int32, Int32)
Copy a subvector.
Public methodSum
Returns the sum of all elements.
Public methodSum(ConverterDouble, Double)
Returns the sum of a function of all elements.
Public methodSum(ConverterDouble, Double, Vector, ConverterDouble, Boolean)
Returns the sum of a function of this vector filtered by a function of a second vector.
Public methodSumI
Returns the sum of over zero-based index * element.
Public methodSumISq
Returns the sum of over square of index^2 times element.
Public methodToArray
Converts this vector to an array of doubles
Public methodToString
Converts this sparse vector into a human readable string
(Overrides ObjectToString.)
Public methodToString(String)
String representation of vector with a specified format for each element
Public methodToString(String, String)
String representation of vector with a specified format and delimiter
Public methodToString(String, String, FuncInt32, String)
String representation of vector with a specified format and delimiter and a function for converting integers to display strings.
Public methodStatic memberZero(Int32)
Creates a dense vector of given length with elements all 0.0
Public methodStatic memberZero(Int32, Sparsity)
Creates a vector of given length with elements all 0.0
Top
Operators
  NameDescription
Public operatorStatic memberAddition(Vector, Vector)
Returns the sum of two vectors.
Public operatorStatic memberAddition(Vector, Double)
Add a scalar to every element of a vector.
Public operatorStatic memberDivision
Returns the ratio of two vectors
Public operatorStatic memberEquality
Equality operator.
Public operatorStatic memberExclusiveOr
Returns a vector to some power.
Public operatorStatic memberGreaterThan(Vector, Vector)
Greater than operator.
Public operatorStatic memberGreaterThan(Vector, Double)
Greater than operator.
Public operatorStatic memberGreaterThanOrEqual(Vector, Vector)
Greater than or equal to operator.
Public operatorStatic memberGreaterThanOrEqual(Vector, Double)
Greater than or equal to operator.
Public operatorStatic memberInequality
Inequality operator.
Public operatorStatic memberLessThan(Vector, Vector)
Less than operator.
Public operatorStatic memberLessThan(Vector, Double)
Less than operator.
Public operatorStatic memberLessThanOrEqual(Vector, Vector)
Less than or equal to operator.
Public operatorStatic memberLessThanOrEqual(Vector, Double)
Less than or equal to operator.
Public operatorStatic memberMultiply(Double, Vector)
Multiply every element of this vector by a scalar.
Public operatorStatic memberMultiply(Vector, Vector)
Returns the elementwise product of two vectors.
Public operatorStatic memberMultiply(Vector, Double)
Multiplies every element of a vector by a scalar.
Public operatorStatic memberSubtraction(Double, Vector)
Subtracts a scalar from each element of a vector.
Public operatorStatic memberSubtraction(Vector, Vector)
Returns the difference of two vectors
Public operatorStatic memberSubtraction(Vector, Double)
Subtracts a scalar from each element of a vector.
Public operatorStatic memberUnaryNegation
Returns a vector which is the unary negation of a vector.
Top
Extension Methods
  NameDescription
Public Extension MethodAddRangeDouble
Add multiple items to a collection
(Defined by Collection.)
Public Extension MethodContainsAllDouble
Test if a collection contains multiple items
(Defined by Collection.)
Public Extension MethodContainsAnyDouble
Test if a collection contains any of multiple items
(Defined by Collection.)
Public Extension MethodCopyToDouble (Defined by EnumerableExtensions.)
Public Extension MethodEnumerableReduceDouble, TRes
Reduces across an enumerable, supporting sparse enumerables
(Defined by IEnumerableExensions.)
Public Extension MethodEnumerableSumDouble (Defined by IEnumerableExensions.)
Public Extension MethodFindAllIndexDouble (Defined by EnumerableExtensions.)
Public Extension MethodFindIndexDouble(PredicateDouble)Overloaded.
Get the index of the first item where predicate returns true, or -1 if none
(Defined by EnumerableExtensions.)
Public Extension MethodFindIndexT(PredicateT)Overloaded. (Defined by EnumerableExtensions.)
Public Extension MethodForEachDouble(ActionDouble)Overloaded. (Defined by EnumerableExtensions.)
Public Extension MethodForEachDouble(ActionInt32, Double)Overloaded. (Defined by EnumerableExtensions.)
Public Extension MethodForEachT(ActionT)Overloaded. (Defined by EnumerableExtensions.)
Public Extension MethodForEachT(ActionInt32, T)Overloaded. (Defined by EnumerableExtensions.)
Public Extension MethodIndexOfDouble(Double)Overloaded. (Defined by EnumerableExtensions.)
Public Extension MethodIndexOfT(T)Overloaded. (Defined by EnumerableExtensions.)
Public Extension MethodIndexOfAllDouble (Defined by EnumerableExtensions.)
Public Extension MethodIsSparseDouble
Returns true if and only if this list is sparse
(Defined by IListExtensions.)
Public Extension MethodListReduceDouble, TRes(TRes, FuncTRes, Double, TRes)Overloaded.
Reduces across a list.
(Defined by IListExtensions.)
Public Extension MethodListReduceDouble, T2, TRes(IEnumerableT2, TRes, FuncTRes, Double, T2, TRes)Overloaded.
Reduces across a list and another collection
(Defined by IListExtensions.)
Public Extension MethodListSelectDouble, T2
Similar to LINQ Select, except it takes and returns a list. If the supplied list is sparse, the returned list will also be sparse.
(Defined by IListExtensions.)
Public Extension MethodListZipDouble, TSecond, TResult(IEnumerableTSecond, FuncDouble, TSecond, TResult)Overloaded. (Defined by IEnumerableExensions.)
Public Extension MethodListZipDouble, TSecond, TThird, TResult(IEnumerableTSecond, IEnumerableTThird, FuncDouble, TSecond, TThird, TResult)Overloaded. (Defined by IEnumerableExensions.)
Public Extension MethodListZipDouble, TSecond, TThird, TFourth, TResult(IListTSecond, IListTThird, IListTFourth, FuncDouble, TSecond, TThird, TFourth, TResult)Overloaded. (Defined by IEnumerableExensions.)
Public Extension MethodSetToDouble
Sets this list from an enumerable
(Defined by IListExtensions.)
Public Extension MethodSkipDouble
Skip n items from a stream, saving the skipped items to a list
(Defined by EnumerableExtensions.)
Public Extension MethodToVector
Converts a list of doubles into a vector.
(Defined by IListExtensions.)
Top
Properties
  NameDescription
Public propertyCount
Number of elements in vector
Public propertyIsApproximate
True if this vector is approximate (sparse only)
Public propertyIsDense
True if this vector is dense
Public propertyIsExact
True if this vector is exact (dense or sparse)
Public propertyIsReadOnly
Is read only
Public propertyIsSparse
True if is this vector is sparse (exact or approximate)
Public propertyItem
Gets and sets an element.
Public propertySparsity
The Sparsity specification of this vector.
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implementationPrivate methodICollectionDoubleAdd
Explicit interface implementationPrivate methodICollectionDoubleClear
Explicit interface implementationPrivate methodICloneableClone
Explicit interface implementationPrivate methodIEnumerableGetEnumerator
Explicit interface implementationPrivate methodIXmlSerializableGetSchema
Explicit interface implementationPrivate methodIListDoubleInsert
Explicit interface implementationPrivate methodIXmlSerializableReadXml
Throws an exception. Provided only to allow serialization of derived classes.
Explicit interface implementationPrivate methodICollectionDoubleRemove
Explicit interface implementationPrivate methodIListDoubleRemoveAt
Explicit interface implementationPrivate methodIXmlSerializableWriteXml
Throws an exception. Provided only to allow serialization of derived classes.
Top
Remarks
This class includes factory methods for instantiating Vectors of different Sparsity specifications. Beyond this initial construction, application code does not need to know the the sparsity, and most operations can be done via this general base class which will handle sparsity correctly.
See Also