1#ifndef STAN_MATH_FWD_FUN_MULTIPLY_HPP
2#define STAN_MATH_FWD_FUN_MULTIPLY_HPP
15template <
typename Mat1,
typename Mat2,
16 require_all_eigen_vt<is_fvar, Mat1, Mat2>* =
nullptr,
17 require_vt_same<Mat1, Mat2>* =
nullptr,
18 require_not_eigen_row_and_col_t<Mat1, Mat2>* =
nullptr>
19inline auto multiply(
const Mat1& m1,
const Mat2& m2) {
21 return (m1 * m2).eval();
24template <
typename Mat1,
typename Mat2,
28inline auto multiply(
const Mat1& m1,
const Mat2& m2) {
30 Eigen::Matrix<value_type_t<Mat1>, Mat1::RowsAtCompileTime,
31 Mat2::ColsAtCompileTime>
32 result(m1.rows(), m2.cols());
33 for (
size_type i = 0; i < m1.rows(); i++) {
34 Eigen::Matrix<value_type_t<Mat1>, 1, Mat1::ColsAtCompileTime> crow
36 for (
size_type j = 0; j < m2.cols(); j++) {
43template <
typename Mat1,
typename Mat2,
44 require_eigen_vt<std::is_floating_point, Mat1>* =
nullptr,
45 require_eigen_vt<is_fvar, Mat2>* =
nullptr,
46 require_not_eigen_row_and_col_t<Mat1, Mat2>* =
nullptr>
47inline auto multiply(
const Mat1& m1,
const Mat2& m2) {
49 Eigen::Matrix<value_type_t<Mat2>, Mat1::RowsAtCompileTime,
50 Mat2::ColsAtCompileTime>
51 result(m1.rows(), m2.cols());
52 for (
size_type i = 0; i < m1.rows(); i++) {
53 Eigen::Matrix<double, 1, Mat1::ColsAtCompileTime> crow = m1.row(i);
54 for (
size_type j = 0; j < m2.cols(); j++) {
55 auto ccol = m2.col(j);
require_t< container_type_check_base< is_eigen, value_type_t, TypeCheck, Check... > > require_eigen_vt
Require type satisfies is_eigen.
void check_multiplicable(const char *function, const char *name1, const T1 &y1, const char *name2, const T2 &y2)
Check if the matrices can be multiplied.
auto multiply(const Mat1 &m1, const Mat2 &m2)
Return the product of the specified matrices.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic >::Index size_type
Type for sizes and indexes in an Eigen matrix with double elements.
auto dot_product(const T_a &a, const T_b &b)
Returns the dot product of the specified vectors.
require_not_t< math::conjunction< is_eigen_row_vector< Row >, is_eigen_col_vector< Col > > > require_not_eigen_row_and_col_t
Require Row is not a row vector and Col is not a column vector.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...