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
im trying to create a list with some specific rules.
ex ) x :2, y:5
0, 0
0, 1
0, 2
0, 3
0, 4
1, 0
1, 1
1, 2
1, 3
1, 4
it should have 2 sets, y should be repeated for x times.
so the table shape should be [2, x * y].
1D data should look like [0, 1, 0, 2, 0, 3, 0, 4, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4]
it works fine until here but when i try to get myNdarray.get(0, 5), i expected 1 but gives 2 instead.
let x = 2;
let y = 4;
let datArr = []
for (let xx = 0; xx < x; xx++){
for (let yy = 0; yy < y; yy++){
datArr.push(xx)
datArr.push(yy)
// narr.
}
}
let narr = ndarray(new Float32Array(datArr), [2, x*y]);
console.log(narr)
console.log(narr.get(0, 5))
console.log(narr.get(1, 5))
The first thing that jumps out is the possibility of mistakes when making assumptions about the 1D data buffer. Can you use .set() instead and examine narr.data to see what it looks like instead of passing the data buffer directly? It's very slightly slower, but for the majority cases is equivalent and at least much less error-prone.
im trying to create a list with some specific rules.
ex ) x :2, y:5
0, 0
0, 1
0, 2
0, 3
0, 4
1, 0
1, 1
1, 2
1, 3
1, 4
it should have 2 sets,
y
should be repeated forx
times.so the table shape should be [2, x * y].
1D data should look like [0, 1, 0, 2, 0, 3, 0, 4, 1, 0, 1, 1, 1, 2, 1, 3, 1, 4]
it works fine until here but when i try to get
myNdarray.get(0, 5)
, i expected 1 but gives 2 instead.here is my test code, and
this is the log
what is happening?
am i using the wrong code?
The text was updated successfully, but these errors were encountered: