pangolin.interface.extract_tril

Contents

pangolin.interface.extract_tril#

pangolin.interface.extract_tril(L)#

Extract the lower-triangular entries of a square matrix row by row.

This function creates no specialized Op; it lowers the operation to vectorized indexing in the ordinary Pangolin IR.

Parameters:

L (RVLike) – Square two-dimensional RV or array-like value with shape (N, N).

Returns:

entries – One-dimensional RV of length N * (N + 1) / 2.

Return type:

RV

Examples

>>> import pangolin.interface as pi
>>> L = pi.constant([[1.1,0],[2.2,3.3]])
>>> l = pi.extract_tril(L)
>>> l.shape
(3,)
>>> pi.print_upstream(l)
shape  | statement
------ | ---------
(2, 2) | a = [[1.1 0. ] [2.2 3.3]]
(3,)   | b = [0 1 1]
(3,)   | c = [0 0 1]
(3,)   | d = vmap(index, [None, 0, 0], 3)(a, b, c)