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
Ttype, 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
xT[]yT
Returns
- T[]
Concat(T[], T[])
concatenates arrays x and y into a new larger array
public static T[] Concat(T[] x, T[] y)
Parameters
xT[]yT[]
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
Returns
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
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
valueTNint
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
valTThe results are related to the positions in this vector
vecList<T>vec1is compared to this vector
Returns
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
vec1List<T>The results are related to the positions in this vector
vec2List<T>vec1is compared to this vector
Returns
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
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
Returns
- T[]
Intersect(List<List<T>>)
returns the intersection of a number of arrays
public static List<T> Intersect(List<List<T>> lists)
Parameters
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
Returns
- List<T>
IsConstant(T[])
returns the intersection of a number of arrays
public static bool IsConstant(T[] vec)
Parameters
vecT[]
Returns
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
Returns
- double[]
Sort(T[], VectorSortType)
Sort a vector
public static T[] Sort(T[] vec, VectorSortType sortType)
Parameters
vecT[]vector to be sorted
sortTypeVectorSortTypethe 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
vecT[]sortTypeVectorSortTypeidxint[]
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
array1T[]array to get subarray from
indStartintstarting index
indEndintending index(or to the end if omitted)
Returns
- T[]
null if indStart and indEnd are the same, otherwise the subarray