Skip to content

Instantly share code, notes, and snippets.

View aormorningstar's full-sized avatar

Alan Morningstar aormorningstar

View GitHub Profile
@aormorningstar
aormorningstar / FloquetCircuits.jl
Last active February 17, 2021 23:54
Build the unitary matrix corresponding to one period of a periodic (Floquet) quantum circuit.
module FloquetCircuits
import Base: Matrix
using LinearAlgebra: I
using TensorOperations: tensorcontract
export Gate, FloquetCircuit, Matrix
"Quantum gate acting on some number of qubits."
struct Gate
@aormorningstar
aormorningstar / rotation.py
Last active January 12, 2024 21:24
Find the rotation matrix that aligns one three-dimensional vector with another.
import numpy as np
def rotation(v1, v2):
"""
Compute a matrix R that rotates v1 to align with v2.
v1 and v2 must be length-3 1d numpy arrays.
"""
# unit vectors
u = v1 / np.linalg.norm(v1)
Ru = v2 / np.linalg.norm(v2)