-
-
Notifications
You must be signed in to change notification settings - Fork 207
Add derivatives for mvn #2980
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
Merged
+251
−43
Merged
Add derivatives for mvn #2980
Changes from 5 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
b6d0cf0
add derivatives for mvn
spinkney bdc7e52
Merge commit 'f627912fecfbbb57bbf80a39e1987a499e05f589' into HEAD
yashikno 208658a
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot 1505d55
fix test and remove some includes not used
spinkney 50335c4
Merge branch 'multi-normal-derivatives-2' of https://github.com/stan-…
spinkney 69ccbcd
add value_of as per reviewer
spinkney b733c7f
update both
spinkney 8afeba0
remove unnecessary declaration
spinkney 9d1c773
fix multiplication
spinkney 204cce8
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot cc398d0
Update multi_normal_lpdf.hpp
spinkney 75d8a9e
Merge commit '754e94e31d992721829da631a33fe34d4af6b0d8' into HEAD
yashikno a6ec92c
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot e8a0b79
cleanup
spinkney ba13cb7
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot 057c18b
fix header
spinkney a2360de
Merge branch 'multi-normal-derivatives-2' of https://github.com/stan-…
spinkney 27584b0
more cleanup
spinkney 53ba6d8
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot 5530904
fix CI test
spinkney 636a94e
use vector instead of matrix
spinkney bc48cbb
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot f21fe28
Update multi_normal_lpdf.hpp
spinkney 53018f5
final update
spinkney bac7e60
[Jenkins] auto-formatting by clang-format version 10.0.0-4ubuntu1
stan-buildbot 479c04b
Merge branch 'develop' into multi-normal-derivatives-2
spinkney 52b36e6
Merge branch 'develop' into multi-normal-derivatives-2
spinkney File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| #include <stan/math/rev.hpp> | ||
| #include <test/unit/math/rev/util.hpp> | ||
| #include <gtest/gtest.h> | ||
|
|
||
| TEST(ProbDistributionsMultiNormal, MultiNormalVar) { | ||
| using Eigen::Dynamic; | ||
| using Eigen::Matrix; | ||
| using stan::math::var; | ||
| using std::vector; | ||
| Matrix<var, Dynamic, 1> y(3, 1); | ||
| y << 2.0, -2.0, 11.0; | ||
| Matrix<var, Dynamic, 1> mu(3, 1); | ||
| mu << 1.0, -1.0, 3.0; | ||
| Matrix<var, Dynamic, Dynamic> Sigma(3, 3); | ||
| Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; | ||
| EXPECT_FLOAT_EQ(-11.73908, stan::math::multi_normal_lpdf(y, mu, Sigma).val()); | ||
| } | ||
|
|
||
| TEST(ProbDistributionsMultiNormal, check_varis_on_stack) { | ||
| using Eigen::Dynamic; | ||
| using Eigen::Matrix; | ||
| using stan::math::to_var; | ||
| using std::vector; | ||
| Matrix<double, Dynamic, 1> y(3, 1); | ||
| y << 2.0, -2.0, 11.0; | ||
| Matrix<double, Dynamic, 1> mu(3, 1); | ||
| mu << 1.0, -1.0, 3.0; | ||
| Matrix<double, Dynamic, Dynamic> Sigma(3, 3); | ||
| Sigma << 9.0, -3.0, 0.0, -3.0, 4.0, 0.0, 0.0, 0.0, 5.0; | ||
| test::check_varis_on_stack(stan::math::multi_normal_lpdf<true>( | ||
| to_var(y), to_var(mu), to_var(Sigma))); | ||
| test::check_varis_on_stack( | ||
| stan::math::multi_normal_lpdf<true>(to_var(y), to_var(mu), Sigma)); | ||
| test::check_varis_on_stack( | ||
| stan::math::multi_normal_lpdf<true>(to_var(y), mu, to_var(Sigma))); | ||
| test::check_varis_on_stack( | ||
| stan::math::multi_normal_lpdf<true>(to_var(y), mu, Sigma)); | ||
| test::check_varis_on_stack( | ||
| stan::math::multi_normal_lpdf<true>(y, to_var(mu), to_var(Sigma))); | ||
| test::check_varis_on_stack( | ||
| stan::math::multi_normal_lpdf<true>(y, to_var(mu), Sigma)); | ||
| test::check_varis_on_stack( | ||
| stan::math::multi_normal_lpdf<true>(y, mu, to_var(Sigma))); | ||
|
|
||
| test::check_varis_on_stack(stan::math::multi_normal_lpdf<false>( | ||
| to_var(y), to_var(mu), to_var(Sigma))); | ||
| test::check_varis_on_stack( | ||
| stan::math::multi_normal_lpdf<false>(to_var(y), to_var(mu), Sigma)); | ||
| test::check_varis_on_stack( | ||
| stan::math::multi_normal_lpdf<false>(to_var(y), mu, to_var(Sigma))); | ||
| test::check_varis_on_stack( | ||
| stan::math::multi_normal_lpdf<false>(to_var(y), mu, Sigma)); | ||
| test::check_varis_on_stack( | ||
| stan::math::multi_normal_lpdf<false>(y, to_var(mu), to_var(Sigma))); | ||
| test::check_varis_on_stack( | ||
| stan::math::multi_normal_lpdf<false>(y, to_var(mu), Sigma)); | ||
| test::check_varis_on_stack( | ||
| stan::math::multi_normal_lpdf<false>(y, mu, to_var(Sigma))); | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.