Stan Math Library  2.20.0
reverse mode automatic differentiation
multiply_lower_tri_self_transpose.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_FWD_MAT_FUN_MULTIPLY_LOWER_TRI_SELF_TRANSPOSE_HPP
2 #define STAN_MATH_FWD_MAT_FUN_MULTIPLY_LOWER_TRI_SELF_TRANSPOSE_HPP
3 
7 #include <vector>
8 
9 namespace stan {
10 namespace math {
11 
12 template <typename T, int R, int C>
13 inline Eigen::Matrix<fvar<T>, R, R> multiply_lower_tri_self_transpose(
14  const Eigen::Matrix<fvar<T>, R, C>& m) {
15  if (m.rows() == 0)
16  return Eigen::Matrix<fvar<T>, R, R>(0, 0);
17  Eigen::Matrix<fvar<T>, R, C> L(m.rows(), m.cols());
18  L.setZero();
19 
20  for (size_type i = 0; i < m.rows(); i++) {
21  for (size_type j = 0; (j < i + 1) && (j < m.cols()); j++)
22  L(i, j) = m(i, j);
23  }
24  return multiply(L, transpose(L));
25 }
26 
27 } // namespace math
28 } // namespace stan
29 #endif
Eigen::Matrix< fvar< T >, R1, C1 > multiply(const Eigen::Matrix< fvar< T >, R1, C1 > &m, const fvar< T > &c)
Definition: multiply.hpp:14
Eigen::Matrix< fvar< T >, R, R > multiply_lower_tri_self_transpose(const Eigen::Matrix< fvar< T >, R, C > &m)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Type for sizes and indexes in an Eigen matrix with double e.
Definition: typedefs.hpp:11
matrix_cl transpose(const matrix_cl &src)
Takes the transpose of the matrix on the OpenCL device.
Definition: transpose.hpp:20
This template class represents scalars used in forward-mode automatic differentiation, which consist of values and directional derivatives of the specified template type.
Definition: fvar.hpp:41

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