google / TensorNetwork

A library for easy and efficient manipulation of tensor networks.
Apache License 2.0
1.8k stars 355 forks source link

tn.connect should check if tensor-legs are compatible for symmetric backend #518

Open mganahl opened 4 years ago

mganahl commented 4 years ago

For block-sparse tensors, an identical dense shape of two legs is not sufficient for their contraction. Flows and charges have to match as well. tn.connect is currently not checking this. An error is eventually raised upon contraction, but we could detect it earlier already when connecting two legs

chaserileyroberts commented 4 years ago

Yeah, we could add a is_connectable method to the backends. So BaseBackend would always return True/check the dimensions, and then your could do specific checks for the symmetric backend.