google / TensorNetwork

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

Make Node a subclass of Tensor? #858

Open repst opened 3 years ago

repst commented 3 years ago

Having not followed the recent PRs, our group became aware of the new Tensor class with the release of 0.4.2. We found that tensornetwork.ncon, tensornetwork.conj and tensornetwork.node now take Tensor objects and throw errors when passed Node objects. If Node inherited from Tensor they could share such functionality. I think of a node as a tensor with extra ability to connect to other nodes.

What do you think of this solution rather than wrapping Node around Tensor as discussed in #848?

mganahl commented 3 years ago

Hi Ryan, great suggestion! I think that would make sense. @Thenerdstation @alewis, what are your thoughts?

alewis commented 3 years ago

It seems fine to me. I don't know how Node works well enough to decide how hard it would be.

On Tue, Oct 27, 2020 at 3:15 AM Martin Ganahl notifications@github.com wrote:

Hi Ryan, great suggestion! I think that would make sense. @Thenerdstation https://github.com/Thenerdstation @alewis https://github.com/alewis, what are your thoughts?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/google/TensorNetwork/issues/858#issuecomment-717040016, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAINHBUYOISOGBOZQJ3NYODSMZXRXANCNFSM4S77AMAA .

mganahl commented 3 years ago

Hey @repst to give you some perspective: we added Tensor specifically for use in traditional tensor network calculations where the Node API becomes cumbersome to use. We are currently working to move the DMRG implementation towards a consistent use of Tensor.

alewis commented 3 years ago

Nevertheless, it would be a nice simplification to the interface if all the tn. functions worked on Node

On Tue, Oct 27, 2020 at 11:02 AM Martin Ganahl notifications@github.com wrote:

Hey @repst https://github.com/repst to give you some perspective: we added Tensor specifically for use in traditional tensor network calculations where the Node API becomes cumbersome to use. We are currently working to move the DMRG implementation towards a consistent use of Tensor.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/google/TensorNetwork/issues/858#issuecomment-717305882, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAINHBRAG56SVAWNEQTTVKDSM3OIRANCNFSM4S77AMAA .

chaserileyroberts commented 3 years ago

Yeah, as long as all of the nodes created by these methods always return with dangling legs, i think that would be fine.