Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up kronecker product #70

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from typing import Dict, Sequence, Union, Tuple, List, Optional, Any


import numpy as np
from nptyping import NDArray
from qiskit import QuantumCircuit
from qiskit.circuit import Qubit
Expand Down Expand Up @@ -371,9 +370,16 @@ def naive_compute(
if summation_term_prob is None:
summation_term_prob = subcircuit_entry_prob
else:
summation_term_prob = np.kron(
summation_term_prob, subcircuit_entry_prob
)
summation_term_prob = (
summation_term_prob[
:,
None,
]
* subcircuit_entry_prob[
None,
:,
]
).reshape(summation_term_prob.size * subcircuit_entry_prob.size)
overhead["multiplications"] += len(summation_term_prob)
if reconstructed_prob is None:
reconstructed_prob = summation_term_prob
Expand Down