Exemplo n.º 1
0
        /// <summary>
        ///     Moves NdArray entity to new immutable NdArray.
        /// </summary>
        /// <remarks> This method will destroy this NdArray instance. </remarks>
        /// <returns></returns>
        public NdArray <T> MoveToImmutable()
        {
            var entity = Entity;

            Entity = null !;
            return(new NdArray <T>(entity));
        }
Exemplo n.º 2
0
 /// <inheritdoc />
 /// <summary>
 /// </summary>
 /// <param name="source"></param>
 /// <param name="slices"> [source.Rank != slices.Length] </param>
 public MutableSliceViewNdArrayImpl(MutableNdArrayImpl <T> source, IndexOrRange[] slices)
     : base(CalculateShape(source.Shape, slices))
 {
     Guard.AssertIndices(source.Shape, slices);
     _source = source;
     _slices = new IndexOrRange[slices.Length];
     Array.Copy(slices, _slices, slices.Length);
 }
Exemplo n.º 3
0
        /// <summary>
        ///     Creates new NdArray object.
        /// </summary>
        /// <param name="array"></param>
        internal MutableNdArray(Array array)
        {
            var shape = Enumerable
                        .Range(0, array.Rank)
                        .Select(array.GetLength)
                        .ToIndexArray();
            var entity = new RawNdArrayImpl <T>(shape);

            foreach (var(value, i) in array.Cast <T>().Select((x, i) => (x, i)))
            {
                entity.Buffer.Span[i] = value;
            }
            Entity = entity;
        }
Exemplo n.º 4
0
 /// <summary>
 ///     Creates new NdArray object with values and shapes.
 /// </summary>
 /// <param name="shape"> [<c>shape.Product() == array.Length</c>] </param>
 internal MutableNdArray(IndexArray shape)
 {
     Entity = new RawNdArrayImpl <T>(shape);
 }
Exemplo n.º 5
0
 /// <summary>
 ///     Creates new NdArray object with entity object.
 /// </summary>
 /// <param name="entity"></param>
 internal MutableNdArray(MutableNdArrayImpl <T> entity)
 {
     Entity = entity;
 }
 internal MutableReshapeViewNdArrayImpl(MutableNdArrayImpl <T> source, IndexArray shape)
     : base(shape)
 {
     _source = source;
 }