Stan Math Library
4.9.0
Automatic Differentiation
|
|
inline |
Index a kernel generator expression using two expressions for indices.
The result is a matrix of the same size as index matrices and with same scalar type as indexed expression. indexing(mat, col_index, row_index)[i,j] = mat[col_index[i,j], row_index[i,j]]
If a matrix is both indexed and the result of the kernel (such as in indexing(a, b, c) = indexing(a, d, e);
), the result can be wrong due to aliasing. In this case the expression should be evaluated in a temporary by doing indexing(a, b, c) = indexing(a, d, e).eval();
. This is not necessary if both indexings use the same indices or index no common elements of the matrix.
If indexing is assigned to and some element is indexed multiple times it can end with either of the assigned values due to a data race.
T_mat | type of indexed expression |
T_row_index | type of row index |
T_col_index | type of column index |
Definition at line 304 of file indexing.hpp.