warp.sparse.bsr_set_from_triplets#

warp.sparse.bsr_set_from_triplets(
dest,
rows,
columns,
values=None,
count=None,
prune_numerical_zeros=True,
topology=None,
build_mapping=None,
)[source]#

Fill a BSR matrix with values defined by coordinate-oriented (COO) triplets, discarding existing blocks.

The first dimension of the three input arrays must match and indicates the number of COO triplets.

Parameters:
  • dest (BsrMatrix[BlockType[Rows, Cols, Scalar]]) – Sparse matrix to populate.

  • rows (Array[int]) – Row index for each non-zero.

  • columns (Array[int]) – Columns index for each non-zero.

  • values (Array[Scalar | BlockType[Rows, Cols, Scalar]] | None) – Block values for each non-zero. Must be contiguous and either a one-dimensional array with data type identical to the dest matrix’s block type, or a 3d array with data type equal to the dest matrix’s scalar type. If None, the values array of the resulting matrix will be allocated but uninitialized.

  • count (Array[int] | None) – Single-element array indicating the number of triplets. If None, the number of triplets is determined from the shape of rows and columns arrays.

  • prune_numerical_zeros (bool) – If True, will ignore the zero-valued blocks.

  • topology (Literal['compact', 'masked', 'padded'] | None) – Optional topology policy. "compact" keeps the existing compact rebuild behavior, "masked" updates only existing non-zero blocks of dest, and "padded" writes the compacted triplet topology into existing destination row capacity and records capacity overflow in dest.status_sync().

  • build_mapping (BsrTripletMap | bool | None) – If True, build and return a new reusable mapping from the input entries to the compact destination blocks, see BsrTripletMap. If a BsrTripletMap, rebuild that mapping in place, reusing its storage, and return it. This is only supported for topology="compact" and requires prune_numerical_zeros=False.

Returns:

The built BsrTripletMap when build_mapping is provided; otherwise None.

Return type:

BsrTripletMap | None