1#ifndef STAN_MATH_PRIM_FUN_CSR_EXTRACT_HPP
2#define STAN_MATH_PRIM_FUN_CSR_EXTRACT_HPP
23const std::tuple<Eigen::Matrix<T, Eigen::Dynamic, 1>, std::vector<int>,
25csr_extract(
const Eigen::SparseMatrix<T, Eigen::RowMajor>& A) {
26 auto a_nonzeros = A.nonZeros();
27 Eigen::Matrix<T, Eigen::Dynamic, 1> w
28 = Eigen::Matrix<T, Eigen::Dynamic, 1>::Zero(a_nonzeros);
29 std::vector<int> v(a_nonzeros);
30 for (
int nze = 0; nze < a_nonzeros; ++nze) {
31 w[nze] = *(A.valuePtr() + nze);
34 std::vector<int> u(A.outerSize() + 1);
35 for (
int nze = 0; nze <= A.outerSize(); ++nze) {
38 return std::make_tuple(std::move(w), std::move(v), std::move(u));
51template <
typename T, require_eigen_dense_base_t<T>* =
nullptr>
52const std::tuple<Eigen::Matrix<scalar_type_t<T>, Eigen::Dynamic, 1>,
53 std::vector<int>, std::vector<int>>
56 Eigen::SparseMatrix<scalar_type_t<T>, Eigen::RowMajor> B
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...