-
-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dense Iterator off by 1 #16
Comments
OK. Will investigate. P/S: you can just do this |
Thanks, this makes it more readable.
Probably this is related to some implementation details I don't quite understand at the moment. |
Yeah. So think of it as this:
Assuming that it's row-major with standard strides (12,4,1), the next increment of an index would cause this to happen:
But the last action cannot be done because the maximum size of the coordinate is 4. Coordinate cannot be greater than 3. So the algorithm will try a "carry", like you would carry a 1 when you add 9+1 = 10. So then the algorithm will try A[1, 3, 0], which will then also cause an error, then it will try A[2,0,0,], which will cause an error, there fore it will try the last carry, causing it to go to [0,0,0] Does that help? |
Ok, but why the
Unfortunately I'm still having issues with formatted output:
Figuring out right index there is pretty daunting. |
I'm currently trying to work thru your comment. Will take a while. Things I'll definitely check on is the weird formatting issue. Can you share the code that created that? |
Yes absolutely. I used the following snippet for test the tensor's output (the tensor.Data() and formatted): A separate issue I run into in my tests was that I had to work locally, directly in gorgonia/tensor. Apparently When importing a forked package gives me the following error: |
the common trick to that is to create the That's really more of a Go issue than anything. What I personally do is I checkout upstream branches from that dir |
OK.. so I had a look at it. Your code could be fixed by this:
I'm gonna think about having a store for current coord in iterators |
Although it is not immediately obvious why the copy is needed there (from client's perspective) this solution works for my current needs. Thanks. |
The solution for the iterators to return current coordinates would be to also have a copy of the current coordinate. Copies are a lot cheaper than the |
I'd love some input on what should be a better option |
Are you considering the alternative option in the attached link? |
which link? (sorry for being dense) |
It appears that in 3x3x3 tensor while iterating the iterator Start is not pointing to the first element so that all values are off by one index.
CODE:
The text was updated successfully, but these errors were encountered: