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

Implement spin_op::to_sparse_matrix(). #567

Merged
merged 4 commits into from
Aug 19, 2023
Merged

Conversation

amccaskey
Copy link
Collaborator

@amccaskey amccaskey commented Aug 18, 2023

Usage:

auto H = 5.907 - 2.1433 * x(0) * x(1) - 2.1433 * y(0) * y(1) + .21829 * z(0) -
         6.125 * z(1);
auto [values, rows, cols] = H.to_sparse_matrix();
hamiltonian = 5.907 - 2.1433 * spin.x(0) * spin.x(1) - 2.1433 * spin.y(
    0) * spin.y(1) + .21829 * spin.z(0) - 6.125 * spin.z(1)
numQubits = hamiltonian.get_qubit_count()
values, rows, cols = hamiltonian.to_sparse_matrix()

# can use scipy 
scipyM = scipy.sparse.csr_array((values, (rows, cols)), shape=(2**numQubits,2**numQubits))
energy, _ = scipy.sparse.linalg.eigsh(scipyM, k=1, which='SA')

@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Aug 18, 2023
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Aug 18, 2023
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Aug 18, 2023
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Aug 19, 2023
runtime/cudaq/spin_op.h Outdated Show resolved Hide resolved
Signed-off-by: Alex McCaskey <amccaskey@nvidia.com>
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

github-actions bot pushed a commit that referenced this pull request Aug 19, 2023
@amccaskey amccaskey merged commit 2f0c889 into NVIDIA:main Aug 19, 2023
101 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Aug 19, 2023
@amccaskey amccaskey deleted the sparse branch September 13, 2023 23:09
@bettinaheim bettinaheim added this to the release 0.4.1 milestone Sep 27, 2023
@bettinaheim bettinaheim added the release notes Changes need to be captured in the release notes label Sep 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release notes Changes need to be captured in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants