Skip to content

Backstrides iteration#110

Merged
JohanMabille merged 1 commit into
xtensor-stack:masterfrom
SylvainCorlay:backstrides_iteration
Sep 6, 2017
Merged

Backstrides iteration#110
JohanMabille merged 1 commit into
xtensor-stack:masterfrom
SylvainCorlay:backstrides_iteration

Conversation

@SylvainCorlay
Copy link
Copy Markdown
Member

No description provided.

Comment thread include/xtensor-python/pyarray.hpp Outdated
{
value_type sh = p_a->shape()[m_offset];
value_type res = sh == 1 ? 0 : (sh - 1) * p_a->strides()[m_offset];
return res;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think taking a pointer on the backstrides object instead of the pyarray would allow to make this method call pyarray_backstrides::operator[] and would avoid code duplication.

// Returning the address of a temporary
value_type sh = p_a->shape()[m_offset];
value_type res = sh == 1 ? 0 : (sh - 1) * p_a->strides()[m_offset];
return &res;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same remark as above

Comment thread include/xtensor-python/pyarray.hpp Outdated
auto index = m_offset + n;
value_type sh = p_a->shape()[index];
value_type res = sh == 1 ? 0 : (sh - 1) * p_a->strides()[index];
return res;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

idem

@SylvainCorlay
Copy link
Copy Markdown
Member Author

Done!

@JohanMabille JohanMabille merged commit dbd3a2f into xtensor-stack:master Sep 6, 2017
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.

2 participants