Search Results for

    Show / Hide Table of Contents

    Class PiecewiseVector

    A one-dimensional vector of double values, optimised for the case where many contiguous ranges of elements have the same value.

    Inheritance
    Object
    Vector
    PiecewiseVector
    Implements
    IReadOnlyList<Double>
    IReadOnlyCollection<Double>
    SettableToPower<Vector>
    SettableToProduct<Vector>
    SettableToProduct<Vector, Vector>
    SettableToWeightedSum<Vector>
    IList<Double>
    ICollection<Double>
    IEnumerable<Double>
    IEnumerable
    ICloneable
    CanSetAllElementsTo<Double>
    SettableTo<Vector>
    Inherited Members
    Vector.Sparsity
    Vector.IsDense
    Vector.IsSparse
    Vector.IsApproximate
    Vector.IsExact
    Vector.Zero(Int32, Sparsity)
    Vector.Constant(Int32, Double, Sparsity)
    Vector.Copy(Vector, Sparsity)
    Vector.FromArray(Double[], Sparsity)
    Vector.FromArray(Int32, Double[], Int32)
    Vector.FromList(IList<Double>)
    Vector.FromArray(Int32, Double[], Int32, Sparsity)
    Vector.IList<Double>.Insert(Int32, Double)
    Vector.IList<Double>.RemoveAt(Int32)
    Vector.IsReadOnly
    Vector.ICollection<Double>.Add(Double)
    Vector.ICollection<Double>.Clear()
    Vector.ICollection<Double>.Remove(Double)
    Vector.CheckCompatible(Vector, String)
    Vector.IndexOfAll(Converter<Double, Boolean>)
    Vector.Reduce(Double, Vector, Vector, Func<Double, Double, Double, Double, Double>)
    Vector.Median()
    Vector.Outer(Vector)
    Vector.SetToPower(Vector, Double)
    Vector.SetToProduct(Vector, Vector)
    Vector.SetToSum(Double, Vector, Double, Vector)
    Vector.SetToSum(Vector, Vector)
    Vector.SetToSum(Vector, Double)
    Vector.SetToDifference(Vector, Vector)
    Vector.SetToDifference(Vector, Double)
    Vector.SetToDifference(Double, Vector)
    Vector.SetToProduct(Vector, Double)
    Vector.SetToProduct(Vector, Matrix)
    Vector.SetToProduct(Matrix, Vector)
    Vector.SetToRatio(Vector, Vector)
    Vector.InnerProduct(Vector, Vector)
    Vector.EqualsAll(Double)
    Vector.GreaterThan(Double)
    Vector.LessThan(Double)
    Vector.GreaterThanOrEqual(Double)
    Vector.LessThanOrEqual(Double)
    Vector.PredivideBy(UpperTriangularMatrix)
    Vector.PredivideByTranspose(LowerTriangularMatrix)
    Vector.PredivideBy(LowerTriangularMatrix)
    Vector.EnsureDense(Vector)
    Vector.PredivideBy(PositiveDefiniteMatrix)
    Vector.Concat(Vector, Vector)
    Vector.Subvector(Vector, Int32, Int32)
    Vector.SetToSubarray(Double[], Int32)
    Vector.SetSubvector(Int32, Vector)
    Vector.ToString()
    Object.Equals(Object, Object)
    Object.GetType()
    Object.MemberwiseClone()
    Object.ReferenceEquals(Object, Object)
    Namespace: Microsoft.ML.Probabilistic.Math
    Assembly: Microsoft.ML.Probabilistic.dll
    Syntax
    [Serializable]
    [DataContract]
    public class PiecewiseVector : Vector, IReadOnlyList<double>, IReadOnlyCollection<double>, SettableToPower<Vector>, SettableToProduct<Vector>, SettableToProduct<Vector, Vector>, SettableToWeightedSum<Vector>, IList<double>, ICollection<double>, IEnumerable<double>, IEnumerable, ICloneable, CanSetAllElementsTo<double>, SettableTo<Vector>

    Constructors

    PiecewiseVector()

    Constructs a zero vector with the given number of elements.

    Declaration
    protected PiecewiseVector()

    PiecewiseVector(PiecewiseVector)

    Copy constructor.

    Declaration
    protected PiecewiseVector(PiecewiseVector that)
    Parameters
    Type Name Description
    PiecewiseVector that

    the vector to copy into this new vector

    PiecewiseVector(IList<Double>)

    Creates a piecewise vector from a list of doubles.

    Declaration
    protected PiecewiseVector(IList<double> dlist)
    Parameters
    Type Name Description
    IList<Double> dlist

    the list of doubles

    PiecewiseVector(Int32)

    Constructs a zero vector with the given number of elements.

    Declaration
    protected PiecewiseVector(int count)
    Parameters
    Type Name Description
    Int32 count

    Number of elements to allocate (>= 0).

    PiecewiseVector(Int32, Double)

    Constructs a vector of a given length and assigns all elements the given value.

    Declaration
    protected PiecewiseVector(int count, double commonValue)
    Parameters
    Type Name Description
    Int32 count

    Number of elements to allocate (>= 0).

    Double commonValue

    The value to assign to all elements.

    PiecewiseVector(Int32, Double, List<ConstantVector>)

    Constructs a vector of a given length and assigns all elements the given value, except for the specified list of vectors. This list is stored internally as is so MUST be sorted by index and must not be modified externally.

    Declaration
    protected PiecewiseVector(int count, double commonValue, List<ConstantVector> sortedVectors)
    Parameters
    Type Name Description
    Int32 count

    Number of elements to allocate (>= 0).

    Double commonValue

    The value to assign to all elements.

    List<ConstantVector> sortedVectors

    The list of vectors, which must be disjoint and sorted by index.

    Properties

    CommonValue

    The value of all elements which are not in any of the vector pieces.

    Declaration
    [DataMember]
    public double CommonValue { get; protected set; }
    Property Value
    Type Description
    Double

    Count

    The number of elements in this vector

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

    Item[Int32]

    Gets and sets an element.

    Declaration
    public override double this[int index] { get; set; }
    Parameters
    Type Name Description
    Int32 index
    Property Value
    Type Description
    Double
    Overrides
    Vector.Item[Int32]

    Pieces

    A list of the pieces of this vector.

    Declaration
    public List<ConstantVector> Pieces { get; }
    Property Value
    Type Description
    List<ConstantVector>

    Methods

    All(Converter<Double, Boolean>)

    Tests if all elements in the vector satisfy the specified condition.

    Declaration
    public override bool All(Converter<double, bool> fun)
    Parameters
    Type Name Description
    Converter<Double, Boolean> fun

    The condition for the elements to satisfy.

    Returns
    Type Description
    Boolean

    True if all elements satisfy the condition, false otherwise.

    Overrides
    Vector.All(Converter<Double, Boolean>)

    Any(PiecewiseVector, Func<Double, Double, Boolean>)

    Declaration
    public bool Any(PiecewiseVector that, Func<double, double, bool> fun)
    Parameters
    Type Name Description
    PiecewiseVector that
    Func<Double, Double, Boolean> fun
    Returns
    Type Description
    Boolean

    Any(Vector, Func<Double, Double, Boolean>)

    Declaration
    public override bool Any(Vector that, Func<double, double, bool> fun)
    Parameters
    Type Name Description
    Vector that
    Func<Double, Double, Boolean> fun
    Returns
    Type Description
    Boolean
    Overrides
    Vector.Any(Vector, Func<Double, Double, Boolean>)

    Any(Converter<Double, Boolean>)

    Tests if any elements in the vector satisfy the specified condition.

    Declaration
    public override bool Any(Converter<double, bool> fun)
    Parameters
    Type Name Description
    Converter<Double, Boolean> fun

    The condition for the elements to satisfy.

    Returns
    Type Description
    Boolean

    True if any elements satisfy the condition, false otherwise.

    Overrides
    Vector.Any(Converter<Double, Boolean>)

    Append(Vector)

    Returns a new vector which appends a second vector to this vector

    Declaration
    public override Vector Append(Vector second)
    Parameters
    Type Name Description
    Vector second

    Second vector

    Returns
    Type Description
    Vector
    Overrides
    Vector.Append(Vector)
    Remarks

    If the second vector is dense then the result becomes dense

    Append(Double)

    Appends an item to a vector - returns a new piecewise vector

    Declaration
    public override Vector Append(double item)
    Parameters
    Type Name Description
    Double item
    Returns
    Type Description
    Vector
    Overrides
    Vector.Append(Double)

    ApplyRangeFunction(PiecewiseVector, PiecewiseVector.RangeFunc)

    Applies a function to ranges in common between this vector and another and returns the number of elements with common values in both vectors.

    Declaration
    protected int ApplyRangeFunction(PiecewiseVector b, PiecewiseVector.RangeFunc func)
    Parameters
    Type Name Description
    PiecewiseVector b
    PiecewiseVector.RangeFunc func
    Returns
    Type Description
    Int32

    Clone()

    Clones this vector - return as a vector

    Declaration
    public override Vector Clone()
    Returns
    Type Description
    Vector
    Overrides
    Vector.Clone()

    Constant(Int32, Double)

    Create a piecewise vector of given length with elements all equal to a specified value

    Declaration
    public static PiecewiseVector Constant(int count, double value)
    Parameters
    Type Name Description
    Int32 count

    Number of elements in vector

    Double value

    value for each element

    Returns
    Type Description
    PiecewiseVector

    Contains(Double)

    Returns true if the Vector contains the specified value

    Declaration
    public override bool Contains(double value)
    Parameters
    Type Name Description
    Double value

    The value to test for

    Returns
    Type Description
    Boolean
    Overrides
    Vector.Contains(Double)

    Copy(Vector)

    Creator a piecewise vector as a copy of another vector (of any type)

    Declaration
    public static PiecewiseVector Copy(Vector that)
    Parameters
    Type Name Description
    Vector that

    The source vector - can be dense or sparse

    Returns
    Type Description
    PiecewiseVector

    CopyTo(Double[], Int32)

    Copies this vector to the given array starting at the specified index in the target array

    Declaration
    public override void CopyTo(double[] array, int index)
    Parameters
    Type Name Description
    Double[] array

    The target array

    Int32 index

    The start index in the target array

    Overrides
    Vector.CopyTo(Double[], Int32)

    CountAll(Converter<Double, Boolean>)

    Returns the number of elements in the vector which satisfy a given condition.

    Declaration
    public override int CountAll(Converter<double, bool> fun)
    Parameters
    Type Name Description
    Converter<Double, Boolean> fun

    The condition for the elements to satisfy.

    Returns
    Type Description
    Int32

    The number of elements in the vector which satisfy the condition.

    Overrides
    Vector.CountAll(Converter<Double, Boolean>)

    Equals(Object)

    Determines object equality.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    Object obj

    Another (vector) object.

    Returns
    Type Description
    Boolean

    True if equal.

    Overrides
    Vector.Equals(Object)

    FindAll(Converter<Double, Boolean>)

    Returns an enumeration over the indices and values of all the elements which satisfy the specified condition. Indices are returned in sorted order.

    Declaration
    public override IEnumerable<ValueAtIndex<double>> FindAll(Converter<double, bool> fun)
    Parameters
    Type Name Description
    Converter<Double, Boolean> fun

    A function to check if the condition is satisfied.

    Returns
    Type Description
    IEnumerable<ValueAtIndex<Double>>

    An enumeration over the indices and values of all the elements which satisfy the specified condition.

    Overrides
    Vector.FindAll(Converter<Double, Boolean>)

    FindFirstIndex(Converter<Double, Boolean>)

    Returns the index of the first element that satisfies a given condition.

    Declaration
    public override int FindFirstIndex(Converter<double, bool> fun)
    Parameters
    Type Name Description
    Converter<Double, Boolean> fun

    The condition for the element to satisfy.

    Returns
    Type Description
    Int32

    The zero-based index of the first occurrence of an element that matches the conditions defined by match, if found; otherwise, –1.

    Overrides
    Vector.FindFirstIndex(Converter<Double, Boolean>)

    FindLastIndex(Converter<Double, Boolean>)

    Returns the index of the last element that satisfies a given condition.

    Declaration
    public override int FindLastIndex(Converter<double, bool> fun)
    Parameters
    Type Name Description
    Converter<Double, Boolean> fun

    The condition for the element to satisfy.

    Returns
    Type Description
    Int32

    The last index.

    Overrides
    Vector.FindLastIndex(Converter<Double, Boolean>)

    FromArray(Double[])

    Constructs a piecewise vector from a dense array.

    Declaration
    public static PiecewiseVector FromArray(params double[] data)
    Parameters
    Type Name Description
    Double[] data

    1D array of elements.

    Returns
    Type Description
    PiecewiseVector
    Remarks

    The array data is copied into new storage. The size of the vector is taken from the array.

    FromSubvectors(Int32, Double, List<ConstantVector>)

    Constructs a piecewise vector from a sorted list of subvectors, which will be used directly and not copied.

    Declaration
    [Construction(new string[]{"Count", "CommonValue", "Pieces"})]
    public static PiecewiseVector FromSubvectors(int count, double commonValue, List<ConstantVector> sortedDisjointVectors)
    Parameters
    Type Name Description
    Int32 count

    Count for result

    Double commonValue

    Common value

    List<ConstantVector> sortedDisjointVectors

    Sorted list of disjoint subvectors

    Returns
    Type Description
    PiecewiseVector

    GetCommonValueCount()

    Gets the number of elements that don't belong to any subvector and so take the common value.

    Declaration
    protected int GetCommonValueCount()
    Returns
    Type Description
    Int32

    GetEnumerator()

    Gets a typed enumerator which yields the vector elements

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

    GetFirstCommonIndex()

    Gets the dense index of the first common element.

    Declaration
    public int GetFirstCommonIndex()
    Returns
    Type Description
    Int32

    Returns the dense index of the first common element or -1 if there are no common elements

    GetHashCode()

    Gets a hash code for the instance.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32

    The code.

    Overrides
    Vector.GetHashCode()

    GetSubvector(Int32)

    Gets the subvector that contains the specified index, or null if none.

    Declaration
    protected ConstantVector? GetSubvector(int index)
    Parameters
    Type Name Description
    Int32 index
    Returns
    Type Description
    Nullable<ConstantVector>

    GreaterThan(Vector)

    Tests if this vector is strictly greater than a second vector.

    Declaration
    public override bool GreaterThan(Vector that)
    Parameters
    Type Name Description
    Vector that

    The value to test against.

    Returns
    Type Description
    Boolean

    True if each element is strictly greater than the corresponding element of that.

    Overrides
    Vector.GreaterThan(Vector)

    GreaterThanOrEqual(Vector)

    Tests if this vector is than or equal to a second vector.

    Declaration
    public override bool GreaterThanOrEqual(Vector that)
    Parameters
    Type Name Description
    Vector that

    The value to test against.

    Returns
    Type Description
    Boolean

    True if each element is greater than or equal to the corresponding element of that.

    Overrides
    Vector.GreaterThanOrEqual(Vector)

    HasCommonElements()

    Gets whether there are any elements that don't belong to a subvector and so take the common value.

    Declaration
    public bool HasCommonElements()
    Returns
    Type Description
    Boolean

    IndexAtCumulativeSum(Double)

    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.

    Declaration
    public override int IndexAtCumulativeSum(double targetSum)
    Parameters
    Type Name Description
    Double targetSum

    The sum of interest

    Returns
    Type Description
    Int32

    The index of the element where targetSum is exceeded or -1 if targetSum cannot be exceeded.

    Overrides
    Vector.IndexAtCumulativeSum(Double)

    IndexOf(Double)

    Returns the index of the first occurence of the given value in the array. Returns -1 if the value is not in the array

    Declaration
    public override int IndexOf(double item)
    Parameters
    Type Name Description
    Double item

    The item to check for

    Returns
    Type Description
    Int32

    Its index in the array

    Overrides
    Vector.IndexOf(Double)

    IndexOfMaximum()

    Returns the index of the maximum element.

    Declaration
    public override int IndexOfMaximum()
    Returns
    Type Description
    Int32

    The index of the maximum element.

    Overrides
    Vector.IndexOfMaximum()

    IndexOfMinimum()

    Returns the index of the minimum element.

    Declaration
    public override int IndexOfMinimum()
    Returns
    Type Description
    Int32

    The index of the minimum element.

    Overrides
    Vector.IndexOfMinimum()

    Inner(PiecewiseVector)

    Returns the inner product of this piecewise vector with another piecewise vector.

    Declaration
    public double Inner(PiecewiseVector that)
    Parameters
    Type Name Description
    PiecewiseVector that

    Second vector, which must have the same size as this.

    Returns
    Type Description
    Double

    Their inner product.

    Inner(PiecewiseVector, Converter<Double, Double>)

    Returns the inner product of this piecewise vector with a function of a second piecewise vector.

    Declaration
    public double Inner(PiecewiseVector that, Converter<double, double> fun)
    Parameters
    Type Name Description
    PiecewiseVector that

    Second vector, which must have the same size as this.

    Converter<Double, Double> fun

    Function to convert the elements of the second vector

    Returns
    Type Description
    Double

    Their inner product.

    Inner(Vector)

    Returns the inner product of this vector with another vector.

    Declaration
    public override double Inner(Vector that)
    Parameters
    Type Name Description
    Vector that

    Second vector, which must have the same size as this.

    Returns
    Type Description
    Double

    Their inner product.

    Overrides
    Vector.Inner(Vector)

    Inner(Vector, Converter<Double, Double>)

    Returns the inner product of this vector with a function of a second vector.

    Declaration
    public override double Inner(Vector that, Converter<double, double> fun)
    Parameters
    Type Name Description
    Vector that

    Second vector, which must have the same size as this.

    Converter<Double, Double> fun

    Function to convert the elements of the second vector

    Returns
    Type Description
    Double

    Their inner product.

    Overrides
    Vector.Inner(Vector, Converter<Double, Double>)

    Inner(Converter<Double, Double>, PiecewiseVector, Converter<Double, Double>)

    Returns the inner product of a function of this piecewise vector with a function of a second piecewise vector.

    Declaration
    public double Inner(Converter<double, double> thisFun, PiecewiseVector that, Converter<double, double> thatFun)
    Parameters
    Type Name Description
    Converter<Double, Double> thisFun

    Function to convert the elements of this vector

    PiecewiseVector that

    Second vector, which must have the same size as this.

    Converter<Double, Double> thatFun

    Function to convert the elements of that vector

    Returns
    Type Description
    Double

    Their inner product.

    Inner(Converter<Double, Double>, Vector, Converter<Double, Double>)

    Returns the inner product of a function of this vector with a function of a second vector.

    Declaration
    public override double Inner(Converter<double, double> thisFun, Vector that, Converter<double, double> thatFun)
    Parameters
    Type Name Description
    Converter<Double, Double> thisFun

    Function to convert the elements of this vector

    Vector that

    Second vector, which must have the same size as this.

    Converter<Double, Double> thatFun

    Function to convert the elements of that vector

    Returns
    Type Description
    Double

    Their inner product.

    Overrides
    Vector.Inner(Converter<Double, Double>, Vector, Converter<Double, Double>)

    LessThan(Vector)

    Tests if this vector is strictly less than a second vector.

    Declaration
    public override bool LessThan(Vector that)
    Parameters
    Type Name Description
    Vector that

    The value to test against.

    Returns
    Type Description
    Boolean

    True if each element is strictly less than the corresponding element of that.

    Overrides
    Vector.LessThan(Vector)

    LessThanOrEqual(Vector)

    Tests if this vector is less than or equal to a second vector.

    Declaration
    public override bool LessThanOrEqual(Vector that)
    Parameters
    Type Name Description
    Vector that

    The value to test against.

    Returns
    Type Description
    Boolean

    True if each element is strictly less than or equal to the corresponding element of that.

    Overrides
    Vector.LessThanOrEqual(Vector)

    LogSumExp()

    Returns the log of the sum of exponentials of the elements of the vector computed to high accuracy

    Declaration
    public override double LogSumExp()
    Returns
    Type Description
    Double
    Overrides
    Vector.LogSumExp()

    Max()

    Returns the maximum of the elements in the vector

    Declaration
    public override double Max()
    Returns
    Type Description
    Double
    Overrides
    Vector.Max()

    Max(Converter<Double, Double>)

    Returns the maximum of a function of the elements in the vector

    Declaration
    public override double Max(Converter<double, double> fun)
    Parameters
    Type Name Description
    Converter<Double, Double> fun

    Conversion function

    Returns
    Type Description
    Double
    Overrides
    Vector.Max(Converter<Double, Double>)

    MaxDiff(Vector)

    Returns the maximum absolute difference between this vector and another vector.

    Declaration
    public override double MaxDiff(Vector that)
    Parameters
    Type Name Description
    Vector that

    The second vector.

    Returns
    Type Description
    Double

    max(abs(this[i] - that[i])). Matching infinities or NaNs do not count.
    If this and that are not the same size, returns infinity.

    Overrides
    Vector.MaxDiff(Vector)
    Remarks

    This routine is typically used instead of Equals, since Equals is susceptible to roundoff errors.

    MaxDiff(Vector, Double)

    Returns the maximum relative difference between this vector and another.

    Declaration
    public override double MaxDiff(Vector that, double rel)
    Parameters
    Type Name Description
    Vector that

    The second vector.

    Double rel

    An offset to avoid division by zero.

    Returns
    Type Description
    Double

    max(abs(this[i] - that[i])/(abs(this[i]) + rel)). Matching infinities or NaNs do not count.
    If this and that are not the same size, returns infinity.

    Overrides
    Vector.MaxDiff(Vector, Double)
    Remarks

    This routine is typically used instead of Equals, since Equals is susceptible to roundoff errors.

    Min()

    Returns the minimum of the elements in the vector

    Declaration
    public override double Min()
    Returns
    Type Description
    Double
    Overrides
    Vector.Min()

    Min(Converter<Double, Double>)

    Returns the minimum of the elements in the vector

    Declaration
    public override double Min(Converter<double, double> fun)
    Parameters
    Type Name Description
    Converter<Double, Double> fun

    Conversion function

    Returns
    Type Description
    Double
    Overrides
    Vector.Min(Converter<Double, Double>)

    Reduce(Double, PiecewiseVector, Func<Double, Double, Double, Double>)

    Reduce method. Operates on this vector and that vector

    Declaration
    public double Reduce(double initial, PiecewiseVector that, Func<double, double, double, double> fun)
    Parameters
    Type Name Description
    Double initial

    Initial value

    PiecewiseVector that

    A second vector

    Func<Double, Double, Double, Double> fun

    Reduction function taking partial result, current element, and current element of that

    Returns
    Type Description
    Double

    Reduce(Double, Vector, Func<Double, Double, Double, Double>)

    Reduce method. Operates on this vector and that vector

    Declaration
    public override double Reduce(double initial, Vector that, Func<double, double, double, double> fun)
    Parameters
    Type Name Description
    Double initial

    Initial value

    Vector that

    A second vector

    Func<Double, Double, Double, Double> fun

    Reduction function taking partial result, current element, and current element of that

    Returns
    Type Description
    Double
    Overrides
    Vector.Reduce(Double, Vector, Func<Double, Double, Double, Double>)

    Reduce(Double, Func<Double, Double, Double>)

    Reduce method. Operates on this vector

    Declaration
    public override double Reduce(double initial, Func<double, double, double> fun)
    Parameters
    Type Name Description
    Double initial

    Initial value

    Func<Double, Double, Double> fun

    Reduction function taking partial result and current element

    Returns
    Type Description
    Double
    Overrides
    Vector.Reduce(Double, Func<Double, Double, Double>)

    Reduce<TRes>(TRes, Func<TRes, Double, Int32, TRes>)

    Reduce method which can take advantage of piecewise structure. Operates on this list

    Declaration
    public TRes Reduce<TRes>(TRes initial, Func<TRes, double, int, TRes> repeatedFun)
    Parameters
    Type Name Description
    TRes initial

    Initial value

    Func<TRes, Double, Int32, TRes> repeatedFun

    Function which computes the reduction function applied multiple times

    Returns
    Type Description
    TRes
    Type Parameters
    Name Description
    TRes
    Remarks

    This method does not take advantage of this list's sparseness.

    Scale(Double)

    Multiplies this vector by a scalar.

    Declaration
    public override void Scale(double scale)
    Parameters
    Type Name Description
    Double scale

    The scalar.

    Overrides
    Vector.Scale(Double)
    Remarks

    this receives the product. This method is a synonym for SetToProduct(this, scale)

    SetAllElementsTo(Double)

    Sets all elements to a given value.

    Declaration
    public override void SetAllElementsTo(double value)
    Parameters
    Type Name Description
    Double value

    The new value.

    Overrides
    Vector.SetAllElementsTo(Double)

    SetTo(PiecewiseVector)

    Copies values from a piecewise vector to this piecewise vector.

    Declaration
    public virtual void SetTo(PiecewiseVector that)
    Parameters
    Type Name Description
    PiecewiseVector that

    SetTo(Vector)

    Copies values from a Vector to this vector.

    Declaration
    public override void SetTo(Vector that)
    Parameters
    Type Name Description
    Vector that
    Overrides
    Vector.SetTo(Vector)
    Remarks

    The source vector can be dense, in which case the minimum value is used as the common value.

    SetTo(IEnumerable<Double>)

    Copies values from an Enumerable to this vector

    Declaration
    public override void SetTo(IEnumerable<double> that)
    Parameters
    Type Name Description
    IEnumerable<Double> that
    Overrides
    Vector.SetTo(IEnumerable<Double>)

    SetTo(IList<Double>)

    Copies values from a list of doubles which must have the same size as this vector. The 'common value' is set to the minimum value of the list.

    Declaration
    public virtual void SetTo(IList<double> dlist)
    Parameters
    Type Name Description
    IList<Double> dlist

    SetTo(IList<Double>, Double)

    Copies values from a list of doubles which must have the same size as this vector, using the specified common value.

    Declaration
    public virtual void SetTo(IList<double> dlist, double commonValue)
    Parameters
    Type Name Description
    IList<Double> dlist

    List of doubles

    Double commonValue

    Common value

    SetTo(Double[])

    Copies values from an array. The minimum value is used as the common value

    Declaration
    public override void SetTo(double[] values)
    Parameters
    Type Name Description
    Double[] values

    An array whose length matches this.Count.

    Overrides
    Vector.SetTo(Double[])

    SetToConstantInRange(Int32, Int32, Double)

    Sets the vector to a constant value between the specified start and end indices inclusive (and zero elsewhere).

    Declaration
    public void SetToConstantInRange(int start, int end, double value)
    Parameters
    Type Name Description
    Int32 start

    The start index

    Int32 end

    The end index

    Double value

    The constant value

    SetToConstantInRanges(IEnumerable<Int32>, Double)

    Sets the vector to a constant value in multiple ranges (and zero elsewhere). The start and end points of the ranges are specified as consecutive pairs in a single enumerable which must therefore have even length.

    Declaration
    public void SetToConstantInRanges(IEnumerable<int> startEndPairs, double value)
    Parameters
    Type Name Description
    IEnumerable<Int32> startEndPairs

    Enumerable containing pairs of start and end values

    Double value

    SetToDiagonal(Matrix)

    Sets this vector to the diagonal of a matrix.

    Declaration
    public override void SetToDiagonal(Matrix m)
    Parameters
    Type Name Description
    Matrix m

    A matrix with Rows==Cols==this.Count.

    Overrides
    Vector.SetToDiagonal(Matrix)

    SetToFunction(PiecewiseVector, PiecewiseVector, Func<Double, Double, Double>)

    Sets the elements of this piecewise vector to a function of the elements of two other piecewise vectors

    Declaration
    public virtual PiecewiseVector SetToFunction(PiecewiseVector a, PiecewiseVector b, Func<double, double, double> fun)
    Parameters
    Type Name Description
    PiecewiseVector a

    The first vector

    PiecewiseVector b

    The second vector

    Func<Double, Double, Double> fun

    The function which maps two doubles to a double

    Returns
    Type Description
    PiecewiseVector
    Remarks

    Assumes the vectors are compatible

    SetToFunction(PiecewiseVector, Converter<Double, Double>)

    Sets the elements of this piecewise vector to a function of the elements of another piecewise vector

    Declaration
    public virtual PiecewiseVector SetToFunction(PiecewiseVector that, Converter<double, double> fun)
    Parameters
    Type Name Description
    PiecewiseVector that

    The other vector

    Converter<Double, Double> fun

    The function which maps doubles to doubles

    Returns
    Type Description
    PiecewiseVector
    Remarks

    Assumes the vectors are compatible

    SetToFunction(Vector, Vector, Func<Double, Double, Double>)

    Sets the elements of this vector to a function of the elements of two vectors

    Declaration
    public override Vector SetToFunction(Vector a, Vector b, Func<double, double, double> fun)
    Parameters
    Type Name Description
    Vector a

    The first vector

    Vector b

    The second vector

    Func<Double, Double, Double> fun

    The function which maps two doubles to a double

    Returns
    Type Description
    Vector
    Overrides
    Vector.SetToFunction(Vector, Vector, Func<Double, Double, Double>)
    Remarks

    Assumes the vectors are compatible

    SetToFunction(Vector, Converter<Double, Double>)

    Sets the elements of this vector to a function of the elements of a given vector

    Declaration
    public override Vector SetToFunction(Vector that, Converter<double, double> fun)
    Parameters
    Type Name Description
    Vector that

    The given vector

    Converter<Double, Double> fun

    The function which maps doubles to doubles

    Returns
    Type Description
    Vector
    Overrides
    Vector.SetToFunction(Vector, Converter<Double, Double>)
    Remarks

    Assumes the vectors are compatible

    SetToFunctionInPlace(PiecewiseVector, Func<Double, Double, Double>)

    Sets the elements of this piecewise vector to a function of the elements of this piecewise vector and another piecewise vectors x = fun(x,b)

    Declaration
    public virtual PiecewiseVector SetToFunctionInPlace(PiecewiseVector b, Func<double, double, double> fun)
    Parameters
    Type Name Description
    PiecewiseVector b

    The second vector

    Func<Double, Double, Double> fun

    The function which maps two doubles to a double

    Returns
    Type Description
    PiecewiseVector
    Remarks

    Assumes the vectors are compatible

    SetToSubvector(PiecewiseVector, Int32)

    Copies values from a piecewise vector. The common value is set to the common value from the source vector.

    Declaration
    public virtual void SetToSubvector(PiecewiseVector that, int startIndex)
    Parameters
    Type Name Description
    PiecewiseVector that

    A vector whose length is at least this.Count + startIndex.

    Int32 startIndex

    The index of the first value in that to copy.

    SetToSubvector(Vector, Int32)

    Copies values from a vector. If the source vector is piecewise, then the common value is set to the common value from the source vector. If the source vector is dense, then the common value is set to the minimum of the data in the source vector

    Declaration
    public override void SetToSubvector(Vector that, int startIndex)
    Parameters
    Type Name Description
    Vector that

    A vector whose length is at least this.Count + startIndex.

    Int32 startIndex

    The index of the first value in that to copy.

    Overrides
    Vector.SetToSubvector(Vector, Int32)

    Subvector(Int32, Int32)

    Create a subvector of this piecewise vector.

    Declaration
    public override Vector Subvector(int startIndex, int count)
    Parameters
    Type Name Description
    Int32 startIndex
    Int32 count
    Returns
    Type Description
    Vector
    Overrides
    Vector.Subvector(Int32, Int32)

    Sum()

    Returns the sum of all elements.

    Declaration
    public override double Sum()
    Returns
    Type Description
    Double
    Overrides
    Vector.Sum()

    Sum(Converter<Double, Double>)

    Returns the sum of a function of all elements.

    Declaration
    public override double Sum(Converter<double, double> fun)
    Parameters
    Type Name Description
    Converter<Double, Double> fun

    Conversion function

    Returns
    Type Description
    Double
    Overrides
    Vector.Sum(Converter<Double, Double>)

    Sum(Converter<Double, Double>, PiecewiseVector, Converter<Double, Boolean>)

    Returns the sum of a function of this piecewise vector filtered by a function of a second piecewise vector.

    Declaration
    public double Sum(Converter<double, double> fun, PiecewiseVector that, Converter<double, bool> cond)
    Parameters
    Type Name Description
    Converter<Double, Double> fun

    Function to convert the elements of this vector

    PiecewiseVector that

    Second vector, which must have the same size as this.

    Converter<Double, Boolean> cond

    Function to convert the elements of that vector to give the filter condition

    Returns
    Type Description
    Double

    The filtered and mapped sum

    Sum(Converter<Double, Double>, Vector, Converter<Double, Boolean>)

    Returns the sum of a function of this vector filtered by a function of a second vector.

    Declaration
    public override double Sum(Converter<double, double> fun, Vector that, Converter<double, bool> cond)
    Parameters
    Type Name Description
    Converter<Double, Double> fun

    Function to convert the elements of this vector

    Vector that

    Second vector, which must have the same size as this.

    Converter<Double, Boolean> cond

    Function to convert the elements of that vector to give the filter condition

    Returns
    Type Description
    Double

    The filtered and mapped sum

    Overrides
    Vector.Sum(Converter<Double, Double>, Vector, Converter<Double, Boolean>)

    SumI()

    Returns the sum of over zero-based index times element.

    Declaration
    public override double SumI()
    Returns
    Type Description
    Double
    Overrides
    Vector.SumI()

    SumISq()

    Returns the sum of over square of index^2 times element.

    Declaration
    public override double SumISq()
    Returns
    Type Description
    Double
    Overrides
    Vector.SumISq()

    ToArray()

    Converts this piecewise vector to an array of doubles

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

    ToString(String)

    String representation of vector with a specified format for each element

    Declaration
    public override string ToString(string format)
    Parameters
    Type Name Description
    String format
    Returns
    Type Description
    String
    Overrides
    Vector.ToString(String)

    ToString(String, String)

    String representation of vector with a specified format and delimiter

    Declaration
    public override string ToString(string format, string delimiter)
    Parameters
    Type Name Description
    String format
    String delimiter
    Returns
    Type Description
    String
    Overrides
    Vector.ToString(String, String)

    ToString(String, String, Func<Int32, String>)

    String representation of vector with a specified format and delimiter and a function for converting integers to display strings.

    Declaration
    public override string ToString(string format, string delimiter, Func<int, string> intToString)
    Parameters
    Type Name Description
    String format
    String delimiter
    Func<Int32, String> intToString
    Returns
    Type Description
    String
    Overrides
    Vector.ToString(String, String, Func<Int32, String>)

    ToVector()

    Converts this piecewise vector to an ordinary dense vector

    Declaration
    public DenseVector ToVector()
    Returns
    Type Description
    DenseVector

    Zero(Int32)

    Create a piecewise vector of given length with elements all 0.0

    Declaration
    public static PiecewiseVector Zero(int count)
    Parameters
    Type Name Description
    Int32 count

    Number of elements in vector

    Returns
    Type Description
    PiecewiseVector

    Explicit Interface Implementations

    IEnumerable.GetEnumerator()

    Gets an enumerator which yields the vector elements

    Declaration
    IEnumerator IEnumerable.GetEnumerator()
    Returns
    Type Description
    IEnumerator

    ICloneable.Clone()

    Clones this vector - return as an object

    Declaration
    object ICloneable.Clone()
    Returns
    Type Description
    Object

    Implements

    System.Collections.Generic.IReadOnlyList<T>
    System.Collections.Generic.IReadOnlyCollection<T>
    SettableToPower<T>
    SettableToProduct<T>
    SettableToProduct<T, U>
    SettableToWeightedSum<T>
    System.Collections.Generic.IList<T>
    System.Collections.Generic.ICollection<T>
    System.Collections.Generic.IEnumerable<T>
    System.Collections.IEnumerable
    System.ICloneable
    CanSetAllElementsTo<T>
    SettableTo<T>

    Extension Methods

    CollectionExtensions.AddRange<T>(ICollection<T>, IEnumerable<T>)
    CollectionExtensions.ContainsAll<T>(ICollection<T>, IEnumerable<T>)
    CollectionExtensions.ContainsAny<T>(ICollection<T>, IEnumerable<T>)
    EnumerableExtensions.ForEach<T>(IEnumerable<T>, Action<T>)
    EnumerableExtensions.ForEach<T>(IEnumerable, Action<T>)
    EnumerableExtensions.ForEach<T>(IEnumerable<T>, Action<Int32, T>)
    EnumerableExtensions.ForEach<T>(IEnumerable, Action<Int32, T>)
    EnumerableExtensions.Sum<TSource>(IEnumerable<TSource>, Func<TSource, UInt32>)
    EnumerableExtensions.Sum<TSource>(IEnumerable<TSource>, Func<TSource, UInt64>)
    EnumerableExtensions.ValueEquals<T>(IEnumerable<T>, IEnumerable<T>)
    EnumerableExtensions.IndexOf<T>(IEnumerable<T>, T)
    EnumerableExtensions.IndexOf<T>(IEnumerable, T)
    EnumerableExtensions.FindIndex<T>(IEnumerable<T>, Predicate<T>)
    EnumerableExtensions.FindIndex<T>(IEnumerable, Predicate<T>)
    EnumerableExtensions.FindAllIndex<T>(IEnumerable<T>, Predicate<T>)
    EnumerableExtensions.IndexOfAll<T>(IEnumerable<T>, T)
    EnumerableExtensions.Skip<T>(IEnumerable<T>, Int32, out List<T>)
    EnumerableExtensions.CopyTo<T>(IEnumerable<T>, T[], Int32)
    EnumerableExtensions.ToReadOnlyList<T>(IEnumerable<T>)
    IEnumerableExensions.EnumerableReduce<T, TRes>(IEnumerable<T>, TRes, Func<TRes, T, TRes>, Func<TRes, T, Int32, TRes>)
    IEnumerableExensions.EnumerableSum<T>(IEnumerable<T>, Func<T, Double>)
    IEnumerableExensions.ListZip<TFirst, TSecond, TResult>(IList<TFirst>, IEnumerable<TSecond>, Func<TFirst, TSecond, TResult>)
    IEnumerableExensions.ListZip<TFirst, TSecond, TThird, TResult>(IList<TFirst>, IEnumerable<TSecond>, IEnumerable<TThird>, Func<TFirst, TSecond, TThird, TResult>)
    IEnumerableExensions.ListZip<TFirst, TSecond, TThird, TFourth, TResult>(IList<TFirst>, IList<TSecond>, IList<TThird>, IList<TFourth>, Func<TFirst, TSecond, TThird, TFourth, TResult>)
    IListExtensions.IsSparse<T>(IList<T>)
    IListExtensions.ListSelect<T, T2>(IList<T>, Func<T, T2>)
    IListExtensions.ListReduce<T, TRes>(IList<T>, TRes, Func<TRes, T, TRes>)
    IListExtensions.ListReduce<T, T2, TRes>(IList<T>, IEnumerable<T2>, TRes, Func<TRes, T, T2, TRes>)
    IListExtensions.ToVector(IList<Double>)
    IListExtensions.SetTo<T>(IList<T>, IEnumerable<T>)
    IListExtensions.SetTo(IList<Double>, IEnumerable<Double>)
    IListExtensions.AsReadOnly<T>(IList<T>)
    ReadOnlyArray.ToReadOnlyArray<T>(IEnumerable<T>)
    In This Article
    Back to top Copyright © .NET Foundation. All rights reserved.