| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5 #include <stan/math/prim/mat/fun/typedefs.hpp>
6
7 namespace stan {
8 namespace math {
9
16 inline matrix_d
17 tcrossprod(const matrix_d& M) {
18 if (M.rows() == 0)
19 return matrix_d(0, 0);
20 if (M.rows() == 1)
21 return M * M.transpose();
22 matrix_d result(M.rows(), M.rows());
23 return result
24 .setZero()
25 .selfadjointView<Eigen::Upper>()
26 .rankUpdate(M);
27 }
28
29 }
30 }
31 #endif
stan
Definition: log_sum_exp.hpp:8
stan::math::tcrossprod
Eigen::Matrix< fvar< T >, R, R > tcrossprod(const Eigen::Matrix< fvar< T >, R, C > &m)
Definition: tcrossprod.hpp:17
Eigen.hpp
stan::math::matrix_d
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrix_d
Type for matrix of double values.
Definition: typedefs.hpp:22
typedefs.hpp

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