Skip to content
This repository was archived by the owner on Nov 7, 2024. It is now read-only.
Merged
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
63cddc4
started implementing block-sparse tensors
mganahl Oct 22, 2019
2910b27
removed files
mganahl Oct 22, 2019
6dafdd7
Merge remote-tracking branch 'upstream/master' into block_sparse
mganahl Oct 24, 2019
46f1e10
working on AbelianIndex
mganahl Oct 25, 2019
9ba1d21
Merge remote-tracking branch 'upstream/master' into block_sparse
mganahl Nov 28, 2019
91f32a6
working in block sparisty
mganahl Nov 29, 2019
58feabc
added reshape
mganahl Nov 30, 2019
307f2dc
added Index, an index type for symmetric tensors
mganahl Nov 30, 2019
1ebbc7f
added small tutorial
mganahl Nov 30, 2019
1eb3d6f
added docstring
mganahl Nov 30, 2019
d25d8aa
fixed bug in retrieve_diagonal_blocks
mganahl Nov 30, 2019
ae8cda6
TODO added
mganahl Nov 30, 2019
bbac9c4
improved initialization a bit
mganahl Nov 30, 2019
db828c7
more efficient initialization
mganahl Dec 1, 2019
99204f7
just formatting
mganahl Dec 1, 2019
73a9628
added random
mganahl Dec 1, 2019
efa64a4
added fuse_degeneracies
mganahl Dec 1, 2019
7619162
fixed bug in reshape
mganahl Dec 1, 2019
2be30a9
dosctring, typing
mganahl Dec 1, 2019
742824f
removed TODO
mganahl Dec 1, 2019
2e6c395
removed confusing code line
mganahl Dec 1, 2019
ab13d4a
bug removed
mganahl Dec 1, 2019
d375b1d
comment
mganahl Dec 1, 2019
2727cd0
added __mul__ to Index
mganahl Dec 2, 2019
283e364
added sparse_shape
mganahl Dec 2, 2019
7328ad4
more in tutorial
mganahl Dec 2, 2019
e5b6147
comment
mganahl Dec 2, 2019
eb91c79
added new test function
mganahl Dec 2, 2019
a544dbc
testing function hacking
mganahl Dec 2, 2019
0457cca
docstring
mganahl Dec 2, 2019
95958a7
small speed up
mganahl Dec 3, 2019
ac3d980
Remove gui directory (migrated to another repo) (#399)
coryell Dec 3, 2019
5d2d2ba
a slightly more elegant code
mganahl Dec 7, 2019
04eadf3
use one more np function
mganahl Dec 7, 2019
2ea5674
removed some crazy slow code
mganahl Dec 7, 2019
5d8c86a
faster code
mganahl Dec 7, 2019
22a642e
Merge remote-tracking branch 'upstream/experimental_blocksparse' into…
mganahl Dec 7, 2019
4eae410
Update README.md (#404)
Dec 9, 2019
04c8573
add return_data
mganahl Dec 9, 2019
7c2d5a0
Merge remote-tracking branch 'upstream/experimental_blocksparse' into…
mganahl Dec 9, 2019
29bb154
Merge remote-tracking branch 'upstream/master' into block_sparse
mganahl Dec 9, 2019
33d1a40
doc
mganahl Dec 9, 2019
fb1978a
bug fix
mganahl Dec 9, 2019
5228f56
Merge remote-tracking branch 'upstream/experimental_blocksparse' into…
mganahl Dec 9, 2019
0d4a625
a little faster
mganahl Dec 11, 2019
82a4148
substantial speedup
mganahl Dec 11, 2019
7bd7be7
renaming
mganahl Dec 11, 2019
7a8c7df
Merge remote-tracking branch 'upstream/experimental_blocksparse' into…
mganahl Dec 11, 2019
d9c094b
removed todo
mganahl Dec 11, 2019
06c3f3c
some comments
mganahl Dec 11, 2019
426fd1a
comments
mganahl Dec 11, 2019
7f3e148
fixed some bug in reshape
mganahl Dec 11, 2019
19c3fe8
comments
mganahl Dec 11, 2019
5c8fd3e
default value changed
mganahl Dec 11, 2019
94c8c2c
fixed bug, old version is now faster again
mganahl Dec 12, 2019
7eec7f0
cleaned up reshape
mganahl Dec 12, 2019
c188ab9
started adding tests
mganahl Dec 12, 2019
d7ab7ab
Merge remote-tracking branch 'upstream/experimental_blocksparse' into…
mganahl Dec 12, 2019
d228f61
Merge remote-tracking branch 'upstream/experimental_blocksparse' into…
mganahl Dec 14, 2019
46aeec1
replace kron with broadcasting
mganahl Dec 14, 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
43 changes: 28 additions & 15 deletions tensornetwork/block_tensor/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,37 @@ def __init__(self,
name: Optional[Text] = None,
left_child: Optional["Index"] = None,
right_child: Optional["Index"] = None):
self.charges = np.asarray(charges)
self._charges = np.asarray(charges)
self.flow = flow
self.left_child = left_child
self.right_child = right_child
self.name = name if name else 'index'

@property
def is_leave(self):
return (self.left_child is None) and (self.right_child is None)

@property
def dimension(self):
return len(self.charges)
return np.prod([len(i.charges) for i in self.get_elementary_indices()])

def _copy_helper(self, index: "Index", copied_index: "Index") -> None:
"""
Helper function for copy
"""
if index.left_child != None:
left_copy = Index(
charges=index.left_child.charges.copy(),
charges=copy.copy(index.left_child.charges),
flow=copy.copy(index.left_child.flow),
name=index.left_child.name)
name=copy.copy(index.left_child.name))

copied_index.left_child = left_copy
self._copy_helper(index.left_child, left_copy)
if index.right_child != None:
right_copy = Index(
charges=index.right_child.charges.copy(),
charges=copy.copy(index.right_child.charges),
flow=copy.copy(index.right_child.flow),
name=index.right_child.name)
name=copy.copy(index.right_child.name))
copied_index.right_child = right_copy
self._copy_helper(index.right_child, right_copy)

Expand All @@ -72,7 +77,7 @@ def copy(self):
`Index` are copied as well.
"""
index_copy = Index(
charges=self.charges.copy(), flow=copy.copy(self.flow), name=self.name)
charges=self._charges.copy(), flow=copy.copy(self.flow), name=self.name)

self._copy_helper(self, index_copy)
return index_copy
Expand Down Expand Up @@ -100,10 +105,20 @@ def __mul__(self, index: "Index") -> "Index":
Merge `index` and self into a single larger index.
The flow of the resulting index is set to 1.
Flows of `self` and `index` are multiplied into
the charges upon fusing.
the charges upon fusing.n
"""
return fuse_index_pair(self, index)

@property
def charges(self):
if self.is_leave:
return self._charges
fused_charges = fuse_charges(self.left_child.charges, self.left_child.flow,
self.right_child.charges,
self.right_child.flow)

return fused_charges


def fuse_charges(q1: Union[List, np.ndarray], flow1: int,
q2: Union[List, np.ndarray], flow2: int) -> np.ndarray:
Expand Down Expand Up @@ -146,7 +161,8 @@ def fuse_degeneracies(degen1: Union[List, np.ndarray],
Returns:
np.ndarray: The result of fusing `q1` with `q2`.
"""
return np.kron(degen2, degen1)
return np.reshape(degen2[:, None] * degen1[None, :],
len(degen1) * len(degen2))


def fuse_index_pair(left_index: Index,
Expand All @@ -166,13 +182,10 @@ def fuse_index_pair(left_index: Index,
raise ValueError(
"index1 and index2 are the same object. Can only fuse distinct objects")

fused_charges = fuse_charges(left_index.charges, left_index.flow,
right_index.charges, right_index.flow)
# fused_charges = fuse_charges(left_index.charges, left_index.flow,
# right_index.charges, right_index.flow)
return Index(
charges=fused_charges,
flow=flow,
left_child=left_index,
right_child=right_index)
charges=None, flow=flow, left_child=left_index, right_child=right_index)


def fuse_indices(indices: List[Index], flow: Optional[int] = 1) -> Index:
Expand Down