1 #ifndef STAN_MATH_FWD_MAT_FUN_MULTIPLY_HPP
2 #define STAN_MATH_FWD_MAT_FUN_MULTIPLY_HPP
11 #include <boost/math/tools/promotion.hpp>
17 template<
typename T,
int R1,
int C1>
19 Eigen::Matrix<fvar<T>, R1, C1>
21 Eigen::Matrix<fvar<T>, R1, C1> res(m.rows(), m.cols());
22 for (
int i = 0; i < m.rows(); i++) {
23 for (
int j = 0; j < m.cols(); j++)
24 res(i, j) = c * m(i, j);
29 template<
typename T,
int R2,
int C2>
31 Eigen::Matrix<fvar<T>, R2, C2>
33 Eigen::Matrix<fvar<T>, R2, C2> res(m.rows(), m.cols());
34 for (
int i = 0; i < m.rows(); i++) {
35 for (
int j = 0; j < m.cols(); j++)
36 res(i, j) = c * m(i, j);
41 template<
typename T,
int R1,
int C1>
43 Eigen::Matrix<fvar<T>, R1, C1>
45 Eigen::Matrix<fvar<T>, R1, C1> res(m.rows(), m.cols());
46 for (
int i = 0; i < m.rows(); i++) {
47 for (
int j = 0; j < m.cols(); j++)
48 res(i, j) = c * m(i, j);
53 template<
typename T,
int R1,
int C1>
55 Eigen::Matrix<fvar<T>, R1, C1>
60 template<
typename T,
int R1,
int C1>
62 Eigen::Matrix<fvar<T>, R1, C1>
67 template<
typename T,
int R1,
int C1>
69 Eigen::Matrix<fvar<T>, R1, C1>
74 template<
typename T,
int R1,
int C1,
int R2,
int C2>
76 Eigen::Matrix<fvar<T>, R1, C2>
78 const Eigen::Matrix<
fvar<T>, R2, C2>& m2) {
82 Eigen::Matrix<fvar<T>, R1, C2> result(m1.rows(), m2.cols());
83 for (
size_type i = 0; i < m1.rows(); i++) {
84 Eigen::Matrix<fvar<T>, 1, C1> crow = m1.row(i);
85 for (
size_type j = 0; j < m2.cols(); j++) {
86 Eigen::Matrix<fvar<T>, R2, 1> ccol = m2.col(j);
93 template<
typename T,
int R1,
int C1,
int R2,
int C2>
95 Eigen::Matrix<fvar<T>, R1, C2>
97 const Eigen::Matrix<double, R2, C2>& m2) {
101 Eigen::Matrix<fvar<T>, R1, C2> result(m1.rows(), m2.cols());
102 for (
size_type i = 0; i < m1.rows(); i++) {
103 Eigen::Matrix<fvar<T>, 1, C1> crow = m1.row(i);
104 for (
size_type j = 0; j < m2.cols(); j++) {
105 Eigen::Matrix<double, R2, 1> ccol = m2.col(j);
112 template<
typename T,
int R1,
int C1,
int R2,
int C2>
114 Eigen::Matrix<fvar<T>, R1, C2>
116 const Eigen::Matrix<
fvar<T>, R2, C2>& m2) {
120 Eigen::Matrix<fvar<T>, R1, C2> result(m1.rows(), m2.cols());
121 for (
size_type i = 0; i < m1.rows(); i++) {
122 Eigen::Matrix<double, 1, C1> crow = m1.row(i);
123 for (
size_type j = 0; j < m2.cols(); j++) {
124 Eigen::Matrix<fvar<T>, R2, 1> ccol = m2.col(j);
131 template <
typename T,
int C1,
int R2>
135 const Eigen::Matrix<
fvar<T>, R2, 1>& v) {
136 if (rv.size() != v.size())
142 template <
typename T,
int C1,
int R2>
146 const Eigen::Matrix<double, R2, 1>& v) {
147 if (rv.size() != v.size())
153 template <
typename T,
int C1,
int R2>
157 const Eigen::Matrix<
fvar<T>, R2, 1>& v) {
158 if (rv.size() != v.size())
Eigen::Matrix< fvar< T >, R1, C1 > multiply(const Eigen::Matrix< fvar< T >, R1, C1 > &m, const fvar< T > &c)
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Type for sizes and indexes in an Eigen matrix with double e.
bool check_multiplicable(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Return true if the matrices can be multiplied.
fvar< T > dot_product(const Eigen::Matrix< fvar< T >, R1, C1 > &v1, const Eigen::Matrix< fvar< T >, R2, C2 > &v2)
void domain_error(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.