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

◆ diag_inv()

__kernel void stan::math::opencl_kernels::diag_inv ( __global double *  A,
__global double *  tmp_inv,
int  rows 
)

Calculates inplace submatrix inversions along the matrix diagonal.

For a full guide to the inverse lower triangular kernels see the link here. In the special case that the thread block size is larger than the input matrix A then this kernel will perform the complete lower triangular of matrix A. More often, TB is smaller than A and A will have lower triangular inverses calculated on submatrices along the diagonal equal to the size of the thread block. Running this kernel on a matrix with N = 4

  • thread_block will yield a lower triangular matrix with identity matrices in blue as shown below. Identity matrices in the blue triangles

This kernel is run with threads organized in a single dimension. If we want to calculate N blocks of size TB across the diagonal we spawn N x TB threads with TB used as the thread block size.

Parameters
[in,out]AThe input matrix.
[in,out]tmp_invA matrix with batches of identities matrices along the diagonal.
rowsThe number of rows for A.
Note
Code is a const char* held in diag_inv_kernel_code. Used in math/opencl/tri_inverse.hpp. This kernel uses the helper macros available in helpers.cl.

Definition at line 43 of file diag_inv.hpp.