Open bob-carpenter opened 3 years ago
I would like to work on this issue!
Hi, @tvrsimhan. That'd be great. We accept pull requests for issues. Please let us know if you have any questions about how to implement it or test it (questions on the issue are fine).
There are two possible ways to do this: either by adding the functions with inefficient autodiff implementations or by adding custom gradients. We'd accept the former, but the advantage in compute speed is from the latter.
Thank you, @bob-carpenter! In which directory should this be implemented? I read through the guide but I couldn't locate those directories. Also, please point me to any other links I can refer to! I'll try my best and get back to you with any questions I have!
I'll try to add custom gradients, but I'll get back to you if I have any trouble with it!
It should follow the other functions. That means a primitive (double
) implementation in stan/math/prim/fun
and then one with custom gradients in stan/math/rev/fun
. The primitive version needs thorough testing, then the reverse mode should be tested in the mix
directory for autodiff like the other matrix functions.
You can see how dot_self
is implemented as it has the same signature:
Thank you for your guidance! I'll do my best!
@tvrsimhan any update on this issue? Thanks.
@tvrsimhan the stan math docs have some examples to get started with as well
Ah sorry, was too quick to close. #2636 addressed the first point of the issue, the second one is still open. Reopening.
Description
We should have L1 and L2 norm functions in the Stan language. They have to be implemented in the math library first, which is what this PR is for. We want the functions, but ideally we want custom derivatives.
The definitions are:
The derivatives are:
norm1
andnorm2
in the Stan Math library with autodiff test framework testsnorm2
Current Version:
v4.1.0