33using System ;
44using System . Numerics ;
55using System . Runtime . InteropServices ;
6+ using NumSharp . Backends . Unmanaged ;
67
78namespace NumSharp
89{
@@ -75,6 +76,24 @@ public interface IStorage : ICloneable
7576 /// <remarks>Does not copy <paramref name="values"/></remarks>
7677 void Allocate ( Array values ) ;
7778
79+ /// <summary>
80+ /// Assign this <see cref="ArraySlice{T}"/> as the internal array storage and assign <see cref="shape"/> to it.
81+ /// </summary>
82+ /// <param name="values">The array to set as internal data storage</param>
83+ /// <param name="shape">The shape of the array.</param>
84+ /// <param name="copy">Should perform a copy of <paramref name="values"/></param>
85+ /// <remarks>Does not copy <paramref name="values"/></remarks>
86+ void Allocate < T > ( ArraySlice < T > values , Shape shape , bool copy = false ) where T : unmanaged;
87+
88+ /// <summary>
89+ /// Allocate <paramref name="values"/> into memory.
90+ /// </summary>
91+ /// <param name="values">The array to set as internal data storage</param>
92+ /// <param name="shape">The shape of the array.</param>
93+ /// <param name="copy">Should perform a copy of <paramref name="values"/></param>
94+ /// <remarks>Does not copy <paramref name="values"/></remarks>
95+ void Allocate ( IArraySlice values , Shape shape , bool copy = false ) ;
96+
7897 /// <summary>
7998 /// Allocate <paramref name="values"/> into memory.
8099 /// </summary>
@@ -88,39 +107,39 @@ public interface IStorage : ICloneable
88107 /// </summary>
89108 /// <param name="values">The array to set as internal data storage</param>
90109 /// <remarks>Does not copy <paramref name="values"/></remarks>
91- void Allocate < T > ( T [ ] values ) ;
110+ void Allocate < T > ( T [ ] values ) where T : unmanaged ;
92111
93112 /// <summary>
94113 /// Get reference to internal data storage
95114 /// </summary>
96115 /// <returns>reference to internal storage as System.Array</returns>
97- Array GetData ( ) ;
116+ IArraySlice GetData ( ) ;
98117
99118 /// <summary>
100119 /// Clone internal storage and returns reference to it
101120 /// </summary>
102121 /// <returns>reference to cloned storage as System.Array</returns>
103- Array CloneData ( ) ;
122+ IArraySlice CloneData ( ) ;
104123
105124 /// <summary>
106125 /// Get reference to internal data storage and if necessary: copy and cast elements to new dtype of <typeparamref name="T"/>.
107126 /// </summary>
108127 /// <typeparam name="T">new storage data type</typeparam>
109128 /// <returns>reference to internal (casted) storage as T[]</returns>
110- T [ ] GetData < T > ( ) ;
129+ ArraySlice < T > GetData < T > ( ) where T : unmanaged ;
111130
112131 /// <summary>
113132 /// Attempts to cast internal storage to an array of type <typeparamref name="T"/> and returns the result, therefore results can be null.
114133 /// </summary>
115134 /// <typeparam name="T">The type that is expected.</typeparam>
116- T [ ] AsArray < T > ( ) ;
135+ ArraySlice < T > AsArray < T > ( ) where T : unmanaged ;
117136
118137 /// <summary>
119138 /// Get all elements from cloned storage as T[] and cast dtype
120139 /// </summary>
121140 /// <typeparam name="T">cloned storgae dtype</typeparam>
122141 /// <returns>reference to cloned storage as T[]</returns>
123- T [ ] CloneData < T > ( ) ;
142+ ArraySlice < T > CloneData < T > ( ) where T : unmanaged ;
124143
125144 /// <summary>
126145 /// Get single value from internal storage as type T and cast dtype to T
@@ -146,6 +165,13 @@ public interface IStorage : ICloneable
146165 /// <remarks>Does not copy values and doesn't change shape.</remarks>
147166 void ReplaceData ( Array values ) ;
148167
168+ /// <summary>
169+ /// Sets <see cref="values"/> as the internal data source and changes the internal storage data type to <see cref="values"/> type.
170+ /// </summary>
171+ /// <param name="values"></param>
172+ /// <remarks>Does not copy values and doesn't change shape.</remarks>
173+ void ReplaceData ( IArraySlice values ) ;
174+
149175 /// <summary>
150176 /// Set an Array to internal storage, cast it to new dtype and if necessary change dtype
151177 /// </summary>
@@ -175,9 +201,9 @@ public interface IStorage : ICloneable
175201 /// <param name="dimensions"></param>
176202 void Reshape ( params int [ ] dimensions ) ;
177203
178- Span < T > View < T > ( Slice slice = null ) ;
204+ ArraySlice < T > View < T > ( Slice slice = null ) where T : unmanaged ;
179205
180- Span < T > GetSpanData < T > ( Slice slice , params int [ ] indice ) ;
206+ ArraySlice < T > GetSpanData < T > ( Slice slice , params int [ ] indice ) where T : unmanaged ;
181207
182208 #region Get Methods
183209
0 commit comments