1 #ifndef STAN_MATH_PRIM_FUN_COL_HPP 2 #define STAN_MATH_PRIM_FUN_COL_HPP 3 4 #include <stan/math/prim/err.hpp> 5 #include <stan/math/prim/fun/Eigen.hpp> 6 7 namespace stan { 8 namespace math { 9 10 /** 11 * Return the specified column of the specified matrix 12 * using start-at-1 indexing. 13 * 14 * This is equivalent to calling <code>m.col(i - 1)</code> and 15 * assigning the resulting template expression to a column vector. 16 * 17 * @tparam T type of the matrix 18 * @param m Matrix. 19 * @param j Column index (count from 1). 20 * @return Specified column of the matrix. 21 * @throw std::out_of_range if j is out of range. 22 */ 23 template <typename T, require_matrix_t<T>* = nullptr> col(const T & m,size_t j)24inline auto col(const T& m, size_t j) { 25 check_column_index("col", "j", m, j); 26 return m.col(j - 1); 27 } 28 29 } // namespace math 30 } // namespace stan 31 32 #endif 33