Table of Contents

Class Vec<T>

Namespace
TimeSeriesAnalysis
Assembly
TimeSeriesAnalysis.dll

Class for generic methods on any type T that treat arrays as vectors (sorting,slicing,concatenating).

For mathematical methods on vectors of doubles and integers, look into non-generic sister class "Vec".

public static class Vec<T>

Type Parameters

T

type, such as double, int or DateTime

Inheritance
Vec<T>
Inherited Members

Methods

Concat(T[], T)

concatenates the value y to the end of array x

public static T[] Concat(T[] x, T y)

Parameters

x T[]
y T

Returns

T[]

Concat(T[], T[])

concatenates arrays x and y into a new larger array

public static T[] Concat(T[] x, T[] y)

Parameters

x T[]
y T[]

Returns

T[]

Downsample(T[], int, List<int>)

Downsample a vector by a given factor, while ignore indices to ignore, and returns a new "downsampled" ind to ignore

public static (T[], List<int>) Downsample(T[] vec, int factor, List<int> indToIgnore)

Parameters

vec T[]
factor int
indToIgnore List<int>

indices in vec that are to be ignored.

Returns

(T[], List<int>)

the downsampled list and the new indices to ignore

Downsample(T[], int, int)

Downsample a vector by a given factor by choosing every Floor(factor*n) value. The optional key index indicates an index for which to base the downsampling around.

public static T[] Downsample(T[] vec, int factor, int keyIndex = 0)

Parameters

vec T[]
factor int
keyIndex int

Returns

T[]

Fill(T, int)

creates an array of size N where every element has value value

public static T[] Fill(T value, int N)

Parameters

value T
N int

Returns

T[]

GetIndicesOfValue(T, List<T>)

Get the indice of value val values that are present in vec

public static List<int> GetIndicesOfValue(T val, List<T> vec)

Parameters

val T

The results are related to the positions in this vector

vec List<T>

vec1 is compared to this vector

Returns

List<int>

GetIndicesOfValues(List<T>, List<T>)

Get the indices of vec1 values that are present in vec2

public static List<int> GetIndicesOfValues(List<T> vec1, List<T> vec2)

Parameters

vec1 List<T>

The results are related to the positions in this vector

vec2 List<T>

vec1 is compared to this vector

Returns

List<int>

GetValuesAtIndices(T[], List<int>)

returns an array of the values that are in array at the indices given by indices list, or null if input is null

public static T[] GetValuesAtIndices(T[] array, List<int> indices)

Parameters

array T[]
indices List<int>

Returns

T[]

GetValuesExcludingIndices(T[], List<int>)

returns an array of the values that are in array excluding those with indices given by indices list

public static T[] GetValuesExcludingIndices(T[] array, List<int> indices)

Parameters

array T[]
indices List<int>

Returns

T[]

Intersect(List<List<T>>)

returns the intersection of a number of arrays

public static List<T> Intersect(List<List<T>> lists)

Parameters

lists List<List<T>>

Returns

List<T>

Intersect(List<T>, List<T>)

returns the intersection of array1 and array2, a list of elements that are in both vectors

public static List<T> Intersect(List<T> vec1, List<T> vec2)

Parameters

vec1 List<T>
vec2 List<T>

Returns

List<T>

IsConstant(T[])

returns the intersection of a number of arrays

public static bool IsConstant(T[] vec)

Parameters

vec T[]

Returns

bool

ReplaceIndWithValuesPrior(double[], List<int>)

replaces all the vaules in array with indices in indList with the last good value prior to that index.

public static double[] ReplaceIndWithValuesPrior(double[] array, List<int> indList)

Parameters

array double[]
indList List<int>

Returns

double[]

Sort(T[], VectorSortType)

Sort a vector

public static T[] Sort(T[] vec, VectorSortType sortType)

Parameters

vec T[]

vector to be sorted

sortType VectorSortType

the type of sorting

Returns

T[]

indices of vec in sorted order

Sort(T[], VectorSortType, out int[])

Sort the vector

public static T[] Sort(T[] vec, VectorSortType sortType, out int[] idx)

Parameters

vec T[]
sortType VectorSortType
idx int[]

Returns

T[]

SubArray(T[], int, int)

Returns the portion of array1 starting and indStart, and ending at indEnd(or at the end if third paramter is omitted)

public static T[] SubArray(T[] array1, int indStart, int indEnd = -9999)

Parameters

array1 T[]

array to get subarray from

indStart int

starting index

indEnd int

ending index(or to the end if omitted)

Returns

T[]

null if indStart and indEnd are the same, otherwise the subarray