-
Notifications
You must be signed in to change notification settings - Fork 30
Add transpose node/symbol #405
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
base: main
Are you sure you want to change the base?
Conversation
dc1df20
to
f7cbaa2
Compare
// transpose indices | ||
std::reverse(multi_index.begin(), multi_index.end()); | ||
// convert multidimensional transpose indices to transpose flat index | ||
transpose_update.index = ravel_multi_index(multi_index, node_shape); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just realized there should be a way to condense the unravel_index
, the reverse
, and the ravel_multi_index
into one and make this faster. Will inspect tomorrow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a way but it is a bit of a brain twister
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Happy to review changes to indexing if any come down. Or merge as-is.
Finished C++ code and tests.
Added test for dynamic vector. Ensured that min(), max(), and integral() are stored in ValuesInfo and attached to node.
011143a
to
2e91c12
Compare
2e91c12
to
65302e0
Compare
transpose_diff.reserve(array_ptr_->size_diff(state)); | ||
|
||
for (const Update& update : pred_diff) { | ||
// make a copy of the update | ||
Update transpose_update = update; | ||
// convert the index to the transpose index | ||
transpose_update.index = convert_predecessor_index(update.index); | ||
// save the converted update | ||
transpose_diff.emplace_back(transpose_update); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could also replace this with something like
transpose_diff.assign(pred_diff.begin(), pred_diff.end());
std::transform(
transpose_diff.cbegin(),
transpose_diff.cend(),
transpose_diff.begin(),
[this](const Update& u) { return Update(convert_predecessor_index(u.index), u.old, u.value; }
);
or let convert_predecessor_index
take an Update
to make it even shorter.
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should also add a test for a scalar (0-d) array?
Closes #160