Class ApproximateSparseList<T>
Approximate Sparse List.
Inherited Members
Namespace: Microsoft.ML.Probabilistic.Collections
Assembly: Microsoft.ML.Probabilistic.dll
Syntax
[Serializable]
[DataContract]
public class ApproximateSparseList<T> : SparseList<T>, ISparseList<T>, ISparseEnumerable<T>, IList<T>, ICollection<T>, IEnumerable<T>, IList, ICollection, IEnumerable, ICloneable where T : Diffable
Type Parameters
Name | Description |
---|---|
T | List element type. Must implement Diffable. |
Constructors
ApproximateSparseList()
Null constructor.
Declaration
protected ApproximateSparseList()
ApproximateSparseList(ISparseList<T>)
Copy constructor.
Declaration
protected ApproximateSparseList(ISparseList<T> that)
Parameters
Type | Name | Description |
---|---|---|
ISparseList<T> | that | the sparse list to copy into this new sparse list |
ApproximateSparseList(ISparseList<T>, Double)
Copy constructor.
Declaration
protected ApproximateSparseList(ISparseList<T> that, double tolerance)
Parameters
Type | Name | Description |
---|---|---|
ISparseList<T> | that | the sparse list to copy into this new sparse list |
Double | tolerance | The tolerance for the approximation |
ApproximateSparseList(Double)
Constructs an approximate sparse list with the given tolerance
Declaration
protected ApproximateSparseList(double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Double | tolerance | The tolerance for the approximation |
ApproximateSparseList(Int32)
Constructs an approximate sparse list with the given number of elements and with default tolerance.
Declaration
protected ApproximateSparseList(int count)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | Number of elements to allocate (>= 0). |
ApproximateSparseList(Int32, T)
Constructs a sparse list of a given length and assigns all elements the given value. The tolerance is set to the default value.
Declaration
protected ApproximateSparseList(int count, T commonValue)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | Number of elements to allocate (>= 0). |
T | commonValue | The value to assign to all elements. |
ApproximateSparseList(Int32, T, List<ValueAtIndex<T>>)
Constructs a sparse list of a given length and assigns all elements the given value, except for the specified list of sparse values. This list is stored internally as is so MUST be sorted by index and must not be modified externally after being passed in. The tolerance is set to the default value.
Declaration
protected ApproximateSparseList(int count, T commonValue, List<ValueAtIndex<T>> sortedSparseValues)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | Number of elements to allocate (>= 0). |
T | commonValue | The value to assign to all elements. |
List<ValueAtIndex<T>> | sortedSparseValues | The list of sparse values, which must be sorted by index. |
ApproximateSparseList(Int32, T, List<ValueAtIndex<T>>, Double)
Constructs a sparse list of a given length and assigns all elements the given value, except for the specified list of sparse values. This list is stored internally as is so MUST be sorted by index and must not be modified externally after being passed in.
Declaration
protected ApproximateSparseList(int count, T commonValue, List<ValueAtIndex<T>> sortedSparseValues, double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | Number of elements to allocate (>= 0). |
T | commonValue | The value to assign to all elements. |
List<ValueAtIndex<T>> | sortedSparseValues | The list of sparse values, which must be sorted by index. |
Double | tolerance | The tolerance for the approximation |
ApproximateSparseList(Int32, T, Double)
Constructs a sparse list of a given length and assigns all elements the given value.
Declaration
protected ApproximateSparseList(int count, T commonValue, double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | Number of elements to allocate (>= 0). |
T | commonValue | The value to assign to all elements. |
Double | tolerance | The tolerance for the approximation |
ApproximateSparseList(Int32, Double)
Constructs an approximate sparse list with the given number of elements and with the given tolerance.
Declaration
protected ApproximateSparseList(int count, double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | Number of elements to allocate (>= 0). |
Double | tolerance | The tolerance for the approximation |
Fields
DefaultTolerance
The default tolerance for the approximate sparse list
Declaration
public static double DefaultTolerance
Field Value
Type | Description |
---|---|
Double |
Properties
Item[Int32]
Gets or sets an element.
Declaration
public override T this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Int32 | index |
Property Value
Type | Description |
---|---|
T |
Overrides
Tolerance
The tolerance for the approximation
Declaration
public double Tolerance { get; protected set; }
Property Value
Type | Description |
---|---|
Double |
Methods
Clone()
Clones this list - return as a sparse list.
Declaration
public ApproximateSparseList<T> Clone()
Returns
Type | Description |
---|---|
ApproximateSparseList<T> |
Constant(Int32, T, Double)
Create a sparse list of given length with elements all equal to a specified value
Declaration
public static ApproximateSparseList<T> Constant(int count, T value, double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | Number of elements in the list |
T | value | Value for each element |
Double | tolerance | The tolerance for the approximation |
Returns
Type | Description |
---|---|
ApproximateSparseList<T> |
Equals(Object)
Determines object equality.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | Another object. |
Returns
Type | Description |
---|---|
Boolean | True if equal. |
Overrides
FromSize(Int32, Double)
Create a sparse list of given length with elements all equal to the default value for the element type
Declaration
public static ApproximateSparseList<T> FromSize(int count, double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | Number of elements in the list |
Double | tolerance | The tolerance for the approximation |
Returns
Type | Description |
---|---|
ApproximateSparseList<T> |
FromSparseValues(Int32, T, List<ValueAtIndex<T>>, Double)
Constructs a sparse list from a sorted list of sparse elements.
Declaration
[Construction(new string[]{"Count", "CommonValue", "SparseValues", "Tolerance"})]
public static SparseList<T> FromSparseValues(int count, T commonValue, List<ValueAtIndex<T>> sortedSparseValues, double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Int32 | count | Count for result |
T | commonValue | Common value |
List<ValueAtIndex<T>> | sortedSparseValues | Sorted list of sparse elements |
Double | tolerance | The tolerance for the approximation |
Returns
Type | Description |
---|---|
SparseList<T> |
GetHashCode()
Gets a hash code for the instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | The code. |
Overrides
SetTo(ApproximateSparseList<T>)
Copies values from a sparse list to this sparse list.
Declaration
public void SetTo(ApproximateSparseList<T> that)
Parameters
Type | Name | Description |
---|---|---|
ApproximateSparseList<T> | that |
SetTo(IList<T>, T)
Copies values from a list which must have the same size as this list, using the specified common value.
Declaration
public override void SetTo(IList<T> dlist, T commonValue)
Parameters
Type | Name | Description |
---|---|---|
IList<T> | dlist | The list to copy from |
T | commonValue | Common value |
Overrides
SetToFunction<T2>(ISparseEnumerable<T2>, Func<T2, T>)
Sets the elements of this sparse list to a function of the elements of a sparse collection
Declaration
public ApproximateSparseList<T> SetToFunction<T2>(ISparseEnumerable<T2> that, Func<T2, T> fun)
Parameters
Type | Name | Description |
---|---|---|
ISparseEnumerable<T2> | that | The other list |
Func<T2, T> | fun | The function which maps from type T2 to type T |
Returns
Type | Description |
---|---|
ApproximateSparseList<T> |
Type Parameters
Name | Description |
---|---|
T2 |
Remarks
Assumes the lists are the same length
SetToFunction<T2>(SparseList<T2>, Func<T2, T>)
Sets the elements of this sparse list to a function of the elements of another sparse list
Declaration
public ApproximateSparseList<T> SetToFunction<T2>(SparseList<T2> that, Func<T2, T> fun)
Parameters
Type | Name | Description |
---|---|---|
SparseList<T2> | that | The other list |
Func<T2, T> | fun | The function which maps from type T2 to type T |
Returns
Type | Description |
---|---|
ApproximateSparseList<T> |
Type Parameters
Name | Description |
---|---|
T2 |
Remarks
Assumes the lists are the same length
SetToFunction<T2>(IEnumerable<T2>, Func<T2, T>)
Sets the elements of this sparse list to a function of the elements of a collection
Declaration
public ApproximateSparseList<T> SetToFunction<T2>(IEnumerable<T2> that, Func<T2, T> fun)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T2> | that | The other list |
Func<T2, T> | fun | The function which maps from type T2 to type T |
Returns
Type | Description |
---|---|
ApproximateSparseList<T> |
Type Parameters
Name | Description |
---|---|
T2 |
Remarks
Assumes the lists are the same length
SetToFunction<T1, T2>(ISparseEnumerable<T1>, ISparseEnumerable<T2>, Func<T1, T2, T>)
Sets the elements of this sparse list to a function of the elements of two other sparse lists
Declaration
public ApproximateSparseList<T> SetToFunction<T1, T2>(ISparseEnumerable<T1> a, ISparseEnumerable<T2> b, Func<T1, T2, T> fun)
Parameters
Type | Name | Description |
---|---|---|
ISparseEnumerable<T1> | a | The first list |
ISparseEnumerable<T2> | b | The second list |
Func<T1, T2, T> | fun | The function which maps two elements to an element of this list |
Returns
Type | Description |
---|---|
ApproximateSparseList<T> |
Type Parameters
Name | Description |
---|---|
T1 | |
T2 |
SetToFunction<T1, T2>(SparseList<T1>, SparseList<T2>, Func<T1, T2, T>)
Sets the elements of this approximate sparse list to a function of the elements of two other sparse lists
Declaration
public ApproximateSparseList<T> SetToFunction<T1, T2>(SparseList<T1> a, SparseList<T2> b, Func<T1, T2, T> fun)
Parameters
Type | Name | Description |
---|---|---|
SparseList<T1> | a | The first list |
SparseList<T2> | b | The second list |
Func<T1, T2, T> | fun | The function which maps two elements to an element of this list |
Returns
Type | Description |
---|---|
ApproximateSparseList<T> |
Type Parameters
Name | Description |
---|---|
T1 | |
T2 |
Remarks
Assumes the lists are all the same length
SetToFunction<T1, T2>(IEnumerable<T1>, IEnumerable<T2>, Func<T1, T2, T>)
Sets the elements of this list to a function of the elements of two collections
Declaration
public ApproximateSparseList<T> SetToFunction<T1, T2>(IEnumerable<T1> a, IEnumerable<T2> b, Func<T1, T2, T> fun)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T1> | a | The first list |
IEnumerable<T2> | b | The second list |
Func<T1, T2, T> | fun | The function which maps the two elements of the other lists to an element of this list |
Returns
Type | Description |
---|---|
ApproximateSparseList<T> |
Type Parameters
Name | Description |
---|---|
T1 | |
T2 |
Remarks
Assumes the lists are the same length
SetToFunction<T1, T2, T3>(ISparseEnumerable<T1>, ISparseEnumerable<T2>, ISparseEnumerable<T3>, Func<T1, T2, T3, T>)
Sets the elements of this sparse list to a function of the elements of three sparse collections
Declaration
public ApproximateSparseList<T> SetToFunction<T1, T2, T3>(ISparseEnumerable<T1> a, ISparseEnumerable<T2> b, ISparseEnumerable<T3> c, Func<T1, T2, T3, T> fun)
Parameters
Type | Name | Description |
---|---|---|
ISparseEnumerable<T1> | a | The first collection |
ISparseEnumerable<T2> | b | The second collection |
ISparseEnumerable<T3> | c | The third collection |
Func<T1, T2, T3, T> | fun | The function which maps three elements to an element of this list |
Returns
Type | Description |
---|---|
ApproximateSparseList<T> |
Type Parameters
Name | Description |
---|---|
T1 | |
T2 | |
T3 |
SetToFunction<T1, T2, T3>(IEnumerable<T1>, IEnumerable<T2>, IEnumerable<T3>, Func<T1, T2, T3, T>)
Sets the elements of this sparse list to a function of the elements of three sparse collections
Declaration
public ApproximateSparseList<T> SetToFunction<T1, T2, T3>(IEnumerable<T1> a, IEnumerable<T2> b, IEnumerable<T3> c, Func<T1, T2, T3, T> fun)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T1> | a | The first collection |
IEnumerable<T2> | b | The second collection |
IEnumerable<T3> | c | The third collection |
Func<T1, T2, T3, T> | fun | The function which maps three elements to an element of this list |
Returns
Type | Description |
---|---|
ApproximateSparseList<T> |
Type Parameters
Name | Description |
---|---|
T1 | |
T2 | |
T3 |
SetToFunction<T1, T2, T3, T4>(ISparseList<T1>, ISparseList<T2>, ISparseList<T3>, ISparseList<T4>, Func<T1, T2, T3, T4, T>)
Sets the elements of this sparse list to a function of the elements of three other collections
Declaration
public ApproximateSparseList<T> SetToFunction<T1, T2, T3, T4>(ISparseList<T1> a, ISparseList<T2> b, ISparseList<T3> c, ISparseList<T4> d, Func<T1, T2, T3, T4, T> fun)
Parameters
Type | Name | Description |
---|---|---|
ISparseList<T1> | a | The first collection |
ISparseList<T2> | b | The second collection |
ISparseList<T3> | c | The third collection |
ISparseList<T4> | d | The fourth collection |
Func<T1, T2, T3, T4, T> | fun | The function which maps four elements to an element of this list |
Returns
Type | Description |
---|---|
ApproximateSparseList<T> |
Type Parameters
Name | Description |
---|---|
T1 | |
T2 | |
T3 | |
T4 |
SetToFunction<T1, T2, T3, T4>(IEnumerable<T1>, IEnumerable<T2>, IEnumerable<T3>, IEnumerable<T4>, Func<T1, T2, T3, T4, T>)
Sets the elements of this sparse list to a function of the elements of four sparse collections
Declaration
public ApproximateSparseList<T> SetToFunction<T1, T2, T3, T4>(IEnumerable<T1> a, IEnumerable<T2> b, IEnumerable<T3> c, IEnumerable<T4> d, Func<T1, T2, T3, T4, T> fun)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<T1> | a | The first collection |
IEnumerable<T2> | b | The second collection |
IEnumerable<T3> | c | The third collection |
IEnumerable<T4> | d | The fourth collection |
Func<T1, T2, T3, T4, T> | fun | The function which maps four elements to an element of this list |
Returns
Type | Description |
---|---|
ApproximateSparseList<T> |
Type Parameters
Name | Description |
---|---|
T1 | |
T2 | |
T3 | |
T4 |
SetToFunctionInPlace<T1>(SparseList<T1>, Func<T, T1, T>)
Sets the elements of this approximate sparse list to a function of the elements of this sparse list and another sparse list x = fun(x,b)
Declaration
public ApproximateSparseList<T> SetToFunctionInPlace<T1>(SparseList<T1> b, Func<T, T1, T> fun)
Parameters
Type | Name | Description |
---|---|---|
SparseList<T1> | b | The other sparse list |
Func<T, T1, T> | fun | The function which maps (T,T1) to T |
Returns
Type | Description |
---|---|
ApproximateSparseList<T> |
Type Parameters
Name | Description |
---|---|
T1 |
Remarks
Assumes the lists are the same length