Skip to content

Nditer tut #138

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

Closed
wants to merge 6 commits into from
Closed

Nditer tut #138

wants to merge 6 commits into from

Conversation

mwiebe
Copy link
Member

@mwiebe mwiebe commented Aug 13, 2011

Because of a query from Neal Becker (http://mail.scipy.org/pipermail/numpy-discussion/2011-August/058031.html), I've written an introductory tutorial-style document about the nditer in Python. This walks through nditer usage starting with basic iteration of one array, through broadcasting and iterator-allocated outputs, and finally covers accelerating the inner loop with Cython.

Please review and try out the examples!

@charris
Copy link
Member

charris commented Aug 14, 2011

Excellent tutorial!

@rgommers
Copy link
Member

Very nice.

@mwiebe
Copy link
Member Author

mwiebe commented Aug 15, 2011

Thanks for the feedback! I've added a new commit with links to this document from the two main places most people will start from.

inner loop out of the iterator and into your code. This way, NumPy's
vectorized operations can be used on larger chunks of the elements
being visited.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might give a short explanation/justification of calling this an External Loop. The wording is slightly confusing because it's not immediately clear how it relates to the 'inner loops' in, say, ufuncs. I'm not sure if external loop here refers to it being external to python or more like an outer loop.

@chrisjordansquire
Copy link
Contributor

Great tutorial. It'll be a great reference when I use the nditer for vectorizing stuff.

@mwiebe
Copy link
Member Author

mwiebe commented Aug 19, 2011

I've updated it to try to improve the areas pointed out by Chris. Thanks for the feedback!


When adding the 'out' parameter, we have to explicitly provide those flags,
because if someone passes in an array as 'out', the iterator will default
to 'readonly', and our inner loop would fail.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explaining why the interator defaults to readonly might help clarify this bit. I assume it is because of potential overlaps.

@mwiebe
Copy link
Member Author

mwiebe commented Aug 25, 2011

I've added a little more explaining why the iterator defaults operands to read-only.

@charris
Copy link
Member

charris commented Aug 26, 2011

Pushed in e53c055..4fb84e7.

@charris charris closed this Aug 26, 2011
luyahan pushed a commit to plctlab/numpy that referenced this pull request Apr 25, 2024
feat: Add vsub_[s8|s16|s32|s64|u8|u16|u32|u64|f32]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants