Generated by DocFX

Class Sparse<T>

Sparse vector representation (in LibSVM format).

Inheritance
System.Object
Sparse<T>
Implements
ICloneable
IList<T>
IList
IFormattable
Namespace: ISynergy.Framework.Mathematics.Common
Assembly: ISynergy.Framework.Mathematics.dll
Syntax
public sealed class Sparse<T> : IEnumerable<T> where T : IEquatable<T>
Type Parameters
Name Description
T

The type for the non-zero elements in this vector.

Constructors

View Source

Sparse()

Creates a sparse vector with zero elements.

Declaration
public Sparse()
View Source

Sparse(Int32)

Creates a sparse vector with the maximum number of elements.

Declaration
public Sparse(int length)
Parameters
Type Name Description
System.Int32 length

The maximum number of non-zero elements that this vector can accomodate.

View Source

Sparse(Int32[], T[])

Creates a sparse vector from a vector of indices and a vector of values occuring at those indices.

Declaration
public Sparse(int[] indices, T[] values)
Parameters
Type Name Description
System.Int32[] indices

The indices for non-zero entries.

T[] values

The non-zero values happening at each index.

Properties

View Source

Indices

Gets or sets the vector of indices indicating the location of the non-zero elements contained in this sparse vector.

Declaration
public int[] Indices { get; set; }
Property Value
Type Description
System.Int32[]
View Source

Item[Int32]

Gets the the value stored at position i.

Declaration
public T this[int i] { get; set; }
Parameters
Type Name Description
System.Int32 i
Property Value
Type Description
T
View Source

Length

Gets the maximum non-zero element index in the sparse vector.

Declaration
public int Length { get; }
Property Value
Type Description
System.Int32
View Source

Values

Gets or sets the vector of values indicating which non-zero value happens at each position indicated in Indices.

Declaration
public T[] Values { get; set; }
Property Value
Type Description
T[]

Methods

View Source

Clone()

Creates a new object that is a copy of the current instance.

Declaration
public object Clone()
Returns
Type Description
System.Object

A new object that is a copy of this instance.

View Source

CopyTo(T[], Int32)

Copies the elements of the System.Collections.Generic.ICollection<T> to an System.Array, starting at a particular System.Array index.

Declaration
public void CopyTo(T[] array, int arrayIndex)
Parameters
Type Name Description
T[] array

The one-dimensional System.Array that is the destination of the elements copied from System.Collections.Generic.ICollection<T>. The System.Array must have zero-based indexing.

System.Int32 arrayIndex

The zero-based index in array at which copying begins.

View Source

IsFull()

Determines whether this Sparse vector has elements on all indices.

Declaration
public bool IsFull()
Returns
Type Description
System.Boolean

true if this instance is full; otherwise, false.

View Source

ToDense()

Converts this sparse vector to a dense vector of the given length.

Declaration
public T[] ToDense()
Returns
Type Description
T[]
View Source

ToDense(Int32)

Converts this sparse vector to a dense vector of the given length.

Declaration
public T[] ToDense(int length)
Parameters
Type Name Description
System.Int32 length
Returns
Type Description
T[]
View Source

ToSparse()

Converts this sparse vector to a sparse representation where the indices are intertwined with their corresponding values.

Declaration
public T[] ToSparse()
Returns
Type Description
T[]
View Source

ToString()

Returns a that represents this instance.

Declaration
public override string ToString()
Returns
Type Description
System.String

A that represents this instance.

View Source

ToString(String, IFormatProvider)

Returns a that represents this instance.

Declaration
public string ToString(string format, IFormatProvider formatProvider)
Parameters
Type Name Description
System.String format

The format.

IFormatProvider formatProvider

The format provider.

Returns
Type Description
System.String

A that represents this instance.

Operators

View Source

Implicit(Sparse<T> to Array)

Performs an implicit conversion from Sparse<T> to .

Declaration
public static implicit operator Array(Sparse<T> obj)
Parameters
Type Name Description
Sparse<T> obj
Returns
Type Description
Array

Implements

ICloneable
IList<>
IList
IFormattable

Extension Methods

Matrix.Replace<T>(T, Object, Object)
Matrix.IsEqual(Object, Object, Decimal, Decimal)
EntityBaseExtensions.HasProperty(Object, String)
ArrayExtensions.Concatenate<T>(T, T[])
CollectionExtensions.FromHierarchy<TSource>(TSource, Func<TSource, TSource>, Func<TSource, Boolean>)
CollectionExtensions.FromHierarchy<TSource>(TSource, Func<TSource, TSource>)
ObjectExtensions.Clone<T>(T)
ObjectExtensions.To<T>(Object)
ObjectExtensions.To(Object, Type)
ObjectExtensions.HasMethod(Object, String)
ObjectExtensions.AddressOf<T>(T)
ReflectionExtensions.GetIdentityValue<T>(T)
ReflectionExtensions.GetIdentityValue<T, TResult>(T)
ReflectionExtensions.GetIdentityProperty<T>(T)
ReflectionExtensions.HasIdentityProperty<T>(T)
ReflectionExtensions.GetPropertyValue<T, TResult>(T, String, TResult)
ReflectionExtensions.GetPropertyInfo<T, TValue>(T, Expression<Func<T, TValue>>)
ReflectionExtensions.GetTitleValue<T>(T)
ReflectionExtensions.HasParentIdentityProperty<T>(T)
ReflectionExtensions.GetParentIdentityProperty<T>(T)
ReflectionExtensions.IsFreeApplication<T>(T)