示例#1
0
        public NDArray this[string slice]
        {
            get
            {
                var s = new Slice(slice);
                s.Start = s.Start.HasValue ? s.Start.Value : 0;
                s.Stop  = s.Stop.HasValue ? s.Stop.Value : shape[0];
                var nd = new NDArray(Array, new int[] { s.Length.Value }.Concat(Shape.GetShape(shape, 0)).ToArray());
                nd.Storage.Slice = s;
                return(nd);
            }

            set
            {
                throw new NotImplementedException("slice data set is not implemented.");
            }
        }
示例#2
0
        private NDArray setValue <T>(NDArray indexes)
        {
            Shape newShape = new int[] { indexes.size }.Concat(shape.Skip(1)).ToArray();
            var   buf   = Data <T>();
            var   idx   = indexes.Data <int>();
            var   array = new T[newShape.Size];

            var indice = Shape.GetShape(newShape.Dimensions, axis: 0);
            var length = Shape.GetSize(indice);

            for (var row = 0; row < newShape[0]; row++)
            {
                var d = buf.AsSpan(idx[row] * length, length);
                d.CopyTo(array.AsSpan(row * length));
            }

            var nd = new NDArray(array, newShape);

            return(nd);
        }