Stan Math Library  2.20.0
reverse mode automatic differentiation
rows_dot_self.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_FWD_MAT_FUN_ROWS_DOT_SELF_HPP
2 #define STAN_MATH_FWD_MAT_FUN_ROWS_DOT_SELF_HPP
3 
5 #include <stan/math/fwd/core.hpp>
7 
8 namespace stan {
9 namespace math {
10 
11 template <typename T, int R, int C>
12 inline Eigen::Matrix<fvar<T>, R, 1> rows_dot_self(
13  const Eigen::Matrix<fvar<T>, R, C>& x) {
14  Eigen::Matrix<fvar<T>, R, 1> ret(x.rows(), 1);
15  for (size_type i = 0; i < x.rows(); i++) {
16  Eigen::Matrix<fvar<T>, 1, C> crow = x.row(i);
17  ret(i, 0) = dot_self(crow);
18  }
19  return ret;
20 }
21 } // namespace math
22 } // namespace stan
23 #endif
Eigen::Matrix< fvar< T >, R, 1 > rows_dot_self(const Eigen::Matrix< fvar< T >, R, C > &x)
fvar< T > dot_self(const Eigen::Matrix< fvar< T >, R, C > &v)
Definition: dot_self.hpp:13
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
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.