/// <summary> /// Add outarray[i] + val /// </summary> public static void Add(Floatarray outarray, float val) { for (int i = 0; i < outarray.Length1d(); i++) { outarray.UnsafePut1d(i, outarray.UnsafeAt1d(i) + val); } }
/// <summary> /// Normalize the 1-norm of the array. /// </summary> public static void Normalize1(Floatarray a) { double scale = 1.0 / Norm1(a); for (int i = 0; i < a.Length1d(); i++) { a.UnsafePut1d(i, (float)(a.UnsafeAt1d(i) * scale)); } }
public static Floatarray operator /(Floatarray array, double val) { Floatarray res = array; for (int i = 0; i < array.Length1d(); i++) { res.UnsafePut1d(i, (float)(array.UnsafeAt1d(i) / val)); } return(res); }
public static Floatarray operator -(Floatarray array, float val) { Floatarray res = array; for (int i = 0; i < array.Length1d(); i++) { res.UnsafePut1d(i, array.UnsafeAt1d(i) - val); } return(res); }
public static void Shuffle <T>(Narray <T> values) { Floatarray temp = new Floatarray(values.Length()); Intarray index = new Intarray(); for (int i = 0; i < temp.Length(); i++) { temp.UnsafePut1d(i, DRandomizer.Default.drand()); } Quicksort(index, temp); Permute(values, index); }
public static Floatarray operator -(Floatarray outarray1, Floatarray array2) { if (!SameDims(outarray1, array2)) { throw new Exception("outarray1 and array2 must be same dims!"); } Floatarray res = outarray1; for (int i = 0; i < outarray1.Length1d(); i++) { res.UnsafePut1d(i, outarray1.UnsafeAt1d(i) - array2.UnsafeAt1d(i)); } return(res); }