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

pow() for varmat #2546

Merged
merged 17 commits into from
Jul 10, 2022
Merged

pow() for varmat #2546

merged 17 commits into from
Jul 10, 2022

Conversation

SteveBronder
Copy link
Collaborator

Summary

This adds pow for var<Matrix> types. I thought it would be better as it's own PR since this is a vectorized binary functions that takes in all combinations of matrices and scalars (and std::vector<int>/std::vector<std::vector<int>>)

Tests

Tests added in mix for pow with varmat as well as all of the vectorizable input types.

./': ./runTests.py -j28 ./test/unit/math/mix/fun/ -f /pow

Side Effects

Nope!

Release notes

Replace this text with a short note on what will change if this pull request is merged in which case this will be included in the release notes.

Checklist

  • Math issue How to add static matrix? #1805

  • Copyright holder: Steve Bronder

    The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
    - Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
    - Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

  • the basic tests are passing

    • unit tests pass (to run, use: ./runTests.py test/unit)
    • header checks pass, (make test-headers)
    • dependencies checks pass, (make test-math-dependencies)
    • docs build, (make doxygen)
    • code passes the built in C++ standards checks (make cpplint)
  • [x the code is written in idiomatic C++ and changes are documented in the doxygen

  • the new changes are tested

@stan-buildbot
Copy link
Contributor


Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 3.11 3.05 1.02 1.73% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 1.02 2.36% faster
eight_schools/eight_schools.stan 0.12 0.12 1.0 -0.23% slower
gp_regr/gp_regr.stan 0.16 0.16 1.01 1.12% faster
irt_2pl/irt_2pl.stan 5.88 5.95 0.99 -1.26% slower
performance.compilation 87.9 86.78 1.01 1.27% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 8.58 8.59 1.0 -0.15% slower
pkpd/one_comp_mm_elim_abs.stan 31.08 29.58 1.05 4.82% faster
sir/sir.stan 122.32 119.95 1.02 1.94% faster
gp_regr/gen_gp_data.stan 0.03 0.03 0.99 -0.91% slower
low_dim_gauss_mix/low_dim_gauss_mix.stan 3.0 2.99 1.0 0.18% faster
pkpd/sim_one_comp_mm_elim_abs.stan 0.42 0.4 1.03 3.22% faster
arK/arK.stan 2.53 2.54 1.0 -0.35% slower
arma/arma.stan 0.66 0.65 1.02 1.93% faster
garch/garch.stan 0.65 0.64 1.01 1.36% faster
Mean result: 1.0117451219

Jenkins Console Log
Blue Ocean
Commit hash: 74cab27


Machine information ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010

CPU:
Intel(R) Xeon(R) CPU E5-1680 v2 @ 3.00GHz

G++:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

Clang:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

@SteveBronder
Copy link
Collaborator Author

@andrjohns would you mind taking a look at this?

Copy link
Collaborator

@andrjohns andrjohns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for taking so long to get to this! I think with these binary functions where we need overloads for the various combinations of scalar/matrix/arith/var, we're going to end up with a lot of code duplication if we're not careful.

I know you've mentioned before that you're not a huge fan of the forward_as approach because it's more abstract, but I think we're going to end up with much more code to maintain otherwise

stan/math/prim/fun/pow.hpp Show resolved Hide resolved
stan/math/rev/fun/pow.hpp Show resolved Hide resolved
@syclik
Copy link
Member

syclik commented Jun 16, 2022

@SteveBronder, I merged develop back in... let's see if the tests get kicked off again.

@andrjohns
Copy link
Collaborator

@SteveBronder this was something I was keen to have in, so I made some changes and updates after merging develop. Feel absolutely free to revert/change anything you disagree with!

@SteveBronder
Copy link
Collaborator Author

Thanks @andrjohns those changes look good to me!

@rok-cesnovar rok-cesnovar merged commit e4b9bde into develop Jul 10, 2022
@rok-cesnovar rok-cesnovar deleted the feature/varmat-pow branch July 10, 2022 08:10
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

Successfully merging this pull request may close these issues.

None yet

6 participants