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>
18 template<
typename T,
int R1,
int C1>
20 Eigen::Matrix<fvar<T>, R1, C1>
22 Eigen::Matrix<fvar<T>, R1, C1> res(m.rows(), m.cols());
23 for (
int i = 0; i < m.rows(); i++) {
24 for (
int j = 0; j < m.cols(); j++)
25 res(i, j) = c * m(i, j);
30 template<
typename T,
int R2,
int C2>
32 Eigen::Matrix<fvar<T>, R2, C2>
34 Eigen::Matrix<fvar<T>, R2, C2> res(m.rows(), m.cols());
35 for (
int i = 0; i < m.rows(); i++) {
36 for (
int j = 0; j < m.cols(); j++)
37 res(i, j) = c * m(i, j);
42 template<
typename T,
int R1,
int C1>
44 Eigen::Matrix<fvar<T>, R1, C1>
46 Eigen::Matrix<fvar<T>, R1, C1> res(m.rows(), m.cols());
47 for (
int i = 0; i < m.rows(); i++) {
48 for (
int j = 0; j < m.cols(); j++)
49 res(i, j) = c * m(i, j);
54 template<
typename T,
int R1,
int C1>
56 Eigen::Matrix<fvar<T>, R1, C1>
61 template<
typename T,
int R1,
int C1>
63 Eigen::Matrix<fvar<T>, R1, C1>
68 template<
typename T,
int R1,
int C1>
70 Eigen::Matrix<fvar<T>, R1, C1>
75 template<
typename T,
int R1,
int C1,
int R2,
int C2>
77 Eigen::Matrix<fvar<T>, R1, C2>
79 const Eigen::Matrix<
fvar<T>, R2, C2>& m2) {
83 Eigen::Matrix<fvar<T>, R1, C2> result(m1.rows(), m2.cols());
84 for (
size_type i = 0; i < m1.rows(); i++) {
85 Eigen::Matrix<fvar<T>, 1, C1> crow = m1.row(i);
86 for (
size_type j = 0; j < m2.cols(); j++) {
87 Eigen::Matrix<fvar<T>, R2, 1> ccol = m2.col(j);
94 template<
typename T,
int R1,
int C1,
int R2,
int C2>
96 Eigen::Matrix<fvar<T>, R1, C2>
98 const Eigen::Matrix<double, R2, C2>& m2) {
102 Eigen::Matrix<fvar<T>, R1, C2> result(m1.rows(), m2.cols());
103 for (
size_type i = 0; i < m1.rows(); i++) {
104 Eigen::Matrix<fvar<T>, 1, C1> crow = m1.row(i);
105 for (
size_type j = 0; j < m2.cols(); j++) {
106 Eigen::Matrix<double, R2, 1> ccol = m2.col(j);
113 template<
typename T,
int R1,
int C1,
int R2,
int C2>
115 Eigen::Matrix<fvar<T>, R1, C2>
117 const Eigen::Matrix<
fvar<T>, R2, C2>& m2) {
121 Eigen::Matrix<fvar<T>, R1, C2> result(m1.rows(), m2.cols());
122 for (
size_type i = 0; i < m1.rows(); i++) {
123 Eigen::Matrix<double, 1, C1> crow = m1.row(i);
124 for (
size_type j = 0; j < m2.cols(); j++) {
125 Eigen::Matrix<fvar<T>, R2, 1> ccol = m2.col(j);
132 template <
typename T,
int C1,
int R2>
136 const Eigen::Matrix<
fvar<T>, R2, 1>& v) {
137 if (rv.size() != v.size())
143 template <
typename T,
int C1,
int R2>
147 const Eigen::Matrix<double, R2, 1>& v) {
148 if (rv.size() != v.size())
154 template <
typename T,
int C1,
int R2>
158 const Eigen::Matrix<
fvar<T>, R2, 1>& v) {
159 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.