Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
64ae004
add empty demo template
mariaschuld Jul 23, 2025
154533a
write intro
mariaschuld Jul 23, 2025
b5f094f
sketched the standard Fourier analysis example
mariaschuld Jul 23, 2025
27c0e69
Merge branch 'master' into resourcefulness_demo
mariaschuld Jul 24, 2025
340a6c5
polish first part, code runs now
mariaschuld Jul 24, 2025
5eb21a7
Merge branch 'resourcefulness_demo' of github.com:PennyLaneAI/qml int…
mariaschuld Jul 24, 2025
f894a3f
Merge branch 'master' into resourcefulness_demo
mariaschuld Jul 28, 2025
cc0ee9e
outline second part
mariaschuld Jul 29, 2025
6f8a54a
Merge branch 'master' into resourcefulness_demo
Alan-eMartin Aug 5, 2025
978cce5
migrate tutorial_resourcefulness to v2
Alan-eMartin Aug 5, 2025
d91f818
temp rm unverified categories
Alan-eMartin Aug 5, 2025
e212321
backup
mariaschuld Aug 6, 2025
d705faf
Merge branch 'master' of github.com:PennyLaneAI/qml into resourcefuln…
mariaschuld Aug 6, 2025
2e583f1
Merge branch 'resourcefulness_demo' of github.com:PennyLaneAI/qml int…
mariaschuld Aug 6, 2025
e68546f
backup
mariaschuld Aug 6, 2025
c80c69d
backup
mariaschuld Aug 6, 2025
e3f070d
backup
mariaschuld Aug 11, 2025
9809b15
backup
mariaschuld Aug 12, 2025
539b4fa
backup
mariaschuld Aug 13, 2025
509d04f
backup
mariaschuld Aug 13, 2025
3f484d1
first draft, plot not working
mariaschuld Aug 13, 2025
58335c0
trigger ci
mariaschuld Aug 13, 2025
12fc9fb
fixes from Paolo
mariaschuld Aug 19, 2025
2822442
fix conflicts
mariaschuld Aug 19, 2025
5d5287c
Merge branch 'master' into resourcefulness_demo
mariaschuld Aug 19, 2025
902b18f
fix argument
mariaschuld Aug 19, 2025
37b3c4d
fix argument
mariaschuld Aug 19, 2025
973dbae
fix more issues
mariaschuld Aug 19, 2025
06e1063
polish
mariaschuld Aug 20, 2025
713eb8a
add second author
mariaschuld Aug 20, 2025
1ceba91
Merge branch 'master' into resourcefulness_demo
mariaschuld Aug 20, 2025
5b56b9e
fix plot
mariaschuld Aug 20, 2025
d7a3680
Merge branch 'resourcefulness_demo' of github.com:PennyLaneAI/qml int…
mariaschuld Aug 20, 2025
5b78c3c
merge master
mariaschuld Aug 21, 2025
6d8d21c
minor changes
mariaschuld Aug 21, 2025
76f3dcf
polishing
mariaschuld Aug 28, 2025
4c4fc90
Merge branch 'master' into resourcefulness_demo
mariaschuld Sep 1, 2025
4bead7d
correct thumbnail name
mariaschuld Sep 1, 2025
8e9d5fb
Merge branch 'resourcefulness_demo' of github.com:PennyLaneAI/qml int…
mariaschuld Sep 1, 2025
364b7ba
add Tariks pics
mariaschuld Sep 8, 2025
15329c5
delete unused files
mariaschuld Sep 8, 2025
189622f
Merge branch 'master' into resourcefulness_demo
mariaschuld Sep 8, 2025
d28f703
minor change
mariaschuld Sep 16, 2025
5b17195
Merge branch 'master' into resourcefulness_demo
mariaschuld Sep 17, 2025
63e8850
polish
mariaschuld Sep 17, 2025
eb27ffd
Merge branch 'resourcefulness_demo' of github.com:PennyLaneAI/qml int…
mariaschuld Sep 17, 2025
9767bac
fix sphinx issue
mariaschuld Sep 17, 2025
36e6989
minor fixes
mariaschuld Sep 17, 2025
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
751 changes: 751 additions & 0 deletions demonstrations_v2/tutorial_resourcefulness/demo.py

Large diffs are not rendered by default.

55 changes: 55 additions & 0 deletions demonstrations_v2/tutorial_resourcefulness/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"title": "Resourcefulness of quantum states with Fourier analysis",
"authors": [
{
"username": "impolster"
},
{
"username": "mariaschuld"
}
],
"executable_stable": true,
"executable_latest": true,
"dateOfPublication": "2025-08-05T09:00:00+00:00",
"dateOfLastModification": "2025-08-05T09:00:00+00:00",
"categories": [
"Quantum Computing"
],
"tags": [],
"previewImages": [
{
"type": "thumbnail",
"uri": "/_static/demo_thumbnails/regular_demo_thumbnails/pennylane-demo-resourcefulness-thumbnail.png"
},
{
"type": "large_thumbnail",
"uri": "/_static/demo_thumbnails/large_demo_thumbnails/pennylane-demo-resourcefulness-large-thumbnail.png"
}
],
"seoDescription": "Find out how entangled a state is by looking at its generalised Fourier spectrum.",
"doi": "",
"references": [
{
"id": "Bermejo_Braccia",
"type": "preprint",
"title": "Characterizing quantum resourcefulness via group-Fourier decompositions",
"authors": "Pablo Bermejo, Paolo Braccia, Antonio Anna Mele, N. L. Diaz, Andrew E. Deneris, Martín Larocca, Marco Cerezo",
"year": "2025",
"url": "https://arxiv.org/pdf/2506.19696"
}
],
"basedOnPapers": ["10.48550/arXiv.2506.19696"],
"referencedByPapers": [],
"relatedContent": [
{
"type": "demonstration",
"id": "tutorial_resourcefulness",
"weight": 1.0
},
{
"type": "demonstration",
"id": "tutorial_resourcefulness_with_fourier_transform",
"weight": 1.0
}
]
}
66 changes: 66 additions & 0 deletions demonstrations_v2/tutorial_resourcefulness/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""
Utility function that sorts a block-diagonal matrix for visualisation purposes.
"""

import numpy as np
from collections import OrderedDict

def group_rows_cols_by_sparsity(B, tol=0):
"""
Given matrix B, this function groups identical rows and columns, orders these groups
by sparsity (most zeros first) and returns the row & column permutation
matrices P_row, P_col such that B2 = P_row @ B @ P_col is block-diagonal.
"""
# compute boolean mask where |B| >= tol
mask = np.abs(B) >= 1e-8
# convert boolean mask to integer (False→0, True→1)
C = mask.astype(int)

# order by sparsity
n, m = C.shape

# helper to get a key tuple and zero count for a vector
def key_and_zeros(vec):
if tol > 0:
bin_vec = (np.abs(vec) < tol).astype(int)
key = tuple(bin_vec)
zero_count = int(np.sum(bin_vec))
else:
key = tuple(vec.tolist())
zero_count = int(np.sum(np.array(vec) == 0))
return key, zero_count

# group rows by key
row_groups = OrderedDict()
row_zero_counts = {}
for i in range(n):
key, zc = key_and_zeros(C[i, :])
row_groups.setdefault(key, []).append(i)
row_zero_counts[key] = zc

# sort row groups by zero_count descending
sorted_row_keys = sorted(row_groups.keys(),
key=lambda k: row_zero_counts[k],
reverse=True)
# flatten row permutation
row_perm = [i for key in sorted_row_keys for i in row_groups[key]]

# group columns by key
col_groups = OrderedDict()
col_zero_counts = {}
for j in range(m):
key, zc = key_and_zeros(C[:, j])
col_groups.setdefault(key, []).append(j)
col_zero_counts[key] = zc

# sort column groups by zero_count descending
sorted_col_keys = sorted(col_groups.keys(),
key=lambda k: col_zero_counts[k],
reverse=True)
col_perm = [j for key in sorted_col_keys for j in col_groups[key]]

# build permutation matrices
P_row = np.eye(n)[row_perm, :]
P_col = np.eye(m)[:, col_perm]

return P_row, P_col