| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
rows_dot_product.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_FWD_MAT_FUN_ROWS_DOT_PRODUCT_HPP
2 #define STAN_MATH_FWD_MAT_FUN_ROWS_DOT_PRODUCT_HPP
3
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5 #include <stan/math/prim/mat/fun/typedefs.hpp>
6 #include <stan/math/prim/mat/err/check_matching_dims.hpp>
7 #include <stan/math/fwd/mat/fun/typedefs.hpp>
8 #include <stan/math/fwd/mat/fun/dot_product.hpp>
9 #include <stan/math/fwd/core.hpp>
10 #include <vector>
11
12 namespace stan {
13 namespace math {
14
15 template<typename T, int R1, int C1, int R2, int C2>
16 inline
17 Eigen::Matrix<fvar<T>, R1, 1>
18 rows_dot_product(const Eigen::Matrix<fvar<T>, R1, C1>& v1,
19 const Eigen::Matrix<fvar<T>, R2, C2>& v2) {
20 stan::math::check_matching_dims("rows_dot_product",
21 "v1", v1,
22 "v2", v2);
23 Eigen::Matrix<fvar<T>, R1, 1> ret(v1.rows(), 1);
24 for (size_type j = 0; j < v1.rows(); ++j) {
25 Eigen::Matrix<fvar<T>, R1, C1> crow1 = v1.row(j);
26 Eigen::Matrix<fvar<T>, R2, C2> crow2 = v2.row(j);
27 ret(j, 0) = dot_product(crow1, crow2);
28 }
29 return ret;
30 }
31
32 template<typename T, int R1, int C1, int R2, int C2>
33 inline
34 Eigen::Matrix<fvar<T>, R1, 1>
35 rows_dot_product(const Eigen::Matrix<double, R1, C1>& v1,
36 const Eigen::Matrix<fvar<T>, R2, C2>& v2) {
37 stan::math::check_matching_dims("rows_dot_product",
38 "v1", v1,
39 "v2", v2);
40 Eigen::Matrix<fvar<T>, R1, 1> ret(v1.rows(), 1);
41 for (size_type j = 0; j < v1.rows(); ++j) {
42 Eigen::Matrix<double, R1, C1> crow = v1.row(j);
43 Eigen::Matrix<fvar<T>, R2, C2> crow2 = v2.row(j);
44 ret(j, 0) = dot_product(crow, crow2);
45 }
46 return ret;
47 }
48
49 template<typename T, int R1, int C1, int R2, int C2>
50 inline
51 Eigen::Matrix<fvar<T>, R1, 1>
52 rows_dot_product(const Eigen::Matrix<fvar<T>, R1, C1>& v1,
53 const Eigen::Matrix<double, R2, C2>& v2) {
54 stan::math::check_matching_dims("rows_dot_product",
55 "v1", v1,
56 "v2", v2);
57 Eigen::Matrix<fvar<T>, R1, 1> ret(v1.rows(), 1);
58 for (size_type j = 0; j < v1.rows(); ++j) {
59 Eigen::Matrix<fvar<T>, R1, C1> crow1 = v1.row(j);
60 Eigen::Matrix<double, R2, C2> crow = v2.row(j);
61 ret(j, 0) = dot_product(crow1, crow);
62 }
63 return ret;
64 }
65 }
66 }
67 #endif
typedefs.hpp
check_matching_dims.hpp
core.hpp
stan::math::size_type
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:13
stan::math::check_matching_dims
bool check_matching_dims(const char *function, const char *name1, const Eigen::Matrix< T1, R1, C1 > &y1, const char *name2, const Eigen::Matrix< T2, R2, C2 > &y2)
Return true if the two matrices are of the same size.
Definition: check_matching_dims.hpp:37
dot_product.hpp
stan::math::dot_product
fvar< T > dot_product(const Eigen::Matrix< fvar< T >, R1, C1 > &v1, const Eigen::Matrix< fvar< T >, R2, C2 > &v2)
Definition: dot_product.hpp:20
Eigen.hpp
stan::math::rows_dot_product
Eigen::Matrix< fvar< T >, R1, 1 > rows_dot_product(const Eigen::Matrix< fvar< T >, R1, C1 > &v1, const Eigen::Matrix< fvar< T >, R2, C2 > &v2)
Definition: rows_dot_product.hpp:18
stan::math::fvar
Definition: fvar.hpp:13
typedefs.hpp

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