Class Vec<T>
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".
Assembly: TimeSeriesAnalysis.dll
Syntax
public static class Vec<T>
Type Parameters
Name |
Description |
T |
type, such as double, int or DateTime
|
Methods
|
Edit this page
View Source
Concat(T[], T)
concatenates the value y to the end of array x
Declaration
public static T[] Concat(T[] x, T y)
Parameters
Type |
Name |
Description |
T[] |
x |
|
T |
y |
|
Returns
|
Edit this page
View Source
Concat(T[], T[])
concatenates arrays x and y into a new larger array
Declaration
public static T[] Concat(T[] x, T[] y)
Parameters
Type |
Name |
Description |
T[] |
x |
|
T[] |
y |
|
Returns
|
Edit this page
View Source
Downsample(T[], int)
Downsample a vector by a given factor(selet only every Nth value)
Declaration
public static T[] Downsample(T[] vec, int factor)
Parameters
Type |
Name |
Description |
T[] |
vec |
|
int |
factor |
|
Returns
|
Edit this page
View Source
Fill(T, int)
creates an array of size N where every element has value value
Declaration
public static T[] Fill(T value, int N)
Parameters
Type |
Name |
Description |
T |
value |
|
int |
N |
|
Returns
|
Edit this page
View Source
GetIndicesOfValue(T, List<T>)
Get the indice of value val
values that are present in vec
Declaration
public static List<int> GetIndicesOfValue(T val, List<T> vec)
Parameters
Type |
Name |
Description |
T |
val |
The results are related to the positions in this vector
|
List<T> |
vec |
vec1 is compared to this vector
|
Returns
|
Edit this page
View Source
GetIndicesOfValues(List<T>, List<T>)
Get the indices of vec1
values that are present in vec2
Declaration
public static List<int> GetIndicesOfValues(List<T> vec1, List<T> vec2)
Parameters
Type |
Name |
Description |
List<T> |
vec1 |
The results are related to the positions in this vector
|
List<T> |
vec2 |
vec1 is compared to this vector
|
Returns
|
Edit this page
View Source
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
Declaration
public static T[] GetValuesAtIndices(T[] array, List<int> indices)
Parameters
Type |
Name |
Description |
T[] |
array |
|
List<int> |
indices |
|
Returns
|
Edit this page
View Source
GetValuesExcludingIndices(T[], List<int>)
returns an array of the values that are in array excluding those with indices given by indices list
Declaration
public static T[] GetValuesExcludingIndices(T[] array, List<int> indices)
Parameters
Type |
Name |
Description |
T[] |
array |
|
List<int> |
indices |
|
Returns
|
Edit this page
View Source
Intersect(List<List<T>>)
returns the intersection of a number of arrays
Declaration
public static List<T> Intersect(List<List<T>> lists)
Parameters
Type |
Name |
Description |
List<List<T>> |
lists |
|
Returns
|
Edit this page
View Source
Intersect(List<T>, List<T>)
returns the intersection of array1 and array2, a list of elements that are in both vectors
Declaration
public static List<T> Intersect(List<T> vec1, List<T> vec2)
Parameters
Type |
Name |
Description |
List<T> |
vec1 |
|
List<T> |
vec2 |
|
Returns
|
Edit this page
View Source
IsConstant(T[])
returns the intersection of a number of arrays
Declaration
public static bool IsConstant(T[] vec)
Parameters
Type |
Name |
Description |
T[] |
vec |
|
Returns
|
Edit this page
View Source
ReplaceIndWithValuesPrior(double[], List<int>)
replaces all the vaules in array with indices in indList with the last good value
prior to that index.
Declaration
public static double[] ReplaceIndWithValuesPrior(double[] array, List<int> indList)
Parameters
Returns
|
Edit this page
View Source
Sort(T[], VectorSortType)
Declaration
public static T[] Sort(T[] vec, VectorSortType sortType)
Parameters
Type |
Name |
Description |
T[] |
vec |
vector to be sorted
|
VectorSortType |
sortType |
the type of sorting
|
Returns
Type |
Description |
T[] |
indices of vec in sorted order
|
|
Edit this page
View Source
Sort(T[], VectorSortType, out int[])
Declaration
public static T[] Sort(T[] vec, VectorSortType sortType, out int[] idx)
Parameters
Returns
|
Edit this page
View Source
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)
Declaration
public static T[] SubArray(T[] array1, int indStart, int indEnd = -9999)
Parameters
Type |
Name |
Description |
T[] |
array1 |
array to get subarray from
|
int |
indStart |
starting index
|
int |
indEnd |
ending index(or to the end if omitted)
|
Returns
Type |
Description |
T[] |
null if indStart and indEnd are the same, otherwise the subarray
|