private static void Max_Inner(UniformDistributionSampler sampler, int len) { // Alloc arrays and fill with uniform random noise. float[] a = new float[len]; sampler.Sample(a); // Calc results and compare. float expected = PointwiseMax(a); float actual = MathSpan.Max(a); Assert.Equal(expected, actual); }
private static void Max_Inner(ISampler <int> sampler, int len) { // Alloc arrays and fill with uniform random noise. int[] a = new int[len]; sampler.Sample(a); // Calc results and compare. int expected = PointwiseMax(a); int actual = MathSpan.Max(a); Assert.Equal(expected, actual); }
private static LightweightList <int>[] BuildNodesByLayer(DirectedGraph digraph) { // Build an array that gives the node layer for each node, keyed by node index. int[] nodeLayerByIdx = BuildNodeLayerByIdx(digraph); // Group nodes into layers. int layerCount = MathSpan.Max(nodeLayerByIdx) + 1; var nodesByLayer = new LightweightList <int> [layerCount]; for (int i = 0; i < layerCount; i++) { nodesByLayer[i] = new LightweightList <int>(); } for (int nodeIdx = 0; nodeIdx < nodeLayerByIdx.Length; nodeIdx++) { int depth = nodeLayerByIdx[nodeIdx]; nodesByLayer[depth].Add(nodeIdx); } return(nodesByLayer); }