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
I love the idea of using the hi and lo functions to get a subsection of the array, so that I can pass that subsection to a function and it can work on it oblivious to where it is in the array.
Unfortunately, that doesn't quite work properly. I have a 3D array of cells. For every cell, I need to check all the cells in the cardinal directions around it. I figured I could just use hi() and lo() to give me a 3x3x3 view of the cells around the cell I'm working on (using arr.hi(x-1,y-1,z-1).lo(2,2,2). I was hoping (because the documentation said nothing on edge cases) that when I'm on the edge of one of the dimensions (say, x = 0), this new view would have a view where x=0 pointed to theoretical x=-1 in the parent array. And I figured calling get(0, 1, 1) on that subview would give me null or undefined, as there is nothing to retrieve from the empty space beyond the edge of the array.
Instead, I find the subarray is badly shifted: the hi() function reverts to 0 instead of allowing a negative view range, and now I get a view of the 3D array one off in the +X direction, causing the whole operation to just be wrong.
Not sure how to do an "oblivious array operation" when there's something like this going on. I'm going to have to actually give the for-each function the whole array now or something.
Basically what I think should happen: Allow a view to be partially outside the range of the theoretical array, and return undefined when you try and query it. Throw an exception when you try and set out there.
The text was updated successfully, but these errors were encountered:
ndarray doesn't bounds check the arrays as it slows things down too much. If there is interest in this functionality, I might make a separate module that supports it.
I love the idea of using the hi and lo functions to get a subsection of the array, so that I can pass that subsection to a function and it can work on it oblivious to where it is in the array.
Unfortunately, that doesn't quite work properly. I have a 3D array of cells. For every cell, I need to check all the cells in the cardinal directions around it. I figured I could just use hi() and lo() to give me a 3x3x3 view of the cells around the cell I'm working on (using
arr.hi(x-1,y-1,z-1).lo(2,2,2)
. I was hoping (because the documentation said nothing on edge cases) that when I'm on the edge of one of the dimensions (say, x = 0), this new view would have a view where x=0 pointed to theoretical x=-1 in the parent array. And I figured calling get(0, 1, 1) on that subview would give menull
orundefined
, as there is nothing to retrieve from the empty space beyond the edge of the array.Instead, I find the subarray is badly shifted: the hi() function reverts to 0 instead of allowing a negative view range, and now I get a view of the 3D array one off in the +X direction, causing the whole operation to just be wrong.
Not sure how to do an "oblivious array operation" when there's something like this going on. I'm going to have to actually give the for-each function the whole array now or something.
Basically what I think should happen: Allow a view to be partially outside the range of the theoretical array, and return
undefined
when you try and query it. Throw an exception when you try and set out there.The text was updated successfully, but these errors were encountered: