I’m opening this thread to ask some questions about issue #1011, the GP Functor specification. It’s been beautifully outlined for me, to make my job a lot easier/faster. I’m anticipating mostly C++ questions.
So I’m looking at the algebra solver to see how we’re passing in functional arguments. It looks like all the test cases written are declared as a struct, and then passed into the algebra solver with no arguments. I’ve also check out Bob’s lotka-volterra test case to see how user defined functions are are generated in C++, looks like we’ve got about the same thing as in the test cases (cmdstan 2.18):
can I assume any user defined function is generated in c++ as a struct?
with that said, for testing functional stuff can I just implement my own struct, as what’s done in: test/unit/math/rev/mat/functor/util_algebra_solver.hpp, for say, the RBF (cov_exp_quad)?
will the functionality break if a struct becomes a class? are there any C++ conventions we should follow?
anything else I can do to make sure what I’ve written is compatible with the language?
Whatever it is, it’ll act like a functor in that you’ll be able to apply it. We might replace the explicit structs with closures (lambdas) at some point, but they’re essentially structs under the hood.
Yes.
struct {
...
};
is just syntactic sugar for:
class {
public:
...
};
That’s a bit too open-ended to answer. Best thing to do is write a bit and have someone look it over if you’re worried about wandering too far down the wrong path.