Class Sparse
Extension methods for sparse vectors.
Inheritance
System.Object
Sparse
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Mars.Numerics
Assembly: Mars.Numerics.dll
Syntax
public static class Sparse
Methods
| Improve this Doc View SourceColumns<T>(Sparse<T>[])
Gets the maximum number of columns (dimensions)
that can be inferred from the given sparse vectors.
Declaration
public static int Columns<T>(this Sparse<T>[] inputs)
where T : IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
Sparse<T>[] | inputs |
Returns
Type | Description |
---|---|
System.Int32 |
Type Parameters
Name | Description |
---|---|
T |
FromDense<T>(T[], Boolean)
Creates a sparse vector from a dense array.
Declaration
public static Sparse<T> FromDense<T>(T[] dense, bool removeZeros = true)
where T : IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
T[] | dense | |
System.Boolean | removeZeros |
Returns
Type | Description |
---|---|
Sparse<T> |
Type Parameters
Name | Description |
---|---|
T |
FromDense<T>(T[][], Boolean)
Creates sparse vectors from dense arrays.
Declaration
public static Sparse<T>[] FromDense<T>(T[][] dense, bool removeZeros = true)
where T : IEquatable<T>
Parameters
Type | Name | Description |
---|---|---|
T[][] | dense | |
System.Boolean | removeZeros |
Returns
Type | Description |
---|---|
Sparse<T>[] |
Type Parameters
Name | Description |
---|---|
T |
Parse(String, Nullable<Double>)
Parses a string containing a sparse array in LibSVM
format into a Sparse<T> vector.
Declaration
public static Sparse<double> Parse(string values, double? insertValueAtBeginning = null)
Parameters
Type | Name | Description |
---|---|---|
System.String | values | An array of "index:value" strings indicating where each value belongs in the sparse vector. |
System.Nullable<System.Double> | insertValueAtBeginning | Whether an intercept term should be added at the beginning of the vector. |
Returns
Type | Description |
---|---|
Sparse<System.Double> |
Parse(String[], Nullable<Double>, CultureInfo)
Parses a string containing a sparse array in LibSVM
format into a Sparse<T> vector.
Declaration
public static Sparse<double> Parse(string[] values, double? insertValueAtBeginning = null, CultureInfo cultureInfo = null)
Parameters
Type | Name | Description |
---|---|---|
System.String[] | values | An array of "index:value" strings indicating where each value belongs in the sparse vector. |
System.Nullable<System.Double> | insertValueAtBeginning | Whether an intercept term should be added at the beginning of the vector. |
System.Globalization.CultureInfo | cultureInfo | The culture when parsing numbers e.g. comma for decimal or dot. |
Returns
Type | Description |
---|---|
Sparse<System.Double> |