You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// If the user indicated that "any" order suffices (meaning the user does not care about ndarray order), then we use the default order, unless the input ndarray is either unequivocally "row-major" or "column-major" or configured as such....
222
228
if(order==='any'){
223
229
// Compute the layout order in order to ascertain whether an ndarray can be considered both "row-major" and "column-major":
224
-
ord=strides2order(buffer.strides);
230
+
ord=strides2order(getStrides(buffer,false));
225
231
226
232
// If the ndarray can be considered both "row-major" and "column-major", then use the default order; otherwise, use the ndarray's stated layout order...
227
233
if(ord===3){
228
234
order=defaults.order;
229
235
}else{
230
-
order=buffer.order;
236
+
order=getOrder(buffer);
231
237
}
232
238
}
233
239
// Otherwise, use the same order as the provided ndarray...
234
240
elseif(order==='same'){
235
-
order=buffer.order;
241
+
order=getOrder(buffer);
236
242
}
237
243
}else{
238
244
order=defaults.order;
@@ -276,9 +282,9 @@ function array() {
276
282
len=numel(shape);
277
283
}elseif(buffer){
278
284
if(FLG){
279
-
shape=buffer.shape;
280
-
ndims=buffer.ndims;
281
-
len=buffer.length;
285
+
shape=getShape(buffer,true);
286
+
ndims=shape.length;
287
+
len=numel(shape);
282
288
}elseif(opts.flatten&&isArray(buffer)){
283
289
shape=arrayShape(buffer);
284
290
osh=shape;// cache a reference to the inferred shape
@@ -299,15 +305,15 @@ function array() {
299
305
}
300
306
// If not provided a data buffer, create it; otherwise, see if we need to cast a provided data buffer to another data type or perform a copy...
301
307
if(FLG){
302
-
if(buffer.length!==len){
308
+
if(numel(buffer.shape)!==len){
303
309
thrownewRangeError('invalid arguments. Array shape is incompatible with provided data source. Number of data source elements does not match array shape.');
304
310
}
305
311
if(btype!==dtype||opts.copy){
306
312
buffer=copyView(buffer,dtype);
307
313
}else{
308
-
strides=buffer.strides;
309
-
offset=buffer.offset;
310
-
buffer=buffer.data;
314
+
strides=getStrides(buffer,true);
315
+
offset=getOffset(buffer);
316
+
buffer=getData(buffer);
311
317
if(strides.length<ndims){
312
318
// Account for augmented dimensions (note: expanding the strides array to account for prepended singleton dimensions does **not** affect the index offset):
0 commit comments