Skip to contents

Sum rows of x grouped by integer labels, dispatching to GPU when available.

Usage

segment_sum(x, labels, K)

Arguments

x

A numeric matrix or adgeMatrix.

labels

Integer vector of group labels (1-based).

K

Number of groups.

Value

A K-by-ncol(x) matrix of group sums.