1#ifndef STAN_MATH_PRIM_FUN_CSR_MATRIX_TIMES_VECTOR_HPP
2#define STAN_MATH_PRIM_FUN_CSR_MATRIX_TIMES_VECTOR_HPP
72template <
typename T1,
typename T2,
73 require_all_not_rev_matrix_t<T1, T2>* =
nullptr>
74inline Eigen::Matrix<return_type_t<T1, T2>, Eigen::Dynamic, 1>
76 const std::vector<int>& u,
const T2& b) {
83 u[m - 1] +
csr_u_to_z(u, m - 1) - 1,
"v", v.size());
85 check_range(
"csr_matrix_times_vector",
"v[]", n, i);
87 std::vector<int> v_zero_based(v.size());
88 std::transform(v.begin(), v.end(), v_zero_based.begin(),
89 [](
auto&& x) { return x - 1; });
90 std::vector<int> u_zero_based(u.size());
91 std::transform(u.begin(), u.end(), u_zero_based.begin(),
92 [](
auto&& x) { return x - 1; });
95 Eigen::Map<const Eigen::SparseMatrix<scalar_type_t<T1>, Eigen::RowMajor>>
96 w_mat(m, n, w_ref.size(), u_zero_based.data(), v_zero_based.data(),
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
void check_positive(const char *function, const char *name, const T_y &y)
Check if y is positive.
void check_range(const char *function, const char *name, int max, int index, int nested_level, const char *error_msg)
Check if specified index is within range.
void check_size_match(const char *function, const char *name_i, T_size1 i, const char *name_j, T_size2 j)
Check if the provided sizes match.
Eigen::Matrix< return_type_t< T1, T2 >, Eigen::Dynamic, 1 > csr_matrix_times_vector(int m, int n, const T1 &w, const std::vector< int > &v, const std::vector< int > &u, const T2 &b)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...