Skip to content
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

support arbitrary data type in function block's function signatures #2572

Closed
yizhang-yiz opened this issue Jul 8, 2018 · 8 comments
Closed

Comments

@yizhang-yiz
Copy link

yizhang-yiz commented Jul 8, 2018

Summary:

support arbitrary type in external C++ code so user_header.hpp can provide higher-order function support.

Description:

Currently external C++ function in Stan must be declared in functions block with full signature, e.g.

functions {
       real foo(real theta);
}
/*...*/
transformed parameters {
       x = foo(y);
}
/*...*/

This allows user-supplied function. One further step would be to allow user's functions with functor arguments, similar to what Stan has for ODE solvers. Specifically, with that one can do

functions {
       real foo(T func, real theta); /* similar to template */
       real bar(real x) {
/* define function bar */
}
}
/*...*/
transformed parameters {
       x = foo(bar, y);
}
/*...*/

With this user can supply both ordinary and higher-order functions through C++ headers. Essentially Stan would have some basic plugin mechanism.

I'm not sure how difficult it'll be to realize something like this.

Current Version:

v2.17.1

@yizhang-yiz yizhang-yiz changed the title support arbitrary data type in external C++ code support arbitrary data type in function block's function signatures Jul 8, 2018
@bgoodri
Copy link
Contributor

bgoodri commented Jul 11, 2018

@yizhang-yiz
Copy link
Author

Not a problem that I'm familiar with. Leave to you guys for a sanity check.

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Jul 12, 2018 via email

@yizhang-yiz
Copy link
Author

That's exactly the syntax I want to see. Is there a timeline for this feature?

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Jul 12, 2018 via email

@yizhang-yiz
Copy link
Author

Yes, something like

functions{
   func foo;
}

and allowing foo to be a higher-order function. I don't mind working on it but would need guidance as I know little about the lang part of Stan.

@bob-carpenter
Copy link
Contributor

bob-carpenter commented Jul 13, 2018 via email

@WardBrian
Copy link
Member

WardBrian commented Feb 14, 2024

There is a newer stanc3 issue which is similar: stan-dev/stanc3#1348
I'm going to close this older one in favor of it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants