Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.

Quantum abstractions #379

Merged
merged 49 commits into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
2eac0ca
Initial attempt at quantum classes.
amilsted Nov 5, 2019
8fdb613
.tensor() and QuantumIdentity.
amilsted Nov 5, 2019
164a859
check_hilberts -> check_spaces
amilsted Nov 6, 2019
04d6fc3
Add some blurb.
amilsted Nov 7, 2019
d8a7eec
Rename to Qu.
amilsted Nov 7, 2019
76d682b
Finish Qu.
amilsted Nov 7, 2019
52ac9e1
Fix matmul in case operators share network components.
amilsted Nov 7, 2019
6deb648
Add some scalar methods.
amilsted Nov 7, 2019
f020c48
Improve a docstring.
amilsted Nov 7, 2019
d121a5f
Redo scalars and make identity work using copy tensors.
amilsted Nov 8, 2019
c47aef6
Remove obsolete parts of QuScalar.
amilsted Nov 8, 2019
68cf9ad
Add contraction stuff.
amilsted Nov 8, 2019
3dac3b0
Add from_tensor() constructors.
amilsted Nov 8, 2019
93f459c
Doctstring.
amilsted Nov 8, 2019
ecded14
Doc/comments fixes.
amilsted Nov 8, 2019
8841d60
Add typing.
amilsted Nov 8, 2019
4b53b1a
Remove some lint.
amilsted Nov 8, 2019
2960424
Fix a bug.
amilsted Nov 8, 2019
05c2aff
Add very simple constructor tests.
amilsted Nov 8, 2019
ad136c3
Merge branch 'master' of github.com:google/TensorNetwork into quantum
amilsted Nov 8, 2019
ac0429d
Default edge ordering for eval(). Better docstrings.
amilsted Nov 9, 2019
d029277
A bunch more tests.
amilsted Nov 9, 2019
ade0005
Merge branch 'master' into quantum
Nov 13, 2019
e83ecce
Merge branch 'master' into quantum
Nov 14, 2019
8d8bb8c
tensor_prod -> tensor_product, outer_product
amilsted Nov 15, 2019
53c142b
.is_scalar -> is_scalar() etc.
amilsted Nov 19, 2019
fc0de02
Merge branch 'quantum' of github.com:amilsted/TensorNetwork into quantum
amilsted Nov 19, 2019
f7e70fd
Improve docstrings on axis ordering.
amilsted Nov 19, 2019
c349667
Improve and fix scalar multiplication.
amilsted Nov 19, 2019
bf99930
Kill outer_product().
amilsted Nov 19, 2019
254ded8
CopyNode needs a backend and dtype.
amilsted Nov 20, 2019
d87e9d1
Fix __mul__ and add __rmul__.
amilsted Nov 20, 2019
f457bc9
More docstrings and add axis arguments to vector from_tensor()s.
amilsted Nov 20, 2019
5af882c
Add backends to tests.
amilsted Nov 20, 2019
b96f3bf
Merge branch 'master' into quantum
Nov 20, 2019
6d1496f
Delint.
amilsted Nov 21, 2019
53379f6
Merge branch 'quantum' of github.com:amilsted/TensorNetwork into quantum
amilsted Nov 21, 2019
ea38c38
Merge branch 'master' into quantum
amilsted Nov 25, 2019
4973ec8
Merge branch 'master' into quantum
Nov 26, 2019
327e41e
Merge branch 'master' into quantum
amilsted Dec 11, 2019
4c54a68
CopyNode should not inflate its tensor just to tell you the dtype.
amilsted Dec 12, 2019
eb99692
Correct two docstrings.
amilsted Dec 12, 2019
5ff4a66
Improve some tests.
amilsted Dec 12, 2019
00c88c0
Treat CopyNode identity tensors efficiently.
amilsted Dec 12, 2019
8e8b9a8
Merge branch 'quantum' of github.com:amilsted/TensorNetwork into quantum
amilsted Dec 12, 2019
fb46456
Add support for copying CopyNodes.
amilsted Dec 12, 2019
f463005
Propagate output edges properly.
amilsted Dec 12, 2019
7ef2ba3
Test that CopyNodes are propagated.
amilsted Dec 12, 2019
cb9189c
Improve typing.
amilsted Dec 12, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tensornetwork/network_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,11 @@ def __init__(self,
backend=backend_obj,
shape=(dimension,) * rank)

@property
def dtype(self):
# Override so we don't construct the dense tensor when asked for the dtype!
return self.copy_node_dtype

def get_tensor(self) -> Tensor:
return self.tensor

Expand Down
33 changes: 18 additions & 15 deletions tensornetwork/network_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,23 +125,29 @@ def copy(nodes: Iterable[BaseNode],
node_dict: A dictionary mapping the nodes to their copies.
edge_dict: A dictionary mapping the edges to their copies.
"""
#TODO: add support for copying CopyTensor
if conjugate:
node_dict = {
node: Node(
node_dict = {}
for node in nodes:
if isinstance(node, CopyNode):
node_dict[node] = CopyNode(
node.rank,
node.dimension,
name=node.name,
axis_names=node.axis_names,
backend=node.backend,
dtype=node.dtype)
else:
if conjugate:
node_dict[node] = Node(
node.backend.conj(node.tensor),
name=node.name,
axis_names=node.axis_names,
backend=node.backend) for node in nodes
}
else:
node_dict = {
node: Node(
backend=node.backend)
else:
node_dict[node] = Node(
node.tensor,
name=node.name,
axis_names=node.axis_names,
backend=node.backend) for node in nodes
}
backend=node.backend)
edge_dict = {}
for edge in get_all_edges(nodes):
node1 = edge.node1
Expand Down Expand Up @@ -184,9 +190,6 @@ def remove_node(node: BaseNode) -> Tuple[Dict[Text, Edge], Dict[int, Edge]]:
the newly broken edges.
disconnected_edges_by_axis: A Dictionary mapping `node`'s axis numbers
to the newly broken edges.

Raises:
ValueError: If the node isn't in the network.
"""
disconnected_edges_by_name = {}
disconnected_edges_by_axis = {}
Expand Down Expand Up @@ -607,7 +610,7 @@ def reachable(inputs: Union[BaseNode, Iterable[BaseNode], Edge, Iterable[Edge]]
Args:
inputs: A `BaseNode`/`Edge` or collection of `BaseNodes`/`Edges`
Returns:
A list of `BaseNode` objects that can be reached from `node`
A set of `BaseNode` objects that can be reached from `node`
via connected edges.
Raises:
ValueError: If an unknown value for `strategy` is passed.
Expand Down
Loading