Stan Math Library  2.20.0
reverse mode automatic differentiation
tcrossprod.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_TCROSSPROD_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_TCROSSPROD_HPP
3 
6 
7 namespace stan {
8 namespace math {
9 
16 inline matrix_d tcrossprod(const matrix_d& M) {
17  if (M.rows() == 0)
18  return matrix_d(0, 0);
19  if (M.rows() == 1)
20  return M * M.transpose();
21  matrix_d result(M.rows(), M.rows());
22  return result.setZero().selfadjointView<Eigen::Upper>().rankUpdate(M);
23 }
24 
25 } // namespace math
26 } // namespace stan
27 #endif
Eigen::Matrix< fvar< T >, R, R > tcrossprod(const Eigen::Matrix< fvar< T >, R, C > &m)
Definition: tcrossprod.hpp:12
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrix_d
Type for matrix of double values.
Definition: typedefs.hpp:19

     [ Stan Home Page ] © 2011–2018, Stan Development Team.