public static void RowPush <T>(Narray <T> table, Narray <T> data) { if (table.Length1d() == 0) { table.Copy(data); table.Reshape(1, table.Length()); return; } CHECK_ARG(table.Dim(1) == data.Length(), "table.Dim(1) == data.Length()"); table.Reserve(table.Length1d() + data.Length()); table.SetDims(table.Dim(0) + 1, table.Dim(1), 0, 0); int irow = table.Dim(0) - 1; for (int k = 0; k < table.Dim(1); k++) { table[irow, k] = data.UnsafeAt1d(k); } }
public static float Median(Narray <int> a) { Narray <int> s = new Narray <int>(); s.Copy(a); s.Reshape(s.Length1d()); Quicksort(s); int n = s.Length(); if (n == 0) { return(0); } if ((n % 2) > 0) { return(s[n / 2]); } else { return((s[n / 2 - 1] + s[n / 2]) / 2.0f); } }
public static void Copy <S>(Narray <T> dest, Narray <S> src) { dest.Copy(src); }