Пример #1
0
            private static IndexArray Calculate(
                NdArray <T> source,
                int filterAxis,
                Func <NdArray <T>, bool> predicate,
                out IReadOnlyDictionary <int, int> axisIndexMap)
            {
                var tmpAxesMap = new Dictionary <int, int>();
                var from       = 0;
                var to         = 0;

                foreach (var part in source.AsEnumerable(filterAxis))
                {
                    if (predicate(part))
                    {
                        tmpAxesMap.Add(from, to);
                        ++from;
                    }

                    ++to;
                }

                axisIndexMap = tmpAxesMap;
                var newShape = source.Shape.ToArray();

                newShape[filterAxis] = from;
                return(newShape);
            }