-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add slicing for TriangularMap
class
#251
base: main
Are you sure you want to change the base?
Conversation
Test Results 1 files ± 0 1 suites ±0 0s ⏱️ ±0s For more details on these errors, see this check. Results for commit 7c4c91b. ± Comparison against base commit b6d75d3. This pull request removes 38 and adds 4 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
Test Results with Externally Built Libraries 1 files ± 0 1 suites ±0 0s ⏱️ ±0s For more details on these errors, see this check. Results for commit 7c4c91b. ± Comparison against base commit b6d75d3. This pull request removes 38 and adds 4 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
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.
Hey @dannys4 ! I think returning the triangular map is fine, but I think we might need to revise how the slicing is being performed.
I think it might be best to implement the Slice
function in the ConditionalMapBase
class and to have it slice by dimension, not by the potentially vector-valued components that make up the TriangularMap. I think this is more natural, although harder to implement, because it slices the map in a way that is equivalent to slicing the vector-valued output of the map. (i.e., map.Evaluate(x)[a:b] == map.Slice(a,b).Evaluate(x)
). If the boundaries of the slice land in the middle of one of the component outputs, we can then slice that block, which would be possible if the Slice
function was added to ConditionalMapBase
What do you think?
I'll leave it up to you, but I could imagine a few different options for the default ConditionalMapBase::Slice
implementation. We could leave it as pure virtual, we could throw a not implemented exception, or we could define and return a SlicedMap
class that simply evaluates the full map and slices the output.
Also for future reference, it's possible to downcast a shared pointer to a parent class (e.g., ConditionalMapBase
) to a child class (e.g., TriangularMap
) by using something like auto childPtr = std::dynamic_pointer_cast<ChildClass>(parentPtr);
.
It occurred to me that ConditionalMapBase should probably have a slice function, and I quite like the equivalence of
|
That sounds good to me. This is a great way to do this too, because it will make conditioning straight forward whenever we add a |
For completeness (and linking a mention), this partly solves #106 , but leaves |
@mparno need a nugget of C++ wisdom. Would you expect |
I have run into a moderately large problem-- for most cases, I end up calling While I'm not sure about the solution, I believe creating |
@dannys4 Just curious, where does this stand? I have some upcoming applications where this feature would be great to have. I know things will probably be slow over the the next couple of holiday weeks, but I would be happy to help push this over the finish line. |
To be completely frank, this is a little lower than I'd like on my priorities list. What's left, to my knowledge, is making the |
This PR adds the ability to slice a
TriangularMap
(using a contiguous slice in Julia/Python). I added bindings for those two languages (sorry @rubiop, no matlab ), but I haven't tested Python yet.I had to change the return type of
CreateTriangular
for this to actually work in practice, since you can't slice arbitrary objects of typeConditionalMapBase
(or useGetComponent
). If this presents a problem, or we usedConditionalMapBase
for a particular purpose, then I'd be happy to figure out what the best way forward is. Tagging @mparno particularly for this reason.