Esempio n. 1
0
        protected void _ChangeColumnToRowLayout()
        {
            if (_Shape.NDim == 1)
            {
            }
            else if (_Shape.NDim == 2)
            {
                var puffer = Array.CreateInstance(_values.GetType().GetElementType(), _values.Length);

                var pufferShape = new Shape(_Shape.Dimensions);
                pufferShape.ChangeTensorLayout(1);

                for (int idx = 0; idx < _values.Length; idx++)
                {
                    puffer.SetValue(_values.GetValue(idx), pufferShape.GetIndexInShape(Shape.GetDimIndexOutShape(idx)));
                }

                _values = puffer;
            }
            else
            {
                var puffer = Array.CreateInstance(_values.GetType().GetElementType(), _values.Length);

                var pufferShape = new Shape(_Shape.Dimensions);
                pufferShape.ChangeTensorLayout(1);

                for (int idx = 0; idx < _values.Length; idx++)
                {
                    puffer.SetValue(_values.GetValue(idx), pufferShape.GetIndexInShape(Shape.GetDimIndexOutShape(idx)));
                }

                _values = puffer;
            }
            _TensorLayout = 1;
            Shape.ChangeTensorLayout(1);
        }
Esempio n. 2
0
 public NDStorage(Type dtype)
 {
     this.dtype = dtype;
     Shape      = new Shape(1);
     values     = Array.CreateInstance(dtype, 1);
 }
Esempio n. 3
0
 public NDArray zeros(Shape shape, Type dtype = null)
 {
     return(new NDArray(dtype == null? float64 : dtype, shape));
 }
Esempio n. 4
0
 public NDStorage()
 {
     dtype  = typeof(ValueType);
     Shape  = new Shape(1);
     values = new int[] { 0 };
 }