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

Add check_matching_dims for std::vector<eigen<var>> #2220

Merged
merged 15 commits into from
Jan 12, 2021

Conversation

rok-cesnovar
Copy link
Member

Summary

Fixes #2207

Mainly fixes this case:

std::vector<Eigen::Matrix<double, -1, 1>> z_1_offset;
std::vector<Eigen::Matrix<stan::math::var, -1, 1>> z_1;
size_t M_1 = 5;
size_t N_1 = 4;
z_1_offset = std::vector<Eigen::Matrix<double, -1, 1>>(M_1, Eigen::Matrix<double, -1, 1>(N_1));
z_1 = std::vector<Eigen::Matrix<stan::math::var, -1, 1>>(M_1, Eigen::Matrix<stan::math::var, -1, 1>(N_1));

check_matching_dims("constraint", "z_1", z_1, "offset", z_1_offset);

Tests

Added test for the case that caused the issue and a few others.

Side Effects

/

Release notes

Fixed a bug in check_matching_dims that prevented checking vectors of Eigen matrices of vars.

Checklist

  • Math issue #(issue number)

  • Copyright holder: (fill in copyright holder information)

    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)
  • the code is written in idiomatic C++ and changes are documented in the doxygen

  • the new changes are tested

@rok-cesnovar
Copy link
Member Author

The original bug in the is_rev_matrix template metaprogram was fixed in one of the varmat PRs. This PR now just fixes an ambiguity for the all-scalar case and adds tests so we dont reintroduce the original bug again.

@rok-cesnovar
Copy link
Member Author

The tests now pass so this is ready for review. Also checked that the problematic model @wds15 posted in the original issue compiles.

@stan-buildbot
Copy link
Contributor


Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 3.44 3.36 1.02 2.21% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 0.98 -2.54% slower
eight_schools/eight_schools.stan 0.11 0.12 0.92 -9.28% slower
gp_regr/gp_regr.stan 0.15 0.16 0.98 -1.86% slower
irt_2pl/irt_2pl.stan 5.11 5.24 0.98 -2.55% slower
performance.compilation 92.4 89.67 1.03 2.96% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 8.65 8.67 1.0 -0.21% slower
pkpd/one_comp_mm_elim_abs.stan 30.3 28.81 1.05 4.92% faster
sir/sir.stan 136.99 135.68 1.01 0.96% faster
gp_regr/gen_gp_data.stan 0.04 0.04 1.02 1.92% faster
low_dim_gauss_mix/low_dim_gauss_mix.stan 3.07 3.05 1.01 0.84% faster
pkpd/sim_one_comp_mm_elim_abs.stan 0.39 0.39 1.0 0.28% faster
arK/arK.stan 2.54 2.56 0.99 -0.76% slower
arma/arma.stan 0.62 0.62 0.99 -0.85% slower
garch/garch.stan 0.57 0.58 0.98 -2.06% slower
Mean result: 0.996952532213

Jenkins Console Log
Blue Ocean
Commit hash: 566e1b2


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

@rok-cesnovar rok-cesnovar merged commit 0e419e9 into develop Jan 12, 2021
@rok-cesnovar rok-cesnovar deleted the fix_check_matching_dims branch January 12, 2021 12:50
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.

check_matching_dims with std::vector<Eigen>
4 participants