Skip to contents

Pure-C++ port of tma's apply_tensor(). Accepts 0-based index vectors for sender/receiver/mode dimensions and a pre-converted integer context lookup matrix.

Usage

apply_tensor(
  tensor,
  dims,
  dims_sender,
  dims_receiver,
  dims_mode,
  context_lookup,
  unit_rows,
  codes,
  times,
  ordered = TRUE,
  misses = FALSE
)

Arguments

tensor

Numeric vector (column-major flat tensor)

dims

Integer vector of tensor dimensions

dims_sender

0-based sender axis indices

dims_receiver

0-based receiver axis indices

dims_mode

0-based mode axis indices

context_lookup

Integer matrix (n_context_rows x n_factors), 0-based

unit_rows

0-based response-row indices for this unit

codes

Numeric matrix (n_context_rows x n_codes)

times

Numeric vector of timestamps per context row

ordered

TRUE = directed; FALSE = undirected

misses

TRUE = also return missed co-occurrences: ground code i present while response code j is absent (n_codes^2, ground i -> response j at j*n+i; no response self-term). Raw directed rows, like `row_connection_counts`; fold them with `finalize_row_connections()` / `aggregate_row_connections()` for unordered networks.

Value

List with `connection_counts` (vector) and `row_connection_counts` (matrix); with `misses = TRUE`, also `miss_counts` (vector) and `row_miss_counts` (matrix)