2using System.Collections.Generic;
15 public static double[]
CumSum(IList<double> values)
17 if (values.Count == 0)
18 return Array.Empty<
double>();
21 var result =
new double[values.Count];
23 for (
int i = 0; i < values.Count; i++)
37 public static void CumSum(IList<double> values, List<double> result)
42 for (
int i = 0; i < values.Count; i++)
53 public static double[]
CumSum(IList<float> values)
55 if (values.Count == 0)
56 return Array.Empty<
double>();
59 var result =
new double[values.Count];
61 for (
int i = 0; i < values.Count; i++)
75 public static void CumSum(IList<float> values, List<double> result)
80 for (
int i = 0; i < values.Count; i++)
91 public static double[]
Softmax(IList<double> values)
93 if (values.Count == 0)
94 return Array.Empty<
double>();
97 var softmax =
new double[values.Count];
99 for (
int i = 0; i < softmax.Length; i++)
101 var value = Math.Exp(values[i]);
108 for (
int i = 0; i < softmax.Length; i++)
121 public static double[]
Softmax(IList<float> values)
123 if (values.Count == 0)
124 return Array.Empty<
double>();
127 var softmax =
new double[values.Count];
129 for (
int i = 0; i < softmax.Length; i++)
131 var value = Math.Exp(values[i]);
138 for (
int i = 0; i < softmax.Length; i++)
154 if (values.Count == 0)
158 var maxValue = values[0];
160 for (
int i = 1; i < values.Count; i++)
162 var value = values[i];
164 if (value > maxValue)
181 if (values.Count == 0)
185 var maxValue = values[0];
187 for (
int i = 1; i < values.Count; i++)
189 var value = values[i];
191 if (value > maxValue)
208 if (values.Count == 0)
212 var maxValue = values[0];
214 for (
int i = 1; i < values.Count; i++)
216 var value = values[i];
218 if (value > maxValue)
235 if (values.Count == 0)
239 var minValue = values[0];
241 for (
int i = 1; i < values.Count; i++)
243 var value = values[i];
245 if (value < minValue)
262 if (values.Count == 0)
266 var minValue = values[0];
268 for (
int i = 1; i < values.Count; i++)
270 var value = values[i];
272 if (value < minValue)
289 if (values.Count == 0)
293 var minValue = values[0];
295 for (
int i = 1; i < values.Count; i++)
297 var value = values[i];
299 if (value < minValue)
329 public static double Lerp(
double a,
double b,
double t)
342 return a * (1 - t) + b * t;
Contains extra math operations.
static void CumSum(IList< float > values, List< double > result)
Adds the cumulative sum of the list to teh specified results list.
static double[] Softmax(IList< double > values)
Returns the softmax of the collection of values.
static double Clamp01(double t)
Clamps the value between 0 and 1.
static double[] CumSum(IList< float > values)
Returns the cumulative sums of the list.
static int MaxIndex(IList< double > values)
Returns the index in the collection where the first maximum value occurs. Returns -1 if the collectio...
static int MaxIndex(IList< float > values)
Returns the index in the collection where the first maximum value occurs. Returns -1 if the collectio...
static int MinIndex(IList< float > values)
Returns the index in the collection where the first minimum value occurs. Returns -1 if the collectio...
static int MinIndex(IList< int > values)
Returns the index in the collection where the first minimum value occurs. Returns -1 if the collectio...
static int MinIndex(IList< double > values)
Returns the index in the collection where the first minimum value occurs. Returns -1 if the collectio...
static double LerpUnclamped(double a, double b, double t)
Linearly interpolates between two points based on a fractional distance parameter.
static double[] CumSum(IList< double > values)
Returns the cumulative sums of the list.
static void CumSum(IList< double > values, List< double > result)
Adds the cumulative sum of the list to teh specified results list.
static int MaxIndex(IList< int > values)
Returns the index in the collection where the first maximum value occurs. Returns -1 if the collectio...
static double[] Softmax(IList< float > values)
Returns the softmax of the collection of values.
static double Lerp(double a, double b, double t)
Linearly interpolates between two points based on a fractional distance parameter....