Class DenseVector
Class defining a dense vector.
Inherited Members
Namespace: BRIDGES.LinearAlgebra.Vectors
Assembly: BRIDGES.dll
Syntax
public sealed class DenseVector : Vector, IDotProduct<Vector, double>, INorm<Vector>, IMetric<Vector>, IGroupAction<Vector, double>, IDotProduct<DenseVector, double>, INorm<DenseVector>, IMetric<DenseVector>, IGroupAction<DenseVector, double>
Constructors
| Improve this Doc View SourceDenseVector(DenseVector)
Initialises a new instance of the DenseVector class from another DenseVector.
Declaration
public DenseVector(DenseVector vector)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | vector | DenseVector to deep copy. |
DenseVector(SparseVector)
Initialises a new instance of the DenseVector class from a SparseVector.
Declaration
public DenseVector(SparseVector vector)
Parameters
Type | Name | Description |
---|---|---|
SparseVector | vector | SparseVector to copy. |
DenseVector(IList<Double>)
Initialises a new instance of the DenseVector class from its components.
Declaration
public DenseVector(IList<double> components)
Parameters
Type | Name | Description |
---|---|---|
IList<Double> | components | Components of the DenseVector. |
DenseVector(Int32)
Initialises a new instance of the DenseVector class of given size, containing only zeros.
Declaration
public DenseVector(int size)
Parameters
Type | Name | Description |
---|---|---|
Int32 | size | Number of component of the DenseVector. |
Properties
| Improve this Doc View SourceItem[Int32]
Gets or sets the component at a given index.
Declaration
public override double this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index | Index of the component to get or set. |
Property Value
Type | Description |
---|---|
Double | The value of the component. |
Overrides
| Improve this Doc View SourceSize
Number of component of this vector.
Declaration
public override int Size { get; }
Property Value
Type | Description |
---|---|
Int32 |
Overrides
Methods
| Improve this Doc View SourceAdd(DenseVector, DenseVector)
Computes the addition of two DenseVector.
Declaration
public static DenseVector Add(DenseVector left, DenseVector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector for the addition. |
DenseVector | right | Right DenseVector for the addition. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the addition. |
Add(DenseVector, SparseVector)
Computes the right addition of a DenseVector with a SparseVector.
Declaration
public static DenseVector Add(DenseVector left, SparseVector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector for the addition. |
SparseVector | right | Right SparseVector for the addition. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the addition. |
Add(DenseVector, Vector)
Computes the right addition of a DenseVector with a Vector.
Declaration
public static DenseVector Add(DenseVector left, Vector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector for the addition. |
Vector | right | Right Vector for the addition. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the addition. |
Divide(DenseVector, Double)
Computes the scalar division of a DenseVector with a
Declaration
public static DenseVector Divide(DenseVector operand, double divisor)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | operand | DenseVector to divide. |
Double | divisor |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the scalar division. |
Equals(DenseVector)
Class defining a dense vector.
Declaration
public bool Equals(DenseVector other)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | other |
Returns
Type | Description |
---|---|
Boolean |
Equals(Vector)
Class defining a dense vector.
Declaration
public override bool Equals(Vector other)
Parameters
Type | Name | Description |
---|---|---|
Vector | other |
Returns
Type | Description |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceEquals(Object)
Class defining a dense vector.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj |
Returns
Type | Description |
---|---|
Boolean |
Overrides
| Improve this Doc View SourceGetEnumerator()
Class defining a dense vector.
Declaration
public override IEnumerator<double> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<Double> |
Overrides
| Improve this Doc View SourceGetHashCode()
Class defining a dense vector.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 |
Overrides
| Improve this Doc View SourceGramSchmidt(IEnumerable<DenseVector>)
Ortho-normalise the set of DenseVector using a Gram-Schimdt process.
Declaration
public static DenseVector[] GramSchmidt(IEnumerable<DenseVector> vectors)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<DenseVector> | vectors | Set of DenseVector to operate on. |
Returns
Type | Description |
---|---|
DenseVector[] | The ortho-normal set of DenseVector. |
Remarks
If the vectors are not linearly independent the number of vectors will change.
Multiply(DenseVector, Double)
Computes the right scalar multiplication of a DenseVector with a
Declaration
public static DenseVector Multiply(DenseVector operand, double factor)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | operand | DenseVector to multiply on the right. |
Double | factor |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the right scalar multiplication. |
Multiply(Double, DenseVector)
Computes the left scalar multiplication of a DenseVector with a
Declaration
public static DenseVector Multiply(double factor, DenseVector operand)
Parameters
Type | Name | Description |
---|---|---|
Double | factor | |
DenseVector | operand | DenseVector to multiply on the left. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the left scalar multiplication. |
Opposite(DenseVector)
Computes the opposite of the DenseVector.
Declaration
public static DenseVector Opposite(DenseVector operand)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | operand | DenseVector from which the opposite is computed. |
Returns
Type | Description |
---|---|
DenseVector | The DenseVector, opposite of the initial one. |
StandardVector(Int32, Int32)
Returns the unit DenseVector of a given size
, with one at the given row index
and zeros elsewhere.
Declaration
public static DenseVector StandardVector(int size, int index)
Parameters
Type | Name | Description |
---|---|---|
Int32 | size | Size of the DenseVector. |
Int32 | index | Index of the standard vector, i.e of the component equal to one. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector representing the standard vector. |
Subtract(DenseVector, DenseVector)
Computes the subtraction of two DenseVector.
Declaration
public static DenseVector Subtract(DenseVector left, DenseVector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector to subtract. |
DenseVector | right | Right DenseVector to subtract with. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the subtraction. |
Subtract(DenseVector, SparseVector)
Computes the right subtraction of a DenseVector with a SparseVector.
Declaration
public static DenseVector Subtract(DenseVector left, SparseVector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector to subtract. |
SparseVector | right | Right SparseVector to subtract with. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the subtraction. |
Subtract(DenseVector, Vector)
Computes the right subtraction of a DenseVector with a Vector.
Declaration
public static DenseVector Subtract(DenseVector left, Vector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector to subtract. |
Vector | right | Right Vector to subtract with. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the subtraction. |
ToArray()
Translates this vector into its array representation.
Declaration
public override double[] ToArray()
Returns
Type | Description |
---|---|
Double[] | The array representing the vector. |
Overrides
| Improve this Doc View SourceToString()
Class defining a dense vector.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |
Overrides
| Improve this Doc View SourceTransposeMultiply(DenseVector, DenseVector)
Computes the multiplication between the transposed left DenseVector and the right DenseVector.
Declaration
public static double TransposeMultiply(DenseVector left, DenseVector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector to transpose, then multiply. |
DenseVector | right | Right DenseVector to multiply. |
Returns
Type | Description |
---|---|
Double | The scalar value resulting from the operation. |
TransposeMultiply(DenseVector, SparseVector)
Computes the multiplication between the transposed left DenseVector and the right SparseVector.
Declaration
public static double TransposeMultiply(DenseVector left, SparseVector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector to transpose, then multiply. |
SparseVector | right | Right SparseVector to multiply. |
Returns
Type | Description |
---|---|
Double | The scalar value resulting from the operation. |
TransposeMultiply(DenseVector, Vector)
Computes the multiplication between the transposed left DenseVector and the right Vector.
Declaration
public static double TransposeMultiply(DenseVector left, Vector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector to transpose, then multiply. |
Vector | right | Right Vector to multiply. |
Returns
Type | Description |
---|---|
Double | The scalar value resulting from the operation. |
Zero(Int32)
Returns the neutral DenseVector for the addition.
Declaration
public static DenseVector Zero(int size)
Parameters
Type | Name | Description |
---|---|---|
Int32 | size | Number of component of the DenseVector. |
Returns
Type | Description |
---|---|
DenseVector | The DenseVector of the given size, with zeros on every coordinates. |
Operators
| Improve this Doc View SourceAddition(DenseVector, DenseVector)
Computes the addition of two DenseVector.
Declaration
public static DenseVector operator +(DenseVector left, DenseVector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector for the addition. |
DenseVector | right | Right DenseVector for the addition. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the addition. |
Addition(DenseVector, SparseVector)
Computes the right addition of a DenseVector with a SparseVector.
Declaration
public static DenseVector operator +(DenseVector left, SparseVector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector for the addition. |
SparseVector | right | Right SparseVector for the addition. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the addition. |
Addition(DenseVector, Vector)
Computes the right addition of a DenseVector with a Vector.
Declaration
public static DenseVector operator +(DenseVector left, Vector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector for the addition. |
Vector | right | Right Vector for the addition. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the addition. |
Division(DenseVector, Double)
Computes the scalar division of a DenseVector with a
Declaration
public static DenseVector operator /(DenseVector operand, double divisor)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | operand | DenseVector to divide. |
Double | divisor |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the scalar division. |
Equality(DenseVector, DenseVector)
Evaluates whether two DenseVector are equal or not.
Declaration
public static bool operator ==(DenseVector left, DenseVector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector for the comparison. |
DenseVector | right | Right DenseVector for the comparison. |
Returns
Type | Description |
---|---|
Boolean | true if the two DenseVector are equal, false otherwise. |
Inequality(DenseVector, DenseVector)
Evaluates whether two DenseVector are different.
Declaration
public static bool operator !=(DenseVector left, DenseVector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector for the comparison. |
DenseVector | right | Right DenseVector for the comparison. |
Returns
Type | Description |
---|---|
Boolean | true if the two DenseVector are different, false otherwise. |
Multiply(DenseVector, Double)
Computes the right scalar multiplication of a DenseVector with a
Declaration
public static DenseVector operator *(DenseVector operand, double factor)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | operand | DenseVector to multiply on the right. |
Double | factor |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the right scalar multiplication. |
Multiply(Double, DenseVector)
Computes the left scalar multiplication of a DenseVector with a
Declaration
public static DenseVector operator *(double factor, DenseVector operand)
Parameters
Type | Name | Description |
---|---|---|
Double | factor | |
DenseVector | operand | DenseVector to multiply on the left. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the left scalar multiplication. |
Subtraction(DenseVector, DenseVector)
Computes the subtraction of two DenseVector.
Declaration
public static DenseVector operator -(DenseVector left, DenseVector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector to subtract. |
DenseVector | right | Right DenseVector to subtract with. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the subtraction. |
Subtraction(DenseVector, SparseVector)
Computes the right subtraction of a DenseVector with a SparseVector.
Declaration
public static DenseVector operator -(DenseVector left, SparseVector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector to subtract. |
SparseVector | right | Right SparseVector to subtract with. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the subtraction. |
Subtraction(DenseVector, Vector)
Computes the right subtraction of a DenseVector with a Vector.
Declaration
public static DenseVector operator -(DenseVector left, Vector right)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | left | Left DenseVector to subtract. |
Vector | right | Right Vector to subtract with. |
Returns
Type | Description |
---|---|
DenseVector | The new DenseVector resulting from the subtraction. |
UnaryNegation(DenseVector)
Computes the opposite of the DenseVector.
Declaration
public static DenseVector operator -(DenseVector operand)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | operand | DenseVector from which the opposite is computed. |
Returns
Type | Description |
---|---|
DenseVector | The DenseVector, opposite of the initial one. |
Explicit Interface Implementations
| Improve this Doc View SourceIDotProduct<DenseVector, Double>.DotProduct(DenseVector)
Computes the dot product of this element with another element.
Declaration
double IDotProduct<DenseVector, double>.DotProduct(DenseVector other)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | other |
Returns
Type | Description |
---|---|
Double | The value of the dot product of the two elements. |
IMetric<DenseVector>.DistanceTo(DenseVector)
Computes the distance of this element to another element.
Declaration
double IMetric<DenseVector>.DistanceTo(DenseVector other)
Parameters
Type | Name | Description |
---|---|---|
DenseVector | other |
Returns
Type | Description |
---|---|
Double | The value of the distance between the two elements. |
IGroupAction<DenseVector, Double>.Divide(Double)
Computes the right scalar division of the current element.
Declaration
DenseVector IGroupAction<DenseVector, double>.Divide(double divisor)
Parameters
Type | Name | Description |
---|---|---|
Double | divisor |
Returns
Type | Description |
---|---|
DenseVector | The new element resulting from the scalar dividion. |
IGroupAction<DenseVector, Double>.Multiply(Double)
Computes the right scalar multiplication of the current element.
Declaration
DenseVector IGroupAction<DenseVector, double>.Multiply(double factor)
Parameters
Type | Name | Description |
---|---|---|
Double | factor |
Returns
Type | Description |
---|---|
DenseVector | The new element resulting from the scalar multiplication. |