BRIDGES
  • Articles
  • BRIDGES
Search Results for

    Show / Hide Table of Contents
    • Settings
    • LinearAlgebra
      • Vectors
        • DenseVector
        • SparseVector
        • Vector
      • Factorisation
        • SparseQR
      • Matrices
        • DenseMatrix
        • Matrix
        • SparseMatrix
        • Sparse
          • CompressedColumn
          • CompressedRow
        • Storage
          • DictionaryOfKeys
    • Algebra
      • Measure
        • IDotProduct<TSelf, TValue>
        • IMetric<TSelf>
        • INorm<TSelf>
      • Sets
        • IGroupAction<TSelf, TValue>
      • Fundamentals
        • IAddable<T>
    • Solvers
      • GuidedProjection
        • Energy
        • GuidedProjectionAlgorithm
        • LinearisedConstraint
        • QuadraticConstraint
        • VariableSet
        • EnergyTypes
          • SegmentOrthogonality
          • SegmentParallelity
        • Interfaces
          • IEnergyType
          • ILinearisedConstraintType
          • IQuadraticConstraintType
        • QuadraticConstraintTypes
          • CoherentLength
          • LowerBound
          • UpperBound
          • VectorLength
    • Arithmetic
      • Polynomials
        • Multivariate
          • Monomial
          • Polynomial
        • Univariate
          • Polynomial
          • Specials
            • Bernstein
            • BSpline
      • Numbers
        • Complex
        • Quaternion
        • Real
    • Geometry
      • Euclidean3D
        • Basis
        • BSplineCurve
        • BSplineSurface
        • Circle
        • Frame
        • Line
        • NurbsCurve
        • NurbsSurface
        • Plane
        • Point
        • Polyline
        • Ray
        • Segment
        • Sphere
        • Vector
      • Kernel
        • BSplineCurve<TPoint>
        • BSplineSurface<TPoint>
        • CurveParameterFormat
        • IGeometricallyEquatable<T>
      • Projective3D
        • Point
    • DataStructures
      • PolyhedralMeshes
        • IEdge<TPosition>
        • IFace<TPosition>
        • IMesh<TPosition>
        • IVertex<TPosition>
        • FaceVertexMesh
          • Edge<TPosition>
          • Face<TPosition>
          • Mesh<TPosition>
          • Vertex<TPosition>
        • Abstract
          • Edge<TPosition, TVertex, TEdge, TFace>
          • Face<TPosition, TVertex, TEdge, TFace>
          • Mesh<TPosition, TVertex, TEdge, TFace>
          • Vertex<TPosition, TVertex, TEdge, TFace>
        • HalfedgeMesh
          • Edge<TPosition>
          • Face<TPosition>
          • Halfedge<TPosition>
          • Mesh<TPosition>
          • Vertex<TPosition>

    Class SparseVector

    Class defining a sparse vector.

    Inheritance
    Object
    Vector
    SparseVector
    Implements
    IDotProduct<Vector, Double>
    INorm<Vector>
    IMetric<Vector>
    IGroupAction<Vector, Double>
    IEquatable<SparseVector>
    IEnumerable<Double>
    IDotProduct<SparseVector, Double>
    INorm<SparseVector>
    IMetric<SparseVector>
    IGroupAction<SparseVector, Double>
    Inherited Members
    Vector.Add(Vector, Vector)
    Vector.Subtract(Vector, Vector)
    Vector.Opposite(Vector)
    Vector.Multiply(Double, Vector)
    Vector.Multiply(Vector, Double)
    Vector.Divide(Vector, Double)
    Vector.TransposeMultiply(Vector, Vector)
    Vector.GramSchmidt(IEnumerable<Vector>)
    Vector.Norm()
    Vector.SquaredNorm()
    Vector.IMetric<Vector>.DistanceTo(Vector)
    Vector.IDotProduct<Vector, Double>.DotProduct(Vector)
    Vector.IGroupAction<Vector, Double>.Multiply(Double)
    Vector.IGroupAction<Vector, Double>.Divide(Double)
    Namespace: BRIDGES.LinearAlgebra.Vectors
    Assembly: BRIDGES.dll
    Syntax
    public sealed class SparseVector : Vector, IDotProduct<Vector, double>, INorm<Vector>, IMetric<Vector>, IGroupAction<Vector, double>, IDotProduct<SparseVector, double>, INorm<SparseVector>, IMetric<SparseVector>, IGroupAction<SparseVector, double>

    Constructors

    | Improve this Doc View Source

    SparseVector(SparseVector)

    Initialises a new instance of the SparseVector class from another SparseVector.

    Declaration
    public SparseVector(SparseVector other)
    Parameters
    Type Name Description
    SparseVector other

    SparseVector to deep copy.

    | Improve this Doc View Source

    SparseVector(Int32, IEnumerable<Int32>, IEnumerable<Double>)

    Initialises a new instance of the SparseVector class of given size, with given values.

    Declaration
    public SparseVector(int size, IEnumerable<int> rowIndices, IEnumerable<double> values)
    Parameters
    Type Name Description
    Int32 size

    Number of components of the SparseVector.

    IEnumerable<Int32> rowIndices

    Row indices of the non-zero values of the SparseVector.

    IEnumerable<Double> values

    Non-zero values of the SparseVector.

    | Improve this Doc View Source

    SparseVector(Int32)

    Initialises a new instance of the SparseVector class of given size, containing only zeros.

    Declaration
    public SparseVector(int size)
    Parameters
    Type Name Description
    Int32 size

    Number of components of the SparseVector.

    Properties

    | Improve this Doc View Source

    Item[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
    Vector.Item[Int32]
    | Improve this Doc View Source

    NonZerosCount

    Gets the number of non-zero values in the current sparse vector.

    Declaration
    public int NonZerosCount { get; }
    Property Value
    Type Description
    Int32
    | Improve this Doc View Source

    Size

    Number of component of this vector.

    Declaration
    public override int Size { get; }
    Property Value
    Type Description
    Int32
    Overrides
    Vector.Size

    Methods

    | Improve this Doc View Source

    Add(SparseVector, DenseVector)

    Computes the right addition of a SparseVector with a DenseVector.

    Declaration
    public static DenseVector Add(SparseVector left, DenseVector right)
    Parameters
    Type Name Description
    SparseVector left

    Left SparseVector for the addition.

    DenseVector right

    Right DenseVector for the addition.

    Returns
    Type Description
    DenseVector

    The new DenseVector resulting from the addition.

    | Improve this Doc View Source

    Add(SparseVector, SparseVector)

    Computes the addition of two SparseVector.

    Declaration
    public static SparseVector Add(SparseVector left, SparseVector right)
    Parameters
    Type Name Description
    SparseVector left

    Left SparseVector for the addition.

    SparseVector right

    Right SparseVector for the addition.

    Returns
    Type Description
    SparseVector

    The new SparseVector resulting from the addition.

    | Improve this Doc View Source

    Add(SparseVector, Vector)

    Computes the right addition of a DenseVector with a Vector.

    Declaration
    public static Vector Add(SparseVector left, Vector right)
    Parameters
    Type Name Description
    SparseVector left

    Left DenseVector for the addition.

    Vector right

    Right Vector for the addition.

    Returns
    Type Description
    Vector

    The new DenseVector resulting from the addition.

    | Improve this Doc View Source

    Divide(SparseVector, Double)

    Computes the scalar division of a SparseVector with a number.

    Declaration
    public static SparseVector Divide(SparseVector operand, double divisor)
    Parameters
    Type Name Description
    SparseVector operand

    SparseVector to divide.

    Double divisor

    number to divide with.

    Returns
    Type Description
    SparseVector

    The new SparseVector resulting from the scalar division.

    | Improve this Doc View Source

    Equals(SparseVector)

    Class defining a sparse vector.

    Declaration
    public bool Equals(SparseVector other)
    Parameters
    Type Name Description
    SparseVector other
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    Equals(Vector)

    Class defining a sparse vector.

    Declaration
    public override bool Equals(Vector other)
    Parameters
    Type Name Description
    Vector other
    Returns
    Type Description
    Boolean
    Overrides
    Vector.Equals(Vector)
    | Improve this Doc View Source

    Equals(Object)

    Class defining a sparse vector.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj
    Returns
    Type Description
    Boolean
    Overrides
    Vector.Equals(Object)
    | Improve this Doc View Source

    GetEnumerator()

    Class defining a sparse vector.

    Declaration
    public override IEnumerator<double> GetEnumerator()
    Returns
    Type Description
    IEnumerator<Double>
    Overrides
    Vector.GetEnumerator()
    Remarks

    This method iterates over both zero and non-zero values. To iterate only on non-zero values use NonZeros().

    | Improve this Doc View Source

    GetHashCode()

    Class defining a sparse vector.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32
    Overrides
    Vector.GetHashCode()
    | Improve this Doc View Source

    GramSchmidt(IEnumerable<SparseVector>)

    Ortho-normalise the set of DenseVector using a Gram-Schimdt process.

    Declaration
    public static SparseVector[] GramSchmidt(IEnumerable<SparseVector> vectors)
    Parameters
    Type Name Description
    IEnumerable<SparseVector> vectors

    Set of DenseVector to operate on.

    Returns
    Type Description
    SparseVector[]

    The ortho-normal set of DenseVector.

    Remarks

    If the vectors are not linearly independent the number of vectors will change.

    | Improve this Doc View Source

    Multiply(SparseVector, Double)

    Computes the right scalar multiplication of a SparseVector with a number.

    Declaration
    public static SparseVector Multiply(SparseVector operand, double factor)
    Parameters
    Type Name Description
    SparseVector operand

    SparseVector to multiply on the right.

    Double factor

    number to multiply with.

    Returns
    Type Description
    SparseVector

    The new SparseVector resulting from the right scalar multiplication.

    | Improve this Doc View Source

    Multiply(Double, SparseVector)

    Computes the left scalar multiplication of a SparseVector with a number.

    Declaration
    public static SparseVector Multiply(double factor, SparseVector operand)
    Parameters
    Type Name Description
    Double factor

    number to multiply with.

    SparseVector operand

    SparseVector to multiply on the left.

    Returns
    Type Description
    SparseVector

    The new SparseVector resulting from the left scalar multiplication.

    | Improve this Doc View Source

    NonZeros()

    Returns an enumerator which reads through the non-zero components of the current SparseVector.
    The represents is composed of the row index and the component value.

    Declaration
    public IEnumerable<(int rowIndex, double value)> NonZeros()
    Returns
    Type Description
    IEnumerable<(, )<Int32, Double>>

    The enumerator of the SparseVector.

    | Improve this Doc View Source

    Opposite(SparseVector)

    Computes the opposite of the SparseVector.

    Declaration
    public static SparseVector Opposite(SparseVector operand)
    Parameters
    Type Name Description
    SparseVector operand

    SparseVector from which the opposite is computed.

    Returns
    Type Description
    SparseVector

    The SparseVector, opposite of the initial one.

    | Improve this Doc View Source

    StandardVector(Int32, Int32)

    Returns the unit SparseVector of a given size, with one at the given row index and zeros elsewhere.

    Declaration
    public static SparseVector StandardVector(int size, int index)
    Parameters
    Type Name Description
    Int32 size

    Size of the SparseVector.

    Int32 index

    Index of the standard vector, i.e of the component equal to one.

    Returns
    Type Description
    SparseVector

    The new SparseVector representing the standard vector.

    | Improve this Doc View Source

    Subtract(SparseVector, DenseVector)

    Computes the right subtraction of a SparseVector with a DenseVector.

    Declaration
    public static DenseVector Subtract(SparseVector left, DenseVector right)
    Parameters
    Type Name Description
    SparseVector left

    Left SparseVector to subtract.

    DenseVector right

    Right DenseVector to subtract with.

    Returns
    Type Description
    DenseVector

    The new DenseVector resulting from the subtraction.

    | Improve this Doc View Source

    Subtract(SparseVector, SparseVector)

    Computes the subtraction of two SparseVector.

    Declaration
    public static SparseVector Subtract(SparseVector left, SparseVector right)
    Parameters
    Type Name Description
    SparseVector left

    Left SparseVector to subtract.

    SparseVector right

    Right SparseVector to subtract with.

    Returns
    Type Description
    SparseVector

    The new SparseVector resulting from the subtraction.

    | Improve this Doc View Source

    Subtract(SparseVector, Vector)

    Computes the right subtraction of a DenseVector with a Vector.

    Declaration
    public static Vector Subtract(SparseVector left, Vector right)
    Parameters
    Type Name Description
    SparseVector left

    Left DenseVector to subtract.

    Vector right

    Right Vector to subtract with.

    Returns
    Type Description
    Vector

    The new DenseVector resulting from the subtraction.

    | Improve this Doc View Source

    ToArray()

    Translates this vector into its array representation.

    Declaration
    public override double[] ToArray()
    Returns
    Type Description
    Double[]

    The array representing the vector.

    Overrides
    Vector.ToArray()
    | Improve this Doc View Source

    ToString()

    Class defining a sparse vector.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String
    Overrides
    Vector.ToString()
    | Improve this Doc View Source

    TransposeMultiply(SparseVector, DenseVector)

    Computes the multiplication between the transposed left SparseVector and the right DenseVector.

    Declaration
    public static double TransposeMultiply(SparseVector left, DenseVector right)
    Parameters
    Type Name Description
    SparseVector left

    Left SparseVector to transpose, then multiply.

    DenseVector right

    Right DenseVector to multiply.

    Returns
    Type Description
    Double

    The scalar value resulting from the multiplication.

    | Improve this Doc View Source

    TransposeMultiply(SparseVector, SparseVector)

    Computes the multiplication between the transposed left SparseVector and the right SparseVector.

    Declaration
    public static double TransposeMultiply(SparseVector left, SparseVector right)
    Parameters
    Type Name Description
    SparseVector left

    Left SparseVector to transpose, then multiply.

    SparseVector right

    Right SparseVector to multiply.

    Returns
    Type Description
    Double

    The scalar value resulting from the multiplication.

    | Improve this Doc View Source

    TransposeMultiply(SparseVector, Vector)

    Computes the multiplication between the transposed left SparseVector and the right Vector.

    Declaration
    public static double TransposeMultiply(SparseVector left, Vector right)
    Parameters
    Type Name Description
    SparseVector left

    Left SparseVector to transpose, then multiply.

    Vector right

    Right Vector to multiply.

    Returns
    Type Description
    Double

    The scalar value resulting from the multiplication.

    | Improve this Doc View Source

    TryGetComponent(Int32, out Double)

    Gets the components at the given index.

    Declaration
    public bool TryGetComponent(int index, out double val)
    Parameters
    Type Name Description
    Int32 index

    The index of the component to get.

    Double val

    Value containing the component at the given index if it was found, zero otherwise.

    Returns
    Type Description
    Boolean

    true if the component was found, false otherwise.

    | Improve this Doc View Source

    Zero(Int32)

    Returns the neutral SparseVector for the addition.

    Declaration
    public static SparseVector Zero(int size)
    Parameters
    Type Name Description
    Int32 size

    Number of component of the SparseVector.

    Returns
    Type Description
    SparseVector

    The SparseVector of the given size and with zeros on every coordinates.

    Operators

    | Improve this Doc View Source

    Addition(SparseVector, DenseVector)

    Computes the right addition of a SparseVector with a DenseVector.

    Declaration
    public static DenseVector operator +(SparseVector left, DenseVector right)
    Parameters
    Type Name Description
    SparseVector left

    Left SparseVector for the addition.

    DenseVector right

    Right DenseVector for the addition.

    Returns
    Type Description
    DenseVector

    The new DenseVector resulting from the addition.

    | Improve this Doc View Source

    Addition(SparseVector, SparseVector)

    Computes the addition of two SparseVector.

    Declaration
    public static SparseVector operator +(SparseVector left, SparseVector right)
    Parameters
    Type Name Description
    SparseVector left

    Left SparseVector for the addition.

    SparseVector right

    Right SparseVector for the addition.

    Returns
    Type Description
    SparseVector

    The new SparseVector resulting from the addition.

    | Improve this Doc View Source

    Addition(SparseVector, Vector)

    Computes the right addition of a DenseVector with a Vector.

    Declaration
    public static Vector operator +(SparseVector left, Vector right)
    Parameters
    Type Name Description
    SparseVector left

    Left DenseVector for the addition.

    Vector right

    Right Vector for the addition.

    Returns
    Type Description
    Vector

    The new DenseVector resulting from the addition.

    | Improve this Doc View Source

    Division(SparseVector, Double)

    Computes the scalar division of a SparseVector with a number.

    Declaration
    public static SparseVector operator /(SparseVector operand, double divisor)
    Parameters
    Type Name Description
    SparseVector operand

    SparseVector to divide.

    Double divisor

    number to divide with.

    Returns
    Type Description
    SparseVector

    The new SparseVector resulting from the scalar division.

    | Improve this Doc View Source

    Equality(SparseVector, SparseVector)

    Evaluates whether two SparseVector are equal or not.

    Declaration
    public static bool operator ==(SparseVector left, SparseVector right)
    Parameters
    Type Name Description
    SparseVector left

    Left SparseVector for the comparison.

    SparseVector right

    Right SparseVector for the comparison.

    Returns
    Type Description
    Boolean

    true if the two SparseVector are equal, false otherwise.

    | Improve this Doc View Source

    Inequality(SparseVector, SparseVector)

    Evaluates whether two SparseVector are different.

    Declaration
    public static bool operator !=(SparseVector left, SparseVector right)
    Parameters
    Type Name Description
    SparseVector left

    Left SparseVector for the comparison.

    SparseVector right

    Right SparseVector for the comparison.

    Returns
    Type Description
    Boolean

    true if the two SparseVector are different, false otherwise.

    | Improve this Doc View Source

    Multiply(SparseVector, Double)

    Computes the right scalar multiplication of a SparseVector with a number.

    Declaration
    public static SparseVector operator *(SparseVector operand, double factor)
    Parameters
    Type Name Description
    SparseVector operand

    SparseVector to multiply on the right.

    Double factor

    number to multiply with.

    Returns
    Type Description
    SparseVector

    The new SparseVector resulting from the right scalar multiplication.

    | Improve this Doc View Source

    Multiply(Double, SparseVector)

    Computes the left scalar multiplication of a SparseVector with a number.

    Declaration
    public static SparseVector operator *(double factor, SparseVector operand)
    Parameters
    Type Name Description
    Double factor

    number to multiply with.

    SparseVector operand

    SparseVector to multiply on the left.

    Returns
    Type Description
    SparseVector

    The new SparseVector resulting from the left scalar multiplication.

    | Improve this Doc View Source

    Subtraction(SparseVector, DenseVector)

    Computes the right subtraction of a SparseVector with a DenseVector.

    Declaration
    public static DenseVector operator -(SparseVector left, DenseVector right)
    Parameters
    Type Name Description
    SparseVector left

    Left SparseVector to subtract.

    DenseVector right

    Right DenseVector to subtract with.

    Returns
    Type Description
    DenseVector

    The new DenseVector resulting from the subtraction.

    | Improve this Doc View Source

    Subtraction(SparseVector, SparseVector)

    Computes the subtraction of two SparseVector.

    Declaration
    public static SparseVector operator -(SparseVector left, SparseVector right)
    Parameters
    Type Name Description
    SparseVector left

    Left SparseVector to subtract.

    SparseVector right

    Right SparseVector to subtract with.

    Returns
    Type Description
    SparseVector

    The new SparseVector resulting from the subtraction.

    | Improve this Doc View Source

    Subtraction(SparseVector, Vector)

    Computes the right subtraction of a DenseVector with a Vector.

    Declaration
    public static Vector operator -(SparseVector left, Vector right)
    Parameters
    Type Name Description
    SparseVector left

    Left DenseVector to subtract.

    Vector right

    Right Vector to subtract with.

    Returns
    Type Description
    Vector

    The new DenseVector resulting from the subtraction.

    | Improve this Doc View Source

    UnaryNegation(SparseVector)

    Computes the opposite of the SparseVector.

    Declaration
    public static SparseVector operator -(SparseVector operand)
    Parameters
    Type Name Description
    SparseVector operand

    SparseVector from which the opposite is computed.

    Returns
    Type Description
    SparseVector

    The SparseVector, opposite of the initial one.

    Explicit Interface Implementations

    | Improve this Doc View Source

    IDotProduct<SparseVector, Double>.DotProduct(SparseVector)

    Computes the dot product of this element with another element.

    Declaration
    double IDotProduct<SparseVector, double>.DotProduct(SparseVector other)
    Parameters
    Type Name Description
    SparseVector other
    Returns
    Type Description
    Double

    The value of the dot product of the two elements.

    | Improve this Doc View Source

    IMetric<SparseVector>.DistanceTo(SparseVector)

    Computes the distance of this element to another element.

    Declaration
    double IMetric<SparseVector>.DistanceTo(SparseVector other)
    Parameters
    Type Name Description
    SparseVector other
    Returns
    Type Description
    Double

    The value of the distance between the two elements.

    | Improve this Doc View Source

    IGroupAction<SparseVector, Double>.Divide(Double)

    Computes the right scalar division of the current element.

    Declaration
    SparseVector IGroupAction<SparseVector, double>.Divide(double divisor)
    Parameters
    Type Name Description
    Double divisor
    Returns
    Type Description
    SparseVector

    The new element resulting from the scalar dividion.

    | Improve this Doc View Source

    IGroupAction<SparseVector, Double>.Multiply(Double)

    Computes the right scalar multiplication of the current element.

    Declaration
    SparseVector IGroupAction<SparseVector, double>.Multiply(double factor)
    Parameters
    Type Name Description
    Double factor
    Returns
    Type Description
    SparseVector

    The new element resulting from the scalar multiplication.

    Implements

    IDotProduct<TSelf, TValue>
    INorm<TSelf>
    IMetric<TSelf>
    IGroupAction<TSelf, TValue>
    IEquatable<>
    IEnumerable<>
    IDotProduct<TSelf, TValue>
    INorm<TSelf>
    IMetric<TSelf>
    IGroupAction<TSelf, TValue>
    • Improve this Doc
    • View Source
    In This Article
    Back to top By ENPC and the Build'In Platform