Stan  2.5.0
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tcrossprod.hpp
Go to the documentation of this file.
1 #ifndef STAN__MATH__MATRIX__TCROSSPROD_HPP
2 #define STAN__MATH__MATRIX__TCROSSPROD_HPP
3 
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
matrix_d tcrossprod(const matrix_d &M)
Returns the result of post-multiplying a matrix by its own transpose.
Definition: tcrossprod.hpp:17
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrix_d
Type for matrix of double values.
Definition: typedefs.hpp:23

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