Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ zip_index() [2/2]

template<typename EigMat , typename IdxRows , typename IdxCols , require_eigen_matrix_dynamic_t< EigMat > * = nullptr, require_all_std_vector_t< IdxRows, IdxCols > * = nullptr>
var_value< Eigen::VectorXd > stan::math::zip_index ( const var_value< EigMat > &  x,
IdxRows &&  idx_row,
IdxCols &&  idx_col 
)
inline

Return a column vector of matrix entries selected by paired one-based row and column indices.

Repeated index pairs accumulate adjoints in the same input entry.

Template Parameters
EigMatEigen matrix type inside the input var_value
IdxRowsRow index std::vector type with integer elements
IdxColsColumn index std::vector type with integer elements
Parameters
xInput matrix
idx_rowRow indices
idx_colColumn indices
Returns
A var_value column vector with element i equal to x(idx_row[i] - 1, idx_col[i] - 1), or an empty vector for empty indices
Exceptions
std::invalid_argumentif the index vectors have different lengths
std::out_of_rangeif an index is outside the matrix bounds

Definition at line 32 of file zip_index.hpp.