ensign.cp_decomp.reconstruct_into

reconstruct_into(decomp, tensor, comp_ids=None, orig_entries=False)[source]

Reconstructs a CP decomposition ‘into’ a sparse tensor.

Reconstructs a tensor from a decomposition decomp by computing and summing selected outer products. If a list of component IDs is given in comp_ids then only components in this list will contribute to the reconstruction. Only nonzero indices of tensor are included in the reconstructed tensor.

Parameters
decompCPDecomp

Decompostion to reconstruct using sum-of-outer-products.

tensorSPTensor

The sparse tensor that contains the nonzero entries to reconstruct into.

comp_idslist, optional

A list of components to reconstruct the SPTensor from. If None (default), all components are used.

orig_entriesbool, optional

This parameter controls the value of entries in the reconstructed tensor. When True, nonzero values in the sum-of-outer-products reconstruction are given the same value as tensor regardless of reconstructed value. When False (default) nonzero values are given the value produced by the sum-of-outer-products reconstruction.

Returns
reconstructed_sptSPTensor

The sparse tensor produced by reconstructing selected components of decomp into nonzero values of tensor.