Generated by DocFX

Class Vector

Static class Vector. Defines a set of extension methods that operates mainly on single-dimensional arrays.

Inheritance
System.Object
Vector
Namespace: ISynergy.Framework.Mathematics
Assembly: ISynergy.Framework.Mathematics.dll
Syntax
public static class Vector : object

Methods

View Source

Add(Sparse<Double>, Double[], Double[])

Adds a sparse vector to a dense vector.

Declaration
public static double[] Add(this Sparse<double> a, double[] b, double[] result)
Parameters
Type Name Description
Sparse<System.Double> a
System.Double[] b
System.Double[] result
Returns
Type Description
System.Double[]
View Source

Copy<T>(T[])

Creates a shallow copy of the array.

Declaration
public static T[] Copy<T>(this T[] vector)
Parameters
Type Name Description
T[] vector
Returns
Type Description
T[]
Type Parameters
Name Description
T
View Source

Create<T>(T, Boolean[])

Creates a vector with the given value at the positions where mask is true, and zero when they are false.

Declaration
public static T[] Create<T>(T value, bool[] mask)
Parameters
Type Name Description
T value

The initial values for the vector.

System.Boolean[] mask

The boolean mask determining where the values will be placed.

Returns
Type Description
T[]
Type Parameters
Name Description
T
View Source

Create<T>(T[])

Creates a vector with the given starting values.

Declaration
public static T[] Create<T>(params T[] values)
Parameters
Type Name Description
T[] values

The initial values for the vector.

Returns
Type Description
T[]
Type Parameters
Name Description
T
View Source

Create<T>(Int32, T)

Creates a vector with the given dimension and starting value.

Declaration
public static T[] Create<T>(int size, T value)
Parameters
Type Name Description
System.Int32 size

The number of elements in the vector.

T value

The initial values for the vector.

Returns
Type Description
T[]
Type Parameters
Name Description
T
View Source

Create<T>(Int32, T[])

Creates a vector with the given dimension and starting value.

Declaration
public static T[] Create<T>(int size, T[] values)
Parameters
Type Name Description
System.Int32 size

The number of elements in the vector.

T[] values

The initial values for the vector.

Returns
Type Description
T[]
Type Parameters
Name Description
T
View Source

CreateAs<T>(T[])

Creates a vector with the shape of the given vector.

Declaration
public static T[] CreateAs<T>(T[] vector)
Parameters
Type Name Description
T[] vector

The vector whose shape should be copied.

Returns
Type Description
T[]
Type Parameters
Name Description
T
View Source

Divide(Sparse<Double>, Double, Sparse<Double>)

Divides a sparse vector by a scalar.

Declaration
public static Sparse<double> Divide(this Sparse<double> a, double b, Sparse<double> result)
Parameters
Type Name Description
Sparse<System.Double> a
System.Double b
Sparse<System.Double> result
Returns
Type Description
Sparse<System.Double>
View Source

Divide(Sparse<Double>[], Double[], Sparse<Double>[])

Divides an array of sparse vectors by the associated scalars in a dense vector.

Declaration
public static Sparse<double>[] Divide(this Sparse<double>[] a, double[] b, Sparse<double>[] result)
Parameters
Type Name Description
Sparse<System.Double>[] a
System.Double[] b
Sparse<System.Double>[] result
Returns
Type Description
Sparse<System.Double>[]
View Source

Dot(Sparse<Double>, Sparse<Double>)

Gets the inner product (scalar product) between two vectors (a'*b).

Declaration
public static double Dot(this Sparse<double> a, Sparse<double> b)
Parameters
Type Name Description
Sparse<System.Double> a

A vector.

Sparse<System.Double> b

A vector.

Returns
Type Description
System.Double

The inner product of the multiplication of the vectors.

View Source

Dot(Sparse<Double>, Double[])

Gets the inner product (scalar product) between two vectors (a'*b).

Declaration
public static double Dot(this Sparse<double> a, double[] b)
Parameters
Type Name Description
Sparse<System.Double> a

A vector.

System.Double[] b

A vector.

Returns
Type Description
System.Double

The inner product of the multiplication of the vectors.

View Source

EnumerableRange(Double)

Enumerates through a range (like Python's xrange function).

Declaration
public static IEnumerable<double> EnumerableRange(double n)
Parameters
Type Name Description
System.Double n

The exclusive upper bound of the range.

Returns
Type Description
IEnumerable<System.Double>
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

EnumerableRange(Double, Double)

Enumerates through a range (like Python's xrange).

Declaration
public static IEnumerable<double> EnumerableRange(double a, double b)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

Returns
Type Description
IEnumerable<System.Double>
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

EnumerableRange(Double, Double, Byte)

Enumerates through a range (like Python's xrange function).

Declaration
public static IEnumerable<double> EnumerableRange(double a, double b, byte stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.Byte stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
IEnumerable<System.Double>
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

EnumerableRange(Double, Double, Double)

Enumerates through a range (like Python's xrange function).

Declaration
public static IEnumerable<double> EnumerableRange(double a, double b, double stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.Double stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
IEnumerable<System.Double>
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

EnumerableRange(Double, Double, Int16)

Enumerates through a range (like Python's xrange function).

Declaration
public static IEnumerable<double> EnumerableRange(double a, double b, short stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.Int16 stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
IEnumerable<System.Double>
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

EnumerableRange(Double, Double, Int32)

Enumerates through a range (like Python's xrange function).

Declaration
public static IEnumerable<double> EnumerableRange(double a, double b, int stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.Int32 stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
IEnumerable<System.Double>
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

EnumerableRange(Double, Double, Int64)

Enumerates through a range (like Python's xrange function).

Declaration
public static IEnumerable<double> EnumerableRange(double a, double b, long stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.Int64 stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
IEnumerable<System.Double>
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

EnumerableRange(Double, Double, SByte)

Enumerates through a range (like Python's xrange function).

Declaration
public static IEnumerable<double> EnumerableRange(double a, double b, sbyte stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.SByte stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
IEnumerable<System.Double>
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

EnumerableRange(Double, Double, UInt16)

Enumerates through a range (like Python's xrange function).

Declaration
public static IEnumerable<double> EnumerableRange(double a, double b, ushort stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.UInt16 stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
IEnumerable<System.Double>
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

EnumerableRange(Double, Double, UInt64)

Enumerates through a range (like Python's xrange function).

Declaration
public static IEnumerable<double> EnumerableRange(double a, double b, ulong stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.UInt64 stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
IEnumerable<System.Double>
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

GetIndices<T>(T[])

Creates a vector containing every index that can be used to address a given array, in order.

Declaration
public static int[] GetIndices<T>(this T[] array)
Parameters
Type Name Description
T[] array

The array whose indices will be returned.

Returns
Type Description
System.Int32[]

A vector of the same size as the given array containing all vector indices from 0 up to the length of array.

Type Parameters
Name Description
T
Examples
double[] a = { 5.3, 2.3, 4.2 };
int[] idx = a.GetIndices(); // output will be { 0, 1, 2 }
See Also
GetIndices(Array, Boolean, Boolean, MatrixOrder)
View Source

Histogram(Int32[])

Counts how many times an integer label appears in a vector (i.e. creates an histogram of integer values assuming possible values start at zero and go up to the maximum value of in the vector).

Declaration
public static int[] Histogram(this int[] labels)
Parameters
Type Name Description
System.Int32[] labels

An array containing the integer labels to be counted.

Returns
Type Description
System.Int32[]

An integer array of size corresponding to the maximum label in the vector labels, containing how many times each possible label appears in labels.

View Source

Histogram(Int32[], Int32)

Counts how many times an integer label appears in a vector (i.e. creates an histogram of integer values assuming possible values start at zero and go up to the value of size).

Declaration
public static int[] Histogram(this int[] labels, int size)
Parameters
Type Name Description
System.Int32[] labels

An array containing the integer labels to be counted.

System.Int32 size

The number of labels (will be the size of the generated histogram).

Returns
Type Description
System.Int32[]

An integer array of size size containing how many times each possible label appears in labels.

View Source

Histogram(Int32[], Int32[])

Counts how many times an integer label appears in a vector (i.e. creates an histogram of integer values assuming possible values start at zero and go up to the maximum value of in the vector).

Declaration
public static int[] Histogram(this int[] labels, int[] result)
Parameters
Type Name Description
System.Int32[] labels

An array containing the integer labels to be counted.

System.Int32[] result

The histogram to were the counts will be added. This vector should have been zeroed out before being passed to this method.

Returns
Type Description
System.Int32[]

The same vector result passed as an argument.

View Source

Indices(Int32, Int32)

Creates a index vector.

Declaration
public static double[] Indices(int from, int to)
Parameters
Type Name Description
System.Int32 from
System.Int32 to
Returns
Type Description
System.Double[]
View Source

Interval(NumericRange, Double)

Obsolete. Please use Vector.Range(range, stepSize) instead.

Declaration
public static double[] Interval(this NumericRange range, double stepSize)
Parameters
Type Name Description
NumericRange range
System.Double stepSize
Returns
Type Description
System.Double[]
View Source

Interval(NumericRange, Int32)

Creates an interval vector (like NumPy's linspace function).

Declaration
public static double[] Interval(this NumericRange range, int steps)
Parameters
Type Name Description
NumericRange range
System.Int32 steps
Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.linspace function. For a similar method that accepts a step size instead of a number of steps, see Range(Int32, Int32).

See Also
Range(Int32, Int32)
View Source

Interval(Double, Double)

Creates an interval vector (like NumPy's linspace function).

Declaration
public static double[] Interval(double a, double b)
Parameters
Type Name Description
System.Double a
System.Double b
Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.linspace function. For a similar method that accepts a step size instead of a number of steps, see Range(Int32, Int32).

See Also
Range(Int32, Int32)
View Source

Interval(Double, Double, Double)

Obsolete. Please use Vector.Range(a, b, stepSize) instead.

Declaration
public static double[] Interval(double a, double b, double stepSize)
Parameters
Type Name Description
System.Double a
System.Double b
System.Double stepSize
Returns
Type Description
System.Double[]
View Source

Interval(Double, Double, Int32, Boolean)

Creates an interval vector (like NumPy's linspace function).

Declaration
public static double[] Interval(double a, double b, int steps, bool includeLast = true)
Parameters
Type Name Description
System.Double a
System.Double b
System.Int32 steps
System.Boolean includeLast
Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.linspace function. For a similar method that accepts a step size instead of a number of steps, see Range(Int32, Int32).

See Also
Range(Int32, Int32)
View Source

Interval(Int32, Int32)

Creates an interval vector (like NumPy's linspace function).

Declaration
public static double[] Interval(int a, int b)
Parameters
Type Name Description
System.Int32 a
System.Int32 b
Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.linspace function. For a similar method that accepts a step size instead of a number of steps, see Range(Int32, Int32).

See Also
Range(Int32, Int32)
View Source

Interval(Int32, Int32, Int32, Boolean)

Creates an interval vector (like NumPy's linspace function).

Declaration
public static double[] Interval(int a, int b, int steps, bool includeLast = true)
Parameters
Type Name Description
System.Int32 a
System.Int32 b
System.Int32 steps
System.Boolean includeLast
Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.linspace function. For a similar method that accepts a step size instead of a number of steps, see Range(Int32, Int32).

See Also
Range(Int32, Int32)
View Source

KHot(Int32[], Double[])

Creates a k-hot vector, where all values are zero except for the elements at the indicated indices, which are set to one.

Declaration
public static double[] KHot(int[] indices, double[] result)
Parameters
Type Name Description
System.Int32[] indices

The vector's dimensions which will be marked as ones.

System.Double[] result

The vector where the k-hot should be marked.

Returns
Type Description
System.Double[]

A k-hot vector where the indicated positions are one and the others are zero.

View Source

KHot(Int32[], Int32)

Creates a k-hot vector, where all values are zero except for the elements at the indicated indices, which are set to one.

Declaration
public static double[] KHot(int[] indices, int columns)
Parameters
Type Name Description
System.Int32[] indices

The vector's dimensions which will be marked as ones.

System.Int32 columns

The size (length) of the vector.

Returns
Type Description
System.Double[]

A k-hot vector where the indicated positions are one and the others are zero.

View Source

KHot<T>(Boolean[], T[])

Creates a k-hot vector, where all values are zero except for the elements at the positions where mask is true, which are set to one.

Declaration
public static T[] KHot<T>(bool[] mask, T[] result)
Parameters
Type Name Description
System.Boolean[] mask

The boolean mask determining where the values will be placed.

T[] result

The vector where the k-hot should be marked.

Returns
Type Description
T[]

A k-hot vector where the indicated positions are one and the others are zero.

Type Parameters
Name Description
T
View Source

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

Creates a k-hot vector, where all values are zero except for the elements at the indicated indices, which are set to one.

Declaration
public static T[] KHot<T>(int[] indices, T[] result)
Parameters
Type Name Description
System.Int32[] indices

The vector's dimensions which will be marked as ones.

T[] result

The vector where the k-hot should be marked.

Returns
Type Description
T[]

A k-hot vector where the indicated positions are one and the others are zero.

Type Parameters
Name Description
T
View Source

KHot<T>(Int32[], Int32)

Creates a k-hot vector, where all values are zero except for the elements at the indicated indices, which are set to one.

Declaration
public static T[] KHot<T>(int[] indices, int columns)
Parameters
Type Name Description
System.Int32[] indices

The vector's dimensions which will be marked as ones.

System.Int32 columns

The size (length) of the vector.

Returns
Type Description
T[]

A k-hot vector where the indicated positions are one and the others are zero.

Type Parameters
Name Description
T
View Source

OneHot(Int32, Double[])

Creates a one-hot vector, where all values are zero except for the indicated index, which is set to one.

Declaration
public static double[] OneHot(int index, double[] result)
Parameters
Type Name Description
System.Int32 index

The vector's dimension which will be marked as one.

System.Double[] result

The vector where the one-hot should be marked.

Returns
Type Description
System.Double[]

A one-hot vector where only a single position is one and the others are zero.

View Source

OneHot(Int32, Int32)

Creates a one-hot vector, where all values are zero except for the indicated index, which is set to one.

Declaration
public static double[] OneHot(int index, int columns)
Parameters
Type Name Description
System.Int32 index

The vector's dimension which will be marked as one.

System.Int32 columns

The size (length) of the vector.

Returns
Type Description
System.Double[]

A one-hot vector where only a single position is one and the others are zero.

View Source

OneHot<T>(Boolean)

Creates a vector with the given value at the positions where mask is true, and zero when they are false.

Declaration
public static T[] OneHot<T>(bool mask)
Parameters
Type Name Description
System.Boolean mask

The boolean mask determining where the values will be placed.

Returns
Type Description
T[]
Type Parameters
Name Description
T
View Source

OneHot<T>(Boolean, T[])

Creates a vector with the given value at the positions where mask is true, and zero when they are false.

Declaration
public static T[] OneHot<T>(bool mask, T[] result)
Parameters
Type Name Description
System.Boolean mask

The boolean mask determining where the values will be placed.

T[] result

The vector where the one-hot should be marked.

Returns
Type Description
T[]
Type Parameters
Name Description
T
View Source

OneHot<T>(Int32, T[])

Creates a one-hot vector, where all values are zero except for the indicated index, which is set to one.

Declaration
public static T[] OneHot<T>(int index, T[] result)
Parameters
Type Name Description
System.Int32 index

The vector's dimension which will be marked as one.

T[] result

The vector where the one-hot should be marked.

Returns
Type Description
T[]

A one-hot vector where only a single position is one and the others are zero.

Type Parameters
Name Description
T

The data type for the vector.

View Source

OneHot<T>(Int32, Int32)

Creates a one-hot vector, where all values are zero except for the indicated index, which is set to one.

Declaration
public static T[] OneHot<T>(int index, int columns)
Parameters
Type Name Description
System.Int32 index

The vector's dimension which will be marked as one.

System.Int32 columns

The size (length) of the vector.

Returns
Type Description
T[]

A one-hot vector where only a single position is one and the others are zero.

Type Parameters
Name Description
T

The data type for the vector.

View Source

Ones(Boolean[])

Creates a vector with ones at the positions where mask is true, and zero when they are false.

Declaration
public static double[] Ones(bool[] mask)
Parameters
Type Name Description
System.Boolean[] mask

The boolean mask determining where ones will be placed.

Returns
Type Description
System.Double[]
View Source

Ones(Int32)

Creates a one-valued vector.

Declaration
public static double[] Ones(int size)
Parameters
Type Name Description
System.Int32 size

The number of elements in the vector.

Returns
Type Description
System.Double[]

A vector of the specified size.

View Source

Ones<T>(Boolean[])

Creates a vector with ones at the positions where mask is true, and zero when they are false.

Declaration
public static T[] Ones<T>(bool[] mask)
Parameters
Type Name Description
System.Boolean[] mask

The boolean mask determining where ones will be placed.

Returns
Type Description
T[]
Type Parameters
Name Description
T

The type of the vector to be created.

View Source

Ones<T>(Int32)

Creates a zero-valued vector.

Declaration
public static T[] Ones<T>(int size)
Parameters
Type Name Description
System.Int32 size

The number of elements in the vector.

Returns
Type Description
T[]

A vector of the specified size.

Type Parameters
Name Description
T

The type of the vector to be created.

View Source

Parse(String)

Converts the string representation of a vector to its double-precision floating-point number vector equivalent.

Declaration
public static double[] Parse(string str)
Parameters
Type Name Description
System.String str

The string representation of the matrix.

Returns
Type Description
System.Double[]

A double-precision floating-point number matrix parsed from the given string using the given format provider.

View Source

Parse(String, IMatrixFormatProvider)

Converts the string representation of a vector to its double-precision floating-point number vector equivalent.

Declaration
public static double[] Parse(string str, IMatrixFormatProvider provider)
Parameters
Type Name Description
System.String str

The string representation of the vector.

IMatrixFormatProvider provider

The format provider to use in the conversion. Default is to use CurrentCulture.

Returns
Type Description
System.Double[]

A double-precision floating-point number matrix parsed from the given string using the given format provider.

View Source

Random(Int32)

Creates a vector with uniformly distributed random data.

Declaration
public static double[] Random(int size)
Parameters
Type Name Description
System.Int32 size
Returns
Type Description
System.Double[]
View Source

Random(Int32, Double, Double)

Creates a vector with uniformly distributed random data.

Declaration
public static double[] Random(int size, double min, double max)
Parameters
Type Name Description
System.Int32 size
System.Double min
System.Double max
Returns
Type Description
System.Double[]
View Source

Random(Int32, Int32, Int32)

Creates a vector with uniformly distributed random data.

Declaration
public static int[] Random(int size, int min, int max)
Parameters
Type Name Description
System.Int32 size
System.Int32 min
System.Int32 max
Returns
Type Description
System.Int32[]
View Source

Range(NumericRange)

Creates a range vector (like NumPy's arange function).

Declaration
public static double[] Range(this NumericRange range)
Parameters
Type Name Description
NumericRange range

The range from where values should be created.

Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

Range(NumericRange, Double)

Creates a range vector (like NumPy's arange function).

Declaration
public static double[] Range(this NumericRange range, double stepSize)
Parameters
Type Name Description
NumericRange range

The range from where values should be created.

System.Double stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

Range(Double)

Creates a range vector (like NumPy's arange function).

Declaration
public static double[] Range(double n)
Parameters
Type Name Description
System.Double n

The exclusive upper bound of the range.

Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

Range(Double, Double)

Creates a range vector (like NumPy's arange function).

Declaration
public static double[] Range(double a, double b)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

Range(Double, Double, Byte)

Creates a range vector (like NumPy's arange function).

Declaration
public static double[] Range(double a, double b, byte stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.Byte stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

Range(Double, Double, Double)

Creates a range vector (like NumPy's arange function).

Declaration
public static double[] Range(double a, double b, double stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.Double stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

Range(Double, Double, Int16)

Creates a range vector (like NumPy's arange function).

Declaration
public static double[] Range(double a, double b, short stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.Int16 stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

Range(Double, Double, Int32)

Creates a range vector (like NumPy's arange function).

Declaration
public static double[] Range(double a, double b, int stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.Int32 stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

Range(Double, Double, Int64)

Creates a range vector (like NumPy's arange function).

Declaration
public static double[] Range(double a, double b, long stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.Int64 stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

Range(Double, Double, SByte)

Creates a range vector (like NumPy's arange function).

Declaration
public static double[] Range(double a, double b, sbyte stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.SByte stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

Range(Double, Double, UInt16)

Creates a range vector (like NumPy's arange function).

Declaration
public static double[] Range(double a, double b, ushort stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.UInt16 stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

Range(Double, Double, UInt64)

Creates a range vector (like NumPy's arange function).

Declaration
public static double[] Range(double a, double b, ulong stepSize)
Parameters
Type Name Description
System.Double a

The inclusive lower bound of the range.

System.Double b

The exclusive upper bound of the range.

System.UInt64 stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
System.Double[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

Range(Int32)

Creates a range vector (like NumPy's arange function).

Declaration
public static int[] Range(int n)
Parameters
Type Name Description
System.Int32 n

The exclusive upper bound of the range.

Returns
Type Description
System.Int32[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval methods.

View Source

Range(Int32, Int32)

Creates a range vector (like NumPy's arange function).

Declaration
public static int[] Range(int a, int b)
Parameters
Type Name Description
System.Int32 a

The inclusive lower bound of the range.

System.Int32 b

The exclusive upper bound of the range.

Returns
Type Description
System.Int32[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

Range(Int32, Int32, Int32)

Creates a range vector (like NumPy's arange function).

Declaration
public static int[] Range(int a, int b, int stepSize)
Parameters
Type Name Description
System.Int32 a

The inclusive lower bound of the range.

System.Int32 b

The exclusive upper bound of the range.

System.Int32 stepSize

The step size to be taken between elements. This parameter can be negative to create a decreasing range.

Returns
Type Description
System.Int32[]
Remarks

The Range methods should be equivalent to NumPy's np.arange method, with one single difference: when the intervals are inverted (i.e. a > b) and the step size is negative, the framework still iterates over the range backwards, as if the step was negative.

This function never includes the upper bound of the range. For methods that include it, please see the Interval(Int32, Int32) methods.

See Also
Interval(Int32, Int32)
View Source

Sample(Double, Int32)

Returns a vector of the specified percentage of the populationSize containing non-repeating indices in the range [0, populationSize) in random order.

Declaration
public static int[] Sample(double percentage, int populationSize)
Parameters
Type Name Description
System.Double percentage

The percentage of the population to sample.

System.Int32 populationSize

The non-inclusive maximum number an index can have.

Returns
Type Description
System.Int32[]
Examples
  var a = Vector.Sample(0.3, 10);  // a possible output is { 1, 7, 4 };
  var b = Vector.Sample(1.0, 10); // a possible output is { 5, 4, 2, 0, 1, 3, 7, 9, 8, 6 };

  foreach (var i in Vector.Sample(0.2, 6))
  {
     // ...
  }
View Source

Sample(Int32)

Returns a vector containing indices (0, 1, 2, ..., n - 1) in random order. The vector grows up to to size, but does not include size among its values.

Declaration
public static int[] Sample(int size)
Parameters
Type Name Description
System.Int32 size

The size of the sample vector to be generated.

Returns
Type Description
System.Int32[]
Examples
  var a = Vector.Sample(3);  // a possible output is { 2, 1, 0 };
  var b = Vector.Sample(10); // a possible output is { 5, 4, 2, 0, 1, 3, 7, 9, 8, 6 };

  foreach (var i in Vector.Sample(5))
  {
     // ...
  }
View Source

Sample(Int32, Int32)

Returns a vector of the specified sampleSize containing non-repeating indices in the range [0, populationSize) in random order.

Declaration
public static int[] Sample(int sampleSize, int populationSize)
Parameters
Type Name Description
System.Int32 sampleSize

The size of the sample vector to be generated.

System.Int32 populationSize

The non-inclusive maximum number an index can have.

Returns
Type Description
System.Int32[]
Remarks

In other words, this return a sample of size k from a population of size N, where k is the parameter sampleSize and N is the parameter populationSize.

Examples
  var a = Vector.Sample(3, 10);  // a possible output is { 1, 7, 4 };
  var b = Vector.Sample(10, 10); // a possible output is { 5, 4, 2, 0, 1, 3, 7, 9, 8, 6 };

  foreach (var i in Vector.Sample(5, 6))
  {
     // ...
  }
View Source

Sample<T>(T[], Int32, Boolean)

Draws a random sample from a group of observations, with or without repetitions.

Declaration
public static T[] Sample<T>(this T[] values, int size, bool replacement = false)
Parameters
Type Name Description
T[] values

The observation vector.

System.Int32 size

The size of the sample to be drawn (how many samples to get).

System.Boolean replacement

Whether to sample with replacement (repeating values) or without replacement (non-repeating values).

Returns
Type Description
T[]

A vector containing the samples drawn from values.

Type Parameters
Name Description
T

The type of the observations.

View Source

Scale(Double, NumericRange, NumericRange)

Converts values from one scale to another scale.

Declaration
public static double Scale(this double value, NumericRange fromRange, NumericRange toRange)
Parameters
Type Name Description
System.Double value
NumericRange fromRange
NumericRange toRange
Returns
Type Description
System.Double
View Source

Scale(Double, Double, Double, Double, Double)

Converts a value from one scale to another scale.

Declaration
public static double Scale(this double value, double fromMin, double fromMax, double toMin, double toMax)
Parameters
Type Name Description
System.Double value
System.Double fromMin
System.Double fromMax
System.Double toMin
System.Double toMax
Returns
Type Description
System.Double
View Source

Scale(Double[], NumericRange, NumericRange)

Converts values from one scale to another scale.

Declaration
public static double[] Scale(this double[] values, NumericRange fromRange, NumericRange toRange)
Parameters
Type Name Description
System.Double[] values
NumericRange fromRange
NumericRange toRange
Returns
Type Description
System.Double[]
View Source

Scale(Double[], NumericRange, NumericRange, Double[])

Converts values from one scale to another scale.

Declaration
public static double[] Scale(this double[] values, NumericRange fromRange, NumericRange toRange, double[] result)
Parameters
Type Name Description
System.Double[] values
NumericRange fromRange
NumericRange toRange
System.Double[] result
Returns
Type Description
System.Double[]
View Source

Scale(Double[], NumericRange, Double[])

Converts values from one scale to another scale.

Declaration
public static double[] Scale(this double[] values, NumericRange toRange, double[] result)
Parameters
Type Name Description
System.Double[] values
NumericRange toRange
System.Double[] result
Returns
Type Description
System.Double[]
View Source

Scale(Double[], Double, Double)

Converts values from one scale to another scale.

Declaration
public static double[] Scale(this double[] values, double toMin, double toMax)
Parameters
Type Name Description
System.Double[] values
System.Double toMin
System.Double toMax
Returns
Type Description
System.Double[]
View Source

Scale(Double[], Double, Double, Double, Double)

Converts values from one scale to another scale.

Declaration
public static double[] Scale(this double[] values, double fromMin, double fromMax, double toMin, double toMax)
Parameters
Type Name Description
System.Double[] values
System.Double fromMin
System.Double fromMax
System.Double toMin
System.Double toMax
Returns
Type Description
System.Double[]
View Source

Scale(Double[], Double, Double, Double, Double, Double[])

Converts values from one scale to another scale.

Declaration
public static double[] Scale(this double[] values, double fromMin, double fromMax, double toMin, double toMax, double[] result)
Parameters
Type Name Description
System.Double[] values
System.Double fromMin
System.Double fromMax
System.Double toMin
System.Double toMax
System.Double[] result
Returns
Type Description
System.Double[]
View Source

Scale(Double[], Double, Double, Double[])

Converts values from one scale to another scale.

Declaration
public static double[] Scale(this double[] values, double toMin, double toMax, double[] result)
Parameters
Type Name Description
System.Double[] values
System.Double toMin
System.Double toMax
System.Double[] result
Returns
Type Description
System.Double[]
View Source

Scale(Double[], Double, Double, Int32, Int32)

Converts values from one scale to another scale.

Declaration
public static double[] Scale(this double[] values, double fromMin, double fromMax, int toMin, int toMax)
Parameters
Type Name Description
System.Double[] values
System.Double fromMin
System.Double fromMax
System.Int32 toMin
System.Int32 toMax
Returns
Type Description
System.Double[]
View Source

Scale(Double[], Double, Double, Int32, Int32, Double[])

Converts values from one scale to another scale.

Declaration
public static double[] Scale(this double[] values, double fromMin, double fromMax, int toMin, int toMax, double[] result)
Parameters
Type Name Description
System.Double[] values
System.Double fromMin
System.Double fromMax
System.Int32 toMin
System.Int32 toMax
System.Double[] result
Returns
Type Description
System.Double[]
View Source

Scale(Double[], Double[], Double, Double, Double[][])

Converts values from one scale to another scale.

Declaration
public static double[][] Scale(double[] fromMin, double[] fromMax, double toMin, double toMax, double[][] x)
Parameters
Type Name Description
System.Double[] fromMin
System.Double[] fromMax
System.Double toMin
System.Double toMax
System.Double[][] x
Returns
Type Description
System.Double[][]
View Source

Scale(Double[], Int32, Int32)

Converts values from one scale to another scale.

Declaration
public static double[] Scale(this double[] values, int toMin, int toMax)
Parameters
Type Name Description
System.Double[] values
System.Int32 toMin
System.Int32 toMax
Returns
Type Description
System.Double[]
View Source

Shuffle<T>(T[])

Shuffles an array.

Declaration
public static void Shuffle<T>(this T[] array)
Parameters
Type Name Description
T[] array
Type Parameters
Name Description
T
View Source

Shuffle<T>(IList<T>)

Shuffles a collection.

Declaration
public static void Shuffle<T>(this IList<T> array)
Parameters
Type Name Description
IList<T> array
Type Parameters
Name Description
T
View Source

Shuffled<T>(T[])

Shuffles an array.

Declaration
public static T[] Shuffled<T>(this T[] array)
Parameters
Type Name Description
T[] array
Returns
Type Description
T[]
Type Parameters
Name Description
T
View Source

Shuffled<TList, T>(TList)

Shuffles a collection.

Declaration
public static TList Shuffled<TList, T>(this TList array)
    where TList : ICloneable, IList<T>
Parameters
Type Name Description
TList array
Returns
Type Description
TList
Type Parameters
Name Description
TList
T
View Source

Sort<T>(T[], Comparison<T>, Boolean, Boolean)

Sorts the elements of an entire one-dimensional array using the given comparison.

Declaration
public static void Sort<T>(this T[] values, Comparison<T> comparison, bool stable = false, bool asc = true)
Parameters
Type Name Description
T[] values
Comparison<T> comparison
System.Boolean stable
System.Boolean asc
Type Parameters
Name Description
T
View Source

Sort<T>(T[], Boolean, Boolean)

Sorts the elements of an entire one-dimensional array using the given comparison.

Declaration
public static void Sort<T>(this T[] values, bool stable = false, bool asc = true)
    where T : IComparable<T>
Parameters
Type Name Description
T[] values
System.Boolean stable
System.Boolean asc
Type Parameters
Name Description
T
View Source

Sort<T>(T[], out Int32[], Boolean, ComparerDirection)

Sorts the elements of an entire one-dimensional array using the given comparison.

Declaration
public static void Sort<T>(this T[] values, out int[] order, bool stable = false, ComparerDirection direction = default(ComparerDirection))
    where T : IComparable<T>
Parameters
Type Name Description
T[] values
System.Int32[] order
System.Boolean stable
ComparerDirection direction
Type Parameters
Name Description
T
View Source

Sorted<T>(T[], Comparison<T>, Boolean)

Sorts the elements of an entire one-dimensional array using the given comparison.

Declaration
public static T[] Sorted<T>(this T[] values, Comparison<T> comparison, bool stable = false)
Parameters
Type Name Description
T[] values
Comparison<T> comparison
System.Boolean stable
Returns
Type Description
T[]
Type Parameters
Name Description
T
View Source

Sorted<T>(T[], Boolean, Boolean)

Sorts the elements of an entire one-dimensional array using the given comparison.

Declaration
public static T[] Sorted<T>(this T[] values, bool stable = false, bool asc = true)
    where T : IComparable<T>
Parameters
Type Name Description
T[] values
System.Boolean stable
System.Boolean asc
Returns
Type Description
T[]
Type Parameters
Name Description
T
View Source

Sorted<T>(T[], out Int32[], Boolean, ComparerDirection)

Sorts the elements of an entire one-dimensional array using the given comparison.

Declaration
public static T[] Sorted<T>(this T[] values, out int[] order, bool stable = false, ComparerDirection direction = default(ComparerDirection))
    where T : IComparable<T>
Parameters
Type Name Description
T[] values
System.Int32[] order
System.Boolean stable
ComparerDirection direction
Returns
Type Description
T[]
Type Parameters
Name Description
T
View Source

Sorted<T>(ICollection<T>, Boolean)

Sorts the elements of an entire one-dimensional array using the given comparison.

Declaration
public static T[] Sorted<T>(this ICollection<T> values, bool stable = false)
    where T : IComparable<T>
Parameters
Type Name Description
ICollection<T> values
System.Boolean stable
Returns
Type Description
T[]
Type Parameters
Name Description
T
View Source

TryParse(String, IMatrixFormatProvider, out Double[])

Converts the string representation of a vector to its double-precision floating-point number vector equivalent. A return value indicates whether the conversion succeeded or failed.

Declaration
public static bool TryParse(string s, IMatrixFormatProvider provider, out double[] vector)
Parameters
Type Name Description
System.String s

The string representation of the vector.

IMatrixFormatProvider provider

The format provider to use in the conversion. Default is to use CurrentCulture.

System.Double[] vector

A double-precision floating-point number matrix parsed from the given string using the given format provider.

Returns
Type Description
System.Boolean
View Source

Zeros(Int32)

Creates a zero-valued vector.

Declaration
public static double[] Zeros(int size)
Parameters
Type Name Description
System.Int32 size

The number of elements in the vector.

Returns
Type Description
System.Double[]

A vector of the specified size.

View Source

Zeros<T>(Int32)

Creates a zero-valued vector.

Declaration
public static T[] Zeros<T>(int size)
Parameters
Type Name Description
System.Int32 size

The number of elements in the vector.

Returns
Type Description
T[]

A vector of the specified size.

Type Parameters
Name Description
T

The type of the vector to be created.

See Also

Jagged
Vector