-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Implement num_traits::identities::{One, Zero}
for Variable
#133
Comments
Since Variable operations happen arround
For both of this cases we would either need to own Graph instead of having a reference or to have it passed as a parameter of the one function which in turn makes the use of the num_traits not possible. |
Hi thanks for the suggestions. Point 2 is not possible with the current implementation because we require a reference to a shared graph, or could make a new graph in the I am not sure what you mean by Point 1. Could you describe what you have in mind a bit more ? |
Both
we need a reference, hence a borrow of a graph when creating the One, Zero traits. Thus, maybe a declaration of an empty graph as a global
since a default variable may have an index equal to zero and the values are thus given by 0, 1 depending on the trait Zero, One respectively. Let me know what your thoughts are. |
I have thought about a global graph, but I am not sure because either:
|
I have implemented the functions using a Static empty graph. And added in the
Let me know what you think Edit: I omitted the part that there was the need of changing the Graphs to a thread safe construct from
|
Thanks for the example :) Are users able to create an arbitrary number of graphs, or is it a single global static ? And does this push any cloning/locking/unlocking onto the end user ? |
|
I'd be interested to see the code, do you have a branch or repo you can link me to ? |
Here is the branch forked from the RustQuant repository. |
With the It's not really meaningful though, since the index on the zero and one variables will not make sense, because there can be more than one variable with index 0 for example, so operations on these variables will be garbled. I could be mistaken so correct me if I'm wrong, but I think it does not solve the problem of needing |
W.l.o.g. lets talk about the One case. To answer the first question: we still have the need to use a static graph since the The other option I can think of is to create a custom function For the second note. I agree that there will be more than one variable with index 0. But is also true that without additional parameters there is no way we can infer the index of a new variable. (although maybe a global counter could work). e.g
But it is true that it does not solve the problem immediately. |
Seems I was too tired to recall Rust 101, thanks for pointing that out. I have not taken a proper look at this module for some time, but I am now interested again so I will have a look over the weekend and see if I can think of anything that might work. I appreciate the interest :) |
I need to find a reasonable way to implement the
num_traits::identities::{One, Zero}
traits for theVariable
type inRustQuant::autodiff
.The traits are here
The text was updated successfully, but these errors were encountered: