Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 0 additions & 4 deletions stan/math/fwd/fun.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@
#include <stan/math/fwd/fun/ceil.hpp>
#include <stan/math/fwd/fun/cos.hpp>
#include <stan/math/fwd/fun/cosh.hpp>
#include <stan/math/fwd/fun/crossprod.hpp>
#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_self.hpp>
#include <stan/math/fwd/fun/Eigen_NumTraits.hpp>
#include <stan/math/fwd/fun/erf.hpp>
#include <stan/math/fwd/fun/erfc.hpp>
Expand Down Expand Up @@ -96,7 +93,6 @@
#include <stan/math/fwd/fun/softmax.hpp>
#include <stan/math/fwd/fun/sqrt.hpp>
#include <stan/math/fwd/fun/square.hpp>
#include <stan/math/fwd/fun/squared_distance.hpp>
#include <stan/math/fwd/fun/sum.hpp>
#include <stan/math/fwd/fun/tan.hpp>
#include <stan/math/fwd/fun/tanh.hpp>
Expand Down
22 changes: 0 additions & 22 deletions stan/math/fwd/fun/crossprod.hpp

This file was deleted.

9 changes: 5 additions & 4 deletions stan/math/fwd/fun/determinant.hpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#ifndef STAN_MATH_FWD_FUN_DETERMINANT_HPP
#define STAN_MATH_FWD_FUN_DETERMINANT_HPP

#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/err.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/fwd/core.hpp>

namespace stan {
namespace math {

template <typename T, int R, int C>
inline fvar<T> determinant(const Eigen::Matrix<fvar<T>, R, C>& m) {
template <typename EigMat, require_eigen_vt<is_fvar, EigMat>* = nullptr>
inline value_type_t<EigMat> determinant(const EigMat& m) {
check_square("determinant", "m", m);

const T vals = m.val().determinant();
return fvar<T>(vals, vals * (m.val().inverse() * m.d()).trace());
const typename value_type_t<EigMat>::Scalar vals = m.val().determinant();
return {vals, vals * (m.val().inverse() * m.d()).trace()};
}

} // namespace math
Expand Down
56 changes: 0 additions & 56 deletions stan/math/fwd/fun/divide.hpp

This file was deleted.

20 changes: 0 additions & 20 deletions stan/math/fwd/fun/dot_self.hpp

This file was deleted.

167 changes: 0 additions & 167 deletions stan/math/fwd/fun/squared_distance.hpp

This file was deleted.

10 changes: 6 additions & 4 deletions stan/math/fwd/fun/tcrossprod.hpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#ifndef STAN_MATH_FWD_FUN_TCROSSPROD_HPP
#define STAN_MATH_FWD_FUN_TCROSSPROD_HPP

#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/prim/fun/transpose.hpp>
#include <stan/math/fwd/fun/multiply.hpp>

namespace stan {
namespace math {

template <typename T, int R, int C>
inline Eigen::Matrix<fvar<T>, R, R> tcrossprod(
const Eigen::Matrix<fvar<T>, R, C>& m) {
template <typename EigMat, require_eigen_vt<is_fvar, EigMat>* = nullptr>
inline Eigen::Matrix<value_type_t<EigMat>, EigMat::RowsAtCompileTime,
EigMat::RowsAtCompileTime>
tcrossprod(const EigMat& m) {
Comment thread
SteveBronder marked this conversation as resolved.
if (m.rows() == 0) {
return {};
}
return multiply(m, transpose(m));
return multiply(m, m.transpose());
}

} // namespace math
Expand Down
3 changes: 1 addition & 2 deletions stan/math/fwd/fun/unit_vector_constrain.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
#define STAN_MATH_FWD_FUN_UNIT_VECTOR_CONSTRAIN_HPP

#include <stan/math/fwd/core.hpp>
#include <stan/math/fwd/fun/divide.hpp>
#include <stan/math/fwd/fun/dot_self.hpp>
#include <stan/math/fwd/fun/tcrossprod.hpp>
#include <stan/math/fwd/fun/sqrt.hpp>
#include <stan/math/prim/fun/divide.hpp>
#include <stan/math/prim/fun/dot_self.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/prim/fun/inv.hpp>
#include <stan/math/prim/fun/unit_vector_constrain.hpp>
Expand Down
7 changes: 5 additions & 2 deletions stan/math/prim/fun/crossprod.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef STAN_MATH_PRIM_FUN_CROSSPROD_HPP
#define STAN_MATH_PRIM_FUN_CROSSPROD_HPP

#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/fun/typedefs.hpp>
#include <stan/math/prim/fun/tcrossprod.hpp>

Expand All @@ -11,11 +12,13 @@ namespace math {
* Returns the result of pre-multiplying a matrix by its
* own transpose.
*
* @tparam EigMat type of the matrix (must be derived from \c Eigen::MatrixBase)
* @param M Matrix to multiply.
* @return Transpose of M times M
*/
inline matrix_d crossprod(const matrix_d& M) {
return tcrossprod(static_cast<matrix_d>(M.transpose()));
template <typename EigMat, require_eigen_t<EigMat>* = nullptr>
inline auto crossprod(const EigMat& M) {
return tcrossprod(M.transpose());
}

} // namespace math
Expand Down
Loading