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
// Trivial case where we have all positive strides...
41
+
if(this._iterationOrder===1){
42
+
returnthis._buffer[this._offset+idx];
43
+
}
44
+
// Trivial case where we have all negative strides...
45
+
if(this._iterationOrder===-1){
46
+
returnthis._buffer[this._offset-idx];
47
+
}
46
48
}
47
49
// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...
// Trivial case where we have all positive strides...
42
+
if(this._iterationOrder===1){
43
+
this._buffer[this._offset+idx]=v;
44
+
returnthis;
45
+
}
46
+
// Trivial case where we have all negative strides...
47
+
if(this._iterationOrder===-1){
48
+
this._buffer[this._offset-idx]=v;
49
+
returnthis;
50
+
}
49
51
}
50
52
// The approach which follows is to resolve a view index to its subscripts and then plug the subscripts into the standard formula for computing the linear index in the underlying data buffer...
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/ndarray/base/ctor/test/test.js
+142
Original file line number
Diff line number
Diff line change
@@ -1136,6 +1136,38 @@ tape( 'an ndarray constructor returns an instance which has an `iget` method for
1136
1136
t.end();
1137
1137
});
1138
1138
1139
+
tape('an ndarray constructor returns an instance which has an `iget` method for retrieving an array element using a linear index (row-major; noncontiguous)',functiontest(t){
tape('an ndarray constructor returns an instance which has an `iget` method for retrieving an array element using a linear index (column-major)',functiontest(t){
1140
1172
varstrides;
1141
1173
varbuffer;
@@ -1264,6 +1296,38 @@ tape( 'an ndarray constructor returns an instance which has an `iget` method for
1264
1296
t.end();
1265
1297
});
1266
1298
1299
+
tape('an ndarray constructor returns an instance which has an `iget` method for retrieving an array element using a linear index (column-major; noncontiguous)',functiontest(t){
tape('an ndarray constructor returns an instance which has a `set` method for setting an array element using subscripts (row-major)',functiontest(t){
1268
1332
varstrides;
1269
1333
varbuffer;
@@ -1732,6 +1796,45 @@ tape( 'an ndarray constructor returns an instance which has an `iset` method for
1732
1796
t.end();
1733
1797
});
1734
1798
1799
+
tape('an ndarray constructor returns an instance which has an `iset` method for setting an array element using a linear index (row-major; noncontiguous)',functiontest(t){
1800
+
varstrides;
1801
+
varbuffer;
1802
+
varoffset;
1803
+
vardtype;
1804
+
varorder;
1805
+
varshape;
1806
+
vararr;
1807
+
varf;
1808
+
1809
+
dtype='generic';
1810
+
buffer=[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0];
1811
+
shape=[2,2,1];
1812
+
order='row-major';
1813
+
strides=[4,1,1];
1814
+
offset=0;
1815
+
1816
+
f=ctor(dtype,shape.length);
1817
+
arr=f(buffer,shape,strides,offset,order);
1818
+
1819
+
t.strictEqual(hasOwnProp(arr,'iset'),false,'does not have own property');
tape('an ndarray constructor returns an instance which has an `iset` method for setting an array element using a linear index (column-major)',functiontest(t){
1736
1839
varstrides;
1737
1840
varbuffer;
@@ -1888,6 +1991,45 @@ tape( 'an ndarray constructor returns an instance which has an `iset` method for
1888
1991
t.end();
1889
1992
});
1890
1993
1994
+
tape('an ndarray constructor returns an instance which has an `iset` method for setting an array element using a linear index (column-major; noncontiguous)',functiontest(t){
1995
+
varstrides;
1996
+
varbuffer;
1997
+
varoffset;
1998
+
vardtype;
1999
+
varorder;
2000
+
varshape;
2001
+
vararr;
2002
+
varf;
2003
+
2004
+
dtype='generic';
2005
+
buffer=[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0];
2006
+
shape=[2,2,1];
2007
+
order='column-major';
2008
+
strides=[1,4,8];
2009
+
offset=0;
2010
+
2011
+
f=ctor(dtype,shape.length);
2012
+
arr=f(buffer,shape,strides,offset,order);
2013
+
2014
+
t.strictEqual(hasOwnProp(arr,'iset'),false,'does not have own property');
tape('an ndarray constructor returns an instance which has a `get` method for retrieving an array element using subscripts (row-major; codegen=false)',functiontest(t){
0 commit comments