Exemple #1
0
 /// <summary>
 /// Take the data held by the src array and put it into the dest array.
 /// The src array is made empty in the proceess.  This is an O(1) operation.
 /// </summary>
 public void Move(Narray <T> src)
 {
     this.data = src.data;
     for (int i = 0; i < 5; i++)
     {
         this.dims[i] = src.dims[i];
     }
     this.total     = src.total;
     this.allocated = src.allocated;
     src.Dealloc();
 }
Exemple #2
0
        /// <summary>
        /// Make the first array have the same dimensions as the second array.
        /// </summary>
        public Narray <T> MakeLike <S>(Narray <S> b)
        {
            if (SameDims(b))
            {
                return(this);
            }
            Narray <T> a = this;
            int        r = b.Rank();

            switch (r)
            {
            case 0:
                a.Dealloc();
                break;

            case 1:
                a.Resize(b.Dim(0));
                break;

            case 2:
                a.Resize(b.Dim(0), b.Dim(1));
                break;

            case 3:
                a.Resize(b.Dim(0), b.Dim(1), b.Dim(2));
                break;

            case 4:
                a.Resize(b.Dim(0), b.Dim(1), b.Dim(2), b.Dim(3));
                break;

            default:
                throw new Exception("bad rank");
            }
            return(this);
        }
Exemple #3
0
 public void Resize(int n)
 {
     data.Dealloc();
     data.Resize(n);
 }