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

Generalize operator-like functions #1628

Merged
merged 34 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
84b5ab6
generalized operator-like functions
t4c1 Jan 20, 2020
7d7779e
optimize fwd multiply
t4c1 Jan 20, 2020
4b50381
Merge commit '10cc6ba675743f09832c6749fbb1a92d74888bd2' into HEAD
yashikno Jan 20, 2020
3c23987
[Jenkins] auto-formatting by clang-format version 6.0.0 (tags/google/…
stan-buildbot Jan 20, 2020
7cd74ef
fixed call sites.
t4c1 Jan 20, 2020
8263fdb
fixed a test.
t4c1 Jan 20, 2020
fb2de8a
generalized transpose.hpp() input
t4c1 Jan 21, 2020
1fedd01
fixed transpose
t4c1 Jan 21, 2020
9029b14
[Jenkins] auto-formatting by clang-format version 5.0.2-svn328729-1~e…
stan-buildbot Jan 21, 2020
d73d0c8
removed compile time multiplicable requirements
t4c1 Jan 21, 2020
45319be
Merge commit '12cbb63adfcfb64440ade29e97a25db30c5ac8e2' into HEAD
yashikno Jan 21, 2020
f989b11
fix unnecessary vector to matrix conversions
t4c1 Jan 22, 2020
01a87f4
Merge commit '81248fdcd9bbd107f63cf8211333c2acbdbe5ed8' into HEAD
yashikno Jan 22, 2020
d34d6fe
[Jenkins] auto-formatting by clang-format version 6.0.0 (tags/google/…
stan-buildbot Jan 22, 2020
c68504a
addressed review comments
t4c1 Jan 22, 2020
aaa8c17
fix cpplint
t4c1 Jan 22, 2020
b98a5a0
[Jenkins] auto-formatting by clang-format version 6.0.0 (tags/google/…
stan-buildbot Jan 22, 2020
9445e07
Merge branch 'generalize_operators' of https://github.com/bstatcomp/m…
t4c1 Jan 22, 2020
9180fc6
generalized matrix_exp
t4c1 Jan 22, 2020
ed9b73a
Merge branch 'generalize_operators' of https://github.com/bstatcomp/m…
t4c1 Jan 22, 2020
f2b4e13
[Jenkins] auto-formatting by clang-format version 6.0.0 (tags/google/…
stan-buildbot Jan 22, 2020
d989040
replaced expression return values with matrices.
t4c1 Jan 27, 2020
ca27b44
fix dot_product
t4c1 Jan 28, 2020
e7d4d53
addressed review comments and generalized dot_product
t4c1 Feb 3, 2020
87d205c
Merge commit 'b3dde68ece20db22da4979175c07a4d42ccdc050' into HEAD
yashikno Feb 3, 2020
a9490b3
[Jenkins] auto-formatting by clang-format version 6.0.0 (tags/google/…
stan-buildbot Feb 3, 2020
c7162fd
added missing include
t4c1 Feb 3, 2020
b160720
one more header
t4c1 Feb 3, 2020
f88d89a
Merge branch 'develop' into generalize_operators
t4c1 Feb 10, 2020
d9284e8
Merge branch 'develop' into generalize_operators
t4c1 Feb 11, 2020
cf2b72d
fixed size zero multiply
t4c1 Feb 12, 2020
fb619c0
Merge branch 'develop' into generalize_operators
t4c1 Feb 12, 2020
5290f6b
fixed multiply templates
t4c1 Feb 12, 2020
9529ccc
addressed remaining review comments
t4c1 Feb 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion stan/math/fwd/fun.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <stan/math/fwd/fun/determinant.hpp>
#include <stan/math/fwd/fun/digamma.hpp>
#include <stan/math/fwd/fun/divide.hpp>
#include <stan/math/fwd/fun/dot_product.hpp>
#include <stan/math/fwd/fun/dot_self.hpp>
#include <stan/math/fwd/fun/Eigen_NumTraits.hpp>
#include <stan/math/fwd/fun/erf.hpp>
Expand Down
12 changes: 6 additions & 6 deletions stan/math/fwd/fun/columns_dot_product.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ inline Eigen::Matrix<fvar<T>, 1, C1> columns_dot_product(
check_matching_dims("columns_dot_product", "v1", v1, "v2", v2);
Eigen::Matrix<fvar<T>, 1, C1> ret(1, v1.cols());
for (size_type j = 0; j < v1.cols(); ++j) {
Eigen::Matrix<fvar<T>, R1, C1> ccol1 = v1.col(j);
Eigen::Matrix<fvar<T>, R2, C2> ccol2 = v2.col(j);
Eigen::Matrix<fvar<T>, R1, 1> ccol1 = v1.col(j);
Eigen::Matrix<fvar<T>, R2, 1> ccol2 = v2.col(j);
ret(0, j) = dot_product(ccol1, ccol2);
}
Comment on lines 16 to 22
Copy link
Collaborator

Choose a reason for hiding this comment

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

For these functions is there a reason not to use more generic templates like

template <typename EigMat1, typename EigMat2,
  typename = require_eigen_vt<is_fvar, EigMat1>,
  typename = require_eigen_vt<std::is_floating_point, EigMat2>>
inline auto columns_dot_product(
    const EigMat1& v1,
    const EigMat2& v2) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not intend to include columns_dot_product in this PR. This is just a bugfix, that was required for generalization some other functions. Now that functions don't return expressions anymore it is not needed, but I would leave it in.

return ret;
Expand All @@ -30,8 +30,8 @@ inline Eigen::Matrix<fvar<T>, 1, C1> columns_dot_product(
check_matching_dims("columns_dot_product", "v1", v1, "v2", v2);
Eigen::Matrix<fvar<T>, 1, C1> ret(1, v1.cols());
for (size_type j = 0; j < v1.cols(); ++j) {
Eigen::Matrix<fvar<T>, R1, C1> ccol1 = v1.col(j);
Eigen::Matrix<double, R2, C2> ccol = v2.col(j);
Eigen::Matrix<fvar<T>, R1, 1> ccol1 = v1.col(j);
Eigen::Matrix<double, R2, 1> ccol = v2.col(j);
ret(0, j) = dot_product(ccol1, ccol);
}
return ret;
Expand All @@ -44,8 +44,8 @@ inline Eigen::Matrix<fvar<T>, 1, C1> columns_dot_product(
check_matching_dims("columns_dot_product", "v1", v1, "v2", v2);
Eigen::Matrix<fvar<T>, 1, C1> ret(1, v1.cols());
for (size_type j = 0; j < v1.cols(); ++j) {
Eigen::Matrix<double, R1, C1> ccol = v1.col(j);
Eigen::Matrix<fvar<T>, R2, C2> ccol2 = v2.col(j);
Eigen::Matrix<double, R1, 1> ccol = v1.col(j);
Eigen::Matrix<fvar<T>, R2, 1> ccol2 = v2.col(j);
ret(0, j) = dot_product(ccol, ccol2);
}
return ret;
Expand Down
1 change: 1 addition & 0 deletions stan/math/fwd/fun/columns_dot_self.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/fwd/core.hpp>
#include <stan/math/fwd/fun/typedefs.hpp>
#include <stan/math/fwd/fun/dot_self.hpp>

namespace stan {
Expand Down
215 changes: 0 additions & 215 deletions stan/math/fwd/fun/dot_product.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion stan/math/fwd/fun/dot_self.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/fwd/core.hpp>
#include <stan/math/fwd/fun/dot_product.hpp>
#include <stan/math/prim/fun/dot_product.hpp>

namespace stan {
namespace math {
Expand Down
Loading