Share via


VBuffer<T> Constructors

Definition

Overloads

VBuffer<T>(Int32, T[], Int32[])

Construct a dense representation. The indices array is often unspecified, but if specified it should be considered a buffer to be held on to, to be possibly used.

VBuffer<T>(Int32, Int32, T[], Int32[])

Construct a possibly sparse vector representation.

VBuffer<T>(Int32, T[], Int32[])

Construct a dense representation. The indices array is often unspecified, but if specified it should be considered a buffer to be held on to, to be possibly used.

public VBuffer (int length, T[] values, int[] indices = default);
new Microsoft.ML.Data.VBuffer<'T> : int * 'T[] * int[] -> Microsoft.ML.Data.VBuffer<'T>
Public Sub New (length As Integer, values As T(), Optional indices As Integer() = Nothing)

Parameters

length
Int32

The logical length of the resulting instance.

values
T[]

The values to be used. This must be at least as long as length. If length is 0, it is legal for this to be null. The constructed buffer takes ownership of this array.

indices
Int32[]

The internal indices buffer. Because this constructor is for dense representations this will not be immediately useful, but it does provide a buffer to be potentially reused to avoid allocation. This is mostly non-null in situations where you want to produce a dense VBuffer<T>, but you happen to have an indices array "left over" and you don't want to needlessly lose.

Remarks

The resulting structure takes ownership of the passed in arrays, so they should not be used for other purposes in the future.

Applies to

VBuffer<T>(Int32, Int32, T[], Int32[])

Construct a possibly sparse vector representation.

public VBuffer (int length, int count, T[] values, int[] indices);
new Microsoft.ML.Data.VBuffer<'T> : int * int * 'T[] * int[] -> Microsoft.ML.Data.VBuffer<'T>
Public Sub New (length As Integer, count As Integer, values As T(), indices As Integer())

Parameters

length
Int32

The length of the constructed buffer.

count
Int32

The count of explicit entries. This must be between 0 and length, both inclusive. If it equals length the result is a dense vector, and if less this will be a sparse vector.

values
T[]

The values to be used. This must be at least as long as count. If count is 0, it is legal for this to be null.

indices
Int32[]

The indices to be used. If we are constructing a dense representation, or count is 0, this can be null. Otherwise, this must be at least as long as count.

Remarks

The resulting structure takes ownership of the passed in arrays, so they should not be used for other purposes in the future.

Applies to