Пример #1
0
 public SingleSelectWrapper(IArray2d <T> source, Kernel <T, R> kernel)
 {
     _source = source ?? throw new ArgumentNullException(nameof(source));
     _kernel = kernel ?? throw new ArgumentNullException(nameof(kernel));
     _h      = source.GetLength(0);
     _w      = source.GetLength(1);
     _km     = KernelMeasure.Measure(kernel);
     if (source is IRelQueryableArray2d <T> rqa)
     {
         if (rqa.BoundOptions[BoundsDirection.Top] != Bounds.Skip)
         {
             _km.xmin = 0;
         }
         if (rqa.BoundOptions[BoundsDirection.Bottom] != Bounds.Skip)
         {
             _km.xmax = 0;
         }
         if (rqa.BoundOptions[BoundsDirection.Left] != Bounds.Skip)
         {
             _km.ymin = 0;
         }
         if (rqa.BoundOptions[BoundsDirection.Right] != Bounds.Skip)
         {
             _km.ymax = 0;
         }
     }
 }
Пример #2
0
 public Cell(IArray2d <T> array, int x, int y)
 {
     _array = array ?? throw new ArgumentNullException(nameof(array));
     _h     = array.GetLength(0);
     _w     = array.GetLength(1);
     _x     = x; _y = y;
 }
Пример #3
0
        public DualSelectWrapper(IArray2d <T> left, IArray2d <A> right, Expression <Func <ICell <T>, ICell <A>, R> > kernel)
        {
            _left           = left ?? throw new ArgumentNullException(nameof(left));
            _right          = right ?? throw new ArgumentNullException(nameof(right));
            _kernel         = kernel ?? throw new ArgumentNullException(nameof(kernel));
            _compiledKernel = _kernel.Compile();

            _h = Min(left.GetLength(0), right.GetLength(0));
            _w = Min(left.GetLength(1), right.GetLength(1));

            _km = new KernelMeasure();
            var km1 = new KernelMeasure <T>(_km);
            var km2 = new KernelMeasure <A>(_km);

            _compiledKernel(km1, km2);
        }
Пример #4
0
        public RecurrentSelectWrapper(IArray2d <T> source, Func <ICell <T>, ICell <R>, R> kernel)
        {
            _source = source ?? throw new ArgumentNullException(nameof(source));
            _kernel = kernel ?? throw new ArgumentNullException(nameof(kernel));
            _h      = source.GetLength(0);
            _w      = source.GetLength(1);
            var m   = new KernelMeasure();
            var km1 = new KernelMeasure <T>(m);
            var km2 = new KernelMeasure <R>(m);

            kernel(km1, km2);
            _xmin = m.xmin;
            _xmax = m.xmax;
            _ymin = m.ymin;
            _ymax = m.ymax;
        }
Пример #5
0
        public static T Max <T>(this IArray2d <T> source)
            where T : IComparable <T>
        {
            T   max    = source[0, 0];
            int height = source.GetLength(0);
            int width  = source.GetLength(1);

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    if (max.CompareTo(source[i, j]) < 0)
                    {
                        max = source[i, j];
                    }
                }
            }
            return(max);
        }
Пример #6
0
        public DualSelectWrapper(IArray2d <T> left, IArray2d <A> right, Func <ICell <T>, ICell <A>, R> kernel)
        {
            _left   = left ?? throw new ArgumentNullException(nameof(left));
            _right  = right ?? throw new ArgumentNullException(nameof(right));
            _kernel = kernel ?? throw new ArgumentNullException(nameof(kernel));

            _h = Math.Min(left.GetLength(0), right.GetLength(0));
            _w = Math.Min(left.GetLength(1), right.GetLength(1));

            var m   = new KernelMeasure();
            var km1 = new KernelMeasure <T>(m);
            var km2 = new KernelMeasure <A>(m);

            kernel(km1, km2);
            _xmin = m.xmin;
            _xmax = m.xmax;
            _ymin = m.ymin;
            _ymax = m.ymax;
        }
Пример #7
0
 //public static IQueryableArray2d<T> AsDirect<T>(this IArray2d<T> source) => new ArrayWrapper<T>(source);
 public static IRelQueryableArray2d <T> AsRelative <T>(this IArray2d <T> source, BoundOptions bounds) => source.Wrap(bounds);
Пример #8
0
 public static ArrayWrapper <T> Wrap <T>(this IArray2d <T> array, BoundOptions bounds) => new ArrayWrapper <T>(array, bounds);
Пример #9
0
 public Cell(IArray2d <T> array) : this(array, 0, 0)
 {
 }
Пример #10
0
        private readonly T[] _data; // temporary public

        public FastArray2d(IArray2d size) : this(size.GetLength(0), size.GetLength(1))
        {
        }