Neuro-VISOR  0.2.0
Visualize and interact with computational simulations using a virtual reality interface
C2M2.Utils.Array Class Reference

Utilities with quick but manual array operations for merging, filling, converting to lists, etc. More...

Static Public Member Functions

static T[] MergeArrays< T > (this T[] beginningArray, T[] endArray)
 Returns a new array with endArray concatenated onto the end of beginningArray More...
 
static T[] Fill< T > (this T[] array, T value)
 Fill a preallocated array of type T with identical values of type T. More...
 
static T[] Fill< T > (this T[] array, T value, int size)
 Fill an unallocated array of type T with identical values of type T. More...
 
static void FillArrayRandom (this int[] array, int min, int max)
 Fills float array with random numbers from min [inclusive] to max [inclusive] More...
 
static void FillArrayRandom (this float[] array, float min, float max)
 Fills float array with random numbers from min [inclusive] to max [inclusive] More...
 
static void FillArrayRandom (this double[] array, float min, float max)
 Fills double array with random numbers from min [inclusive] to max [inclusive] More...
 
static void FillArrayRandom (this double[] array, double min, double max)
 Fills double array with random numbers from min [inclusive] to max [inclusive] More...
 
static int[] ToArray (this List< int > list)
 
static float[] ToArray (this List< float > list)
 
static double[] ToArray (this List< double > list)
 
static Vector3[] ToArray (this List< Vector3 > list)
 
static List< int > ToList (this int[] array)
 
static List< float > ToList (this float[] array)
 
static List< double > ToList (this double[] array)
 
static float[] ToFloat (this double[] array)
 Cast an array of doubles into an array of floats More...
 
static int[] Reverse (this int[] array)
 
static float[] Reverse (this float[] array)
 
static double[] Reverse (this double[] array)
 
static void RescaleArray (this float[] array, float newMin, float newMax, float oldMin, float oldMax)
 Rescale each member of an array from (oldMin, oldMax) to (newMin, newMax) More...
 
static void RescaleArray (this float[] array, float newMin, float newMax)
 Rescale each member of an array from (oldMin, oldMax) to (newMin, newMax) More...
 
static float[] Times (this float[] array, float s)
 Multiplies every value in this array by s More...
 
static double[] Times (this double[] array, double s)
 Multiplies every value in this array by s More...
 
static T[] Subset< T > (this T[] array, int to, int from=0)
 Returns a subset of this array from [from] (inclusive) to [to] (exclusive) More...
 
static List< int > GetExtrema (this double[] array, bool includeEnds=false, bool onlyMaxima=false, bool onlyMinima=false)
 Returns a list of indices of the array/list's local extrema in the order in which they are found. More...
 
static List< int > GetExtrema (this List< double > list, bool includeEnds=false, bool onlyMaxima=false, bool onlyMinima=false)
 Returns a list of indices of the array/list's local extrema in the order in which they are found. More...
 
static List< int > GetExtrema (this List< float > list, bool includeEnds=false, bool usePivots=false, bool onlyMaxima=false, bool onlyMinima=false)
 Returns a list of indices of the array/list's local extrema in the order in which they are found. More...
 
static string ToStringFull (this double[] array)
 

Static Private Attributes

static Random rand = new Random()
 

Detailed Description

Utilities with quick but manual array operations for merging, filling, converting to lists, etc.

Relevant methods should vastly outperform System.Linq methods

Member Function Documentation

◆ Fill< T >() [1/2]

static T [] C2M2.Utils.Array.Fill< T > ( this T[]  array,
value 
)
static

Fill a preallocated array of type T with identical values of type T.

◆ Fill< T >() [2/2]

static T [] C2M2.Utils.Array.Fill< T > ( this T[]  array,
value,
int  size 
)
static

Fill an unallocated array of type T with identical values of type T.

◆ FillArrayRandom() [1/4]

static void C2M2.Utils.Array.FillArrayRandom ( this double[]  array,
double  min,
double  max 
)
static

Fills double array with random numbers from min [inclusive] to max [inclusive]

◆ FillArrayRandom() [2/4]

static void C2M2.Utils.Array.FillArrayRandom ( this double[]  array,
float  min,
float  max 
)
static

Fills double array with random numbers from min [inclusive] to max [inclusive]

TODO: rand.NextDouble() makes a number between 0 and 1, so min is not considered rn

◆ FillArrayRandom() [3/4]

static void C2M2.Utils.Array.FillArrayRandom ( this float[]  array,
float  min,
float  max 
)
static

Fills float array with random numbers from min [inclusive] to max [inclusive]

◆ FillArrayRandom() [4/4]

static void C2M2.Utils.Array.FillArrayRandom ( this int[]  array,
int  min,
int  max 
)
static

Fills float array with random numbers from min [inclusive] to max [inclusive]

◆ GetExtrema() [1/3]

static List<int> C2M2.Utils.Array.GetExtrema ( this double[]  array,
bool  includeEnds = false,
bool  onlyMaxima = false,
bool  onlyMinima = false 
)
static

Returns a list of indices of the array/list's local extrema in the order in which they are found.

Parameters
includeEndsIf true, also returns the first and last index of the array/list.
onlyMaximaIf true, only returns local maxima.
onlyMinimaIf true, only returns local minima.
Returns

◆ GetExtrema() [2/3]

static List<int> C2M2.Utils.Array.GetExtrema ( this List< double >  list,
bool  includeEnds = false,
bool  onlyMaxima = false,
bool  onlyMinima = false 
)
static

Returns a list of indices of the array/list's local extrema in the order in which they are found.

Parameters
includeEndsIf true, also returns the first and last index of the array/list.
onlyMaximaIf true, only returns local maxima.
onlyMinimaIf true, only returns local minima.
Returns

◆ GetExtrema() [3/3]

static List<int> C2M2.Utils.Array.GetExtrema ( this List< float >  list,
bool  includeEnds = false,
bool  usePivots = false,
bool  onlyMaxima = false,
bool  onlyMinima = false 
)
static

Returns a list of indices of the array/list's local extrema in the order in which they are found.

Parameters
includeEndsIf true, also returns the first and last index of the array/list.
usePivotsIf true, will use the first index of a found extrema: {0, 0.25, 1, 1, 1, 0.25} would return 2 as one extrema index.
onlyMaximaIf true, only returns local maxima.
onlyMinimaIf true, only returns local minima.
Returns

◆ MergeArrays< T >()

static T [] C2M2.Utils.Array.MergeArrays< T > ( this T[]  beginningArray,
T[]  endArray 
)
static

Returns a new array with endArray concatenated onto the end of beginningArray

◆ RescaleArray() [1/2]

static void C2M2.Utils.Array.RescaleArray ( this float[]  array,
float  newMin,
float  newMax 
)
static

Rescale each member of an array from (oldMin, oldMax) to (newMin, newMax)

◆ RescaleArray() [2/2]

static void C2M2.Utils.Array.RescaleArray ( this float[]  array,
float  newMin,
float  newMax,
float  oldMin,
float  oldMax 
)
static

Rescale each member of an array from (oldMin, oldMax) to (newMin, newMax)

◆ Reverse() [1/3]

static double [] C2M2.Utils.Array.Reverse ( this double[]  array)
static

◆ Reverse() [2/3]

static float [] C2M2.Utils.Array.Reverse ( this float[]  array)
static

◆ Reverse() [3/3]

static int [] C2M2.Utils.Array.Reverse ( this int[]  array)
static

◆ Subset< T >()

static T [] C2M2.Utils.Array.Subset< T > ( this T[]  array,
int  to,
int  from = 0 
)
static

Returns a subset of this array from [from] (inclusive) to [to] (exclusive)

Parameters
fromBeginning index (included in returned array)
toFinal index + 1 (not included in returned array)
Returns

◆ Times() [1/2]

static double [] C2M2.Utils.Array.Times ( this double[]  array,
double  s 
)
static

Multiplies every value in this array by s

◆ Times() [2/2]

static float [] C2M2.Utils.Array.Times ( this float[]  array,
float  s 
)
static

Multiplies every value in this array by s

◆ ToArray() [1/4]

static double [] C2M2.Utils.Array.ToArray ( this List< double >  list)
static

◆ ToArray() [2/4]

static float [] C2M2.Utils.Array.ToArray ( this List< float >  list)
static

◆ ToArray() [3/4]

static int [] C2M2.Utils.Array.ToArray ( this List< int >  list)
static

◆ ToArray() [4/4]

static Vector3 [] C2M2.Utils.Array.ToArray ( this List< Vector3 >  list)
static

◆ ToFloat()

static float [] C2M2.Utils.Array.ToFloat ( this double[]  array)
static

Cast an array of doubles into an array of floats

◆ ToList() [1/3]

static List<double> C2M2.Utils.Array.ToList ( this double[]  array)
static

◆ ToList() [2/3]

static List<float> C2M2.Utils.Array.ToList ( this float[]  array)
static

◆ ToList() [3/3]

static List<int> C2M2.Utils.Array.ToList ( this int[]  array)
static

◆ ToStringFull()

static string C2M2.Utils.Array.ToStringFull ( this double[]  array)
static

Member Data Documentation

◆ rand

Random C2M2.Utils.Array.rand = new Random()
staticprivate

The documentation for this class was generated from the following file: